public function getAuthenticationType() { if (!$this->authenticationType) { $this->authenticationType = \AuthenticationType::getByHandle($this->getHandle()); } return $this->authenticationType; }
public function callback($type, $method = 'callback') { $at = AuthenticationType::getByHandle($type); $this->view(); if (!method_exists($at->controller, $method)) { throw new exception('Invalid method.'); } if ($method != 'callback') { if (!is_array($at->controller->apiMethods) || !in_array($method, $at->controller->apiMethods)) { throw new Exception("Invalid method."); } } try { $message = call_user_method($method, $at->controller); if (trim($message)) { $this->set('message', $message); } } catch (exception $e) { if ($e instanceof AuthenticationTypeFailureException) { // Throw again if this is a big`n throw $e; } $this->error->add($e->getMessage()); } }
/** * @param \UserInfo $uo * @return bool * @throws \Exception */ public function getAuthTypeImagePath($uo) { $lat = $uo->getUserObject()->getLastAuthType(); if ($lat > 1) { try { $at = AuthenticationType::getByID($lat); if (method_exists($at->controller, 'getUserImagePath')) { $uimgpath = $at->controller->getUserImagePath($uo); return $uimgpath; } } catch (\Exception $e) { } } return false; }
public function up(Schema $schema) { /* refresh CollectionVersionBlocks, CollectionVersionBlocksCacheSettings tables */ $cvb = $schema->getTable('CollectionVersionBlocks'); $cvb->addColumn('cbOverrideBlockTypeCacheSettings', 'boolean', array('default' => 0)); $cvbcs = $schema->createTable('CollectionVersionBlocksCacheSettings'); $cvbcs->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->addColumn('cvID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 1)); $cvbcs->addColumn('bID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->addColumn('arHandle', 'string', array('notnull' => false)); $cvbcs->addColumn('btCacheBlockOutput', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputOnPost', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputForRegisteredUsers', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputLifetime', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->setPrimaryKey(array('cID', 'cvID', 'bId', 'arHandle')); /* add permissions lines for edit_block_name and edit_block_cache_settings */ $ebk = Key::getByHandle('edit_block_name'); if (!is_object($ebk)) { Key::add('block', 'edit_block_name', 'Edit Name', "Controls whether users can change the block's name (rarely used.).", false, false); } $ebk = Key::getByHandle('edit_block_cache_settings'); if (!is_object($ebk)) { Key::add('block', 'edit_block_cache_settings', 'Edit Cache Settings', "Controls whether users can change the block cache settings for this block instance.", false, false); } /* Add marketplace single pages */ $sp = Page::getByPath('/dashboard/extend/connect'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/connect'); $sp->update(array('cName' => 'Connect to the Community')); $sp->setAttribute('meta_keywords', 'concrete5.org, my account, marketplace'); } $sp = Page::getByPath('/dashboard/extend/themes'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/themes'); $sp->update(array('cName' => 'Get More Themes')); $sp->setAttribute('meta_keywords', 'buy theme, new theme, marketplace, template'); } $sp = Page::getByPath('/dashboard/extend/addons'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/addons'); $sp->update(array('cName' => 'Get More Add-Ons')); $sp->setAttribute('meta_keywords', 'buy addon, buy add on, buy add-on, purchase addon, purchase add on, purchase add-on, find addon, new addon, marketplace'); } /* Add auth types ("handle|name") "twitter|Twitter" and "community|concrete5.org" */ try { $community = AuthenticationType::getByHandle('community'); } catch (Exception $e) { $community = AuthenticationType::add('community', 'concrete5.org'); if (is_object($community)) { $community->disable(); } } try { $twitter = AuthenticationType::getByHandle('twitter'); } catch (Exception $e) { $twitter = AuthenticationType::add('twitter', 'Twitter'); if (is_object($twitter)) { $twitter->disable(); } } /* delete customize page themes dashboard single page */ $customize = Page::getByPath('/dashboard/pages/themes/customize'); if (is_object($customize) && !$customize->isError()) { $customize->delete(); } /* exclude nav from flat view in dashboard */ $flat = Page::getByPath('/dashboard/sitemap/explore'); if (is_object($customize) && !$customize->isError()) { $flat->setAttribute("exclude_nav", false); } }
public function verifyAuthTypeCookie() { if ($_COOKIE['ccmAuthUserHash']) { list($_uID, $authType, $uHash) = explode(':', $_COOKIE['ccmAuthUserHash']); $at = AuthenticationType::getByHandle($authType); $u = User::getByUserID($_uID); if (!is_object($u) || $u->isError()) { return; } if ($at->controller->verifyHash($u, $uHash)) { User::loginByUserID($_uID); } } }
public function fill_attributes() { try { $session = $this->app->make('session'); if (!$session->has('uRequiredAttributeUser') || intval($session->get('uRequiredAttributeUser')) < 1 || !$session->has('uRequiredAttributeUserAuthenticationType') || !$session->get('uRequiredAttributeUserAuthenticationType')) { $session->remove('uRequiredAttributeUser'); $session->remove('uRequiredAttributeUserAuthenticationType'); throw new \Exception(t('Invalid Request, please attempt login again.')); } User::loginByUserID($session->get('uRequiredAttributeUser')); $session->remove('uRequiredAttributeUser'); $u = new User(); $at = AuthenticationType::getByHandle($session->get('uRequiredAttributeUserAuthenticationType')); $session->remove('uRequiredAttributeUserAuthenticationType'); if (!$at) { throw new \Exception(t("Invalid Authentication Type")); } $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); $unfilled = array_values(array_filter($aks, function ($ak) use($ui) { return $ak->isAttributeKeyRequiredOnRegister() && !is_object($ui->getAttributeValueObject($ak)); })); $saveAttributes = array(); foreach ($unfilled as $attribute) { $controller = $attribute->getController(); $validator = $controller->getValidator(); $response = $validator->validateSaveValueRequest($controller, $this->request); /** * @var $response ResponseInterface */ if ($response->isValid()) { $saveAttributes[] = $attribute; } else { $error = $response->getErrorObject(); $this->error->add($error); } } if (count($saveAttributes) > 0) { $ui->saveUserAttributesForm($saveAttributes); } return $this->finishAuthentication($at); } catch (\Exception $e) { $this->error->add($e->getMessage()); } }
public function getPackageItems(Package $package) { return \Concrete\Core\Authentication\AuthenticationType::getListByPackage($package); }
public function fill_attributes() { try { if (!Session::has('uRequiredAttributeUser') || intval(Session::get('uRequiredAttributeUser')) < 1 || !Session::has('uRequiredAttributeUserAuthenticationType') || !Session::get('uRequiredAttributeUserAuthenticationType')) { Session::remove('uRequiredAttributeUser'); Session::remove('uRequiredAttributeUserAuthenticationType'); throw new \Exception(t('Invalid Request, please attempt login again.')); } User::loginByUserID(Session::get('uRequiredAttributeUser')); Session::remove('uRequiredAttributeUser'); $u = new User(); $at = AuthenticationType::getByHandle(Session::get('uRequiredAttributeUserAuthenticationType')); Session::remove('uRequiredAttributeUserAuthenticationType'); if (!$at) { throw new \Exception(t("Invalid Authentication Type")); } $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); $unfilled = array_values(array_filter($aks, function ($ak) use($ui) { return $ak->isAttributeKeyRequiredOnRegister() && !is_object($ui->getAttributeValueObject($ak)); })); $saveAttributes = array(); foreach ($unfilled as $attribute) { $err = $attribute->validateAttributeForm(); if ($err == false) { $this->error->add(t('The field "%s" is required', $attribute->getAttributeKeyDisplayName())); } elseif ($err instanceof \Concrete\Core\Error\Error) { $this->error->add($err); } else { $saveAttributes[] = $attribute; } } if (count($saveAttributes) > 0) { $ui->saveUserAttributesForm($saveAttributes); } $this->finishAuthentication($at); } catch (\Exception $e) { $this->error->add($e->getMessage()); } }
/** * Returns an array of package items (e.g. blocks, themes) * @return array */ public function getPackageItems() { $items = array(); $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this); $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this); $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this); $items['attribute_keys'] = AttributeKey::getListByPackage($this); $items['attribute_sets'] = AttributeSet::getListByPackage($this); $items['group_sets'] = GroupSet::getListByPackage($this); $items['page_types'] = PageType::getListByPackage($this); $items['page_templates'] = PageTemplate::getListByPackage($this); $items['mail_importers'] = MailImporter::getListByPackage($this); $items['gathering_item_template_types'] = GatheringItemTemplateType::getListByPackage($this); $items['gathering_item_templates'] = GatheringItemTemplate::getListByPackage($this); $items['gathering_data_sources'] = GatheringDataSource::getListByPackage($this); $items['features'] = Feature::getListByPackage($this); $items['feature_categories'] = FeatureCategory::getListByPackage($this); $btl = new BlockTypeList(); $btl->filterByPackage($this); $blocktypes = $btl->get(); $items['block_types'] = $blocktypes; $items['block_type_sets'] = BlockTypeSet::getListByPackage($this); $items['page_themes'] = PageTheme::getListByPackage($this); $items['permissions'] = PermissionKey::getListByPackage($this); $items['single_pages'] = SinglePage::getListByPackage($this); $items['attribute_types'] = AttributeType::getListByPackage($this); $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this); $items['content_editor_snippets'] = SystemContentEditorSnippet::getListByPackage($this); $items['conversation_editors'] = ConversationEditor::getListByPackage($this); $items['conversation_rating_types'] = ConversationRatingType::getListByPackage($this); $items['page_type_publish_target_types'] = PageTypePublishTargetType::getListByPackage($this); $items['page_type_composer_control_types'] = PageTypeComposerControlType::getListByPackage($this); $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this); $items['community_point_actions'] = UserPointAction::getListByPackage($this); $items['jobs'] = Job::getListByPackage($this); $items['workflow_types'] = WorkflowType::getListByPackage($this); $items['workflow_progress_categories'] = WorkflowProgressCategory::getListByPackage($this); $items['authentication_types'] = AuthenticationType::getListByPackage($this); $items['storage_locations'] = StorageLocation::getListByPackage($this); ksort($items); return $items; }
public function setPropertiesFromArray($arr) { return parent::setPropertiesFromArray($arr); }
public function configurePackage($pkg) { $theme = Theme::getByHandle('worldskills'); if (!is_object($theme)) { $theme = Theme::add('worldskills', $pkg); } // add skill ID attribute $attributeKey = CollectionAttributeKey::getByHandle('worldskills_skill_id'); if (!is_object($attributeKey)) { $type = AttributeType::getByHandle('text'); $args = array('akHandle' => 'worldskills_skill_id', 'akName' => t('Skill ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1); CollectionAttributeKey::add($type, $args, $pkg); } // add skill page type $pageType = \PageType::getByHandle('worldskills_skill'); if (!is_object($pageType)) { $template = \PageTemplate::getByHandle('full'); \PageType::add(array('handle' => 'worldskills_skill', 'name' => 'Skill', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all'))); } // add member ID attribute $attributeKey = CollectionAttributeKey::getByHandle('worldskills_member_id'); if (!is_object($attributeKey)) { $type = AttributeType::getByHandle('text'); $args = array('akHandle' => 'worldskills_member_id', 'akName' => t('Member ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1); CollectionAttributeKey::add($type, $args, $pkg); } // add member page type $pageType = \PageType::getByHandle('worldskills_member'); if (!is_object($pageType)) { $template = \PageTemplate::getByHandle('full'); \PageType::add(array('handle' => 'worldskills_member', 'name' => 'Member', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all'))); } // add skill block $blockType = \BlockType::getByHandle('worldskills_skill'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_skill', $pkg); } // add skill list block $blockType = \BlockType::getByHandle('worldskills_skill_list'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_skill_list', $pkg); } // add people block $blockType = \BlockType::getByHandle('worldskills_people'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_people', $pkg); } // add member block $blockType = \BlockType::getByHandle('worldskills_member'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_member', $pkg); } // add member list block $blockType = \BlockType::getByHandle('worldskills_member_list'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_member_list', $pkg); } try { $authenticationType = AuthenticationType::getByHandle('worldskills'); } catch (\Exception $e) { $authenticationType = AuthenticationType::add('worldskills', 'WorldSkills Auth', 0, $pkg); $authenticationType->disable(); } $page = \SinglePage::add('/dashboard/system/basics/worldskills', $pkg); if (is_object($pag)) { $page->updateCollectionName('WorldSkills'); } \Config::save('worldskills.api_url', \Config::get('worldskills.api_url', 'https://api.worldskills.org')); \Config::save('worldskills.authorize_url', \Config::get('worldskills.authorize_url', 'https://auth.worldskills.org')); }
public function install() { $pkg = parent::install(); \Concrete\Core\Authentication\AuthenticationType::add('ldap', 'Ldap', 0, $pkg); }
/** * Return loaded AuthenticationType with the given ID. * @param int $authTypeID * @throws \Exception * @return AuthenticationType */ public static function getByID($authTypeID) { $db = Loader::db(); $row = $db->GetRow('SELECT * FROM AuthenticationTypes where authTypeID=?', array($authTypeID)); if (!$row) { throw new Exception(t('Invalid Authentication Type ID')); } $at = AuthenticationType::load($row); $at->loadController(); return $at; }