Esempio n. 1
0
 public function save_importer()
 {
     if (!Loader::helper('validation/token')->validate('save_importer')) {
         $this->error->add(t('Invalid Token.'));
         return;
     }
     $miID = $this->post('miID');
     $mi = MailImporter::getByID($miID);
     if (is_object($mi)) {
         $mi->update($this->post());
         $this->redirect('/dashboard/system/mail/importers', 'importer_updated');
     }
 }
Esempio n. 2
0
 public function run()
 {
     $mailImporter = new MailImporter();
     $list = $mailImporter->getEnabledList();
     foreach ($list as $mi) {
         // for each one, we connect and retrieve any mail messages we haven't seen
         $messages = $mi->getPendingMessages();
         foreach ($messages as $me) {
             if ($me->validate()) {
                 $mi->process($me);
             } elseif (!$me->isSendError()) {
                 $mh = Loader::helper('mail');
                 $mh->to($me->getOriginalSender());
                 $mh->from($mi->getMailImporterEmail());
                 $mh->addParameter('originalSubject', $me->getSubject());
                 $mh->addParameter('error', $mi->getValidationErrorMessage());
                 $mh->load('mail_importer_error');
                 $mh->sendMail();
             }
             $mi->cleanup($me);
         }
     }
 }
Esempio n. 3
0
 /** 
  * Returns the relevant content of the email message, minus any quotations, and the line that includes the validation hash
  */
 public function getProcessedBody()
 {
     $r = preg_split(MailImporter::getMessageBodyHashRegularExpression(), $this->body, $matches);
     $message = $r[0];
     $r = preg_replace(array('/^On (.*) at (.*), (.*) wrote:/sm', '/[\\n\\r\\s\\>]*\\Z/i'), '', $message);
     return $r;
 }
 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));
 }
Esempio n. 5
0
 public function sendPrivateMessage($recipient, $subject, $text, $inReplyTo = false)
 {
     if (Limit::isOverLimit($this->getUserID())) {
         return Limit::getErrorObject();
     }
     $antispam = Loader::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 = Loader::db();
     $dt = Loader::helper('date');
     $v = array($this->getUserID(), $dt->getOverridableNow(), $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 = Loader::helper('mail');
         $mh->addParameter('msgSubject', $subject);
         $mh->addParameter('msgBody', $text);
         $mh->addParameter('msgAuthor', $this->getUserName());
         $mh->addParameter('msgDateCreated', $msgDateCreated);
         $mh->addParameter('profileURL', View::url('/members/profile', 'view', $this->getUserID()));
         $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();
     }
 }
Esempio n. 6
0
 /**
  * Returns an array of package items (e.g. blocks, themes)
  */
 public function getPackageItems()
 {
     $items = array();
     $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this);
     $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this);
     $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this);
     $items['attribute_keys'] = AttributeKey::getListByPackage($this);
     $items['attribute_sets'] = AttributeSet::getListByPackage($this);
     $items['group_sets'] = GroupSet::getListByPackage($this);
     $items['page_types'] = PageType::getListByPackage($this);
     $items['page_templates'] = PageTemplate::getListByPackage($this);
     $items['mail_importers'] = MailImporter::getListByPackage($this);
     $items['gathering_item_template_types'] = GatheringItemTemplateType::getListByPackage($this);
     $items['gathering_item_templates'] = GatheringItemTemplate::getListByPackage($this);
     $items['gathering_data_sources'] = GatheringDataSource::getListByPackage($this);
     $items['features'] = Feature::getListByPackage($this);
     $items['feature_categories'] = FeatureCategory::getListByPackage($this);
     $btl = new BlockTypeList();
     $btl->filterByPackage($this);
     $blocktypes = $btl->get();
     $items['block_types'] = $blocktypes;
     $items['block_type_sets'] = BlockTypeSet::getListByPackage($this);
     $items['page_themes'] = PageTheme::getListByPackage($this);
     $items['permissions'] = PermissionKey::getListByPackage($this);
     $items['single_pages'] = SinglePage::getListByPackage($this);
     $items['attribute_types'] = AttributeType::getListByPackage($this);
     $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this);
     $items['content_editor_snippets'] = SystemContentEditorSnippet::getListByPackage($this);
     $items['conversation_editors'] = ConversationEditor::getListByPackage($this);
     $items['conversation_rating_types'] = ConversationRatingType::getListByPackage($this);
     $items['page_type_publish_target_types'] = PageTypePublishTargetType::getListByPackage($this);
     $items['page_type_composer_control_types'] = PageTypeComposerControlType::getListByPackage($this);
     $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this);
     $items['community_point_actions'] = UserPointAction::getListByPackage($this);
     $items['jobs'] = Job::getListByPackage($this);
     $items['workflow_types'] = WorkflowType::getListByPackage($this);
     ksort($items);
     return $items;
 }
Esempio n. 7
0
 public function getPackageItems(Package $package)
 {
     return \Concrete\Core\Mail\Importer\MailImporter::getListByPackage($package);
 }