idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
49,000 | public function debug ( ) { $ info = array ( ) ; $ metadata = $ this -> getMetadata ( ) ; $ referenceFields = array ( ) ; foreach ( array_merge ( $ metadata [ 'referencesOne' ] , $ metadata [ 'referencesMany' ] ) as $ name => $ reference ) { $ referenceFields [ ] = $ reference [ 'field' ] ; } foreach ( $ metadata [ 'fields' ] as $ name => $ field ) { if ( in_array ( $ name , $ referenceFields ) ) { continue ; } $ info [ 'fields' ] [ $ name ] = $ this -> { 'get' . ucfirst ( $ name ) } ( ) ; } foreach ( $ metadata [ 'referencesOne' ] as $ name => $ referenceOne ) { $ info [ 'referencesOne' ] [ $ name ] = $ this -> { 'get' . ucfirst ( $ referenceOne [ 'field' ] ) } ( ) ; } foreach ( $ metadata [ 'referencesMany' ] as $ name => $ referenceMany ) { $ info [ 'referencesMany' ] [ $ name ] = $ this -> { 'get' . ucfirst ( $ referenceMany [ 'field' ] ) } ( ) ; } foreach ( $ metadata [ 'embeddedsOne' ] as $ name => $ embeddedOne ) { $ embedded = $ this -> { 'get' . ucfirst ( $ name ) } ( ) ; $ info [ 'embeddedsOne' ] [ $ name ] = $ embedded ? $ embedded -> debug ( ) : null ; } foreach ( $ metadata [ 'embeddedsMany' ] as $ name => $ embeddedMany ) { $ info [ 'embeddedsMany' ] [ $ name ] = array ( ) ; foreach ( $ this -> { 'get' . ucfirst ( $ name ) } ( ) as $ key => $ value ) { $ info [ 'embeddedsMany' ] [ $ name ] [ $ key ] = $ value -> debug ( ) ; } } return $ info ; } | Returns an array with the document info to debug . |
49,001 | static public function has ( $ object , $ key ) { $ oid = spl_object_hash ( $ object ) ; return isset ( static :: $ archive [ $ oid ] ) && ( isset ( static :: $ archive [ $ oid ] [ $ key ] ) || array_key_exists ( $ key , static :: $ archive [ $ oid ] ) ) ; } | Returns if an object has a key in the archive . |
49,002 | static public function & getByRef ( $ object , $ key , $ default = null ) { $ oid = spl_object_hash ( $ object ) ; if ( ! isset ( static :: $ archive [ $ oid ] [ $ key ] ) ) { static :: $ archive [ $ oid ] [ $ key ] = $ default ; } return static :: $ archive [ $ oid ] [ $ key ] ; } | Returns an object key by reference . It creates the key if the key does not exist . |
49,003 | static public function getOrDefault ( $ object , $ key , $ default ) { $ oid = spl_object_hash ( $ object ) ; if ( isset ( static :: $ archive [ $ oid ] ) && ( isset ( static :: $ archive [ $ oid ] [ $ key ] ) || array_key_exists ( $ key , static :: $ archive [ $ oid ] ) ) ) { return static :: $ archive [ $ oid ] [ $ key ] ; } return $ default ; } | Returns an object key or returns a default value otherwise . |
49,004 | public function setRootAndPath ( Document $ root , $ path ) { Archive :: set ( $ this , 'root_and_path' , array ( 'root' => $ root , 'path' => $ path ) ) ; if ( isset ( $ this -> data [ 'embeddedsOne' ] ) ) { foreach ( $ this -> data [ 'embeddedsOne' ] as $ name => $ embedded ) { $ embedded -> setRootAndPath ( $ root , $ path . '.' . $ name ) ; } } if ( isset ( $ this -> data [ 'embeddedsMany' ] ) ) { foreach ( $ this -> data [ 'embeddedsMany' ] as $ name => $ embedded ) { $ embedded -> setRootAndPath ( $ root , $ path . '.' . $ name ) ; } } } | Set the root and path of the embedded document . |
49,005 | public function isEmbeddedOneChangedInParent ( ) { if ( ! $ rap = $ this -> getRootAndPath ( ) ) { return false ; } if ( $ rap [ 'root' ] instanceof EmbeddedGroup ) { return false ; } $ exPath = explode ( '.' , $ rap [ 'path' ] ) ; unset ( $ exPath [ count ( $ exPath ) - 1 ] ) ; $ parentDocument = $ rap [ 'root' ] ; foreach ( $ exPath as $ embedded ) { $ parentDocument = $ parentDocument -> { 'get' . ucfirst ( $ embedded ) } ( ) ; if ( $ parentDocument instanceof EmbeddedGroup ) { return false ; } } $ rap = $ this -> getRootAndPath ( ) ; $ exPath = explode ( '.' , $ rap [ 'path' ] ) ; $ name = $ exPath [ count ( $ exPath ) - 1 ] ; return $ parentDocument -> isEmbeddedOneChanged ( $ name ) ; } | Returns if the embedded document is an embedded one document changed . |
49,006 | public function getCollection ( ) { if ( ! $ this -> collection ) { if ( $ this -> isFile ) { $ this -> collection = $ this -> getConnection ( ) -> getMongoDB ( ) -> getGridFS ( $ this -> collectionName ) ; } else { $ this -> collection = $ this -> getConnection ( ) -> getMongoDB ( ) -> selectCollection ( $ this -> collectionName ) ; } } return $ this -> collection ; } | Returns the collection . |
49,007 | public function createQuery ( array $ criteria = array ( ) ) { $ class = $ this -> documentClass . 'Query' ; $ query = new $ class ( $ this ) ; $ query -> criteria ( $ criteria ) ; return $ query ; } | Create a query for the repository document class . |
49,008 | public function idsToMongo ( array $ ids ) { foreach ( $ ids as & $ id ) { $ id = $ this -> idToMongo ( $ id ) ; } return $ ids ; } | Converts an array of ids to use in Mongo . |
49,009 | public function findOneById ( $ id ) { $ id = $ this -> idToMongo ( $ id ) ; if ( $ this -> identityMap -> has ( $ id ) ) { return $ this -> identityMap -> get ( $ id ) ; } return $ this -> createQuery ( array ( '_id' => $ id ) ) -> one ( ) ; } | Returns one document by id . |
49,010 | public function update ( array $ query , array $ newObject , array $ options = array ( ) ) { return $ this -> getCollection ( ) -> update ( $ query , $ newObject , $ options ) ; } | Updates documents . |
49,011 | public function group ( $ keys , array $ initial , $ reduce , array $ options = array ( ) ) { return $ this -> getCollection ( ) -> group ( $ keys , $ initial , $ reduce , $ options ) ; } | Shortcut to the collection group method . |
49,012 | public function isPendingForPersist ( Document $ document ) { return isset ( $ this -> persist [ get_class ( $ document ) ] [ spl_object_hash ( $ document ) ] ) ; } | Returns if a document is pending for persist . |
49,013 | public function isPendingForRemove ( Document $ document ) { return isset ( $ this -> remove [ get_class ( $ document ) ] [ spl_object_hash ( $ document ) ] ) ; } | Returns if a document is pending for remove . |
49,014 | public function getFieldsCache ( ) { $ cache = $ this -> repository -> getMandango ( ) -> getCache ( ) -> get ( $ this -> hash ) ; return ( $ cache && isset ( $ cache [ 'fields' ] ) ) ? $ cache [ 'fields' ] : null ; } | Returns the fields in cache . |
49,015 | public function mergeCriteria ( array $ criteria ) { $ this -> criteria = null === $ this -> criteria ? $ criteria : array_merge ( $ this -> criteria , $ criteria ) ; return $ this ; } | Merges a criteria with the current one . |
49,016 | public function references ( $ references ) { if ( null !== $ references && ! is_array ( $ references ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The references "%s" are not valid.' , $ references ) ) ; } $ this -> references = $ references ; return $ this ; } | Set the references . |
49,017 | public function sort ( $ sort ) { if ( null !== $ sort && ! is_array ( $ sort ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The sort "%s" is not valid.' , $ sort ) ) ; } $ this -> sort = $ sort ; return $ this ; } | Set the sort . |
49,018 | public function skip ( $ skip ) { if ( null !== $ skip ) { if ( ! is_numeric ( $ skip ) || $ skip != ( int ) $ skip ) { throw new \ InvalidArgumentException ( 'The skip is not valid.' ) ; } $ skip = ( int ) $ skip ; } $ this -> skip = $ skip ; return $ this ; } | Set the skip . |
49,019 | public function batchSize ( $ batchSize ) { if ( null !== $ batchSize ) { if ( ! is_numeric ( $ batchSize ) || $ batchSize != ( int ) $ batchSize ) { throw new \ InvalidArgumentException ( 'The batchSize is not valid.' ) ; } $ batchSize = ( int ) $ batchSize ; } $ this -> batchSize = $ batchSize ; return $ this ; } | Set the batch size . |
49,020 | public function hint ( $ hint ) { if ( null !== $ hint && ! is_array ( $ hint ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The hint "%s" is not valid.' , $ hint ) ) ; } $ this -> hint = $ hint ; return $ this ; } | Set the hint . |
49,021 | public function slaveOkay ( $ okay = true ) { if ( null !== $ okay ) { if ( ! is_bool ( $ okay ) ) { throw new \ InvalidArgumentException ( 'The slave okay is not a boolean.' ) ; } } $ this -> slaveOkay = $ okay ; return $ this ; } | Sets the slave okay . |
49,022 | public function one ( ) { $ currentLimit = $ this -> limit ; $ results = $ this -> limit ( 1 ) -> all ( ) ; $ this -> limit = $ currentLimit ; return $ results ? array_shift ( $ results ) : null ; } | Returns one result . |
49,023 | public function createCursor ( ) { $ cursor = $ this -> repository -> getCollection ( ) -> find ( $ this -> criteria , $ this -> fields ) ; if ( null !== $ this -> sort ) { $ cursor -> sort ( $ this -> sort ) ; } if ( null !== $ this -> limit ) { $ cursor -> limit ( $ this -> limit ) ; } if ( null !== $ this -> skip ) { $ cursor -> skip ( $ this -> skip ) ; } if ( null !== $ this -> batchSize ) { $ cursor -> batchSize ( $ this -> batchSize ) ; } if ( null !== $ this -> hint ) { $ cursor -> hint ( $ this -> hint ) ; } if ( null !== $ this -> slaveOkay ) { $ cursor -> slaveOkay ( $ this -> slaveOkay ) ; } if ( $ this -> snapshot ) { $ cursor -> snapshot ( ) ; } if ( null !== $ this -> timeout ) { $ cursor -> timeout ( $ this -> timeout ) ; } return $ cursor ; } | Create a cursor with the data of the query . |
49,024 | public function stop ( ) { $ time = ( int ) round ( ( microtime ( true ) - $ this -> time ) * 1000 ) ; $ this -> time = null ; return $ time ; } | Stop of count the time and returns the result . |
49,025 | public function setConnection ( $ name , ConnectionInterface $ connection ) { if ( null !== $ this -> loggerCallable ) { $ connection -> setLoggerCallable ( $ this -> loggerCallable ) ; $ connection -> setLogDefault ( array ( 'connection' => $ name ) ) ; } else { $ connection -> setLoggerCallable ( null ) ; } $ this -> connections [ $ name ] = $ connection ; } | Set a connection . |
49,026 | public function setConnections ( array $ connections ) { $ this -> connections = array ( ) ; foreach ( $ connections as $ name => $ connection ) { $ this -> setConnection ( $ name , $ connection ) ; } } | Set the connections . |
49,027 | public function removeConnection ( $ name ) { if ( ! $ this -> hasConnection ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The connection "%s" does not exists.' , $ name ) ) ; } unset ( $ this -> connections [ $ name ] ) ; } | Remove a connection . |
49,028 | public function getDefaultConnection ( ) { if ( null === $ this -> defaultConnectionName ) { throw new \ RuntimeException ( 'There is not default connection name.' ) ; } if ( ! isset ( $ this -> connections [ $ this -> defaultConnectionName ] ) ) { throw new \ RuntimeException ( sprintf ( 'The default connection "%s" does not exists.' , $ this -> defaultConnectionName ) ) ; } return $ this -> connections [ $ this -> defaultConnectionName ] ; } | Returns the default connection . |
49,029 | public function getRepository ( $ documentClass ) { if ( ! isset ( $ this -> repositories [ $ documentClass ] ) ) { if ( ! $ this -> metadataFactory -> hasClass ( $ documentClass ) || ! $ this -> metadataFactory -> isDocumentClass ( $ documentClass ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The class "%s" is not a valid document class.' , $ documentClass ) ) ; } $ repositoryClass = $ documentClass . 'Repository' ; if ( ! class_exists ( $ repositoryClass ) ) { throw new \ RuntimeException ( sprintf ( 'The class "%s" does not exists.' , $ repositoryClass ) ) ; } $ this -> repositories [ $ documentClass ] = new $ repositoryClass ( $ this ) ; } return $ this -> repositories [ $ documentClass ] ; } | Returns repositories by document class . |
49,030 | public function all ( ) { $ documents = array_merge ( $ this -> getSaved ( ) , $ this -> getAdd ( ) ) ; foreach ( $ this -> getRemove ( ) as $ document ) { if ( false !== $ key = array_search ( $ document , $ documents ) ) { unset ( $ documents [ $ key ] ) ; } } return array_values ( $ documents ) ; } | Returns the saved + add - removed elements . |
49,031 | public function replace ( array $ documents ) { $ this -> clearAdd ( ) ; $ this -> clearRemove ( ) ; $ this -> remove ( $ this -> getSaved ( ) ) ; $ this -> add ( $ documents ) ; } | Replace all documents . |
49,032 | public function calculate ( $ price , $ unitTax , $ quantity = 0 ) { $ this -> Tax = $ unitTax * $ quantity ; $ this -> Total = $ this -> Tax + ( $ quantity * $ price ) ; return $ this ; } | Used to set the line item s values so that the total and tax add up correctly . |
49,033 | private function parseResponse ( $ rawResponse , $ headerSize ) { foreach ( self :: $ CONNECTION_ESTABLISHED_HEADERS as $ established_header ) { if ( stripos ( $ rawResponse , $ established_header ) !== false ) { $ rawResponse = str_ireplace ( $ established_header , '' , $ rawResponse ) ; if ( ! $ this -> needsCurlProxyFix ( ) ) { $ headerSize -= strlen ( $ established_header ) ; } break ; } } $ responseBody = substr ( $ rawResponse , $ headerSize ) ; return $ responseBody ; } | Returns the HTTP body from raw response . |
49,034 | private function customerToTransaction ( $ customer ) { $ transaction = [ 'Customer' => $ customer -> toArray ( ) , 'TransactionType' => TransactionType :: MOTO , ] ; foreach ( $ customer -> toArray ( ) as $ key => $ value ) { if ( $ key != 'TokenCustomerID' ) { $ transaction [ $ key ] = $ value ; } } return ClassValidator :: getInstance ( 'Eway\Rapid\Model\Transaction' , $ transaction ) ; } | Convert a Customer to a Transaction object for a create or update token transaction |
49,035 | public function log ( $ level , $ message , array $ context = array ( ) ) { if ( ! LogLevel :: isValidValue ( $ level ) ) { throw new \ InvalidArgumentException ( 'Invalid loge level: ' . $ level ) ; } $ timestamp = time ( ) ; $ log = sprintf ( '[%s] %s %s' , date ( 'Y-m-d H:i:s' , $ timestamp ) , strtoupper ( $ level ) , self :: interpolate ( $ message , $ context ) ) ; error_log ( $ log ) ; } | Logs with an arbitrary level . This logs to PHP s error log . |
49,036 | public static function createClient ( $ apiKey , $ apiPassword , $ endpoint = ClientContract :: MODE_SANDBOX , $ logger = null ) { return new Client ( $ apiKey , $ apiPassword , $ endpoint , $ logger ) ; } | Static method to create a new Rapid Client object configured to communicate with a specific instance of the Rapid API . |
49,037 | public static function getMessage ( $ errorCode , $ language = 'en' ) { self :: initMessages ( ) ; $ messagesByLanguage = self :: getMessagesByLanguage ( $ language ) ; if ( ! array_key_exists ( $ errorCode , $ messagesByLanguage ) ) { return $ errorCode ; } return $ messagesByLanguage [ $ errorCode ] ; } | This static method provides a message suitable for display to a user corresponding to a given Rapid Code & language . |
49,038 | public function checkConnection ( $ socket ) { if ( DIRECTORY_SEPARATOR === '\\' ) { Worker :: $ globalEvent -> del ( $ socket , EventInterface :: EV_EXCEPT ) ; } if ( $ address = stream_socket_get_name ( $ socket , true ) ) { Worker :: $ globalEvent -> del ( $ socket , EventInterface :: EV_WRITE ) ; stream_set_blocking ( $ socket , 0 ) ; if ( function_exists ( 'stream_set_read_buffer' ) ) { stream_set_read_buffer ( $ socket , 0 ) ; } if ( function_exists ( 'socket_import_stream' ) && $ this -> transport === 'tcp' ) { $ raw_socket = socket_import_stream ( $ socket ) ; socket_set_option ( $ raw_socket , SOL_SOCKET , SO_KEEPALIVE , 1 ) ; socket_set_option ( $ raw_socket , SOL_TCP , TCP_NODELAY , 1 ) ; } Worker :: $ globalEvent -> add ( $ socket , EventInterface :: EV_READ , array ( $ this , 'baseRead' ) ) ; if ( $ this -> _sendBuffer ) { Worker :: $ globalEvent -> add ( $ socket , EventInterface :: EV_WRITE , array ( $ this , 'baseWrite' ) ) ; } $ this -> _status = self :: STATUS_ESTABLISHED ; $ this -> _remoteAddress = $ address ; $ this -> _sslHandshakeCompleted = true ; if ( $ this -> onConnect ) { try { call_user_func ( $ this -> onConnect , $ this ) ; } catch ( \ Exception $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } catch ( \ Error $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } } if ( method_exists ( $ this -> protocol , 'onConnect' ) ) { try { call_user_func ( array ( $ this -> protocol , 'onConnect' ) , $ this ) ; } catch ( \ Exception $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } catch ( \ Error $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } } } else { $ this -> emitError ( WORKERMAN_CONNECT_FAIL , 'connect ' . $ this -> _remoteAddress . ' fail after ' . round ( microtime ( true ) - $ this -> _connectStartTime , 4 ) . ' seconds' ) ; if ( $ this -> _status === self :: STATUS_CLOSING ) { $ this -> destroy ( ) ; } if ( $ this -> _status === self :: STATUS_CLOSED ) { $ this -> onConnect = null ; } } } | Check connection is successfully established or faild . |
49,039 | public function add ( $ fd , $ flag , $ func , $ args = array ( ) ) { $ args = ( array ) $ args ; switch ( $ flag ) { case EventInterface :: EV_READ : return $ this -> addReadStream ( $ fd , $ func ) ; case EventInterface :: EV_WRITE : return $ this -> addWriteStream ( $ fd , $ func ) ; case EventInterface :: EV_SIGNAL : return $ this -> addSignal ( $ fd , $ func ) ; case EventInterface :: EV_TIMER : $ timer_id = ++ $ this -> _timerIdIndex ; $ timer_obj = $ this -> addPeriodicTimer ( $ fd , function ( ) use ( $ func , $ args ) { call_user_func_array ( $ func , $ args ) ; } ) ; $ this -> _timerIdMap [ $ timer_id ] = $ timer_obj ; return $ timer_id ; case EventInterface :: EV_TIMER_ONCE : $ timer_id = ++ $ this -> _timerIdIndex ; $ timer_obj = $ this -> addTimer ( $ fd , function ( ) use ( $ func , $ args , $ timer_id ) { unset ( $ this -> _timerIdMap [ $ timer_id ] ) ; call_user_func_array ( $ func , $ args ) ; } ) ; $ this -> _timerIdMap [ $ timer_id ] = $ timer_obj ; return $ timer_id ; } return false ; } | Add event listener to event loop . |
49,040 | public function del ( $ fd , $ flag ) { switch ( $ flag ) { case EventInterface :: EV_READ : return $ this -> removeReadStream ( $ fd ) ; case EventInterface :: EV_WRITE : return $ this -> removeWriteStream ( $ fd ) ; case EventInterface :: EV_SIGNAL : return $ this -> removeSignal ( $ fd ) ; case EventInterface :: EV_TIMER : case EventInterface :: EV_TIMER_ONCE ; if ( isset ( $ this -> _timerIdMap [ $ fd ] ) ) { $ timer_obj = $ this -> _timerIdMap [ $ fd ] ; unset ( $ this -> _timerIdMap [ $ fd ] ) ; $ this -> cancelTimer ( $ timer_obj ) ; return true ; } } return false ; } | Remove event listener from event loop . |
49,041 | public function minify ( $ htmlText = "" ) { if ( $ this -> shouldMinify ) { $ options = [ 'cssMinifier' => '\Minify_CSSmin::minify' , 'jsMinifier' => '\JSMin\JSMin::minify' , ] ; $ htmlText = \ Minify_HTML :: minify ( $ htmlText , $ options ) ; } return $ htmlText ; } | Minify all the things |
49,042 | public function jsMin ( $ jsText = "" ) { if ( $ this -> shouldMinify ) { $ jsText = \ JSMin \ JSMin :: minify ( $ jsText ) ; } return $ jsText ; } | Minify the passed in JS |
49,043 | public static function createFromProcess ( $ message , Process $ process ) { return new static ( \ sprintf ( '%s [%s]' , $ message , $ process -> getCommandLine ( ) ) . PHP_EOL . \ sprintf ( 'work dir: %s' , $ process -> getWorkingDirectory ( ) ) . PHP_EOL . $ process -> getErrorOutput ( ) , $ process -> getWorkingDirectory ( ) , $ process -> getCommandLine ( ) , $ process -> getOutput ( ) , $ process -> getErrorOutput ( ) ) ; } | Create new exception from process . |
49,044 | public function date ( $ date ) { if ( $ date instanceof \ DateTime ) { $ date = $ date -> format ( 'Y-m-d H:i:s' ) ; } $ this -> arguments [ ] = '--date=' . $ date ; return $ this ; } | Add the date option to the command line . |
49,045 | public function move ( $ oldName = false ) { $ this -> arguments [ ] = '-M' ; if ( $ oldName ) { $ this -> arguments [ ] = $ oldName ; } return $ this ; } | Add the M option to the command line . |
49,046 | public function getNames ( ) { $ branches = $ this -> execute ( ) ; $ branches = \ explode ( "\n" , $ branches ) ; $ branches = \ array_map ( function ( $ branch ) { return \ ltrim ( $ branch , '*' ) ; } , $ branches ) ; $ branches = \ array_map ( 'trim' , $ branches ) ; $ branches = \ array_filter ( $ branches ) ; return $ branches ; } | Retrieve the branch names . |
49,047 | protected function buildProcess ( ) { if ( ! \ count ( $ this -> arguments ) ) { throw new LogicException ( 'You must add command arguments before the process can build.' ) ; } $ process = new Process ( $ this -> arguments , $ this -> workingDirectory ) ; $ process -> setCommandLine ( $ process -> getCommandLine ( ) ) ; return $ process ; } | Build the the command line process . |
49,048 | public function orphan ( $ newBranch = null ) { $ this -> arguments [ ] = '--orphan' ; if ( $ newBranch ) { $ this -> arguments [ ] = $ newBranch ; } return $ this ; } | Add the orphan option to the command line . |
49,049 | public function init ( ) { Yii :: setAlias ( '@maintenance' , $ this -> commandPath ) ; if ( ! file_exists ( Yii :: getAlias ( '@maintenance' ) ) ) { FileHelper :: createDirectory ( Yii :: getAlias ( '@maintenance' ) ) ; } if ( Yii :: $ app instanceof \ yii \ console \ Application ) { Yii :: $ app -> controllerMap [ 'maintenance' ] = $ this -> consoleController ; } else { if ( $ this -> getIsEnabled ( ) ) { $ this -> filtering ( ) ; } } } | Initial component method . |
49,050 | public function getIsEnabled ( $ onlyConsole = false ) { $ exists = file_exists ( $ this -> getStatusFilePath ( ) ) ; return $ onlyConsole ? $ exists : $ this -> enabled || $ exists ; } | Checks if mode is on . |
49,051 | public function disable ( ) { $ path = $ this -> getStatusFilePath ( ) ; if ( $ path && file_exists ( $ path ) ) { return ( bool ) unlink ( $ path ) ; } return false ; } | Turn off mode . |
49,052 | public function config ( $ key , $ value ) { $ this -> arguments [ ] = '--config' ; $ this -> arguments [ ] = $ key . '=' . $ value ; return $ this ; } | Add the config option to the command line . |
49,053 | public function getStatus ( $ pathspec = null , $ _ = null ) { $ this -> porcelain ( ) ; $ status = \ call_user_func_array ( [ $ this , 'execute' ] , \ func_get_args ( ) ) ; $ status = \ explode ( "\n" , $ status ) ; $ files = [ ] ; foreach ( $ status as $ line ) { if ( \ trim ( $ line ) ) { $ index = \ trim ( \ substr ( $ line , 0 , 1 ) ) ; $ worktree = \ trim ( \ substr ( $ line , 1 , 1 ) ) ; if ( $ index && $ worktree ) { $ file = \ trim ( \ substr ( $ line , 2 ) ) ; $ files [ $ file ] = [ 'index' => $ index ? : false , 'worktree' => $ worktree ? : false , ] ; } } } return $ files ; } | Return the parsed index and work tree status . |
49,054 | public function file ( $ file ) { if ( \ in_array ( $ file , [ 'global' , 'system' , 'local' ] ) ) { $ this -> arguments [ ] = '--' . $ file ; } else { $ this -> arguments [ ] = '--file' ; $ this -> arguments [ ] = $ file ; } return $ this ; } | Specify a single config file that should be looked at . Has special support for the global system and local flags . |
49,055 | public function add ( $ name , $ value ) { $ this -> arguments [ ] = '--add' ; $ this -> arguments [ ] = $ name ; $ this -> arguments [ ] = $ value ; return $ this ; } | Add the add option and associated parameters to the command line . |
49,056 | public function replaceAll ( $ name , $ value , $ valueRegex = null ) { $ this -> arguments [ ] = '--replace-all' ; $ this -> arguments [ ] = $ name ; $ this -> arguments [ ] = $ value ; if ( $ valueRegex !== null ) { $ this -> arguments [ ] = $ valueRegex ; } return $ this ; } | Add the replace - all option and associated parameters to the command line . |
49,057 | public function get ( $ name , $ valueRegex = null ) { $ this -> arguments [ ] = '--get' ; $ this -> addNameAndPattern ( $ name , $ valueRegex ) ; return $ this ; } | Add the get option and associated parameters to the command line . |
49,058 | public function getAll ( $ name , $ valueRegex = null ) { $ this -> arguments [ ] = '--get-all' ; $ this -> addNameAndPattern ( $ name , $ valueRegex ) ; return $ this ; } | Add the get - all option and associated parameters to the command line . |
49,059 | public function getRegexp ( $ nameRegex , $ valueRegex = null ) { $ this -> arguments [ ] = '--get-regexp' ; $ this -> addNameAndPattern ( $ nameRegex , $ valueRegex ) ; return $ this ; } | Add the get - regexp option and associated parameters to the command line . |
49,060 | public function getUrlmatch ( $ name , $ url ) { $ this -> arguments [ ] = '--get-urlmatch' ; $ this -> addNameAndPattern ( $ name , $ url ) ; return $ this ; } | Add the get - urlmatch option and associated parameters to the command line . |
49,061 | public function unsetOpt ( $ name , $ valueRegex = null ) { $ this -> arguments [ ] = '--unset' ; $ this -> addNameAndPattern ( $ name , $ valueRegex ) ; return $ this ; } | Add the unset option and associated parameters to the command line . |
49,062 | public function unsetAll ( $ name , $ valueRegex = null ) { $ this -> arguments [ ] = '--unset-all' ; $ this -> addNameAndPattern ( $ name , $ valueRegex ) ; return $ this ; } | Add the unset - all option and associated parameters to the command line . |
49,063 | private function addNameAndPattern ( $ name , $ pattern ) { $ this -> arguments [ ] = $ name ; if ( $ pattern !== null ) { $ this -> arguments [ ] = $ pattern ; } } | Add the passed name and the passed pattern if not null . |
49,064 | public function renameSection ( $ oldName , $ newName ) { $ this -> arguments [ ] = '--rename-section' ; $ this -> arguments [ ] = $ oldName ; $ this -> arguments [ ] = $ newName ; return $ this ; } | Add the rename - section option and associated parameters to the command line . |
49,065 | public function getColor ( $ name , $ default = null ) { $ this -> arguments [ ] = '--get-color' ; $ this -> arguments [ ] = $ name ; if ( $ default !== null ) { $ this -> arguments [ ] = $ default ; } return $ this ; } | Add the get - color option and associated parameters to the command line . |
49,066 | public function getColorBool ( $ name , $ stdoutIsTty = null ) { $ this -> arguments [ ] = '--get-colorbool' ; $ this -> arguments [ ] = $ name ; if ( \ is_bool ( $ stdoutIsTty ) ) { $ this -> arguments [ ] = $ stdoutIsTty ? 'true' : 'false' ; } return $ this ; } | Add the get - colorbool option and associated parameters to the command line . |
49,067 | public function dirty ( $ mark = false ) { $ this -> arguments [ ] = '--dirty' ; if ( $ mark ) { $ this -> arguments [ ] = $ mark ; } return $ this ; } | Add the dirty option to the command line . |
49,068 | public function add ( $ name , $ url ) { $ this -> arguments [ ] = 'add' ; $ this -> arguments [ ] = $ name ; $ this -> arguments [ ] = $ url ; return $ this ; } | Add the add option to the command line . |
49,069 | public function rename ( $ new , $ old = null ) { $ this -> arguments [ ] = 'rename' ; if ( $ old ) { $ this -> arguments [ ] = $ old ; } $ this -> arguments [ ] = $ new ; return $ this ; } | Add the rename option to the command line . |
49,070 | public function setBranches ( $ name , $ branch , $ add = false ) { $ this -> arguments [ ] = 'set-branches' ; if ( $ add ) { $ this -> arguments [ ] = '--add' ; } $ this -> arguments [ ] = $ name ; $ this -> arguments [ ] = $ branch ; return $ this ; } | Add the set - branches option to the command line . |
49,071 | public function prune ( $ name , $ dryRun = false ) { $ this -> arguments [ ] = 'prune' ; if ( $ dryRun ) { $ this -> arguments [ ] = '--dry-run' ; } $ this -> arguments [ ] = $ name ; return $ this ; } | Add the prune option to the command line . |
49,072 | public function update ( $ groupOrRemote , $ prune = false ) { $ this -> arguments [ ] = 'update' ; if ( $ prune ) { $ this -> arguments [ ] = '--prune' ; } $ this -> arguments [ ] = $ groupOrRemote ; return $ this ; } | Add the update option to the command line . |
49,073 | public function getNames ( ) { $ tags = $ this -> execute ( ) ; $ tags = \ explode ( "\n" , $ tags ) ; $ tags = \ array_map ( 'trim' , $ tags ) ; $ tags = \ array_filter ( $ tags ) ; return $ tags ; } | Retrieve the tag names . |
49,074 | public function listStash ( $ options = null ) { $ this -> arguments [ ] = 'list' ; if ( $ options ) { $ this -> arguments [ ] = $ options ; } return $ this -> run ( ) ; } | List stashes and return the results |
49,075 | public function pop ( $ stash = null ) { $ this -> arguments [ ] = 'pop' ; if ( $ stash ) { $ this -> arguments [ ] = 'stash@{' . $ stash . '}' ; } return $ this -> run ( ) ; } | Remove a single stashed state from the stash list and apply it on top of the current working tree state . |
49,076 | public function w ( $ width , $ indent1 = null , $ indent2 = null ) { if ( $ indent1 ) { $ width .= ',' . $ indent1 ; if ( $ indent2 ) { $ width .= ',' . $ indent2 ; } } $ this -> arguments [ ] = '-w' . $ width ; return $ this ; } | Linewrap the output by wrapping each line at width . |
49,077 | public function actionEnable ( ) { $ maintenance = Yii :: $ app -> maintenanceMode ; if ( ! $ maintenance -> getIsEnabled ( true ) && $ maintenance -> enable ( ) ) { $ this -> stdout ( "Maintenance mode enabled successfully.\n" , Console :: FG_GREEN ) ; return Controller :: EXIT_CODE_NORMAL ; } else { $ this -> stdout ( "Maintenance mode already enabled.\n" , Console :: FG_RED ) ; return Controller :: EXIT_CODE_ERROR ; } } | Enable maintenance mode . |
49,078 | public function actionDisable ( ) { $ maintenance = Yii :: $ app -> maintenanceMode ; if ( $ maintenance -> getIsEnabled ( true ) && $ maintenance -> disable ( ) ) { $ this -> stdout ( "Maintenance mode disabled successfully.\n" , Console :: FG_GREEN ) ; return Controller :: EXIT_CODE_NORMAL ; } else { $ this -> stdout ( "Maintenance mode already disabled.\n" , Console :: FG_RED ) ; return Controller :: EXIT_CODE_ERROR ; } } | Disable maintenance mode . |
49,079 | public static function queue ( $ address , $ subject , $ content , $ userId = null ) { try { $ email = new static ; $ email -> user_id = $ userId ; $ email -> email = $ address ; $ email -> subject = $ subject ; $ email -> content = $ content ; $ email -> status = self :: STATUS_PENDING ; $ email -> attempt = 0 ; return $ email -> save ( ) ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; } | Adds email to queue . |
49,080 | public function actions ( ) { return [ 'promote' => [ 'class' => 'bizley\podium\actions\AdminAction' , 'fromRole' => User :: ROLE_MEMBER , 'toRole' => User :: ROLE_MODERATOR , 'method' => 'promoteTo' , 'restrictMessage' => Yii :: t ( 'podium/flash' , 'You can only promote Members to Moderators.' ) , 'successMessage' => Yii :: t ( 'podium/flash' , 'User has been promoted.' ) , 'errorMessage' => Yii :: t ( 'podium/flash' , 'Sorry! There was an error while promoting the user.' ) ] , 'demote' => [ 'class' => 'bizley\podium\actions\AdminAction' , 'fromRole' => User :: ROLE_MODERATOR , 'toRole' => User :: ROLE_MEMBER , 'method' => 'demoteTo' , 'restrictMessage' => Yii :: t ( 'podium/flash' , 'You can only demote Moderators to Members.' ) , 'successMessage' => Yii :: t ( 'podium/flash' , 'User has been demoted.' ) , 'errorMessage' => Yii :: t ( 'podium/flash' , 'Sorry! There was an error while demoting the user.' ) ] , ] ; } | Returns separated admin actions . |
49,081 | public function actionBan ( $ id = null ) { $ model = User :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> id == User :: loggedId ( ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not ban or unban your own account.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> status == User :: STATUS_ACTIVE ) { if ( $ model -> ban ( ) ) { $ this -> module -> podiumCache -> delete ( 'members.fieldlist' ) ; Log :: info ( 'User banned' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'User has been banned.' ) ) ; } else { Log :: error ( 'Error while banning user' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while banning the user.' ) ) ; } return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> status == User :: STATUS_BANNED ) { if ( $ model -> unban ( ) ) { $ this -> module -> podiumCache -> delete ( 'members.fieldlist' ) ; Log :: info ( 'User unbanned' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'User has been unbanned.' ) ) ; } else { Log :: error ( 'Error while unbanning user' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while unbanning the user.' ) ) ; } return $ this -> redirect ( [ 'admin/members' ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! User has got the wrong status.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } | Banning the user of given ID . |
49,082 | public function actionDelete ( $ id = null ) { $ model = User :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> id == User :: loggedId ( ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not delete your own account.' ) ) ; return $ this -> redirect ( [ 'admin/members' ] ) ; } if ( $ model -> delete ( ) ) { PodiumCache :: clearAfter ( 'userDelete' ) ; Activity :: deleteUser ( $ model -> id ) ; Log :: info ( 'User deleted' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'User has been deleted.' ) ) ; } else { Log :: error ( 'Error while deleting user' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while deleting the user.' ) ) ; } return $ this -> redirect ( [ 'admin/members' ] ) ; } | Deleting the user of given ID . |
49,083 | public function actionMods ( $ id = null ) { $ mod = null ; $ moderators = User :: find ( ) -> where ( [ 'role' => User :: ROLE_MODERATOR ] ) -> indexBy ( 'id' ) -> all ( ) ; if ( is_numeric ( $ id ) && $ id > 0 ) { if ( isset ( $ moderators [ $ id ] ) ) { $ mod = $ moderators [ $ id ] ; } } else { reset ( $ moderators ) ; $ mod = current ( $ moderators ) ; } $ searchModel = new ForumSearch ( ) ; $ dataProvider = $ searchModel -> searchForMods ( Yii :: $ app -> request -> get ( ) ) ; $ postData = Yii :: $ app -> request -> post ( ) ; if ( $ postData ) { if ( ! User :: can ( Rbac :: PERM_PROMOTE_USER ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'You are not allowed to perform this action.' ) ) ; } else { $ mod_id = ! empty ( $ postData [ 'mod_id' ] ) && is_numeric ( $ postData [ 'mod_id' ] ) && $ postData [ 'mod_id' ] > 0 ? $ postData [ 'mod_id' ] : 0 ; $ selection = ! empty ( $ postData [ 'selection' ] ) ? $ postData [ 'selection' ] : [ ] ; $ pre = ! empty ( $ postData [ 'pre' ] ) ? $ postData [ 'pre' ] : [ ] ; if ( $ mod_id == $ mod -> id ) { if ( $ mod -> updateModeratorForMany ( $ selection , $ pre ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Moderation list has been saved.' ) ) ; } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while saving the moderation list.' ) ) ; } return $ this -> refresh ( ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while selecting the moderator ID.' ) ) ; } } return $ this -> render ( 'mods' , [ 'moderators' => $ moderators , 'mod' => $ mod , 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; } | Listing and updating moderation list for the forum of given ID . |
49,084 | public function setParams ( ) { if ( Yii :: $ app -> request -> get ( 'page' ) && Yii :: $ app -> session -> has ( 'forum-search' ) ) { $ session = Yii :: $ app -> session -> get ( 'forum-search' ) ; $ this -> query = $ session [ 'query' ] ; $ this -> match = $ session [ 'match' ] ; $ this -> author = $ session [ 'author' ] ; $ this -> dateFrom = $ session [ 'dateFrom' ] ; $ this -> dateFromStamp = $ session [ 'dateFromStamp' ] ; $ this -> dateTo = $ session [ 'dateTo' ] ; $ this -> dateToStamp = $ session [ 'dateToStamp' ] ; $ this -> forums = $ session [ 'forums' ] ; $ this -> type = $ session [ 'type' ] ; $ this -> display = $ session [ 'display' ] ; $ this -> nextPage = true ; } else { $ this -> match = 'all' ; $ this -> type = 'posts' ; $ this -> display = 'topics' ; $ this -> nextPage = false ; } } | Sets search parameters based on the session . |
49,085 | protected function prepareQuery ( $ query , $ topics = false ) { $ field = $ topics ? Thread :: tableName ( ) . '.created_at' : Post :: tableName ( ) . '.updated_at' ; if ( ! empty ( $ this -> author ) ) { $ query -> andWhere ( [ 'like' , 'username' , $ this -> author ] ) -> joinWith ( [ 'author' ] ) ; } if ( ! empty ( $ this -> dateFromStamp ) && empty ( $ this -> dateToStamp ) ) { $ query -> andWhere ( [ '>=' , $ field , $ this -> dateFromStamp ] ) ; } elseif ( ! empty ( $ this -> dateToStamp ) && empty ( $ this -> dateFromStamp ) ) { $ this -> dateToStamp += 23 * 3600 + 59 * 60 + 59 ; $ query -> andWhere ( [ '<=' , $ field , $ this -> dateToStamp ] ) ; } elseif ( ! empty ( $ this -> dateToStamp ) && ! empty ( $ this -> dateFromStamp ) ) { if ( $ this -> dateFromStamp > $ this -> dateToStamp ) { $ tmp = $ this -> dateToStamp ; $ this -> dateToStamp = $ this -> dateFromStamp ; $ this -> dateFromStamp = $ tmp ; } $ this -> dateToStamp += 23 * 3600 + 59 * 60 + 59 ; $ query -> andWhere ( [ '<=' , $ field , $ this -> dateToStamp ] ) ; $ query -> andWhere ( [ '>=' , $ field , $ this -> dateFromStamp ] ) ; } if ( ! empty ( $ this -> forums ) ) { if ( is_array ( $ this -> forums ) ) { $ forums = [ ] ; foreach ( $ this -> forums as $ f ) { if ( is_numeric ( $ f ) ) { $ forums [ ] = ( int ) $ f ; } } if ( ! empty ( $ forums ) ) { $ query -> andWhere ( [ 'forum_id' => $ forums ] ) ; } } } } | Prepares query conditions . |
49,086 | protected function searchTopics ( ) { $ query = Thread :: find ( ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'forum' => function ( $ q ) { $ q -> andWhere ( [ Forum :: tableName ( ) . '.visible' => 1 ] ) -> joinWith ( [ 'category' => function ( $ q ) { $ q -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; } ] ) ; } if ( ! empty ( $ this -> query ) ) { $ words = explode ( ' ' , preg_replace ( '/\s+/' , ' ' , $ this -> query ) ) ; foreach ( $ words as $ word ) { if ( $ this -> match == 'all' ) { $ query -> andWhere ( [ 'like' , Thread :: tableName ( ) . '.name' , $ word ] ) ; } else { $ query -> orWhere ( [ 'like' , Thread :: tableName ( ) . '.name' , $ word ] ) ; } } } $ this -> prepareQuery ( $ query , true ) ; $ sort = [ 'defaultOrder' => [ Thread :: tableName ( ) . '.id' => SORT_DESC ] , 'attributes' => [ Thread :: tableName ( ) . '.id' => [ 'asc' => [ Thread :: tableName ( ) . '.id' => SORT_ASC ] , 'desc' => [ Thread :: tableName ( ) . '.id' => SORT_DESC ] , 'default' => SORT_DESC , ] , ] ] ; return new ActiveDataProvider ( [ 'query' => $ query , 'sort' => $ sort , ] ) ; } | Advanced topics search . |
49,087 | public function searchPosts ( ) { $ query = Vocabulary :: find ( ) -> select ( 'post_id, thread_id' ) -> joinWith ( [ 'posts.author' , 'posts.thread' ] ) -> andWhere ( [ 'is not' , 'post_id' , null ] ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'posts.forum' => function ( $ q ) { $ q -> andWhere ( [ Forum :: tableName ( ) . '.visible' => 1 ] ) -> joinWith ( [ 'category' => function ( $ q ) { $ q -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; } ] ) ; } if ( ! empty ( $ this -> query ) ) { $ words = explode ( ' ' , preg_replace ( '/\s+/' , ' ' , $ this -> query ) ) ; $ countWords = 0 ; foreach ( $ words as $ word ) { $ query -> orWhere ( [ 'like' , 'word' , $ word ] ) ; $ countWords ++ ; } $ query -> groupBy ( 'post_id' ) ; if ( $ this -> match == 'all' && $ countWords > 1 ) { $ query -> select ( [ 'post_id' , 'thread_id' , 'COUNT(post_id) AS c' ] ) -> having ( [ '>' , 'c' , $ countWords - 1 ] ) ; } } $ this -> prepareQuery ( $ query ) ; $ sort = [ 'defaultOrder' => [ 'post_id' => SORT_DESC ] , 'attributes' => [ 'post_id' => [ 'asc' => [ 'post_id' => SORT_ASC ] , 'desc' => [ 'post_id' => SORT_DESC ] , 'default' => SORT_DESC , ] , ] ] ; return new ActiveDataProvider ( [ 'query' => $ query , 'sort' => $ sort , ] ) ; } | Advanced posts search . |
49,088 | public function searchAdvanced ( ) { if ( ! $ this -> nextPage ) { Yii :: $ app -> session -> set ( 'forum-search' , [ 'query' => $ this -> query , 'match' => $ this -> match , 'author' => $ this -> author , 'dateFrom' => $ this -> dateFrom , 'dateFromStamp' => $ this -> dateFromStamp , 'dateTo' => $ this -> dateTo , 'dateToStamp' => $ this -> dateToStamp , 'forums' => $ this -> forums , 'type' => $ this -> type , 'display' => $ this -> display ] ) ; } if ( $ this -> type == 'topics' ) { return $ this -> searchTopics ( ) ; } return $ this -> searchPosts ( ) ; } | Advanced search . |
49,089 | public function init ( ) { parent :: init ( ) ; $ this -> setAliases ( [ '@podium' => '@vendor/bizley/podium/src' ] ) ; if ( Yii :: $ app instanceof WebApplication ) { $ this -> podiumComponent -> registerComponents ( ) ; $ this -> layout = 'main' ; if ( ! is_string ( $ this -> slugGenerator ) ) { $ this -> slugGenerator = PodiumSluggableBehavior :: className ( ) ; } } else { $ this -> podiumComponent -> registerConsoleComponents ( ) ; } } | Initializes the module for Web application . Sets Podium alias ( |
49,090 | public function bootstrap ( $ app ) { if ( $ app instanceof WebApplication ) { $ this -> addUrlManagerRules ( $ app ) ; $ this -> setPodiumLogTarget ( $ app ) ; } elseif ( $ app instanceof ConsoleApplication ) { $ this -> controllerNamespace = 'bizley\podium\console' ; } } | Bootstrap method to be called during application bootstrap stage . Adding routing rules and log target . |
49,091 | public function afterAction ( $ action , $ result ) { if ( Yii :: $ app instanceof WebApplication && ! in_array ( $ action -> id , [ 'import' , 'run' , 'update' , 'level-up' ] , true ) ) { Activity :: add ( ) ; } return parent :: afterAction ( $ action , $ result ) ; } | Registers user activity after every action . |
49,092 | protected function addUrlManagerRules ( $ app ) { $ app -> urlManager -> addRules ( [ new GroupUrlRule ( [ 'prefix' => $ this -> id , 'rules' => require __DIR__ . '/url-rules.php' , ] ) ] , true ) ; } | Adds UrlManager rules . |
49,093 | protected function setPodiumLogTarget ( $ app ) { $ dbTarget = new DbTarget ; $ dbTarget -> logTable = '{{%podium_log}}' ; $ dbTarget -> categories = [ 'bizley\podium\*' ] ; $ dbTarget -> logVars = [ ] ; $ app -> log -> targets [ 'podium' ] = $ dbTarget ; } | Sets Podium log target . |
49,094 | public function getPodiumComponent ( ) { if ( $ this -> _component === null ) { $ this -> _component = new PodiumComponent ( $ this ) ; } return $ this -> _component ; } | Returns Podium component service . |
49,095 | public function passwordRequirements ( $ attribute ) { if ( ! preg_match ( '~\p{Lu}~' , $ this -> $ attribute ) || ! preg_match ( '~\p{Ll}~' , $ this -> $ attribute ) || ! preg_match ( '~[0-9]~' , $ this -> $ attribute ) || mb_strlen ( $ this -> $ attribute , 'UTF-8' ) < 6 || mb_strlen ( $ this -> $ attribute , 'UTF-8' ) > 100 ) { $ this -> addError ( $ attribute , Yii :: t ( 'podium/view' , 'Password must contain uppercase and lowercase letter, digit, and be at least 6 characters long.' ) ) ; } } | Finds out if unencrypted password fulfill requirements . |
49,096 | public static function findByActivationToken ( $ token ) { if ( ! static :: isActivationTokenValid ( $ token ) ) { return null ; } return static :: find ( ) -> where ( [ 'activation_token' => $ token , 'status' => self :: STATUS_REGISTERED ] ) -> limit ( 1 ) -> one ( ) ; } | Finds registered user by activation token . |
49,097 | public static function findByEmailToken ( $ token ) { if ( ! static :: isEmailTokenValid ( $ token ) ) { return null ; } return static :: find ( ) -> where ( [ 'email_token' => $ token , 'status' => self :: STATUS_ACTIVE ] ) -> limit ( 1 ) -> one ( ) ; } | Finds active user by email token . |
49,098 | public static function findByKeyfield ( $ keyfield , $ status = self :: STATUS_ACTIVE ) { if ( $ status === null ) { return static :: find ( ) -> where ( [ 'or' , [ 'email' => $ keyfield ] , [ 'username' => $ keyfield ] ] ) -> limit ( 1 ) -> one ( ) ; } return static :: find ( ) -> where ( [ 'and' , [ 'status' => $ status ] , [ 'or' , [ 'email' => $ keyfield ] , [ 'username' => $ keyfield ] ] ] ) -> limit ( 1 ) -> one ( ) ; } | Finds user of given status by username or email . |
49,099 | public static function findByPasswordResetToken ( $ token , $ status = self :: STATUS_ACTIVE ) { if ( ! static :: isPasswordResetTokenValid ( $ token ) ) { return null ; } if ( $ status == null ) { return static :: find ( ) -> where ( [ 'password_reset_token' => $ token ] ) -> limit ( 1 ) -> one ( ) ; } return static :: find ( ) -> where ( [ 'password_reset_token' => $ token , 'status' => $ status ] ) -> limit ( 1 ) -> one ( ) ; } | Finds user of given status by password reset token |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.