public static function getOrCreate(UserInfo $ui) { $db = Loader::db(); $petID = $db->GetOne('SELECT petID FROM PermissionAccessEntityTypes WHERE petHandle = \'user\''); $peID = $db->GetOne('SELECT pae.peID FROM PermissionAccessEntities pae INNER JOIN PermissionAccessEntityUsers paeg ON pae.peID = paeg.peID WHERE petID = ? AND paeg.uID = ?', array($petID, $ui->getUserID())); if (!$peID) { $db->Execute("INSERT INTO PermissionAccessEntities (petID) VALUES(?)", array($petID)); $peID = $db->Insert_ID(); Config::save('concrete.misc.access_entity_updated', time()); $db->Execute('INSERT INTO PermissionAccessEntityUsers (peID, uID) VALUES (?, ?)', array($peID, $ui->getUserID())); } return \Concrete\Core\Permission\Access\Entity\Entity::getByID($peID); }
public function trigger() { $user = UserInfo::getByID($this->requestedUID); $pk = PermissionKey::getByID($this->pkID); $pk->setPermissionObject($user); return parent::triggerRequest($pk); }
/** * After canceling delete request, do nothing */ public function cancel(Progress $wp) { $ui = UserInfo::getByID($this->getRequestedUserID()); $wpr = parent::cancel($wp); $wpr->message = t("User deletion request has been cancelled."); return $wpr; }
public function userExists($username, $batch) { $ui = UserInfo::getByUserName($username); if (is_object($ui)) { return true; } return false; }
public function sendActivationEmail(UserInfo $ui) { $mh = Loader::helper('mail'); $mh->to($ui->getUserEmail()); if (Config::get('concrete.user.registration.notification_email')) { $mh->from(Config::get('concrete.user.registration.notification_email'), t('Website Registration Notification')); } else { $adminUser = UserInfo::getByID(USER_SUPER_ID); $mh->from($adminUser->getUserEmail(), t('Website Registration Notification')); } $mh->addParameter('uID', $ui->getUserID()); $mh->addParameter('user', $ui); $mh->addParameter('uName', $ui->getUserName()); $mh->addParameter('uEmail', $ui->getUserEmail()); $mh->addParameter('siteName', \Core::make('site')->getSite()->getSiteName()); $mh->load('user_registered_approval_complete'); $mh->sendMail(); }
/** * @param mixed */ public function setUser($user) { if ($user instanceof \Concrete\Core\User\User) { $this->user = UserInfo::getByID($user->getUserID()); } else { $this->user = $user; } $this->name = $this->user->getUserName(); $this->email = $this->user->getUserEmail(); }
public function getMatchedTargetItem(Batch $batch, ItemInterface $item) { $user = UserInfo::getByUserName($item->getIdentifier()); if (is_object($user)) { $targetItem = new TargetItem($this); $targetItem->setItemId($user->getUserID()); $targetItem->setItemName($user->getUserDisplayName()); return $targetItem; } }
public function testActiveUsers() { $ui = UserInfo::getByID(2); $ui->deactivate(); $this->assertEquals(2, $this->list->getTotalResults()); $this->list->includeInactiveUsers(); $this->assertEquals(3, $this->list->getTotalResults()); $this->list->filterByIsActive(0); $this->assertEquals(1, $this->list->getTotalResults()); }
public function testCreateLegacy() { $ui = \UserInfo::add(array('uName' => 'andrew', 'uEmail' => '*****@*****.**')); $this->assertEquals(1, $ui->getUserID()); $this->assertEquals('andrew', $ui->getUserName()); $this->assertEquals('*****@*****.**', $ui->getUserEmail()); $ui = \Concrete\Core\User\UserInfo::add(array('uName' => 'andrew2', 'uEmail' => '*****@*****.**')); $this->assertEquals(2, $ui->getUserID()); $this->assertEquals('andrew2', $ui->getUserName()); $this->assertEquals('*****@*****.**', $ui->getUserEmail()); }
public static function add($filename, $prefix, $data = array(), $fsl = false, $folder = false) { $db = Loader::db(); $dh = Loader::helper('date'); $date = $dh->getOverridableNow(); if (!is_object($fsl)) { $fsl = StorageLocation::getDefault(); } $uID = 0; $u = new User(); if (isset($data['uID'])) { $uID = $data['uID']; } else { if ($u->isRegistered()) { $uID = $u->getUserID(); } } if (!$folder instanceof FileFolder) { $filesystem = new Filesystem(); $folder = $filesystem->getRootFolder(); } $f = new \Concrete\Core\Entity\File\File(); $f->storageLocation = $fsl; $f->fDateAdded = new Carbon($date); $f->folderTreeNodeID = $folder->getTreeNodeID(); $em = \ORM::entityManager(); $em->persist($f); $em->flush(); if ($uID > 0) { $ui = UserInfo::getByID($uID); if (is_object($ui)) { $ue = $ui->getEntityObject(); if (is_object($ue)) { $f->setUser($ue); } } } $node = \Concrete\Core\Tree\Node\Type\File::add($f, $folder); $fv = Version::add($f, $filename, $prefix, $data); $f->versions->add($fv); $fve = new \Concrete\Core\File\Event\FileVersion($fv); Events::dispatch('on_file_add', $fve); $entities = $u->getUserAccessEntityObjects(); $hasUploader = false; foreach ($entities as $obj) { if ($obj instanceof FileUploaderPermissionAccessEntity) { $hasUploader = true; } } if (!$hasUploader) { $u->refreshUserGroups(); } return $fv; }
public function get($itemsToGet = 0, $offset = 0) { $_users = DatabaseItemList::get($itemsToGet, $offset); $users = array(); foreach ($_users as $row) { $u = UserInfo::getByID($row['uID']); $wp = UserWorkflowProgress::getByID($row['wpID']); $users[] = new ProgressUser($u, $wp); } return $users; }
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 static function getLastLoggedInUser() { $db = Loader::db(); $uID = $db->GetOne("select uID from Users order by uLastLogin desc"); return ConcreteUserInfo::getByID($uID); }
public function import(\SimpleXMLElement $sx) { if (isset($sx->pages)) { $nodes = array(); $i = 0; foreach ($sx->pages->page as $p) { $p->originalPos = $i; $nodes[] = $p; ++$i; } usort($nodes, array('static', 'setupPageNodeOrder')); $siteTree = null; if (isset($this->home)) { $home = $this->home; $siteTree = $this->home->getSiteTreeObject(); } else { $home = Page::getByID(HOME_CID, 'RECENT'); } foreach ($nodes as $px) { $pkg = static::getPackageObject($px['package']); $data = array(); $user = (string) $px['user']; if ($user != '') { $ui = UserInfo::getByUserName($user); if (is_object($ui)) { $data['uID'] = $ui->getUserID(); } else { $data['uID'] = USER_SUPER_ID; } } $cDatePublic = (string) $px['public-date']; if ($cDatePublic) { $data['cDatePublic'] = $cDatePublic; } $data['pkgID'] = 0; if (is_object($pkg)) { $data['pkgID'] = $pkg->getPackageID(); } $args = array(); $ct = Type::getByHandle($px['pagetype']); $template = Template::getByHandle($px['template']); if ($px['path'] != '') { // not home page $page = Page::getByPath($px['path'], 'RECENT', $siteTree); if (!is_object($page) || $page->isError()) { $lastSlash = strrpos((string) $px['path'], '/'); $parentPath = substr((string) $px['path'], 0, $lastSlash); $data['cHandle'] = substr((string) $px['path'], $lastSlash + 1); if (!$parentPath) { $parent = $home; } else { $parent = Page::getByPath($parentPath, 'RECENT', $siteTree); } $page = $parent->add($ct, $data); } } else { $page = $home; } $args['cName'] = $px['name']; $args['cDescription'] = $px['description']; if (is_object($ct)) { $args['ptID'] = $ct->getPageTypeID(); } $args['pTemplateID'] = $template->getPageTemplateID(); $page->update($args); } } }
protected static function createUser($uName, $uEmail) { $user = \Concrete\Core\User\UserInfo::add(array('uName' => $uName, 'uEmail' => $uEmail)); return $user; }
protected function getAssignments(AccessEntity $entity) { $class = $this->getClass($entity); $ui = UserInfo::getByUserName($entity->getUserName()); return $class::getOrCreate($ui); }
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 setPropertiesFromArray($arr) { return parent::setPropertiesFromArray($arr); }
public function removeAvatar(UserInfo $ui) { $this->connection->update('Users', array('uHasAvatar' => 0), array('uID' => $ui->getUserID())); }
/** * @param UserInfo $recipient * @param string $subject * @param string $text * @param \Concrete\Core\User\PrivateMessage\PrivateMessage $inReplyTo * * @return \Concrete\Core\Error\Error|false|null */ public function sendPrivateMessage($recipient, $subject, $text, $inReplyTo = false) { if (Limit::isOverLimit($this->getUserID())) { return Limit::getErrorObject(); } $antispam = Core::make('helper/validation/antispam'); $messageText = t('Subject: %s', $subject); $messageText .= "\n"; $messageText .= t('Message: %s', $text); $additionalArgs = array('user' => $this); if (!$antispam->check($messageText, 'private_message', $additionalArgs)) { return false; } $subject = $subject == '' ? t('(No Subject)') : $subject; $db = $this->connection; $dt = Core::make('helper/date'); $msgDateCreated = $dt->getOverridableNow(); $v = array($this->getUserID(), $msgDateCreated, $subject, $text, $recipient->getUserID()); $db->Execute('insert into UserPrivateMessages (uAuthorID, msgDateCreated, msgSubject, msgBody, uToID) values (?, ?, ?, ?, ?)', $v); $msgID = $db->Insert_ID(); if ($msgID > 0) { // we add the private message to the sent box of the sender, and the inbox of the recipient $v = array($msgID, $this->getUserID(), $this->getUserID(), UserPrivateMessageMailbox::MBTYPE_SENT, 0, 1); $db->Execute('insert into UserPrivateMessagesTo (msgID, uID, uAuthorID, msgMailboxID, msgIsNew, msgIsUnread) values (?, ?, ?, ?, ?, ?)', $v); $v = array($msgID, $recipient->getUserID(), $this->getUserID(), UserPrivateMessageMailbox::MBTYPE_INBOX, 1, 1); $db->Execute('insert into UserPrivateMessagesTo (msgID, uID, uAuthorID, msgMailboxID, msgIsNew, msgIsUnread) values (?, ?, ?, ?, ?, ?)', $v); } // If the message is in reply to another message, we make a note of that here if (is_object($inReplyTo)) { $db->Execute('update UserPrivateMessagesTo set msgIsReplied = 1 where uID = ? and msgID = ?', array($this->getUserID(), $inReplyTo->getMessageID())); } // send the email notification if ($recipient->getAttribute('profile_private_messages_notification_enabled')) { $mh = Core::make('mail'); $mh->addParameter('msgSubject', $subject); $mh->addParameter('msgBody', $text); $mh->addParameter('msgAuthor', $this->getUserName()); $mh->addParameter('msgDateCreated', $msgDateCreated); $mh->addParameter('profileURL', $this->getUserPublicProfileUrl()); $mh->addParameter('profilePreferencesURL', View::url('/account/profile/edit')); $mh->to($recipient->getUserEmail()); $mh->addParameter('siteName', Config::get('concrete.site')); $mi = MailImporter::getByHandle("private_message"); if (is_object($mi) && $mi->isMailImporterEnabled()) { $mh->load('private_message_response_enabled'); // we store information ABOUT the message here. The mail handler has to know how to handle this. $data = new \stdClass(); $data->msgID = $msgID; $data->toUID = $recipient->getUserID(); $data->fromUID = $this->getUserID(); $mh->enableMailResponseProcessing($mi, $data); } else { $mh->load('private_message'); } $mh->sendMail(); } }
public function getRequesterUserObject() { return UserInfo::getByID($this->uID); }
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->getGroupName()); $mh->addParameter('uDisplayName', $ui->getUserDisplayName()); $mh->addParameter('uProfileURL', BASE_URL . View::url('/members/profile', 'view', $this->getUserID())); $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 getUserPointEntryUserObject() { $ui = UserInfo::getByID($this->upuID); return $ui; }
public function getConversationMessageUserObject() { return UserInfo::getByID($this->uID); }
/** * @param $queryRow * * @return \Concrete\Core\User\UserInfo */ public function getResult($queryRow) { $ui = CoreUserInfo::getByID($queryRow['uID']); return $ui; }
/** * @param array $data * @return UserInfo */ public function register($data) { // slightly different than add. this is public facing if (Config::get('concrete.user.registration.validate_email')) { $data['uIsValidated'] = 0; } $ui = UserInfo::add($data); return $ui; }