public function sendPrivateMessage($recipient, $subject, $text, $inReplyTo = false) { Loader::model('user_private_message'); if(UserPrivateMessageLimit::isOverLimit($this->getUserID())) { return UserPrivateMessageLimit::getErrorObject(); } $subject = ($subject == '') ? t('(No Subject)') : $subject; $db = Loader::db(); $dt = Loader::helper('date'); $v = array($this->getUserID(), $dt->getLocalDateTime(), $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($db->Insert_ID(), $this->getUserID(), $this->getUserID(), UserPrivateMessageMailbox::MBTYPE_SENT, 0, 1); $db->Execute('insert into UserPrivateMessagesTo (msgID, uID, uAuthorID, msgMailboxID, msgIsNew, msgIsUnread) values (?, ?, ?, ?, ?, ?)', $v); $v = array($db->Insert_ID(), $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 = Loader::helper('mail'); $mh->addParameter('msgSubject', $subject); $mh->addParameter('msgBody', $text); $mh->addParameter('msgAuthor', $this->getUserName()); $mh->addParameter('msgDateCreated', $msgDateCreated); $mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $this->getUserID())); $mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit')); $mh->to($recipient->getUserEmail()); Loader::library('mail/importer'); $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 run() { $db = Loader::db(); Cache::disableLocalCache(); Loader::model('attribute/categories/collection'); Loader::model('attribute/categories/file'); Loader::model('attribute/categories/user'); $collectionErrors = array(); $fileErrors = array(); $userErrors = array(); //add the new collection attribute keys $this->installCoreAttributeItems(); $dict = NewDataDictionary($db->db, DB_TYPE); $tables = $db->MetaTables(); if (in_array('_CollectionAttributeKeys', $tables)) { $collectionErrors = $this->upgradeCollectionAttributes(); } if (in_array('_FileAttributeKeys', $tables)) { $fileErrors = $this->upgradeFileAttributes(); } if (in_array('_UserAttributeKeys', $tables)) { $userErrors = $this->upgradeUserAttributes(); } $cak=CollectionAttributeKey::getByHandle('exclude_sitemapxml'); if (!is_object($cak)) { $cak = CollectionAttributeKey::add('exclude_sitemapxml', t('Exclude From sitemap.xml'), true, null, 'BOOLEAN'); } //change the page/tab name of the dashboard users registration page $dashboardRegistrationPage=Page::getByPath('/dashboard/users/registration'); if( intval($dashboardRegistrationPage->cID) ) $dashboardRegistrationPage->update(array('cName'=>t('Login & Registration'))); Config::save('LOGIN_ADMIN_TO_DASHBOARD', 1); //profile friends page install Loader::model('single_page'); $friendsPage=Page::getByPath('/profile/friends'); if( !intval($friendsPage->cID)) { SinglePage::add('/profile/friends'); } $membersPage =Page::getByPath('/members'); if( !intval($membersPage->cID)) { SinglePage::add('/members'); } $messagesPage =Page::getByPath('/profile/messages'); if( !intval($messagesPage->cID)) { SinglePage::add('/profile/messages'); } $ppme = UserAttributeKey::getByHandle('profile_private_messages_enabled'); if (!is_object($ppme)) { UserAttributeKey::add('BOOLEAN', array('akHandle' => 'profile_private_messages_enabled', 'akName' => t('I would like to receive private messages.'), 'akIsSearchable' => true)); } $ppmne = UserAttributeKey::getByHandle('profile_private_messages_notification_enabled'); if (!is_object($ppmne)) { UserAttributeKey::add('BOOLEAN', array('akHandle' => 'profile_private_messages_notification_enabled', 'akName' => t('Send me email notifications when I receive a private message.'), 'akIsSearchable' => true)); } $em = Page::getByPath('/dashboard/settings'); if (!$em->isError()) { $em = SinglePage::getByID($em->getCollectionID()); $em->refresh(); } $em1=Page::getByPath('/dashboard/settings/mail'); if ($em1->isError()) { $em1 = SinglePage::add('/dashboard/settings/mail'); $em1->update(array('cName'=>t('Email'), 'cDescription'=>t('Enable post via email and other settings.'))); } // remove adodb database logs $databaseReports = Page::getByPath('/dashboard/reports/database'); if (!$databaseReports->isError()) { $databaseReports->delete(); } if (in_array('adodb_logsql', $tables)) { @$db->query('DROP TABLE adodb_logsql'); } Loader::library('mail/importer'); $mi = MailImporter::getByHandle("private_message"); if (!is_object($mi)) { MailImporter::add(array('miHandle' => 'private_message')); } Loader::model("job"); Job::installByHandle('process_email'); Cache::enableLocalCache(); return array_merge($collectionErrors, $fileErrors, $userErrors); }