idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,900 | protected function _validateIPv4 ( $ value ) { $ ip2long = ip2long ( $ value ) ; if ( $ ip2long === false ) { return false ; } return $ value == long2ip ( $ ip2long ) ; } | Validates an IPv4 address |
23,901 | protected function _validateIPv6 ( $ value ) { if ( strlen ( $ value ) < 3 ) { return $ value == '::' ; } if ( strpos ( $ value , '.' ) ) { $ lastcolon = strrpos ( $ value , ':' ) ; if ( ! ( $ lastcolon && $ this -> _validateIPv4 ( substr ( $ value , $ lastcolon + 1 ) ) ) ) { return false ; } $ value = substr ( $ value... | Validates an IPv6 address |
23,902 | public static function factory ( $ name , $ filename ) { switch ( $ name ) { case 'ZipArchive' : if ( class_exists ( 'ZipArchive' , false ) ) { return new ZipArchive ( $ filename ) ; } break ; case 'tar.gz' : return new Tar ( $ filename , 'gz' ) ; case 'tar.bz2' : return new Tar ( $ filename , 'bz2' ) ; case 'gz' : if ... | Factory method to create an unarchiver |
23,903 | public function setPassword ( $ password ) { if ( empty ( $ password ) ) { $ this -> hashedPassword = null ; } else { $ this -> hashedPassword = UsersManager :: getPasswordHash ( $ password ) ; } } | Sets the password to authenticate with . |
23,904 | public function setPasswordHash ( $ passwordHash ) { if ( $ passwordHash === null ) { $ this -> hashedPassword = null ; return ; } UsersManager :: checkPasswordHash ( $ passwordHash , Piwik :: translate ( 'Login_ExceptionPasswordMD5HashExpected' ) ) ; $ this -> hashedPassword = $ passwordHash ; } | Sets the password hash to use when authentication . |
23,905 | public static function getInstance ( ) { $ class = get_called_class ( ) ; if ( ! isset ( self :: $ instances [ $ class ] ) ) { $ container = StaticContainer :: getContainer ( ) ; $ refl = new \ ReflectionClass ( $ class ) ; if ( ! $ refl -> getConstructor ( ) || $ refl -> getConstructor ( ) -> isPublic ( ) ) { self :: ... | Returns the singleton instance for the derived class . If the singleton instance has not been created this method will create it . |
23,906 | protected function _getFileData ( $ id , $ field = null ) { if ( ! isset ( $ this -> _files [ $ id - 1 ] ) ) { throw new Zend_Mail_Storage_Exception ( 'id does not exist' ) ; } if ( ! $ field ) { return $ this -> _files [ $ id - 1 ] ; } if ( ! isset ( $ this -> _files [ $ id - 1 ] [ $ field ] ) ) { throw new Zend_Mail_... | Get one or all fields from file structure . Also checks if message is valid |
23,907 | protected function _isMaildir ( $ dirname ) { if ( file_exists ( $ dirname . '/new' ) && ! is_dir ( $ dirname . '/new' ) ) { return false ; } if ( file_exists ( $ dirname . '/tmp' ) && ! is_dir ( $ dirname . '/tmp' ) ) { return false ; } return is_dir ( $ dirname . '/cur' ) ; } | check if a given dir is a valid maildir |
23,908 | protected function _openMaildir ( $ dirname ) { if ( $ this -> _files ) { $ this -> close ( ) ; } $ dh = @ opendir ( $ dirname . '/cur/' ) ; if ( ! $ dh ) { throw new Zend_Mail_Storage_Exception ( 'cannot open maildir' ) ; } $ this -> _getMaildirFiles ( $ dh , $ dirname . '/cur/' ) ; closedir ( $ dh ) ; $ dh = @ opendi... | open given dir as current maildir |
23,909 | protected function _getMaildirFiles ( $ dh , $ dirname , $ default_flags = array ( ) ) { while ( ( $ entry = readdir ( $ dh ) ) !== false ) { if ( $ entry [ 0 ] == '.' || ! is_file ( $ dirname . $ entry ) ) { continue ; } @ list ( $ uniq , $ info ) = explode ( ':' , $ entry , 2 ) ; @ list ( , $ size ) = explode ( ',' ,... | find all files in opened dir handle and add to maildir files |
23,910 | private function runExclusive ( $ closure ) { $ process = new Process ( 'archive.sharedsiteids' ) ; while ( $ process -> isRunning ( ) && $ process -> getSecondsSinceCreation ( ) < 5 ) { usleep ( 25 * 1000 ) ; } $ process -> startProcess ( ) ; try { $ result = $ closure ( ) ; } catch ( Exception $ e ) { $ process -> fi... | If there are multiple archiver running on the same node it makes sure only one of them performs an action and it will wait until another one has finished . Any closure you pass here should be very fast as other processes wait for this closure to finish otherwise . Currently only used for making multiple archivers at th... |
23,911 | public function getNextSiteId ( ) { if ( $ this -> done ) { return null ; } $ self = $ this ; $ this -> currentSiteId = $ this -> runExclusive ( function ( ) use ( $ self ) { $ siteIds = $ self -> getAllSiteIdsToArchive ( ) ; if ( empty ( $ siteIds ) ) { return null ; } if ( count ( $ siteIds ) > $ self -> numWebsitesL... | Get the next site id that needs to be processed or null if all site ids where processed . |
23,912 | public function initSession ( AuthInterface $ auth ) { $ this -> regenerateSessionId ( ) ; $ authResult = $ this -> doAuthenticateSession ( $ auth ) ; if ( ! $ authResult -> wasAuthenticationSuccessful ( ) ) { Piwik :: postEvent ( 'Login.authenticate.failed' , array ( $ auth -> getLogin ( ) ) ) ; $ this -> processFaile... | Authenticates the user and if successful initializes an authenticated session . |
23,913 | public function addType ( $ type ) { if ( is_string ( $ type ) ) { $ type = array ( $ type ) ; } foreach ( $ type as $ typ ) { if ( defined ( 'self::' . strtoupper ( $ typ ) ) && ! in_array ( $ typ , $ this -> _type ) ) { $ this -> _type [ ] = $ typ ; } if ( ( $ typ == self :: ALL ) ) { $ this -> _type = array_keys ( $... | Adds a CCI to be accepted by validation |
23,914 | public function getMigrations ( Updater $ updater ) { $ migration1 = $ this -> migration -> db -> changeColumnType ( 'log_visit' , 'example' , 'BOOLEAN NOT NULL' ) ; $ migration2 = $ this -> migration -> db -> sql ( $ sqlQuery = 'SELECT 1' ) ; return array ( ) ; } | Return database migrations to be executed in this update . |
23,915 | public function getMigrations ( Updater $ updater ) { $ visitMigrations = $ this -> getMigrationsThatRemoveOptionEntriesOfNotActuallyInstalledColumns ( VisitDimension :: INSTALLER_PREFIX , 'log_visit' ) ; $ actionMigrations = $ this -> getMigrationsThatRemoveOptionEntriesOfNotActuallyInstalledColumns ( ActionDimension ... | Removes option entries for columns that are marked as installed but are actually no longer installed due to a bug in previous versions where the option entries were not correctly removed . |
23,916 | protected function aggregateUsers ( ) { $ userIdFieldName = self :: USER_ID_FIELD ; $ visitorIdFieldName = self :: VISITOR_ID_FIELD ; $ query = $ this -> getLogAggregator ( ) -> queryVisitsByDimension ( array ( self :: USER_ID_FIELD ) , "log_visit.$userIdFieldName IS NOT NULL AND log_visit.$userIdFieldName != ''" , arr... | Used to aggregate daily data per user ID |
23,917 | protected function insertDayReports ( ) { $ dataTable = $ this -> arrays -> asDataTable ( ) ; $ this -> setVisitorIds ( $ dataTable ) ; $ report = $ dataTable -> getSerialized ( $ this -> maximumRowsInDataTableLevelZero , null , Metrics :: INDEX_NB_VISITS ) ; $ this -> getProcessor ( ) -> insertBlobRecord ( self :: USE... | Insert aggregated daily data serialized |
23,918 | private function rememberVisitorId ( $ row ) { if ( ! empty ( $ row [ self :: USER_ID_FIELD ] ) && ! empty ( $ row [ self :: VISITOR_ID_FIELD ] ) ) { $ this -> visitorIdsUserIdsMap [ $ row [ self :: USER_ID_FIELD ] ] = $ row [ self :: VISITOR_ID_FIELD ] ; } } | Remember visitor ID per user . We use it to fill metadata before actual inserting rows to DB . |
23,919 | private function setVisitorIds ( DataTable $ dataTable ) { foreach ( $ dataTable -> getRows ( ) as $ row ) { $ userId = $ row -> getColumn ( 'label' ) ; if ( isset ( $ this -> visitorIdsUserIdsMap [ $ userId ] ) ) { $ row -> setMetadata ( self :: VISITOR_ID_FIELD , $ this -> visitorIdsUserIdsMap [ $ userId ] ) ; } } } | Fill visitor ID as metadata before actual inserting rows to DB . |
23,920 | public function filter ( $ translations ) { foreach ( $ translations as $ pluginName => $ pluginTranslations ) { foreach ( $ pluginTranslations as $ key => $ translation ) { if ( isset ( $ this -> baseTranslations [ $ pluginName ] [ $ key ] ) && $ this -> baseTranslations [ $ pluginName ] [ $ key ] != Translate :: clea... | Decodes all encoded entities in the given translations |
23,921 | public function createNewDashboardForUser ( $ login , $ dashboardName = '' , $ addDefaultWidgets = true ) { Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ login ) ; $ layout = '{}' ; if ( $ addDefaultWidgets ) { $ layout = $ this -> dashboard -> getDefaultLayout ( ) ; } return $ this -> model -> createNewDashboard... | Creates a new dashboard for the given login |
23,922 | public function removeDashboard ( $ idDashboard , $ login = '' ) { $ login = $ login ? $ login : Piwik :: getCurrentUserLogin ( ) ; Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ login ) ; $ this -> model -> deleteDashboardForUser ( $ idDashboard , $ login ) ; } | Removes a dashboard according to given dashboard id and login |
23,923 | public function copyDashboardToUser ( $ idDashboard , $ copyToUser , $ dashboardName = '' ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ users = Request :: processRequest ( 'UsersManager.getUsers' ) ; $ userFound = false ; foreach ( $ users as $ user ) { if ( $ user [ 'login' ] === $ copyToUser ) { $ userFound = true... | Copy a dashboard of current user to another user |
23,924 | public function resetDashboardLayout ( $ idDashboard , $ login = '' ) { $ login = $ login ? $ login : Piwik :: getCurrentUserLogin ( ) ; Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ login ) ; $ layout = $ this -> dashboard -> getDefaultLayout ( ) ; $ this -> model -> updateLayoutForUser ( $ login , $ idDashboard... | Resets a dashboard to the default widget configuration |
23,925 | private function getDefaultDashboard ( ) { $ defaultLayout = $ this -> dashboard -> getDefaultLayout ( ) ; $ defaultLayout = $ this -> dashboard -> decodeLayout ( $ defaultLayout ) ; $ defaultDashboard = array ( 'name' => Piwik :: translate ( 'Dashboard_Dashboard' ) , 'layout' => $ defaultLayout , 'iddashboard' => 1 ) ... | Get the default dashboard . |
23,926 | private function getUserDashboards ( $ userLogin ) { $ userDashboards = $ this -> dashboard -> getAllDashboards ( $ userLogin ) ; $ dashboards = array ( ) ; foreach ( $ userDashboards as $ userDashboard ) { $ widgets = $ this -> getVisibleWidgetsWithinDashboard ( $ userDashboard ) ; $ dashboards [ ] = $ this -> buildDa... | Get all dashboards which a user has created . |
23,927 | private function getSingleRowEvolution ( $ idSite , $ dataTable , $ metadata , $ apiModule , $ apiAction , $ label , $ labelUseAbsoluteUrl = true ) { $ metricNames = array_keys ( $ metadata [ 'metrics' ] ) ; $ logo = $ actualLabel = false ; $ urlFound = false ; foreach ( $ dataTable -> getDataTables ( ) as $ subTable )... | Get row evolution for a single label |
23,928 | private function cleanOriginalLabel ( $ label ) { $ label = str_replace ( LabelFilter :: SEPARATOR_RECURSIVE_LABEL , ' - ' , $ label ) ; $ label = SafeDecodeLabel :: decodeLabelSafe ( $ label ) ; return $ label ; } | Returns a prettier more comprehensible version of a row evolution label for display . |
23,929 | public static function findAvailableSmsProviders ( ) { $ smsProviders = Plugin \ Manager :: getInstance ( ) -> findMultipleComponents ( 'SMSProvider' , 'Piwik\Plugins\MobileMessaging\SMSProvider' ) ; $ providers = array ( ) ; foreach ( $ smsProviders as $ provider ) { $ provider = StaticContainer :: get ( $ provider ) ... | Returns all available SMS Providers |
23,930 | public static function containsUCS2Characters ( $ string ) { $ GSMCharsetAsString = implode ( array_keys ( GSMCharset :: $ GSMCharset ) ) ; foreach ( self :: mb_str_split ( $ string ) as $ char ) { if ( mb_strpos ( $ GSMCharsetAsString , $ char ) === false ) { return true ; } } return false ; } | Assert whether a given String contains UCS2 characters |
23,931 | public function moveArchiveBlobsIntoChunks ( $ recordName , $ blobs ) { $ chunks = array ( ) ; foreach ( $ blobs as $ tableId => $ blob ) { $ name = $ this -> getRecordNameForTableId ( $ recordName , $ tableId ) ; if ( ! array_key_exists ( $ name , $ chunks ) ) { $ chunks [ $ name ] = array ( ) ; } $ chunks [ $ name ] ... | Moves the given blobs into chunks and assigns a proper record name containing the chunk number . |
23,932 | public function isRecordNameAChunk ( $ recordName ) { $ posAppendix = $ this -> getEndPosOfChunkAppendix ( $ recordName ) ; if ( false === $ posAppendix ) { return false ; } $ blobId = substr ( $ recordName , $ posAppendix ) ; return $ this -> isChunkRange ( $ blobId ) ; } | Detects whether a recordName like Actions_ActionUrls_chunk_0_99 or Actions_ActionUrls belongs to a chunk or not . |
23,933 | public function getRecordNameWithoutChunkAppendix ( $ recordName ) { if ( ! $ this -> isRecordNameAChunk ( $ recordName ) ) { return $ recordName ; } $ posAppendix = $ this -> getStartPosOfChunkAppendix ( $ recordName ) ; if ( false === $ posAppendix ) { return $ recordName ; } return substr ( $ recordName , 0 , $ posA... | When having a record like Actions_ActionUrls_chunk_0_99 it will return the raw recordName Actions_ActionUrls . |
23,934 | public function download ( $ url , $ destinationPath = null , $ timeout = null ) { $ method = Http :: getTransportMethod ( ) ; if ( ! isset ( $ timeout ) ) { $ timeout = static :: HTTP_REQUEST_TIMEOUT ; } $ post = null ; if ( $ this -> accessToken ) { $ post = array ( 'access_token' => $ this -> accessToken ) ; } $ fil... | Downloads data from the given URL via a POST request . If a destination path is given the downloaded data will be stored in the given path and returned otherwise . |
23,935 | public function fetch ( $ action , $ params ) { $ endpoint = sprintf ( '%s/api/%s/' , $ this -> domain , $ this -> version ) ; $ query = Http :: buildQuery ( $ params ) ; $ url = sprintf ( '%s%s?%s' , $ endpoint , $ action , $ query ) ; $ response = $ this -> download ( $ url ) ; $ result = json_decode ( $ response , t... | Executes the given API action on the Marketplace using the given params and returns the result . |
23,936 | protected function manipulateSubtableRequest ( $ request ) { $ request [ 'totals' ] = 0 ; $ request [ 'expanded' ] = 0 ; $ request [ 'filter_limit' ] = - 1 ; $ request [ 'filter_offset' ] = 0 ; $ request [ 'filter_sort_column' ] = '' ; $ parametersToRemove = array ( 'flat' ) ; if ( ! array_key_exists ( 'idSubtable' , $... | Make sure to get all rows of the first level table . |
23,937 | public static function removeAllUserSettingsForUser ( $ userLogin ) { if ( empty ( $ userLogin ) ) { throw new Exception ( 'No userLogin specified. Cannot remove all settings for this user' ) ; } try { $ table = Common :: prefixTable ( 'plugin_setting' ) ; Db :: get ( ) -> query ( sprintf ( 'DELETE FROM %s WHERE user_l... | Unsets all settings for a user . The settings will be removed from the database . Used when a user is deleted . |
23,938 | public static function removeAllSettingsForPlugin ( $ pluginName ) { try { $ table = Common :: prefixTable ( 'plugin_setting' ) ; Db :: get ( ) -> query ( sprintf ( 'DELETE FROM %s WHERE plugin_name = ?' , $ table ) , array ( $ pluginName ) ) ; } catch ( Exception $ e ) { if ( $ e -> getCode ( ) != 42 ) { throw $ e ; }... | Unsets all settings for a plugin . The settings will be removed from the database . Used when a plugin is uninstalled . |
23,939 | private function loadDocumentation ( ) { $ this -> metrics_documentation = array ( ) ; $ idSite = Common :: getRequestVar ( 'idSite' , 0 , 'int' ) ; if ( $ idSite < 1 ) { return ; } $ apiParameters = array ( ) ; $ entityNames = StaticContainer :: get ( 'entities.idNames' ) ; foreach ( $ entityNames as $ entityName ) { ... | Load documentation from the API |
23,940 | public function addTranslations ( $ translations ) { foreach ( $ translations as $ key => $ translation ) { $ this -> addTranslation ( $ key , $ translation ) ; } } | Associates multiple translations with metrics . |
23,941 | public function getGeneralInformation ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ totalSpaceUsed = 0 ; foreach ( $ this -> metadataProvider -> getAllTablesStatus ( ) as $ status ) { $ totalSpaceUsed += $ status [ 'Data_length' ] + $ status [ 'Index_length' ] ; } $ siteTableStatus = $ this -> metadataProvider -> ... | Gets some general information about this Matomo installation including the count of websites tracked the count of users and the total space used by the database . |
23,942 | public function getDatabaseUsageSummary ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ emptyRow = array ( 'data_size' => 0 , 'index_size' => 0 , 'row_count' => 0 ) ; $ rows = array ( 'tracker_data' => $ emptyRow , 'metric_data' => $ emptyRow , 'report_data' => $ emptyRow , 'other_data' => $ emptyRow ) ; foreach ( $... | Returns a datatable summarizing how data is distributed among Matomo tables . |
23,943 | public function getMetricDataSummaryByYear ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ dataTable = $ this -> getMetricDataSummary ( ) ; $ dataTable -> filter ( 'GroupBy' , array ( 'label' , __NAMESPACE__ . '\API::getArchiveTableYear' ) ) ; return $ dataTable ; } | Returns a datatable describing how much space is taken up by each numeric archive table grouped by year . |
23,944 | public function getReportDataSummaryByYear ( ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ dataTable = $ this -> getReportDataSummary ( ) ; $ dataTable -> filter ( 'GroupBy' , array ( 'label' , __NAMESPACE__ . '\API::getArchiveTableYear' ) ) ; return $ dataTable ; } | Returns a datatable describing how much space is taken up by each blob archive table grouped by year . |
23,945 | private function getTablesSummary ( $ statuses ) { $ dataTable = new DataTable ( ) ; foreach ( $ statuses as $ status ) { $ dataTable -> addRowFromSimpleArray ( array ( 'label' => $ status [ 'Name' ] , 'data_size' => $ status [ 'Data_length' ] , 'index_size' => $ status [ 'Index_length' ] , 'row_count' => $ status [ 'R... | Returns a datatable representation of a set of table statuses . |
23,946 | protected function loadContentFromCookie ( ) { $ cookieStr = $ this -> extractSignedContent ( $ _COOKIE [ $ this -> name ] ) ; if ( $ cookieStr === false ) { return ; } $ values = explode ( self :: VALUE_SEPARATOR , $ cookieStr ) ; foreach ( $ values as $ nameValue ) { $ equalPos = strpos ( $ nameValue , '=' ) ; $ varN... | Load the cookie content into a php array . Parses the cookie string to extract the different variables . Unserialize the array when necessary . Decode the non numeric values that were base64 encoded . |
23,947 | public function set ( $ name , $ value ) { $ name = self :: escapeValue ( $ name ) ; if ( is_null ( $ value ) ) { if ( $ this -> keyStore === false ) { unset ( $ this -> value [ $ name ] ) ; return ; } unset ( $ this -> value [ $ this -> keyStore ] [ $ name ] ) ; return ; } if ( $ this -> keyStore === false ) { $ this ... | Registers a new name = > value association in the cookie . |
23,948 | private function postDataTableLoadedFromAPI ( ) { $ columns = $ this -> dataTable -> getColumns ( ) ; $ hasNbVisits = in_array ( 'nb_visits' , $ columns ) ; $ hasNbUniqVisitors = in_array ( 'nb_uniq_visitors' , $ columns ) ; if ( empty ( $ this -> config -> columns_to_display ) ) { $ this -> config -> setDefaultColumns... | Hook called after the dataTable has been loaded from the API Can be used to add delete or modify the data freshly loaded |
23,949 | private function makePrettyArchivedOnText ( ) { $ dateText = $ this -> metadata [ DataTable :: ARCHIVED_DATE_METADATA_NAME ] ; $ date = Date :: factory ( $ dateText ) ; $ today = mktime ( 0 , 0 , 0 ) ; if ( $ date -> getTimestamp ( ) > $ today ) { $ elapsedSeconds = time ( ) - $ date -> getTimestamp ( ) ; $ timeAgo = $... | Returns prettified and translated text that describes when a report was last updated . |
23,950 | private function getClientSidePropertiesToSet ( ) { $ result = array ( ) ; foreach ( $ this -> config -> clientSideProperties as $ name ) { if ( property_exists ( $ this -> requestConfig , $ name ) ) { $ result [ $ name ] = $ this -> getIntIfValueIsBool ( $ this -> requestConfig -> $ name ) ; } elseif ( property_exists... | Returns array of properties that should be visible to client side JavaScript . The data will be available in the data - props HTML attribute of the . dataTable div . |
23,951 | public function deleteVisits ( $ visitIds ) { $ numDeletedVisits = 0 ; foreach ( $ this -> logTablesProvider -> getAllLogTables ( ) as $ logTable ) { if ( $ logTable -> getColumnToJoinOnIdVisit ( ) ) { $ numVisits = $ this -> rawLogDao -> deleteFromLogTable ( $ logTable -> getName ( ) , $ visitIds ) ; if ( $ logTable -... | Deletes visits by ID . This method cascades so conversions conversion items and visit actions for the visits are also deleted . |
23,952 | public function addOptgroup ( $ label , $ attributes = null ) { $ optgroup = new HTML_QuickForm2_Element_Select_Optgroup ( $ this -> values , $ this -> possibleValues , $ label , $ attributes ) ; $ this -> options [ ] = $ optgroup ; return $ optgroup ; } | Adds a new optgroup |
23,953 | protected function loadOptionsFromArray ( HTML_QuickForm2_Element_Select_OptionContainer $ container , $ options ) { foreach ( $ options as $ key => $ value ) { if ( is_array ( $ value ) ) { $ optgroup = $ container -> addOptgroup ( $ key ) ; $ this -> loadOptionsFromArray ( $ optgroup , $ value ) ; } else { $ containe... | Adds options from given array into given container |
23,954 | protected function _detectFormat ( ) { $ sep = quotemeta ( $ this -> _separator ) ; $ patterns = array ( ) ; $ lengths = array ( ) ; if ( $ this -> _type == self :: ISBN10 || $ this -> _type == self :: AUTO ) { if ( empty ( $ sep ) ) { $ pattern = '/^[0-9]{9}[0-9X]{1}$/' ; $ length = 10 ; } else { $ pattern = "/^[0-9]{... | Detect input format . |
23,955 | public static function makePeriodFromQueryParams ( $ timezone , $ period , $ date ) { if ( empty ( $ timezone ) ) { $ timezone = 'UTC' ; } if ( $ period == 'range' ) { self :: checkPeriodIsEnabled ( 'range' ) ; $ oPeriod = new Range ( 'range' , $ date , $ timezone , Date :: factory ( 'today' , $ timezone ) ) ; } else {... | Creates a Period instance using a period date and timezone . |
23,956 | public function close ( ) { if ( $ this -> _stmt ) { $ r = $ this -> _stmt -> close ( ) ; $ this -> _stmt = null ; return $ r ; } return false ; } | Closes the cursor and the statement . |
23,957 | public function addConfigValuesFromSystemSettings ( $ configValues , $ systemSettings ) { foreach ( $ systemSettings as $ pluginSetting ) { $ pluginName = $ pluginSetting -> getPluginName ( ) ; if ( empty ( $ pluginName ) ) { continue ; } if ( ! array_key_exists ( $ pluginName , $ configValues ) ) { $ configValues [ $ ... | Adds config values that can be used to overwrite a plugin system setting and adds a description + default value for already existing configured config values that overwrite a plugin system setting . |
23,958 | public static function getAllArchiveBlobTables ( ) { if ( empty ( self :: $ archiveBlobTables ) ) { $ archiveTables = ArchiveTableCreator :: getTablesArchivesInstalled ( ) ; self :: $ archiveBlobTables = array_filter ( $ archiveTables , function ( $ name ) { return ArchiveTableCreator :: getTypeFromTableName ( $ name )... | Returns all available archive blob tables |
23,959 | public static function getFirstDayOfArchivedDeviceDetectorData ( ) { static $ deviceDetectionBlobAvailableDate ; if ( empty ( $ deviceDetectionBlobAvailableDate ) ) { $ archiveBlobTables = self :: getAllArchiveBlobTables ( ) ; $ deviceDetectionBlobAvailableDate = null ; foreach ( $ archiveBlobTables as $ table ) { $ de... | Find the first day on which DevicesDetection archives were generated |
23,960 | public static function updateBrowserArchives ( $ table ) { Db :: exec ( sprintf ( "UPDATE IGNORE %s SET name='DevicesDetection_browserVersions' WHERE name = 'UserSettings_browser'" , $ table ) ) ; $ oldBrowserBlobs = Db :: get ( ) -> fetchAll ( sprintf ( "SELECT * FROM %s WHERE name = 'UserSettings_browser' AND `period... | Updates all browser archives to new structure |
23,961 | public function setOption ( $ name , $ value ) { if ( $ name == 'tag_cache' ) { $ this -> setInnerCache ( $ value ) ; } else { parent :: setOption ( $ name , $ value ) ; } return $ this ; } | Interceptor child method to handle the case where an Inner Cache object is being set since it s not supported by the standard backend interface |
23,962 | public function getOption ( $ name ) { if ( $ name == 'tag_cache' ) { return $ this -> getInnerCache ( ) ; } else { if ( in_array ( $ name , $ this -> _options ) ) { return $ this -> _options [ $ name ] ; } if ( $ name == 'lifetime' ) { return parent :: getLifetime ( ) ; } return null ; } } | Retrieve any option via interception of the parent s statically held options including the local option for a tag cache . |
23,963 | protected function _createDirectoriesFor ( $ path ) { if ( ! is_dir ( $ path ) ) { $ oldUmask = umask ( 0 ) ; if ( ! @ mkdir ( $ path , $ this -> _octdec ( $ this -> _options [ 'cache_directory_umask' ] ) , true ) ) { $ lastErr = error_get_last ( ) ; umask ( $ oldUmask ) ; Zend_Cache :: throwException ( "Can't create d... | Recursively create the directories needed to write the static file |
23,964 | protected function _verifyPath ( $ path ) { $ path = realpath ( $ path ) ; $ base = realpath ( $ this -> _options [ 'public_dir' ] ) ; return strncmp ( $ path , $ base , strlen ( $ base ) ) !== 0 ; } | Verify path exists and is non - empty |
23,965 | public function getRangeFormatPattern ( $ short = false , $ maxDifference = 'Y' ) { return $ this -> translator -> translate ( sprintf ( 'Intl_Format_Interval_%s_%s' , $ short ? 'Short' : 'Long' , $ maxDifference ) ) ; } | Returns interval format pattern for the given format type |
23,966 | public function setConfig ( Zend_Config $ config ) { $ options = $ config -> toArray ( ) ; while ( list ( $ name , $ value ) = each ( $ options ) ) { $ this -> setOption ( $ name , $ value ) ; } return $ this ; } | Set options using an instance of type Zend_Config |
23,967 | public function save ( $ data , $ id = null , $ tags = array ( ) , $ specificLifetime = false , $ priority = 8 ) { if ( ! $ this -> _options [ 'caching' ] ) { return true ; } if ( $ id === null ) { $ id = $ this -> _lastId ; } else { $ id = $ this -> _id ( $ id ) ; } self :: _validateIdOrTag ( $ id ) ; self :: _validat... | Save some data in a cache |
23,968 | public function remove ( $ id ) { if ( ! $ this -> _options [ 'caching' ] ) { return true ; } $ id = $ this -> _id ( $ id ) ; self :: _validateIdOrTag ( $ id ) ; $ this -> _log ( "Zend_Cache_Core: remove item '{$id}'" , 7 ) ; return $ this -> _backend -> remove ( $ id ) ; } | Remove a cache |
23,969 | public function clean ( $ mode = 'all' , $ tags = array ( ) ) { if ( ! $ this -> _options [ 'caching' ] ) { return true ; } if ( ! in_array ( $ mode , array ( Zend_Cache :: CLEANING_MODE_ALL , Zend_Cache :: CLEANING_MODE_OLD , Zend_Cache :: CLEANING_MODE_MATCHING_TAG , Zend_Cache :: CLEANING_MODE_NOT_MATCHING_TAG , Zen... | Clean cache entries |
23,970 | protected function _id ( $ id ) { if ( ( $ id !== null ) && isset ( $ this -> _options [ 'cache_id_prefix' ] ) ) { return $ this -> _options [ 'cache_id_prefix' ] . $ id ; } return $ id ; } | Make and return a cache id |
23,971 | public static function decodeLabelSafe ( $ value ) { if ( empty ( $ value ) ) { return $ value ; } $ raw = urldecode ( $ value ) ; $ value = htmlspecialchars_decode ( $ raw , ENT_QUOTES ) ; $ style = ENT_QUOTES | ENT_IGNORE ; $ value = htmlspecialchars ( $ value , $ style , 'UTF-8' ) ; return $ value ; } | Decodes the given value |
23,972 | public function filter ( $ table ) { foreach ( $ table -> getRows ( ) as $ row ) { $ value = $ row -> getColumn ( $ this -> columnToDecode ) ; if ( $ value !== false ) { $ value = self :: decodeLabelSafe ( $ value ) ; $ row -> setColumn ( $ this -> columnToDecode , $ value ) ; $ this -> filterSubTable ( $ row ) ; } } } | Decodes all columns of the given data table |
23,973 | public function getDuplicateIdActions ( ) { $ sql = "SELECT name, COUNT(*) AS count, GROUP_CONCAT(idaction ORDER BY idaction ASC SEPARATOR ',') as idactions FROM " . Common :: prefixTable ( 'log_action' ) . " GROUP BY name, hash, type HAVING count > 1" ; $ result = array ( ) ; foreach ( Db... | Returns list of all duplicate actions in the log_action table by name and the lowest action ID . The duplicate actions are returned with each action . |
23,974 | public function getSitesAndDatesOfRowsUsingDuplicates ( $ table , $ duplicateIdActions ) { $ idactionColumns = $ this -> getIdActionTableColumnsFromMetadata ( ) ; $ idactionColumns = array_values ( $ idactionColumns [ $ table ] ) ; $ table = Common :: prefixTable ( $ table ) ; $ sql = "SELECT idsite, DATE(server_time) ... | Returns the server time and idsite of rows in a log table that reference at least one action in a set . |
23,975 | public function delete ( $ idActions ) { foreach ( $ idActions as & $ id ) { $ id = ( int ) $ id ; } $ table = Common :: prefixTable ( 'log_action' ) ; $ sql = "DELETE FROM $table WHERE idaction IN (" . implode ( "," , $ idActions ) . ")" ; Db :: query ( $ sql ) ; } | Removes a list of actions from the log_action table by ID . |
23,976 | public function fetch ( $ query , $ parameters = array ( ) ) { try { $ sth = $ this -> query ( $ query , $ parameters ) ; if ( $ sth === false ) { return false ; } return $ sth -> fetch ( PDO :: FETCH_ASSOC ) ; } catch ( PDOException $ e ) { throw new DbException ( "Error query: " . $ e -> getMessage ( ) ) ; } } | Returns the first row of a query result using optional bound parameters . |
23,977 | public function getAllSystemSettings ( ) { $ cacheId = CacheId :: languageAware ( 'AllSystemSettings' ) ; $ cache = PiwikCache :: getTransientCache ( ) ; if ( ! $ cache -> contains ( $ cacheId ) ) { $ pluginNames = $ this -> pluginManager -> getActivatedPlugins ( ) ; $ byPluginName = array ( ) ; foreach ( $ pluginNames... | Returns all available system settings . A plugin has to specify a file named SystemSettings . php containing a class named SystemSettings that extends Piwik \ Settings \ Plugin \ SystemSettings in order to be considered as a system setting . Otherwise the settings for a plugin won t be available . |
23,978 | public function startForm ( HTML_QuickForm2 $ form ) { $ this -> formId = $ form -> getId ( ) ; $ this -> rules [ $ this -> formId ] = array ( ) ; } | Sets the form currently being processed |
23,979 | public static function canAutoUpdate ( ) { if ( ! is_writable ( PIWIK_INCLUDE_PATH . '/' ) || ! is_writable ( PIWIK_DOCUMENT_ROOT . '/index.php' ) || ! is_writable ( PIWIK_INCLUDE_PATH . '/core' ) || ! is_writable ( PIWIK_USER_PATH . '/config/global.ini.php' ) ) { return false ; } return true ; } | Check if this installation can be auto - updated . For performance we look for clues rather than an exhaustive test . |
23,980 | public static function checkDirectoriesWritable ( $ directoriesToCheck ) { $ resultCheck = array ( ) ; foreach ( $ directoriesToCheck as $ directoryToCheck ) { if ( ! preg_match ( '/^' . preg_quote ( PIWIK_USER_PATH , '/' ) . '/' , $ directoryToCheck ) ) { $ directoryToCheck = PIWIK_USER_PATH . $ directoryToCheck ; } F... | Checks if directories are writable and create them if they do not exist . |
23,981 | public static function dieIfDirectoriesNotWritable ( $ directoriesToCheck = null ) { $ resultCheck = self :: checkDirectoriesWritable ( $ directoriesToCheck ) ; if ( array_search ( false , $ resultCheck ) === false ) { return ; } $ directoryList = '' ; foreach ( $ resultCheck as $ dir => $ bool ) { $ realpath = Filesys... | Checks that the directories Piwik needs write access are actually writable Displays a nice error page if permissions are missing on some directories |
23,982 | public static function getAutoUpdateMakeWritableMessage ( ) { $ realpath = Filesystem :: realpath ( PIWIK_INCLUDE_PATH . '/' ) ; $ message = '' ; $ message .= "<code>" . self :: getCommandToChangeOwnerOfPiwikFiles ( ) . "</code><br />" ; $ message .= "<code>chmod -R 0755 " . $ realpath . "</code><br />" ; $ message .= ... | Returns the help message when the auto update can t run because of missing permissions |
23,983 | public static function getErrorMessageMissingPermissions ( $ path ) { $ message = "Please check that the web server has enough permission to write to these files/directories:<br />" ; if ( SettingsServer :: isWindows ( ) ) { $ message .= "On Windows, check that the folder is not read only and is writable.\n You ca... | Returns friendly error message explaining how to fix permissions |
23,984 | private static function getMakeWritableCommand ( $ realpath ) { $ realpath = Common :: sanitizeInputValue ( $ realpath ) ; if ( SettingsServer :: isWindows ( ) ) { return "<code>cacls $realpath /t /g " . Common :: sanitizeInputValue ( self :: getUser ( ) ) . ":f</code><br />\n" ; } return "<code>chmod -R 0755 $realpath... | Returns the help text displayed to suggest which command to run to give writable access to a file or directory |
23,985 | public static function registerElement ( $ type , $ className , $ includeFile = null ) { self :: $ elementTypes [ strtolower ( $ type ) ] = array ( $ className , $ includeFile ) ; } | Registers a new element type |
23,986 | public static function createElement ( $ type , $ name = null , $ attributes = null , array $ data = array ( ) ) { $ type = strtolower ( $ type ) ; if ( ! isset ( self :: $ elementTypes [ $ type ] ) ) { throw new HTML_QuickForm2_InvalidArgumentException ( "Element type '$type' is not known" ) ; } list ( $ className , $... | Creates a new element object of the given type |
23,987 | public static function registerRule ( $ type , $ className , $ includeFile = null , $ config = null ) { self :: $ registeredRules [ strtolower ( $ type ) ] = array ( $ className , $ includeFile , $ config ) ; } | Registers a new rule type |
23,988 | public static function createRule ( $ type , HTML_QuickForm2_Node $ owner , $ message = '' , $ config = null ) { $ type = strtolower ( $ type ) ; if ( ! isset ( self :: $ registeredRules [ $ type ] ) ) { throw new HTML_QuickForm2_InvalidArgumentException ( "Rule '$type' is not known" ) ; } list ( $ className , $ includ... | Creates a new Rule of the given type |
23,989 | public function setTable ( Zend_Db_Table_Abstract $ table ) { $ this -> _adapter = $ table -> getAdapter ( ) ; $ this -> _info = $ table -> info ( ) ; $ this -> _table = $ table ; return $ this ; } | Sets the primary table name and retrieves the table schema . |
23,990 | public function isReadOnly ( ) { $ readOnly = false ; $ fields = $ this -> getPart ( Zend_Db_Table_Select :: COLUMNS ) ; $ cols = $ this -> _info [ Zend_Db_Table_Abstract :: COLS ] ; if ( ! count ( $ fields ) ) { return $ readOnly ; } foreach ( $ fields as $ columnEntry ) { $ column = $ columnEntry [ 1 ] ; $ alias = $ ... | Tests query to determine if expressions or aliases columns exist . |
23,991 | public function assemble ( ) { $ fields = $ this -> getPart ( Zend_Db_Table_Select :: COLUMNS ) ; $ primary = $ this -> _info [ Zend_Db_Table_Abstract :: NAME ] ; $ schema = $ this -> _info [ Zend_Db_Table_Abstract :: SCHEMA ] ; if ( count ( $ this -> _parts [ self :: UNION ] ) == 0 ) { if ( ! count ( $ fields ) ) { $ ... | Performs a validation on the select query before passing back to the parent class . Ensures that only columns from the primary Zend_Db_Table are returned in the result . |
23,992 | protected static function mergeMinMaxLength ( $ length , $ config ) { if ( array_key_exists ( 'min' , $ config ) || array_key_exists ( 'max' , $ config ) ) { if ( ! array_key_exists ( 'min' , $ length ) && array_key_exists ( 'min' , $ config ) ) { $ length [ 'min' ] = $ config [ 'min' ] ; } if ( ! array_key_exists ( 'm... | Adds the min and max fields from one array to the other |
23,993 | public function setConfig ( $ config ) { if ( is_array ( $ config ) ) { $ config = self :: mergeMinMaxLength ( array ( ) , $ config ) + array ( 'min' => 0 , 'max' => 0 ) ; } if ( is_array ( $ config ) && ( $ config [ 'min' ] < 0 || $ config [ 'max' ] < 0 ) || ! is_array ( $ config ) && $ config < 0 ) { throw new HTML_Q... | Sets the allowed length limits |
23,994 | protected function getJavascriptCallback ( ) { $ regex = $ this -> getConfig ( ) ; if ( $ pos = strpos ( $ regex , 'u' , strrpos ( $ regex , '/' ) ) ) { $ regex = substr ( $ regex , 0 , $ pos ) . substr ( $ regex , $ pos + 1 ) ; $ regex = preg_replace ( '/(?<!\\\\)(?>\\\\\\\\)*\\\\x{([a-fA-F0-9]+)}/' , '\\u$1' , $ rege... | Returns the client - side validation callback |
23,995 | public function add ( $ idSite , $ date , $ note , $ starred = 0 ) { $ this -> checkUserCanAddNotesFor ( $ idSite ) ; $ this -> checkSingleIdSite ( $ idSite , $ extraMessage = "Note: Cannot add one note to multiple sites." ) ; $ this -> checkDateIsValid ( $ date ) ; $ annotations = new AnnotationList ( $ idSite ) ; $ n... | Create a new annotation for a site . |
23,996 | public function save ( $ idSite , $ idNote , $ date = null , $ note = null , $ starred = null ) { $ this -> checkSingleIdSite ( $ idSite , $ extraMessage = "Note: Cannot modify more than one note at a time." ) ; $ this -> checkDateIsValid ( $ date , $ canBeNull = true ) ; $ annotations = new AnnotationList ( $ idSite )... | Modifies an annotation for a site and returns the modified annotation and its ID . |
23,997 | public function delete ( $ idSite , $ idNote ) { $ this -> checkSingleIdSite ( $ idSite , $ extraMessage = "Note: Cannot delete annotations from multiple sites." ) ; $ annotations = new AnnotationList ( $ idSite ) ; $ this -> checkUserCanModifyOrDelete ( $ idSite , $ annotations -> get ( $ idSite , $ idNote ) ) ; $ ann... | Removes an annotation from a site s list of annotations . |
23,998 | public function deleteAll ( $ idSite ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ this -> checkSingleIdSite ( $ idSite , $ extraMessage = "Note: Cannot delete annotations from multiple sites." ) ; $ annotations = new AnnotationList ( $ idSite ) ; $ annotations -> removeAll ( $ idSite ) ; $ annotations -> save ( $ i... | Removes all annotations for a single site . Only super users can use this method . |
23,999 | public function get ( $ idSite , $ idNote ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ this -> checkSingleIdSite ( $ idSite , $ extraMessage = "Note: Specify only one site ID when getting ONE note." ) ; $ annotations = new AnnotationList ( $ idSite ) ; return $ annotations -> get ( $ idSite , $ idNote ) ; } | Returns a single note for one site . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.