idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
17,700 | public function equals ( StatementObject $ actor ) : bool { if ( ! parent :: equals ( $ actor ) ) { return false ; } if ( ! $ actor instanceof Actor ) { return false ; } if ( $ this -> name !== $ actor -> name ) { return false ; } if ( null !== $ this -> iri xor null !== $ actor -> iri ) { return false ; } if ( null !== $ this -> iri && null !== $ actor -> iri && ! $ this -> iri -> equals ( $ actor -> iri ) ) { return false ; } return true ; } | Checks if another actor is equal . |
17,701 | public static function mkdir ( $ path , $ mode = 0755 ) { $ filesystem = new Filesystem ( ) ; try { $ filesystem -> mkdir ( $ path , $ mode ) ; } catch ( IOException $ exception ) { return false ; } return true ; } | Create a directory structure recursiveley |
17,702 | public static function rmdir ( $ path ) { $ files = array_diff ( scandir ( $ path ) , array ( '.' , '..' ) ) ; $ filesystem = new Filesystem ( ) ; foreach ( $ files as $ file ) { $ file = $ path . DIRECTORY_SEPARATOR . $ file ; if ( ! file_exists ( $ file ) ) { continue ; } try { $ filesystem -> remove ( $ file ) ; } catch ( IOException $ exception ) { return false ; } } return true ; } | Recursiely remove all files from the given directory NOT including the specified directory itself |
17,703 | private static function detectStream ( $ path ) { $ stream = 'file' ; if ( false !== strpos ( $ path , '://' ) ) { $ parts = explode ( '://' , $ path ) ; $ stream = $ parts [ 0 ] ; } return $ stream ; } | detects if the the path is linked to an file stream |
17,704 | public function getAll ( array $ queryParams = [ ] ) { $ response = $ this -> api -> languages ( ) -> getAll ( $ queryParams ) ; return new LanguagesResponse ( $ response ) ; } | Get a collection of language objects |
17,705 | public function getById ( $ languageId , array $ queryParams = [ ] ) { $ response = $ this -> api -> languages ( ) -> getById ( $ languageId , $ queryParams ) ; return new LanguageResponse ( $ response ) ; } | Get a language by id |
17,706 | private function calculateFrameOptions ( ) { $ retval = null ; $ nb_site = $ this -> nb_request -> getSite ( ) ; switch ( $ nb_site -> getXFrameOptions ( ) ) { case 'D' : $ retval = 'DENY' ; break ; case 'S' : $ retval = 'SAMEORIGIN' ; break ; case 'A' : if ( is_string ( $ url = $ nb_site -> getXFrameOptionsURL ( ) ) && strlen ( $ url = preg_replace ( array ( '/^\s*/' , '/\s*$/' ) , '' , $ url ) ) > 0 ) { $ retval = 'ALLOW-FROM ' . $ url ; } else { throw new ENabuHTTPException ( ENabuHTTPException :: ERROR_X_FRAME_OPTIONS_URL_NOT_FOUND ) ; } } return $ retval ; } | Calculates the X - Frame - Options value if setted . |
17,707 | public function buildHeaders ( ) { if ( $ this -> use_cors ) { if ( strlen ( $ this -> cors_allow_origin ) > 0 ) { header ( "Access-Control-Allow-Origin: $this->cors_allow_origin" ) ; } if ( $ this -> cors_with_credentials ) { header ( 'Access-Control-Allow-Credentials: true' ) ; } else { header ( 'Access-Control-Allow-Credentials: false' ) ; } } if ( $ this -> nb_request instanceof CNabuHTTPRequest && ( $ nb_site_target = $ this -> nb_request -> getSiteTarget ( ) ) instanceof CNabuSiteTarget ) { if ( ( $ max_age = $ nb_site_target -> getDynamicCacheEffectiveMaxAge ( ) ) !== false ) { $ expire_date = gmdate ( "D, d M Y H:i:s" , time ( ) + $ max_age ) ; $ this -> setHeader ( 'Expires' , $ expire_date . 'GMT' ) ; $ this -> setHeader ( 'Cache-Control' , "max-age=$max_age" ) ; $ this -> setHeader ( 'User-Cache-Control' , "max-age=$max_age" ) ; $ this -> setHeader ( 'Pragma' , 'cache' ) ; } else { $ this -> setHeader ( 'Expires' , 'Thu, 1 Jan 1981 00:00:00 GMT' ) ; $ this -> setheader ( 'Cache-Control' , 'no-store, no-cache, must-revalidate' ) ; $ this -> setHeader ( 'Pragma' , 'no-cache' ) ; } if ( $ nb_site_target -> getAttachment ( ) === 'T' ) { if ( is_string ( $ this -> attachment_filename ) && strlen ( $ this -> attachment_filename ) > 0 ) { $ this -> setHeader ( 'Content-Disposition' , 'attachment; filename=' . $ this -> attachment_filename ) ; } else { $ this -> setHeader ( 'Content-Disposition' , 'attachment' ) ; } } } if ( ( $ frame_options = $ this -> calculateFrameOptions ( ) ) !== null ) { $ this -> setHeader ( 'X-Frame-Options' , $ frame_options ) ; } if ( count ( $ this -> header_list ) > 0 ) { foreach ( $ this -> header_list as $ name => $ value ) { header ( "$name: $value" ) ; } } } | Build HTTP Headers . |
17,708 | public function getRender ( ) { if ( $ this -> render_factory !== null ) { $ retval = $ this -> render_factory -> getInterface ( ) ; } else { $ retval = $ this -> render ; } return $ retval ; } | Get the current Render for this response . |
17,709 | public function redirect ( $ code , $ nb_site_target , $ nb_language = null , $ params = null ) { global $ NABU_HTTP_CODES ; if ( is_string ( $ nb_site_target ) ) { $ url = new CNabuURL ( $ nb_site_target ) ; if ( ! $ url -> isValid ( ) ) { $ nb_site_target = CNabuSiteTarget :: findByKey ( $ this , $ nb_site_target ) ; unset ( $ url ) ; } } elseif ( is_numeric ( $ nb_site_target ) ) { $ nb_site_target = new CNabuSiteTarget ( $ nb_site_target ) ; if ( $ nb_site_target -> isNew ( ) ) { $ nb_site_target = null ; } } elseif ( $ nb_site_target instanceof CNabuDataObject ) { if ( ! ( $ nb_site_target instanceof CNabuSiteTarget ) ) { $ nb_site_target = new CNabuSiteTarget ( $ nb_site_target ) ; if ( $ nb_site_target -> isNew ( ) ) { $ nb_site_target = null ; } } } else { $ nb_site_target = null ; } if ( $ nb_site_target != null ) { $ encoded = '' ; if ( $ params != null && count ( $ params ) > 0 ) { foreach ( $ params as $ field => $ value ) { $ encoded .= ( strlen ( $ encoded ) > 0 ? "&" : "" ) . urlencode ( $ field ) . "=" . urlencode ( $ value ) ; } $ encoded = '?' . $ encoded ; } $ nb_language_id = nb_getMixedValue ( $ nb_language , 'nb_language_id' ) ; $ nb_site = $ this -> nb_request -> getSite ( ) ; if ( $ nb_language_id == null ) { $ nb_language_id = $ nb_site -> getDefaultLanguageId ( ) ; } $ url = ( $ nb_site_target instanceof CNabuSiteTarget ? $ nb_site_target -> getFullyQualifiedURL ( $ nb_language_id ) . $ encoded : $ nb_site_target ) ; throw new ENabuRedirectionException ( $ code , $ url ) ; } elseif ( isset ( $ url ) ) { throw new ENabuRedirectionException ( $ code , $ url -> getURL ( ) ) ; } else { $ this -> http_response_code = 500 ; throw new ENabuCoreException ( ENabuCoreException :: ERROR_REDIRECTION_TARGET_NOT_VALID ) ; } } | This function makes the redirection to another page . Parameters permits a wide range of options . |
17,710 | public function query ( $ q , $ params = array ( ) ) { try { if ( ! empty ( $ this -> pdo ) ) { $ this -> st = $ this -> pdo -> prepare ( $ q ) ; if ( ! empty ( $ params ) ) { $ keys = array_keys ( $ params ) ; $ qmark = false ; if ( is_int ( $ keys [ 0 ] ) ) { $ qmark = true ; } foreach ( $ params as $ p => $ val ) { if ( $ qmark ) { $ p += 1 ; } if ( is_array ( $ val ) && count ( $ val ) == 2 ) { $ this -> st -> bindValue ( $ p , $ val [ 0 ] , $ val [ 1 ] ) ; } else { if ( ! is_bool ( $ val ) ) { $ this -> st -> bindValue ( $ p , $ val ) ; } else { $ this -> st -> bindValue ( $ p , $ val , PDO :: PARAM_INT ) ; } } } } $ this -> st -> execute ( ) ; return $ this -> st ; } else { throw new DBException ( 'PDO attribute is undefined' ) ; } } catch ( \ Exception $ e ) { throw new DBException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } } | execute a SQL query with params |
17,711 | public function getUserInfo ( array $ params ) { $ this -> logger -> debug ( 'Get User Info.' ) ; if ( array_key_exists ( "error" , $ params ) ) { $ this -> logger -> error ( $ params [ "error" ] . array_key_exists ( "error_description" , $ params ) ? $ params [ "error_description" ] : '' ) ; throw new Exception ( 'FranceConnect error => ' . $ params [ "error" ] ) ; } $ this -> verifyState ( $ params [ 'state' ] ) ; $ accessToken = $ this -> getAccessToken ( $ params [ 'code' ] ) ; $ userInfo = $ this -> getInfos ( $ accessToken ) ; $ userInfo [ 'access_token' ] = $ accessToken ; $ token = new FranceConnectToken ( $ userInfo , [ FranceConnectAuthenticatedVoter :: IS_FRANCE_CONNECT_AUTHENTICATED , AuthenticatedVoter :: IS_AUTHENTICATED_ANONYMOUSLY , ] ) ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( null !== $ request ) { $ this -> sessionStrategy -> onAuthentication ( $ request , $ token ) ; } $ this -> tokenStorage -> setToken ( $ token ) ; foreach ( $ this -> providersKeys as $ key ) { $ this -> session -> set ( '_security_' . $ key , serialize ( $ token ) ) ; } return json_encode ( $ userInfo , true ) ; } | Returns data provided by FranceConnect . |
17,712 | private function verifyState ( $ state ) { $ this -> logger -> debug ( 'Verify parameter state.' ) ; $ state = urldecode ( $ state ) ; $ stateArray = [ ] ; parse_str ( $ state , $ stateArray ) ; $ token = $ stateArray [ 'token' ] ; $ token = preg_replace ( '~{~' , '' , $ token , 1 ) ; $ token = preg_replace ( '~}~' , '' , $ token , 1 ) ; if ( $ token != $ this -> session -> get ( static :: OPENID_SESSION_TOKEN ) ) { $ this -> logger -> error ( 'The value of the parameter STATE is not equal to the one which is expected' ) ; throw new SecurityException ( "The token is invalid." ) ; } } | Check state parameter for security reason . |
17,713 | private function getAccessToken ( $ code ) { $ this -> logger -> debug ( 'Get Access Token.' ) ; $ this -> initRequest ( ) ; $ token_url = $ this -> fcBaseUrl . 'token' ; $ post_data = [ "grant_type" => "authorization_code" , "redirect_uri" => $ this -> callbackUrl , "client_id" => $ this -> clientId , "client_secret" => $ this -> clientSecret , "code" => $ code , ] ; $ this -> logger -> debug ( 'POST Data to FranceConnect.' ) ; $ this -> setPostFields ( $ post_data ) ; $ response = \ Unirest \ Request :: post ( $ token_url ) ; if ( $ response -> code != Response :: HTTP_OK ) { $ result_array = $ response -> body ; $ description = array_key_exists ( "error_description" , $ result_array ) ? $ result_array [ "error_description" ] : '' ; $ this -> logger -> error ( $ result_array [ "error" ] . $ description ) ; throw new Exception ( "FranceConnectError" . $ response -> code . " msg = " . $ response -> raw_body ) ; } $ result_array = $ response -> body ; $ id_token = $ result_array [ 'id_token' ] ; $ this -> session -> set ( static :: ID_TOKEN_HINT , $ id_token ) ; $ all_part = explode ( "." , $ id_token ) ; $ payload = json_decode ( base64_decode ( $ all_part [ 1 ] ) , true ) ; if ( $ payload [ 'nonce' ] != $ this -> session -> get ( static :: OPENID_SESSION_NONCE ) ) { $ this -> logger -> error ( 'The value of the parameter NONCE is not equal to the one which is expected' ) ; throw new SecurityException ( "The nonce parameter is invalid" ) ; } $ this -> logger -> debug ( 'Check JWT signature.' ) ; $ jws = SimpleJWS :: load ( $ id_token ) ; if ( ! $ jws -> verify ( $ this -> clientSecret ) ) { $ this -> logger -> error ( 'The signature of the JWT is not valid.' ) ; throw new SecurityException ( "JWS is invalid" ) ; } $ this -> session -> remove ( static :: OPENID_SESSION_NONCE ) ; return $ result_array [ 'access_token' ] ; } | Get Access Token . |
17,714 | private function setPostFields ( array $ post_data ) { $ pd = [ ] ; foreach ( $ post_data as $ k => $ v ) { $ pd [ ] = "$k=$v" ; } $ pd = implode ( "&" , $ pd ) ; \ Unirest \ Request :: curlOpt ( CURLOPT_POST , true ) ; \ Unirest \ Request :: curlOpt ( CURLOPT_POSTFIELDS , $ pd ) ; \ Unirest \ Request :: curlOpt ( CURLOPT_HTTPHEADER , [ 'Content-Type: application/x-www-form-urlencoded' ] ) ; } | set post fields . |
17,715 | public function getAll ( $ appId , $ scanId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> sources ( ) -> getAll ( $ appId , $ scanId , $ queryParams ) ; return new SourcesResponse ( $ response ) ; } | Get all sources for a scan |
17,716 | public function getById ( $ appId , $ scanId , $ sourceId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> sources ( ) -> getById ( $ appId , $ scanId , $ sourceId , $ queryParams ) ; return new SourceResponse ( $ response ) ; } | Get source for scan by id |
17,717 | public function equals ( InverseFunctionalIdentifier $ iri ) : bool { if ( null !== $ this -> mbox && null !== $ iri -> mbox && ! $ this -> mbox -> equals ( $ iri -> mbox ) ) { return false ; } if ( $ this -> mboxSha1Sum !== $ iri -> mboxSha1Sum ) { return false ; } if ( $ this -> openId !== $ iri -> openId ) { return false ; } if ( null === $ this -> account && null !== $ iri -> account ) { return false ; } if ( null !== $ this -> account && null === $ iri -> account ) { return false ; } if ( null !== $ this -> account && ! $ this -> account -> equals ( $ iri -> account ) ) { return false ; } return true ; } | Checks if another IRI is equal . |
17,718 | public function getAll ( $ appId = null , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> uploads ( ) -> getAll ( $ appId , $ queryParams ) ; return new UploadsResponse ( $ response ) ; } | Get all uploads for an application |
17,719 | public function getById ( $ appId , $ uploadId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> uploads ( ) -> getById ( $ appId , $ uploadId , $ queryParams ) ; return new UploadResponse ( $ response ) ; } | Get upload for application by id |
17,720 | public function deleteAll ( $ appId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> uploads ( ) -> deleteAll ( $ appId , $ queryParams ) ; return new BaseResponse ( $ response ) ; } | Delete all uploads for an application |
17,721 | public function deleteById ( $ appId , $ uploadId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> uploads ( ) -> deleteById ( $ appId , $ uploadId , $ queryParams ) ; return new BaseResponse ( $ response ) ; } | Delete upload for an application by id |
17,722 | public static function hydrate ( stdClass $ ignore ) { $ hydrated = new IgnoredCodeEntity ( ) ; if ( isset ( $ ignore -> id ) ) { $ hydrated -> setId ( $ ignore -> id ) ; } if ( isset ( $ ignore -> class ) ) { $ hydrated -> setClass ( $ ignore -> class ) ; } if ( isset ( $ ignore -> method ) ) { $ hydrated -> setMethod ( $ ignore -> method ) ; } if ( isset ( $ ignore -> exclude ) ) { $ hydrated -> setExclude ( $ ignore -> exclude ) ; } return $ hydrated ; } | Hydrate a ignore object into a IgnoredCodeEntity object |
17,723 | public static function hydrateCollection ( array $ acls ) { $ hydrated = [ ] ; foreach ( $ acls as $ acl ) { $ hydrated [ ] = self :: hydrate ( $ acl ) ; } return $ hydrated ; } | Hydrate a collection of acl objects into a collection of AclEntity objects |
17,724 | public function setServerId ( int $ nb_server_id ) : CNabuDataObject { if ( $ nb_server_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_server_id" ) ) ; } $ this -> setValue ( 'nb_server_id' , $ nb_server_id ) ; return $ this ; } | Sets the Server Id attribute value . |
17,725 | public function setIPId ( int $ nb_ip_id ) : CNabuDataObject { if ( $ nb_ip_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_ip_id" ) ) ; } $ this -> setValue ( 'nb_ip_id' , $ nb_ip_id ) ; return $ this ; } | Sets the IP Id attribute value . |
17,726 | public function setClusterGroupServiceId ( int $ nb_cluster_group_service_id ) : CNabuDataObject { if ( $ nb_cluster_group_service_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_cluster_group_service_id" ) ) ; } $ this -> setValue ( 'nb_cluster_group_service_id' , $ nb_cluster_group_service_id ) ; return $ this ; } | Sets the Cluster Group Service Id attribute value . |
17,727 | public function setPort ( int $ port = 80 ) : CNabuDataObject { if ( $ port === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$port" ) ) ; } $ this -> setValue ( 'nb_server_host_port' , $ port ) ; return $ this ; } | Sets the Server Host Port attribute value . |
17,728 | public static function findByURL ( CNabuSite $ nb_site , string $ target_url ) { $ retval = null ; if ( $ nb_site -> isPublicBasePathEnabled ( ) ) { $ check_pbp = CNabuEngine :: getEngine ( ) -> getMainDB ( ) -> getQueryAsSingleField ( 'nb_site_lang_public_base_path' , "SELECT * FROM nb_site_lang WHERE nb_site_id=%site_id\$d AND length(nb_site_lang_public_base_path) > 0 AND instr('%url\$s', nb_site_lang_public_base_path)=1 LIMIT 1" , array ( 'site_id' => $ nb_site -> getId ( ) , 'url' => $ target_url ) ) ; if ( strlen ( $ check_pbp ) > 0 ) { $ target_url = substr ( $ target_url , strlen ( $ check_pbp ) ) ; } else { $ target_url = null ; } } if ( $ target_url !== null ) { $ retval = CNabuSiteTarget :: buildObjectFromSQL ( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='U' AND cal.nb_site_target_lang_url='%url\$s' LIMIT 1" , array ( 'site_id' => $ nb_site -> getId ( ) , 'url' => $ target_url ) ) ?? CNabuSiteTarget :: buildObjectFromSQL ( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='R' AND length(cal.nb_site_target_lang_url)>0 AND '%url\$s' REGEXP cal.nb_site_target_lang_url ORDER BY ca.nb_site_target_order ASC LIMIT 1" , array ( 'site_id' => $ nb_site -> getValue ( 'nb_site_id' ) , 'url' => $ target_url ) ) ?? CNabuSiteTarget :: buildObjectFromSQL ( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='L' AND length(cal.nb_site_target_lang_url)>0 AND '%url\$s' LIKE cal.nb_site_target_lang_url ORDER BY ca.nb_site_target_order ASC LIMIT 1" , array ( 'site_id' => $ nb_site -> getId ( ) , 'url' => $ target_url ) ) ; } if ( $ retval !== null ) { $ retval -> setSite ( $ nb_site ) ; } return $ retval ; } | Locate a Target by their URL . If the Site is multi - language the search is performed in all languages . Accessible via getValue method you can access to additional fields nb_language_id and nb_site_target_lang_url . |
17,729 | public function addCTAObject ( CNabuSiteTargetCTA $ nb_site_target_cta ) { $ nb_site_target_cta -> setSiteTarget ( $ this ) ; return $ this -> nb_site_target_cta_list -> addItem ( $ nb_site_target_cta ) ; } | Add a CTA to this Site Target instance . |
17,730 | public function getCTAs ( $ force = false ) { if ( $ this -> nb_site_target_cta_list -> isEmpty ( ) || $ force ) { $ this -> nb_site_target_cta_list -> clear ( ) ; $ this -> nb_site_target_cta_list -> merge ( CNabuSiteTargetCTA :: getSiteTargetCTAs ( $ this ) ) ; $ translations = CNabuSiteTargetCTALanguage :: getCTATranslationsForSiteTarget ( $ this ) ; if ( is_array ( $ translations ) && count ( $ translations ) > 0 ) { foreach ( $ translations as $ translation ) { $ nb_site_target_cta = $ this -> nb_site_target_cta_list -> getItem ( $ translation -> getSiteTargetCTAId ( ) ) ; if ( $ nb_site_target_cta instanceof CNabuSiteTargetCTA ) { $ nb_site_target_cta -> setTranslation ( $ translation ) ; } } } $ roles = CNabuSiteTargetCTARole :: getCTARolesForSiteTarget ( $ this ) ; if ( is_array ( $ roles ) && count ( $ roles ) > 0 ) { foreach ( $ roles as $ role ) { $ nb_site_target_cta = $ this -> nb_site_target_cta_list -> getItem ( $ role -> getSiteTargetCTAId ( ) ) ; if ( $ nb_site_target_cta instanceof CNabuSiteTargetCTA ) { $ nb_site_target_cta -> addRole ( $ role ) ; } } } } return $ this -> nb_site_target_cta_list ; } | Get CTAs assigned to this Site Target instance . |
17,731 | public function getCTAByKey ( $ key , $ force = false ) { $ this -> getCTAs ( $ force ) ; return $ this -> nb_site_target_cta_list -> getItem ( $ key , CNabuSiteTargetCTAList :: INDEX_KEY ) ; } | Gets a CTA from the list of CTAs using their key . |
17,732 | public function getDynamicCacheEffectiveMaxAge ( ) { if ( ( $ nb_site = $ this -> getSite ( ) ) === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_SITE_NOT_FOUND ) ; } $ retval = false ; if ( ( $ nb_application = CNabuEngine :: getEngine ( ) -> getApplication ( ) ) !== null ) { if ( ( $ nb_running_site = $ nb_application -> getRequest ( ) -> getSite ( ) ) instanceof CNabuSite && ( $ nb_running_site -> getId ( ) === $ nb_site -> getId ( ) ) ) { if ( ( $ nb_security_manager = $ nb_application -> getSecurityManager ( ) ) !== null && ( ! $ nb_security_manager -> isUserLogged ( ) || $ nb_security_manager -> arePoliciesAccepted ( ) ) ) { $ site_cache_control = $ nb_site -> getDynamicCacheControl ( ) ; $ site_max_age = $ nb_site -> getDynamicCacheDefaultMaxAge ( ) ; $ target_cache_control = $ this -> getDynamicCacheControl ( ) ; $ target_max_age = $ this -> getDynamicCacheMaxAge ( ) ; if ( $ target_cache_control === self :: DYNAMIC_CACHE_CONTROL_INHERITED && $ site_cache_control === CNabuSite :: DYNAMIC_CACHE_CONTROL_ENABLED && is_numeric ( $ site_max_age ) && $ site_max_age > 0 ) { $ retval = $ site_max_age ; } elseif ( $ target_cache_control === self :: DYNAMIC_CACHE_CONTROL_ENABLED && is_numeric ( $ target_max_age ) && $ target_max_age > 0 ) { $ retval = $ target_max_age ; } } } else { throw new ENabuCoreException ( ENabuCoreException :: ERROR_SITES_DOES_NOT_MATCH ) ; } } else { throw new ENabuCoreException ( ENabuCoreException :: ERROR_APPLICATION_REQUIRED ) ; } return $ retval ; } | Gets the effective max - age value for Cache - Control HTTP Headers . This method only returns a valid value it the Target is running inside their Application . |
17,733 | public function logAccess ( ) { $ this -> db -> executeUpdate ( "update nb_site_user " . "set nb_site_user_last_login_datetime=now() " . "where nb_site_id=%site_id\$d " . "and nb_role_id=%role_id\$d " . "and nb_user_id=%user_id\$d" , array ( 'site_id' => $ this -> getValue ( 'nb_site_id' ) , 'role_id' => $ this -> getValue ( 'nb_role_id' ) , 'user_id' => $ this -> getValue ( 'nb_user_id' ) ) ) ; } | Upate table to set last access datetime of the user . |
17,734 | public static function getSitesForUser ( $ nb_user ) { if ( is_numeric ( $ nb_user_id = nb_getMixedValue ( $ nb_user , NABU_USER_FIELD_ID ) ) ) { $ retval = CNabuSiteUser :: buildObjectListFromSQL ( 'nb_site_id' , 'SELECT su.* FROM nb_site_user su, nb_user u, nb_site s WHERE su.nb_user_id=u.nb_user_id AND su.nb_site_id=s.nb_site_id AND su.nb_user_id=%user_id$d' , array ( 'user_id' => $ nb_user_id ) , ( $ nb_user instanceof CNabuUser ? $ nb_user : null ) ) ; } else { $ retval = new CNabuSiteUserList ( ) ; } return $ retval ; } | Get the list of Profiles of a User . |
17,735 | public static function getAvailableSitesForUser ( CNabuCustomer $ nb_customer , $ nb_user ) { if ( $ nb_customer -> isFetched ( ) && is_numeric ( $ nb_user_id = nb_getMixedValue ( $ nb_user , NABU_USER_FIELD_ID ) ) ) { if ( ! ( $ nb_user = $ nb_customer -> getUser ( $ nb_user_id ) ) ) { throw new ENabuSecurityException ( ENabuSecurityException :: ERROR_USER_NOT_ALLOWED ) ; } $ retval = CNabuSite :: buildObjectListFromSQL ( 'nb_site_id' , 'SELECT s.*, su.nb_user_id FROM nb_site s LEFT OUTER JOIN nb_site_user su ON s.nb_site_id=su.nb_site_id AND su.nb_user_id=%user_id$d WHERE s.nb_customer_id=%cust_id$d HAVING su.nb_user_id IS NULL' , array ( 'cust_id' => $ nb_customer -> getId ( ) , 'user_id' => $ nb_user -> getId ( ) ) , $ nb_customer ) ; } else { $ retval = new CNabuSiteList ( $ nb_customer ) ; } return $ retval ; } | Get not subscribed available Sites for a User . |
17,736 | protected function writeStatus ( $ status , $ webExecution ) { if ( $ webExecution ) { $ cachedStatus = unserialize ( Cache :: get ( 'scaffolder-status' ) ) ; array_push ( $ cachedStatus , $ status ) ; Cache :: forever ( 'scaffolder-status' , serialize ( $ cachedStatus ) ) ; } else { $ this -> info ( $ status ) ; } } | Store status in cache or print . |
17,737 | public function getAll ( array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> getAll ( $ queryParams ) ; return new QuotasResponse ( $ response ) ; } | Get all quotas |
17,738 | public function create ( QuotaBuilder $ input , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> create ( $ input -> toArray ( ) , $ queryParams ) ; return new QuotaResponse ( $ response ) ; } | Create a new quota |
17,739 | public function update ( $ quotaId , QuotaBuilder $ input , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> update ( $ quotaId , $ input -> toArray ( ) , $ queryParams ) ; return new QuotaResponse ( $ response ) ; } | Update an existing quota |
17,740 | public function deleteAll ( array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> deleteAll ( $ queryParams ) ; return new BaseResponse ( $ response ) ; } | Delete all quotas |
17,741 | public static function hydrateCollection ( array $ contexts ) { $ hydrated = [ ] ; foreach ( $ contexts as $ context ) { $ hydrated [ ] = self :: hydrate ( $ context ) ; } return $ hydrated ; } | Hydrate a collection of context objects into a collection of ContextEntity objects |
17,742 | public static function hydrate ( stdClass $ context ) { $ hydrated = new ContextEntity ( ) ; if ( isset ( $ context -> id ) ) { $ hydrated -> setId ( $ context -> id ) ; } if ( isset ( $ context -> parts ) ) { $ hydrated -> setParts ( PartHydrator :: hydrateCollection ( $ context -> parts ) ) ; } return $ hydrated ; } | Hydrate a context object into a ContextEntity object |
17,743 | public static function findByKey ( $ nb_messaging , $ key ) { $ nb_messaging_id = nb_getMixedValue ( $ nb_messaging , 'nb_messaging_id' ) ; if ( is_numeric ( $ nb_messaging_id ) ) { $ retval = CNabuMessagingService :: buildObjectFromSQL ( 'select * ' . 'from nb_messaging_service ' . 'where nb_messaging_id=%messaging_id$d ' . "and nb_messaging_service_key='%key\$s'" , array ( 'messaging_id' => $ nb_messaging_id , 'key' => $ key ) ) ; } else { $ retval = null ; } return $ retval ; } | Find an instance identified by nb_messaging_service_key field . |
17,744 | public static function getFilteredMessagingServiceList ( $ nb_messaging = null , $ q = null , $ fields = null , $ order = null , $ offset = 0 , $ num_items = 0 ) { $ nb_messaging_id = nb_getMixedValue ( $ nb_customer , NABU_MESSAGING_FIELD_ID ) ; if ( is_numeric ( $ nb_messaging_id ) ) { $ fields_part = nb_prefixFieldList ( CNabuMessagingServiceBase :: getStorageName ( ) , $ fields , false , true , '`' ) ; $ order_part = nb_prefixFieldList ( CNabuMessagingServiceBase :: getStorageName ( ) , $ fields , false , false , '`' ) ; if ( $ num_items !== 0 ) { $ limit_part = ( $ offset > 0 ? $ offset . ', ' : '' ) . $ num_items ; } else { $ limit_part = false ; } $ nb_item_list = CNabuEngine :: getEngine ( ) -> getMainDB ( ) -> getQueryAsArray ( "select " . ( $ fields_part ? $ fields_part . ' ' : '* ' ) . 'from nb_messaging_service ' . 'where ' . NABU_MESSAGING_FIELD_ID . '=%messaging_id$d ' . ( $ order_part ? "order by $order_part " : '' ) . ( $ limit_part ? "limit $limit_part" : '' ) , array ( 'messaging_id' => $ nb_messaging_id ) ) ; } else { $ nb_item_list = null ; } return $ nb_item_list ; } | Gets a filtered list of Messaging Service instances represented as an array . Params allows the capability of select a subset of fields order by concrete fields or truncate the list by a number of rows starting in an offset . |
17,745 | public function setCustomer ( CNabuCustomer $ nb_customer , $ field = NABU_CUSTOMER_FIELD_ID ) { $ this -> nb_customer = $ nb_customer ; if ( $ this instanceof CNabuDataObject ) { if ( $ nb_customer !== null ) { $ this -> transferValue ( $ nb_customer , NABU_CUSTOMER_FIELD_ID , $ field ) ; } else { $ this -> setValue ( NABU_CUSTOMER_FIELD_ID , null ) ; } } return $ this ; } | Sets the customer instance that owns this object and sets the field containing the customer id . |
17,746 | public function validateCustomer ( $ nb_customer ) { $ nb_customer_id = nb_getMixedValue ( $ nb_customer , NABU_CUSTOMER_FIELD_ID ) ; return ( $ this instanceof CNabuDataObject ) && ( is_numeric ( $ nb_customer_id ) || nb_isValidGUID ( $ nb_customer_id ) ) && $ this -> isValueEqualThan ( NABU_CUSTOMER_FIELD_ID , $ nb_customer_id ) ; } | Checks if the object is owned by the customer passed as param . |
17,747 | public function getRenderFactory ( CNabuRenderInterfaceDescriptor $ nb_descriptor ) { if ( ! ( $ retval = $ this -> nb_render_factory_list -> getItem ( $ nb_descriptor -> getKey ( ) ) ) ) { $ retval = $ this -> nb_render_factory_list -> addItem ( new CNabuRenderFactory ( $ nb_descriptor ) ) ; } return $ retval ; } | Gets a Render Factory instance for a Descriptor . If Factory instance already exists then returns it . |
17,748 | public function getTransformFactory ( CNabuRenderTransformInterfaceDescriptor $ nb_descriptor ) { if ( ! ( $ retval = $ this -> nb_render_transform_factory_list -> getItem ( $ nb_descriptor -> getKey ( ) ) ) ) { $ retval = $ this -> nb_render_transform_factory_list -> addItem ( new CNabuRenderTransformFactory ( $ nb_descriptor ) ) ; } return $ retval ; } | Gets a Render Transform Factory instance for a Descriptor . If Factory instance already exists then returns it . |
17,749 | public function getById ( $ quotaId , $ aclId , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> acls ( ) -> getById ( $ quotaId , $ aclId , $ queryParams ) ; return new AclResponse ( $ response ) ; } | Get a acl for quota by id |
17,750 | public function create ( $ quotaId , AclBuilder $ input , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> acls ( ) -> create ( $ quotaId , $ input -> toArray ( ) , $ queryParams ) ; return new AclResponse ( $ response ) ; } | Create a new acl for a quota |
17,751 | public function update ( $ quotaId , $ aclId , AclBuilder $ input , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> acls ( ) -> update ( $ quotaId , $ aclId , $ input -> toArray ( ) , $ queryParams ) ; return new AclResponse ( $ response ) ; } | Update existing acl for quota by id |
17,752 | public function deleteAll ( $ quotaId , array $ queryParams = [ ] ) { $ response = $ this -> api -> quotas ( ) -> acls ( ) -> deleteAll ( $ quotaId , $ queryParams ) ; return new BaseResponse ( $ response ) ; } | Delete all acls for a quota |
17,753 | public function getItems ( $ force = false ) { if ( ! $ this -> isBuiltIn ( ) && ( $ this -> nb_medioteca_item_list -> isEmpty ( ) || $ force ) ) { $ this -> nb_medioteca_item_list = CNabuMediotecaItem :: getItemsForMedioteca ( $ this ) ; } return $ this -> nb_medioteca_item_list ; } | Gets all items in the Medioteca . |
17,754 | public function getItem ( $ nb_medioteca_item ) { $ nb_medioteca_item_id = nb_getMixedValue ( $ nb_medioteca_item , 'nb_medioteca_item_id' ) ; if ( is_numeric ( $ nb_medioteca_item_id ) || nb_isValidGUID ( $ nb_medioteca_item_id ) ) { return $ this -> nb_medioteca_item_list -> getItem ( $ nb_medioteca_item_id ) ; } return null ; } | Gets an item from the Medioteca by their ID . |
17,755 | public function newItem ( string $ key = null ) { $ nb_medioteca_item = $ this -> isBuiltIn ( ) ? new CNabuBuiltInMediotecaItem ( ) : new CNabuMediotecaItem ( ) ; $ nb_medioteca_item -> setKey ( $ key ) ; return $ this -> addItemObject ( $ nb_medioteca_item ) ; } | Create a new Item in the list . |
17,756 | public function findItemByURL ( string $ url , $ nb_language = null ) { $ retval = false ; $ nb_language_id = nb_getMixedValue ( $ nb_language , NABU_LANG_FIELD_ID ) ; $ this -> getItems ( ) -> iterate ( function ( $ key , CNabuMediotecaItem $ nb_item ) use ( & $ retval , $ url , $ nb_language_id ) { if ( is_numeric ( $ nb_language_id ) && ( $ nb_translation = $ nb_item -> getTranslation ( $ nb_language_id ) ) instanceof CNabuMediotecaItemLanguage && $ nb_translation -> getURL ( ) === $ url ) { $ retval = $ nb_item ; } else { $ nb_item -> getTranslations ( ) -> iterate ( function ( $ key , CNabuMediotecaItemLanguage $ nb_translation ) use ( & $ retval , $ nb_item , $ url ) { if ( $ nb_translation -> getURL ( ) === $ url ) { $ retval = $ nb_item ; } return ! $ retval ; } ) ; } return ! $ retval ; } ) ; return $ retval ; } | Find a Item using their url . |
17,757 | public function addItemObject ( CNabuMediotecaItem $ nb_medioteca_item ) { $ nb_medioteca_item -> setMedioteca ( $ this ) ; return $ this -> nb_medioteca_item_list -> addItem ( $ nb_medioteca_item ) ; } | Add an Item instance to the list . |
17,758 | static public function getMediotecasForCustomer ( CNabuCustomer $ nb_customer ) { $ nb_customer_id = nb_getMixedValue ( $ nb_customer , NABU_CUSTOMER_FIELD_ID ) ; if ( is_numeric ( $ nb_customer_id ) ) { $ retval = CNabuMedioteca :: buildObjectListFromSQL ( NABU_MEDIOTECA_FIELD_ID , 'select * ' . 'from ' . NABU_MEDIOTECA_TABLE . ' ' . 'where nb_customer_id=%cust_id$d' , array ( 'cust_id' => $ nb_customer_id ) , $ nb_customer ) ; } else { $ retval = new CNabuMediotecaList ( $ nb_customer ) ; } return $ retval ; } | Get all Mediotecas of a Customer . |
17,759 | public function refresh ( bool $ force = false , bool $ cascade = false ) : bool { return parent :: refresh ( $ force , $ cascade ) && ( ! $ cascade || $ this -> getItems ( $ force ) ) ; } | Overrides refresh method to add Medioteca subentities to be refreshed . |
17,760 | public function setDomainZoneId ( int $ nb_domain_zone_id ) : CNabuDataObject { if ( $ nb_domain_zone_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_domain_zone_id" ) ) ; } $ this -> setValue ( 'nb_domain_zone_id' , $ nb_domain_zone_id ) ; return $ this ; } | Sets the Domain Zone Id attribute value . |
17,761 | function initial_pointers ( ) { global $ pagenow ; $ defaults = array ( 'class' => '' , 'width' => 300 , 'align' => 'middle' , 'edge' => 'left' , 'post_type' => array ( ) , 'pages' => array ( ) , 'icon_class' => '' ) ; $ screen = get_current_screen ( ) ; $ current_post_type = isset ( $ screen -> post_type ) ? $ screen -> post_type : false ; $ search_pt = false ; $ pointers = apply_filters ( $ this -> prefix . '-pointerplus_list' , array ( ) , $ this -> prefix ) ; foreach ( $ pointers as $ key => $ pointer ) { $ pointers [ $ key ] = wp_parse_args ( $ pointer , $ defaults ) ; $ search_pt = false ; $ pointers [ $ key ] [ 'post_type' ] = array_filter ( $ pointers [ $ key ] [ 'post_type' ] ) ; if ( ! empty ( $ pointers [ $ key ] [ 'post_type' ] ) ) { if ( ! empty ( $ current_post_type ) ) { if ( is_array ( $ pointers [ $ key ] [ 'post_type' ] ) ) { foreach ( $ pointers [ $ key ] [ 'post_type' ] as $ value ) { if ( $ value === $ current_post_type ) { $ search_pt = true ; } } if ( $ search_pt === false ) { unset ( $ pointers [ $ key ] ) ; } } else { new WP_Error ( 'broke' , __ ( 'PointerPlus Error: post_type is not an array!' ) ) ; } } else { unset ( $ pointers [ $ key ] ) ; } } if ( isset ( $ pointers [ $ key ] [ 'pages' ] ) ) { if ( is_array ( $ pointers [ $ key ] [ 'pages' ] ) ) { $ pointers [ $ key ] [ 'pages' ] = array_filter ( $ pointers [ $ key ] [ 'pages' ] ) ; } if ( ! empty ( $ pointers [ $ key ] [ 'pages' ] ) ) { if ( is_array ( $ pointers [ $ key ] [ 'pages' ] ) ) { foreach ( $ pointers [ $ key ] [ 'pages' ] as $ value ) { if ( $ pagenow === $ value ) { $ search_pt = true ; } } if ( $ search_pt === false ) { unset ( $ pointers [ $ key ] ) ; } } else { new WP_Error ( 'broke' , __ ( 'PointerPlus Error: pages is not an array!' ) ) ; } } } } return $ pointers ; } | Set pointers and its options |
17,762 | function maybe_add_pointers ( ) { $ default_keys = $ this -> initial_pointers ( ) ; $ dismissed = explode ( ',' , get_user_meta ( get_current_user_id ( ) , 'dismissed_wp_pointers' , true ) ) ; $ diff = array_diff_key ( $ default_keys , array_combine ( $ dismissed , $ dismissed ) ) ; if ( ! empty ( $ diff ) ) { $ this -> pointers = $ diff ; add_action ( 'admin_enqueue_scripts' , array ( $ this , 'admin_enqueue_assets' ) ) ; foreach ( $ diff as $ pointer ) { if ( isset ( $ pointer [ 'phpcode' ] ) ) { add_action ( 'admin_notices' , $ pointer [ 'phpcode' ] ) ; } } } $ this -> pointers [ 'l10n' ] = array ( 'next' => __ ( 'Next' ) ) ; } | Check that pointers haven t been dismissed already . If there are pointers to show enqueue assets . |
17,763 | function admin_enqueue_assets ( ) { $ base_url = plugins_url ( '' , __FILE__ ) ; wp_enqueue_style ( $ this -> prefix , $ base_url . '/pointerplus.css' , array ( 'wp-pointer' ) ) ; wp_enqueue_script ( $ this -> prefix , $ base_url . '/pointerplus.js?var=' . str_replace ( '-' , '_' , $ this -> prefix ) . '_pointerplus' , array ( 'wp-pointer' ) ) ; wp_localize_script ( $ this -> prefix , str_replace ( '-' , '_' , $ this -> prefix ) . '_pointerplus' , apply_filters ( $ this -> prefix . '_pointerplus_js_vars' , $ this -> pointers ) ) ; } | Enqueue pointer styles and scripts to display them . |
17,764 | function _reset_pointer ( $ id = 'me' ) { if ( $ id === 'me' ) { $ id = get_current_user_id ( ) ; } $ pointers = explode ( ',' , get_user_meta ( $ id , 'dismissed_wp_pointers' , true ) ) ; foreach ( $ pointers as $ key => $ pointer ) { if ( strpos ( $ pointer , $ this -> prefix ) === 0 ) { unset ( $ pointers [ $ key ] ) ; } } $ meta = implode ( ',' , $ pointers ) ; update_user_meta ( get_current_user_id ( ) , 'dismissed_wp_pointers' , $ meta ) ; } | Reset pointer in hook |
17,765 | public function setProjectVersionId ( int $ nb_project_version_id ) : CNabuDataObject { if ( $ nb_project_version_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_project_version_id" ) ) ; } $ this -> setValue ( 'nb_project_version_id' , $ nb_project_version_id ) ; return $ this ; } | Sets the Project Version Id attribute value . |
17,766 | public function getSelectRegister ( ) { return ( $ this -> isValueNumeric ( 'nb_site_id' ) && $ this -> isValueNumeric ( 'nb_role_id' ) && $ this -> isValueNumeric ( 'nb_language_id' ) ) ? $ this -> buildSentence ( 'select * ' . 'from nb_site_role_lang ' . "where nb_site_id=%nb_site_id\$d " . "and nb_role_id=%nb_role_id\$d " . "and nb_language_id=%nb_language_id\$d " ) : null ; } | Gets SELECT sentence to load a single register from the storage . |
17,767 | public function setName ( $ name ) { if ( ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, name, to be a string" ) ; } if ( ! is_readable ( $ name ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, name, to be a readable filename" ) ; } $ this -> name = $ name ; return $ this ; } | Sets the file s name |
17,768 | public function getMaxChunks ( ) { return ceil ( ( $ this -> name !== null ? filesize ( $ this -> name ) : 0 ) / $ this -> size ) ; } | Returns the maximum number of chunks in the file |
17,769 | protected function getChunk ( $ offset ) { if ( ! is_numeric ( $ offset ) || ! is_int ( + $ offset ) || $ offset < 0 ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, offset, to be a positive " . "integer or zero" ) ; } if ( $ this -> name !== null ) { $ sbChunk = @ file_get_contents ( $ this -> name , false , null , max ( 0 , $ offset - self :: MAX_SIZE_CHARACTER ) , $ this -> size + self :: MAX_SIZE_CHARACTER ) ; if ( $ sbChunk !== false ) { $ mbChunk = mb_strcut ( $ sbChunk , min ( max ( 0 , $ offset ) , self :: MAX_SIZE_CHARACTER ) , $ this -> size , $ this -> encoding ) ; } else { $ mbChunk = false ; } } else { $ mbChunk = false ; } return $ mbChunk ; } | Returns a multi - byte - safe file chunk or false |
17,770 | protected function extractNodes ( CNabuDataObject $ item ) { $ main_index_name = $ this -> list -> getIndexedFieldName ( ) ; if ( ( $ item -> isValueNumeric ( $ main_index_name ) || $ item -> isValueGUID ( $ main_index_name ) ) && ( $ item -> isValueString ( $ this -> key_field ) || $ item -> isValueNumeric ( $ this -> key_field ) ) ) { $ key = $ item -> getValue ( $ this -> key_field ) ; $ retval = array ( 'key' => $ key , 'pointer' => $ item -> getValue ( $ main_index_name ) ) ; if ( $ item -> isValueNumeric ( $ this -> order_field ) || $ item -> isValueString ( $ this -> order_field ) ) { $ retval [ 'order' ] = $ item -> getValue ( $ this -> order_field ) ; } $ retval = array ( $ key => $ retval ) ; } else { $ retval = null ; } return $ retval ; } | Extract Nodes list for an item in this node . This method can be overrided in child classes to change the extraction method of nodes . |
17,771 | public function addItem ( CNabuDataObject $ item ) { if ( is_array ( $ nodes = $ this -> extractNodes ( $ item ) ) && count ( $ nodes ) > 0 ) { if ( $ this -> index === null ) { $ this -> index = $ nodes ; } else { $ this -> index = array_merge ( $ this -> index , $ nodes ) ; } } } | Adds a new item to the index . |
17,772 | public function getVersions ( $ force = false ) { if ( $ this -> nb_project_version_list === null ) { $ this -> nb_project_version_list = new CNabuProjectVersionList ( ) ; } if ( $ this -> nb_project_version_list -> isEmpty ( ) || $ force ) { $ this -> nb_project_version_list -> clear ( ) ; $ this -> nb_project_version_list -> merge ( CNabuProjectVersion :: getAllProjectVersions ( $ this ) ) ; } return $ this -> nb_project_version_list ; } | Gets Versions assigned to the project . |
17,773 | public function setIcontactProspectId ( int $ nb_icontact_prospect_id ) : CNabuDataObject { if ( $ nb_icontact_prospect_id === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$nb_icontact_prospect_id" ) ) ; } $ this -> setValue ( 'nb_icontact_prospect_id' , $ nb_icontact_prospect_id ) ; return $ this ; } | Sets the Icontact Prospect Id attribute value . |
17,774 | public function getAll ( array $ queryParams = [ ] ) { $ response = $ this -> api -> licenses ( ) -> getAll ( $ queryParams ) ; return new LicensesResponse ( $ response ) ; } | Get all licenses |
17,775 | public function getById ( $ appId , array $ queryParams = [ ] ) { $ response = $ this -> api -> licenses ( ) -> getById ( $ appId , $ queryParams ) ; return new LicenseResponse ( $ response ) ; } | Get license by id |
17,776 | public function createStatement ( ) : Statement { if ( null === $ this -> actor ) { throw new InvalidStateException ( 'A statement actor is missing.' ) ; } if ( null === $ this -> verb ) { throw new InvalidStateException ( 'A statement verb is missing.' ) ; } if ( null === $ this -> object ) { throw new InvalidStateException ( 'A statement object is missing.' ) ; } return new Statement ( $ this -> id , $ this -> actor , $ this -> verb , $ this -> object , $ this -> result , $ this -> authority , $ this -> created , $ this -> stored , $ this -> context ) ; } | Returns a statement based on the current configuration . |
17,777 | private function discoverServiceInterface ( CNabuMessagingService $ nb_service ) : INabuMessagingServiceInterface { $ retval = false ; $ nb_engine = CNabuEngine :: getEngine ( ) ; if ( is_string ( $ interface_name = $ nb_service -> getInterface ( ) ) ) { if ( is_array ( $ this -> nb_service_interface_list ) && array_key_exists ( $ interface_name , $ this -> nb_service_interface_list ) ) { $ retval = $ this -> nb_service_interface_list [ $ interface_name ] ; } elseif ( is_string ( $ provider_key = $ nb_service -> getProvider ( ) ) && count ( list ( $ vendor_key , $ module_key ) = preg_split ( "/:/" , $ provider_key ) ) === 2 && ( $ nb_manager = $ nb_engine -> getProviderManager ( $ vendor_key , $ module_key ) ) instanceof INabuMessagingModule && ( $ retval = $ nb_manager -> createServiceInterface ( $ interface_name ) ) instanceof INabuMessagingServiceInterface ) { if ( is_array ( $ this -> nb_service_interface_list ) ) { $ this -> nb_service_interface_list [ $ interface_name ] = $ retval ; } else { $ this -> nb_service_interface_list = array ( $ interface_name => $ retval ) ; } $ retval -> connect ( $ nb_service ) ; } else { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_SERVICE_INSTANCE ) ; } } else { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_SERVICE_CLASS_NAME ) ; } return $ retval ; } | Discover the Service Interface . |
17,778 | private function discoverTemplate ( $ nb_template ) : CNabuMessagingTemplate { if ( ! ( $ nb_template instanceof CNabuMessagingTemplate ) ) { if ( is_numeric ( $ nb_template_id = nb_getMixedValue ( $ nb_template , NABU_MESSAGING_TEMPLATE_FIELD_ID ) ) ) { $ nb_template = $ this -> nb_messaging -> getTemplate ( $ nb_template_id ) ; } elseif ( is_string ( $ nb_template_id ) ) { $ nb_template = $ this -> nb_messaging -> getTemplateByKey ( $ nb_template_id ) ; } } if ( ! ( $ nb_template instanceof CNabuMessagingTemplate ) ) { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_TEMPLATE ) ; } elseif ( $ nb_template -> getMessagingId ( ) !== $ this -> nb_messaging -> getId ( ) ) { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_TEMPLATE_NOT_ALLOWED , array ( $ nb_template -> getId ( ) ) ) ; } return $ nb_template ; } | Discover the Messaging Template instance beside a lazzy reference to it . |
17,779 | private function discoverLanguage ( $ nb_language ) : CNabuLanguage { if ( ! ( $ nb_language instanceof CNabuLanguage ) ) { $ nb_language = new CNabuLanguage ( nb_getMixedValue ( $ nb_language , NABU_LANG_FIELD_ID ) ) ; } if ( ! ( $ nb_language instanceof CNabuLanguage ) || $ nb_language -> isNew ( ) ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_LANGUAGE_REQUIRED ) ; } return $ nb_language ; } | Discover the Language instance beside a lazzy reference to it . |
17,780 | private function prepareMessageUsingTemplate ( CNabuMessagingTemplate $ nb_template , CNabuLanguage $ nb_language , array $ params = null ) : array { $ nb_engine = CNabuEngine :: getEngine ( ) ; if ( is_string ( $ interface_name = $ nb_template -> getRenderInterface ( ) ) && is_string ( $ provider_key = $ nb_template -> getRenderProvider ( ) ) && count ( list ( $ vendor_key , $ module_key ) = preg_split ( "/:/" , $ provider_key ) ) === 2 && ( $ nb_manager = $ nb_engine -> getProviderManager ( $ vendor_key , $ module_key ) ) instanceof INabuMessagingModule && ( $ nb_interface = $ nb_manager -> createTemplateRenderInterface ( $ interface_name ) ) instanceof INabuMessagingTemplateRenderInterface ) { $ nb_interface -> setTemplate ( $ nb_template ) ; $ nb_interface -> setLanguage ( $ nb_language ) ; $ subject = $ nb_interface -> createSubject ( $ params ) ; $ body_html = $ nb_interface -> createBodyHTML ( $ params ) ; $ body_text = $ nb_interface -> createBodyText ( $ params ) ; return array ( $ subject , $ body_html , $ body_text ) ; } else { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_TEMPLATE_RENDER_INSTANCE ) ; } } | Prepares the subject and body of a message using a template . |
17,781 | public function postTemplateMessage ( $ nb_template , $ nb_language , $ to = null , $ cc = null , $ bcc = null , array $ params = null , array $ attachments = null ) : bool { $ nb_template = $ this -> discoverTemplate ( $ nb_template ) ; $ nb_language = $ this -> discoverLanguage ( $ nb_language ) ; list ( $ subject , $ body_html , $ body_text ) = $ this -> prepareMessageUsingTemplate ( $ nb_template , $ nb_language , $ params ) ; return $ this -> postMessage ( $ nb_template -> getActiveServices ( ) , $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) ; } | Post a Message in the Messaging queue using a predefined template . |
17,782 | public function sendTemplateMessage ( $ nb_template , $ to = null , $ cc = null , $ bcc = null , array $ params = null , array $ attachments = null ) : bool { $ nb_template = $ this -> discoverTemplate ( $ nb_template ) ; $ nb_language = $ this -> discoverLanguage ( $ nb_language ) ; list ( $ subject , $ body_html , $ body_text ) = $ this -> prepareMessageUsingTemplate ( $ nb_template , $ params ) ; return $ this -> sendMessage ( $ nb_template -> getServices ( ) , $ to , $ bc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) ; } | Send a Message directly using a predefined template . |
17,783 | public function postMessage ( CNabuMessagingServiceList $ nb_service_list , $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) : bool { $ retval = false ; $ nb_service_list -> iterate ( function ( $ key , CNabuMessagingService $ nb_service ) use ( & $ retval , $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) { $ nb_interface = $ this -> discoverServiceInterface ( $ nb_service ) ; $ nb_interface -> post ( $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) ; $ retval |= true ; return true ; } ) ; return $ retval ; } | Post a Message in the Messaging queue . |
17,784 | public function sendMessage ( CNabuMessagingServiceList $ nb_service_list , $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) { $ retval = false ; $ nb_service_list -> iterate ( function ( $ key , CNabuMessagingService $ nb_service ) use ( & $ retval , $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) { $ nb_interface = $ this -> prepareServiceInterface ( $ nb_service ) ; $ nb_interface -> send ( $ to , $ cc , $ bcc , $ subject , $ body_html , $ body_text , $ attachments ) ; $ retval |= true ; return true ; } ) ; return $ retval ; } | Send a Message directly . |
17,785 | public function getAll ( $ appId , $ scanId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> libraries ( ) -> getAll ( $ appId , $ scanId , $ queryParams ) ; return new LibrariesResponse ( $ response ) ; } | Get all libraries for a scan |
17,786 | public function getById ( $ appId , $ scanId , $ libraryId , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> libraries ( ) -> getById ( $ appId , $ scanId , $ libraryId , $ queryParams ) ; return new LibraryResponse ( $ response ) ; } | Get library for scan by id |
17,787 | public function update ( $ appId , $ scanId , $ libraryId , $ input , array $ queryParams = [ ] ) { $ response = $ this -> api -> applications ( ) -> scans ( ) -> libraries ( ) -> update ( $ appId , $ scanId , $ libraryId , $ input -> toArray ( ) , $ queryParams ) ; return new LibraryResponse ( $ response ) ; } | Update a library for a service |
17,788 | public function compile ( $ stub , $ modelName , $ modelData , stdClass $ scaffolderConfig , $ hash , array $ extensions , $ extra = null ) { $ this -> stub = $ stub ; $ this -> replaceResource ( $ modelName ) ; return $ this -> stub ; } | Compiles a route . |
17,789 | protected function setValidations ( $ modelData ) { $ fields = '' ; $ firstIteration = true ; foreach ( $ modelData -> fields as $ field ) { if ( $ firstIteration ) { $ fields .= sprintf ( "'%s' => '%s'," . PHP_EOL , $ field -> name , $ field -> validations ) ; $ firstIteration = false ; } else { $ fields .= sprintf ( $ this -> tab ( 3 ) . "'%s' => '%s'," . PHP_EOL , $ field -> name , $ field -> validations ) ; } } $ this -> stub = str_replace ( '{{validations}}' , $ fields , $ this -> stub ) ; return $ this ; } | Set validations . |
17,790 | public static function hydrateCollection ( array $ controllers ) { $ hydrated = [ ] ; foreach ( $ controllers as $ controller ) { $ hydrated [ ] = self :: hydrate ( $ controller ) ; } return $ hydrated ; } | Hydrate a collection of controller objects into a collection of ControllerEntity objects |
17,791 | public static function hydrate ( stdClass $ controller ) { $ hydrated = new ControllerEntity ( ) ; if ( isset ( $ controller -> id ) ) { $ hydrated -> setId ( $ controller -> id ) ; } if ( isset ( $ controller -> class ) ) { $ hydrated -> setClass ( $ controller -> class ) ; } if ( isset ( $ controller -> method ) ) { $ hydrated -> setMethod ( $ controller -> method ) ; } if ( isset ( $ controller -> parameter ) ) { $ hydrated -> setParameter ( $ controller -> parameter ) ; } if ( isset ( $ controller -> type ) ) { $ hydrated -> setType ( $ controller -> type ) ; } return $ hydrated ; } | Hydrate a controller object into a SourceEntity object |
17,792 | public static function getAllSiteMaps ( CNabuSite $ nb_site ) { $ nb_site_id = nb_getMixedValue ( $ nb_site , 'nb_site_id' ) ; if ( is_numeric ( $ nb_site_id ) ) { $ retval = forward_static_call ( array ( get_called_class ( ) , 'buildObjectListFromSQL' ) , 'nb_site_map_id' , 'select * ' . 'from nb_site_map ' . 'where nb_site_id=%site_id$d' , array ( 'site_id' => $ nb_site_id ) , $ nb_site ) ; } else { $ retval = new CNabuSiteMapList ( ) ; } return $ retval ; } | Get all items in the storage as an associative array where the field nb_site_map_id is the index and each value is an instance of class CNabuSiteMapBase . |
17,793 | public static function getFilteredSiteMapList ( $ nb_site , $ q = null , $ fields = null , $ order = null , $ offset = 0 , $ num_items = 0 ) { $ nb_site_id = nb_getMixedValue ( $ nb_customer , NABU_SITE_FIELD_ID ) ; if ( is_numeric ( $ nb_site_id ) ) { $ fields_part = nb_prefixFieldList ( CNabuSiteMapBase :: getStorageName ( ) , $ fields , false , true , '`' ) ; $ order_part = nb_prefixFieldList ( CNabuSiteMapBase :: getStorageName ( ) , $ fields , false , false , '`' ) ; if ( $ num_items !== 0 ) { $ limit_part = ( $ offset > 0 ? $ offset . ', ' : '' ) . $ num_items ; } else { $ limit_part = false ; } $ nb_item_list = CNabuEngine :: getEngine ( ) -> getMainDB ( ) -> getQueryAsArray ( "select " . ( $ fields_part ? $ fields_part . ' ' : '* ' ) . 'from nb_site_map ' . 'where ' . NABU_SITE_FIELD_ID . '=%site_id$d ' . ( $ order_part ? "order by $order_part " : '' ) . ( $ limit_part ? "limit $limit_part" : '' ) , array ( 'site_id' => $ nb_site_id ) ) ; } else { $ nb_item_list = null ; } return $ nb_item_list ; } | Gets a filtered list of Site Map instances represented as an array . Params allows the capability of select a subset of fields order by concrete fields or truncate the list by a number of rows starting in an offset . |
17,794 | public function setCustomerRequired ( string $ customer_required = "B" ) : CNabuDataObject { if ( $ customer_required === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$customer_required" ) ) ; } $ this -> setValue ( 'nb_site_map_customer_required' , $ customer_required ) ; return $ this ; } | Sets the Site Map Customer Required attribute value . |
17,795 | public function setLevel ( int $ level = 1 ) : CNabuDataObject { if ( $ level === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$level" ) ) ; } $ this -> setValue ( 'nb_site_map_level' , $ level ) ; return $ this ; } | Sets the Site Map Level attribute value . |
17,796 | public function setUseURI ( string $ use_uri = "N" ) : CNabuDataObject { if ( $ use_uri === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$use_uri" ) ) ; } $ this -> setValue ( 'nb_site_map_use_uri' , $ use_uri ) ; return $ this ; } | Sets the Site Map Use URI attribute value . |
17,797 | public function setOpenPopup ( string $ open_popup = "F" ) : CNabuDataObject { if ( $ open_popup === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$open_popup" ) ) ; } $ this -> setValue ( 'nb_site_map_open_popup' , $ open_popup ) ; return $ this ; } | Sets the Site Map Open Popup attribute value . |
17,798 | public function setVisible ( string $ visible = "T" ) : CNabuDataObject { if ( $ visible === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$visible" ) ) ; } $ this -> setValue ( 'nb_site_map_visible' , $ visible ) ; return $ this ; } | Sets the Site Map Visible attribute value . |
17,799 | public function setSeparator ( string $ separator = "F" ) : CNabuDataObject { if ( $ separator === null ) { throw new ENabuCoreException ( ENabuCoreException :: ERROR_NULL_VALUE_NOT_ALLOWED_IN , array ( "\$separator" ) ) ; } $ this -> setValue ( 'nb_site_map_separator' , $ separator ) ; return $ this ; } | Sets the Site Map Separator attribute value . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.