idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
10,200 | protected function setCategory ( CategoryInterface $ category ) { $ this -> category = $ category ; $ this -> attributeKeysAndControllers = null ; $ this -> csvHeader = null ; return $ this ; } | Set the attribute category to be used to export the data . |
10,201 | protected function getAttributeKeysAndControllers ( ) { if ( $ this -> attributeKeysAndControllers === null ) { $ list = [ ] ; foreach ( $ this -> category -> getList ( ) as $ attributeKey ) { $ list [ ] = [ $ attributeKey , $ attributeKey -> getController ( ) ] ; } $ this -> attributeKeysAndControllers = $ list ; } return $ this -> attributeKeysAndControllers ; } | Get a list the attribute keys and controllers for the current category . |
10,202 | private function convertCsvDataForAttributeController ( AttributeController $ attributeController , $ csvData ) { $ result = $ csvData ; if ( $ attributeController instanceof MulticolumnTextExportableAttributeInterface ) { $ attributeHeaders = $ attributeController -> getAttributeTextRepresentationHeaders ( ) ; $ result = array_pad ( [ ] , count ( $ attributeHeaders ) , '' ) ; foreach ( $ attributeHeaders as $ attributeHeaderIndex => $ attributeHeaderName ) { if ( isset ( $ csvData [ $ attributeHeaderName ] ) ) { $ result [ $ attributeHeaderIndex ] = $ csvData [ $ attributeHeaderName ] ; } } } return $ result ; } | Convert the data read from CSV to be passed to the attribute controller . |
10,203 | public function hasActiveSession ( ) { $ cookie = $ this -> app [ 'cookie' ] ; return $ cookie -> has ( $ this -> config -> get ( 'concrete.session.name' ) ) || $ cookie -> has ( 'ccmAuthUserHash' ) ; } | Check if there is an active session . |
10,204 | public function containsField ( $ field ) { $ identifier = $ field instanceof FieldInterface ? $ field -> getFieldElementName ( ) : $ field ; foreach ( $ this -> getList ( ) as $ error ) { $ field = $ error -> getField ( ) ; if ( is_object ( $ field ) && $ field -> getFieldElementName ( ) == $ identifier ) { return true ; } } return false ; } | Does this list contain error associated to a field? |
10,205 | private function detectFromServer ( $ value ) { $ result = null ; if ( is_string ( $ value ) && preg_match ( '/\bnginx\/(\d+(\.\d+)+)/i' , $ value , $ m ) ) { $ result = $ m [ 1 ] ; } return $ result ; } | Detect from the SERVER_SOFTWARE key of the superglobal server array . |
10,206 | public function getActionDescription ( ) { $ entityManager = $ this -> getApplication ( ) -> make ( EntityManagerInterface :: class ) ; $ user = $ entityManager -> find ( User :: class , $ this -> notification -> getUserID ( ) ) ; $ actor = null ; $ actorID = $ this -> notification -> getActorID ( ) ; if ( $ actorID ) { $ actor = $ entityManager -> find ( User :: class , $ actorID ) ; } if ( $ actorID ) { return t ( '%s has been manually deactivated by %s' , $ this -> getUserLink ( $ user ) , $ this -> getUserLink ( $ actor ) ) ; } return t ( '%s has been automatically deactivated.' , $ this -> getUserLink ( $ user ) ) ; } | Build the description for this notification |
10,207 | protected function getUrlResolver ( ) { if ( ! $ this -> resolver ) { $ this -> resolver = $ this -> getApplication ( ) -> make ( ResolverManagerInterface :: class ) ; } return $ this -> resolver ; } | Resolve the url resolver instance |
10,208 | public function refreshEntities ( ) { $ metadatas = $ this -> clearCacheAndProxies ( ) ; $ tool = new SchemaTool ( $ this -> entityManager ) ; $ tool -> updateSchema ( $ metadatas , true ) ; } | Clears cache regenerates all proxy classes and updates metadatas in all entity managers |
10,209 | public function getText ( ) { $ lines = [ ] ; if ( $ this -> error -> has ( ) ) { foreach ( $ this -> error -> getList ( ) as $ error ) { if ( $ error instanceof HtmlAwareErrorInterface && $ error -> messageContainsHtml ( ) ) { $ lines [ ] = strip_tags ( ( string ) $ error ) ; } else { $ lines [ ] = ( string ) $ error ; } } } return implode ( "\n" , $ lines ) ; } | Build an plain text string describing the errors . |
10,210 | protected function uploadZipToTemp ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new Exception ( t ( 'Could not transfer to temp directory - file not found.' ) ) ; } else { $ dir = time ( ) ; copy ( $ file , $ this -> f -> getTemporaryDirectory ( ) . '/' . $ dir . '.zip' ) ; return $ dir ; } } | Moves an uploaded file to the tmp directory . |
10,211 | protected function install ( $ file , $ inplace = false ) { if ( ! $ inplace ) { $ directory = $ this -> uploadZipToTemp ( $ file ) ; } else { $ directory = $ file ; } $ dir = $ this -> unzip ( $ directory ) ; $ dirFull = $ this -> getArchiveDirectory ( $ dir ) ; $ dirFull = str_replace ( DIRECTORY_SEPARATOR , '/' , $ dirFull ) ; $ dirBase = substr ( strrchr ( $ dirFull , '/' ) , 1 ) ; if ( file_exists ( $ this -> targetDirectory . '/' . $ dirBase ) ) { throw new Exception ( t ( 'The directory %s already exists. Perhaps this item has already been installed.' , $ this -> targetDirectory . '/' . $ dirBase ) ) ; } else { $ this -> f -> copyAll ( $ dirFull , $ this -> targetDirectory . '/' . $ dirBase ) ; if ( ! is_dir ( $ this -> targetDirectory . '/' . $ dirBase ) ) { throw new Exception ( t ( 'Unable to copy directory %s to %s. Perhaps permissions are set incorrectly or the target directory does not exist.' , $ dirBase , $ this -> targetDirectory ) ) ; } } return $ dirBase ; } | Installs a zip file from the passed directory . |
10,212 | public function load ( $ akID ) { $ em = $ this -> getFacadeApplication ( ) -> make ( 'Doctrine\ORM\EntityManager' ) ; $ this -> legacyAttributeKey = $ em -> find ( 'Concrete\Core\Entity\Attribute\Key\LegacyKey' , $ akID ) ; } | In 5 . 7 and earlier if a subclassed Key object called load it was loading the core data of an attribute key . we re going to load that data into an internal legacy key object that we can keep around to pass calls to for attribute keys that incorrectly subclass this Key object . |
10,213 | protected function dateDiffNoDST ( \ DateTime $ from , \ DateTime $ to ) { $ fromUTC = new \ DateTime ( $ from -> format ( 'Y-m-d\TH:i:s+00:00' ) ) ; $ toUTC = new \ DateTime ( $ to -> format ( 'Y-m-d\TH:i:s+00:00' ) ) ; return $ fromUTC -> diff ( $ toUTC ) ; } | Returns the difference between two DateTime objects without considering DST changes . |
10,214 | public function add ( $ type , $ key , $ settings = null , $ pkg = null ) { if ( is_string ( $ type ) ) { $ typeFactory = $ this -> application -> make ( TypeFactory :: class ) ; $ type = $ typeFactory -> getByHandle ( $ type ) ; } $ asID = false ; if ( is_array ( $ key ) ) { $ handle = $ key [ 'akHandle' ] ; $ name = $ key [ 'akName' ] ; if ( isset ( $ key [ 'asID' ] ) ) { $ asID = $ key [ 'asID' ] ; } $ key = $ this -> createAttributeKey ( ) ; $ key -> setAttributeKeyHandle ( $ handle ) ; $ key -> setAttributeKeyName ( $ name ) ; } if ( $ settings instanceof Package || $ settings instanceof \ Concrete \ Core \ Package \ Package ) { $ pkg = $ settings ; $ settings = null ; } if ( ! $ settings ) { $ settings = $ type -> getController ( ) -> getAttributeKeySettings ( ) ; } $ key -> setAttributeType ( $ type ) ; $ this -> entityManager -> persist ( $ key ) ; $ this -> entityManager -> flush ( ) ; $ settings -> setAttributeKey ( $ key ) ; $ key -> setAttributeKeySettings ( $ settings ) ; $ this -> entityManager -> persist ( $ settings ) ; $ this -> entityManager -> flush ( ) ; if ( is_object ( $ pkg ) ) { $ key -> setPackage ( $ pkg ) ; } $ indexer = $ this -> getSearchIndexer ( ) ; if ( is_object ( $ indexer ) ) { $ indexer -> updateRepositoryColumns ( $ this , $ key ) ; } $ this -> entityManager -> persist ( $ key ) ; $ this -> entityManager -> flush ( ) ; if ( $ asID ) { $ manager = $ this -> getSetManager ( ) ; $ factory = new SetFactory ( $ this -> entityManager ) ; $ set = $ factory -> getByID ( $ asID ) ; if ( $ set !== null ) { $ manager -> addKey ( $ set , $ key ) ; } } return $ key ; } | Add a new attribute key . |
10,215 | public function import ( AttributeType $ type , SimpleXMLElement $ element , Package $ package = null ) { $ key = $ this -> createAttributeKey ( ) ; $ loader = $ this -> getImportLoader ( ) ; $ loader -> load ( $ key , $ element ) ; $ controller = $ type -> getController ( ) ; $ settings = $ controller -> importKey ( $ element ) ; if ( ! is_object ( $ settings ) ) { $ settings = $ controller -> getAttributeKeySettings ( ) ; } return $ this -> add ( $ type , $ key , $ settings , $ package ) ; } | Import a new attribute key from a SimpleXMLElement instance . |
10,216 | public function shutdown ( $ options = [ ] ) { \ Events :: dispatch ( 'on_shutdown' ) ; if ( $ this -> isInstalled ( ) ) { if ( ! isset ( $ options [ 'jobs' ] ) || $ options [ 'jobs' ] == false ) { $ this -> handleScheduledJobs ( ) ; } foreach ( \ Database :: getConnections ( ) as $ connection ) { $ connection -> close ( ) ; } } exit ; } | Turns off the lights . |
10,217 | protected function handleScheduledJobs ( ) { $ config = $ this [ 'config' ] ; if ( $ config -> get ( 'concrete.jobs.enable_scheduling' ) ) { $ c = Page :: getCurrentPage ( ) ; if ( $ c instanceof Page && ! $ c -> isAdminArea ( ) ) { $ jobs = Job :: getList ( true ) ; $ auth = Job :: generateAuth ( ) ; $ url = '' ; if ( count ( $ jobs ) ) { foreach ( $ jobs as $ j ) { if ( $ j -> isScheduledForNow ( ) ) { $ url = View :: url ( '/ccm/system/jobs/run_single?auth=' . $ auth . '&jID=' . $ j -> getJobID ( ) ) ; break ; } } } if ( ! strlen ( $ url ) ) { $ jSets = JobSet :: getList ( true ) ; if ( is_array ( $ jSets ) && count ( $ jSets ) ) { foreach ( $ jSets as $ set ) { if ( $ set -> isScheduledForNow ( ) ) { $ url = View :: url ( '/ccm/system/jobs?auth=' . $ auth . '&jsID=' . $ set -> getJobSetID ( ) ) ; break ; } } } } if ( strlen ( $ url ) ) { try { $ this -> make ( 'http/client' ) -> setUri ( $ url ) -> send ( ) ; } catch ( Exception $ x ) { } } } } } | If we have job scheduling running through the site we check to see if it s time to go for it . |
10,218 | public function isInstalled ( ) { if ( $ this -> installed === null ) { if ( ! $ this -> isShared ( 'config' ) ) { throw new Exception ( 'Attempting to check install status before application initialization.' ) ; } $ this -> installed = $ this -> make ( 'config' ) -> get ( 'concrete.installed' ) ; } return $ this -> installed ; } | Returns true if concrete5 is installed false if it has not yet been . |
10,219 | public function checkPageCache ( \ Concrete \ Core \ Http \ Request $ request ) { $ library = PageCache :: getLibrary ( ) ; if ( $ library -> shouldCheckCache ( $ request ) ) { $ record = $ library -> getRecord ( $ request ) ; if ( $ record instanceof PageCacheRecord ) { if ( $ record -> validate ( $ request ) ) { return $ library -> deliver ( $ record ) ; } } } return false ; } | Checks to see whether we should deliver a concrete5 response from the page cache . |
10,220 | public function handleAutomaticUpdates ( ) { $ config = $ this [ 'config' ] ; $ installed = $ config -> get ( 'concrete.version_db_installed' ) ; $ core = $ config -> get ( 'concrete.version_db' ) ; if ( $ installed < $ core ) { $ this -> make ( MutexInterface :: class ) -> execute ( Update :: MUTEX_KEY , function ( ) { Update :: updateToCurrentVersion ( ) ; } ) ; } } | Check if the core needs to be updated and if so updates it . |
10,221 | public function setupPackageAutoloaders ( ) { $ pla = \ Concrete \ Core \ Package \ PackageList :: get ( ) ; $ pl = $ pla -> getPackages ( ) ; $ cl = ClassLoader :: getInstance ( ) ; foreach ( $ pl as $ p ) { \ Config :: package ( $ p ) ; if ( $ p -> isPackageInstalled ( ) ) { $ pkg = $ this -> make ( 'Concrete\Core\Package\PackageService' ) -> getClass ( $ p -> getPackageHandle ( ) ) ; if ( is_object ( $ pkg ) && ( ! $ pkg instanceof \ Concrete \ Core \ Package \ BrokenPackage ) ) { $ cl -> registerPackage ( $ pkg ) ; $ this -> packages [ ] = $ pkg ; } } } } | Register package autoloaders . Has to come BEFORE session calls . |
10,222 | public function setupPackages ( ) { $ config = $ this [ 'config' ] ; $ loc = Localization :: getInstance ( ) ; $ entityManager = $ this [ 'Doctrine\ORM\EntityManager' ] ; $ configUpdater = new EntityManagerConfigUpdater ( $ entityManager ) ; foreach ( $ this -> packages as $ pkg ) { if ( $ config -> get ( 'concrete.updates.enable_auto_update_packages' ) ) { $ dbPkg = \ Package :: getByHandle ( $ pkg -> getPackageHandle ( ) ) ; $ pkgInstalledVersion = $ dbPkg -> getPackageVersion ( ) ; $ pkgFileVersion = $ pkg -> getPackageVersion ( ) ; if ( version_compare ( $ pkgFileVersion , $ pkgInstalledVersion , '>' ) ) { $ loc -> pushActiveContext ( Localization :: CONTEXT_SYSTEM ) ; $ dbPkg -> upgradeCoreData ( ) ; $ dbPkg -> upgrade ( ) ; $ loc -> popActiveContext ( ) ; } } } $ packagesWithOnAfterStart = [ ] ; $ service = $ this -> make ( PackageService :: class ) ; foreach ( $ this -> packages as $ pkg ) { if ( method_exists ( $ pkg , 'on_start' ) ) { $ pkg -> on_start ( ) ; } $ service -> bootPackageEntityManager ( $ pkg ) ; if ( method_exists ( $ pkg , 'on_after_packages_start' ) ) { $ packagesWithOnAfterStart [ ] = $ pkg ; } } foreach ( $ packagesWithOnAfterStart as $ pkg ) { $ pkg -> on_after_packages_start ( ) ; } } | Run startup and localization events on any installed packages . |
10,223 | public function setupFilesystem ( ) { $ config = $ this [ 'config' ] ; if ( ! is_dir ( $ config -> get ( 'concrete.cache.directory' ) ) ) { @ mkdir ( $ config -> get ( 'concrete.cache.directory' ) , $ config -> get ( 'concrete.filesystem.permissions.directory' ) ) ; @ touch ( $ config -> get ( 'concrete.cache.directory' ) . '/index.html' , $ config -> get ( 'concrete.filesystem.permissions.file' ) ) ; } } | Ensure we have a cache directory . |
10,224 | public function handleURLSlashes ( SymfonyRequest $ request , Site $ site ) { $ path = $ request -> getPathInfo ( ) ; if ( $ path && $ path != '/' ) { $ config = $ this -> make ( 'config' ) ; $ trailing_slashes = $ config -> get ( 'concrete.seo.trailing_slash' ) ; if ( ( $ trailing_slashes && substr ( $ path , - 1 ) != '/' ) || ( ! $ trailing_slashes && substr ( $ path , - 1 ) == '/' ) ) { $ parsed_url = Url :: createFromUrl ( $ request -> getUri ( ) , $ trailing_slashes ? Url :: TRAILING_SLASHES_ENABLED : Url :: TRAILING_SLASHES_DISABLED ) ; $ response = new RedirectResponse ( $ parsed_url , 301 ) ; $ response -> setRequest ( $ request ) ; return $ response ; } } } | Using the configuration value determines whether we need to redirect to a URL with a trailing slash or not . |
10,225 | public function handleCanonicalURLRedirection ( SymfonyRequest $ r , Site $ site ) { $ globalConfig = $ this [ 'config' ] ; $ siteConfig = $ site -> getConfigRepository ( ) ; if ( $ globalConfig -> get ( 'concrete.seo.redirect_to_canonical_url' ) && $ siteConfig -> get ( 'seo.canonical_url' ) ) { $ requestUri = $ r -> getUri ( ) ; $ path = parse_url ( $ requestUri , PHP_URL_PATH ) ; $ trailingSlash = substr ( $ path , - 1 ) === '/' ; $ url = UrlImmutable :: createFromUrl ( $ requestUri , $ trailingSlash ) ; $ mainCanonical = null ; foreach ( [ 'seo.canonical_url' , 'seo.canonical_url_alternative' ] as $ key ) { $ canonicalUrlString = $ siteConfig -> get ( $ key ) ; if ( ! $ canonicalUrlString ) { continue ; } $ canonicalUrl = UrlImmutable :: createFromUrl ( $ canonicalUrlString , ( bool ) $ globalConfig -> get ( 'concrete.seo.trailing_slash' ) ) ; $ canonical = $ url -> setScheme ( $ canonicalUrl -> getScheme ( ) -> get ( ) ) -> setHost ( $ canonicalUrl -> getHost ( ) -> get ( ) ) -> setPort ( $ canonicalUrl -> getPort ( ) -> get ( ) ) ; if ( $ canonical == $ url ) { return null ; } if ( $ mainCanonical === null ) { $ mainCanonical = $ canonical ; } } $ response = new RedirectResponse ( $ mainCanonical , '301' ) ; return $ response ; } } | If we have redirect to canonical host enabled we need to honor it here . |
10,226 | public function getLocalizedStack ( Section $ section , $ cvID = 'RECENT' ) { $ result = null ; $ mySectionID = $ this -> getMultilingualSectionID ( ) ; if ( $ mySectionID !== 0 && $ section -> getCollectionID ( ) == $ mySectionID ) { $ result = $ this ; } else { $ neutralID = ( $ mySectionID === 0 ) ? $ this -> getCollectionID ( ) : $ this -> getNeutralStackID ( ) ; $ db = Database :: connection ( ) ; $ localizedID = $ db -> fetchColumn ( ' select Stacks.cID from Stacks inner join Pages on Stacks.cID = Pages.cID where Pages.cParentID = ? and Stacks.stMultilingualSection = ? limit 1 ' , [ $ neutralID , $ section -> getCollectionID ( ) ] ) ; if ( $ localizedID ) { $ localized = static :: getByID ( $ localizedID , $ cvID ) ; if ( $ localized ) { $ result = $ localized ; } } } return $ result ; } | Returns the localized version of this stack . |
10,227 | protected function writeError ( OutputInterface $ output , $ error ) { $ result = [ trim ( $ error -> getMessage ( ) ) ] ; if ( $ output -> isVerbose ( ) ) { $ file = $ error -> getFile ( ) ; if ( $ file ) { $ result [ ] = "File: {$file}" . ( $ error -> getLine ( ) ? ':' . $ error -> getLine ( ) : '' ) ; } } if ( $ output -> isVeryVerbose ( ) ) { $ trace = $ error -> getTraceAsString ( ) ; $ result [ ] = 'Trace:' ; $ result [ ] = $ trace ; } $ this -> output -> error ( $ result ) ; } | Write an exception . |
10,228 | protected function execute ( InputInterface $ input , OutputInterface $ output ) { if ( ! method_exists ( $ this , 'handle' ) ) { throw new LogicException ( 'You must define the public handle() method in the command implementation.' ) ; } return $ this -> getApplication ( ) -> getConcrete5 ( ) -> call ( [ $ this , 'handle' ] ) ; } | This method is overridden to pipe execution to the handle method hiding input and output |
10,229 | public function table ( array $ headers , array $ rows , $ tableStyle = 'default' , array $ columnStyles = [ ] ) { $ this -> output -> table ( $ headers , $ rows , $ tableStyle , $ columnStyles ) ; } | Format input to textual table . |
10,230 | public function getConcrete5ProfileURL ( $ user ) { $ result = null ; $ binding = $ this -> getBindingForUser ( $ user ) ; if ( $ binding !== null ) { $ concrete5UserID = ( int ) $ binding ; if ( $ concrete5UserID !== 0 ) { $ result = "https://www.concrete5.org/profile/-/view/$concrete5UserID/" ; } } return $ result ; } | Get the URL of the concrete5 account associated to a user . |
10,231 | private function getQuestion ( $ row , InputInterface $ input ) { $ definition = $ this -> getDefinition ( ) ; $ row = ( array ) $ row ; $ default = null ; $ mutator = null ; $ key = array_shift ( $ row ) ; if ( $ row ) { $ default = array_shift ( $ row ) ; } if ( is_callable ( $ default ) ) { $ mutator = $ default ; $ default = array_shift ( $ row ) ; if ( is_callable ( $ default ) ) { $ default = $ default ( $ input ) ; } } elseif ( $ row ) { $ mutator = array_shift ( $ row ) ; } if ( $ provided = $ input -> getOption ( $ key ) ) { $ default = $ provided ; } $ option = $ definition -> getOption ( $ key ) ; if ( ! $ default ) { $ default = $ option -> getDefault ( ) ; } $ question = new Question ( $ this -> getQuestionString ( $ option , $ default ) , $ default ) ; if ( is_callable ( $ mutator ) ) { $ question = $ mutator ( $ question , $ input , $ option ) ; } return $ question ; } | Do some procedural work to a row in the wizard step list to turn it into a proper question . |
10,232 | private function getWizard ( InputInterface $ input , OutputInterface $ output , $ firstKey = null ) { $ questions = $ this -> wizardSteps ( ) ; $ tryAgain = false ; $ result = null ; foreach ( $ questions as $ question ) { if ( ! $ firstKey && $ question instanceof \ Closure ) { $ result = $ question ( $ input , $ output , $ this ) ; if ( $ result === false || is_string ( $ result ) ) { $ tryAgain = true ; break ; } continue ; } $ question = ( array ) $ question ; if ( $ firstKey && $ question [ 0 ] !== $ firstKey ) { continue ; } if ( $ firstKey ) { $ firstKey = null ; } if ( in_array ( $ question [ 0 ] , [ 'demo-password' , 'demo-email' ] , true ) && '' === ( string ) $ input -> getOption ( 'demo-username' ) ) { continue ; } yield $ question [ 0 ] => $ this -> getQuestion ( $ question , $ input ) ; } if ( $ tryAgain ) { foreach ( $ this -> getWizard ( $ input , $ output , $ result ) as $ key => $ value ) { yield $ key => $ value ; } } } | A wizard generator . |
10,233 | private function getQuestionString ( InputOption $ option , $ default ) { if ( '' !== ( string ) $ default ) { if ( stripos ( $ option -> getName ( ) , 'password' ) !== false ) { return sprintf ( '%s? [<options=bold>HIDDEN</>]: ' , $ option -> getDescription ( ) , $ default ) ; } return sprintf ( '%s? [<options=bold>%s</>]: ' , $ option -> getDescription ( ) , $ default ) ; } return sprintf ( '%s?: ' , $ option -> getDescription ( ) ) ; } | Take an option and return a question string . |
10,234 | public function createClient ( $ name , $ redirect , array $ scopes , $ key , $ secret ) { $ client = $ this -> app -> make ( Client :: class ) ; $ client -> setName ( $ name ) ; $ client -> setRedirectUri ( $ redirect ) ; $ client -> setClientKey ( $ key ) ; $ client -> setClientSecret ( $ secret ) ; $ id = $ this -> generator -> generate ( $ this -> entityManager , $ client ) ; $ client -> setIdentifier ( $ id ) ; return $ client ; } | Create a new OAuth client object and provide it a proper UUID |
10,235 | protected function generateString ( $ length ) { $ bytes = ceil ( $ length / 2 ) ; $ string = bin2hex ( random_bytes ( $ bytes ) ) ; return substr ( $ string , 0 , $ length ) ; } | Generate a cryptographically secure strig |
10,236 | public function getOutput ( $ request = null ) { $ pl = $ this -> getPageListObject ( ) ; $ link = false ; if ( $ this -> cParentID ) { $ parent = Page :: getByID ( $ this -> cParentID ) ; $ link = $ parent -> getCollectionLink ( ) ; } else { $ link = \ URL :: to ( '/' ) ; } $ pagination = $ pl -> getPagination ( ) ; $ results = $ pagination -> getCurrentPageResults ( ) ; if ( count ( $ results ) ) { $ writer = new \ Zend \ Feed \ Writer \ Feed ( ) ; $ writer -> setTitle ( $ this -> getTitle ( ) ) ; $ writer -> setDescription ( $ this -> getDescription ( ) ) ; if ( $ this -> getIconFileID ( ) ) { $ f = \ File :: getByID ( $ this -> getIconFileID ( ) ) ; if ( is_object ( $ f ) ) { $ data = [ 'uri' => $ f -> getURL ( ) , 'title' => $ f -> getTitle ( ) , 'link' => ( string ) $ link , ] ; $ writer -> setImage ( $ data ) ; } } $ writer -> setLink ( ( string ) $ link ) ; foreach ( $ results as $ p ) { $ entry = $ writer -> createEntry ( ) ; $ entry -> setTitle ( $ p -> getCollectionName ( ) ) ; $ entry -> setDateCreated ( strtotime ( $ p -> getCollectionDatePublic ( ) ) ) ; $ content = $ this -> getPageFeedContent ( $ p ) ; if ( ! $ content ) { $ content = t ( 'No Content.' ) ; } $ entry -> setDescription ( $ content ) ; $ entry -> setLink ( ( string ) $ p -> getCollectionLink ( true ) ) ; $ writer -> addEntry ( $ entry ) ; } $ ev = new FeedEvent ( ) ; if ( isset ( $ parent ) ) { $ ev -> setPageObject ( $ parent ) ; } $ ev -> setFeedObject ( $ this ) ; $ ev -> setWriterObject ( $ writer ) ; $ ev -> setRequest ( $ request ) ; $ ev = \ Events :: dispatch ( 'on_page_feed_output' , $ ev ) ; $ writer = $ ev -> getWriterObject ( ) ; return $ writer -> export ( 'rss' ) ; } } | Get the feed output in RSS form given a Request object . |
10,237 | public function cancel ( Progress $ wp ) { $ ui = UserInfo :: getByID ( $ this -> getRequestedUserID ( ) ) ; $ wpr = parent :: cancel ( $ wp ) ; $ wpr -> message = t ( "User deletion request has been cancelled." ) ; return $ wpr ; } | After canceling delete request do nothing |
10,238 | protected function initializeLegacyURLDefinitions ( ) { if ( ! defined ( 'BASE_URL' ) ) { $ resolver = $ this -> getUrlResolver ( ) ; try { $ url = rtrim ( ( string ) $ resolver -> resolve ( [ ] ) , '/' ) ; define ( 'BASE_URL' , $ url ) ; } catch ( Exception $ x ) { return Response :: create ( $ x -> getMessage ( ) , 500 ) ; } } } | Define the base url if not defined This will define BASE_URL to whatever is resolved from the resolver . |
10,239 | protected function setSystemLocale ( ) { $ u = new User ( ) ; $ lan = $ u -> getUserLanguageToDisplay ( ) ; $ loc = Localization :: getInstance ( ) ; $ loc -> setContextLocale ( Localization :: CONTEXT_UI , $ lan ) ; } | Initialize localization . |
10,240 | protected function registerLegacyConfigValues ( ) { $ config = $ this -> getConfig ( ) ; $ name = $ this -> getSiteService ( ) -> getSite ( ) -> getSiteName ( ) ; $ config -> set ( 'concrete.site' , $ name ) ; } | Set legacy config values This sets concrete . site to the current site s sitename . |
10,241 | protected function handleUpdates ( ) { $ config = $ this -> app -> make ( 'config' ) ; if ( ! $ config -> get ( 'concrete.maintenance_mode' ) ) { try { $ this -> app -> handleAutomaticUpdates ( ) ; } catch ( MutexBusyException $ x ) { if ( $ x -> getMutexKey ( ) !== Update :: MUTEX_KEY ) { throw $ x ; } $ config -> set ( 'concrete.maintenance_mode' , true ) ; } catch ( MigrationIncompleteException $ x ) { $ request = Request :: getInstance ( ) ; $ requestUri = $ request -> getUri ( ) ; $ rf = $ this -> app -> make ( ResponseFactoryInterface :: class ) ; return $ rf -> redirect ( $ requestUri , Response :: HTTP_FOUND ) ; } } } | Update automatically . |
10,242 | protected function trySteps ( array $ steps ) { foreach ( $ steps as $ step ) { if ( $ result = $ this -> $ step ( ) ) { return $ result ; } } return null ; } | Try a list of steps . If a response is returned halt progression and return the response ; . |
10,243 | public function getPermissionAssignmentObject ( ) { $ targ = Core :: make ( '\Concrete\Core\Permission\Assignment\ConversationAssignment' ) ; if ( is_object ( $ this -> permissionObject ) ) { $ targ -> setPermissionObject ( $ this -> permissionObject ) ; } $ targ -> setPermissionKeyObject ( $ this ) ; return $ targ ; } | We need this because we don t always have a permission object |
10,244 | public static function getMySets ( $ user = false ) { $ app = Facade :: getFacadeApplication ( ) ; if ( $ user === false ) { $ user = $ app -> make ( User :: class ) ; } $ database = $ app -> make ( 'database' ) -> connection ( ) ; $ fileSets = array ( ) ; $ queryBuilder = $ database -> createQueryBuilder ( ) ; $ results = $ queryBuilder -> select ( '*' ) -> from ( 'FileSets' ) -> where ( $ queryBuilder -> expr ( ) -> eq ( 'fsType' , self :: TYPE_PUBLIC ) ) -> orWhere ( $ queryBuilder -> expr ( ) -> andX ( $ queryBuilder -> expr ( ) -> in ( 'fsType' , [ self :: TYPE_PRIVATE , self :: TYPE_STARRED , self :: TYPE_PUBLIC ] ) , $ queryBuilder -> expr ( ) -> eq ( 'uID' , $ user -> getUserID ( ) ) ) ) -> orderBy ( 'fsName' , 'ASC' ) -> execute ( ) ; while ( $ row = $ results -> fetch ( ) ) { $ fileSet = new static ( ) ; $ fileSet = array_to_object ( $ fileSet , $ row ) ; $ fileSets [ ] = $ fileSet ; } return $ fileSets ; } | Returns all sets currently available to the User |
10,245 | public static function createAndGetSet ( $ fs_name , $ fs_type , $ fs_uid = false ) { if ( $ fs_uid === false ) { $ u = new User ( ) ; $ fs_uid = $ u -> uID ; } $ db = Database :: connection ( ) ; $ criteria = array ( $ fs_name , $ fs_type , $ fs_uid ) ; $ fsID = $ db -> fetchColumn ( 'SELECT fsID FROM FileSets WHERE fsName=? AND fsType=? AND uID=?' , $ criteria ) ; if ( $ fsID > 0 ) { return static :: getByID ( $ fsID ) ; } else { $ fs = static :: create ( $ fs_name , 0 , $ fs_uid , $ fs_type ) ; return $ fs ; } } | Creats a new fileset if set doesn t exists . |
10,246 | public static function getByID ( $ fsID ) { $ db = Database :: connection ( ) ; $ row = $ db -> fetchAssoc ( 'SELECT * FROM FileSets WHERE fsID = ?' , array ( $ fsID ) ) ; if ( is_array ( $ row ) ) { $ fs = new static ( ) ; $ fs = array_to_object ( $ fs , $ row ) ; if ( $ row [ 'fsType' ] == static :: TYPE_SAVED_SEARCH ) { $ row2 = $ db -> GetRow ( 'SELECT fsSearchRequest, fsResultColumns FROM FileSetSavedSearches WHERE fsID = ?' , array ( $ fsID ) ) ; $ fs -> fsSearchRequest = @ unserialize ( $ row2 [ 'fsSearchRequest' ] ) ; $ fs -> fsResultColumns = @ unserialize ( $ row2 [ 'fsResultColumns' ] ) ; } return $ fs ; } } | Get a file set object by a file set s id . |
10,247 | public static function create ( $ setName , $ fsOverrideGlobalPermissions = 0 , $ u = false , $ type = self :: TYPE_PUBLIC ) { if ( is_object ( $ u ) && $ u -> isRegistered ( ) ) { $ uID = $ u -> getUserID ( ) ; } else { if ( $ u ) { $ uID = $ u ; } else { $ uID = 0 ; } } $ db = Database :: connection ( ) ; $ db -> insert ( "FileSets" , array ( 'fsType' => $ type , 'uID' => $ uID , 'fsName' => $ setName , ) ) ; $ fsID = $ db -> lastInsertId ( ) ; $ fs = static :: getByID ( $ fsID ) ; $ fe = new \ Concrete \ Core \ File \ Event \ FileSet ( $ fs ) ; Events :: dispatch ( 'on_file_set_add' , $ fe ) ; return $ fs ; } | Adds a File set . |
10,248 | public static function getFilesBySetID ( $ fsID ) { if ( intval ( $ fsID ) > 0 ) { $ fileset = self :: getByID ( $ fsID ) ; if ( $ fileset instanceof \ Concrete \ Core \ File \ Set \ Set ) { return $ fileset -> getFiles ( ) ; } } } | Static method to return an array of File objects by the set id . |
10,249 | public static function getFilesBySetName ( $ fsName , $ uID = false ) { if ( ! empty ( $ fsName ) ) { $ fileset = self :: getByName ( $ fsName , $ uID ) ; if ( $ fileset instanceof \ Concrete \ Core \ File \ Set \ Set ) { return $ fileset -> getFiles ( ) ; } } } | Static method to return an array of File objects by the set name . |
10,250 | public static function getByName ( $ fsName , $ uID = false ) { $ db = Database :: connection ( ) ; if ( $ uID !== false ) { $ row = $ db -> fetchAssoc ( 'SELECT * FROM FileSets WHERE fsName = ? AND uID = ?' , array ( $ fsName , $ uID ) ) ; } else { $ row = $ db -> fetchAssoc ( 'SELECT * FROM FileSets WHERE fsName = ?' , array ( $ fsName ) ) ; } if ( is_array ( $ row ) && count ( $ row ) ) { $ fs = new static ( ) ; $ fs = array_to_object ( $ fs , $ row ) ; return $ fs ; } } | Get a file set object by a file name . |
10,251 | public function getFiles ( ) { if ( ! $ this -> fileSetFiles ) { $ this -> populateFiles ( ) ; } $ files = array ( ) ; foreach ( $ this -> fileSetFiles as $ file ) { $ files [ ] = ConcreteFile :: getByID ( $ file -> fID ) ; } return $ files ; } | Returns an array of File objects from the current set . |
10,252 | public function update ( $ setName ) { $ db = Database :: connection ( ) ; $ db -> update ( 'FileSets' , array ( 'fsName' => $ setName ) , array ( 'fsID' => $ this -> fsID ) ) ; return static :: getByID ( $ this -> fsID ) ; } | Updates a file set . |
10,253 | public function addFileToSet ( $ f_id ) { $ app = Application :: getFacadeApplication ( ) ; if ( is_object ( $ f_id ) ) { $ f = $ f_id ; if ( $ f instanceof FileEntity ) { $ file = $ f ; $ fileVersion = $ file -> getApprovedVersion ( ) ; } else { $ fileVersion = $ f ; $ file = $ fileVersion -> getFile ( ) ; } $ f_id = ( int ) $ file -> getFileID ( ) ; } else { $ f_id = ( int ) $ f_id ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ file = $ em -> find ( FileEntity :: class , $ f_id ) ; $ fileVersion = $ file -> getApprovedVersion ( ) ; } if ( $ file === null ) { $ result = null ; } else { $ file_set_file = File :: createAndGetFile ( $ f_id , $ this -> fsID ) ; $ fe = new \ Concrete \ Core \ File \ Event \ FileSetFile ( $ file_set_file ) ; $ director = $ app -> make ( EventDispatcherInterface :: class ) ; $ director -> dispatch ( 'on_file_added_to_set' , $ fe ) ; if ( $ fileVersion !== null && $ this -> shouldRefreshFileThumbnails ( 'add' ) ) { $ fileVersion -> refreshThumbnails ( false ) ; } $ result = $ file_set_file ; } return $ result ; } | Adds the file to the set . |
10,254 | protected function shouldRefreshFileThumbnails ( $ fileOperation ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ qb = $ em -> createQueryBuilder ( ) ; $ qb -> select ( 'ft.ftTypeID' ) -> from ( ThumbnailType :: class , 'ft' ) -> innerJoin ( 'ft.ftAssociatedFileSets' , 'ftfs' ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'ftfs.ftfsFileSetID' , ':fsID' ) ) -> setParameter ( 'fsID' , $ this -> getFileSetID ( ) ) -> andWhere ( $ qb -> expr ( ) -> eq ( 'ft.ftLimitedToFileSets' , ':limitedTo' ) ) -> setParameter ( 'limitedTo' , $ fileOperation === 'add' ) -> setMaxResults ( 1 ) ; $ query = $ qb -> getQuery ( ) ; return $ query -> getOneOrNullResult ( $ query :: HYDRATE_SINGLE_SCALAR ) !== null ; } | Check if we should build the thumbnails for files added or removed to this file set should . |
10,255 | public static function authenticateRequest ( $ auth ) { $ val = \ Core :: make ( 'config/database' ) -> get ( 'concrete.security.token.jobs' ) . ':' . DIRNAME_JOBS ; if ( md5 ( $ val ) == $ auth ) { return true ; } } | or from the dashboard |
10,256 | public static function getAvailableList ( $ includeConcreteDirJobs = 1 ) { $ jobObjs = array ( ) ; $ existingJobHandles = array ( ) ; $ existingJobs = static :: getList ( ) ; foreach ( $ existingJobs as $ j ) { $ existingJobHandles [ ] = $ j -> getJobHandle ( ) ; } if ( ! $ includeConcreteDirJobs ) { $ jobClassLocations = array ( DIR_FILES_JOBS ) ; } else { $ jobClassLocations = static :: jobClassLocations ( ) ; } foreach ( $ jobClassLocations as $ jobClassLocation ) { if ( is_dir ( $ jobClassLocation ) ) { if ( $ dh = opendir ( $ jobClassLocation ) ) { while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( substr ( $ file , strlen ( $ file ) - 4 ) != '.php' ) { continue ; } $ alreadyInstalled = 0 ; foreach ( $ existingJobHandles as $ existingJobHandle ) { if ( substr ( $ file , 0 , strlen ( $ file ) - 4 ) == $ existingJobHandle ) { $ alreadyInstalled = 1 ; break ; } } if ( $ alreadyInstalled ) { continue ; } $ jHandle = substr ( $ file , 0 , strlen ( $ file ) - 4 ) ; $ className = static :: getClassName ( $ jHandle ) ; $ jobObjs [ $ jHandle ] = Core :: make ( $ className ) ; $ jobObjs [ $ jHandle ] -> jHandle = $ jHandle ; } closedir ( $ dh ) ; } } } return $ jobObjs ; } | Scan job directories for job classes |
10,257 | public function enableAreaLayoutCustomColumnWidths ( ) { $ db = Loader :: db ( ) ; $ db -> Execute ( 'update AreaLayouts set arLayoutIsCustom = ? where arLayoutID = ?' , array ( 1 , $ this -> arLayoutID ) ) ; $ this -> arLayoutIsCustom = true ; } | Enable custom column widths on layouts . |
10,258 | public function disableAreaLayoutCustomColumnWidths ( ) { $ db = Loader :: db ( ) ; $ db -> Execute ( 'update AreaLayouts set arLayoutIsCustom = ? where arLayoutID = ?' , array ( 0 , $ this -> arLayoutID ) ) ; $ this -> arLayoutIsCustom = false ; } | Disable custom column widths on layouts . |
10,259 | public function functionAvailable ( $ functionName ) { $ result = false ; if ( is_string ( $ functionName ) ) { $ functionName = trim ( $ functionName ) ; if ( $ functionName !== '' ) { if ( function_exists ( $ functionName ) ) { $ disabledFunctions = $ this -> getDisabledFunctions ( ) ; if ( ! in_array ( strtolower ( $ functionName ) , $ disabledFunctions , true ) ) { $ result = true ; } } } } return $ result ; } | Check if a function exists and is not disabled . |
10,260 | public function hasAddTemplate ( ) { $ bv = new BlockView ( $ this ) ; $ path = $ bv -> getBlockPath ( FILENAME_BLOCK_ADD ) ; if ( file_exists ( $ path . '/' . FILENAME_BLOCK_ADD ) ) { return true ; } return false ; } | Determines if the block type has templates available . |
10,261 | public function getBlockTypeComposerTemplates ( ) { $ btHandle = $ this -> getBlockTypeHandle ( ) ; $ files = array ( ) ; $ fh = Loader :: helper ( 'file' ) ; $ dir = DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES_COMPOSER ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } foreach ( PackageList :: get ( ) -> getPackages ( ) as $ pkg ) { $ dir = ( is_dir ( DIR_PACKAGES . '/' . $ pkg -> getPackageHandle ( ) ) ? DIR_PACKAGES : DIR_PACKAGES_CORE ) . '/' . $ pkg -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ btHandle . '/' . DIRNAME_BLOCK_TEMPLATES_COMPOSER ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } } $ dir = DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES_COMPOSER ; if ( file_exists ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } $ templates = array ( ) ; foreach ( array_unique ( $ files ) as $ file ) { $ templates [ ] = new TemplateFile ( $ this , $ file ) ; } return TemplateFile :: sortTemplateFileList ( $ templates ) ; } | gets the available composer templates used for editing instances of the BlockType while in the composer ui in the dashboard . |
10,262 | public function getBlockTypeClass ( ) { return \ Concrete \ Core \ Block \ BlockType \ BlockType :: getBlockTypeMappedClass ( $ this -> getBlockTypeHandle ( ) , $ this -> getPackageHandle ( ) ) ; } | Returns the class for the current block type . |
10,263 | public function getBlockTypeSets ( ) { $ db = Loader :: db ( ) ; $ list = array ( ) ; $ r = $ db -> Execute ( 'select btsID from BlockTypeSetBlockTypes where btID = ? order by displayOrder asc' , array ( $ this -> getBlockTypeID ( ) ) ) ; while ( $ row = $ r -> FetchRow ( ) ) { $ list [ ] = BlockTypeSet :: getByID ( $ row [ 'btsID' ] ) ; } $ r -> Close ( ) ; return $ list ; } | Returns an array of all BlockTypeSet objects that this block is in . |
10,264 | public function getCount ( $ ignoreUnapprovedVersions = false ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ now = $ app -> make ( 'date' ) -> getOverridableNow ( ) ; if ( $ ignoreUnapprovedVersions ) { $ count = $ db -> GetOne ( <<<'EOT'SELECT count(btID)FROM Blocks b INNER JOIN CollectionVersionBlocks cvb ON b.bID=cvb.bID INNER JOIN CollectionVersions cv ON cvb.cID=cv.cID AND cvb.cvID=cv.cvID AND cv.cvIsApproved=1 AND (cv.cvPublishDate IS NULL OR cv.cvPublishDate <= ?) AND (cv.cvPublishEndDate IS NULL OR cv.cvPublishEndDate >= ?)WHERE b.btID = ?EOT , [ $ now , $ now , $ this -> btID ] ) ; } else { $ count = $ db -> GetOne ( "SELECT count(btID) FROM Blocks WHERE btID = ?" , array ( $ this -> btID ) ) ; } return $ count ; } | Returns the number of unique instances of this block throughout the entire site note - this count could include blocks in areas that are no longer rendered by the theme . |
10,265 | public function getBlockTypeCustomTemplates ( Block $ b ) { $ btHandle = $ this -> getBlockTypeHandle ( ) ; $ fh = Loader :: helper ( 'file' ) ; $ files = array ( ) ; $ dir = DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } $ c = $ b -> getBlockCollectionObject ( ) ; if ( is_object ( $ c ) ) { $ theme = $ c -> getCollectionThemeObject ( ) ; if ( is_object ( $ theme ) ) { $ dir = DIR_FILES_THEMES . "/" . $ theme -> getThemeHandle ( ) . "/" . DIRNAME_BLOCKS . "/" . $ btHandle . "/" . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } if ( $ theme -> getPackageHandle ( ) ) { $ dir = ( is_dir ( DIR_PACKAGES . '/' . $ theme -> getPackageHandle ( ) ) ? DIR_PACKAGES : DIR_PACKAGES_CORE ) . '/' . $ theme -> getPackageHandle ( ) . '/' . DIRNAME_THEMES . '/' . $ theme -> getThemeHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ btHandle . '/' . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } } $ dir = DIR_FILES_THEMES_CORE . "/" . $ theme -> getThemeHandle ( ) . "/" . DIRNAME_BLOCKS . "/" . $ btHandle . "/" . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } } } foreach ( PackageList :: get ( ) -> getPackages ( ) as $ pkg ) { $ dir = ( is_dir ( DIR_PACKAGES . '/' . $ pkg -> getPackageHandle ( ) ) ? DIR_PACKAGES : DIR_PACKAGES_CORE ) . '/' . $ pkg -> getPackageHandle ( ) . '/' . DIRNAME_BLOCKS . '/' . $ btHandle . '/' . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } } $ dir = DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES ; if ( is_dir ( $ dir ) ) { $ files = array_merge ( $ files , $ fh -> getDirectoryContents ( $ dir ) ) ; } $ templates = array ( ) ; foreach ( array_unique ( $ files ) as $ file ) { $ templates [ ] = new TemplateFile ( $ this , $ file ) ; } return TemplateFile :: sortTemplateFileList ( $ templates ) ; } | Gets the custom templates available for the current BlockType . |
10,266 | public function refresh ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ pkgHandle = false ; if ( $ this -> pkgID > 0 ) { $ pkgHandle = $ this -> getPackageHandle ( ) ; } $ class = \ Concrete \ Core \ Block \ BlockType \ BlockType :: getBlockTypeMappedClass ( $ this -> btHandle , $ pkgHandle ) ; $ bta = $ app -> build ( $ class ) ; $ this -> loadFromController ( $ bta ) ; $ em = \ ORM :: entityManager ( ) ; $ em -> persist ( $ this ) ; $ em -> flush ( ) ; $ env = Environment :: get ( ) ; $ r = $ env -> getRecord ( DIRNAME_BLOCKS . '/' . $ this -> btHandle . '/' . FILENAME_BLOCK_DB , $ this -> getPackageHandle ( ) ) ; if ( $ r -> exists ( ) ) { $ parser = Schema :: getSchemaParser ( simplexml_load_file ( $ r -> file ) ) ; $ parser -> setIgnoreExistingTables ( false ) ; $ toSchema = $ parser -> parse ( $ db ) ; $ fromSchema = $ db -> getSchemaManager ( ) -> createSchema ( ) ; $ comparator = new \ Doctrine \ DBAL \ Schema \ Comparator ( ) ; $ schemaDiff = $ comparator -> compare ( $ fromSchema , $ toSchema ) ; $ saveQueries = $ schemaDiff -> toSaveSql ( $ db -> getDatabasePlatform ( ) ) ; foreach ( $ saveQueries as $ query ) { $ db -> query ( $ query ) ; } } } | refreshes the BlockType s database schema throws an Exception if error . |
10,267 | public function delete ( ) { $ db = Loader :: db ( ) ; $ r = $ db -> Execute ( 'select cID, cvID, b.bID, arHandle from CollectionVersionBlocks cvb inner join Blocks b on b.bID = cvb.bID where btID = ? union select cID, cvID, cvb.bID, arHandle from CollectionVersionBlocks cvb inner join btCoreScrapbookDisplay btCSD on cvb.bID = btCSD.bID inner join Blocks b on b.bID = btCSD.bOriginalID where btID = ?' , array ( $ this -> getBlockTypeID ( ) , $ this -> getBlockTypeID ( ) ) ) ; while ( $ row = $ r -> FetchRow ( ) ) { $ nc = Page :: getByID ( $ row [ 'cID' ] , $ row [ 'cvID' ] ) ; if ( ! is_object ( $ nc ) || $ nc -> isError ( ) ) { continue ; } $ b = Block :: getByID ( $ row [ 'bID' ] , $ nc , $ row [ 'arHandle' ] ) ; if ( is_object ( $ b ) ) { $ b -> deleteBlock ( ) ; } } $ em = \ ORM :: entityManager ( ) ; $ em -> remove ( $ this ) ; $ em -> flush ( ) ; BlockTypeList :: resetBlockTypeDisplayOrder ( 'btDisplayOrder' ) ; } | Removes the block type . Also removes instances of content . |
10,268 | public function add ( $ data , $ c = false , $ a = false ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ u = new User ( ) ; if ( isset ( $ data [ 'uID' ] ) ) { $ uID = $ data [ 'uID' ] ; } else { $ uID = $ u -> getUserID ( ) ; } $ bName = '' ; if ( isset ( $ data [ 'bName' ] ) ) { $ bName = $ data [ 'bName' ] ; } $ btID = $ this -> btID ; $ dh = $ app -> make ( 'helper/date' ) ; $ bDate = $ dh -> getOverridableNow ( ) ; $ bIsActive = ( isset ( $ this -> btActiveWhenAdded ) && $ this -> btActiveWhenAdded == 1 ) ? 1 : 0 ; $ v = array ( $ bName , $ bDate , $ bDate , $ bIsActive , $ btID , $ uID ) ; $ q = "insert into Blocks (bName, bDateAdded, bDateModified, bIsActive, btID, uID) values (?, ?, ?, ?, ?, ?)" ; $ res = $ db -> executeQuery ( $ q , $ v ) ; if ( $ res ) { $ bIDnew = $ db -> lastInsertId ( ) ; $ nb = Block :: getByID ( $ bIDnew ) ; if ( is_object ( $ c ) ) { $ nb -> setBlockCollectionObject ( $ c ) ; } if ( is_object ( $ a ) ) { $ nb -> setBlockAreaObject ( $ a ) ; } $ class = $ this -> getBlockTypeClass ( ) ; $ bc = $ app -> build ( $ class , [ $ nb ] ) ; $ bc -> save ( $ data ) ; return Block :: getByID ( $ bIDnew ) ; } } | Adds a block to the system without adding it to a collection . Passes page and area data along if it is available however . |
10,269 | protected function addOutputAssetAt ( $ item , $ position ) { if ( ! isset ( $ this -> outputAssets [ $ position ] ) ) { $ this -> outputAssets [ $ position ] = [ $ item ] ; } elseif ( ! in_array ( $ item , $ this -> outputAssets [ $ position ] ) ) { $ this -> outputAssets [ $ position ] [ ] = $ item ; } } | Add an asset at a specific position . |
10,270 | public function getAssetsToOutput ( ) { $ assets = $ this -> getRequiredAssetsToOutput ( ) ; foreach ( $ assets as $ asset ) { $ this -> addOutputAsset ( $ asset ) ; } $ outputAssetsPre = array ( ) ; $ outputAssets = array ( ) ; foreach ( $ this -> outputAssets as $ position => $ assets ) { $ outputAssetsPre [ $ position ] = array ( ) ; foreach ( $ assets as $ key => $ asset ) { $ o = new \ stdClass ( ) ; $ o -> key = $ key ; $ o -> asset = $ asset ; $ outputAssetsPre [ $ position ] [ ] = $ o ; } } foreach ( $ outputAssetsPre as $ position => $ assets ) { usort ( $ assets , function ( $ o1 , $ o2 ) { $ a1 = $ o1 -> asset ; $ a2 = $ o2 -> asset ; $ k1 = $ o1 -> key ; $ k2 = $ o2 -> key ; if ( $ k1 > $ k2 ) { return 1 ; } elseif ( $ k1 < $ k2 ) { return - 1 ; } else { return 0 ; } } ) ; foreach ( $ assets as $ object ) { $ outputAssets [ $ position ] [ ] = $ object -> asset ; } } return $ outputAssets ; } | Get a list of assets that need to be outputted . |
10,271 | public function markAssetAsIncluded ( $ assetType , $ assetHandle = false ) { $ list = AssetList :: getInstance ( ) ; if ( $ assetType && $ assetHandle ) { $ asset = $ list -> getAsset ( $ assetType , $ assetHandle ) ; } else { $ assetGroup = $ list -> getAssetGroup ( $ assetType ) ; } if ( isset ( $ assetGroup ) ) { $ this -> providedAssetGroup -> addGroup ( $ assetGroup ) ; } elseif ( isset ( $ asset ) ) { $ ap = new AssetPointer ( $ asset -> getAssetType ( ) , $ asset -> getAssetHandle ( ) ) ; $ this -> providedAssetGroup -> add ( $ ap ) ; } else { $ ap = new AssetPointer ( $ assetType , $ assetHandle ) ; $ this -> providedAssetGroupUnmatched [ ] = $ ap ; } } | Notes in the current request that a particular asset has already been provided . |
10,272 | public function getRequiredAssetsToOutput ( ) { $ required = $ this -> requiredAssetGroup -> getAssetPointers ( ) ; $ assetPointers = array_filter ( $ required , array ( '\Concrete\Core\Http\ResponseAssetGroup' , 'filterProvidedAssets' ) ) ; $ assets = array ( ) ; $ al = AssetList :: getInstance ( ) ; foreach ( $ assetPointers as $ ap ) { $ asset = $ ap -> getAsset ( ) ; if ( $ asset instanceof Asset ) { $ assets [ ] = $ asset ; } } $ assets = array_merge ( $ this -> requiredAssetGroup -> getAssets ( ) , $ assets ) ; return $ assets ; } | Returns only assets that are required but that aren t also in the providedAssetGroup . |
10,273 | public function setAttribute ( $ ak , $ value ) { $ orm = \ Database :: connection ( ) -> getEntityManager ( ) ; $ this -> clearAttribute ( $ ak ) ; $ attributeValue = $ this -> getAttributeValueObject ( $ ak , true ) ; $ orm -> persist ( $ attributeValue ) ; $ orm -> flush ( ) ; $ genericValue = new Value ( ) ; $ genericValue -> setAttributeKey ( $ attributeValue -> getAttributeKey ( ) ) ; $ orm -> persist ( $ genericValue ) ; $ orm -> flush ( ) ; $ attributeValue -> setGenericValue ( $ genericValue ) ; $ orm -> persist ( $ attributeValue ) ; $ orm -> flush ( ) ; $ controller = $ attributeValue -> getAttributeKey ( ) -> getController ( ) ; $ controller -> setAttributeValue ( $ attributeValue ) ; if ( ! ( $ value instanceof AttributeValue \ AbstractValue ) ) { if ( $ value instanceof EmptyRequestAttributeValue ) { $ controller -> saveForm ( $ controller -> post ( ) ) ; unset ( $ value ) ; } else { $ value = $ controller -> createAttributeValue ( $ value ) ; } } if ( $ value ) { $ value -> setGenericValue ( $ genericValue ) ; $ orm -> persist ( $ value ) ; $ orm -> flush ( ) ; } $ category = $ this -> getObjectAttributeCategory ( ) ; $ indexer = $ category -> getSearchIndexer ( ) ; if ( $ indexer ) { $ indexer -> indexEntry ( $ category , $ attributeValue , $ this ) ; } return $ attributeValue ; } | Sets the attribute of a user info object to the specified value and saves it in the database . |
10,274 | private function doGetAction ( $ repository , $ item ) { $ this -> output -> writeln ( $ this -> serialize ( $ repository -> get ( $ item ) ) ) ; } | Complete a requested get action |
10,275 | private function doSetAction ( Repository $ repository , $ item ) { if ( ! $ this -> hasArgument ( 'value' ) ) { $ this -> output -> error ( 'A value must be provided when using the "set" action.' ) ; } $ value = $ this -> argument ( 'value' ) ; $ repository -> save ( $ item , $ this -> unserialize ( $ value ) ) ; } | Complete a requested set action |
10,276 | public function reindexAll ( $ fullReindex = false ) { Cache :: disableAll ( ) ; $ indexStack = Application :: getFacadeApplication ( ) -> make ( IndexManagerInterface :: class ) ; $ db = Loader :: db ( ) ; if ( $ fullReindex ) { $ db -> Execute ( "truncate table PageSearchIndex" ) ; } $ pl = new PageList ( ) ; $ pl -> ignoreAliases ( ) ; $ pl -> ignorePermissions ( ) ; $ pl -> sortByCollectionIDAscending ( ) ; $ pl -> filter ( false , '(c.cDateModified > psi.cDateLastIndexed or UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(psi.cDateLastIndexed) > ' . $ this -> searchReindexTimeout . ' or psi.cID is null or psi.cDateLastIndexed is null)' ) ; $ pl -> filter ( false , '(ak_exclude_search_index is null or ak_exclude_search_index = 0)' ) ; $ pages = $ pl -> get ( $ this -> searchBatchSize ) ; $ num = 0 ; foreach ( $ pages as $ c ) { $ indexStack -> index ( Page :: class , $ c ) ; } $ pnum = Collection :: reindexPendingPages ( ) ; $ num = $ num + $ pnum ; Cache :: enableAll ( ) ; $ result = new stdClass ( ) ; $ result -> count = $ num ; return $ result ; } | Reindexes the search engine . |
10,277 | public function profileLoader ( ) { $ idTokenString = null ; $ token = $ this -> service -> getStorage ( ) -> retrieveAccessToken ( $ this -> service -> service ( ) ) ; if ( $ token instanceof StdOAuth2Token ) { $ idTokenString = array_get ( $ token -> getExtraParams ( ) , 'id_token' ) ; } if ( ! $ idTokenString ) { return json_decode ( $ this -> service -> request ( self :: USER_PATH ) , true ) [ 'data' ] ; } $ decoder = new Parser ( ) ; $ idToken = $ decoder -> parse ( $ idTokenString ) ; return [ 'claims' => $ idToken -> getClaims ( ) ] ; } | Load the external concrete5 profile either from id_token or through the API |
10,278 | public function getIterator ( ) { $ db = $ this -> manager -> connection ( ) ; if ( ! $ this -> lockColumnsExist ( $ db ) ) { return ; } $ qb = $ db -> createQueryBuilder ( ) ; $ nextQuery = $ this -> getNextQuery ( $ qb ) ; $ try = 10 ; while ( $ next = $ this -> next ( $ nextQuery ) ) { unset ( $ next [ $ this -> lockColumn ] ) ; unset ( $ next [ $ this -> lockTimeoutColumn ] ) ; if ( ! $ this -> reserveNext ( $ next , $ db ) ) { if ( $ try -- ) { break ; } continue ; } yield $ next ; } } | Get an iterator that outputs locked thumbnail rows |
10,279 | private function next ( QueryBuilder $ nextQuery ) { $ now = new \ DateTime ( 'now' ) ; $ qb = clone $ nextQuery ; $ qb -> setParameter ( ':currentTime' , $ now -> format ( 'Y-m-d H:i:s' ) ) ; return $ qb -> execute ( ) -> fetch ( ) ; } | Get the next matching thumbnail path row |
10,280 | private function reserveNext ( array $ next , Connection $ db ) { $ lockID = $ this -> getLockID ( ) ; try { $ date = new \ DateTime ( 'now' ) ; $ date -> setTimestamp ( $ date -> getTimestamp ( ) + $ this -> timeout ) ; if ( ! $ db -> update ( $ this -> table , [ $ this -> lockColumn => $ lockID , $ this -> lockTimeoutColumn => $ date -> format ( 'Y-m-d H:i:s' ) ] , $ next ) ) { return false ; } } catch ( \ Exception $ e ) { return false ; } return $ this -> matchingLock ( $ lockID , $ next , $ db ) ; } | Mark the next item as reserved |
10,281 | private function matchingLock ( $ lockID , array $ next , Connection $ db ) { $ qb = $ db -> createQueryBuilder ( ) ; $ select = $ qb -> select ( '*' ) -> from ( $ this -> table , 't' ) -> where ( $ qb -> expr ( ) -> eq ( $ this -> lockColumn , $ qb -> expr ( ) -> literal ( $ lockID ) ) ) ; $ predicates = array_map ( function ( $ value , $ key ) use ( $ qb ) { return $ qb -> expr ( ) -> eq ( $ key , $ qb -> expr ( ) -> literal ( $ value ) ) ; } , $ next , array_keys ( $ next ) ) ; call_user_func_array ( [ $ select , 'andWhere' ] , $ predicates ) ; if ( $ result = $ select -> setMaxResults ( 1 ) -> execute ( ) -> fetch ( ) ) { return $ result ; } return false ; } | Find the row matching the passed criteria This is used to verify that we ve successfully locked a row in the database . |
10,282 | private function lockColumnsExist ( Connection $ db ) { $ schema = $ db -> getSchemaManager ( ) -> listTableColumns ( $ this -> table ) ; return isset ( $ schema [ 'lockid' ] ) ; } | Check if the required lock columns have been added to the database . This prevents people upgrading from seeing 500 errors in their logs . |
10,283 | private function getLockID ( ) { if ( $ this -> lockID ) { return $ this -> lockID ; } $ id = uniqid ( 'thumbnail_thread_' , true ) ; $ this -> lockID = $ id ; return $ id ; } | Get and memoize the current lock ID |
10,284 | public static function getByHandle ( $ btHandle ) { $ result = null ; $ btHandle = ( string ) $ btHandle ; if ( $ btHandle !== '' ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ repo = $ em -> getRepository ( BlockTypeEntity :: class ) ; $ result = $ repo -> findOneBy ( [ 'btHandle' => $ btHandle ] ) ; if ( $ result !== null ) { $ result -> loadController ( ) ; } } return $ result ; } | Get a BlockType given its handle . |
10,285 | public static function getByID ( $ btID ) { $ result = null ; $ btID = ( int ) $ btID ; if ( $ btID !== 0 ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ result = $ em -> find ( BlockTypeEntity :: class , $ btID ) ; if ( $ result !== null ) { $ result -> loadController ( ) ; } } return $ result ; } | Get a BlockType given its ID . |
10,286 | public static function installBlockType ( $ btHandle , $ pkg = false ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ pkgHandle = ( string ) ( is_object ( $ pkg ) ? $ pkg -> getPackageHandle ( ) : $ pkg ) ; $ class = static :: getBlockTypeMappedClass ( $ btHandle , $ pkgHandle ) ; $ bta = $ app -> build ( $ class ) ; $ locator = $ app -> make ( FileLocator :: class ) ; if ( $ pkgHandle !== '' ) { $ locator -> addLocation ( new FileLocator \ PackageLocation ( $ pkgHandle ) ) ; } $ path = dirname ( $ locator -> getRecord ( DIRNAME_BLOCKS . '/' . $ btHandle . '/' . FILENAME_BLOCK_DB ) -> getFile ( ) ) ; $ bta -> install ( $ path ) ; $ loc = $ app -> make ( Localization :: class ) ; $ loc -> pushActiveContext ( Localization :: CONTEXT_SYSTEM ) ; try { $ bt = new BlockTypeEntity ( ) ; $ bt -> loadFromController ( $ bta ) ; if ( is_object ( $ pkg ) ) { $ bt -> setPackageID ( $ pkg -> getPackageID ( ) ) ; } $ bt -> setBlockTypeHandle ( $ btHandle ) ; } finally { $ loc -> popActiveContext ( ) ; } $ em -> persist ( $ bt ) ; $ em -> flush ( ) ; if ( $ bta -> getBlockTypeDefaultSet ( ) ) { $ set = Set :: getByHandle ( $ bta -> getBlockTypeDefaultSet ( ) ) ; if ( $ set !== null ) { $ set -> addBlockType ( $ bt ) ; } } return $ bt ; } | Install a BlockType that is passed via a btHandle string . The core or override directories are parsed . |
10,287 | public static function getBlockTypeMappedClass ( $ btHandle , $ pkgHandle = false ) { $ app = Application :: getFacadeApplication ( ) ; $ txt = $ app -> make ( 'helper/text' ) ; $ pkgHandle = ( string ) $ pkgHandle ; $ locator = $ app -> make ( FileLocator :: class ) ; if ( $ pkgHandle !== '' ) { $ locator -> addLocation ( new FileLocator \ PackageLocation ( $ pkgHandle ) ) ; } $ r = $ locator -> getRecord ( DIRNAME_BLOCKS . '/' . $ btHandle . '/' . FILENAME_CONTROLLER ) ; $ overriddenPackageHandle = ( string ) $ r -> getPackageHandle ( ) ; if ( $ overriddenPackageHandle !== '' ) { $ pkgHandle = $ overriddenPackageHandle ; } $ prefix = $ r -> isOverride ( ) ? true : $ pkgHandle ; $ class = core_class ( 'Block\\' . $ txt -> camelcase ( $ btHandle ) . '\\Controller' , $ prefix ) ; return class_exists ( $ class ) ? $ class : null ; } | Return the class file that this BlockType uses . |
10,288 | public static function clearCache ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ sm = $ db -> getSchemaManager ( ) ; $ tableNames = array_map ( 'strtolower' , $ sm -> listTableNames ( ) ) ; if ( in_array ( 'config' , $ tableNames , true ) ) { $ platform = $ db -> getDatabasePlatform ( ) ; foreach ( $ sm -> listTableColumns ( 'Blocks' ) as $ tableColumn ) { if ( strcasecmp ( $ tableColumn -> getName ( ) , 'btCachedBlockRecord' ) === 0 ) { $ db -> query ( 'update Blocks set btCachedBlockRecord = null' ) ; break ; } } if ( in_array ( 'collectionversionblocksoutputcache' , $ tableNames , true ) ) { $ db -> exec ( $ platform -> getTruncateTableSQL ( 'CollectionVersionBlocksOutputCache' ) ) ; } } } | Clears output and record caches . |
10,289 | public function installMissingPackageTranslations ( Package $ package ) { $ wanted = Localization :: getAvailableInterfaceLanguages ( ) ; $ siteService = $ this -> app -> make ( SiteService :: class ) ; $ site = $ siteService -> getSite ( ) ; if ( $ site ) { foreach ( $ site -> getLocales ( ) as $ locale ) { $ wanted [ ] = $ locale -> getLocale ( ) ; } } $ wanted = array_unique ( $ wanted ) ; $ wanted = array_filter ( $ wanted , function ( $ localeID ) { return $ localeID !== Localization :: BASE_LOCALE ; } ) ; $ already = array_keys ( $ this -> localFactory -> getAvailablePackageStats ( $ package ) ) ; $ missing = array_diff ( $ wanted , $ already ) ; $ result = [ ] ; if ( count ( $ missing ) > 0 ) { $ available = $ this -> remoteProvider -> getAvailablePackageStats ( $ package -> getPackageHandle ( ) , $ package -> getPackageVersion ( ) ) ; $ toDownload = array_intersect ( $ missing , array_keys ( $ available ) ) ; foreach ( $ missing as $ missingID ) { if ( ! in_array ( $ missingID , $ toDownload , true ) ) { $ result [ $ missingID ] = false ; } else { try { $ this -> installPackageTranslations ( $ package , $ missingID ) ; $ result [ $ missingID ] = true ; } catch ( Exception $ x ) { $ result [ $ missingID ] = $ x ; } } } } return $ result ; } | Install missing package translation files . |
10,290 | protected function getDefaultSubscription ( ) { if ( ! $ this -> defaultSubscription ) { $ this -> defaultSubscription = $ this -> app -> make ( StandardSubscription :: class , [ self :: IDENTIFIER , t ( 'User Deactivated' ) ] ) ; } return $ this -> defaultSubscription ; } | Get the default subscription object . If one was not passed in at construct time create one now |
10,291 | public function getAvailableFilters ( ) { if ( ! $ this -> defaultFilter ) { $ this -> defaultFilter = $ this -> app -> make ( StandardFilter :: class , [ $ this , self :: IDENTIFIER , t ( 'User Deactivated' ) , 'userdeactivatednotification' ] ) ; } return [ $ this -> defaultFilter ] ; } | Get available notification filters |
10,292 | public static function addGlobal ( $ cPath , $ pkg = null ) { $ pathToFile = static :: getPathToNode ( $ cPath , $ pkg ) ; $ txt = Loader :: helper ( 'text' ) ; $ c = CorePage :: getByPath ( $ cPath ) ; if ( $ c -> isError ( ) && $ c -> getError ( ) == COLLECTION_NOT_FOUND ) { $ data = array ( ) ; $ data [ 'handle' ] = trim ( $ cPath , '/' ) ; $ data [ 'name' ] = $ txt -> unhandle ( $ data [ 'handle' ] ) ; $ data [ 'filename' ] = $ pathToFile ; $ data [ 'uID' ] = USER_SUPER_ID ; if ( $ pkg != null ) { $ data [ 'pkgID' ] = $ pkg -> getPackageID ( ) ; } $ c = Page :: addStatic ( $ data , null ) ; $ c -> moveToRoot ( ) ; return $ c ; } } | Adds a single page outside of any site trees . The global = true declaration in content importer XML must come at on the first URL segment so we don t have to be smart and check to see if the parents already eixst . |
10,293 | public static function getList ( ) { $ db = Loader :: db ( ) ; $ r = $ db -> query ( "select Pages.cID from Pages inner join Collections on Pages.cID = Collections.cID where cFilename is not null order by cDateModified desc" ) ; $ pages = array ( ) ; while ( $ row = $ r -> fetchRow ( ) ) { $ c = Page :: getByID ( $ row [ 'cID' ] ) ; $ pages [ ] = $ c ; } return $ pages ; } | returns all pages in the site that are single |
10,294 | public static function getAccessEntitiesForUser ( $ user ) { $ entities = [ ] ; if ( $ user -> isRegistered ( ) ) { $ ingids = [ ] ; $ app = Facade :: getFacadeApplication ( ) ; $ database = $ app -> make ( 'database' ) -> connection ( ) ; foreach ( $ user -> getUserGroups ( ) as $ key => $ val ) { $ ingids [ ] = $ key ; } $ instr = implode ( ',' , $ ingids ) ; $ peIDs = $ database -> fetchAll ( 'select distinct pae.peID from PermissionAccessEntities pae inner join PermissionAccessEntityTypes paet on pae.petID = paet.petID inner join PermissionAccessEntityGroups paeg on pae.peID = paeg.peID where petHandle = \'group_combination\' and paeg.gID in (' . $ instr . ')' ) ; foreach ( $ peIDs as $ peID ) { $ r = $ database -> fetchAssoc ( 'select count(gID) as peGroups, (select count(UserGroups.gID) from UserGroups where uID = ? and gID in (select gID from PermissionAccessEntityGroups where peID = ?)) as uGroups from PermissionAccessEntityGroups where peID = ?' , [ $ user -> getUserID ( ) , $ peID [ 'peID' ] , $ peID [ 'peID' ] ] ) ; if ( $ r [ 'peGroups' ] == $ r [ 'uGroups' ] && $ r [ 'peGroups' ] > 1 ) { $ entity = Entity :: getByID ( $ peID [ 'peID' ] ) ; if ( is_object ( $ entity ) ) { $ entities [ ] = $ entity ; } } } } return $ entities ; } | Returns all GroupCombination Access Entities for the provided user . |
10,295 | public static function getOrCreate ( $ groups ) { $ app = Facade :: getFacadeApplication ( ) ; $ database = $ app -> make ( 'database' ) -> connection ( ) ; $ petID = $ database -> fetchColumn ( 'select petID from PermissionAccessEntityTypes where petHandle = \'group_combination\'' ) ; $ query = $ database -> createQueryBuilder ( ) ; $ query -> select ( 'pae.peID' ) -> from ( 'PermissionAccessEntities' , 'pae' ) ; $ i = 1 ; $ query -> where ( 'petid = :entityTypeID' ) -> setParameter ( 'entityTypeID' , $ petID ) ; foreach ( $ groups as $ group ) { $ query -> leftJoin ( 'pae' , 'PermissionAccessEntityGroups' , 'paeg' . $ i , 'pae.peID = paeg' . $ i . '.peID' ) -> andWhere ( 'paeg' . $ i . '.gID = :group' . $ i ) -> setParameter ( 'group' . $ i , $ group -> getGroupID ( ) ) ; $ i ++ ; } $ peIDs = $ query -> execute ( ) -> fetchAll ( ) ; $ peID = 0 ; if ( ! empty ( $ peIDs ) ) { foreach ( $ peIDs as $ result ) { $ allGroups = $ database -> fetchColumn ( 'select count(gID) from PermissionAccessEntityGroups where peID = ' . $ result [ 'peID' ] ) ; if ( $ allGroups == count ( $ groups ) ) { $ peID = $ result [ 'peID' ] ; break ; } } } if ( empty ( $ peID ) ) { $ database -> insert ( 'PermissionAccessEntities' , [ 'petID' => $ petID ] ) ; $ peID = $ database -> lastInsertId ( ) ; $ app -> make ( 'config' ) -> save ( 'concrete.misc.access_entity_updated' , time ( ) ) ; foreach ( $ groups as $ group ) { $ database -> insert ( 'PermissionAccessEntityGroups' , [ 'peID' => $ peID , 'gID' => $ group -> getGroupID ( ) ] ) ; } } return self :: getByID ( $ peID ) ; } | Function used to get or create a GroupCombination Permission Access Entity . |
10,296 | public function getAccessEntityUsers ( PermissionAccess $ pa ) { $ userList = new UserList ( ) ; $ userList -> ignorePermissions ( ) ; foreach ( $ this -> groups as $ g ) { $ userList -> filterByGroupID ( $ g -> getGroupID ( ) ) ; } return $ userList -> getResults ( ) ; } | Get the users who have access to this GroupCombination . |
10,297 | public function load ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ database = $ app -> make ( 'database' ) -> connection ( ) ; $ gIDs = $ database -> fetchAll ( 'select gID from PermissionAccessEntityGroups where peID = ? order by gID asc' , [ $ this -> peID ] ) ; if ( $ gIDs && is_array ( $ gIDs ) ) { for ( $ i = 0 ; $ i < count ( $ gIDs ) ; ++ $ i ) { $ g = Group :: getByID ( $ gIDs [ $ i ] [ 'gID' ] ) ; if ( is_object ( $ g ) ) { $ this -> groups [ ] = $ g ; $ this -> label .= $ g -> getGroupDisplayName ( ) ; if ( $ i + 1 < count ( $ gIDs ) ) { $ this -> label .= t ( ' + ' ) ; } } } } } | Function used to load the properties for this GroupCombinationEntity from the database . |
10,298 | public function askWithCompletion ( $ question , array $ choices , $ default = null , $ attempts = null , $ strict = false ) { $ question = new Question ( $ question , $ default ) ; $ question -> setMaxAttempts ( $ attempts ) -> setAutocompleterValues ( $ choices ) ; if ( $ strict ) { $ question -> setValidator ( function ( $ result ) use ( $ choices ) { if ( ! in_array ( $ result , $ choices ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The provided answer is ambiguous. Value should be one of %s' , implode ( ' or ' , $ choices ) ) ) ; } return $ result ; } ) ; } return $ this -> askQuestion ( $ question ) ; } | Ask a question with autocompletion |
10,299 | public function columns ( array $ values , $ width = 5 , $ tableStyle = 'compact' , array $ columnStyles = [ ] ) { $ table = new Table ( $ this ) ; $ table -> setHeaders ( [ ] ) -> setRows ( iterator_to_array ( $ this -> chunk ( $ values , $ width ) ) ) -> setStyle ( $ tableStyle ) ; foreach ( $ columnStyles as $ columnIndex => $ columnStyle ) { $ table -> setColumnStyle ( $ columnIndex , $ columnStyle ) ; } $ columnWidths = $ this -> getColumnWidths ( $ width ) ; $ table -> setColumnWidths ( $ columnWidths ) ; $ table -> render ( ) ; } | Output in even width columns |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.