コード例 #1
0
 private function __handlePreferences($prefs, $row)
 {
     include_once "Services/Mail/classes/class.ilMailOptions.php";
     $mailOptions = new ilMailOptions($row["usr_id"]);
     $prefs["mail_incoming_type"] = $mailOptions->getIncomingType();
     $prefs["mail_signature"] = $mailOptions->getSignature();
     $prefs["mail_linebreak"] = $mailOptions->getLinebreak();
     if (count($prefs)) {
         $this->xmlStartTag("Prefs");
         foreach ($prefs as $key => $value) {
             if (ilUserXMLWriter::isPrefExportable($key)) {
                 $this->xmlElement("Pref", array("key" => $key), $value);
             }
         }
         $this->xmlEndTag("Prefs");
     }
 }
コード例 #2
0
 /**
  * send internal message to recipients
  * @access	private
  * @param    string to
  * @param    string cc
  * @param    string bcc
  * @param    string subject
  * @param    string message
  * @param    array attachments
  * @param    integer id of mail which is stored in sentbox
  * @param    array 'normal' and/or 'system' and/or 'email'
  * @return	bool
  */
 function distributeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id, $a_type, $a_action, $a_use_placeholders = 0)
 {
     global $log;
     include_once 'Services/Mail/classes/class.ilMailbox.php';
     include_once './Services/User/classes/class.ilObjUser.php';
     if (!ilMail::_usePearMail()) {
         // REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
         $a_rcp_to = $this->__substituteRecipients($a_rcp_to, 'resubstitute');
         $a_rcp_cc = $this->__substituteRecipients($a_rcp_cc, 'resubstitute');
         $a_rcp_bcc = $this->__substituteRecipients($a_rcp_bcc, 'resubstitute');
     }
     $mbox = new ilMailbox();
     if (!$a_use_placeholders) {
         $rcp_ids = $this->getUserIds(trim($a_rcp_to) . ',' . trim($a_rcp_cc) . ',' . trim($a_rcp_bcc));
         $as_email = array();
         foreach ($rcp_ids as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
             if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                 continue;
             }
             // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS/HER MAIL
             // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 0);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         // SEND EMAIL TO ALL USERS WHO DECIDED 'email' or 'both'
         $to = array();
         $bcc = array();
         if (count($as_email) == 1) {
             $to[] = $as_email[0];
         } else {
             foreach ($as_email as $email) {
                 $bcc[] = $email;
             }
         }
         if (count($to) > 0 || count($bcc) > 0) {
             $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $a_message, $a_attachments);
         }
     } else {
         // to
         $rcp_ids_replace = $this->getUserIds(trim($a_rcp_to));
         // cc / bcc
         $rcp_ids_no_replace = $this->getUserIds(trim($a_rcp_cc) . ',' . trim($a_rcp_bcc));
         $as_email = array();
         // to
         foreach ($rcp_ids_replace as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
             if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                 continue;
             }
             // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
             // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 1);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         if (count($as_email)) {
             foreach ($as_email as $id => $email) {
                 $this->sendMimeMail($email, '', '', $a_subject, $this->replacePlaceholders($a_message, $id), $a_attachments);
             }
         }
         $as_email = array();
         // cc / bcc
         foreach ($rcp_ids_no_replace as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
                 if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                     continue;
                 }
                 // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
                 // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 0);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         if (count($as_email)) {
             $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $a_message, $a_attachments);
         }
     }
     return true;
 }
コード例 #3
0
 private function updateMailPreferences($usr_id)
 {
     if (array_key_exists("mail_incoming_type", $this->prefs) || array_key_exists("mail_signature", $this->prefs) || array_key_exists("mail_linebreak", $this->prefs)) {
         include_once "Services/Mail/classes/class.ilMailOptions.php";
         $mailOptions = new ilMailOptions($usr_id);
         $mailOptions->updateOptions(array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature(), array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak(), array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType(), $mailOptions->getCronjobNotification());
     }
 }
コード例 #4
0
 /** 
  * Fetches data from model and loads this data into form
  */
 private function setMailOptionsValuesByDB()
 {
     global $ilUser, $ilSetting;
     require_once 'Services/Mail/classes/class.ilMailOptions.php';
     $mailOptions = new ilMailOptions($ilUser->getId());
     $data = array('linebreak' => $mailOptions->getLinebreak(), 'signature' => $mailOptions->getSignature(), 'cronjob_notification' => $mailOptions->getCronjobNotification());
     if ($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1') {
         $data['incoming_type'] = $mailOptions->getIncomingType();
     }
     $this->form->setValuesByArray($data);
 }
コード例 #5
0
 /**
  * TODO: drop fields last_update & create_date. redundant data in object_data!
  * saves a new record "user" to database
  * @access	public
  * @param	boolean	user data from formular (addSlashes) or not (prepareDBString)
  */
 function saveAsNew($a_from_formular = true)
 {
     global $ilErr, $ilDB, $ilSetting, $ilUser;
     switch ($this->passwd_type) {
         case IL_PASSWD_PLAIN:
             $pw_field = "passwd";
             if (strlen($this->passwd)) {
                 $pw_value = md5($this->passwd);
             } else {
                 $pw_value = $this->passwd;
             }
             break;
         case IL_PASSWD_MD5:
             $pw_field = "passwd";
             $pw_value = $this->passwd;
             break;
         case IL_PASSWD_CRYPT:
             $pw_field = "i2passwd";
             $pw_value = $this->passwd;
             break;
         default:
             $ilErr->raiseError("<b>Error: passwd_type missing in function saveAsNew. " . $this->id . "!</b><br />class: " . get_class($this) . "<br />Script: " . __FILE__ . "<br />Line: " . __LINE__, $ilErr->FATAL);
     }
     if (!$this->active) {
         $this->setInactivationDate(ilUtil::now());
     }
     $insert_array = array("usr_id" => array("integer", $this->id), "login" => array("text", $this->login), $pw_field => array("text", $pw_value), "firstname" => array("text", $this->firstname), "lastname" => array("text", $this->lastname), "title" => array("text", $this->utitle), "gender" => array("text", $this->gender), "email" => array("text", trim($this->email)), "hobby" => array("text", (string) $this->hobby), "institution" => array("text", $this->institution), "department" => array("text", $this->department), "street" => array("text", $this->street), "city" => array("text", $this->city), "zipcode" => array("text", $this->zipcode), "country" => array("text", $this->country), "sel_country" => array("text", $this->sel_country), "phone_office" => array("text", $this->phone_office), "phone_home" => array("text", $this->phone_home), "phone_mobile" => array("text", $this->phone_mobile), "fax" => array("text", $this->fax), "birthday" => array('date', $this->getBirthday()), "last_login" => array("timestamp", null), "last_update" => array("timestamp", ilUtil::now()), "create_date" => array("timestamp", ilUtil::now()), "referral_comment" => array("text", $this->referral_comment), "matriculation" => array("text", $this->matriculation), "client_ip" => array("text", $this->client_ip), "approve_date" => array("timestamp", $this->approve_date), "agree_date" => array("timestamp", $this->agree_date), "active" => array("integer", (int) $this->active), "time_limit_unlimited" => array("integer", $this->getTimeLimitUnlimited()), "time_limit_until" => array("integer", $this->getTimeLimitUntil()), "time_limit_from" => array("integer", $this->getTimeLimitFrom()), "time_limit_owner" => array("integer", $this->getTimeLimitOwner()), "auth_mode" => array("text", $this->getAuthMode()), "ext_account" => array("text", $this->getExternalAccount()), "profile_incomplete" => array("integer", $this->getProfileIncomplete()), "im_icq" => array("text", $this->im_icq), "im_yahoo" => array("text", $this->im_yahoo), "im_msn" => array("text", $this->im_msn), "im_aim" => array("text", $this->im_aim), "im_skype" => array("text", $this->im_skype), "delicious" => array("text", $this->delicious), "latitude" => array("text", $this->latitude), "longitude" => array("text", $this->longitude), "loc_zoom" => array("integer", (int) $this->loc_zoom), "last_password_change" => array("integer", (int) $this->last_password_change_ts), "im_jabber" => array("text", $this->im_jabber), "im_voip" => array("text", $this->im_voip), 'inactivation_date' => array('timestamp', $this->inactivation_date), 'is_self_registered' => array('integer', (int) $this->is_self_registered));
     $ilDB->insert("usr_data", $insert_array);
     // add new entry in usr_defined_data
     $this->addUserDefinedFieldEntry();
     // ... and update
     $this->updateUserDefinedFields();
     // CREATE ENTRIES FOR MAIL BOX
     include_once "Services/Mail/classes/class.ilMailbox.php";
     $mbox = new ilMailbox($this->id);
     $mbox->createDefaultFolder();
     include_once "Services/Mail/classes/class.ilMailOptions.php";
     $mail_options = new ilMailOptions($this->id);
     $mail_options->createMailOptionsEntry();
     // create personal bookmark folder tree
     include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php";
     $bmf = new ilBookmarkFolder(0, $this->id);
     $bmf->createNewBookmarkTree();
 }
コード例 #6
0
 /**
  * Reset mail options to "local only"
  * 
  */
 protected function resetMailOptions($a_usr_id)
 {
     include_once './Services/Mail/classes/class.ilMailOptions.php';
     $options = new ilMailOptions($a_usr_id);
     $options->updateOptions($options->getSignature(), $options->getLinebreak(), IL_MAIL_LOCAL, $options->getCronjobNotification());
 }