idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
10,600 | public function getClass ( $ pkgHandle ) { $ cache = $ this -> application -> make ( 'cache/request' ) ; $ item = $ cache -> getItem ( 'package/class/' . $ pkgHandle ) ; $ cl = $ item -> get ( ) ; if ( $ item -> isMiss ( ) ) { $ item -> lock ( ) ; $ cl = \ Concrete \ Core \ Foundation \ ClassLoader :: getInstance ( ) ; $ cl -> registerPackageController ( $ pkgHandle ) ; $ class = '\\Concrete\\Package\\' . camelcase ( $ pkgHandle ) . '\\Controller' ; try { $ cl = $ this -> application -> make ( $ class ) ; } catch ( \ Exception $ ex ) { $ cl = $ this -> application -> make ( 'Concrete\Core\Package\BrokenPackage' , [ $ pkgHandle ] ) ; } $ cache -> save ( $ item -> set ( $ cl ) ) ; } return clone $ cl ; } | Get the controller of a package given its handle . |
10,601 | public function getFileDisplayName ( ) { $ base = str_replace ( DIRECTORY_SEPARATOR , '/' , DIR_BASE ) ; if ( strpos ( $ this -> filename , $ base ) === 0 ) { $ path = substr ( $ this -> filename , strlen ( $ base ) + 1 ) ; } else { $ path = $ this -> filename ; } return str_replace ( '/' , DIRECTORY_SEPARATOR , $ path ) ; } | Get the display name of the translation file . |
10,602 | public static function create ( UserEntity $ userEntity , UserEntity $ actorEntity = null , DateTime $ dateCreated = null ) { return new self ( $ userEntity , $ actorEntity , $ dateCreated ) ; } | Factory method for creating new User event objects |
10,603 | public function mimeFromExtension ( $ ext ) { $ ext = strtolower ( $ ext ) ; if ( array_key_exists ( $ ext , self :: $ mime_types_and_extensions ) ) { return self :: $ mime_types_and_extensions [ $ ext ] ; } return false ; } | Converts a file extension into a mime type . |
10,604 | public function register ( ) { if ( ! $ this -> app -> bound ( TranslatorAdapterFactoryInterface :: class ) ) { $ this -> app -> bind ( TranslatorAdapterFactoryInterface :: class , function ( $ app , $ params ) { $ config = $ app -> make ( 'config' ) ; $ loaders = $ config -> get ( 'i18n.adapters.zend.loaders' , [ ] ) ; $ loaderRepository = new TranslationLoaderRepository ( ) ; foreach ( $ loaders as $ key => $ class ) { $ loader = $ app -> build ( $ class , [ $ app ] ) ; $ loaderRepository -> registerTranslationLoader ( $ key , $ loader ) ; } $ serviceManager = new ServiceManager ( ) ; $ loaderPluginManager = new LoaderPluginManager ( $ serviceManager , [ 'factories' => [ GettextLoader :: class => function ( $ creationContext , $ resolvedName , $ options ) { return $ this -> app -> build ( GettextLoader :: class , [ 'webrootDirectory' => DIR_BASE ] ) ; } ] , 'aliases' => [ 'gettext' => GettextLoader :: class , ] , ] ) ; $ zendFactory = new ZendTranslatorAdapterFactory ( $ loaderRepository , $ loaderPluginManager ) ; $ plainFactory = new PlainTranslatorAdapterFactory ( ) ; return new CoreTranslatorAdapterFactory ( $ config , $ plainFactory , $ zendFactory ) ; } ) ; } $ this -> app -> singleton ( Localization :: class , function ( $ app ) { $ loc = new Localization ( ) ; $ translatorAdapterFactory = $ app -> make ( TranslatorAdapterFactoryInterface :: class ) ; $ repository = new TranslatorAdapterRepository ( $ translatorAdapterFactory ) ; $ loc -> setTranslatorAdapterRepository ( $ repository ) ; $ loc -> setActiveContext ( Localization :: CONTEXT_UI ) ; return $ loc ; } ) ; } | Services that are essential for the loading of the localization functionality . |
10,605 | public function getEditorInitJSFunction ( $ dynamicOptions = [ ] ) { $ pluginManager = $ this -> getPluginManager ( ) ; if ( $ this -> allowFileManager ( ) ) { $ pluginManager -> select ( [ 'concrete5filemanager' , 'concrete5uploadimage' ] ) ; } else { $ pluginManager -> deselect ( [ 'concrete5filemanager' , 'concrete5uploadimage' ] ) ; } $ this -> requireEditorAssets ( ) ; $ plugins = $ pluginManager -> getSelectedPlugins ( ) ; $ snippetsAndClasses = $ this -> getEditorSnippetsAndClasses ( ) ; if ( ! is_array ( $ dynamicOptions ) ) { $ dynamicOptions = [ ] ; } $ defaultOptions = [ 'plugins' => implode ( ',' , $ plugins ) , 'stylesSet' => 'concrete5styles' , 'filebrowserBrowseUrl' => 'a' , 'uploadUrl' => ( string ) URL :: to ( '/ccm/system/file/upload' ) , 'language' => $ this -> getLanguageOption ( ) , 'customConfig' => '' , 'allowedContent' => true , 'baseFloatZIndex' => 1990 , 'image2_captionedClass' => 'content-editor-image-captioned' , 'image2_alignClasses' => [ 'content-editor-image-left' , 'content-editor-image-center' , 'content-editor-image-right' , ] , 'toolbarGroups' => $ this -> config -> get ( 'editor.ckeditor4.toolbar_groups' ) , 'snippets' => $ snippetsAndClasses -> snippets , 'classes' => $ snippetsAndClasses -> classes , 'sitemap' => $ this -> allowSitemap ( ) ] ; $ customOptions = $ this -> config -> get ( 'editor.ckeditor4.custom_config_options' ) ; if ( ! is_array ( $ customOptions ) ) { $ customOptions = [ ] ; } $ options = json_encode ( $ dynamicOptions + $ customOptions + $ defaultOptions ) ; $ removeEmptyIcon = '$removeEmpty[\'i\']' ; $ jsfunc = <<<EOL function(identifier) { window.CCM_EDITOR_SECURITY_TOKEN = "{$this->token}"; CKEDITOR.dtd.{$removeEmptyIcon} = false; if (CKEDITOR.stylesSet.get('concrete5styles') === null) { CKEDITOR.stylesSet.add('concrete5styles', {$this->getStylesJson()}); } var ckeditor = $(identifier).ckeditor({$options}).editor; ckeditor.on('blur',function(){ return false; }); ckeditor.on('remove', function(){ $(this).destroy(); }); if (CKEDITOR.env.ie) { ckeditor.on('ariaWidget', function (e) { setTimeout(function() { var \$contents = $(e.editor.ui.contentsElement.$), \$textarea = \$contents.find('>textarea.cke_source'); if (\$textarea.length === 1) { \$textarea.css({ width: \$contents.innerWidth() + 'px', height: \$contents.innerHeight() + 'px' }); } }, 50); }); } {$this->config->get('editor.ckeditor4.editor_function_options')} }EOL ; return $ jsfunc ; } | Generate the Javascript code that initialize the plugin . |
10,606 | public function outputInlineEditorInitJSFunction ( ) { $ pluginManager = $ this -> getPluginManager ( ) ; if ( $ pluginManager -> isSelected ( 'autogrow' ) ) { $ pluginManager -> deselect ( 'autogrow' ) ; } return $ this -> getEditorInitJSFunction ( ) ; } | Generate the Javascript code that initialize the plugin when it will be used inline . |
10,607 | public function outputStandardEditorInitJSFunction ( ) { $ options = [ 'disableAutoInline' => true , ] ; $ pluginManager = $ this -> getPluginManager ( ) ; if ( $ pluginManager -> isSelected ( 'sourcearea' ) ) { $ pluginManager -> deselect ( 'sourcedialog' ) ; } return $ this -> getEditorInitJSFunction ( $ options ) ; } | Generate the standard Javascript code that initialize the plugin . |
10,608 | protected function getLanguageOption ( ) { $ langPath = DIR_BASE_CORE . '/js/ckeditor4/vendor/lang/' ; $ useLanguage = 'en' ; $ language = strtolower ( str_replace ( '_' , '-' , Localization :: activeLocale ( ) ) ) ; if ( file_exists ( $ langPath . $ language . '.js' ) ) { $ useLanguage = $ language ; } elseif ( file_exists ( $ langPath . strtolower ( Localization :: activeLanguage ( ) ) . '.js' ) ) { $ useLanguage = strtolower ( Localization :: activeLanguage ( ) ) ; } else { $ useLanguage = null ; } return $ useLanguage ; } | Get the CKEditor language configuration . |
10,609 | private function getEditorSnippetsAndClasses ( ) { $ obj = new stdClass ( ) ; $ obj -> snippets = [ ] ; $ u = new User ( ) ; if ( $ u -> isRegistered ( ) ) { $ snippets = \ Concrete \ Core \ Editor \ Snippet :: getActiveList ( ) ; foreach ( $ snippets as $ sns ) { $ menu = new stdClass ( ) ; $ menu -> scsHandle = $ sns -> getSystemContentEditorSnippetHandle ( ) ; $ menu -> scsName = $ sns -> getSystemContentEditorSnippetName ( ) ; $ obj -> snippets [ ] = $ menu ; } } $ c = Page :: getCurrentPage ( ) ; $ obj -> classes = [ ] ; if ( is_object ( $ c ) && ! $ c -> isError ( ) ) { $ cp = new Permissions ( $ c ) ; if ( $ cp -> canViewPage ( ) ) { $ pt = $ c -> getCollectionThemeObject ( ) ; if ( is_object ( $ pt ) ) { if ( $ pt -> getThemeHandle ( ) ) { $ obj -> classes = $ pt -> getThemeEditorClasses ( ) ; } else { $ siteTheme = $ pt :: getSiteTheme ( ) ; if ( is_object ( $ siteTheme ) ) { $ obj -> classes = $ siteTheme -> getThemeEditorClasses ( ) ; } } } } } else { $ siteTheme = PageTheme :: getSiteTheme ( ) ; if ( is_object ( $ siteTheme ) ) { $ obj -> classes = $ siteTheme -> getThemeEditorClasses ( ) ; } } return $ obj ; } | Build an object containing the CKEditor preconfigured snippets and classes . |
10,610 | protected function setOptions ( array $ options = [ ] ) { $ options += $ this -> getDefaultOptions ( ) ; $ this -> prefix = ! empty ( $ options [ 'prefix' ] ) ? $ options [ 'prefix' ] : null ; $ servers = [ ] ; foreach ( $ this -> getRedisServers ( array_get ( $ options , 'servers' , [ ] ) ) as $ server ) { $ servers [ ] = $ server ; } $ redis = $ this -> getRedisInstance ( $ servers ) ; if ( isset ( $ options [ 'database' ] ) ) { $ redis -> select ( $ options [ 'database' ] ) ; } if ( ! empty ( $ options [ 'prefix' ] ) ) { $ redis -> setOption ( \ Redis :: OPT_PREFIX , $ options [ 'prefix' ] . ':' ) ; } $ this -> redis = $ redis ; } | The options array should contain an array of servers . |
10,611 | protected function makeKeyString ( $ key , $ path = false ) { $ key = \ Stash \ Utilities :: normalizeKeys ( $ key ) ; $ keyString = 'cache:::' ; $ pathKey = ':pathdb::' ; foreach ( $ key as $ name ) { $ keyString .= $ name ; $ pathKey = ':pathdb::' . $ keyString ; $ pathKey = md5 ( $ pathKey ) ; if ( isset ( $ this -> keyCache [ $ pathKey ] ) ) { $ index = $ this -> keyCache [ $ pathKey ] ; } else { $ index = $ this -> redis -> get ( $ pathKey ) ; $ this -> keyCache [ $ pathKey ] = $ index ; } $ keyString .= '_' . $ index . ':::' ; } return $ path ? $ pathKey : md5 ( $ keyString ) ; } | Turns a key array into a key string . This includes running the indexing functions used to manage the Redis hierarchical storage . |
10,612 | public function get ( $ cfKey , $ pkgID = null ) { if ( $ pkgID > 0 && isset ( $ this -> rows [ "{$cfKey}.{$pkgID}" ] ) ) { return $ this -> rowToConfigValue ( $ this -> rows [ "{$cfKey}.{$pkgID}" ] ) ; } else { foreach ( $ this -> rows as $ row ) { if ( $ row [ 'cfKey' ] == $ cfKey ) { return $ this -> rowToConfigValue ( $ row ) ; } } } return null ; } | Get a config item . |
10,613 | public static function getByID ( $ cnvEditorID ) { $ db = Database :: connection ( ) ; $ r = $ db -> fetchAssoc ( 'select * from ConversationEditors where cnvEditorID = ?' , array ( $ cnvEditorID ) ) ; return static :: createFromRecord ( $ r ) ; } | Returns the appropriate conversation editor object for the given cnvEditorID . |
10,614 | public static function getByHandle ( $ cnvEditorHandle ) { $ db = Database :: connection ( ) ; $ r = $ db -> fetchAssoc ( 'select * from ConversationEditors where cnvEditorHandle = ?' , array ( $ cnvEditorHandle ) ) ; return static :: createFromRecord ( $ r ) ; } | Returns the appropriate conversation editor object for the given cnvEditorHandle . |
10,615 | protected static function createFromRecord ( $ record ) { if ( is_array ( $ record ) && $ record [ 'cnvEditorHandle' ] ) { $ textHelper = Core :: make ( 'helper/text' ) ; $ class = '\\Concrete\\Core\\Conversation\\Editor\\' . $ textHelper -> camelcase ( $ record [ 'cnvEditorHandle' ] ) . 'Editor' ; $ sc = Core :: make ( $ class ) ; $ sc -> setPropertiesFromArray ( $ record ) ; return $ sc ; } return null ; } | This function is used to instantiate a Conversation Editor object from an associative array . |
10,616 | public function outputConversationEditorAddMessageForm ( ) { \ View :: element ( DIRNAME_CONVERSATIONS . '/' . DIRNAME_CONVERSATION_EDITOR . '/' . $ this -> cnvEditorHandle . '/message' , [ 'editor' => $ this ] , $ this -> getPackageHandle ( ) ) ; } | outputs an HTML block containing the add message form for the current Conversation Editor . |
10,617 | public function outputConversationEditorReplyMessageForm ( ) { \ View :: element ( DIRNAME_CONVERSATIONS . '/' . DIRNAME_CONVERSATION_EDITOR . '/' . $ this -> cnvEditorHandle . '/reply' , [ 'editor' => $ this ] , $ this -> getPackageHandle ( ) ) ; } | Outputs an HTML block containing the message reply form for the current Conversation Editor . |
10,618 | public function formatConversationMessageBody ( $ cnv , $ cnvMessageBody , $ config = array ( ) ) { $ htmlHelper = Core :: make ( 'helper/html' ) ; $ cnvMessageBody = $ htmlHelper -> noFollowHref ( $ cnvMessageBody ) ; if ( isset ( $ config [ 'htmlawed' ] ) ) { $ default = array ( 'safe' => 1 , 'elements' => 'p, br, strong, em, strike, a' ) ; $ conf = array_merge ( $ default , ( array ) $ config [ 'htmlawed' ] ) ; $ result = htmLawed ( $ cnvMessageBody , $ conf ) ; } else { $ result = $ cnvMessageBody ; } if ( isset ( $ config [ 'mention' ] ) && $ config [ 'mention' ] !== false ) { $ users = $ cnv -> getConversationMessageUsers ( ) ; $ needle = array ( ) ; $ haystack = array ( ) ; foreach ( $ users as $ user ) { $ needle [ ] = "@" . $ user -> getUserName ( ) ; $ haystack [ ] = "<a href='" . $ user -> getUserPublicProfileURL ( ) . "'>'@" . $ user -> getUserName ( ) . "</a>" ; } $ result = str_ireplace ( $ needle , $ haystack , $ result ) ; } $ result = $ this -> removeJavascriptLinks ( $ result ) ; return $ result ; } | Returns a formatted conversation message body string based on configuration options supplied . |
10,619 | public static function add ( $ cnvEditorHandle , $ cnvEditorName , $ pkg = false ) { $ pkgID = 0 ; if ( is_object ( $ pkg ) ) { $ pkgID = $ pkg -> getPackageID ( ) ; } $ db = Database :: connection ( ) ; $ db -> insert ( 'ConversationEditors' , array ( 'cnvEditorHandle' => $ cnvEditorHandle , 'cnvEditorName' => $ cnvEditorName , 'pkgID' => $ pkgID , ) ) ; return static :: getByHandle ( $ cnvEditorHandle ) ; } | Creates a database record for the Conversation Editor then attempts to return the object . |
10,620 | public static function getList ( $ pkgID = null ) { $ db = Database :: connection ( ) ; $ queryBuilder = $ db -> createQueryBuilder ( ) -> select ( 'e.*' ) -> from ( 'ConversationEditors' , 'e' ) -> orderBy ( 'cnvEditorHandle' , 'asc' ) ; if ( $ pkgID !== null ) { $ queryBuilder -> andWhere ( 'e.pkgID = :pkgID' ) -> setParameter ( 'pkgID' , $ pkgID ) ; } $ cnvEditors = $ db -> fetchAll ( $ queryBuilder -> getSQL ( ) , $ queryBuilder -> getParameters ( ) ) ; $ editors = array ( ) ; foreach ( $ cnvEditors as $ editorRecord ) { $ cnvEditor = static :: createFromRecord ( $ editorRecord ) ; $ editors [ ] = $ cnvEditor ; } return $ editors ; } | Returns an array of all Editor Objects . |
10,621 | public function hasOptionsForm ( ) { $ env = Environment :: get ( ) ; $ rec = $ env -> getRecord ( DIRNAME_ELEMENTS . '/' . DIRNAME_CONVERSATIONS . '/' . DIRNAME_CONVERSATION_EDITOR . '/' . $ this -> cnvEditorHandle . '/' . FILENAME_CONVERSATION_EDITOR_OPTIONS , $ this -> getPackageHandle ( ) ) ; return $ rec -> exists ( ) ; } | Returns whether or not the current Conversation Editor has an options form . |
10,622 | public function getCustomEntityRepositories ( ) { $ result = [ ] ; $ app = ApplicationFacade :: getFacadeApplication ( ) ; $ pev = new PackageEntitiesEvent ( ) ; $ app -> make ( 'director' ) -> dispatch ( 'on_list_package_entities' , $ pev ) ; $ entityManagers = array_merge ( [ $ app -> make ( EntityManagerInterface :: class ) ] , $ pev -> getEntityManagers ( ) ) ; foreach ( $ entityManagers as $ entityManager ) { $ metadataFactory = $ entityManager -> getMetadataFactory ( ) ; foreach ( $ metadataFactory -> getAllMetadata ( ) as $ metadata ) { $ entityClassName = $ metadata -> getName ( ) ; $ entityRepository = $ entityManager -> getRepository ( $ entityClassName ) ; $ entityRepositoryClassName = get_class ( $ entityRepository ) ; switch ( $ entityRepositoryClassName ) { case \ Doctrine \ ORM \ EntityRepository :: class : break ; default : $ result [ $ entityClassName ] = $ entityRepositoryClassName ; break ; } } } return $ result ; } | Return the list of custom entity manager repositories . |
10,623 | protected function queueMessages ( ) { $ pages = $ users = $ files = $ sites = 0 ; foreach ( $ this -> pagesToQueue ( ) as $ id ) { yield "P{$id}" ; $ pages ++ ; } foreach ( $ this -> usersToQueue ( ) as $ id ) { yield "U{$id}" ; $ users ++ ; } foreach ( $ this -> filesToQueue ( ) as $ id ) { yield "F{$id}" ; $ files ++ ; } foreach ( $ this -> sitesToQueue ( ) as $ id ) { yield "S{$id}" ; $ sites ++ ; } yield 'R' . json_encode ( [ $ pages , $ users , $ files , $ sites ] ) ; } | Messages to add to the queue . |
10,624 | protected function clearIndex ( $ index ) { $ index -> clear ( Page :: class ) ; $ index -> clear ( User :: class ) ; $ index -> clear ( File :: class ) ; $ index -> clear ( Site :: class ) ; } | Clear out all indexes . |
10,625 | protected function pagesToQueue ( ) { $ qb = $ this -> connection -> createQueryBuilder ( ) ; $ query = $ qb -> select ( 'p.cID' ) -> from ( 'Pages' , 'p' ) -> leftJoin ( 'p' , 'CollectionSearchIndexAttributes' , 'a' , 'p.cID = a.cID' ) -> where ( 'cIsActive = 1' ) -> andWhere ( $ qb -> expr ( ) -> orX ( 'a.ak_exclude_search_index is null' , 'a.ak_exclude_search_index = 0' ) ) -> execute ( ) ; while ( $ id = $ query -> fetchColumn ( ) ) { yield $ id ; } } | Get Pages to add to the queue . |
10,626 | protected function usersToQueue ( ) { $ db = $ this -> connection ; $ query = $ db -> executeQuery ( 'SELECT uID FROM Users WHERE uIsActive = 1' ) ; while ( $ id = $ query -> fetchColumn ( ) ) { yield $ id ; } } | Get Users to add to the queue . |
10,627 | protected function filesToQueue ( ) { $ db = $ this -> connection ; $ query = $ db -> executeQuery ( 'SELECT fID FROM Files' ) ; while ( $ id = $ query -> fetchColumn ( ) ) { yield $ id ; } } | Get Files to add to the queue . |
10,628 | protected function sitesToQueue ( ) { $ db = $ this -> connection ; $ query = $ db -> executeQuery ( 'SELECT siteID FROM Sites' ) ; while ( $ id = $ query -> fetchColumn ( ) ) { yield $ id ; } } | Get Sites to add to the queue . |
10,629 | public static function translateFromEditMode ( $ text ) { $ app = Application :: getFacadeApplication ( ) ; $ entityManager = $ app -> make ( EntityManagerInterface :: class ) ; $ resolver = $ app -> make ( ResolverManagerInterface :: class ) ; $ appUrl = Application :: getApplicationURL ( ) ; $ text = preg_replace ( [ '/{CCM:BASE_URL}/i' , ] , [ $ appUrl , ] , $ text ) ; $ text = preg_replace ( '/{CCM:CID_([0-9]+)}/i' , $ appUrl . '/' . DISPATCHER_FILENAME . '?cID=\\1' , $ text ) ; $ dom = new HtmlDomParser ( ) ; $ r = $ dom -> str_get_html ( $ text , true , true , DEFAULT_TARGET_CHARSET , false ) ; if ( is_object ( $ r ) ) { foreach ( $ r -> find ( 'concrete-picture' ) as $ picture ) { $ fID = $ picture -> fid ; $ attrString = "" ; foreach ( $ picture -> attr as $ attr => $ val ) { if ( ! in_array ( $ attr , self :: $ blackListImgAttributes ) ) { $ attrString .= "$attr=\"$val\" " ; } } $ picture -> outertext = '<img src="' . $ resolver -> resolve ( [ '/download_file' , 'view_inline' , $ fID ] ) . '" ' . $ attrString . '/>' ; } $ text = ( string ) $ r -> restore_noise ( $ r ) ; } $ text = static :: replacePlaceholder ( $ text , '{CCM:FID_([0-9]+)}' , function ( $ fID ) use ( $ resolver ) { if ( $ fID > 0 ) { return $ resolver -> resolve ( [ '/download_file' , 'view_inline' , $ fID ] ) ; } } ) ; $ text = static :: replacePlaceholder ( $ text , '{CCM:FID_DL_([0-9]+)}' , function ( $ fID ) use ( $ resolver ) { if ( $ fID > 0 ) { return $ resolver -> resolve ( [ '/download_file' , 'view' , $ fID ] ) ; } } ) ; return $ text ; } | Takes a chunk of content containing abstracted link references and expands them to urls suitable for the rich text editor . |
10,630 | protected static function replacePlaceholder ( $ text , $ pattern , callable $ resolver , $ caseSensitive = false ) { $ regex = "/{$pattern}/" ; if ( ! $ caseSensitive ) { $ regex .= 'i' ; } if ( ! preg_match_all ( $ regex , $ text , $ matches ) ) { return $ text ; } $ replaces = array_combine ( $ matches [ 0 ] , $ matches [ 1 ] ) ; if ( ! $ caseSensitive ) { $ replaces = array_change_key_case ( $ replaces , CASE_UPPER ) ; } foreach ( array_keys ( $ replaces ) as $ key ) { $ replaces [ $ key ] = ( string ) $ resolver ( $ replaces [ $ key ] ) ; } return $ caseSensitive ? strtr ( $ text , $ replaces ) : str_ireplace ( array_keys ( $ replaces ) , array_values ( $ replaces ) , $ text ) ; } | Replace a placeholder . |
10,631 | public static function getList ( ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; return $ em -> getRepository ( ThumbnailTypeEntity :: class ) -> findBy ( [ ] , [ 'ftTypeWidth' => 'asc' ] ) ; } | Get the list of all the available thumbnail types . |
10,632 | public static function getVersionList ( ) { $ app = Application :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; $ createHightDPIVersions = ( bool ) $ config -> get ( 'concrete.file_manager.images.create_high_dpi_thumbnails' ) ; $ types = static :: getList ( ) ; $ versions = [ ] ; foreach ( $ types as $ type ) { $ versions [ ] = $ type -> getBaseVersion ( ) ; if ( $ createHightDPIVersions ) { $ versions [ ] = $ type -> getDoubledVersion ( ) ; } } return $ versions ; } | Get the list of all the available thumbnail type versions . |
10,633 | public static function exportList ( $ node ) { $ child = $ node -> addChild ( 'thumbnailtypes' ) ; $ list = static :: getList ( ) ; foreach ( $ list as $ link ) { $ linkNode = $ child -> addChild ( 'thumbnailtype' ) ; $ linkNode -> addAttribute ( 'name' , $ link -> getName ( ) ) ; $ linkNode -> addAttribute ( 'handle' , $ link -> getHandle ( ) ) ; $ linkNode -> addAttribute ( 'sizingMode' , $ link -> getSizingMode ( ) ) ; $ linkNode -> addAttribute ( 'upscalingEnabled' , $ link -> isUpscalingEnabled ( ) ? '1' : '0' ) ; $ linkNode -> addAttribute ( 'keepAnimations' , $ link -> isKeepAnimations ( ) ? '1' : '0' ) ; if ( $ link -> getWidth ( ) ) { $ linkNode -> addAttribute ( 'width' , $ link -> getWidth ( ) ) ; } if ( $ link -> getHeight ( ) ) { $ linkNode -> addAttribute ( 'height' , $ link -> getHeight ( ) ) ; } if ( $ link -> isRequired ( ) ) { $ linkNode -> addAttribute ( 'required' , $ link -> isRequired ( ) ) ; } $ linkNode -> addAttribute ( 'limitedToFileSets' , $ link -> isLimitedToFileSets ( ) ? '1' : '0' ) ; $ filesetsNode = null ; foreach ( $ link -> getAssociatedFileSets ( ) as $ afs ) { $ fileSet = FileSet :: getByID ( $ afs -> getFileSetID ( ) ) ; if ( $ fileSet !== null ) { if ( $ filesetsNode === null ) { $ filesetsNode = $ linkNode -> addChild ( 'fileSets' ) ; } $ filesetsNode -> addChild ( 'fileSet' ) -> addAttribute ( 'name' , $ fileSet -> getFileSetName ( ) ) ; } } } } | Export the list of all the thumbnail types . |
10,634 | public static function getByID ( $ id ) { if ( $ id ) { $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ result = $ em -> find ( ThumbnailTypeEntity :: class , $ id ) ; } else { $ result = null ; } return $ result ; } | Get a thumbnail type given its id . |
10,635 | public static function getByHandle ( $ ftTypeHandle ) { $ ftTypeHandle = ( string ) $ ftTypeHandle ; $ app = Application :: getFacadeApplication ( ) ; $ cache = $ app -> make ( 'cache/request' ) ; $ item = $ cache -> getItem ( 'file/image/thumbnail/' . $ ftTypeHandle ) ; if ( $ item -> isMiss ( ) ) { $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ repo = $ em -> getRepository ( ThumbnailTypeEntity :: class ) ; $ result = $ repo -> findOneBy ( [ 'ftTypeHandle' => $ ftTypeHandle ] ) ; $ cache -> save ( $ item -> set ( $ result ) ) ; } else { $ result = $ item -> get ( ) ; } return $ result ; } | Get a thumbnail type given its handle . |
10,636 | public static function isOverLimit ( $ uID ) { if ( Config :: get ( 'concrete.user.private_messages.throttle_max' ) == 0 ) { return false ; } if ( Config :: get ( 'concrete.user.private_messages.throttle_max_timespan' ) == 0 ) { return false ; } $ db = Loader :: db ( ) ; $ dt = new DateTime ( ) ; $ dt -> modify ( '-' . Config :: get ( 'concrete.user.private_messages.throttle_max_timespan' ) . ' minutes' ) ; $ v = array ( $ uID , $ dt -> format ( 'Y-m-d H:i:s' ) ) ; $ q = "SELECT COUNT(msgID) as sent_count FROM UserPrivateMessages WHERE uAuthorID = ? AND msgDateCreated >= ?" ; $ count = $ db -> getOne ( $ q , $ v ) ; if ( $ count > Config :: get ( 'concrete.user.private_messages.throttle_max' ) ) { self :: notifyAdmin ( $ uID ) ; return true ; } else { return false ; } } | checks to see if a user has exceeded their limit for sending private messages . |
10,637 | public static function getCoreChannels ( ) { return [ self :: CHANNEL_EMAIL , self :: CHANNEL_EXCEPTIONS , self :: CHANNEL_PACKAGES , self :: CHANNEL_SECURITY , self :: CHANNEL_AUTHENTICATION , self :: CHANNEL_PERMISSIONS , self :: CHANNEL_SPAM , self :: CHANNEL_SITE_ORGANIZATION , self :: CHANNEL_NETWORK , self :: CHANNEL_USERS , self :: CHANNEL_OPERATIONS , self :: CHANNEL_API , ] ; } | Get the list of the core channel . |
10,638 | public static function getChannels ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( Connection :: class ) ; $ channels = ( array ) $ db -> GetCol ( 'select distinct channel from Logs order by channel asc' ) ; return $ channels ; } | Get the list of channels that have been used . Requires the database handler . |
10,639 | public static function getChannelDisplayName ( $ channel ) { $ text = new Text ( ) ; switch ( $ channel ) { case self :: CHANNEL_APPLICATION : return tc ( 'Log channel' , 'Application' ) ; case self :: CHANNEL_AUTHENTICATION : return tc ( 'Log channel' , 'Authentication' ) ; case self :: CHANNEL_EMAIL : return tc ( 'Log channel' , 'Sent Emails' ) ; case self :: CHANNEL_EXCEPTIONS : return tc ( 'Log channel' , 'Exceptions' ) ; case self :: CHANNEL_SECURITY : return tc ( 'Log channel' , 'Security' ) ; case self :: CHANNEL_PACKAGES : return tc ( 'Log channel' , 'Packages' ) ; case self :: CHANNEL_SPAM : return tc ( 'Log channel' , 'Spam' ) ; case self :: CHANNEL_SITE_ORGANIZATION : return tc ( 'Log channel' , 'Site Organization' ) ; case self :: CHANNEL_USERS : return tc ( 'Log channel' , 'Users' ) ; case self :: CHANNEL_API : return tc ( 'Log channel' , 'API' ) ; default : return tc ( 'Log channel' , $ text -> unhandle ( $ channel ) ) ; } } | Get the display name of a channel . |
10,640 | protected static function removeExpired ( $ type ) { switch ( $ type ) { case UVTYPE_CHANGE_PASSWORD : $ lifetime = USER_CHANGE_PASSWORD_URL_LIFETIME ; break ; case UVTYPE_LOGIN_FOREVER : $ lifetime = USER_FOREVER_COOKIE_LIFETIME ; break ; default : $ lifetime = 5184000 ; break ; } $ db = Database :: connection ( ) ; $ db -> executeQuery ( 'DELETE FROM UserValidationHashes WHERE type = ? AND uDateGenerated <= ?' , array ( $ type , time ( ) - $ lifetime ) ) ; } | Removes old entries for the supplied type . |
10,641 | public static function add ( $ uID , $ type , $ singeHashAllowed = false , $ hashLength = 64 ) { self :: removeExpired ( $ type ) ; $ hash = self :: generate ( $ hashLength ) ; $ db = Database :: connection ( ) ; if ( $ singeHashAllowed ) { $ db -> executeQuery ( "DELETE FROM UserValidationHashes WHERE uID = ? AND type = ?" , array ( $ uID , $ type ) ) ; } $ db -> executeQuery ( "insert into UserValidationHashes (uID, uHash, uDateGenerated, type) values (?, ?, ?, ?)" , array ( $ uID , $ hash , time ( ) , intval ( $ type ) ) ) ; return $ hash ; } | Adds a hash to the lookup table for a user and type removes any other existing hashes for the same user and type . |
10,642 | public static function getUserID ( $ hash , $ type ) { self :: removeExpired ( $ type ) ; $ db = Database :: connection ( ) ; $ uID = $ db -> fetchColumn ( "SELECT uID FROM UserValidationHashes WHERE uHash = ? AND type = ?" , array ( $ hash , $ type ) ) ; if ( is_numeric ( $ uID ) && $ uID > 0 ) { return $ uID ; } else { return false ; } } | Gets the users id for a given hash and type . |
10,643 | public static function getType ( $ hash ) { $ db = Database :: connection ( ) ; $ type = $ db -> fetchColumn ( "SELECT type FROM UserValidationHashes WHERE uHash = ? " , array ( $ hash ) ) ; if ( is_numeric ( $ type ) && $ type > 0 ) { return $ type ; } else { return false ; } } | Gets the hash type for a given hash . |
10,644 | public static function isValid ( $ hash ) { $ type = self :: getType ( $ hash ) ; self :: removeExpired ( $ type ) ; return ( bool ) self :: getUserID ( $ hash , $ type ) ; } | Validate the given hash |
10,645 | public function addUploadedImage ( $ field , $ errorMsg = null , $ emptyIsOk = true ) { $ const = ( $ emptyIsOk ) ? self :: VALID_UPLOADED_IMAGE : self :: VALID_UPLOADED_IMAGE_REQUIRED ; $ this -> addRequired ( $ field , $ errorMsg , $ const ) ; } | Adds a test to a field to ensure that if set it is a valid uploaded image . |
10,646 | public function addUploadedFile ( $ field , $ errorMsg = null , $ emptyIsOk = true ) { $ const = ( $ emptyIsOk ) ? self :: VALID_UPLOADED_FILE : self :: VALID_UPLOADED_FILE_REQUIRED ; $ this -> addRequired ( $ field , $ errorMsg , $ const ) ; } | Adds a test to a field to ensure that if set it is a valid uploaded file . |
10,647 | public function addInteger ( $ field , $ errorMsg = null , $ emptyIsOk = true ) { $ const = ( $ emptyIsOk ) ? self :: VALID_INTEGER : self :: VALID_INTEGER_REQUIRED ; $ this -> addRequired ( $ field , $ errorMsg , $ const ) ; } | Adds a required field and tests that it is integer only . |
10,648 | public function addRequiredEmail ( $ field , $ errorMsg = null ) { $ this -> addRequired ( $ field , $ errorMsg , self :: VALID_EMAIL ) ; } | Adds a required email address to the suite of tests to be run . |
10,649 | public function requireAsset ( $ assetType , $ assetHandle = false ) { $ list = AssetList :: getInstance ( ) ; if ( $ assetType instanceof AssetInterface ) { $ this -> requiredAssetGroup -> addAsset ( $ assetType ) ; } elseif ( $ assetType && $ assetHandle ) { $ ap = new AssetPointer ( $ assetType , $ assetHandle ) ; $ this -> requiredAssetGroup -> add ( $ ap ) ; } else { $ r = $ list -> getAssetGroup ( $ assetType ) ; if ( isset ( $ r ) ) { $ this -> requiredAssetGroup -> addGroup ( $ r ) ; } else { throw new Exception ( t ( '"%s" is not a valid asset group handle' , $ assetType ) ) ; } } } | Add an asset to the assets required for this plugin . |
10,650 | public function login ( $ username , $ password ) { $ className = $ this -> userClass ; $ user = new $ className ( $ username , $ password ) ; if ( $ user -> isError ( ) ) { $ this -> handleUserError ( $ user -> getError ( ) ) ; } return $ user ; } | Attempt login given a username and a password |
10,651 | public function failLogin ( $ username , $ password ) { $ ipFailed = false ; $ userFailed = false ; $ this -> ipService -> logFailedLogin ( ) ; $ this -> loginAttemptService -> trackAttempt ( $ username , $ password ) ; if ( $ this -> ipService -> failedLoginsThresholdReached ( ) ) { $ this -> ipService -> addToBlacklistForThresholdReached ( ) ; $ ipFailed = true ; } if ( $ this -> loginAttemptService -> remainingAttempts ( $ username , $ password ) <= 0 ) { $ this -> loginAttemptService -> deactivate ( $ username ) ; $ userFailed = true ; } if ( $ ipFailed ) { $ message = $ this -> ipService -> getErrorMessage ( ) ; throw new FailedLoginThresholdExceededException ( $ message ) ; } if ( $ userFailed ) { throw new UserDeactivatedException ( $ this -> config -> get ( 'concrete.user.deactivation.message' ) ) ; } } | Handle a failed login attempt |
10,652 | public function logLoginAttempt ( $ username , array $ errors = [ ] ) { if ( $ this -> app ) { $ entry = $ this -> app -> make ( LoginAttempt :: class , [ $ username , $ this -> request ? $ this -> request -> getPath ( ) : '' , $ this -> getGroups ( $ username ) , $ errors ] ) ; $ context = $ entry -> getContext ( ) ; $ context [ 'ip_address' ] = ( string ) $ this -> ipService -> getRequestIPAddress ( ) ; $ this -> logger -> info ( $ entry -> getMessage ( ) , $ context ) ; } } | Add a log entry for this login attempt |
10,653 | private function getGroups ( $ username ) { if ( ! $ this -> entityManager ) { return [ ] ; } $ db = $ this -> entityManager -> getConnection ( ) ; $ queryBuilder = $ db -> createQueryBuilder ( ) ; $ rows = $ queryBuilder -> select ( 'g.gName' , 'u.uID' ) -> from ( $ db -> getDatabasePlatform ( ) -> quoteSingleIdentifier ( 'Groups' ) , 'g' ) -> leftJoin ( 'g' , 'UserGroups' , 'ug' , 'ug.gID=g.gID' ) -> innerJoin ( 'ug' , 'Users' , 'u' , 'ug.uID=u.uID AND (u.uName=? OR u.uEmail=?)' ) -> setParameters ( [ $ username , $ username ] ) -> execute ( ) ; $ groups = [ ] ; $ uID = 0 ; foreach ( $ rows as $ row ) { $ uID = ( int ) $ row [ 'uID' ] ; $ groups [ ] = $ row [ 'gName' ] ; } if ( $ uID == USER_SUPER_ID ) { $ groups [ ] = 'SUPER' ; } return $ groups ; } | Aggregate a list of groups to report |
10,654 | protected function handleUserError ( $ errorNum ) { switch ( $ errorNum ) { case USER_INACTIVE : throw new NotActiveException ( t ( $ this -> config -> get ( 'concrete.user.deactivation.message' ) ) ) ; case USER_SESSION_EXPIRED : throw new SessionExpiredException ( t ( 'Your session has expired. Please sign in again.' ) ) ; case USER_NON_VALIDATED : throw new NotValidatedException ( t ( 'This account has not yet been validated. Please check the email associated with this ' . 'account and follow the link it contains.' ) ) ; case USER_PASSWORD_RESET : throw new UserPasswordResetException ( t ( 'This password has been reset.' ) ) ; case USER_INVALID : if ( $ this -> config -> get ( 'concrete.user.registration.email_registration' ) ) { $ message = t ( 'Invalid email address or password.' ) ; } else { $ message = t ( 'Invalid username or password.' ) ; } throw new InvalidCredentialsException ( $ message ) ; } throw new \ RuntimeException ( t ( 'An unknown login error occurred. Please try again.' ) ) ; } | Throw an exception based on the given error number |
10,655 | protected function normalizeStringList ( $ value ) { if ( is_string ( $ value ) ) { $ strings = preg_split ( '/\s+/' , $ value , - 1 , PREG_SPLIT_NO_EMPTY ) ; } elseif ( is_array ( $ value ) ) { $ strings = array_map ( 'trim' , array_map ( 'strval' , $ value ) ) ; } else { $ strings = [ ] ; } return array_values ( array_unique ( array_map ( 'strtolower' , $ strings ) ) ) ; } | Takes an array keeps only strings makes them lowercase and returns the unique values . |
10,656 | public function format ( $ mask , callable $ matchHandler ) { try { return preg_replace_callback ( '/%(.*?)%/i' , function ( $ matches ) use ( $ matchHandler ) { return $ this -> getResult ( $ matches [ 1 ] , $ matchHandler ) ? : '' ; } , $ mask ) ; } catch ( \ Exception $ e ) { $ this -> logger -> debug ( 'Failed to format express mask "{mask}": {message}' , [ 'mask' => $ mask , 'message' => $ e -> getMessage ( ) , 'exception' => $ e ] ) ; } } | Format a mask using the standard format given a callable |
10,657 | public function post ( $ key , $ defaultValue = null ) { $ r = Request :: getInstance ( ) ; return $ r -> post ( $ key , $ defaultValue ) ; } | Returns the value of the item in the POST array . |
10,658 | public function setThemeByPath ( $ path , $ theme = null , $ wrapper = FILENAME_THEMES_VIEW ) { $ l = Router :: get ( ) ; $ l -> setThemeByRoute ( $ path , $ theme , $ wrapper ) ; } | Legacy Items . Deprecated |
10,659 | public function setConsentType ( $ consentType ) { if ( $ consentType !== self :: CONSENT_SIMPLE && $ consentType !== self :: CONSENT_NONE ) { throw new InvalidArgumentException ( 'Invalid consent type provided.' ) ; } $ this -> consentType = $ consentType ; } | Set the level of consent this client must receive from the authenticating user |
10,660 | public function selectUser ( $ fieldName , $ uID = false ) { $ v = View :: getRequestInstance ( ) ; $ v -> requireAsset ( 'core/users' ) ; $ request = $ this -> app -> make ( Request :: class ) ; if ( $ request -> request -> has ( $ fieldName ) ) { $ selectedUID = $ request -> request -> get ( $ fieldName ) ; } elseif ( $ request -> query -> has ( $ fieldName ) ) { $ selectedUID = $ request -> query -> get ( $ fieldName ) ; } else { $ selectedUID = $ uID ; } if ( $ selectedUID && $ this -> app -> make ( Numbers :: class ) -> integer ( $ selectedUID , 1 ) ) { $ userInfo = $ this -> app -> make ( UserInfoRepository :: class ) -> getByID ( ( int ) $ selectedUID ) ; } else { $ userInfo = null ; } $ selectedUID = $ userInfo ? $ userInfo -> getUserID ( ) : null ; $ permissions = new Checker ( ) ; if ( $ permissions -> canAccessUserSearch ( ) ) { $ identifier = $ this -> app -> make ( Identifier :: class ) -> getString ( 32 ) ; $ args = [ 'inputName' => $ fieldName ] ; if ( $ userInfo ) { $ args [ 'uID' ] = $ userInfo -> getUserID ( ) ; } $ args = json_encode ( $ args ) ; $ html = <<<EOL<div data-user-selector="{$identifier}"></div><script>$(function() { $('[data-user-selector={$identifier}]').concreteUserSelector({$args});});</script>EOL ; } else { $ uAvatar = null ; if ( $ userInfo ) { $ uName = $ userInfo -> getUserDisplayName ( ) ; $ a = $ userInfo -> getUserAvatar ( ) ; if ( $ a ) { $ uAvatar = $ a -> getPath ( ) ; } } else { $ uName = t ( '(None Selected)' ) ; } if ( ! $ uAvatar ) { $ uAvatar = $ this -> app -> make ( 'config' ) -> get ( 'concrete.icons.user_avatar.default' ) ; } $ html = <<<EOL<div class="ccm-item-selector"> <div class="ccm-item-selector-item-selected"> <input type="hidden" name="{$fieldName}" value="{$selectedUID}"> <div class="ccm-item-selector-item-selected-thumbnail"> <img src="{$uAvatar}" alt="admin" class="u-avatar"> </div> <div class="ccm-item-selector-item-selected-title">{$uName}</div> </div></div>EOL ; } return $ html ; } | Build the HTML to be placed in a page to choose a user using a popup dialog . |
10,661 | public function quickSelect ( $ fieldName , $ uID = false , $ miscFields = [ ] ) { $ v = View :: getRequestInstance ( ) ; $ v -> requireAsset ( 'selectize' ) ; $ request = $ this -> app -> make ( Request :: class ) ; if ( $ request -> request -> has ( $ fieldName ) ) { $ selectedUID = $ request -> request -> get ( $ fieldName ) ; } elseif ( $ request -> query -> has ( $ fieldName ) ) { $ selectedUID = $ request -> query -> get ( $ fieldName ) ; } else { $ selectedUID = $ uID ; } if ( $ selectedUID && $ this -> app -> make ( Numbers :: class ) -> integer ( $ selectedUID , 1 ) ) { $ userInfo = $ this -> app -> make ( UserInfoRepository :: class ) -> getByID ( ( int ) $ selectedUID ) ; } else { $ userInfo = null ; } $ selectedUID = $ userInfo ? $ userInfo -> getUserID ( ) : null ; $ valt = $ this -> app -> make ( 'token' ) ; $ token = $ valt -> generate ( 'quick_user_select_' . $ fieldName ) ; $ identifier = $ this -> app -> make ( Identifier :: class ) -> getString ( 32 ) ; $ selectizeOptions = [ 'valueField' => 'value' , 'labelField' => 'label' , 'searchField' => [ 'label' ] , 'maxItems' => 1 , ] ; if ( $ userInfo ) { $ selectizeOptions += [ 'options' => [ [ 'label' => h ( $ userInfo -> getUserDisplayName ( ) ) , 'value' => $ selectedUID , ] , ] , 'items' => [ $ selectedUID , ] , ] ; } $ selectizeOptions = json_encode ( $ selectizeOptions ) ; $ input = $ this -> app -> make ( 'helper/form' ) -> hidden ( $ fieldName , '' , $ miscFields ) ; $ ajaxUrlBase = json_encode ( REL_DIR_FILES_TOOLS_REQUIRED . '/users/autocomplete?key=' . rawurlencode ( $ fieldName ) . '&token=' . rawurldecode ( $ token ) ) ; return <<<EOT<span id="ccm-quick-user-selector-{$identifier}" class="ccm-quick-user-selector">{$input}</span><script>$(function () { var options = {$selectizeOptions}; options.load = function(query, callback) { if (!query.length) { return callback(); } $.ajax({ url: {$ajaxUrlBase} + '&term=' + encodeURIComponent(query), type: 'GET', dataType: 'json', error: function() { callback(); }, success: function(res) { callback(res); } }); }; $('#ccm-quick-user-selector-{$identifier} input') .unbind() .selectize(options) ;});</script>EOT ; } | Build the HTML to be placed in a page to choose a user using a select with users pupulated dynamically with ajax requests . |
10,662 | public function selectMultipleUsers ( $ fieldName , $ users = [ ] ) { $ identifier = $ this -> app -> make ( Identifier :: class ) -> getString ( 32 ) ; $ i18n = [ 'username' => t ( 'Username' ) , 'emailAddress' => t ( 'Email Address' ) , 'chooseUser' => t ( 'Choose User' ) , 'noUsers' => t ( 'No users selected.' ) , ] ; $ searchLink = $ this -> app -> make ( ResolverManagerInterface :: class ) -> resolve ( [ '/ccm/system/dialogs/user/search' ] ) ; $ valn = $ this -> app -> make ( Numbers :: class ) ; $ userInfoRepository = $ this -> app -> make ( UserInfoRepository :: class ) ; $ preselectedUsers = '' ; foreach ( $ users as $ user ) { if ( $ valn -> integer ( $ user ) ) { $ user = $ userInfoRepository -> getById ( $ user ) ; } if ( is_object ( $ user ) ) { $ preselectedUsers .= <<<EOT<tr data-ccm-user-id="{$user->getUserID()}" class="ccm-list-record"> <td><input type="hidden" name="{$fieldName}[]" value="{$user->getUserID()}" />{$user->getUserName()}</td> <td>{$user->getUserEmail()}</td> <td><a href="#" class="ccm-user-list-clear icon-link"><i class="fa fa-minus-circle ccm-user-list-clear-button"></i></a></td></tr>EOT ; } } $ noUsersStyle = $ preselectedUsers === '' ? '' : ' style="display: none"' ; return <<<EOT<table id="ccmUserSelect-{$identifier}" class="table table-condensed" cellspacing="0" cellpadding="0" border="0"> <thead> <tr> <th>{$i18n['username']}</th> <th>{$i18n['emailAddress']}</th> <th style="width: 1px"><a class="icon-link ccm-user-select-item dialog-launch" dialog-append-buttons="true" dialog-width="90%" dialog-height="70%" dialog-modal="false" dialog-title="{$i18n['chooseUser']}" href="{$searchLink}"><i class="fa fa-plus-circle" /></a></th> </tr> </thead> <tbody> {$preselectedUsers} <tr class="ccm-user-selected-item-none"{$noUsersStyle}><td colspan="3">{$i18n['noUsers']}</td></tr> </tbody></table><script>$(function() { var container = $('#ccmUserSelect-{$identifier}'), noUsersRow = container.find('tr.ccm-user-selected-item-none'), updateNoUsers = function() { if (container.find('tr[data-ccm-user-id]').length === 0) { noUsersRow.show(); } else { noUsersRow.hide(); } }, userSelectCallback = function(e, data) { e.stopPropagation(); var uID = data.uID, uName = data.uName, uEmail = data.uEmail; if (container.find('tr[data-ccm-user-id=' + uID + ']').length > 0) { return; } noUsersRow.before($('<tr data-ccm-user-id="' + uID + '" class="ccm-list-record" />') .append($('<td />') .text(uName) .prepend($('<input type="hidden" name="{$fieldName}[]" />').val(uID)) ) .append($('<td />') .text(uEmail) ) .append($('<td><a href="#" class="ccm-user-list-clear icon-link"><i class="fa fa-minus-circle ccm-user-list-clear-button"></i></a></td>')) ); updateNoUsers(); }; container.on('click', 'a.ccm-user-list-clear', function(e) { e.preventDefault(); $(this).closest('tr').remove(); updateNoUsers(); }); container.find('.ccm-user-select-item') .dialog() .on('click', function(e) { ConcreteEvent.subscribe('UserSearchDialogSelectUser', userSelectCallback) }) ; ConcreteEvent.subscribe('UserSearchDialogAfterSelectUser', function(e) { ConcreteEvent.unsubscribe('UserSearchDialogSelectUser'); jQuery.fn.dialog.closeTop(); });});</script>EOT ; } | Build the HTML to be placed in a page to choose multiple users using a popup dialog . |
10,663 | public function highlightedMarkup ( $ fulltext , $ highlight ) { if ( ! $ highlight ) { return $ fulltext ; } $ this -> hText = $ fulltext ; $ this -> hHighlight = $ highlight ; $ this -> hText = @ preg_replace ( '#' . preg_quote ( $ this -> hHighlight , '#' ) . '#ui' , '<span style="background-color:' . $ this -> hColor . ';">$0</span>' , $ this -> hText ) ; return $ this -> hText ; } | Highlight parts of a text . |
10,664 | public function view ( ) { $ this -> set ( 'title' , $ this -> title ) ; $ this -> set ( 'buttonText' , $ this -> buttonText ) ; $ this -> set ( 'baseSearchPath' , $ this -> baseSearchPath ) ; $ this -> set ( 'postTo_cID' , $ this -> postTo_cID ) ; if ( ( string ) $ this -> resultsURL !== '' ) { $ resultsPage = null ; $ resultsURL = $ this -> resultsURL ; } else { $ resultsPage = $ this -> postTo_cID ? Page :: getById ( $ this -> postTo_cID ) : null ; if ( is_object ( $ resultsPage ) && ! $ resultsPage -> isError ( ) ) { $ resultsURL = $ resultsPage -> getCollectionPath ( ) ; } else { $ resultsPage = null ; $ c = Page :: getCurrentPage ( ) ; $ resultsURL = $ c -> getCollectionPath ( ) ; } } $ resultsURL = $ this -> app -> make ( 'helper/text' ) -> encodePath ( $ resultsURL ) ; $ this -> set ( 'resultTargetURL' , $ resultsURL ) ; if ( $ resultsPage !== null ) { $ this -> set ( 'resultTarget' , $ resultsPage ) ; } else { $ this -> set ( 'resultTarget' , $ resultsURL ) ; } if ( $ resultsPage === null && ( string ) $ this -> resultsURL === '' ) { if ( ( string ) $ this -> request -> request ( 'query' ) !== '' || $ this -> request -> request ( 'akID' ) || $ this -> request -> request ( 'month' ) ) { $ this -> do_search ( ) ; } } } | Default view method . |
10,665 | public static function getUsedExtensionList ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ stm = $ db -> executeQuery ( "select distinct fvExtension from FileVersions where fvIsApproved = 1 and fvExtension is not null and fvExtension <> ''" ) ; $ extensions = [ ] ; while ( $ row = $ stm -> fetch ( ) ) { $ extensions [ ] = $ row [ 'fvExtension' ] ; } return $ extensions ; } | Get the list of all the file extensions used by approved file versions . |
10,666 | public static function getUsedTypeList ( ) { $ app = Application :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ stm = $ db -> query ( 'select distinct fvType from FileVersions where fvIsApproved = 1 and fvType is not null and fvType <> 0' ) ; $ types = [ ] ; while ( $ row = $ stm -> fetch ( ) ) { $ types [ ] = ( int ) $ row [ 'fvType' ] ; } return $ types ; } | Get the list of all the file types used by approved file versions . |
10,667 | public function getThumbnail ( $ fullImageTag = true ) { $ app = Application :: getFacadeApplication ( ) ; $ config = $ app -> make ( 'config' ) ; $ type = ThumbnailType :: getByHandle ( $ config -> get ( 'concrete.icons.file_manager_listing.handle' ) ) ; if ( file_exists ( DIR_AL_ICONS . '/' . $ this -> getExtension ( ) . '.svg' ) ) { $ url = REL_DIR_AL_ICONS . '/' . $ this -> getExtension ( ) . '.svg' ; } else { $ url = AL_ICON_DEFAULT ; } if ( $ fullImageTag == true ) { return sprintf ( '<img src="%s" width="%s" height="%s" class="img-responsive ccm-generic-thumbnail" alt="%s">' , $ url , $ type -> getWidth ( ) , $ type -> getHeight ( ) , t ( '%s file icon' , mb_strtoupper ( $ this -> getExtension ( ) ) ) ) ; } else { return $ url ; } } | Returns a thumbnail for this type of file . |
10,668 | public static function getGenericTypeText ( $ type ) { switch ( $ type ) { case static :: T_IMAGE : return t ( 'Image' ) ; break ; case static :: T_VIDEO : return t ( 'Video' ) ; break ; case static :: T_TEXT : return t ( 'Text' ) ; break ; case static :: T_AUDIO : return t ( 'Audio' ) ; break ; case static :: T_DOCUMENT : return t ( 'Document' ) ; break ; case static :: T_APPLICATION : return t ( 'Application' ) ; break ; case static :: T_UNKNOWN : return t ( 'File' ) ; break ; } } | Get the name of a generic file type . |
10,669 | public function revokeRefreshToken ( $ tokenId ) { $ this -> getEntityManager ( ) -> transactional ( function ( EntityManagerInterface $ em ) use ( $ tokenId ) { $ token = $ this -> find ( $ tokenId ) ; if ( $ token ) { $ em -> remove ( $ token ) ; } } ) ; } | Revoke the refresh token . |
10,670 | private function updateSize ( Version $ fv , ImageInterface $ image ) { $ result = false ; try { $ size = $ image -> getSize ( ) ; } catch ( Exception $ x ) { $ size = null ; } catch ( Throwable $ x ) { $ size = null ; } if ( $ size !== null ) { $ attributeCategory = $ fv -> getObjectAttributeCategory ( ) ; $ atWidth = $ attributeCategory -> getAttributeKeyByHandle ( 'width' ) ; if ( $ atWidth !== null ) { $ fv -> setAttribute ( $ atWidth , $ size -> getWidth ( ) ) ; } $ atHeight = $ attributeCategory -> getAttributeKeyByHandle ( 'height' ) ; if ( $ atHeight !== null ) { $ fv -> setAttribute ( $ atHeight , $ size -> getHeight ( ) ) ; } $ result = true ; } return $ result ; } | Update the width and height attributes of the file version starting from the image data . |
10,671 | public function logFailedLogin ( AddressInterface $ ip = null , $ ignoreConfig = false ) { if ( $ ignoreConfig || $ this -> config -> get ( 'concrete.security.ban.ip.enabled' ) ) { if ( $ ip === null ) { $ ip = $ this -> getRequestIPAddress ( ) ; } $ comparableIP = $ ip -> getComparableString ( ) ; $ this -> connection -> executeQuery ( ' INSERT INTO FailedLoginAttempts (flaIp, flaTimestamp) VALUES (?, ' . $ this -> connection -> getDatabasePlatform ( ) -> getNowExpression ( ) . ') ' , [ $ ip -> getComparableString ( ) ] ) ; $ this -> logger -> notice ( t ( 'Failed login attempt recorded from IP address %s' , $ ip -> toString ( ) , [ 'ip_address' => $ ip -> toString ( ) ] ) ) ; } } | Add the current IP address to the list of IPs with failed login attempts . |
10,672 | public function failedLoginsThresholdReached ( AddressInterface $ ip = null , $ ignoreConfig = false ) { $ result = false ; if ( $ ignoreConfig || $ this -> config -> get ( 'concrete.security.ban.ip.enabled' ) ) { if ( $ ip === null ) { $ ip = $ this -> getRequestIPAddress ( ) ; } if ( ! $ this -> isWhitelisted ( $ ip ) ) { $ thresholdSeconds = ( int ) $ this -> config -> get ( 'concrete.security.ban.ip.time' ) ; $ thresholdTimestamp = new DateTime ( "-{$thresholdSeconds} seconds" ) ; $ rs = $ this -> connection -> executeQuery ( ' SELECT ' . $ this -> connection -> getDatabasePlatform ( ) -> getCountExpression ( 'lcirID' ) . ' AS n FROM FailedLoginAttempts WHERE flaIp = ? AND flaTimestamp > ? ' , [ $ ip -> getComparableString ( ) , $ thresholdTimestamp -> format ( $ this -> connection -> getDatabasePlatform ( ) -> getDateTimeFormatString ( ) ) ] ) ; $ count = $ rs -> fetchColumn ( ) ; $ rs -> closeCursor ( ) ; $ thresholdAttempts = ( int ) $ this -> config -> get ( 'concrete.security.ban.ip.attempts' ) ; if ( $ count !== false && ( int ) $ count >= $ thresholdAttempts ) { $ result = true ; } } } return $ result ; } | Check if the current IP address has reached the failed login attempts threshold . |
10,673 | public function addToBlacklistForThresholdReached ( AddressInterface $ ip = null , $ ignoreConfig = false ) { if ( $ ignoreConfig || $ this -> config -> get ( 'concrete.security.ban.ip.enabled' ) ) { if ( $ ip === null ) { $ ip = $ this -> getRequestIPAddress ( ) ; } $ banDurationMinutes = ( int ) $ this -> config -> get ( 'concrete.security.ban.ip.length' ) ; if ( $ banDurationMinutes > 0 ) { $ expires = new DateTime ( "+{$banDurationMinutes} minutes" ) ; } else { $ expires = null ; } $ this -> createRange ( IPFactory :: rangeFromBoundaries ( $ ip , $ ip ) , static :: IPRANGETYPE_BLACKLIST_AUTOMATIC , $ expires ) ; $ this -> logger -> warning ( t ( 'IP address %s added to blacklist.' , $ ip -> toString ( ) , $ expires ) , [ 'ip_address' => $ ip -> toString ( ) ] ) ; } } | Add an IP address to the list of IPs banned for too many failed login attempts . |
10,674 | public function createRange ( RangeInterface $ range , $ type , DateTime $ expiration = null ) { $ dateTimeFormat = $ this -> connection -> getDatabasePlatform ( ) -> getDateTimeFormatString ( ) ; $ this -> connection -> executeQuery ( ' INSERT INTO LoginControlIpRanges (lcirIpFrom, lcirIpTo, lcirType, lcirExpires) VALUES (?, ?, ?, ?) ' , [ $ range -> getComparableStartString ( ) , $ range -> getComparableEndString ( ) , $ type , ( $ expiration === null ) ? null : $ expiration -> format ( $ dateTimeFormat ) , ] ) ; $ id = $ this -> connection -> lastInsertId ( ) ; $ rs = $ this -> connection -> executeQuery ( 'SELECT * FROM LoginControlIpRanges WHERE lcirID = ? LIMIT 1' , [ $ id ] ) ; $ row = $ rs -> fetch ( ) ; $ rs -> closeCursor ( ) ; return IPRange :: createFromRow ( $ row , $ dateTimeFormat ) ; } | Add persist an IP address range type . |
10,675 | public function getRanges ( $ type , $ includeExpired = false ) { $ sql = 'SELECT * FROM LoginControlIpRanges WHERE lcirType = ?' ; $ params = [ ( int ) $ type ] ; if ( ! $ includeExpired ) { $ sql .= ' AND (lcirExpires IS NULL OR lcirExpires > ' . $ this -> connection -> getDatabasePlatform ( ) -> getNowExpression ( ) . ')' ; } $ sql .= ' ORDER BY lcirID' ; $ result = [ ] ; $ dateTimeFormat = $ this -> connection -> getDatabasePlatform ( ) -> getDateTimeFormatString ( ) ; $ rs = $ this -> connection -> executeQuery ( $ sql , $ params ) ; while ( ( $ row = $ rs -> fetch ( ) ) !== false ) { yield IPRange :: createFromRow ( $ row , $ dateTimeFormat ) ; } } | Get the list of currently available ranges . |
10,676 | public function getRangeByID ( $ id ) { $ result = null ; if ( $ id ) { $ rs = $ this -> connection -> executeQuery ( 'SELECT * FROM LoginControlIpRanges WHERE lcirID = ? LIMIT 1' , [ $ id ] ) ; $ row = $ rs -> fetch ( ) ; $ rs -> closeCursor ( ) ; if ( $ row !== false ) { $ result = IPRange :: createFromRow ( $ row , $ this -> connection -> getDatabasePlatform ( ) -> getDateTimeFormatString ( ) ) ; } } return $ result ; } | Find already defined range given its record ID . |
10,677 | public function deleteRange ( $ range ) { if ( $ range instanceof IPRange ) { $ id = $ range -> getID ( ) ; } else { $ id = ( int ) $ range ; } if ( $ id ) { $ this -> connection -> executeQuery ( 'DELETE FROM LoginControlIpRanges WHERE lcirID = ? LIMIT 1' , [ $ id ] ) ; } } | Delete a range record . |
10,678 | public function deleteFailedLoginAttempts ( $ maxAge = null ) { $ sql = 'DELETE FROM FailedLoginAttempts' ; if ( $ maxAge ) { $ platform = $ this -> connection -> getDatabasePlatform ( ) ; $ sql .= ' WHERE flaTimestamp <= ' . $ platform -> getDateSubSecondsExpression ( $ platform -> getNowExpression ( ) , ( int ) $ maxAge ) ; } return ( int ) $ this -> connection -> executeQuery ( $ sql ) -> rowCount ( ) ; } | Delete the failed login attempts . |
10,679 | public function deleteAutomaticBlacklist ( $ onlyExpired = true ) { $ sql = 'DELETE FROM LoginControlIpRanges WHERE lcirType = ' . ( int ) static :: IPRANGETYPE_BLACKLIST_AUTOMATIC ; if ( $ onlyExpired ) { $ platform = $ this -> connection -> getDatabasePlatform ( ) ; $ sql .= ' AND lcirExpires <= ' . $ platform -> getNowExpression ( ) ; } return ( int ) $ this -> connection -> executeQuery ( $ sql ) -> rowCount ( ) ; } | Clear the IP addresses automatically blacklisted . |
10,680 | private function fixPlurals ( $ filename , TextDomain $ textDomain , Language $ localeInfo ) { $ expectedNumPlurals = count ( $ localeInfo -> categories ) ; $ pluralRule = $ textDomain -> getPluralRule ( false ) ; if ( $ pluralRule === null ) { $ pluralRule = Rule :: fromString ( "nplurals={$expectedNumPlurals}; plural={$localeInfo->formula};" ) ; $ textDomain -> setPluralRule ( $ pluralRule ) ; } else { $ readNumPlurals = $ pluralRule -> getNumPlurals ( ) ; if ( $ expectedNumPlurals < $ readNumPlurals ) { $ pluralRule = Rule :: fromString ( "nplurals={$expectedNumPlurals}; plural={$localeInfo->formula};" ) ; $ textDomain -> setPluralRule ( $ pluralRule ) ; } elseif ( $ expectedNumPlurals > $ readNumPlurals ) { $ filename = str_replace ( DIRECTORY_SEPARATOR , '/' , $ filename ) ; if ( strpos ( $ filename , $ this -> webrootDirectory . '/' ) === 0 ) { $ filename = substr ( $ filename , strlen ( $ this -> webrootDirectory ) ) ; } throw new RuntimeException ( sprintf ( $ readNumPlurals === 1 ? 'The language file %1$s for %2$s has %3$s plural form instead of %4$s.' : 'The language file %1$s for %2$s has %3$s plural forms instead of %4$s.' , $ filename , $ localeInfo -> name , $ readNumPlurals , $ expectedNumPlurals ) ) ; } } return $ textDomain ; } | Fix the plural rules of the translations loaded from a file . |
10,681 | public function getResultIDs ( ) { $ results = $ this -> executeGetResults ( ) ; $ ids = [ ] ; foreach ( $ results as $ result ) { $ ids [ ] = $ result [ 'uID' ] ; } return $ ids ; } | similar to get except it returns an array of userIDs much faster than getting a UserInfo object for each result if all you need is the user s id . |
10,682 | public function filterByIsActive ( $ isActive ) { $ this -> includeInactiveUsers ( ) ; $ this -> query -> andWhere ( 'u.uIsActive = :uIsActive' ) ; $ this -> query -> setParameter ( 'uIsActive' , $ isActive ) ; } | Explicitly filters by whether a user is active or not . Does this by setting include inactive users to true THEN filtering them in our out . Some settings here are redundant given the default settings but a little duplication is ok sometimes . |
10,683 | public function filterByIsValidated ( $ isValidated ) { $ this -> includeInactiveUsers ( ) ; if ( ! $ isValidated ) { $ this -> includeUnvalidatedUsers ( ) ; $ this -> query -> andWhere ( 'u.uIsValidated = :uIsValidated' ) ; $ this -> query -> setParameter ( 'uIsValidated' , $ isValidated ) ; } } | Filter list by whether a user is validated or not . |
10,684 | public function filterByFuzzyUserName ( $ username ) { $ this -> query -> andWhere ( $ this -> query -> expr ( ) -> like ( 'u.uName' , ':uName' ) ) ; $ this -> query -> setParameter ( 'uName' , $ username . '%' ) ; } | Filter list by user name but as a like parameter . |
10,685 | private function checkGroupJoin ( ) { $ query = $ this -> getQueryObject ( ) ; $ params = $ query -> getQueryPart ( 'join' ) ; $ isGroupSet = false ; $ isUserGroupSet = false ; foreach ( $ params as $ param ) { foreach ( $ param as $ setTable ) if ( in_array ( 'ug' , $ setTable ) ) { $ isUserGroupSet = true ; } if ( in_array ( 'g' , $ setTable ) ) { $ isGroupSet = true ; } } if ( $ isUserGroupSet === false ) { $ query -> leftJoin ( 'u' , 'UserGroups' , 'ug' , 'ug.uID = u.uID' ) ; } if ( $ isGroupSet === false ) { $ query -> leftJoin ( 'ug' , $ query -> getConnection ( ) -> getDatabasePlatform ( ) -> quoteSingleIdentifier ( 'Groups' ) , 'g' , 'ug.gID = g.gID' ) ; } } | Function used to check if a group join has already been set |
10,686 | public function filterByInAnyGroup ( $ groups , $ inGroups = true ) { $ this -> checkGroupJoin ( ) ; $ groupIDs = [ ] ; $ orX = $ this -> getQueryObject ( ) -> expr ( ) -> orX ( ) ; $ app = Application :: getFacadeApplication ( ) ; $ likeBuilder = $ app -> make ( LikeBuilder :: class ) ; $ query = $ this -> getQueryObject ( ) -> getConnection ( ) -> createQueryBuilder ( ) ; foreach ( $ groups as $ group ) { if ( $ group instanceof \ Concrete \ Core \ User \ Group \ Group ) { $ orX -> add ( $ this -> getQueryObject ( ) -> expr ( ) -> like ( 'g.gPath' , ':groupPathChild_' . $ group -> getGroupID ( ) ) ) ; $ this -> getQueryObject ( ) -> setParameter ( 'groupPathChild_' . $ group -> getGroupID ( ) , $ likeBuilder -> escapeForLike ( $ group -> getGroupPath ( ) ) . '/%' ) ; $ groupIDs [ ] = $ group -> getGroupID ( ) ; } } if ( is_array ( $ groups ) && count ( $ groups ) > 0 ) { $ query -> select ( 'u.uID' ) -> from ( 'Users' , 'u' ) -> leftJoin ( 'u' , 'UserGroups' , 'ug' , 'u.uID=ug.uID' ) -> leftJoin ( 'ug' , $ query -> getConnection ( ) -> getDatabasePlatform ( ) -> quoteSingleIdentifier ( 'Groups' ) , 'g' , 'ug.gID=g.gID' ) ; $ orX -> add ( $ this -> getQueryObject ( ) -> expr ( ) -> in ( 'g.gID' , $ groupIDs ) ) ; $ query -> where ( $ orX ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> isNotNull ( 'g.gID' ) ) ; if ( $ inGroups ) { $ this -> getQueryObject ( ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> in ( 'u.uID' , $ query -> getSQL ( ) ) ) ; } else { $ this -> getQueryObject ( ) -> andWhere ( $ this -> getQueryObject ( ) -> expr ( ) -> notIn ( 'u.uID' , $ query -> getSQL ( ) ) ) ; $ this -> getQueryObject ( ) -> setParameter ( 'groupIDs' , $ groupIDs , \ Concrete \ Core \ Database \ Connection \ Connection :: PARAM_INT_ARRAY ) ; } } } | Filters the user list for only users within at least one of the provided groups . |
10,687 | protected function loadPictureSettingsFromTheme ( ) { $ c = Page :: getCurrentPage ( ) ; if ( is_object ( $ c ) ) { $ pt = $ c -> getPageController ( ) -> getTheme ( ) ; if ( is_object ( $ pt ) ) { $ pt = $ pt -> getThemeHandle ( ) ; } $ th = Theme :: getByHandle ( $ pt ) ; if ( is_object ( $ th ) ) { $ this -> theme = $ th ; $ this -> usePictureTag = count ( $ th -> getThemeResponsiveImageMap ( ) ) > 0 ; } } } | Load picture settings from the theme . |
10,688 | public function clear ( ) { $ pageCategory = $ this -> app [ PageCategory :: class ] ; foreach ( $ pageCategory -> getList ( ) as $ key ) { $ indexer = $ key -> getSearchIndexer ( ) ; $ indexer -> updateSearchIndexKeyColumns ( $ pageCategory , $ key ) ; } $ database = $ this -> app [ 'database' ] -> connection ( ) ; $ database -> Execute ( 'truncate table PageSearchIndex' ) ; } | Clear out all indexed items |
10,689 | public function getJobQueueBatchSize ( ) { if ( $ this -> jQueueBatchSize === null ) { $ this -> jQueueBatchSize = Config :: get ( 'concrete.limits.job_queue_batch' ) ; } return $ this -> jQueueBatchSize ; } | Get the size of the queue batches |
10,690 | public function getQueueObject ( ) { if ( $ this -> jQueueObject === null ) { $ this -> jQueueObject = Queue :: get ( 'job_' . $ this -> getJobHandle ( ) , array ( 'timeout' => 1 ) ) ; } return $ this -> jQueueObject ; } | Get the queue object we re going to use to queue |
10,691 | public function markCompleted ( $ code = 0 , $ message = false ) { $ obj = parent :: markCompleted ( $ code , $ message ) ; $ queue = $ this -> getQueueObject ( ) ; if ( ! $ this -> didFail ( ) ) { $ queue -> deleteQueue ( ) ; } return $ obj ; } | Mark the queue as having completed |
10,692 | public function executeJob ( ) { if ( $ this -> getJobStatus ( ) !== 'RUNNING' ) { $ queue = $ this -> markStarted ( ) ; $ this -> start ( $ queue ) ; } else { $ queue = $ this -> getQueueObject ( ) ; } try { $ batchSize = $ this -> getJobQueueBatchSize ( ) ? : PHP_INT_MAX ; while ( ( $ messages = $ queue -> receive ( $ batchSize ) ) && $ messages -> count ( ) > 0 ) { $ this -> executeBatch ( $ messages , $ queue ) ; } $ output = $ this -> finish ( $ queue ) ; $ result = $ this -> markCompleted ( 0 , $ output ) ; } catch ( \ Exception $ e ) { $ result = $ this -> markCompleted ( Job :: JOB_ERROR_EXCEPTION_GENERAL , $ e -> getMessage ( ) ) ; $ result -> message = $ result -> result ; } return $ result ; } | Executejob for queueable jobs actually starts the queue runs and ends all in one function . This happens if we run a job in legacy mode . |
10,693 | public function executeBatch ( $ batch , ZendQueue $ queue ) { foreach ( $ batch as $ item ) { $ this -> processQueueItem ( $ item ) ; $ queue -> deleteMessage ( $ item ) ; } } | Process a queue batch |
10,694 | public static function getActive ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ sclHandle = $ db -> fetchColumn ( 'select sclHandle from SystemCaptchaLibraries where sclIsActive = 1' ) ; return ( $ sclHandle === false ) ? null : static :: getByHandle ( $ sclHandle ) ; } | Get the active library . |
10,695 | public static function getByHandle ( $ sclHandle ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ r = $ db -> fetchAssoc ( 'select sclHandle, sclIsActive, pkgID, sclName from SystemCaptchaLibraries where sclHandle = ?' , [ $ sclHandle ] ) ; if ( $ r !== false ) { $ sc = new static ( ) ; $ sc -> setPropertiesFromArray ( $ r ) ; return $ sc ; } } | Get a library given its handle . |
10,696 | public static function add ( $ sclHandle , $ sclName , $ pkg = false ) { if ( is_object ( $ pkg ) ) { $ pkgID = $ pkg -> getPackageID ( ) ; } else { $ pkgID = ( int ) $ pkg ; } $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ db -> executeQuery ( 'insert into SystemCaptchaLibraries (sclHandle, sclName, pkgID) values (?, ?, ?)' , [ $ sclHandle , $ sclName , $ pkgID ] ) ; return static :: getByHandle ( $ sclHandle ) ; } | Add a new library . |
10,697 | public function activate ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ db -> executeQuery ( 'update SystemCaptchaLibraries set sclIsActive = 0' ) ; $ db -> executeQuery ( 'update SystemCaptchaLibraries set sclIsActive = 1 where sclHandle = ?' , [ $ this -> sclHandle ] ) ; $ this -> sclIsActive = 1 ; } | Make this library the active one . |
10,698 | public static function getList ( ) { $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ libraries = [ ] ; foreach ( $ db -> fetchAll ( 'select sclHandle from SystemCaptchaLibraries order by sclHandle asc' ) as $ row ) { $ scl = static :: getByHandle ( $ row [ 'sclHandle' ] ) ; $ libraries [ ] = $ scl ; } return $ libraries ; } | Retrieve all the installed libraries . |
10,699 | public static function getListByPackage ( $ pkg ) { if ( is_object ( $ pkg ) ) { $ pkgID = $ pkg -> getPackageID ( ) ; } else { $ pkgID = ( int ) $ pkg ; } $ app = Facade :: getFacadeApplication ( ) ; $ db = $ app -> make ( 'database' ) -> connection ( ) ; $ libraries = [ ] ; foreach ( $ db -> fetchAll ( 'select sclHandle from SystemCaptchaLibraries where pkgID = ? order by sclHandle asc' , [ $ pkgID ] ) as $ row ) { $ scl = static :: getByHandle ( $ row [ 'sclHandle' ] ) ; $ libraries [ ] = $ scl ; } return $ libraries ; } | Retrieve the libraries installed by a package . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.