idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
38,200
public function removeOldNotifications ( $ actors ) { foreach ( $ actors as $ actor ) { $ read_notifications = array_diff ( $ actor -> notificationIds -> toArray ( ) , $ actor -> newNotificationIds -> toArray ( ) ) ; $ date = $ this -> getService ( 'anahita:domain.attribute.date' ) -> modify ( '-5 days' ) ; $ query = $...
Remove old notifications .
38,201
protected function _actionAdd ( AnCommandContext $ context ) { $ data = $ context -> data ; return $ this -> getRepository ( ) -> create ( $ data -> toArray ( ) ) ; }
Creates a new story . This is an internal method and can not be called from outside .
38,202
protected function _actionBrowse ( AnCommandContext $ context ) { $ entities = parent :: _actionBrowse ( $ context ) ; if ( $ this -> filter == 'leaders' ) { $ ids = get_viewer ( ) -> leaderIds -> toArray ( ) ; $ ids [ ] = get_viewer ( ) -> id ; $ entities -> where ( 'owner.id' , 'IN' , $ ids ) ; } else { $ entities ->...
Browse action .
38,203
protected function _actionDelete ( $ context ) { $ context -> response -> status = AnHttpResponse :: NO_CONTENT ; $ this -> getItem ( ) -> delete ( ) ; $ context -> response -> setRedirect ( route ( $ this -> getItem ( ) -> owner -> getURL ( ) ) ) ; }
Delete a story .
38,204
public function canGet ( ) { if ( ! $ this -> actor ) { $ this -> actor = $ this -> getService ( 'com:people.viewer' ) ; } if ( ! $ this -> actor ) { return false ; } if ( ! $ this -> actor -> authorize ( 'administration' ) ) { return false ; } $ this -> getService ( 'repos:connect.session' ) ; $ api = $ this -> actor ...
Authorize a GET request .
38,205
protected function _actionGet ( AnCommandContext $ context ) { if ( $ context -> request -> getFormat ( ) == 'html' ) { $ context -> response -> setRedirect ( route ( 'format=json&option=com_connect&view=' . $ this -> view ) ) ; return ; } if ( $ this -> get ) { $ url = ltrim ( $ this -> get , '/' ) ; $ data = AnConfig...
Dispatches a call to the oauth handler .
38,206
public function commitEntities ( & $ failed = null ) { if ( $ ret = parent :: commitEntities ( $ failed ) ) { $ ids = array ( ) ; foreach ( $ this -> _entities as $ entity ) { if ( $ entity -> getEntityState ( ) == AnDomain :: STATE_DESTROYED ) { if ( is ( $ entity , 'ComBaseDomainEntityNode' ) ) { $ ids [ ] = $ entity...
After a succesfull commit perform a cleanup of nodes .
38,207
public function removeNodesWithComponent ( $ components ) { settype ( $ components , 'array' ) ; if ( count ( $ components ) ) { $ ids = $ this -> getService ( 'repos:base.node' ) -> getQuery ( ) -> disableChain ( ) -> component ( $ components ) -> fetchValues ( 'id' ) ; if ( count ( $ ids ) ) { $ this -> getService ( ...
Remove node edges for the passed components .
38,208
public function getRelatedNodeIds ( $ ids ) { $ cols = array ( 'story_object_id' , 'story_subject_id' , 'story_comment_id' , 'story_target_id' , 'parent_id' , 'owner_id' , ) ; foreach ( $ cols as $ key => $ value ) { $ cols [ $ key ] = $ value . ' IN (' . implode ( ',' , $ ids ) . ')' ; } $ cols = implode ( ' OR ' , $ ...
Get an array of related nodes ids .
38,209
public function getNodeRepositories ( $ ids ) { $ types = $ this -> getService ( 'repos:base.node' ) -> getQuery ( ) -> disableChain ( ) -> id ( $ ids ) ; $ types -> distinct = true ; $ repositories = array ( ) ; foreach ( $ types -> fetchValues ( 'type' ) as $ key => $ type ) { $ type = explode ( ',' , $ type ) ; $ id...
Return an array of node repositories for a list of ids .
38,210
public function cleanupNodesWithIds ( $ ids ) { $ ids = array_merge ( $ this -> getRelatedNodeIds ( $ ids ) , $ ids ) ; if ( ! empty ( $ ids ) ) { $ repositories = $ this -> getNodeRepositories ( $ ids ) ; $ this -> getService ( 'repos:base.node' ) -> destroy ( $ ids ) ; $ in = '(' . implode ( ',' , $ ids ) . ')' ; $ q...
Clean up node edge table for the deleted nodes with passed ids .
38,211
public function setFederalTax ( array $ taxes ) { $ meta = clone $ this -> meta ; $ taxes = new AnConfig ( $ taxes ) ; $ values = array ( ) ; foreach ( $ taxes as $ tax ) { if ( $ tax -> value != 0 ) { $ value = $ tax -> value ; $ name = $ tax -> name ; if ( $ value > 1 ) { $ value = $ value / 100 ; } $ values [ strtol...
Set the federal tax .
38,212
public function getFederalTaxes ( ) { $ taxes = pick ( $ this -> meta -> federal_taxes , array ( ) ) ; foreach ( $ taxes as & $ tax ) { $ tax = new AnConfig ( $ tax ) ; } return $ taxes ; }
Returns an array of federal taxes .
38,213
public function logout ( $ person ) { $ this -> _destroySession ( $ person ) ; $ oneYear = 365 * 24 * 3600 ; $ hash = get_hash ( 'AN_LOGIN_REMEMBER' ) ; setcookie ( $ hash , '' , time ( ) - $ oneYear , '/' ) ; return true ; }
Deletes a session and logs out the viewer .
38,214
private function _createSession ( ComPeopleDomainEntityPerson $ person ) { $ session = $ this -> getService ( 'com:application' , array ( 'session' => true ) ) -> getSession ( ) ; $ repo = $ this -> getService ( 'repos:sessions.session' ) ; $ entity = $ repo -> findOrAddNew ( array ( 'sessionId' => $ session -> getId (...
Creates a session for the given person
38,215
private function _destroySession ( ComPeopleDomainEntityPerson $ person ) { $ this -> getService ( 'repos:sessions.session' ) -> destroy ( array ( 'nodeId' => $ person -> id ) ) ; $ this -> getService ( 'com:sessions' ) -> destroy ( ) ; }
Destroys the session for the given person
38,216
public function removePortraitImage ( ) { $ sizes = $ this -> _mixer -> getValue ( 'sizes' ) ; if ( empty ( $ sizes ) ) { $ sizes = explode ( ' ' , 'original large medium small thumbnail square' ) ; } else { $ sizes = array_keys ( $ sizes ) ; } foreach ( $ sizes as $ size ) { $ file = $ this -> _mixer -> getPortraitFil...
Removes the portrait image .
38,217
public function getPortraitFile ( $ size ) { $ filename = $ this -> filename ; $ extension = explode ( '.' , $ filename ) ; $ extension = array_pop ( $ extension ) ; $ name = preg_replace ( '#\.[^.]*$#' , '' , $ filename ) ; $ filename = $ name . '_' . $ size . '.' . $ extension ; return $ filename ; }
Return the portrait file for a size . Override the Portriable behavior due to some legacy .
38,218
public function getPortraitURL ( $ size = 'square' ) { $ filename = $ this -> _mixer -> getPortraitFile ( $ size ) ; $ url = $ this -> getPathURL ( $ filename , true ) ; return $ url ; }
Return the URL to the portrait .
38,219
public function getPortraitSizes ( ) { $ sizes = $ this -> getValue ( 'sizes' ) ; if ( empty ( $ sizes ) ) { $ sizes = $ this -> _sizes ; } return $ sizes ; }
Obtain the list of available sizes and dimensions for this photo .
38,220
public function setPortrait ( $ config ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'rotation' => 0 , 'mimetype' => 'image/jpeg' , ) ) ; if ( $ config -> url ) { $ config -> append ( array ( 'data' => file_get_contents ( $ config -> url ) , ) ) ; } $ config -> mimetype = strtolower ( $ config...
Set the portrait .
38,221
public function resizePortraitImage ( $ image ) { $ images = array ( ) ; $ original_width = imagesx ( $ image ) ; $ originl_height = imagesy ( $ image ) ; foreach ( $ this -> _sizes as $ name => $ size ) { if ( ! is_int ( $ size ) ) { list ( $ width , $ height ) = AnHelperImage :: parseSize ( $ size ) ; if ( $ original...
Return a resizes verion of the image .
38,222
protected function _commandEnable ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ label = AnTranslator :: _ ( 'COM-TODOS-ACTION-' . strtoupper ( $ entity -> enabled ? 'disable' : 'enable' ) ) ; $ action = ( $ entity -> enabled ) ? 'disable' : 'enable' ; $ command -> append ( array ( 'label' =>...
Enable Action for an entity .
38,223
public static function getHeader ( $ code , $ message = null , $ protocol = 'HTTP/1.1' ) { return $ protocol . ' ' . $ code . ' ' . ( $ message ? $ message : self :: getMessage ( $ code ) ) ; }
Get the http header based on a status code
38,224
public static function getMessage ( $ code ) { return isset ( self :: $ __messages [ $ code ] ) ? self :: $ __messages [ $ code ] : null ; }
Get the message based on a status code
38,225
public static function getServices ( ) { $ avail_services = array ( 'facebook' , 'twitter' , 'linkedin' ) ; $ services = array ( ) ; foreach ( $ avail_services as $ service ) { $ service = self :: getAPI ( $ service ) ; if ( $ service -> enabled ( ) ) { $ services [ $ service -> getIdentifier ( ) -> name ] = $ service ...
Return an array of services .
38,226
public static function getConsumer ( $ api ) { $ api = strtolower ( $ api ) ; $ key = get_config_value ( 'com_connect.' . $ api . '_key' ) ; $ secret = get_config_value ( 'com_connect.' . $ api . '_secret' ) ; $ consumer = new ComConnectOauthConsumer ( new AnConfig ( array ( 'key' => $ key , 'secret' => $ secret , 'cal...
Gets a consumer .
38,227
public static function getAPI ( $ service ) { $ service = strtolower ( $ service ) ; $ identifier = 'com:connect.oauth.service.' . $ service ; if ( ! AnService :: has ( $ identifier ) ) { $ config = array ( ) ; $ config [ 'consumer' ] = self :: getConsumer ( $ service ) ; $ config [ 'enabled' ] = self :: enabled ( $ se...
Get a service api .
38,228
public static function enabled ( $ service ) { $ service = strtolower ( $ service ) ; return get_config_value ( 'connect.' . $ service . '_enable' , true ) && self :: getConsumer ( $ service ) -> isValid ( ) ; }
Returns if a service is enabled .
38,229
public function up ( ) { $ file = dirname ( $ this -> getIdentifier ( ) -> filepath ) . '/' . $ this -> getVersion ( ) . '.sql' ; if ( file_exists ( $ file ) ) { dbexecfile ( $ file ) ; } }
Called when we need to migrate up . By default it tries to run version . sql file .
38,230
protected function _pathEncode ( $ spec ) { if ( is_string ( $ spec ) ) { $ spec = explode ( '/' , $ spec ) ; } $ keys = array_keys ( $ this -> _encode_path ) ; $ vals = array_values ( $ this -> _encode_path ) ; $ out = array ( ) ; foreach ( ( array ) $ spec as $ elem ) { $ out [ ] = str_replace ( $ keys , $ vals , $ e...
Converts an array of path elements into a string .
38,231
protected function _lock ( $ object , $ lock ) { if ( $ lock ) { self :: $ _locks [ $ object -> getHandle ( ) ] = true ; } else { unset ( self :: $ _locks [ $ object -> getHandle ( ) ] ) ; } }
Set a lock for a repository .
38,232
public function load ( $ properties ) { $ keys = $ this -> _entity -> getIdentifyingData ( ) ; $ this -> _entity -> getRepository ( ) -> getCommandChain ( ) -> disable ( ) ; $ query = $ this -> _entity -> getRepository ( ) -> getQuery ( ) -> columns ( $ properties ) -> where ( $ keys ) ; $ data = $ this -> _entity -> g...
Reloads an array of properies .
38,233
public function offsetGet ( $ key ) { $ this -> _materialize ( $ key ) ; $ result = null ; if ( isset ( $ this -> _property [ $ key ] ) ) { $ result = $ this -> _property [ $ key ] ; } return $ result ; }
Get an item from the array by offset .
38,234
protected function _materialize ( $ key ) { if ( empty ( $ this -> _row ) ) { return ; } $ property = $ this -> _description -> getProperty ( $ key ) ; if ( isset ( $ this -> _materialized [ $ property -> getName ( ) ] ) ) { return ; } $ repository = $ this -> _entity -> getRepository ( ) ; if ( $ property -> isSeriali...
Materialize a proeprty value before accesing .
38,235
public function stateChanged ( $ entity , $ current , $ new ) { $ key = $ current . '=>' . $ new ; if ( ! isset ( $ this -> _machine [ $ key ] ) ) { return true ; } $ callbacks = $ this -> _machine [ $ key ] ; foreach ( $ callbacks as $ callback ) { $ result = $ callback ; if ( is_string ( $ callback ) ) { $ result = $...
Run a state change into the state machine .
38,236
protected function _resetrelationships ( $ entity ) { $ entities = clone $ entity -> getRepository ( ) -> getSpace ( ) -> getEntities ( ) ; foreach ( $ entities as $ child ) { if ( $ child -> eql ( $ entity ) ) { continue ; } $ relationships = $ child -> getEntityDescription ( ) -> getRelationships ( ) ; foreach ( $ re...
Resets an entity .
38,237
protected function _validateDelete ( $ entity ) { $ relationships = $ entity -> getEntityDescription ( ) -> getRelationships ( ) ; foreach ( $ relationships as $ name => $ relationship ) { if ( $ relationship -> isManyToOne ( ) || $ relationship -> isManyToMany ( ) ) { continue ; } if ( $ relationship -> getDeleteRule ...
Validates and apply delete rules for an entity .
38,238
public function getAvatarURL ( $ actor , $ size = 'square' ) { if ( $ actor -> hasPortrait ( ) ) { return $ actor -> getPortraitURL ( $ size ) ; } return $ this -> getService ( 'com:base.template.asset' ) -> getURL ( 'lib_anahita/images/avatar/' . $ size . '_default.gif' ) ; }
Return an avatar URL of an actor . If actor doesn t have an avatar then it reurns the default avatar .
38,239
public function avatar ( $ actor , $ size = 'square' , $ linked = true , $ attr = array ( ) ) { if ( is_numeric ( $ size ) ) { $ width = "width=\"$size\"" ; $ size = 'square' ; } else { $ width = '' ; } $ defaultAvatar = $ this -> getService ( 'com:base.template.asset' ) -> getURL ( 'lib_anahita/images/avatar/' . $ siz...
Draws an actor avatar image .
38,240
public function cover ( $ actor , $ size = 'large' , $ linked = true , $ attr = array ( ) ) { if ( is_numeric ( $ size ) ) { $ width = "width=\"$size\"" ; $ size = 'large' ; } else { $ width = '' ; } if ( $ actor -> hasCover ( ) ) { $ src = $ actor -> getCoverURL ( $ size ) ; $ name = AnHelperString :: ucwords ( $ acto...
Draws an actor cover image .
38,241
public function name ( $ actor , $ linked = true , $ attr = array ( ) ) { if ( is_null ( $ actor ) || ! isset ( $ actor -> id ) ) { $ linked = false ; $ name = '<span class="actor-name">' . AnTranslator :: _ ( 'LIB-AN-UNKNOWN-PERSON' ) . '</span>' ; } else { $ name = '<span class="actor-name" actorid="' . $ actor -> id...
Draws an actor name .
38,242
public function noune ( $ actor , $ options = array ( ) ) { $ options = array_merge ( array ( 'useyou' => false ) , $ options ) ; $ gender = strtolower ( $ actor -> gender ) ; $ type = $ options [ 'type' ] ; if ( ! isset ( $ actor ) || is_null ( $ actor ) ) { return '' ; } switch ( strtolower ( $ type ) ) { case 'prono...
Return pronoune possessive noune or object noune for an actor . The type of noune is passed as an option with key type . If useyou is passed it treat the actor as second person .
38,243
protected function _buildAttribute ( $ attr ) { $ string = array ( ) ; foreach ( $ attr as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( ' ' , $ value ) ; } $ string [ ] = $ key . '="' . $ value . '"' ; } return implode ( ' ' , $ string ) ; }
Build html attribute .
38,244
public function execute ( $ name , AnCommandContext $ context ) { $ parts = explode ( '.' , $ name ) ; $ result = $ context -> result ; if ( $ parts [ 0 ] === 'after' && $ parts [ 1 ] != 'cancel' ) { if ( count ( $ this -> getRepository ( ) -> getSpace ( ) -> getCommitables ( ) ) == 0 ) { return ; } $ result = $ this -...
Executes a commit after each action . This prevents having too many manuall commit .
38,245
protected function _makeStatusMessage ( $ action , $ type = 'success' ) { $ messages = array ( ) ; $ messages [ ] = strtoupper ( 'COM-' . $ this -> _mixer -> getIdentifier ( ) -> package . '-PROMPT-' . $ this -> _mixer -> getIdentifier ( ) -> name . '-' . $ action . '-' . $ type ) ; $ messages [ ] = strtoupper ( 'LIB-A...
Render a message for an action .
38,246
public function getCommitErrors ( ) { $ errors = array ( ) ; if ( $ this -> _failed_commits ) { foreach ( $ this -> _failed_commits as $ entity ) { $ errors [ ( string ) $ entity -> getIdentifier ( ) ] = array_values ( $ entity -> getErrors ( ) -> toArray ( ) ) ; } } return $ errors ; }
Return an array of commit errors .
38,247
public function bind ( $ key , $ value = null ) { $ this -> _parent_query -> bind ( $ key , $ value ) ; return $ this ; }
Passthrough the bind .
38,248
protected function _commandView ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ command -> append ( array ( 'label' => AnTranslator :: _ ( 'COM-ARTICLES-ARTICLE-CURRENT-VERSION' ) ) ) ; $ command -> href ( 'option=com_articles&view=article&id=' . $ entity -> parent -> id ) ; }
View command .
38,249
protected function _commandRestore ( $ command ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ command -> append ( array ( 'label' => AnTranslator :: _ ( 'COM-ARTICLES-ARTICLE-REVISION-RESTORE' ) ) ) ; $ command -> href ( 'option=com_articles&view=revision&action=restore&id=' . $ entity -> id ) -> setAttr...
Restore command .
38,250
final public function validate ( $ data ) { if ( $ this -> _walk && ( is_array ( $ data ) || is_object ( $ data ) ) ) { $ arr = ( array ) $ data ; foreach ( $ arr as $ value ) { if ( $ this -> validate ( $ value ) === false ) { return false ; } } } else { $ context = $ this -> _chain -> getContext ( ) ; $ context -> da...
Validate a variable or data collection
38,251
final public function sanitize ( $ data ) { if ( $ this -> _walk && ( is_array ( $ data ) || is_object ( $ data ) ) ) { $ arr = ( array ) $ data ; foreach ( $ arr as $ key => $ value ) { if ( is_array ( $ data ) ) { $ data [ $ key ] = $ this -> sanitize ( $ value ) ; } if ( is_object ( $ data ) ) { $ data -> $ key = $ ...
Sanitize a variable or data collection
38,252
public function addFilter ( AnFilterInterface $ filter , $ priority = null ) { $ this -> _chain -> enqueue ( $ filter , $ priority ) ; return $ this ; }
Add a filter based on priority
38,253
public function getRepositoryEntities ( $ repository ) { if ( ! isset ( $ this -> _repository_entities [ $ repository ] ) ) { $ this -> _repository_entities [ $ repository ] = $ this -> getService ( 'anahita:domain.entityset' , array ( 'repository' => $ this ) ) ; } return $ this -> _repository_entities [ $ repository ...
Returns a collection of entityset of a repository .
38,254
final protected function _validate ( AnCommandContext $ context ) { foreach ( $ this as $ filter ) { if ( $ filter -> execute ( 'validate' , $ context ) === false ) { return false ; } } return true ; }
Validate the data
38,255
final protected function _sanitize ( AnCommandContext $ context ) { foreach ( $ this as $ filter ) { $ context -> data = $ filter -> execute ( 'sanitize' , $ context ) ; } return $ context -> data ; }
Sanitize the data
38,256
public function getExpressPaymentMethod ( $ token , & $ country = null ) { $ gateway = new Merchant_Billing_PaypalExpress ( $ this -> _gateway_config ) ; $ response = $ gateway -> get_details_for ( $ token , '' ) ; $ method = new ComSubscriptionsDomainPaymentMethodToken ( 'Paypal' , array ( 'payer_id' => $ response -> ...
Return a payment method .
38,257
protected function _logError ( $ response ) { $ log = $ this -> getService ( 'anahita:log' , array ( 'file' => 'system_log.php' ) ) ; $ message = "\nerror_message=" . $ response -> message ( ) . "\n" ; if ( $ response -> cvv_result ( ) ) { $ message .= 'cvv_result=' . implode ( ' ' , $ response -> cvv_result ( ) -> toA...
Logs an error .
38,258
protected function _serializeToArray ( $ item ) { $ result = array ( ) ; if ( is ( $ item , 'AnDomainBehaviorSerializable' ) ) { $ result = $ item -> toSerializableArray ( ) ; } else { $ result = ( array ) $ item ; } return $ result ; }
Serializes an item into an array .
38,259
public function getToolbarCommands ( $ name ) { $ result = array ( ) ; if ( $ this -> _state -> toolbar instanceof AnControllerToolbarAbstract ) { $ this -> _state -> toolbar -> reset ( ) ; $ method = 'add' . ucfirst ( $ name ) . 'Commands' ; if ( method_exists ( $ this -> _state -> toolbar , $ method ) ) { $ this -> _...
Gets the toolbar commands . This method checks if the view state has a toolbar .
38,260
protected function _toArray ( $ data ) { $ array = array ( ) ; foreach ( $ data as $ key => $ value ) { if ( is ( $ value , 'AnDomainBehaviorSerializable' ) ) { $ array [ $ key ] = $ value -> toSerializableArray ( ) ; } elseif ( is_array ( $ value ) ) { $ array [ $ key ] = $ this -> _toArray ( $ value ) ; } else { $ ar...
Return an array representation of the data . It iteratates through the data if an element implements toSerializableArray it will call it .
38,261
public function onBeforeControllerGet ( AnEvent $ event ) { parent :: onBeforeControllerGet ( $ event ) ; if ( ! $ this -> getController ( ) -> isIdentifiable ( ) ) { return ; } if ( $ item = $ this -> getController ( ) -> getItem ( ) ) { if ( $ this -> getController ( ) -> get == 'graph' ) { $ this -> _configureGraphB...
Set the header for the default actor .
38,262
protected function _configureGraphBar ( ) { $ entity = $ this -> getController ( ) -> getItem ( ) ; $ viewer = get_viewer ( ) ; $ types = array ( ) ; if ( $ entity -> isFollowable ( ) ) { $ types [ ] = 'Followers' ; } if ( $ entity -> isLeadable ( ) ) { $ types [ ] = 'Leaders' ; if ( ! $ viewer -> guest ( ) && ! $ enti...
Configure actorbar for when socialgraph is showing . This is temporary as the socialgraph should be moved into its own component .
38,263
protected function _configureBar ( ) { $ filters = array ( 'following' ) ; if ( $ this -> getController ( ) -> getRepository ( ) -> hasBehavior ( 'administrable' ) ) { $ filters [ ] = 'administering' ; } $ this -> setActor ( $ this -> getController ( ) -> actor ) ; foreach ( $ filters as $ filter ) { $ label = array ( ...
Configure actorbar for when a list of actor s related to another is showing .
38,264
protected function _beforeControllerAdd ( AnCommandContext $ context ) { if ( ! $ context -> data [ 'owner' ] instanceof ComActorsDomainEntityActor ) { if ( $ this -> getRepository ( ) -> hasBehavior ( 'ownable' ) ) { $ context -> data [ 'owner' ] = $ this -> actor ; } } }
If the context - > data actor is not already set them set the owner to the data before controller add .
38,265
public static function addMixin ( $ identifier , $ mixins ) { settype ( $ mixins , 'array' ) ; $ objIdentifier = self :: getIdentifier ( $ identifier ) ; $ strIdentifier = ( string ) $ objIdentifier ; if ( ! isset ( self :: $ _mixins [ $ strIdentifier ] ) ) { self :: $ _mixins [ $ strIdentifier ] = array ( ) ; } self :...
Add a mixin or an array of mixins for an identifier
38,266
public static function getMixins ( $ identifier ) { $ objIdentifier = self :: getIdentfier ( $ identifier ) ; $ strIdentifier = ( string ) $ objIdentifier ; $ result = array ( ) ; if ( isset ( self :: $ _mixins [ $ strIdentifier ] ) ) { $ result = self :: $ _mixins [ $ strIdentifier ] ; } return $ result ; }
Get the mixins for an identifier
38,267
public static function getAlias ( $ alias ) { return isset ( self :: $ _aliases [ $ alias ] ) ? self :: $ _aliases [ $ alias ] : null ; }
Get an alias for an identifier
38,268
public static function setConfig ( $ identifier , array $ config ) { $ objIdentifier = self :: getIdentifier ( $ identifier ) ; $ strIdentifier = ( string ) $ objIdentifier ; if ( isset ( self :: $ _configs [ $ strIdentifier ] ) ) { self :: $ _configs [ $ strIdentifier ] = self :: $ _configs [ $ strIdentifier ] -> appe...
Set the configuration options for an identifier
38,269
public static function getConfig ( $ identifier ) { $ objIdentifier = self :: getIdentifier ( $ identifier ) ; $ strIdentifier = ( string ) $ objIdentifier ; return isset ( self :: $ _configs [ $ strIdentifier ] ) ? self :: $ _configs [ $ strIdentifier ] -> toArray ( ) : array ( ) ; }
Get the configuration options for an identifier
38,270
protected static function _mixin ( $ identifier , $ instance ) { if ( isset ( self :: $ _mixins [ $ identifier ] ) && $ instance instanceof AnObject ) { $ mixins = self :: $ _mixins [ $ identifier ] ; foreach ( $ mixins as $ mixin ) { $ instance -> mixin ( $ mixin , self :: getConfig ( $ mixin ) ) ; } } }
Perform the actual mixin of all registered mixins with an object
38,271
public function changeSubscriptionTo ( $ package ) { if ( $ this -> _mixer -> hasSubscription ( false ) && ! $ this -> _mixer -> subscription -> package -> eql ( $ package ) ) { $ diff = max ( 0 , $ package -> duration - $ this -> _mixer -> subscription -> package -> duration ) ; $ end_date = clone $ this -> _mixer -> ...
Upgrades a person current subscription to a new one . It calculates the duration difference of the old package and new package and adds to the remaining time .
38,272
public function subscribeTo ( $ package ) { if ( ! $ this -> hasSubscription ( false ) ) { $ this -> _mixer -> subscription = $ this -> getService ( 'repos:subscriptions.subscription' ) -> getEntity ( array ( 'data' => array ( 'package' => $ package , ) , ) ) ; $ this -> _mixer -> verified = 1 ; } return $ this -> _mix...
Subscribe to a package .
38,273
public function hasSubscription ( $ checkValidity = true ) { if ( ! isset ( $ this -> _mixer -> subscription ) ) { return false ; } if ( $ checkValidity && $ this -> _mixer -> subscription -> getTimeLeft ( ) <= 0 ) { return false ; } return true ; }
Check if the person has subcription .
38,274
public function isSubscribedTo ( $ package ) { return $ this -> hasSubscription ( ) && $ this -> _mixer -> subscription -> package -> eql ( $ package ) ; }
Return whether the person is subscribed to a package or not .
38,275
public function toSerializableArray ( $ entity ) { $ data = array_intersect_key ( $ entity -> getData ( ) , $ entity -> getEntityDescription ( ) -> getAttributes ( ) ) ; return $ data ; }
Return an array of serializable data of the entity in format of associative array .
38,276
public function addAdministrator ( $ person ) { $ result = $ this -> administrators -> insert ( $ person ) ; if ( $ this -> isFollowable ( ) ) { $ this -> addFollower ( $ person ) ; } return $ result ; }
Adds a person as root administrator .
38,277
public function removeAdministrator ( $ person ) { $ result = $ this -> administrators -> extract ( $ person ) ; if ( ! $ result ) { $ this -> resetStats ( array ( $ this -> _mixer , $ person ) ) ; } return $ result ; }
Removes a person as the node administrator .
38,278
public function getAdminCanditates ( ) { $ viewer = get_viewer ( ) ; $ query = $ this -> getService ( 'repos:people.person' ) -> getQuery ( ) ; if ( ! $ viewer -> admin ( ) ) { $ ids = $ this -> _mixer -> followerIds -> toArray ( ) ; $ ids = array_merge ( $ ids , $ viewer -> followerIds -> toArray ( ) ) ; $ query -> id...
Return an entity set of suitable admin canditates .
38,279
public function onAuthenticate ( AnEvent $ event ) { $ credentials = $ event -> credentials ; $ response = $ event -> response ; if ( isset ( $ credentials -> username ) && isset ( $ credentials -> password ) ) { return ; } if ( ! ( isset ( $ credentials -> oauth_token ) && isset ( $ credentials -> oauth_handler ) ) ) ...
Authenticates a user using oauth_token oauth_secret .
38,280
public function possessiveNoune ( $ story , $ actor ) { if ( is_array ( $ actor ) || empty ( $ actor ) ) { $ value = AnTranslator :: _ ( 'LIB-AN-THEIR' ) ; } else { if ( $ actor -> eql ( $ story -> subject ) ) { $ value = AnTranslator :: _ ( AnService :: get ( 'com:actors.template.helper' ) -> noune ( $ actor , array (...
Return a possessive noune .
38,281
public function getEmailTemplateView ( ) { if ( ! $ this -> _template_view instanceof LibBaseViewTemplate ) { if ( ! isset ( $ this -> _template_view ) ) { $ this -> _template_view = clone $ this -> _mixer -> getIdentifier ( ) ; $ this -> _template_view -> path = array ( 'emails' ) ; $ this -> _template_view -> name = ...
Return the email view .
38,282
public function renderMail ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'layout' => 'default' , ) ) ; $ layout = $ config -> layout ; $ data = $ this -> getState ( ) -> toArray ( ) ; if ( $ this -> getState ( ) -> getItem ( ) ) { $ data [ $ this -> _mixer -> getIdentifi...
Retun the mail into a string .
38,283
public function mailAdmins ( $ config ) { $ admins = $ this -> getService ( 'repos:people.person' ) -> fetchSet ( array ( 'usertype' => ComPeopleDomainEntityPerson :: USERTYPE_SUPER_ADMINISTRATOR ) ) ; $ mails = array ( ) ; foreach ( $ admins as $ admin ) { $ mails [ ] = array ( 'subject' => $ config [ 'subject' ] , 't...
Replaces to with the admin emails .
38,284
public function onBeforeRender ( AnEvent $ event ) { if ( $ this -> _option == 'com_people' && $ this -> _viewer -> guest ( ) ) { if ( in_array ( $ this -> _view , array ( 'session' , 'person' ) ) ) { $ this -> _addScripts ( ) ; } } if ( $ this -> _option === 'com_groups' && $ this -> _view === 'group' && $ this -> _id...
onBeforeRender handler .
38,285
private function _addScripts ( ) { $ api = 'https://www.google.com/recaptcha/api.js' ; $ base = AnService :: get ( 'com:application' ) -> getRouter ( ) -> getBaseUrl ( ) ; $ recaptcha = $ base . '/media/plg_recaptcha/js/' ; $ recaptcha .= ANDEBUG ? 'recaptcha.js' : 'min/recaptcha.min.js' ; $ document = AnService :: get...
Adds required javascript code to the header .
38,286
private function _verifyResponse ( $ recaptchaResponse ) { $ data = http_build_query ( array ( 'secret' => $ this -> _params -> get ( 'secret-key' ) , 'response' => $ recaptchaResponse ) ) ; $ options = array ( 'http' => array ( 'method' => 'POST' , 'header' => 'Content-type: application/x-www-form-urlencoded' , 'conte...
Verifies the request reCaptcha token against the reCaptcha API
38,287
protected function _actionRead ( AnCommandContext $ context ) { if ( ! $ this -> getAPI ( ) ) { $ context -> response -> setRedirect ( route ( 'option=com_people&view=session' ) ) ; return false ; } $ service = $ this -> getAPI ( ) -> getName ( ) ; $ profileId = $ this -> getAPI ( ) -> getUser ( ) -> id ; $ token = $ t...
Redners the login form .
38,288
public function sendHeaders ( ) { if ( ! headers_sent ( ) ) { $ response = $ this -> getResponse ( ) ; foreach ( $ response -> getHeaders ( ) as $ name => $ value ) { header ( $ name . ': ' . $ value , false ) ; } header ( 'HTTP/1.1' . ' ' . $ response -> getStatusCode ( ) . ' ' . $ response -> getStatusMessage ( ) ) ;...
Send the headers .
38,289
public function send ( ) { $ response = $ this -> getResponse ( ) ; if ( in_array ( $ response -> getStatusCode ( ) , array ( 204 , 304 ) ) ) { $ response -> setContent ( null ) ; } $ this -> sendHeaders ( ) -> sendContent ( ) ; fastcgi_finish_request ( ) ; }
Sends the transport .
38,290
protected function _validate ( $ value ) { if ( is_array ( $ value ) ) { $ value = $ this -> _arrayToDate ( $ value ) ; } $ expr = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/D' ; return ( preg_match ( $ expr , $ value , $ match ) && checkdate ( $ match [ 2 ] , $ match [ 3 ] , $ match [ 1 ] ) ) ; }
Validates that a value is an ISO 8601 date string
38,291
protected function _afterEntityInstantiate ( AnConfig $ config ) { $ settings = $ this -> getService ( 'com:settings.setting' ) ; $ config -> append ( array ( 'data' => array ( 'value' => hash ( 'sha256' , str_shuffle ( $ settings -> secret . ( ( string ) ( int ) microtime ( true ) ) ) ) ) ) ) ; }
Generate a default token .
38,292
public function write ( & $ text ) { if ( preg_match_all ( '#<\s*form.*?action=""#im' , $ text , $ matches , PREG_SET_ORDER ) ) { $ view = $ this -> getTemplate ( ) -> getView ( ) ; $ state = $ view -> getModel ( ) -> getState ( ) ; $ action = $ view -> getRoute ( http_build_query ( $ state -> getData ( $ state -> isUn...
Add unique token field
38,293
protected function _renderQuery ( $ query , $ key = '' ) { $ input = '' ; foreach ( $ query as $ name => $ value ) { $ name = $ key ? $ key . '[' . $ name . ']' : $ name ; if ( is_array ( $ value ) ) { $ input .= $ this -> _renderQuery ( $ value , $ name ) ; } else { $ input .= PHP_EOL . '<input type="hidden" name="' ....
Recursive function that transforms the query array into a string of input elements
38,294
protected function _afterEntityInstantiate ( AnConfig $ config ) { if ( AnService :: has ( 'com:people.viewer' ) ) { $ config -> data -> append ( array ( 'author' => AnService :: get ( 'com:people.viewer' ) , ) ) ; } }
Executes the command after . instantiate .
38,295
public function setAuthor ( $ author ) { $ this -> set ( 'author' , $ author ) ; $ this -> creationTime = AnDomainAttributeDate :: getInstance ( ) ; $ this -> editor = $ author ; }
Set author of a node . By setting an author the editor is also set to the author . The creationTime property is also updated .
38,296
public function timestamp ( ) { $ this -> updateTime = AnDomainAttributeDate :: getInstance ( ) ; if ( ! isset ( $ this -> creationTime ) ) { $ this -> creationTime = AnDomainAttributeDate :: getInstance ( ) ; } }
Timestamping a node .
38,297
protected function _beforeEntityUpdate ( AnCommandContext $ context ) { $ entity = $ context -> entity ; $ modified = array_keys ( AnConfig :: unbox ( $ entity -> getModifiedData ( ) ) ) ; $ modified = count ( array_intersect ( $ this -> _modifiable_properties , $ modified ) ) > 0 ; if ( $ modified && AnService :: has ...
Before Update timestamp modified on and modifier .
38,298
public static function addAdapter ( AnLoaderAdapterInterface $ adapter ) { self :: $ _adapters [ $ adapter -> getType ( ) ] = $ adapter ; self :: $ _prefix_map [ $ adapter -> getPrefix ( ) ] = $ adapter -> getType ( ) ; }
Add a loader adapter
38,299
public function loadIdentifier ( $ identifier ) { $ result = false ; $ identifier = AnService :: getIdentifier ( $ identifier ) ; $ path = $ identifier -> filepath ; if ( $ path !== false ) { $ result = self :: loadFile ( $ path ) ; } return $ result ; }
Load a class based on an identifier