public function testCustomUserPointAction() { Action::add('won_badge', t('Won a Badge'), 5, false); $action2 = Action::getByID(1); $action3 = Action::getByHandle('won_badge'); /* @var $action2 \Concrete\Core\User\Point\Action\WonBadgeAction */ /* @var $action3 \Concrete\Core\User\Point\Action\WonBadgeAction */ $this->assertTrue($action2->hasCustomClass()); $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeAction', $action2); $this->assertEquals(5, $action2->getUserPointActionDefaultPoints()); $this->assertEquals(null, $action2->getUserPointActionBadgeGroupObject()); $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeAction', $action3); $this->assertEquals(5, $action3->getUserPointActionDefaultPoints()); $this->assertEquals(null, $action3->getUserPointActionBadgeGroupObject()); }
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); } } }
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); } } }