/** * @param $upaHandle * @return UserPointAction */ public static function getByHandle($upaHandle) { $db = Loader::db(); $row = $db->getRow("SELECT * FROM UserPointActions WHERE upaHandle = ?", array($upaHandle)); if ($row['upaID']) { $class = 'UserPointAction'; if ($row['upaHasCustomClass']) { $pkgHandle = false; if ($row['pkgID']) { $pkgHandle = PackageList::getHandle($row['pkgID']); } $class = Loader::helper('text')->camelcase($row['upaHandle']) . $class; } $upa = new Action(); $upa->setDataFromArray($row); return $upa; } }
public function testAddingBadgeToUser() { \Cache::disableAll(); \Config::set('concrete.email.enabled', false); \Config::set('concrete.log.emails', false); Action::add('won_badge', t('Won a Badge'), 5, false); $g = Group::add('Test Group', 'Gettin a Badge'); $g->setBadgeOptions(0, 'test', 10); $g = Group::getByID(1); $user = \Concrete\Core\User\UserInfo::add(array('uName' => 'testuser', 'uEmail' => '*****@*****.**')); $uo = $user->getUserObject(); $uo->enterGroup($g); \Config::clear('concrete.email.enabled'); \Config::clear('concrete.log.emails'); $list = new EntryList(); $list->filterbyUserName('testuser'); $results = $list->get(); $this->assertEquals(1, count($results)); $result = $results[0]; $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Entry', $result); /* @var $result \Concrete\Core\User\Point\Entry */ $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeAction', $result->getUserPointEntryActionObject()); $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeActionDescription', $result->getUserPointEntryDescriptionObject()); }
public function getUserPointEntryActionObject() { return UserPointAction::getByID($this->getUserPointEntryActionID()); }
public function add_users() { // Firstly, install the core authentication types $cba = AuthenticationType::add('concrete', 'Standard'); $coa = AuthenticationType::add('community', 'concrete5.org'); $fba = AuthenticationType::add('facebook', 'Facebook'); $twa = AuthenticationType::add('twitter', 'Twitter'); $gat = AuthenticationType::add('google', 'Google'); $fba->disable(); $twa->disable(); $coa->disable(); $gat->disable(); \Concrete\Core\Tree\TreeType::add('group'); \Concrete\Core\Tree\Node\NodeType::add('group'); $tree = GroupTree::get(); $tree = GroupTree::add(); // insert the default groups // create the groups our site users // specify the ID's since auto increment may not always be +1 $g1 = Group::add(tc("GroupName", "Guest"), tc("GroupDescription", "The guest group represents unregistered visitors to your site."), false, false, GUEST_GROUP_ID); $g2 = Group::add(tc("GroupName", "Registered Users"), tc("GroupDescription", "The registered users group represents all user accounts."), false, false, REGISTERED_GROUP_ID); $g3 = Group::add(tc("GroupName", "Administrators"), "", false, false, ADMIN_GROUP_ID); // insert admin user into the user table if (defined('INSTALL_USER_PASSWORD')) { $hasher = new PasswordHash(Config::get('concrete.user.password.hash_cost_log2'), Config::get('concrete.user.password.hash_portable')); $uPassword = INSTALL_USER_PASSWORD; $uPasswordEncrypted = $hasher->HashPassword($uPassword); } else { $uPasswordEncrypted = INSTALL_USER_PASSWORD_HASH; } $uEmail = INSTALL_USER_EMAIL; $superuser = UserInfo::addSuperUser($uPasswordEncrypted, $uEmail); $u = User::getByUserID(USER_SUPER_ID, true, false); MailImporter::add(array('miHandle' => 'private_message')); UserPointAction::add('won_badge', t('Won a Badge'), 5, false, true); // Install conversation default email \Conversation::setDefaultSubscribedUsers(array($superuser)); }
public function enterGroup($g) { $app = Application::getFacadeApplication(); // takes a group object, and, if the user is not already in the group, it puts them into it $dt = $app->make('helper/date'); if (is_object($g)) { if (!$this->inGroup($g)) { $gID = $g->getGroupID(); $db = $app['database']->connection(); $db->Replace('UserGroups', array('uID' => $this->getUserID(), 'gID' => $g->getGroupID(), 'ugEntered' => $dt->getOverridableNow()), array('uID', 'gID'), true); if ($g->isGroupBadge()) { $action = UserPointAction::getByHandle('won_badge'); if (is_object($action)) { $action->addDetailedEntry($this, $g); } $mh = $app->make('mail'); $ui = UserInfo::getByID($this->getUserID()); $mh->addParameter('badgeName', $g->getGroupDisplayName(false)); $mh->addParameter('uDisplayName', $ui->getUserDisplayName()); $mh->addParameter('uProfileURL', (string) $ui->getUserPublicProfileURL()); $mh->addParameter('siteName', $app['config']->get('concrete.site')); $mh->to($ui->getUserEmail()); $mh->load('won_badge'); $mh->sendMail(); } $ue = new \Concrete\Core\User\Event\UserGroup($this); $ue->setGroupObject($g); $app['director']->dispatch('on_user_enter_group', $ue); } } }
/** * Returns an array of package items (e.g. blocks, themes) */ 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); ksort($items); return $items; }
public function getJsonDefaultPointAction($upaID) { $upa = new UserPointAction(); $upa->load($upaID); echo json_encode($upa->getUserPointActionDefaultPoints()); exit; }
public function save() { if ($this->post('upaID') > 0) { $this->upa->load($this->post('upaID')); if (!$this->upa->hasCustomClass()) { $this->upa->upaHandle = $this->post('upaHandle'); } $this->upa->upaName = $this->post('upaName'); $this->upa->upaDefaultPoints = $this->post('upaDefaultPoints'); $this->upa->gBadgeID = $this->post('gBadgeID'); if (!$this->upa->pkgID) { // i hate this activerecord crap $this->upa->pkgID = 0; } $this->upa->upaIsActive = 0; if ($this->post('upaIsActive')) { $this->upa->upaIsActive = 1; } $this->upa->save(); } else { $upa = UserPointAction::add($this->post('upaHandle'), $this->post('upaName'), $this->post('upaDefaultPoints'), $this->post('gBadgeID'), $this->post('upaIsActive')); } $this->redirect('/dashboard/users/points/actions', 'action_saved'); }
public function enterGroup($g) { // takes a group object, and, if the user is not already in the group, it puts them into it $dt = Loader::helper('date'); if (is_object($g)) { if (!$this->inGroup($g)) { $gID = $g->getGroupID(); $db = Loader::db(); $db->Replace('UserGroups', array('uID' => $this->getUserID(), 'gID' => $g->getGroupID(), 'ugEntered' => $dt->getOverridableNow()), array('uID', 'gID'), true); if ($g->isGroupBadge()) { $action = UserPointAction::getByHandle('won_badge'); if (is_object($action)) { $action->addDetailedEntry($this, $g); } $mh = Loader::helper('mail'); $ui = CoreUserInfo::getByID($this->getUserID()); $mh->addParameter('badgeName', $g->getGroupDisplayName(false)); $mh->addParameter('uDisplayName', $ui->getUserDisplayName()); $mh->addParameter('uProfileURL', View::url('/members/profile', 'view', $this->getUserID())); $mh->addParameter('siteName', Config::get('concrete.site')); $mh->to($ui->getUserEmail()); $mh->load('won_badge'); $mh->sendMail(); } $ue = new \Concrete\Core\User\Event\UserGroup($this); $ue->setGroupObject($g); Events::dispatch('on_user_enter_group', $ue); } } }
public function save() { if (!\Core::make('helper/validation/token')->validate('add_action')) { $this->error = new Error(); $this->error->add('Invalid Token'); $this->add(); return; } if ($this->post('upaID') > 0) { $this->upa->load($this->post('upaID')); if (!$this->upa->hasCustomClass()) { $this->upa->upaHandle = $this->post('upaHandle'); } $this->upa->upaName = $this->post('upaName'); $this->upa->upaDefaultPoints = $this->post('upaDefaultPoints'); $this->upa->gBadgeID = $this->post('gBadgeID'); if (!$this->upa->pkgID) { // i hate this activerecord crap $this->upa->pkgID = 0; } $this->upa->upaIsActive = 0; if ($this->post('upaIsActive')) { $this->upa->upaIsActive = 1; } $this->upa->save(); } else { $upa = UserPointAction::add($this->post('upaHandle'), $this->post('upaName'), $this->post('upaDefaultPoints'), $this->post('gBadgeID'), $this->post('upaIsActive')); } $this->redirect('/dashboard/users/points/actions', 'action_saved'); }
public function getPackageItems(Package $package) { return Action::getListByPackage($package); }