idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
23,700 | public function setProfiler ( $ profiler ) { $ enabled = null ; $ profilerClass = $ this -> _defaultProfilerClass ; $ profilerInstance = null ; if ( $ profilerIsObject = is_object ( $ profiler ) ) { if ( $ profiler instanceof Zend_Db_Profiler ) { $ profilerInstance = $ profiler ; } else if ( $ profiler instanceof Zend_... | Set the adapter s profiler object . |
23,701 | public function query ( $ sql , $ bind = array ( ) ) { $ this -> _connect ( ) ; if ( $ sql instanceof Zend_Db_Select ) { if ( empty ( $ bind ) ) { $ bind = $ sql -> getBind ( ) ; } $ sql = $ sql -> assemble ( ) ; } if ( ! is_array ( $ bind ) ) { $ bind = array ( $ bind ) ; } $ stmt = $ this -> prepare ( $ sql ) ; $ stm... | Prepares and executes an SQL statement with bound data . |
23,702 | public function beginTransaction ( ) { $ this -> _connect ( ) ; $ q = $ this -> _profiler -> queryStart ( 'begin' , Zend_Db_Profiler :: TRANSACTION ) ; $ this -> _beginTransaction ( ) ; $ this -> _profiler -> queryEnd ( $ q ) ; return $ this ; } | Leave autocommit mode and begin a transaction . |
23,703 | public function update ( $ table , array $ bind , $ where = '' ) { $ set = array ( ) ; $ i = 0 ; foreach ( $ bind as $ col => $ val ) { if ( $ val instanceof Zend_Db_Expr ) { $ val = $ val -> __toString ( ) ; unset ( $ bind [ $ col ] ) ; } else { if ( $ this -> supportsParameters ( 'positional' ) ) { $ val = '?' ; } el... | Updates table rows with specified data based on a WHERE clause . |
23,704 | public function delete ( $ table , $ where = '' ) { $ where = $ this -> _whereExpr ( $ where ) ; $ sql = "DELETE FROM " . $ this -> quoteIdentifier ( $ table , true ) . ( ( $ where ) ? " WHERE $where" : '' ) ; $ stmt = $ this -> query ( $ sql ) ; $ result = $ stmt -> rowCount ( ) ; return $ result ; } | Deletes table rows based on a WHERE clause . |
23,705 | protected function _whereExpr ( $ where ) { if ( empty ( $ where ) ) { return $ where ; } if ( ! is_array ( $ where ) ) { $ where = array ( $ where ) ; } foreach ( $ where as $ cond => & $ term ) { if ( is_int ( $ cond ) ) { if ( $ term instanceof Zend_Db_Expr ) { $ term = $ term -> __toString ( ) ; } } else { $ term =... | Convert an array string or Zend_Db_Expr object into a string to put in a WHERE clause . |
23,706 | public function fetchAll ( $ sql , $ bind = array ( ) , $ fetchMode = null ) { if ( $ fetchMode === null ) { $ fetchMode = $ this -> _fetchMode ; } $ stmt = $ this -> query ( $ sql , $ bind ) ; $ result = $ stmt -> fetchAll ( $ fetchMode ) ; return $ result ; } | Fetches all SQL result rows as a sequential array . Uses the current fetchMode for the adapter . |
23,707 | public function fetchRow ( $ sql , $ bind = array ( ) , $ fetchMode = null ) { if ( $ fetchMode === null ) { $ fetchMode = $ this -> _fetchMode ; } $ stmt = $ this -> query ( $ sql , $ bind ) ; $ result = $ stmt -> fetch ( $ fetchMode ) ; return $ result ; } | Fetches the first row of the SQL result . Uses the current fetchMode for the adapter . |
23,708 | public function fetchAssoc ( $ sql , $ bind = array ( ) ) { $ stmt = $ this -> query ( $ sql , $ bind ) ; $ data = array ( ) ; while ( $ row = $ stmt -> fetch ( Zend_Db :: FETCH_ASSOC ) ) { $ tmp = array_values ( array_slice ( $ row , 0 , 1 ) ) ; $ data [ $ tmp [ 0 ] ] = $ row ; } return $ data ; } | Fetches all SQL result rows as an associative array . |
23,709 | public function fetchPairs ( $ sql , $ bind = array ( ) ) { $ stmt = $ this -> query ( $ sql , $ bind ) ; $ data = array ( ) ; while ( $ row = $ stmt -> fetch ( Zend_Db :: FETCH_NUM ) ) { $ data [ $ row [ 0 ] ] = $ row [ 1 ] ; } return $ data ; } | Fetches all SQL result rows as an array of key - value pairs . |
23,710 | public function fetchOne ( $ sql , $ bind = array ( ) ) { $ stmt = $ this -> query ( $ sql , $ bind ) ; $ result = $ stmt -> fetchColumn ( 0 ) ; return $ result ; } | Fetches the first column of the first row of the SQL result . |
23,711 | public function quoteInto ( $ text , $ value , $ type = null , $ count = null ) { if ( $ count === null ) { return str_replace ( '?' , $ this -> quote ( $ value , $ type ) , $ text ) ; } else { while ( $ count > 0 ) { if ( strpos ( $ text , '?' ) !== false ) { $ text = substr_replace ( $ text , $ this -> quote ( $ valu... | Quotes a value and places into a piece of text at a placeholder . |
23,712 | public function foldCase ( $ key ) { switch ( $ this -> _caseFolding ) { case Zend_Db :: CASE_LOWER : $ value = strtolower ( ( string ) $ key ) ; break ; case Zend_Db :: CASE_UPPER : $ value = strtoupper ( ( string ) $ key ) ; break ; case Zend_Db :: CASE_NATURAL : default : $ value = ( string ) $ key ; } return $ valu... | Helper method to change the case of the strings used when returning result sets in FETCH_ASSOC and FETCH_BOTH modes . |
23,713 | public function getInvalidatedArchiveIdsSafeToDelete ( $ archiveTable , array $ idSites ) { try { Db :: get ( ) -> query ( 'SET SESSION group_concat_max_len=' . ( 128 * 1024 ) ) ; } catch ( \ Exception $ ex ) { $ this -> logger -> info ( "Could not set group_concat_max_len MySQL session variable." ) ; } $ idSites = arr... | Returns the archives IDs that have already been invalidated and have been since re - processed . |
23,714 | public function getSitesWithInvalidatedArchive ( $ numericTable ) { $ rows = Db :: fetchAll ( "SELECT DISTINCT idsite FROM `$numericTable` WHERE name LIKE 'done%' AND value = " . ArchiveWriter :: DONE_INVALIDATED ) ; $ result = array ( ) ; foreach ( $ rows as $ row ) { $ result [ ] = $ row [ 'idsite' ] ; } return $ res... | Returns the site IDs for invalidated archives in an archive table . |
23,715 | public function checkServerVersion ( ) { $ serverVersion = $ this -> getServerVersion ( ) ; $ requiredVersion = Config :: getInstance ( ) -> General [ 'minimum_mysql_version' ] ; if ( version_compare ( $ serverVersion , $ requiredVersion ) === - 1 ) { throw new Exception ( Piwik :: translate ( 'General_ExceptionDatabas... | Check MySQL version |
23,716 | public function exec ( $ sqlQuery ) { $ rc = mysqli_query ( $ this -> _connection , $ sqlQuery ) ; $ rowsAffected = mysqli_affected_rows ( $ this -> _connection ) ; if ( ! is_bool ( $ rc ) ) { mysqli_free_result ( $ rc ) ; } return $ rowsAffected ; } | Execute unprepared SQL query and throw away the result |
23,717 | public function getClientVersion ( ) { $ this -> _connect ( ) ; $ version = $ this -> _connection -> server_version ; $ major = ( int ) ( $ version / 10000 ) ; $ minor = ( int ) ( $ version % 10000 / 100 ) ; $ revision = ( int ) ( $ version % 100 ) ; return $ major . '.' . $ minor . '.' . $ revision ; } | Get client version |
23,718 | protected function _sendMail ( ) { $ file = $ this -> _path . DIRECTORY_SEPARATOR . call_user_func ( $ this -> _callback , $ this ) ; if ( ! is_writable ( dirname ( $ file ) ) ) { throw new Zend_Mail_Transport_Exception ( sprintf ( 'Target directory "%s" does not exist or is not writable' , dirname ( $ file ) ) ) ; } $... | Saves e - mail message to a file |
23,719 | protected function _prepare ( $ sql ) { try { $ this -> _stmt = $ this -> _adapter -> getConnection ( ) -> prepare ( $ sql ) ; } catch ( PDOException $ e ) { throw new Zend_Db_Statement_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Prepare a string SQL statement and create a statement object . |
23,720 | public function columnCount ( ) { try { return $ this -> _stmt -> columnCount ( ) ; } catch ( PDOException $ e ) { throw new Zend_Db_Statement_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Returns the number of columns in the result set . Returns null if the statement has no result set metadata . |
23,721 | public function getAttribute ( $ key ) { try { return $ this -> _stmt -> getAttribute ( $ key ) ; } catch ( PDOException $ e ) { throw new Zend_Db_Statement_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Retrieve a statement attribute . |
23,722 | public function setAttribute ( $ key , $ val ) { try { return $ this -> _stmt -> setAttribute ( $ key , $ val ) ; } catch ( PDOException $ e ) { throw new Zend_Db_Statement_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Set a statement attribute . |
23,723 | private function buildRememberArchivedReportIdProcessSafe ( $ idSite , $ date ) { $ id = $ this -> buildRememberArchivedReportIdForSiteAndDate ( $ idSite , $ date ) ; $ id .= '_' . getmypid ( ) ; return $ id ; } | This version is multi process safe on the insert of a new date to invalidate . |
23,724 | private function getDatesByYearMonthAndPeriodType ( $ dates ) { $ result = array ( ) ; foreach ( $ dates as $ date ) { $ yearMonth = ArchiveTableCreator :: getTableMonthFromDate ( $ date ) ; $ result [ $ yearMonth ] [ null ] [ ] = $ date -> toString ( ) ; $ janYearMonth = $ date -> toString ( 'Y' ) . '_01' ; $ result [... | Called when deleting all periods . |
23,725 | public function groupUrlsByHost ( $ siteUrls ) { if ( empty ( $ siteUrls ) ) { return array ( ) ; } $ allUrls = array ( ) ; foreach ( $ siteUrls as $ idSite => $ urls ) { $ idSite = ( int ) $ idSite ; foreach ( $ urls as $ url ) { $ urlParsed = @ parse_url ( $ url ) ; if ( $ urlParsed === false || ! isset ( $ urlParsed... | Groups all URLs by host path and idsite . |
23,726 | public function setConfig ( $ config ) { if ( 0 >= $ config ) { throw new HTML_QuickForm2_InvalidArgumentException ( 'MaxFileSize Rule requires a positive size limit, ' . preg_replace ( '/\s+/' , ' ' , var_export ( $ config , true ) ) . ' given' ) ; } return parent :: setConfig ( $ config ) ; } | Sets maximum allowed file size |
23,727 | public static function getNonce ( $ id , $ ttl = 600 ) { $ ns = new SessionNamespace ( $ id ) ; $ nonce = $ ns -> nonce ; if ( empty ( $ nonce ) ) { $ nonce = md5 ( SettingsPiwik :: getSalt ( ) . time ( ) . Common :: generateUniqId ( ) ) ; $ ns -> nonce = $ nonce ; } $ ns -> setExpirationSeconds ( $ ttl , 'nonce' ) ; r... | Returns an existing nonce by ID . If none exists a new nonce will be generated . |
23,728 | public static function verifyNonce ( $ id , $ cnonce ) { $ ns = new SessionNamespace ( $ id ) ; $ nonce = $ ns -> nonce ; if ( empty ( $ cnonce ) || $ cnonce !== $ nonce ) { return false ; } $ referrer = Url :: getReferrer ( ) ; if ( ! empty ( $ referrer ) && ! Url :: isLocalUrl ( $ referrer ) ) { return false ; } $ or... | Returns if a nonce is valid and comes from a valid request . |
23,729 | public static function checkNonce ( $ nonceName , $ nonce = null ) { if ( $ nonce === null ) { $ nonce = Common :: getRequestVar ( 'nonce' , null , 'string' ) ; } if ( ! self :: verifyNonce ( $ nonceName , $ nonce ) ) { throw new \ Exception ( Piwik :: translate ( 'General_ExceptionNonceMismatch' ) ) ; } self :: discar... | Verifies and discards a nonce . |
23,730 | public function getEntryPageUrls ( $ idSite , $ period , $ date , $ segment = false , $ expanded = false , $ idSubtable = false , $ flat = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ dataTable = $ this -> getPageUrls ( $ idSite , $ period , $ date , $ segment , $ expanded , $ idSubtable , false , $ flat ... | Returns a DataTable with analytics information for every unique entry page URL for the specified site period & segment . |
23,731 | public function getExitPageUrls ( $ idSite , $ period , $ date , $ segment = false , $ expanded = false , $ idSubtable = false , $ flat = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ dataTable = $ this -> getPageUrls ( $ idSite , $ period , $ date , $ segment , $ expanded , $ idSubtable , false , $ flat )... | Returns a DataTable with analytics information for every unique exit page URL for the specified site period & segment . |
23,732 | public function getEntryPageTitles ( $ idSite , $ period , $ date , $ segment = false , $ expanded = false , $ idSubtable = false , $ flat = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ dataTable = $ this -> getPageTitles ( $ idSite , $ period , $ date , $ segment , $ expanded , $ idSubtable , $ flat ) ; ... | Returns a DataTable with analytics information for every unique entry page title for the given site time period & segment . |
23,733 | public function getExitPageTitles ( $ idSite , $ period , $ date , $ segment = false , $ expanded = false , $ idSubtable = false , $ flat = false ) { Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ dataTable = $ this -> getPageTitles ( $ idSite , $ period , $ date , $ segment , $ expanded , $ idSubtable , $ flat ) ; $... | Returns a DataTable with analytics information for every unique exit page title for the given site time period & segment . |
23,734 | protected function getFilterPageDatatableSearch ( $ callBackParameters , $ search , $ actionType , $ table = false , $ searchTree = false ) { if ( $ searchTree === false ) { if ( $ actionType == Action :: TYPE_PAGE_TITLE ) { $ searchedString = Common :: unsanitizeInputValue ( $ search ) ; } else { $ idSite = $ callBack... | Will search in the DataTable for a Label matching the searched string and return only the matching row or an empty datatable |
23,735 | protected function doFilterPageDatatableSearch ( $ callBackParameters , $ table , $ searchTree ) { if ( $ table instanceof DataTable \ Map ) { foreach ( $ table -> getDataTables ( ) as $ subTable ) { $ filteredSubTable = $ this -> doFilterPageDatatableSearch ( $ callBackParameters , $ subTable , $ searchTree ) ; if ( $... | This looks very similar to LabelFilter . php should it be refactored somehow? FIXME |
23,736 | public function getSum ( $ a = 0 , $ b = 0 ) { if ( ! is_numeric ( $ a ) || ! is_numeric ( $ b ) ) { throw new \ Exception ( 'Given parameters need to be numeric' ) ; } return ( float ) ( $ a + $ b ) ; } | Sums two floats and returns the result . The paramaters are set automatically from the GET request when the API function is called . You can also use default values as shown in this example . |
23,737 | public function getCompetitionDatatable ( ) { $ dataTable = new DataTable ( ) ; $ row1 = new Row ( ) ; $ row1 -> setColumns ( array ( 'name' => 'piwik' , 'license' => 'GPL' ) ) ; $ row1 -> setMetadata ( 'logo' , 'logo.png' ) ; $ dataTable -> addRow ( $ row1 ) ; $ dataTable -> addRowFromSimpleArray ( array ( 'name' => '... | Returns a custom data table . This data table will be converted to all available formats when requested in the API request . |
23,738 | public static function getKnownSegmentsToArchive ( ) { $ cacheId = 'KnownSegmentsToArchive' ; $ cache = PiwikCache :: getTransientCache ( ) ; if ( $ cache -> contains ( $ cacheId ) ) { return $ cache -> fetch ( $ cacheId ) ; } $ segments = Config :: getInstance ( ) -> Segments ; $ segmentsToProcess = isset ( $ segments... | Returns every stored segment to pre - process for each site during cron archiving . |
23,739 | public static function getKnownSegmentsToArchiveForSite ( $ idSite ) { $ cacheId = 'KnownSegmentsToArchiveForSite' . $ idSite ; $ cache = PiwikCache :: getTransientCache ( ) ; if ( $ cache -> contains ( $ cacheId ) ) { return $ cache -> fetch ( $ cacheId ) ; } $ segments = array ( ) ; Piwik :: postEvent ( 'Segments.get... | Returns the list of stored segments to pre - process for an individual site when executing cron archiving . |
23,740 | public static function getWebsitesCountToDisplay ( ) { $ count = max ( Config :: getInstance ( ) -> General [ 'site_selector_max_sites' ] , Config :: getInstance ( ) -> General [ 'autocomplete_min_sites' ] ) ; return ( int ) $ count ; } | Number of websites to show in the Website selector |
23,741 | public static function isUniqueVisitorsEnabled ( $ periodLabel ) { $ generalSettings = Config :: getInstance ( ) -> General ; $ settingName = "enable_processing_unique_visitors_$periodLabel" ; $ result = ! empty ( $ generalSettings [ $ settingName ] ) && $ generalSettings [ $ settingName ] == 1 ; if ( ( $ periodLabel =... | Returns true if unique visitors should be processed for the given period type . |
23,742 | public static function checkPiwikServerWorking ( $ piwikServerUrl , $ acceptInvalidSSLCertificates = false ) { try { $ fetched = Http :: sendHttpRequestBy ( 'curl' , $ piwikServerUrl , $ timeout = 45 , $ userAgent = null , $ destinationPath = null , $ file = null , $ followDepth = 0 , $ acceptLanguage = false , $ accep... | Returns true if the Piwik server appears to be working . |
23,743 | public function getLogTable ( $ tableNameWithoutPrefix ) { foreach ( $ this -> getAllLogTables ( ) as $ table ) { if ( $ table -> getName ( ) === $ tableNameWithoutPrefix ) { return $ table ; } } } | Get an instance of a specific log table if such a log table exists . |
23,744 | public function getAllLogTables ( ) { if ( ! isset ( $ this -> tablesCache ) ) { $ tables = $ this -> pluginManager -> findMultipleComponents ( 'Tracker' , 'Piwik\\Tracker\\LogTable' ) ; $ logTables = array ( ) ; Piwik :: postEvent ( 'LogTables.addLogTables' , array ( & $ logTables ) ) ; foreach ( $ tables as $ table )... | Get all log table instances defined by any activated and loaded plugin . The returned tables are not sorted in any order . |
23,745 | public function onExistingVisit ( Request $ request , Visitor $ visitor , $ action ) { if ( empty ( $ action ) ) { return false ; } return $ visitor -> getVisitorColumn ( $ this -> columnName ) + 1 ; } | The onExistingVisit method is triggered when a visitor was recognized meaning it is not a new visitor . If you want you can overwrite any previous value set by the event onNewVisit . By returning boolean false no value will be updated . If you do not want to perform any action on a new visit you can just remove this me... |
23,746 | public function getAllInstances ( ) { $ cacheId = CacheId :: pluginAware ( 'ProfileSummaries' ) ; $ cache = Cache :: getTransientCache ( ) ; if ( ! $ cache -> contains ( $ cacheId ) ) { $ instances = [ ] ; Piwik :: postEvent ( 'Live.addProfileSummaries' , array ( & $ instances ) ) ; foreach ( $ this -> getAllProfileSum... | Returns all available profile summaries |
23,747 | public function getCurrencyList ( ) { if ( $ this -> currencyList === null ) { $ this -> currencyList = require __DIR__ . '/../Resources/currencies.php' ; $ custom = Config :: getInstance ( ) -> General [ 'currencies' ] ; foreach ( $ custom as $ code => $ name ) { $ this -> currencyList [ $ code ] = array ( $ code , $ ... | Returns the list of all known currency symbols . |
23,748 | public static function splitMessageStruct ( $ message , $ boundary , $ EOL = Zend_Mime :: LINEEND ) { $ parts = self :: splitMime ( $ message , $ boundary ) ; if ( count ( $ parts ) <= 0 ) { return null ; } $ result = array ( ) ; foreach ( $ parts as $ part ) { self :: splitMessage ( $ part , $ headers , $ body , $ EOL... | decodes a mime encoded String and returns a struct of parts with header and body |
23,749 | public static function splitHeaderField ( $ field , $ wantedPart = null , $ firstName = 0 ) { $ wantedPart = strtolower ( $ wantedPart ) ; $ firstName = strtolower ( $ firstName ) ; if ( $ firstName === $ wantedPart ) { $ field = strtok ( $ field , ';' ) ; return $ field [ 0 ] == '"' ? substr ( $ field , 1 , - 1 ) : $ ... | split a header field like content type in its different parts |
23,750 | public function onVisitProcessed ( OutputInterface $ output ) { ++ $ this -> processed ; $ percent = ceil ( $ this -> processed / $ this -> amountOfVisits * 100 ) ; if ( $ percent > $ this -> processedPercent && $ percent % $ this -> percentStep === 0 ) { $ output -> writeln ( sprintf ( '%d%% processed. <comment>%s</co... | Print information about progress . |
23,751 | private function paintMessage ( $ message ) { $ this -> TCPDF -> SetFont ( $ this -> reportFont , $ this -> reportFontStyle , $ this -> reportSimpleFontSize ) ; $ this -> TCPDF -> SetTextColor ( $ this -> reportTextColor [ 0 ] , $ this -> reportTextColor [ 1 ] , $ this -> reportTextColor [ 2 ] ) ; $ message = $ this ->... | Prints a message |
23,752 | public function getAvailableRoles ( ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ response = array ( ) ; foreach ( $ this -> roleProvider -> getAllRoles ( ) as $ role ) { $ response [ ] = array ( 'id' => $ role -> getId ( ) , 'name' => $ role -> getName ( ) , 'description' => $ role -> getDescription ( ) , 'helpUrl'... | Get the list of all available roles . It does not return the super user role and neither the noaccess role . |
23,753 | public function getAvailableCapabilities ( ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; $ response = array ( ) ; foreach ( $ this -> capabilityProvider -> getAllCapabilities ( ) as $ capability ) { $ response [ ] = array ( 'id' => $ capability -> getId ( ) , 'name' => $ capability -> getName ( ) , 'description' => $ ... | Get the list of all available capabilities . |
23,754 | public function setUserPreference ( $ userLogin , $ preferenceName , $ preferenceValue ) { Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ userLogin ) ; Option :: set ( $ this -> getPreferenceId ( $ userLogin , $ preferenceName ) , $ preferenceValue ) ; } | Sets a user preference |
23,755 | public function getUserPreference ( $ userLogin , $ preferenceName ) { Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ userLogin ) ; $ optionValue = $ this -> getPreferenceValue ( $ userLogin , $ preferenceName ) ; if ( $ optionValue !== false ) { return $ optionValue ; } return $ this -> getDefaultUserPreference (... | Gets a user preference |
23,756 | public function initUserPreferenceWithDefault ( $ userLogin , $ preferenceName ) { Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ userLogin ) ; $ optionValue = $ this -> getPreferenceValue ( $ userLogin , $ preferenceName ) ; if ( $ optionValue === false ) { $ defaultValue = $ this -> getDefaultUserPreference ( $ ... | Sets a user preference in the DB using the preference s default value . |
23,757 | public function getAllUsersPreferences ( array $ preferenceNames ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ userPreferences = array ( ) ; foreach ( $ preferenceNames as $ preferenceName ) { $ optionNameMatchAllUsers = $ this -> getPreferenceId ( '%' , $ preferenceName ) ; $ preferences = Option :: getLike ( $ opt... | Returns an array of Preferences |
23,758 | public function addUser ( $ userLogin , $ password , $ email , $ alias = false , $ _isPasswordHashed = false , $ initialIdSite = null ) { Piwik :: checkUserHasSomeAdminAccess ( ) ; if ( ! Piwik :: hasUserSuperUserAccess ( ) ) { if ( empty ( $ initialIdSite ) ) { throw new \ Exception ( Piwik :: translate ( "UsersManage... | Add a user in the database . A user is defined by - a login that has to be unique and valid - a password that has to be valid - an alias - an email that has to be in a correct format |
23,759 | public function getUsersHavingSuperUserAccess ( ) { Piwik :: checkUserIsNotAnonymous ( ) ; $ users = $ this -> model -> getUsersHavingSuperUserAccess ( ) ; $ users = $ this -> enrichUsers ( $ users ) ; return $ users ; } | Returns a list of all Super Users containing there userLogin and email address . |
23,760 | public function regenerateTokenAuth ( $ userLogin ) { $ this -> checkUserIsNotAnonymous ( $ userLogin ) ; Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ userLogin ) ; $ this -> model -> updateUserTokenAuth ( $ userLogin , $ this -> createTokenAuth ( $ userLogin ) ) ; } | Regenerate the token_auth associated with a user . |
23,761 | public function deleteUser ( $ userLogin ) { Piwik :: checkUserHasSuperUserAccess ( ) ; $ this -> checkUserIsNotAnonymous ( $ userLogin ) ; $ this -> checkUserExist ( $ userLogin ) ; if ( $ this -> isUserTheOnlyUserHavingSuperUserAccess ( $ userLogin ) ) { $ message = Piwik :: translate ( "UsersManager_ExceptionDeleteO... | Delete one or more users and all its access given its login . |
23,762 | public function userExists ( $ userLogin ) { if ( $ userLogin == 'anonymous' ) { return true ; } Piwik :: checkUserIsNotAnonymous ( ) ; Piwik :: checkUserHasSomeViewAccess ( ) ; if ( $ userLogin == Piwik :: getCurrentUserLogin ( ) ) { return true ; } return $ this -> model -> userExists ( $ userLogin ) ; } | Returns true if the given userLogin is known in the database |
23,763 | public function getUserLoginFromUserEmail ( $ userEmail ) { Piwik :: checkUserIsNotAnonymous ( ) ; Piwik :: checkUserHasSomeAdminAccess ( ) ; $ this -> checkUserEmailExists ( $ userEmail ) ; $ user = $ this -> model -> getUserByEmail ( $ userEmail ) ; return $ user [ 'login' ] ; } | Returns the first login name of an existing user that has the given email address . If no user can be found for this user an error will be returned . |
23,764 | public function setUserAccess ( $ userLogin , $ access , $ idSites ) { if ( $ access != 'noaccess' ) { $ this -> checkAccessType ( $ access ) ; } $ idSites = $ this -> getIdSitesCheckAdminAccess ( $ idSites ) ; if ( $ userLogin === 'anonymous' && ( is_array ( $ access ) || ! in_array ( $ access , array ( 'view' , 'noac... | Set an access level to a given user for a list of websites ID . |
23,765 | public function removeCapabilities ( $ userLogin , $ capabilities , $ idSites ) { $ idSites = $ this -> getIdSitesCheckAdminAccess ( $ idSites ) ; $ this -> checkUserExists ( $ userLogin ) ; if ( ! is_array ( $ capabilities ) ) { $ capabilities = array ( $ capabilities ) ; } foreach ( $ capabilities as $ capability ) {... | Removes the given capabilities from the given user for the given sites . The capability will be only removed if it is actually granted as a separate capability . If the user has a role that includes a specific capability for example Admin then the capability will not be removed because the assigned role will always inc... |
23,766 | public function createTokenAuth ( $ userLogin ) { return md5 ( $ userLogin . microtime ( true ) . Common :: generateUniqId ( ) . SettingsPiwik :: getSalt ( ) ) ; } | Generates a new random authentication token . |
23,767 | public function getTokenAuth ( $ userLogin , $ md5Password ) { UsersManager :: checkPasswordHash ( $ md5Password , Piwik :: translate ( 'UsersManager_ExceptionPasswordMD5HashExpected' ) ) ; $ user = $ this -> model -> getUser ( $ userLogin ) ; if ( empty ( $ user ) || ! $ this -> password -> verify ( $ md5Password , $ ... | Returns the user s API token . |
23,768 | public function getAvailableResources ( ) { $ cache = Cache :: getTransientCache ( ) ; $ cacheId = 'transifex_resources_' . $ this -> projectSlug ; $ resources = $ cache -> fetch ( $ cacheId ) ; if ( empty ( $ resources ) ) { $ apiPath = 'project/' . $ this -> projectSlug . '/resources' ; $ resources = $ this -> getApi... | Returns all resources available on Transifex project |
23,769 | public function resourceExists ( $ resource ) { $ resources = $ this -> getAvailableResources ( ) ; foreach ( $ resources as $ res ) { if ( $ res -> slug == $ resource ) { return true ; } } return false ; } | Checks if the given resource exists in Transifex project |
23,770 | public function getAvailableLanguageCodes ( ) { $ cache = Cache :: getTransientCache ( ) ; $ cacheId = 'transifex_languagescodes_' . $ this -> projectSlug ; $ languageCodes = $ cache -> fetch ( $ cacheId ) ; if ( empty ( $ languageCodes ) ) { $ apiData = $ this -> getApiResults ( 'project/' . $ this -> projectSlug . '/... | Returns all language codes the transifex project is available for |
23,771 | public function getTranslations ( $ resource , $ language , $ raw = false ) { if ( $ this -> resourceExists ( $ resource ) ) { $ apiPath = 'project/' . $ this -> projectSlug . '/resource/' . $ resource . '/translation/' . $ language . '/?mode=onlytranslated&file' ; return $ this -> getApiResults ( $ apiPath , $ raw ) ;... | Return the translations for the given resource and language |
23,772 | protected function getApiResults ( $ apiPath , $ raw = false ) { $ apiUrl = $ this -> apiUrl . $ apiPath ; $ response = Http :: sendHttpRequest ( $ apiUrl , 1000 , null , null , 5 , false , false , true , 'GET' , $ this -> username , $ this -> password ) ; $ httpStatus = $ response [ 'status' ] ; $ response = $ respons... | Returns response for API request with given path |
23,773 | public function getRowEvolutionGraph ( $ graphType = false , $ metrics = false ) { $ view = Factory :: build ( $ graphType ? : $ this -> graphType , $ this -> apiMethod , $ controllerAction = 'CoreHome.getRowEvolutionGraph' , $ forceDefault = true ) ; $ view -> setDataTable ( $ this -> dataTable ) ; if ( ! empty ( $ th... | Generic method to get an evolution graph or a sparkline for the row evolution popover . Do as much as possible from outside the controller . |
23,774 | protected function getSparkline ( $ metric ) { $ view = $ this -> getRowEvolutionGraph ( $ graphType = 'sparkline' , $ metrics = array ( $ metric => $ metric ) ) ; ob_start ( ) ; $ view -> render ( ) ; $ spark = ob_get_contents ( ) ; ob_end_clean ( ) ; Common :: sendHeader ( 'Content-type: text/html' ) ; $ spark = base... | Get the img tag for a sparkline showing a single metric |
23,775 | public function isTokenValid ( $ token , $ user , $ keySuffix ) { $ now = time ( ) ; for ( $ i = 0 ; $ i <= 24 ; $ i ++ ) { $ generatedToken = $ this -> generatePasswordResetToken ( $ user , $ keySuffix , $ now + $ i * 60 * 60 ) ; if ( $ generatedToken === $ token ) { return true ; } } return false ; } | Returns true if a reset token is valid false if otherwise . A reset token is valid if it exists and has not expired . |
23,776 | public function generatePasswordResetToken ( $ user , $ keySuffix , $ expiryTimestamp = null ) { if ( ! $ expiryTimestamp ) { $ expiryTimestamp = $ this -> getDefaultExpiryTime ( ) ; } $ expiry = strftime ( '%Y%m%d%H' , $ expiryTimestamp ) ; $ token = $ this -> generateSecureHash ( $ expiry . $ user [ 'login' ] . $ use... | Generate a password reset token . Expires in 24 hours from the beginning of the current hour . |
23,777 | protected function generateSecureHash ( $ hashIdentifier , $ data ) { $ halfDataLen = strlen ( $ data ) / 2 ; $ stringToHash = $ hashIdentifier . substr ( $ data , 0 , $ halfDataLen ) . $ this -> getSalt ( ) . substr ( $ data , $ halfDataLen ) ; return $ this -> hashData ( $ stringToHash ) ; } | Generates a hash using a hash identifier and some data to hash . The hash identifier is a string that differentiates the hash in some way . |
23,778 | protected function getUserInformation ( $ loginOrMail ) { $ userModel = new Model ( ) ; $ user = null ; if ( $ userModel -> userExists ( $ loginOrMail ) ) { $ user = $ userModel -> getUser ( $ loginOrMail ) ; } else if ( $ userModel -> userEmailExists ( $ loginOrMail ) ) { $ user = $ userModel -> getUserByEmail ( $ log... | Returns user information based on a login or email . |
23,779 | protected function checkPasswordHash ( $ passwordHash ) { $ hashInfo = $ this -> passwordHelper -> info ( $ passwordHash ) ; if ( ! isset ( $ hashInfo [ 'algo' ] ) || 0 >= $ hashInfo [ 'algo' ] ) { throw new Exception ( Piwik :: translate ( 'Login_ExceptionPasswordMD5HashExpected' ) ) ; } } | Checks the password hash that was retrieved from the Option table . Used as a sanity check when finishing the reset password process . If a password is obviously malformed changing a user s password to it will keep the user from being able to login again . |
23,780 | private function sendEmailConfirmationLink ( $ user , $ keySuffix ) { $ login = $ user [ 'login' ] ; $ email = $ user [ 'email' ] ; $ resetToken = $ this -> generatePasswordResetToken ( $ user , $ keySuffix ) ; $ confirmPasswordModule = $ this -> confirmPasswordModule ; $ confirmPasswordAction = $ this -> confirmPasswo... | Sends email confirmation link for a password reset request . |
23,781 | private function savePasswordResetInfo ( $ login , $ newPassword , $ keySuffix ) { $ optionName = $ this -> getPasswordResetInfoOptionName ( $ login ) ; $ optionData = [ 'hash' => $ this -> passwordHelper -> hash ( UsersManager :: getPasswordHash ( $ newPassword ) ) , 'keySuffix' => $ keySuffix , ] ; $ optionData = jso... | Stores password reset info for a specific login . |
23,782 | private function getPasswordToResetTo ( $ login ) { $ optionName = self :: getPasswordResetInfoOptionName ( $ login ) ; $ optionValue = Option :: get ( $ optionName ) ; $ optionValue = json_decode ( $ optionValue , $ isAssoc = true ) ; return $ optionValue ; } | Gets password hash stored in password reset info . |
23,783 | public function getActionReferenceColumnsByTable ( ) { $ result = array ( 'log_link_visit_action' => array ( 'idaction_url' , 'idaction_url_ref' , 'idaction_name_ref' ) , 'log_conversion' => array ( 'idaction_url' ) , 'log_visit' => array ( 'visit_exit_idaction_url' , 'visit_exit_idaction_name' , 'visit_entry_idaction_... | Returns a list of idaction column names organized by table name . Uses dimension metadata to find idaction columns dynamically . |
23,784 | public function addReport ( $ idSite , $ description , $ period , $ hour , $ reportType , $ reportFormat , $ reports , $ parameters , $ idSegment = false , $ evolutionPeriodFor = 'prev' , $ evolutionPeriodN = null ) { Piwik :: checkUserIsNotAnonymous ( ) ; Piwik :: checkUserHasViewAccess ( $ idSite ) ; $ currentUser = ... | Creates a new report and schedules it . |
23,785 | public function updateReport ( $ idReport , $ idSite , $ description , $ period , $ hour , $ reportType , $ reportFormat , $ reports , $ parameters , $ idSegment = false , $ evolutionPeriodFor = 'prev' , $ evolutionPeriodN = null ) { Piwik :: checkUserIsNotAnonymous ( ) ; Piwik :: checkUserHasViewAccess ( $ idSite ) ; ... | Updates an existing report . |
23,786 | public function deleteReport ( $ idReport ) { $ APIScheduledReports = $ this -> getReports ( $ idSite = false , $ periodSearch = false , $ idReport ) ; $ report = reset ( $ APIScheduledReports ) ; Piwik :: checkUserHasSuperUserAccessOrIsTheUser ( $ report [ 'login' ] ) ; $ this -> getModel ( ) -> updateReport ( $ idRep... | Deletes a specific report |
23,787 | public function getReports ( $ idSite = false , $ period = false , $ idReport = false , $ ifSuperUserReturnOnlySuperUserReports = false , $ idSegment = false ) { Piwik :: checkUserHasSomeViewAccess ( ) ; $ cacheKey = ( int ) $ idSite . '.' . ( string ) $ period . '.' . ( int ) $ idReport . '.' . ( int ) $ ifSuperUserRe... | Returns the list of reports matching the passed parameters |
23,788 | public static function getCurrentUrl ( ) { return self :: getCurrentScheme ( ) . '://' . self :: getCurrentHost ( ) . self :: getCurrentScriptName ( false ) . self :: getCurrentQueryString ( ) ; } | Returns the current URL . |
23,789 | public static function getCurrentUrlWithoutQueryString ( $ checkTrustedHost = true ) { return self :: getCurrentScheme ( ) . '://' . self :: getCurrentHost ( $ default = 'unknown' , $ checkTrustedHost ) . self :: getCurrentScriptName ( false ) ; } | Returns the current URL without the query string . |
23,790 | public static function getCurrentScriptPath ( ) { $ queryString = self :: getCurrentScriptName ( ) ; $ urlDir = dirname ( $ queryString . 'x' ) ; $ urlDir = str_replace ( '\\' , '/' , $ urlDir ) ; if ( strlen ( $ urlDir ) > 1 ) { $ urlDir .= '/' ; } return $ urlDir ; } | Returns the path to the script being executed . The script file name is not included . |
23,791 | public static function getCurrentScriptName ( $ removePathInfo = true ) { $ url = '' ; if ( isset ( Config :: getInstance ( ) -> General [ 'proxy_uri_header' ] ) && Config :: getInstance ( ) -> General [ 'proxy_uri_header' ] == 1 && ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_URI' ] ) ) { $ url .= $ _SERVER [ 'HTTP_X_FORWA... | Returns the path to the script being executed . Includes the script file name . |
23,792 | public static function getQueryStringFromParameters ( $ parameters ) { $ query = '' ; foreach ( $ parameters as $ name => $ value ) { if ( is_null ( $ value ) || $ value === false ) { continue ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ theValue ) { $ query .= $ name . "[]=" . $ theValue . "&" ; } } else {... | Converts an array of parameters name = > value mappings to a query string . Values must already be URL encoded before you call this function . |
23,793 | public static function redirectToReferrer ( ) { $ referrer = self :: getReferrer ( ) ; if ( $ referrer !== false ) { self :: redirectToUrl ( $ referrer ) ; } self :: redirectToUrl ( self :: getCurrentUrlWithoutQueryString ( ) ) ; } | Redirects the user to the referrer . If no referrer exists the user is redirected to the current URL without query string . |
23,794 | public static function redirectToHttps ( ) { if ( ProxyHttp :: isHttps ( ) ) { return ; } $ url = self :: getCurrentUrl ( ) ; $ url = str_replace ( "http://" , "https://" , $ url ) ; self :: redirectToUrl ( $ url ) ; } | If the page is using HTTP redirect to the same page over HTTPS |
23,795 | public static function isLocalUrl ( $ url ) { if ( empty ( $ url ) ) { return true ; } $ requestUri = isset ( $ _SERVER [ 'SCRIPT_URI' ] ) ? $ _SERVER [ 'SCRIPT_URI' ] : '' ; $ parseRequest = @ parse_url ( $ requestUri ) ; $ hosts = array ( self :: getHost ( ) , self :: getCurrentHost ( ) ) ; if ( ! empty ( $ parseRequ... | Returns true if the URL points to something on the same host false if otherwise . |
23,796 | public static function isLocalHost ( $ host ) { if ( empty ( $ host ) ) { return false ; } $ hostWithoutPort = explode ( ':' , $ host ) ; array_pop ( $ hostWithoutPort ) ; $ hostWithoutPort = implode ( ':' , $ hostWithoutPort ) ; $ localHostnames = Url :: getLocalHostnames ( ) ; return in_array ( $ host , $ localHostna... | Checks whether the given host is a local host like 127 . 0 . 0 . 1 or localhost . |
23,797 | public static function getHostFromUrl ( $ url ) { $ parsedUrl = parse_url ( $ url ) ; if ( empty ( $ parsedUrl [ 'host' ] ) ) { return ; } return Common :: mb_strtolower ( $ parsedUrl [ 'host' ] ) ; } | Returns the host part of any valid URL . |
23,798 | private function sanitizeRequest ( ) { if ( isset ( $ this -> request [ 'label' ] ) && ! empty ( $ this -> request [ 'label' ] ) && isset ( $ this -> request [ 'expanded' ] ) && $ this -> request [ 'expanded' ] ) { unset ( $ this -> request [ 'expanded' ] ) ; } } | Make sure that the request contains no logical errors |
23,799 | public function process ( ) { $ outputFormat = strtolower ( Common :: getRequestVar ( 'format' , 'xml' , 'string' , $ this -> request ) ) ; $ disablePostProcessing = $ this -> shouldDisablePostProcessing ( ) ; $ response = new ResponseBuilder ( $ outputFormat , $ this -> request ) ; if ( $ disablePostProcessing ) { $ r... | Dispatches the API request to the appropriate API method and returns the result after post - processing . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.