Ejemplo n.º 1
0
 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 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();
 }
Ejemplo n.º 3
0
 public function removeAvatar(UserInfo $ui)
 {
     $this->connection->update('Users', array('uHasAvatar' => 0), array('uID' => $ui->getUserID()));
 }
Ejemplo n.º 4
0
 /**
  * @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();
     }
 }
Ejemplo n.º 5
0
 public function getUserID()
 {
     return parent::getUserID();
 }