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 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 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 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'); }