idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
10,700 | public function export ( \ SimpleXMLElement $ xml ) { $ type = $ xml -> addChild ( 'library' ) ; $ type -> addAttribute ( 'handle' , $ this -> getSystemCaptchaLibraryHandle ( ) ) ; $ type -> addAttribute ( 'name' , $ this -> getSystemCaptchaLibraryName ( ) ) ; $ type -> addAttribute ( 'package' , $ this -> getPackageHandle ( ) ) ; $ type -> addAttribute ( 'activated' , $ this -> isSystemCaptchaLibraryActive ( ) ? '1' : '0' ) ; } | Export the data of this library . |
10,701 | public static function exportList ( \ SimpleXMLElement $ xml ) { $ list = self :: getList ( ) ; $ nxml = $ xml -> addChild ( 'systemcaptcha' ) ; foreach ( $ list as $ sc ) { $ sc -> export ( $ nxml ) ; } } | Export the data of all the libraries . |
10,702 | public function hasOptionsForm ( ) { $ path = DIRNAME_SYSTEM . '/' . DIRNAME_SYSTEM_CAPTCHA . '/' . $ this -> sclHandle . '/' . FILENAME_FORM ; if ( file_exists ( DIR_FILES_ELEMENTS . '/' . $ path ) ) { return true ; } elseif ( $ this -> pkgID > 0 ) { $ pkgHandle = $ this -> getPackageHandle ( ) ; $ dp = DIR_PACKAGES . '/' . $ pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $ path ; $ dpc = DIR_PACKAGES_CORE . '/' . $ pkgHandle . '/' . DIRNAME_ELEMENTS . '/' . $ path ; if ( file_exists ( $ dp ) ) { return true ; } elseif ( file_exists ( $ dpc ) ) { return true ; } } else { return file_exists ( DIR_FILES_ELEMENTS_CORE . '/' . $ path ) ; } } | Does this library has an option form? |
10,703 | public function getEntryPoint ( ) { if ( $ this -> entryPoint === null ) { $ this -> setEntryPoint ( $ this -> config -> get ( 'concrete.i18n.community_translation.entry_point' , '' ) ) ; } return $ this -> entryPoint ; } | Get the API entry point . |
10,704 | public function getApiToken ( ) { if ( $ this -> apiToken === null ) { $ this -> apiToken = ( string ) $ this -> config -> get ( 'concrete.i18n.community_translation.api_token' , '' ) ; } return $ this -> apiToken ; } | Get the API token . |
10,705 | public function getProgressLimit ( ) { if ( $ this -> progressLimit === null ) { $ this -> setProgressLimit ( $ this -> config -> get ( 'concrete.i18n.community_translation.progress_limit' , 90 ) ) ; } return $ this -> progressLimit ; } | Get the default progress limit . |
10,706 | protected function fixOverlappingStartEndDates ( ) { $ rs = $ this -> connection -> executeQuery ( <<<'EOT'select cv1.cID, cv1.cvIDfrom CollectionVersions as cv1 inner join CollectionVersions as cv2 on cv1.cID = cv2.cID and cv1.cvID <> cv2.cvID and cv1.cvIsApproved = cv2.cvIsApprovedwhere cv1.cvIsApproved = 1 and ifnull(cv1.cvPublishDate, '0000-00-00 00:00:00') <= ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') and ifnull(cv1.cvPublishEndDate, '9999-99-99 99:99:99') >= ifnull(cv2.cvPublishDate, '0000-00-00 00:00:00')order by cv1.cID, cv1.cvID descEOT ) ; $ page = null ; while ( ( $ row = $ rs -> fetch ( PDO :: FETCH_ASSOC ) ) !== false ) { if ( $ page === null || $ page -> getCollectionID ( ) != $ row [ 'cID' ] ) { $ page = Page :: getByID ( $ row [ 'cID' ] , $ row [ 'cvID' ] ) ; } else { $ page -> loadVersionObject ( $ row [ 'cvID' ] ) ; } $ version = $ page -> getVersionObject ( ) ; $ version -> setPublishInterval ( $ version -> getPublishDate ( ) , $ version -> getPublishDate ( ) ) ; } } | Be sure that there are not approved collection versions with overlapping publish dates . |
10,707 | public function filterByAttribute ( $ handle , $ value , $ comparison = '=' ) { $ ak = call_user_func_array ( array ( $ this -> getAttributeKeyClassName ( ) , 'getByHandle' ) , array ( $ handle ) ) ; if ( ! is_object ( $ ak ) ) { throw new \ Exception ( t ( 'Unable to find attribute %s' , $ handle ) ) ; } $ ak -> getController ( ) -> filterByAttribute ( $ this , $ value , $ comparison ) ; } | Filters by a attribute . |
10,708 | public function process ( Version $ version ) { $ resource = $ version -> getFileResource ( ) ; $ originalData = $ resource -> read ( ) ; $ sanitizedData = $ this -> sanitizer -> sanitizeData ( $ originalData , $ this -> sanitizerOptions ) ; if ( $ sanitizedData !== $ originalData ) { $ version -> updateContents ( $ sanitizedData ) ; } } | Remove potentially harmful elements and attributes from the SVG image . |
10,709 | public function filterByParentID ( $ cParentID ) { $ db = Loader :: db ( ) ; if ( is_array ( $ cParentID ) ) { $ cth = '(' ; for ( $ i = 0 ; $ i < count ( $ cParentID ) ; ++ $ i ) { if ( $ i > 0 ) { $ cth .= ',' ; } $ cth .= $ db -> quote ( $ cParentID [ $ i ] ) ; } $ cth .= ')' ; $ this -> filter ( false , "(p1.cParentID in {$cth})" ) ; } else { $ this -> filterByCParentID = $ cParentID ; $ this -> filter ( 'p1.cParentID' , $ cParentID ) ; } } | Sets the parent ID that we will grab pages from . |
10,710 | public function get ( $ itemsToGet = 0 , $ offset = 0 ) { $ pages = [ ] ; if ( $ this -> getQuery ( ) == '' ) { $ this -> setBaseQuery ( ) ; } $ this -> setItemsPerPage ( $ itemsToGet ) ; $ r = parent :: get ( $ itemsToGet , $ offset ) ; foreach ( $ r as $ row ) { $ nc = $ this -> loadPageID ( $ row [ 'cID' ] , 'ACTIVE' ) ; if ( ! $ this -> displayOnlyApprovedPages ) { $ cp = new Permissions ( $ nc ) ; if ( $ cp -> canViewPageVersions ( ) ) { $ nc -> loadVersionObject ( 'RECENT' ) ; } } $ nc -> setPageIndexScore ( $ row [ 'cIndexScore' ] ) ; $ pages [ ] = $ nc ; } return $ pages ; } | Returns an array of page objects based on current settings . |
10,711 | protected function nullifyInvalidForeignKey ( $ table , $ field , $ linkedTable , $ linkedField ) { $ platform = $ this -> connection -> getDatabasePlatform ( ) ; $ sqlTable = $ platform -> quoteSingleIdentifier ( $ table ) ; $ sqlField = $ platform -> quoteSingleIdentifier ( $ field ) ; $ sqlLinkedTable = $ platform -> quoteSingleIdentifier ( $ linkedTable ) ; $ sqlLinkedField = $ platform -> quoteSingleIdentifier ( $ linkedField ) ; $ this -> connection -> executeQuery ( " update {$sqlTable} left join {$sqlLinkedTable} on {$sqlTable}.{$sqlField} = {$sqlLinkedTable}.{$sqlLinkedField} set {$sqlTable}.{$sqlField} = null where {$sqlLinkedTable}.{$sqlLinkedField} is null " ) ; } | Set to NULL the fields in a table that reference not existing values of another table . |
10,712 | public function setConsole ( SymfonyApplication $ console , OutputInterface $ output = null , InputInterface $ input = null ) { $ this -> traitConsole = $ console ; if ( $ output ) { $ this -> setOutput ( $ output ) ; } if ( $ input ) { $ this -> setInput ( $ input ) ; } return $ this ; } | Set the console object |
10,713 | public function cloneCollection ( Collection $ c , ClonerOptions $ options ) { $ cDate = $ this -> dateHelper -> getOverridableNow ( ) ; $ this -> connection -> insert ( 'Collections' , [ 'cDateAdded' => $ cDate , 'cDateModified' => $ cDate , 'cHandle' => $ c -> getCollectionHandle ( ) , ] ) ; $ cID = $ c -> getCollectionID ( ) ; $ newCID = $ this -> connection -> lastInsertId ( ) ; $ rs = $ this -> connection -> executeQuery ( 'select * from CollectionVersions where cID = ? order by cvDateCreated asc' , [ $ cID ] ) ; while ( ( $ row = $ rs -> fetch ( PDO :: FETCH_ASSOC ) ) !== false ) { $ cDate = date ( 'Y-m-d H:i:s' , strtotime ( $ cDate ) + 1 ) ; $ this -> connection -> insert ( 'CollectionVersions' , [ 'cID' => $ newCID , 'cvID' => $ row [ 'cvID' ] , 'cvName' => $ row [ 'cvName' ] , 'cvHandle' => $ row [ 'cvHandle' ] , 'cvDescription' => $ row [ 'cvDescription' ] , 'cvDatePublic' => $ row [ 'cvDatePublic' ] , 'cvDateCreated' => $ cDate , 'cvComments' => $ row [ 'cvComments' ] , 'cvAuthorUID' => $ options -> keepOriginalAuthor ( ) ? $ row [ 'cvAuthorUID' ] : $ options -> getCurrentUser ( ) -> getUserID ( ) , 'cvIsApproved' => $ options -> forceUnapproved ( ) ? 0 : $ row [ 'cvIsApproved' ] , 'pThemeID' => $ row [ 'pThemeID' ] , 'pTemplateID' => $ row [ 'pTemplateID' ] , ] ) ; } $ this -> copyData ( $ options , [ $ cID , $ newCID ] ) ; return Collection :: getByID ( $ newCID ) ; } | Create a clone of a collection and all its versions contents and attributes . |
10,714 | public function cloneCollectionVersion ( Version $ cvSource , Collection $ cDestination , ClonerOptions $ options ) { $ cSourceID = $ cvSource -> getCollectionID ( ) ; $ cvSourceID = $ cvSource -> getVersionID ( ) ; $ cSource = Page :: getByID ( $ cSourceID , $ cvSourceID ) ; $ cDestinationID = $ cDestination -> getCollectionID ( ) ; $ cvDestinationID = 1 + ( int ) $ this -> connection -> fetchColumn ( 'select max(cvID) from CollectionVersions where cID = ?' , [ $ cDestinationID ] ) ; $ versionComments = $ options -> getVersionComments ( ) ; if ( $ versionComments === '' ) { $ versionComments = t ( 'New Version %s' , $ cvDestinationID ) ; } if ( $ cSourceID == $ cDestinationID ) { $ cvIsNew = 1 ; if ( $ cSource -> getPageTypeHandle ( ) === STACKS_PAGE_TYPE ) { $ cvIsNew = 0 ; } } else { $ cvIsNew = 0 ; } $ this -> connection -> insert ( 'CollectionVersions' , [ 'cID' => $ cDestinationID , 'cvID' => $ cvDestinationID , 'cvName' => $ cvSource -> getVersionName ( ) , 'cvHandle' => $ cDestination -> getCollectionHandle ( ) , 'cvDescription' => $ cvSource -> cvDescription , 'cvDatePublic' => $ cvSource -> cvDatePublic , 'cvDateCreated' => $ this -> dateHelper -> getOverridableNow ( ) , 'cvComments' => $ versionComments , 'cvAuthorUID' => $ options -> keepOriginalAuthor ( ) ? $ cvSource -> getVersionAuthorUserID ( ) : $ options -> getCurrentUser ( ) -> getUserID ( ) , 'cvIsNew' => $ cvIsNew , 'pThemeID' => $ cvSource -> pThemeID , 'pTemplateID' => $ cvSource -> pTemplateID , 'cvPublishDate' => null , ] ) ; $ this -> copyData ( $ options , [ $ cSourceID , $ cDestinationID ] , [ $ cvSourceID , $ cvDestinationID ] ) ; $ cvDestination = Version :: get ( $ cSource , $ cvDestinationID ) ; $ ev = new CollectionVersionEvent ( $ cSource ) ; $ ev -> setCollectionVersionObject ( $ cvDestination ) ; $ this -> eventDispatcher -> dispatch ( 'on_page_version_add' , $ ev ) ; $ cvDestination -> refreshCache ( ) ; return $ cvDestination ; } | Create a copy of a collection version to another collection . |
10,715 | public function cloneBlock ( Block $ block , Collection $ destinationCollection ) { $ bID = $ block -> getBlockID ( ) ; $ aHandle = $ block -> getAreaHandle ( ) ; $ toID = $ destinationCollection -> getCollectionID ( ) ; $ toCVID = $ destinationCollection -> getVersionID ( ) ; $ already = $ this -> connection -> fetchColumn ( 'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1' , [ $ toID , $ toCVID , $ bID , $ aHandle ] ) ; if ( $ already !== false ) { return false ; } $ newBlockDisplayOrder = ( int ) $ destinationCollection -> getCollectionAreaDisplayOrder ( $ aHandle ) ; $ sourceCollection = $ block -> getBlockCollectionID ( ) ? $ block -> getBlockCollectionObject ( ) : null ; if ( $ sourceCollection ) { $ this -> copyBlocks ( [ $ sourceCollection -> getCollectionID ( ) , $ destinationCollection -> getCollectionID ( ) ] , [ $ sourceCollection -> getVersionID ( ) , $ destinationCollection -> getVersionID ( ) ] , [ $ bID , $ bID ] , $ newBlockDisplayOrder ) ; } else { $ this -> connection -> insert ( 'CollectionVersionBlocks' , [ 'cID' => $ toID , 'cvID' => $ toCVID , 'bID' => $ bID , 'arHandle' => $ aHandle , 'cbRelationID' => $ block -> getBlockRelationID ( ) , 'cbDisplayOrder' => $ newBlockDisplayOrder , 'isOriginal' => 0 , 'cbOverrideAreaPermissions' => $ block -> overrideAreaPermissions ( ) , 'cbOverrideBlockTypeCacheSettings' => $ block -> overrideBlockTypeCacheSettings ( ) , 'cbOverrideBlockTypeContainerSettings' => $ block -> overrideBlockTypeContainerSettings ( ) , 'cbEnableBlockContainer' => $ block -> enableBlockContainer ( ) ? 1 : 0 , ] ) ; } return true ; } | Create an alias of a block to another collection . |
10,716 | protected function getUniquePageName ( $ pageName , $ parentID ) { $ uniquePageName = $ pageName ; $ parentID = ( int ) $ parentID ; $ index = 1 ; for ( ; ; ) { $ pageWithSameName = $ this -> connection -> fetchColumn ( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvName = ? limit 1' , [ $ parentID , $ uniquePageName ] ) ; if ( $ pageWithSameName === false ) { return $ uniquePageName ; } ++ $ index ; $ uniquePageName = $ pageName . ' ' . $ index ; } } | Get the name of a page that s unique for the parent . |
10,717 | protected function getUniquePageHandle ( $ handle , $ parentID ) { $ uniqueHandle = $ handle ; $ parentID = ( int ) $ parentID ; $ index = 1 ; for ( ; ; ) { $ pageWithSameHandle = $ this -> connection -> fetchColumn ( 'select Pages.cID from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvHandle = ? limit 1' , [ $ parentID , $ uniqueHandle ] ) ; if ( $ pageWithSameHandle === false ) { return $ uniqueHandle ; } ++ $ index ; $ uniqueHandle = $ handle . '-' . $ index ; } } | Get the handle of a page that s unique for the parent . |
10,718 | public function canDoAnyOf ( array $ operations ) { foreach ( $ operations as $ operation ) { if ( $ this -> canDo ( $ operation ) ) { return true ; } } return false ; } | Check if at least one operation can be performed . |
10,719 | public function whyCantDo ( $ operation ) { if ( ! is_string ( $ operation ) ) { return 'Invalid $operation' ; } if ( ! isset ( $ this -> operationErrors [ $ operation ] ) ) { switch ( $ operation ) { case static :: OPERATION_MOVE : $ error = $ this -> whyCantMove ( ) ; break ; case static :: OPERATION_ALIAS : $ error = $ this -> whyCantAlias ( ) ; break ; case static :: OPERATION_COPY : $ error = $ this -> whyCantCopy ( ) ; break ; case static :: OPERATION_COPYALL : $ error = $ this -> whyCantDo ( static :: OPERATION_COPY ) ; if ( $ error === '' ) { $ error = $ this -> whyCantCopyAll ( ) ; } break ; case static :: OPERATION_COPYVERSION : $ error = $ this -> whyCantCopyVersion ( ) ; break ; default : return 'Invalid $operation' ; } $ this -> operationErrors [ $ operation ] = $ error ; } return $ this -> operationErrors [ $ operation ] ; } | Get the reason why an operation can t be performed . |
10,720 | protected function whyCantMove ( ) { $ destinationPageChecker = new Checker ( $ this -> getDestinationPage ( ) ) ; $ destinationPageID = $ this -> getDestinationPage ( ) -> getCollectionID ( ) ; foreach ( $ this -> getOriginalPages ( ) as $ originalPage ) { if ( $ originalPage -> getCollectionParentID ( ) == $ destinationPageID ) { return t ( '"%1$s" is already the parent page of "%2$s".' , $ this -> getDestinationPage ( ) -> getCollectionName ( ) , $ originalPage -> getCollectionName ( ) ) ; } $ originalPageChecker = new Checker ( $ originalPage ) ; if ( ! $ originalPageChecker -> canMoveOrCopyPage ( ) ) { return t ( 'You don\'t have the permission move the page "%s".' , $ originalPage -> getCollectionName ( ) ) ; } if ( $ originalPage -> getCollectionID ( ) == $ destinationPageID ) { return t ( 'It\'s not possible to move the page "%s" under itself.' , $ originalPage -> getCollectionName ( ) ) ; } if ( in_array ( $ destinationPageID , $ originalPage -> getCollectionChildrenArray ( ) ) ) { return t ( 'It\'s not possible to move the page "%s" under one of its child pages.' , $ originalPage -> getCollectionName ( ) ) ; } $ originalPageType = $ originalPage -> getPageTypeObject ( ) ; if ( ! $ destinationPageChecker -> canAddSubpage ( $ originalPageType ) ) { return t ( 'You do not have sufficient privileges to move the page "%1$s" under "%2$s".' , $ originalPage -> getCollectionName ( ) , $ this -> getDestinationPage ( ) -> getCollectionName ( ) ) ; } } return '' ; } | Get the reason why the move operation can t be performed . |
10,721 | protected function whyCantAlias ( ) { if ( $ this -> isSomeOriginalPageAnAlias ( ) ) { return t ( 'It\'s not possible to create aliases of aliases.' ) ; } $ destinationPageChecker = new Checker ( $ this -> getDestinationPage ( ) ) ; foreach ( $ this -> getOriginalPages ( ) as $ originalPage ) { $ originalPageChecker = new Checker ( $ originalPage ) ; if ( ! $ originalPageChecker -> canMoveOrCopyPage ( ) ) { return t ( 'You don\'t have the permission to create an alias of the page "%s".' , $ originalPage -> getCollectionName ( ) ) ; } $ originalPageType = $ originalPage -> getPageTypeObject ( ) ; if ( ! $ destinationPageChecker -> canAddSubpage ( $ originalPageType ) ) { return t ( 'You do not have sufficient privileges to alias the page "%1$s" under "%2$s".' , $ originalPage -> getCollectionName ( ) , $ this -> getDestinationPage ( ) -> getCollectionName ( ) ) ; } } return '' ; } | Get the reason why the alias operation can t be performed . |
10,722 | protected function whyCantCopyVersion ( ) { $ originalPage = $ this -> getSingleOriginalPage ( ) ; if ( $ originalPage === null ) { return t ( "It's possible to copy just one page version at a time." ) ; } if ( $ originalPage -> isExternalLink ( ) ) { return t ( "It's not possible to copy the page version of an external URL." ) ; } if ( $ originalPage -> isAliasPage ( ) ) { return t ( "It's not possible to copy the page version of aliases." ) ; } $ destinationPage = $ this -> getDestinationPage ( ) ; if ( $ destinationPage -> getCollectionID ( ) == $ originalPage -> getCollectionID ( ) ) { return t ( "It's not possible to copy the page version of a page to the page itself." ) ; } $ pc = new Checker ( $ destinationPage ) ; if ( ! $ pc -> canWrite ( ) ) { return t ( 'You don\'t have the permission to edit the contents of "%s".' , $ destinationPage -> getCollectionName ( ) ) ; } return '' ; } | Get the reason why the copy - version operation can t be performed . |
10,723 | public static function get ( ) { $ db = Database :: connection ( ) ; $ treeID = $ db -> fetchColumn ( 'select Trees.treeID from TreeTypes inner join Trees on TreeTypes.treeTypeID = Trees.treeTypeID where TreeTypes.treeTypeHandle = ?' , [ 'file_manager' ] ) ; return $ treeID ? Tree :: getByID ( $ treeID ) : null ; } | Get the FileManager instance . |
10,724 | public function getConversationUsersToEmail ( ) { $ db = Loader :: db ( ) ; $ ids = array ( ) ; if ( ! $ this -> getConversationNotificationOverridesEnabled ( ) > 0 ) { $ ids = $ db -> GetCol ( 'select uID from ConversationSubscriptions where cnvID = 0' ) ; } $ r = $ db -> Execute ( 'select uID, type from ConversationSubscriptions where cnvID = ?' , array ( $ this -> getConversationID ( ) ) ) ; while ( $ row = $ r -> FetchRow ( ) ) { if ( $ row [ 'type' ] == 'U' && in_array ( $ row [ 'uID' ] , $ ids ) ) { $ ids = array_diff ( $ ids , array ( $ row [ 'uID' ] ) ) ; } else { $ ids [ ] = $ row [ 'uID' ] ; } } $ ids = array_unique ( $ ids ) ; $ users = array ( ) ; foreach ( $ ids as $ uID ) { $ ui = \ UserInfo :: getByID ( $ uID ) ; if ( is_object ( $ ui ) ) { $ users [ ] = $ ui ; } } return $ users ; } | Similar to the method below but excludes global subscribers who have opted out of conversations etc ... This method should be used any time we actually act on subscriptions send emails etc ... |
10,725 | public function getAllowedFileExtensions ( ) { $ pk = $ this -> category -> getPermissionKeyByHandle ( 'add_file' ) ; $ pk -> setPermissionObject ( $ this -> object ) ; $ r = $ pk -> getAllowedFileExtensions ( ) ; return $ r ; } | Returns all file extensions this user can add . |
10,726 | public static function create ( $ href = '#' , $ rel = null , $ type = null , $ media = null ) { return new static ( $ href , $ rel , $ type , $ media ) ; } | Static alias for constructor . |
10,727 | public function register ( ) { $ config = $ this -> app -> make ( "config" ) ; if ( $ this -> app -> isInstalled ( ) && $ config -> get ( 'concrete.api.enabled' ) ) { $ router = $ this -> app -> make ( Router :: class ) ; $ list = new ApiRouteList ( ) ; $ list -> loadRoutes ( $ router ) ; $ this -> registerAuthorizationServer ( ) ; } } | Register API related stuff |
10,728 | private function getKeyPair ( ) { $ config = $ this -> app -> make ( 'config/database' ) ; $ keyPair = $ config -> get ( 'api.keypair' ) ; if ( ! $ keyPair ) { $ rsa = $ this -> app -> make ( RSA :: class ) ; $ keyPair = $ rsa -> createKey ( 2048 ) ; foreach ( $ keyPair as & $ item ) { $ item = str_replace ( "\r\n" , "\n" , $ item ) ; } $ config -> save ( 'api.keypair' , $ keyPair ) ; } return $ keyPair ; } | Generate new RSA keys if needed |
10,729 | private function getKey ( $ handle ) { if ( ! $ this -> keyPair ) { $ this -> keyPair = $ this -> getKeyPair ( ) ; } return isset ( $ this -> keyPair [ $ handle ] ) ? $ this -> keyPair [ $ handle ] : null ; } | Get a key by handle |
10,730 | public function process ( Request $ request , DelegateInterface $ frame ) { try { return $ frame -> next ( $ request ) ; } catch ( OAuthServerException $ e ) { return $ e -> generateHttpResponse ( new Response ( ) ) ; } } | Process the request and return a PSR7 error response if needed |
10,731 | public function addAttachmentWithHeaders ( File $ file , array $ headers ) { $ fileVersion = $ file -> getVersion ( ) ; $ resource = $ fileVersion -> getFileResource ( ) ; if ( array_key_exists ( 'filename' , $ headers ) ) { $ filename = $ headers [ 'filename' ] ; unset ( $ headers [ 'filename' ] ) ; } else { $ filename = $ fileVersion -> getFilename ( ) ; } if ( ! array_key_exists ( 'mimetype' , $ headers ) ) { $ headers [ 'mimetype' ] = $ resource -> getMimetype ( ) ; } $ this -> addRawAttachmentWithHeaders ( $ resource -> read ( ) , $ filename , $ headers ) ; } | Add a File entity as an attachment of the message specifying the headers of the mail MIME part . |
10,732 | public function addRawAttachmentWithHeaders ( $ content , $ filename , array $ headers = [ ] ) { $ headers += [ 'mimetype' => 'application/octet-stream' , 'disposition' => Mime :: DISPOSITION_ATTACHMENT , 'encoding' => Mime :: ENCODING_BASE64 , 'charset' => '' , 'boundary' => '' , 'id' => '' , 'description' => '' , 'location' => '' , 'language' => '' , ] ; $ mp = new MimePart ( $ content ) ; $ mp -> setFileName ( $ filename ) -> setType ( $ headers [ 'mimetype' ] ) -> setDisposition ( $ headers [ 'disposition' ] ) -> setEncoding ( $ headers [ 'encoding' ] ) -> setCharset ( $ headers [ 'charset' ] ) -> setBoundary ( $ headers [ 'boundary' ] ) -> setId ( $ headers [ 'id' ] ) -> setDescription ( $ headers [ 'description' ] ) -> setLocation ( $ headers [ 'location' ] ) -> setLanguage ( $ headers [ 'language' ] ) ; $ this -> attachments [ ] = $ mp ; } | Add a mail attachment by specifying its raw binary data specifying the headers of the mail MIME part . |
10,733 | public function to ( $ email , $ name = null ) { if ( strpos ( $ email , ',' ) > 0 ) { $ email = explode ( ',' , $ email ) ; foreach ( $ email as $ em ) { $ this -> to [ ] = [ $ em , $ name ] ; } } else { $ this -> to [ ] = [ $ email , $ name ] ; } } | Add one or more To recipients to the message . |
10,734 | protected function generateEmailStrings ( $ arr ) { $ str = '' ; for ( $ i = 0 ; $ i < count ( $ arr ) ; ++ $ i ) { $ v = $ arr [ $ i ] ; if ( isset ( $ v [ 1 ] ) ) { $ str .= '"' . $ v [ 1 ] . '" <' . $ v [ 0 ] . '>' ; } elseif ( isset ( $ v [ 0 ] ) ) { $ str .= $ v [ 0 ] ; } if ( ( $ i + 1 ) < count ( $ arr ) ) { $ str .= ', ' ; } } return $ str ; } | Convert a list of email addresses to a string . |
10,735 | protected function isInlineAttachment ( MimePart $ attachment ) { return $ this -> bodyHTML !== false && $ attachment -> getId ( ) && in_array ( ( string ) $ attachment -> getDisposition ( ) , [ '' , Mime :: DISPOSITION_INLINE ] , true ) ; } | Determine if an attachment should be used as an inline attachment associated to the HTML body . |
10,736 | private function hasBeenUsed ( $ string , $ id ) { $ repository = $ this -> entityManager -> getRepository ( UsedString :: class ) ; $ allUses = $ repository -> findBy ( [ 'subject' => $ id ] , [ 'id' => 'desc' ] , $ this -> maxReuse ) ; foreach ( $ allUses as $ use ) { if ( $ this -> matches ( $ string , $ use ) ) { return true ; } } return false ; } | Check whether a string has been used against an id |
10,737 | public function trackReview ( Message $ message , Block $ block ) { $ average = $ this -> fetchConversationAverage ( $ message -> getConversationID ( ) ) ; $ this -> assignAverage ( $ block , $ average ) ; } | Track a review on a message |
10,738 | public function transformNode ( $ treeNodeType ) { $ class = self :: getClassByType ( $ treeNodeType ) ; $ node = new $ class ( ) ; $ node -> setPropertiesFromArray ( $ this ) ; return $ node ; } | Transforms a node to another node . |
10,739 | public function getTreeNodeParentArray ( ) { $ db = Database :: connection ( ) ; $ nodeArray = [ ] ; $ currentNodeParentID = $ this -> getTreeNodeParentID ( ) ; if ( $ currentNodeParentID > 0 ) { while ( is_numeric ( $ currentNodeParentID ) && $ currentNodeParentID > 0 && $ currentNodeParentID ) { $ row = $ db -> fetchAssoc ( 'select treeNodeID, treeNodeParentID from TreeNodes where treeNodeID = ?' , [ $ currentNodeParentID ] ) ; if ( $ row && $ row [ 'treeNodeID' ] ) { $ nodeArray [ ] = self :: getByID ( $ row [ 'treeNodeID' ] ) ; } $ currentNodeParentID = $ row [ 'treeNodeParentID' ] ; } } return $ nodeArray ; } | Returns an array of all parents of this tree node . |
10,740 | public function selectChildrenNodesByID ( $ nodeID , $ loadMissingChildren = false ) { if ( $ this -> getTreeNodeID ( ) == $ nodeID ) { $ this -> treeNodeIsSelected = true ; } else { foreach ( $ this -> getChildNodes ( ) as $ childnode ) { if ( $ loadMissingChildren && ! $ childnode -> getChildNodesLoaded ( ) ) { $ childnode -> populateDirectChildrenOnly ( ) ; } $ childnode -> selectChildrenNodesByID ( $ nodeID , $ loadMissingChildren ) ; } } } | Recursively searches for a children node and marks it as selected . |
10,741 | public function checkMove ( Node $ newParent ) { $ result = null ; if ( $ this -> getTreeNodeParentID ( ) != $ newParent -> getTreeNodeID ( ) ) { if ( $ this -> getTreeNodeID ( ) == $ newParent -> getTreeNodeID ( ) ) { $ result = new MoveException ( t ( "It's not possible to move a node under itself" ) ) ; } else { foreach ( $ newParent -> getTreeNodeParentArray ( ) as $ newParentAncestor ) { if ( $ newParentAncestor -> getTreeNodeID ( ) == $ this -> getTreeNodeID ( ) ) { $ result = MoveException ( t ( "It's not possible to move a node under one of its descending nodes" ) ) ; break ; } } } } return $ result ; } | Check if this node can be moved under another parent . |
10,742 | public function move ( Node $ newParent ) { $ error = $ this -> checkMove ( $ newParent ) ; if ( $ error !== null ) { throw $ error ; } if ( $ this -> getTreeNodeParentID ( ) != $ newParent -> getTreeNodeID ( ) ) { $ db = Database :: connection ( ) ; $ existingDisplayOrder = $ this -> treeNodeDisplayOrder ; $ treeNodeDisplayOrder = ( int ) $ db -> fetchColumn ( 'select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?' , [ $ newParent -> getTreeNodeID ( ) ] ) ; $ db -> executeQuery ( 'update TreeNodes set treeNodeParentID = ?, treeNodeDisplayOrder = ? where treeNodeID = ?' , [ $ newParent -> getTreeNodeID ( ) , $ treeNodeDisplayOrder , $ this -> treeNodeID ] ) ; if ( ! $ this -> overrideParentTreeNodePermissions ( ) ) { $ db -> executeQuery ( 'update TreeNodes set inheritPermissionsFromTreeNodeID = ? where treeNodeID = ?' , [ $ newParent -> getTreeNodePermissionsNodeID ( ) , $ this -> treeNodeID ] ) ; } $ oldParent = $ this -> getTreeNodeParentObject ( ) ; if ( is_object ( $ oldParent ) ) { $ db -> executeQuery ( 'update TreeNodes set treeNodeDisplayOrder = (treeNodeDisplayOrder - 1) where treeNodeDisplayOrder > ? and treeNodeParentID = ?' , [ $ existingDisplayOrder , $ oldParent -> getTreeNodeID ( ) ] ) ; $ oldParent -> updateDateModified ( ) ; } $ newParent -> updateDateModified ( ) ; $ this -> treeNodeParentID = $ newParent -> getTreeNodeID ( ) ; $ this -> treeNodeDisplayOrder = $ treeNodeDisplayOrder ; } } | Move this node under another node . |
10,743 | public function updateDateModified ( ) { $ dateModified = Core :: make ( 'date' ) -> toDB ( ) ; $ db = Database :: connection ( ) ; $ db -> update ( 'TreeNodes' , [ 'dateModified' => $ dateModified ] , [ 'treeNodeID' => $ this -> getTreeNodeID ( ) ] ) ; } | Update the Date Modified to the current time . |
10,744 | public static function add ( $ parent = false ) { $ db = Database :: connection ( ) ; $ treeNodeParentID = 0 ; $ treeID = 0 ; $ treeNodeDisplayOrder = 0 ; $ inheritPermissionsFromTreeNodeID = 0 ; if ( is_object ( $ parent ) ) { $ treeNodeParentID = $ parent -> getTreeNodeID ( ) ; $ treeID = $ parent -> getTreeID ( ) ; $ inheritPermissionsFromTreeNodeID = $ parent -> getTreeNodePermissionsNodeID ( ) ; $ treeNodeDisplayOrder = ( int ) $ db -> fetchColumn ( 'select count(treeNodeDisplayOrder) from TreeNodes where treeNodeParentID = ?' , [ $ treeNodeParentID ] ) ; $ parent -> updateDateModified ( ) ; } else { $ parent = null ; } $ treeNodeTypeHandle = uncamelcase ( strrchr ( get_called_class ( ) , '\\' ) ) ; $ dateModified = Core :: make ( 'date' ) -> toDB ( ) ; $ dateCreated = Core :: make ( 'date' ) -> toDB ( ) ; $ type = TreeNodeType :: getByHandle ( $ treeNodeTypeHandle ) ; $ db -> executeQuery ( 'insert into TreeNodes (treeNodeTypeID, treeNodeParentID, treeNodeDisplayOrder, inheritPermissionsFromTreeNodeID, dateModified, dateCreated, treeID) values (?, ?, ?, ?, ?, ?, ?)' , [ $ type -> getTreeNodeTypeID ( ) , $ treeNodeParentID , $ treeNodeDisplayOrder , $ inheritPermissionsFromTreeNodeID , $ dateModified , $ dateCreated , $ treeID , ] ) ; $ id = $ db -> lastInsertId ( ) ; $ node = self :: getByID ( $ id ) ; if ( ! $ inheritPermissionsFromTreeNodeID ) { $ node -> setTreeNodePermissionsToOverride ( ) ; } if ( $ parent !== null && $ parent -> childNodesLoaded ) { $ parent -> childNodes [ ] = $ node ; } return $ node ; } | Add a new node . |
10,745 | public function hasGroup ( $ key ) { list ( $ namespace , $ group ) = $ this -> parseKey ( $ key ) ; return $ this -> loader -> exists ( $ group , $ namespace ) ; } | Determine if a configuration group exists . |
10,746 | public function save ( $ key , $ value ) { list ( $ namespace , $ group , $ item ) = $ this -> parseKey ( $ key ) ; $ collection = $ this -> getCollection ( $ group , $ namespace ) ; unset ( $ this -> items [ $ collection ] ) ; if ( $ this -> saver -> save ( $ item , $ value , $ this -> environment , $ group , $ namespace ) ) { $ this -> load ( $ group , $ namespace , $ this -> getCollection ( $ group , $ namespace ) ) ; return true ; } return false ; } | Save a key . |
10,747 | public function withKey ( $ key , $ value , callable $ callable ) { $ initialValue = $ this -> get ( $ key ) ; try { $ this -> set ( $ key , $ value ) ; return $ callable ( ) ; } finally { $ this -> set ( $ key , $ initialValue ) ; } } | Execute a callable using a specific key value . |
10,748 | protected function applyLengthValidators ( ValidatorManagerInterface $ manager ) { $ minimum = $ this -> getMinimumRequirement ( ) ; $ maximum = $ this -> getMaximumRequirement ( ) ; $ this -> applyMinMaxStrings ( $ minimum , $ maximum ) ; if ( $ maximum ) { $ manager -> setValidator ( 'maximum_length' , $ maximum ) ; } if ( $ minimum ) { $ manager -> setValidator ( 'minimum_length' , $ minimum ) ; } } | Apply configured password length validators |
10,749 | protected function getMaximumRequirement ( ) { $ maximumLength = $ this -> config -> get ( 'concrete.user.password.maximum' ) ; return $ maximumLength ? $ this -> app -> make ( MaximumLengthValidator :: class , [ $ maximumLength ] ) : null ; } | Get maximum length validator |
10,750 | protected function getMinimumRequirement ( ) { $ minimumLength = $ this -> config -> get ( 'concrete.user.password.minimum' , 8 ) ; return $ minimumLength ? $ this -> app -> make ( MinimumLengthValidator :: class , [ $ minimumLength ] ) : null ; } | Get minimum length validator |
10,751 | protected function applyMinMaxStrings ( $ minimum , $ maximum ) { if ( $ minimum && $ maximum ) { $ errorString = t ( 'A password must be between %s and %s characters long.' , $ minimum -> getMinimumLength ( ) , $ maximum -> getMaximumLength ( ) ) ; $ requirement = t ( 'Must be between %s and %s characters long.' , $ minimum -> getMinimumLength ( ) , $ maximum -> getMaximumLength ( ) ) ; } elseif ( $ minimum ) { $ errorString = t ( 'Must be at least %s characters long.' , $ minimum -> getMinimumLength ( ) ) ; $ requirement = t ( 'A password must be at least %s characters long.' , $ minimum -> getMinimumLength ( ) ) ; } elseif ( $ maximum ) { $ errorString = t ( 'A password must be at most %s characters long.' , $ maximum -> getMaximumLength ( ) ) ; $ requirement = t ( 'Must be at most %s characters long.' , $ maximum -> getMaximumLength ( ) ) ; } else { $ errorString = t ( 'Invalid Password.' ) ; $ requirement = '' ; } $ errorHandler = function ( $ validator , $ code , $ password ) use ( $ errorString ) { return $ errorString ; } ; $ requirementHandler = function ( $ validator , $ code ) use ( & $ requirement ) { return $ requirement ; } ; $ minimum -> setRequirementString ( $ minimum :: E_TOO_SHORT , $ requirementHandler ) ; $ minimum -> setErrorString ( $ minimum :: E_TOO_SHORT , $ errorHandler ) ; $ maximum -> setRequirementString ( $ maximum :: E_TOO_LONG , $ requirementHandler ) ; $ maximum -> setErrorString ( $ maximum :: E_TOO_LONG , $ errorHandler ) ; } | Apply translatable strings to minimum and maximum requirements |
10,752 | protected function applyStringRequirementValidators ( ValidatorManagerInterface $ manager ) { $ specialCharacters = ( int ) $ this -> config -> get ( 'concrete.user.password.required_special_characters' , 0 ) ; $ lowerCase = ( int ) $ this -> config -> get ( 'concrete.user.password.required_lower_case' , 0 ) ; $ upperCase = ( int ) $ this -> config -> get ( 'concrete.user.password.required_upper_case' , 0 ) ; if ( $ specialCharacters ) { $ regex = "/([^a-zA-Z0-9].*){{$specialCharacters},}/" ; $ requirement = t2 ( 'Must contain at least %d special character.' , 'Must contain at least %d special characters.' , $ specialCharacters ) ; $ manager -> setValidator ( 'required_special_characters' , $ this -> regexValidator ( $ regex , $ requirement ) ) ; } if ( $ lowerCase ) { $ regex = "/([a-z].*){{$lowerCase},}/" ; $ requirement = t2 ( 'Must contain at least %d lowercase character.' , 'Must contain at least %d lowercase characters.' , $ lowerCase ) ; $ manager -> setValidator ( 'required_lower_case' , $ this -> regexValidator ( $ regex , $ requirement ) ) ; } if ( $ upperCase ) { $ regex = "/([A-Z].*){{$upperCase},}/" ; $ requirement = t2 ( 'Must contain at least %d uppercase character.' , 'Must contain at least %d uppercase characters.' , $ upperCase ) ; $ manager -> setValidator ( 'required_upper_case' , $ this -> regexValidator ( $ regex , $ requirement ) ) ; } } | Apply validators that require specific substrings |
10,753 | protected function regexValidator ( $ regex , $ requirement ) { $ validator = $ this -> app -> make ( RegexValidator :: class , [ $ regex ] ) ; $ validator -> setRequirementString ( RegexValidator :: E_DOES_NOT_MATCH , $ requirement ) ; $ validator -> setErrorString ( RegexValidator :: E_DOES_NOT_MATCH , $ requirement ) ; return $ validator ; } | Create a regex validator |
10,754 | protected function wrappedRegexValidator ( $ regex , $ requirementString ) { $ regexValidator = $ this -> regexValidator ( $ regex , $ requirementString ) ; $ validator = $ this -> app -> make ( ClosureValidator :: class , [ function ( ClosureValidator $ validator , $ string , ArrayAccess $ error = null ) use ( $ regexValidator ) { try { $ regexValidator -> isValid ( $ string , $ error ) ; } catch ( \ RuntimeException $ e ) { if ( $ error ) { $ error [ ] = $ regexValidator :: E_DOES_NOT_MATCH ; } return false ; } } , function ( ) use ( $ regexValidator , $ requirementString ) { return [ $ regexValidator :: E_DOES_NOT_MATCH => $ requirementString ] ; } ] ) ; return $ validator ; } | Create a closure validator that wraps a regex validator and handles all errors If the given regex is invalid we will deny all passwords! |
10,755 | public function getPageHeaderMenuItems ( $ position = false ) { if ( $ position ) { $ tmpItems = array ( ) ; foreach ( $ this -> pageHeaderMenuItems as $ mi ) { if ( $ mi -> getPosition ( ) == $ position ) { $ tmpItems [ ] = $ mi ; } } return $ tmpItems ; } else { return $ this -> pageHeaderMenuItems ; } } | Returns current menu items . |
10,756 | protected function getReplacingFile ( ) { if ( $ this -> replacingFile === false ) { $ replacingFile = null ; $ fID = $ this -> request -> request -> get ( 'fID' , $ this -> request -> query -> get ( 'fID' ) ) ; if ( $ fID && is_scalar ( $ fID ) ) { $ fID = ( int ) $ fID ; if ( $ fID !== 0 ) { $ replacingFile = $ this -> app -> make ( EntityManagerInterface :: class ) -> find ( File :: class , $ fID ) ; } } $ this -> setReplacingFile ( $ replacingFile ) ; } return $ this -> replacingFile ; } | Get the file being replaced . |
10,757 | protected function setReplacingFile ( File $ value = null ) { if ( $ value !== $ this -> replacingFile ) { $ this -> replacingFile = $ value ; } return $ this ; } | Set the file being replaced . |
10,758 | public function process ( ) { $ queue = $ this -> getQueue ( ) ; $ tasks = $ this -> getTasks ( ) ; foreach ( $ this -> target -> getItems ( ) as $ targetItem ) { foreach ( $ tasks as $ task ) { $ action = new QueueAction ( $ this , $ this -> target , $ task [ 1 ] , $ targetItem ) ; $ queue -> send ( serialize ( $ action ) ) ; } } } | Takes the current queue and fills it based on the currently registered tasks and the registered processor . |
10,759 | public function getConfigRepository ( ) { if ( ! $ this -> siteConfig ) { $ app = Application :: getFacadeApplication ( ) ; $ this -> updateSiteConfigRepository ( $ app -> make ( 'config' ) , $ this ) ; } return $ this -> siteConfig ; } | Get the site configuration repository . |
10,760 | public function getSiteHomePageObject ( $ version = 'RECENT' ) { $ tree = $ this -> getSiteTreeObject ( ) ; return $ tree === null ? null : $ tree -> getSiteHomePageObject ( $ version ) ; } | Get the home page of the default language . |
10,761 | public function getTimezone ( ) { $ timezone = null ; $ config = $ this -> getConfigRepository ( ) ; if ( $ config ) { $ timezone = $ config -> get ( 'timezone' ) ; } if ( ! $ timezone ) { $ timezone = date_default_timezone_get ( ) ; } return $ timezone ; } | Get the site time zone identifier . |
10,762 | public function reindex ( ) { $ category = \ Core :: make ( 'Concrete\Core\Attribute\Category\FileCategory' ) ; $ indexer = $ category -> getSearchIndexer ( ) ; $ values = $ category -> getAttributeValues ( $ this ) ; foreach ( $ values as $ value ) { $ indexer -> indexEntry ( $ category , $ value , $ this ) ; } } | Reindex the attributes on this file . |
10,763 | public function setFileStorageLocation ( \ Concrete \ Core \ Entity \ File \ StorageLocation \ StorageLocation $ newLocation ) { $ fh = Loader :: helper ( 'concrete/file' ) ; $ currentLocation = $ this -> getFileStorageLocationObject ( ) ; if ( $ newLocation -> getID ( ) == $ currentLocation -> getID ( ) ) { return false ; } $ currentFilesystem = $ currentLocation -> getFileSystemObject ( ) ; $ newFileSystem = $ newLocation -> getFileSystemObject ( ) ; $ list = $ this -> getVersionList ( ) ; try { foreach ( $ list as $ fv ) { $ manager = new \ League \ Flysystem \ MountManager ( [ 'current' => $ currentFilesystem , 'new' => $ newFileSystem , ] ) ; $ fp = $ fh -> prefix ( $ fv -> getPrefix ( ) , $ fv -> getFilename ( ) ) ; $ manager -> move ( 'current://' . $ fp , 'new://' . $ fp ) ; $ thumbs = Type :: getVersionList ( ) ; foreach ( $ thumbs as $ type ) { $ fv -> updateThumbnailStorageLocation ( $ type , $ newLocation ) ; } } } catch ( \ Exception $ e ) { throw new \ Exception ( $ e -> getMessage ( ) ) ; } $ this -> setStorageLocation ( $ newLocation ) ; $ this -> save ( ) ; } | Move a file from its current FSL to a new FSL . |
10,764 | public function setPassword ( $ pw ) { $ fe = new \ Concrete \ Core \ File \ Event \ FileWithPassword ( $ this ) ; $ fe -> setFilePassword ( $ pw ) ; Events :: dispatch ( 'on_file_set_password' , $ fe ) ; $ this -> fPassword = $ pw ; $ this -> save ( ) ; } | Sets the access password on a file . |
10,765 | public function setUser ( \ Concrete \ Core \ Entity \ User \ User $ user ) { $ this -> author = $ user ; $ this -> save ( ) ; } | Set the user who authored the file . |
10,766 | public function getFileSetIDs ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ rows = $ db -> fetchAll ( 'select fsID from FileSetFiles where fID = ?' , [ $ this -> getFileID ( ) ] ) ; $ ids = array_map ( 'intval' , array_map ( 'array_pop' , $ rows ) ) ; return $ ids ; } | Get the IDs of the file sets that this file belongs to . |
10,767 | public function getFileSets ( ) { $ filesets = [ ] ; foreach ( $ this -> getFileSetIDs ( ) as $ fsID ) { $ fs = FileSet :: getByID ( $ fsID ) ; if ( $ fs !== null ) { $ filesets [ ] = $ fs ; } } return $ filesets ; } | Get the file sets that this file belongs to . |
10,768 | public function isStarred ( $ u = false ) { if ( ! $ u ) { $ u = new User ( ) ; } $ db = Loader :: db ( ) ; $ r = $ db -> GetOne ( 'select fsfID from FileSetFiles fsf inner join FileSets fs on fs.fsID = fsf.fsID where fsf.fID = ? and fs.uID = ? and fs.fsType = ?' , [ $ this -> getFileID ( ) , $ u -> getUserID ( ) , FileSet :: TYPE_STARRED ] ) ; return $ r > 0 ; } | Tell if a file is starred by a user . |
10,769 | public function createNewVersion ( $ copyUnderlyingFile = false ) { $ fv = $ this -> getRecentVersion ( ) ; $ fav = $ this -> getApprovedVersion ( ) ; $ fv2 = $ fv -> duplicate ( ) ; if ( $ fv -> getFileVersionID ( ) == $ fav -> getFileVersionID ( ) ) { $ fv2 -> approve ( ) ; } if ( $ copyUnderlyingFile ) { $ fv2 -> duplicateUnderlyingFile ( ) ; } return $ fv2 ; } | Create a new version of a file . |
10,770 | public function getVersionToModify ( $ forceCreateNew = false ) { $ u = new User ( ) ; $ createNew = false ; $ fv = $ this -> getRecentVersion ( ) ; $ fav = $ this -> getApprovedVersion ( ) ; if ( $ u -> getUserID ( ) != $ fv -> getAuthorUserID ( ) ) { $ createNew = true ; } $ diff = time ( ) - $ fv -> getDateAdded ( ) -> getTimestamp ( ) ; if ( $ diff > self :: CREATE_NEW_VERSION_THRESHOLD ) { $ createNew = true ; } if ( $ forceCreateNew ) { $ createNew = true ; } if ( $ createNew ) { $ fv2 = $ fv -> duplicate ( ) ; if ( $ fv -> getFileVersionID ( ) == $ fav -> getFileVersionID ( ) ) { $ fv2 -> approve ( ) ; } return $ fv2 ; } else { return $ fv ; } } | Returns a file version object that is to be written to . Computes whether we can use the current most recent version OR a new one should be created . |
10,771 | public function setFileFolder ( FileFolder $ folder ) { $ em = \ ORM :: entityManager ( 'core' ) ; $ this -> folderTreeNodeID = $ folder -> getTreeNodeID ( ) ; $ em -> persist ( $ this ) ; $ em -> flush ( ) ; } | Folder to put the file in . |
10,772 | public function inFileSet ( Set $ fs ) { $ db = Loader :: db ( ) ; $ r = $ db -> GetOne ( 'select fsfID from FileSetFiles where fID = ? and fsID = ?' , [ $ this -> getFileID ( ) , $ fs -> getFileSetID ( ) ] ) ; return $ r > 0 ; } | If a file is in a particular file set . |
10,773 | public function delete ( $ removeNode = true ) { $ db = Core :: make ( Connection :: class ) ; $ em = $ db -> getEntityManager ( ) ; $ em -> beginTransaction ( ) ; try { $ fve = new \ Concrete \ Core \ File \ Event \ DeleteFile ( $ this ) ; $ fve = Events :: dispatch ( 'on_file_delete' , $ fve ) ; if ( ! $ fve -> proceed ( ) ) { return false ; } if ( $ removeNode ) { $ nodeID = $ db -> fetchColumn ( 'select treeNodeID from TreeFileNodes where fID = ?' , [ $ this -> getFileID ( ) ] ) ; if ( $ nodeID ) { $ node = Node :: getByID ( $ nodeID ) ; $ node -> delete ( ) ; } } $ versions = $ this -> getVersionList ( ) ; foreach ( $ versions as $ fv ) { $ fv -> delete ( true ) ; } $ db -> Execute ( 'delete from FileSetFiles where fID = ?' , [ $ this -> fID ] ) ; $ db -> Execute ( 'delete from FileSearchIndexAttributes where fID = ?' , [ $ this -> fID ] ) ; $ db -> Execute ( 'delete from DownloadStatistics where fID = ?' , [ $ this -> fID ] ) ; $ db -> Execute ( 'delete from FilePermissionAssignments where fID = ?' , [ $ this -> fID ] ) ; $ db -> Execute ( 'delete from FileImageThumbnailPaths where fileID = ?' , [ $ this -> fID ] ) ; $ db -> Execute ( 'delete from Files where fID = ?' , [ $ this -> fID ] ) ; $ em -> commit ( ) ; } catch ( \ Exception $ e ) { $ em -> rollback ( ) ; throw $ e ; } return true ; } | Removes a file including all of its versions . |
10,774 | public function getRecentVersion ( ) { $ em = \ ORM :: entityManager ( ) ; $ r = $ em -> getRepository ( '\Concrete\Core\Entity\File\Version' ) ; return $ r -> findOneBy ( [ 'file' => $ this ] , [ 'fvID' => 'desc' ] ) ; } | Returns the most recent FileVersion object . |
10,775 | public function getVersion ( $ fvID = null ) { if ( ! $ fvID ) { return $ this -> getApprovedVersion ( ) ; } $ em = \ ORM :: entityManager ( ) ; $ r = $ em -> getRepository ( '\Concrete\Core\Entity\File\Version' ) ; return $ r -> findOneBy ( [ 'file' => $ this , 'fvID' => $ fvID ] ) ; } | returns the FileVersion object for the provided fvID if none provided returns the approved version . |
10,776 | public function getDownloadStatistics ( $ limit = 20 ) { $ db = Loader :: db ( ) ; $ limitString = '' ; if ( $ limit != false ) { $ limitString = 'limit ' . intval ( $ limit ) ; } if ( is_object ( $ this ) && $ this instanceof self ) { return $ db -> getAll ( "SELECT * FROM DownloadStatistics WHERE fID = ? ORDER BY timestamp desc {$limitString}" , [ $ this -> getFileID ( ) ] ) ; } else { return $ db -> getAll ( "SELECT * FROM DownloadStatistics ORDER BY timestamp desc {$limitString}" ) ; } } | Get the download statistics for the current file . |
10,777 | public function trackDownload ( $ rcID = null ) { $ u = new User ( ) ; $ uID = intval ( $ u -> getUserID ( ) ) ; $ fv = $ this -> getApprovedVersion ( ) ; $ fvID = $ fv -> getFileVersionID ( ) ; if ( ! isset ( $ rcID ) || ! is_numeric ( $ rcID ) ) { $ rcID = 0 ; } $ fve = new \ Concrete \ Core \ File \ Event \ FileAccess ( $ fv ) ; Events :: dispatch ( 'on_file_download' , $ fve ) ; $ config = Core :: make ( 'config' ) ; if ( $ config -> get ( 'concrete.statistics.track_downloads' ) ) { $ db = Loader :: db ( ) ; $ db -> Execute ( 'insert into DownloadStatistics (fID, fvID, uID, rcID) values (?, ?, ?, ?)' , [ $ this -> fID , intval ( $ fvID ) , $ uID , $ rcID ] ) ; } } | Tracks File Download takes the cID of the page that the file was downloaded from . |
10,778 | public function delete ( ) { $ list = StorageLocation :: getList ( ) ; foreach ( $ list as $ item ) { if ( $ item -> getTypeObject ( ) -> getHandle ( ) == $ this -> getHandle ( ) ) { throw new \ Exception ( t ( 'Please remove all storage locations using this storage type.' ) ) ; } } $ em = \ ORM :: entityManager ( ) ; $ em -> remove ( $ this ) ; $ em -> flush ( ) ; return true ; } | Removes the storage type if no configurations exist . |
10,779 | public function getStyleValueList ( ) { if ( ! isset ( $ this -> styleValueList ) ) { $ this -> styleValueList = \ Concrete \ Core \ StyleCustomizer \ Style \ ValueList :: loadFromLessFile ( $ this -> file , $ this -> urlroot ) ; } return $ this -> styleValueList ; } | Gets the style value list object for this preset . |
10,780 | public static function getByID ( $ cID , $ version = 'RECENT' ) { $ db = Loader :: db ( ) ; $ q = 'select Collections.cDateAdded, Collections.cDateModified, Collections.cID from Collections where cID = ?' ; $ row = $ db -> getRow ( $ q , [ $ cID ] ) ; $ c = new self ( ) ; $ c -> setPropertiesFromArray ( $ row ) ; if ( $ version != false ) { $ c -> loadVersionObject ( $ version ) ; } return $ c ; } | Get a collection by ID . |
10,781 | public static function createCollection ( $ data ) { $ db = Loader :: db ( ) ; $ dh = Loader :: helper ( 'date' ) ; $ cDate = $ dh -> getOverridableNow ( ) ; $ data = array_merge ( [ 'name' => '' , 'pTemplateID' => 0 , 'handle' => null , 'uID' => null , 'cDatePublic' => $ cDate , 'cDescription' => null , ] , $ data ) ; $ cDatePublic = ( $ data [ 'cDatePublic' ] ) ? $ data [ 'cDatePublic' ] : $ cDate ; if ( isset ( $ data [ 'cID' ] ) ) { $ res = $ db -> query ( 'insert into Collections (cID, cHandle, cDateAdded, cDateModified) values (?, ?, ?, ?)' , [ $ data [ 'cID' ] , $ data [ 'handle' ] , $ cDate , $ cDate ] ) ; $ newCID = $ data [ 'cID' ] ; } else { $ res = $ db -> query ( 'insert into Collections (cHandle, cDateAdded, cDateModified) values (?, ?, ?)' , [ $ data [ 'handle' ] , $ cDate , $ cDate ] ) ; $ newCID = $ db -> Insert_ID ( ) ; } $ cvIsApproved = ( isset ( $ data [ 'cvIsApproved' ] ) && $ data [ 'cvIsApproved' ] == 0 ) ? 0 : 1 ; $ cvIsNew = 1 ; if ( $ cvIsApproved ) { $ cvIsNew = 0 ; } if ( isset ( $ data [ 'cvIsNew' ] ) ) { $ cvIsNew = $ data [ 'cvIsNew' ] ; } $ data [ 'name' ] = Loader :: helper ( 'text' ) -> sanitize ( $ data [ 'name' ] ) ; $ pThemeID = 0 ; if ( isset ( $ data [ 'pThemeID' ] ) && $ data [ 'pThemeID' ] ) { $ pThemeID = $ data [ 'pThemeID' ] ; } $ pTemplateID = 0 ; if ( $ data [ 'pTemplateID' ] ) { $ pTemplateID = $ data [ 'pTemplateID' ] ; } if ( $ res ) { $ v2 = [ $ newCID , 1 , $ pTemplateID , $ data [ 'name' ] , $ data [ 'handle' ] , $ data [ 'cDescription' ] , $ cDatePublic , $ cDate , t ( VERSION_INITIAL_COMMENT ) , $ data [ 'uID' ] , $ cvIsApproved , $ cvIsNew , $ pThemeID , ] ; $ q2 = 'insert into CollectionVersions (cID, cvID, pTemplateID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved, cvIsNew, pThemeID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' ; $ r2 = $ db -> prepare ( $ q2 ) ; $ res2 = $ db -> execute ( $ r2 , $ v2 ) ; } $ nc = self :: getByID ( $ newCID ) ; return $ nc ; } | Create a new Collection instance . |
10,782 | public function getNextVersionComments ( ) { $ c = Page :: getByID ( $ this -> getCollectionID ( ) , 'ACTIVE' ) ; $ cvID = $ c -> getVersionID ( ) ; return t ( 'Version %d' , $ cvID + 1 ) ; } | Get the automatic comment for the next collection version . |
10,783 | public function clearCollectionAttributes ( $ retainAKIDs = [ ] ) { $ db = Loader :: db ( ) ; if ( count ( $ retainAKIDs ) > 0 ) { $ cleanAKIDs = [ ] ; foreach ( $ retainAKIDs as $ akID ) { $ cleanAKIDs [ ] = ( int ) $ akID ; } $ akIDStr = implode ( ',' , $ cleanAKIDs ) ; $ v2 = [ $ this -> getCollectionID ( ) , $ this -> getVersionID ( ) ] ; $ db -> query ( "delete from CollectionAttributeValues where cID = ? and cvID = ? and akID not in ({$akIDStr})" , $ v2 ) ; } else { $ v2 = [ $ this -> getCollectionID ( ) , $ this -> getVersionID ( ) ] ; $ db -> query ( 'delete from CollectionAttributeValues where cID = ? and cvID = ?' , $ v2 ) ; } $ this -> reindex ( ) ; } | Delete the values of the attributes associated to the currently loaded collection version . |
10,784 | public function getSetCollectionAttributes ( ) { $ category = $ this -> vObj -> getObjectAttributeCategory ( ) ; $ values = $ category -> getAttributeValues ( $ this -> vObj ) ; $ attribs = [ ] ; foreach ( $ values as $ value ) { $ attribs [ ] = $ value -> getAttributeKey ( ) ; } return $ attribs ; } | Get the list of attribute keys for which the currently loaded collection version has values . |
10,785 | public function hasAliasedContent ( ) { $ db = Loader :: db ( ) ; $ v = [ $ this -> cID ] ; $ q = 'select bID from CollectionVersionBlocks where cID = ? and isOriginal = 1' ; $ r = $ db -> query ( $ q , $ v ) ; $ bIDArray = [ ] ; if ( $ r ) { while ( $ row = $ r -> fetchRow ( ) ) { $ bIDArray [ ] = $ row [ 'bID' ] ; } if ( count ( $ bIDArray ) > 0 ) { $ bIDList = implode ( ',' , $ bIDArray ) ; $ v2 = [ $ bIDList , $ this -> cID ] ; $ q2 = 'select cID from CollectionVersionBlocks where bID in (?) and cID <> ? limit 1' ; $ aliasedCID = $ db -> getOne ( $ q2 , $ v2 ) ; if ( $ aliasedCID > 0 ) { return true ; } } } return false ; } | Does this collection contain blocks that are aliased in other pages? |
10,786 | public function getAreaCustomStyle ( $ area , $ force = false ) { $ areac = $ area -> getAreaCollectionObject ( ) ; if ( $ areac instanceof Stack ) { return null ; } $ result = null ; $ styles = $ this -> vObj -> getCustomAreaStyles ( ) ; $ areaHandle = $ area -> getAreaHandle ( ) ; if ( $ force || isset ( $ styles [ $ areaHandle ] ) ) { $ pss = isset ( $ styles [ $ areaHandle ] ) ? StyleSet :: getByID ( $ styles [ $ areaHandle ] ) : null ; $ result = new AreaCustomStyle ( $ pss , $ area , $ this -> getCollectionThemeObject ( ) ) ; } return $ result ; } | Get the custom style of an area in the currently loaded collection version . |
10,787 | public function setCustomStyleSet ( $ area , $ set ) { $ db = Loader :: db ( ) ; $ db -> Replace ( 'CollectionVersionAreaStyles' , [ 'cID' => $ this -> getCollectionID ( ) , 'cvID' => $ this -> getVersionID ( ) , 'arHandle' => $ area -> getAreaHandle ( ) , 'issID' => $ set -> getID ( ) , ] , [ 'cID' , 'cvID' , 'arHandle' ] , true ) ; } | Set the custom style of an area in the currently loaded collection version . |
10,788 | public function resetAreaCustomStyle ( $ area ) { $ db = Loader :: db ( ) ; $ db -> Execute ( 'delete from CollectionVersionAreaStyles where cID = ? and cvID = ? and arHandle = ?' , [ $ this -> getCollectionID ( ) , $ this -> getVersionID ( ) , $ area -> getAreaHandle ( ) , ] ) ; } | Delete all the custom styles of an area of the currently loaded collection version . |
10,789 | public function relateVersionEdits ( $ oc ) { $ db = Loader :: db ( ) ; $ v = [ $ this -> getCollectionID ( ) , $ this -> getVersionID ( ) , $ oc -> getCollectionID ( ) , $ oc -> getVersionID ( ) , ] ; $ r = $ db -> GetOne ( 'select count(*) from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?' , $ v ) ; if ( $ r > 0 ) { return false ; } else { $ db -> Execute ( 'insert into CollectionVersionRelatedEdits (cID, cvID, cRelationID, cvRelationID) values (?, ?, ?, ?)' , $ v ) ; } } | Associate the edits of another collection to this collection . |
10,790 | public function getGlobalBlocks ( ) { $ db = Loader :: db ( ) ; $ v = [ Stack :: ST_TYPE_GLOBAL_AREA ] ; $ rs = $ db -> GetCol ( 'select stName from Stacks where Stacks.stType = ?' , $ v ) ; $ blocks = [ ] ; if ( count ( $ rs ) > 0 ) { $ pcp = new Permissions ( $ this ) ; foreach ( $ rs as $ garHandle ) { if ( $ pcp -> canViewPageVersions ( ) ) { $ s = Stack :: getByName ( $ garHandle , 'RECENT' ) ; } else { $ s = Stack :: getByName ( $ garHandle , 'ACTIVE' ) ; } if ( is_object ( $ s ) ) { $ blocksTmp = $ s -> getBlocks ( STACKS_AREA_NAME ) ; $ blocks = array_merge ( $ blocks , $ blocksTmp ) ; } } } return $ blocks ; } | Get the blocks contained in the all the global areas . |
10,791 | public function addBlock ( $ bt , $ a , $ data ) { $ db = Loader :: db ( ) ; $ nb = $ bt -> add ( $ data , $ this , $ a ) ; $ arHandle = ( is_object ( $ a ) ) ? $ a -> getAreaHandle ( ) : $ a ; $ cID = $ this -> getCollectionID ( ) ; $ vObj = $ this -> getVersionObject ( ) ; if ( $ bt -> includeAll ( ) ) { $ newBlockDisplayOrder = $ this -> getCollectionAreaDisplayOrder ( $ arHandle , true ) ; } else { $ newBlockDisplayOrder = $ this -> getCollectionAreaDisplayOrder ( $ arHandle ) ; } $ cbRelationID = $ db -> GetOne ( 'select max(cbRelationID) as cbRelationID from CollectionVersionBlocks' ) ; if ( ! $ cbRelationID ) { $ cbRelationID = 1 ; } else { ++ $ cbRelationID ; } $ v = [ $ cID , $ vObj -> getVersionID ( ) , $ nb -> getBlockID ( ) , $ arHandle , $ cbRelationID , $ newBlockDisplayOrder , 1 , ( int ) ( $ bt -> includeAll ( ) ) , ] ; $ q = 'insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbRelationID, cbDisplayOrder, isOriginal, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?)' ; $ res = $ db -> Execute ( $ q , $ v ) ; $ controller = $ nb -> getController ( ) ; $ features = $ controller -> getBlockTypeFeatureObjects ( ) ; if ( count ( $ features ) > 0 ) { foreach ( $ features as $ fe ) { $ fd = $ fe -> getFeatureDetailObject ( $ controller ) ; $ fa = CollectionVersionFeatureAssignment :: add ( $ fe , $ fd , $ this ) ; $ db -> Execute ( 'insert into BlockFeatureAssignments (cID, cvID, bID, faID) values (?, ?, ?, ?)' , [ $ this -> getCollectionID ( ) , $ this -> getVersionID ( ) , $ nb -> getBlockID ( ) , $ fa -> getFeatureAssignmentID ( ) , ] ) ; } } return Block :: getByID ( $ nb -> getBlockID ( ) , $ this , $ a ) ; } | Add a new block to a specific area of the currently loaded collection version . |
10,792 | public function addFeature ( Feature $ fe ) { $ db = Loader :: db ( ) ; $ db -> Replace ( 'CollectionVersionFeatures' , [ 'cID' => $ this -> getCollectionID ( ) , 'cvID' => $ this -> getVersionID ( ) , 'feID' => $ fe -> getFeatureID ( ) ] , [ 'cID' , 'cvID' , 'feID' ] , true ) ; } | Associate a feature to the currently loaded collection version . |
10,793 | public function delete ( ) { if ( $ this -> cID > 0 ) { $ db = Loader :: db ( ) ; $ vl = new VersionList ( $ this ) ; $ vl -> setItemsPerPage ( - 1 ) ; $ vlArray = $ vl -> getPage ( ) ; foreach ( $ vlArray as $ v ) { $ v -> delete ( ) ; } $ cID = $ this -> getCollectionID ( ) ; $ q = "delete from CollectionAttributeValues where cID = {$cID}" ; $ db -> query ( $ q ) ; $ q = "delete from Collections where cID = '{$cID}'" ; $ r = $ db -> query ( $ q ) ; try { $ q = "delete from CollectionSearchIndexAttributes where cID = {$cID}" ; $ db -> query ( $ q ) ; } catch ( \ Exception $ e ) { } } } | Delete this collection and all its versions contents and attributes . |
10,794 | public function duplicateCollection ( ) { $ app = Application :: getFacadeApplication ( ) ; $ cloner = $ app -> make ( Cloner :: class ) ; $ clonerOptions = $ app -> build ( ClonerOptions :: class ) -> setKeepOriginalAuthor ( true ) ; $ newCollection = $ cloner -> cloneCollection ( $ this , $ clonerOptions ) ; return $ newCollection ; } | Create a clone of this collection and all its versions contents and attributes . |
10,795 | public function cloneVersion ( $ versionComments , $ createEmpty = false ) { $ app = Application :: getFacadeApplication ( ) ; $ cloner = $ app -> make ( Cloner :: class ) ; $ clonerOptions = $ app -> make ( ClonerOptions :: class ) -> setVersionComments ( $ versionComments ) -> setCopyContents ( $ createEmpty ? false : true ) ; $ newVersion = $ cloner -> cloneCollectionVersion ( $ this -> getVersionObject ( ) , $ this , $ clonerOptions ) ; return Page :: getByID ( $ newVersion -> getCollectionID ( ) , $ newVersion -> getVersionID ( ) ) ; } | Clone the currently loaded version and returns a Page instance containing the new version . |
10,796 | public function addEntityManager ( EntityManagerInterface $ em ) { if ( ! in_array ( $ em , $ this -> entityManagers , true ) ) { $ this -> entityManagers [ ] = $ em ; } return $ this ; } | Add an EntityManagerInterface instance to the list . |
10,797 | public function image ( $ pathToImage ) { if ( ! function_exists ( 'exif_imagetype' ) ) { function exif_imagetype ( $ filename ) { if ( ( list ( $ width , $ height , $ type , $ attr ) = getimagesize ( $ filename ) ) !== false ) { return $ type ; } return false ; } } $ val = @ exif_imagetype ( $ pathToImage ) ; return in_array ( $ val , array ( IMAGETYPE_GIF , IMAGETYPE_JPEG , IMAGETYPE_PNG ) ) ; } | Tests whether the passed item a valid image . |
10,798 | public function extension ( $ filename , $ extensions = null ) { $ f = Loader :: helper ( 'file' ) ; $ ext = strtolower ( $ f -> getExtension ( $ filename ) ) ; if ( isset ( $ extensions ) && is_array ( $ extensions ) && count ( $ extensions ) ) { $ allowed_extensions = $ extensions ; } else { $ extensions_string = strtolower ( str_replace ( array ( "*" , "." ) , "" , Config :: get ( 'concrete.upload.extensions' ) ) ) ; $ allowed_extensions = explode ( ";" , $ extensions_string ) ; } return in_array ( $ ext , $ allowed_extensions ) ; } | Parses the file extension for a given file name checks it to see if it s in the the extension array if provided if not it checks to see if it s in the concrete . upload . extensions configuration option . |
10,799 | public function addCookie ( $ name , $ value = null , $ expire = 0 , $ path = '/' , $ domain = null , $ secure = false , $ httpOnly = true ) { $ cookie = new Cookie ( $ name , $ value , $ expire , $ path , $ domain , $ secure , $ httpOnly ) ; $ this -> addCookieObject ( $ cookie ) ; return $ cookie ; } | Adds a Cookie object to the cookie pantry . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.