public function notify(ilNotificationObject $notification)
 {
     // use a specific sender or ANONYMOUS
     $sender_id = isset($notification->handlerParams['mail']['sender']) ? $notification->handlerParams['mail']['sender'] : ANONYMOUS_USER_ID;
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($sender_id);
     $mail->appendInstallationSignature(true);
     $mail->sendMail($notification->user->getLogin(), '', '', $notification->title, $notification->longDescription, false, array('normal'));
     //mail($notification->user->getEmail(), $notification->title, $notification->longDescription);
 }
Пример #2
0
 /**
  * Sends a notification message to all users responsible for vat assignment.
  * 
  * @access	public
  * @static
  * @param	ilPaymentObject $oPaymentObject
  */
 public static function _sendNotificationToVATAdministration($oPaymentObject)
 {
     global $ilSetting, $lng, $ilClientIniFile;
     $payment_vat_admins = $ilSetting->get('payment_vat_admins');
     $users = explode(',', $payment_vat_admins);
     $subject = $lng->txt('payment_vat_assignment_notification_subject');
     $tmp_obj = ilObjectFactory::getInstanceByRefId($oPaymentObject->getRefId());
     $message = sprintf($lng->txt('payment_vat_assignment_notification_body'), $tmp_obj->getTitle()) . "\n\n";
     $message .= "------------------------------------------------------------\n";
     $message .= sprintf($lng->txt('payment_vat_assignment_notification_intro'), $ilClientIniFile->readVariable('client', 'name'), ILIAS_HTTP_PATH . '/?client_id=' . CLIENT_ID);
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail_obj = new ilMail(ANONYMOUS_USER_ID);
     foreach ((array) $users as $login) {
         if (strlen(trim($login)) && (int) ilObjUser::_lookupId(trim($login))) {
             $success = $mail_obj->sendMail(trim($login), '', '', $subject, $message, array(), array("system"));
         }
     }
 }
 /**
  * send notifications about new EContent
  *
  * @return bool
  */
 protected function sendNewContentNotification(ilECSSetting $a_server, $a_econtent_id)
 {
     global $ilLog;
     if (!count($rcps = $a_server->getApprovalRecipients())) {
         return true;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     // @TODO: read mail
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_export_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->content_obj->getTitle() . "\n";
     if (strlen($desc = $this->content_obj->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     // Participant info
     $message .= "\n" . $lang->txt('ecs_published_for');
     try {
         $found = false;
         $receivers = null;
         include_once './Services/WebServices/ECS/classes/class.ilECSEContentDetails.php';
         $details = ilECSEContentDetails::getInstance($a_server->getServerId(), $a_econtent_id, $this->getECSObjectType());
         if ($details instanceof ilECSEContentDetails) {
             $receivers = $details->getReceivers();
         }
         if ($receivers) {
             foreach ($receivers as $member) {
                 $found = true;
                 include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php';
                 $part = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())->getParticipantByMID($member);
                 $message .= "\n\n" . $part->getParticipantName() . "\n";
                 $message .= $part->getDescription();
             }
         }
         if ($found) {
             $message .= "\n\n";
         } else {
             $message .= ' ' . $lang->txt('ecs_not_published') . "\n\n";
         }
     } catch (ilECSConnectorException $e) {
         $ilLog->write(__METHOD__ . ': Cannot read approvements.');
         return false;
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->content_obj->getRefId(), 'crs', true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($a_server->getApprovalRecipientsAsString(), '', '', $lang->txt('ecs_new_approval_subject'), $message, array(), array('normal'));
     return true;
 }
Пример #4
0
 public function confirmRegistration()
 {
     global $lng, $ilias, $ilLog;
     ilUtil::setCookie('iltest', 'cookie', false);
     if (!isset($_GET['rh']) || !strlen(trim($_GET['rh']))) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
     }
     try {
         require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $oRegSettings = new ilRegistrationSettings();
         $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
         $oUser = ilObjectFactory::getInstanceByObjId($usr_id);
         $oUser->setActive(true);
         if ($oRegSettings->passwordGenerationEnabled()) {
             $passwd = ilUtil::generatePasswords(1);
             $password = $passwd[0];
             $oUser->setPasswd($password, IL_PASSWD_PLAIN);
             $oUser->setLastPasswordChangeTS(time());
         }
         $oUser->update();
         $usr_lang = $oUser->getPref('language');
         if ($lng->getLangKey() != $usr_lang) {
             $lng = new ilLanguage($usr_lang);
         }
         // send email
         // try individual account mail in user administration
         include_once "Services/Mail/classes/class.ilAccountMail.php";
         include_once './Services/User/classes/class.ilObjUserFolder.php';
         $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
         if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
             $acc_mail = new ilAccountMail();
             $acc_mail->setUser($oUser);
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $acc_mail->setUserPassword($password);
             }
             $acc_mail->send();
         } else {
             include_once 'Services/Mail/classes/class.ilMail.php';
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             // mail subject
             $subject = $lng->txt("reg_mail_subject");
             // mail body
             $body = $lng->txt("reg_mail_body_salutation") . " " . $oUser->getFullname() . ",\n\n" . $lng->txt("reg_mail_body_text1") . "\n\n" . $lng->txt("reg_mail_body_text2") . "\n" . ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID . "\n";
             $body .= $lng->txt("login") . ": " . $oUser->getLogin() . "\n";
             if ($oRegSettings->passwordGenerationEnabled()) {
                 $body .= $lng->txt("passwd") . ": " . $password . "\n";
             }
             $body .= "\n";
             $body .= $lng->txt('reg_mail_body_forgot_password_info') . "\n";
             $body .= "\n";
             $body .= $lng->txt("reg_mail_body_text3") . "\n\r";
             $body .= $oUser->getProfileAsString($lng);
             $mail_obj->enableSoap(false);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail($oUser->getEmail(), '', '', $subject, $body, array(), array('normal'));
         }
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang=' . $usr_lang);
     } catch (ilRegConfirmationLinkExpiredException $exception) {
         include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
         $soap_client = new ilSoapClient();
         $soap_client->setResponseTimeout(1);
         $soap_client->enableWSDL(true);
         $soap_client->init();
         $ilLog->write(__METHOD__ . ': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
         $soap_client->call('deleteExpiredDualOptInUserObjects', array($_COOKIE['PHPSESSID'] . '::' . $_COOKIE['ilClientId'], $exception->getCode()));
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     } catch (ilRegistrationHashNotFoundException $exception) {
         ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=' . $exception->getMessage() . "&lang=" . $usr_lang);
     }
 }
Пример #5
0
    function sendPostActivationNotification($post_data)
    {
        global $ilDB, $ilUser, $lng;
        if (is_array($moderators = $this->getModerators())) {
            // GET THREAD DATA
            $result = $ilDB->queryf('
				SELECT thr_subject FROM frm_threads 
				WHERE thr_pk = %s', array('integer'), array($post_data['pos_thr_fk']));
            while ($record = $ilDB->fetchAssoc($result)) {
                $post_data['thr_subject'] = $record['thr_subject'];
                break;
            }
            // GET AUTHOR OF NEW POST
            if ($post_data['pos_usr_id']) {
                $post_data['pos_usr_name'] = ilObjUser::_lookupLogin($post_data['pos_usr_id']);
            } else {
                if (strlen($post_data['pos_usr_alias'])) {
                    $post_data['pos_usr_name'] = $post_data['pos_usr_alias'] . ' (' . $lng->txt('frm_pseudonym') . ')';
                }
            }
            if ($post_data['pos_usr_name'] == '') {
                $post_data['pos_usr_name'] = $this->lng->txt('forums_anonymous');
            }
            // save language of the current user
            global $lng;
            $userLanguage = $lng;
            $mail_obj = new ilMail(ANONYMOUS_USER_ID);
            foreach ($moderators as $moderator) {
                // set forum language instance for earch user
                $this->setLanguage(self::_getLanguageInstanceByUsrId($moderator));
                $subject = $this->formatNotificationSubject($post_data);
                $message = $this->formatPostActivationNotification($post_data, $moderator);
                $mail_obj->sendMail(ilObjUser::_lookupLogin($moderator), '', '', $subject, $message, array(), array("system"));
            }
            // reset language
            $this->setLanguage($userLanguage);
        }
    }
 /**
  * Send news mail for 1 object and 1 user
  *
  * @param int $a_user_id
  * @param int $a_ref_id
  * @param array $news
  */
 public function sendMail($a_user_id, $a_ref_id, array $news)
 {
     global $lng, $ilUser;
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     $this->initLanguage($a_user_id);
     $this->getLanguage()->loadLanguageModule("crs");
     $this->getLanguage()->loadLanguageModule("news");
     // needed for ilNewsItem
     $lng = $this->getLanguage();
     $this->initMail();
     $obj_title = $this->getLanguageText($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\"";
     $this->setRecipients($a_user_id);
     $this->setSubject(sprintf($this->getLanguageText("crs_subject_course_group_notification"), $obj_title));
     $this->setBody(ilMail::getSalutation($a_user_id, $this->getLanguage()));
     $this->appendBody("\n\n");
     $this->appendBody(sprintf($this->getLanguageText("crs_intro_course_group_notification_for"), $obj_title));
     $this->appendBody("\n\n");
     // ilDatePresentation::setUseRelativeDates(false);
     // news summary
     $counter = 1;
     foreach ($news as $item) {
         $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
         $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]);
         /* process sub-item info
         			if($item["aggregation"])
         			{
         				$sub = array();
         				foreach($item["aggregation"] as $subitem)
         				{
         					$sub_id = ilObject::_lookupObjId($subitem["ref_id"]);
         					$sub_title = ilObject::_lookupTitle($sub_id);
         					
         					// to include posting title
         					if($subitem["context_obj_type"] == "frm")
         					{
         						$sub_title = ilNewsItem::determineNewsTitle($subitem["context_obj_type"],
         							$subitem["title"], $subitem["content_is_lang_var"]);
         					}					
         								
         					$sub[] = $sub_title;
         					
         					$sub_content = ilNewsItem::determineNewsContent($subitem["context_obj_type"], 
         						$subitem["content"], $subitem["content_text_is_lang_var"]);								
         					if($sub_content)
         					{
         						$sub[] = strip_tags($sub_content);
         					}
         				}
         				$content .= "\n".implode("\n\n", $sub);
         			} 
         			*/
         $obj_id = ilObject::_lookupObjId($item["ref_id"]);
         $obj_title = ilObject::_lookupTitle($obj_id);
         // path
         include_once './Services/Locator/classes/class.ilLocatorGUI.php';
         $cont_loc = new ilLocatorGUI();
         $cont_loc->addContextItems($item["ref_id"], true);
         $cont_loc->setTextOnly(true);
         // #9954/#10044
         // see ilInitialisation::requireCommonIncludes()
         @(include_once "HTML/Template/ITX.php");
         // new implementation
         if (class_exists("HTML_Template_ITX")) {
             include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php";
         } else {
             include_once "HTML/ITX.php";
             // old implementation
             include_once "./Services/UICore/classes/class.ilTemplateITX.php";
         }
         require_once "./Services/UICore/classes/class.ilTemplate.php";
         $loc = "[" . $cont_loc->getHTML() . "]";
         $this->appendBody("----------------------------------------------------------------------------------------------");
         $this->appendBody("\n\n");
         $this->appendBody('#' . $counter . " - " . $loc . " " . $obj_title . "\n\n");
         $this->appendBody($title);
         if ($content) {
             $this->appendBody("\n");
             $this->appendBody($content);
         }
         $this->appendBody("\n\n");
         ++$counter;
     }
     $this->appendBody("----------------------------------------------------------------------------------------------");
     $this->appendBody("\n\n");
     // link to object
     $this->appendBody($this->getLanguageText("crs_course_group_notification_link"));
     $this->appendBody("\n");
     $object_link = ilUtil::_getHttpPath();
     $object_link .= "/goto.php?target=" . $obj_type . "_" . $a_ref_id . "&client_id=" . CLIENT_ID;
     $this->appendBody($object_link);
     $this->appendBody("\n\n");
     $this->appendBody(ilMail::_getAutoGeneratedMessageString($this->getLanguage()));
     $this->appendBody(ilMail::_getInstallationSignature());
     // #10044
     $mail = new ilMail($ilUser->getId());
     $mail->enableSOAP(false);
     // #10410
     $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $this->getSubject(), $this->getBody(), null, array("system"));
 }
Пример #7
0
 static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null)
 {
     global $ilUser, $ilObjDataCache, $ilAccess;
     include_once "./Services/Notification/classes/class.ilNotification.php";
     include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
     $wiki = new ilObjWiki($a_wiki_ref_id, true);
     $page = new ilWikiPage($a_page_id);
     // #11138
     $ignore_threshold = $a_action == "comment";
     // 1st update will be converted to new - see below
     if ($a_action == "new") {
         return;
     }
     if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
         $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold);
         $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         $users = array_merge($users, $wiki_users);
         if (!sizeof($users)) {
             return;
         }
         ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users);
     } else {
         $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         if (!sizeof($users)) {
             return;
         }
     }
     ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id);
     // #15192 - should always be present
     if ($a_page_id) {
         include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php";
         $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
     } else {
         include_once "./Services/Link/classes/class.ilLink.php";
         $link = ilLink::_getLink($a_wiki_ref_id);
     }
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     // see ilBlogPostingGUI::getSnippet()
     // see ilBlogPosting::getNotificationAbstract()
     include_once "Modules/Wiki/classes/class.ilWikiPageGUI.php";
     $pgui = new ilWikiPageGUI($page->getId());
     $pgui->setRawPageContent(true);
     $pgui->setAbstractOnly(true);
     $pgui->setFileDownloadLink(".");
     $pgui->setFullscreenLink(".");
     $pgui->setSourcecodeDownloadScript(".");
     $snippet = $pgui->showPage();
     $snippet = ilPageObject::truncateHTML($snippet, 500, "...");
     // making things more readable
     $snippet = str_replace('<br/>', "\n", $snippet);
     $snippet = str_replace('<br />', "\n", $snippet);
     $snippet = str_replace('</p>', "\n", $snippet);
     $snippet = str_replace('</div>', "\n", $snippet);
     $snippet = trim(strip_tags($snippet));
     // "fake" new (to enable snippet - if any)
     $current_version = array_shift($page->getHistoryEntries());
     $current_version = $current_version["nr"];
     if (!$current_version) {
         $a_type = ilNotification::TYPE_WIKI;
         $a_action = "new";
     }
     foreach (array_unique($users) as $idx => $user_id) {
         if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) {
             // use language of recipient to compose message
             $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
             $ulng->loadLanguageModule('wiki');
             $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle(), $page->getTitle());
             $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
             if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
                 // update/delete
                 $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
                 if ($snippet) {
                     $message .= "\n" . $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n";
                 }
                 // include comment/note text
                 if ($a_comment) {
                     $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
                 }
                 $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link;
             } else {
                 // new
                 $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
                 if ($snippet) {
                     $message .= $ulng->txt('content') . "\n" . "----------------------------------------\n" . $snippet . "\n" . "----------------------------------------\n\n";
                 }
                 $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link;
             }
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         } else {
             unset($users[$idx]);
         }
     }
 }
Пример #8
0
 protected function sentReminder(array $a_recipient_ids)
 {
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     include_once "./Services/Link/classes/class.ilLink.php";
     $link = ilLink::_getStaticLink($this->getRefId(), "svy");
     foreach ($a_recipient_ids as $user_id) {
         // use language of recipient to compose message
         $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
         $ulng->loadLanguageModule('survey');
         $subject = sprintf($ulng->txt('survey_reminder_subject'), $this->getTitle());
         $message = sprintf($ulng->txt('survey_reminder_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
         $message .= $ulng->txt('survey_reminder_body') . ":\n\n";
         $message .= $ulng->txt('obj_svy') . ": " . $this->getTitle() . "\n";
         $message .= "\n" . $ulng->txt('survey_reminder_link') . ": " . $link;
         $mail_obj = new ilMail(ANONYMOUS_USER_ID);
         $mail_obj->appendInstallationSignature(true);
         $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
     }
 }
 /**
  * Send notification about team status
  * 
  * @param int $a_exc_ref_id
  * @param int $a_user_id
  * @param string $a_action
  */
 public function sendNotification($a_exc_ref_id, $a_user_id, $a_action)
 {
     global $ilUser;
     // no need to notify current user
     if ($ilUser->getId() == $a_user_id) {
         return;
     }
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     include_once "./Services/Link/classes/class.ilLink.php";
     $link = ilLink::_getStaticLink($a_exc_ref_id);
     // use language of recipient to compose message
     $ulng = ilLanguageFactory::_getLanguageOfUser($a_user_id);
     $ulng->loadLanguageModule('exc');
     $subject = sprintf($ulng->txt('exc_team_notification_subject_' . $a_action), $this->getTitle());
     $message = sprintf($ulng->txt('exc_team_notification_salutation'), ilObjUser::_lookupFullname($a_user_id)) . "\n\n";
     $message .= $ulng->txt('exc_team_notification_body_' . $a_action) . "\n\n";
     $message .= $ulng->txt('obj_exc') . ": " . ilObject::_lookupTitle($this->getExerciseId()) . "\n";
     $message .= $ulng->txt('exc_assignment') . ": " . $this->getTitle() . "\n";
     $message .= $ulng->txt('exc_team_notification_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
     $message .= $ulng->txt('exc_team_notification_link') . ": " . $link;
     $mail_obj = new ilMail(ANONYMOUS_USER_ID);
     $mail_obj->appendInstallationSignature(true);
     $ret = $mail_obj->sendMail(ilObjUser::_lookupLogin($a_user_id), "", "", $subject, $message, array(), array("system"));
     // var_dump($ret);
 }
 /**
  * Send news mail for 1 object and 1 user
  *
  * @param int $a_user_id
  * @param int $a_ref_id
  * @param array $news
  */
 protected function sendMail($a_user_id, $a_ref_id, array $news)
 {
     global $lng, $ilUser;
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     include_once "./Services/Notification/classes/class.ilSystemNotification.php";
     $ntf = new ilSystemNotification();
     $ntf->setLangModules(array("crs", "news"));
     $ntf->setRefId($a_ref_id);
     $ntf->setGotoLangId('url');
     $ntf->setSubjectLangId('crs_subject_course_group_notification');
     // user specific language
     $lng = $ntf->getUserLanguage($a_user_id);
     $obj_title = $lng->txt($obj_type) . " \"" . ilObject::_lookupTitle($obj_id) . "\"";
     $ntf->setIntroductionDirect(sprintf($lng->txt("crs_intro_course_group_notification_for"), $obj_title));
     $subject = sprintf($lng->txt("crs_subject_course_group_notification"), $obj_title);
     // news summary
     $counter = 1;
     $txt = "";
     foreach ($news as $item) {
         $title = ilNewsItem::determineNewsTitle($item["context_obj_type"], $item["title"], $item["content_is_lang_var"], $item["agg_ref_id"], $item["aggregation"]);
         $content = ilNewsItem::determineNewsContent($item["context_obj_type"], $item["content"], $item["content_text_is_lang_var"]);
         $obj_id = ilObject::_lookupObjId($item["ref_id"]);
         $obj_title = ilObject::_lookupTitle($obj_id);
         // path
         include_once './Services/Locator/classes/class.ilLocatorGUI.php';
         $cont_loc = new ilLocatorGUI();
         $cont_loc->addContextItems($item["ref_id"], true);
         $cont_loc->setTextOnly(true);
         // #9954/#10044
         // see ilInitialisation::requireCommonIncludes()
         @(include_once "HTML/Template/ITX.php");
         // new implementation
         if (class_exists("HTML_Template_ITX")) {
             include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php";
         } else {
             include_once "HTML/ITX.php";
             // old implementation
             include_once "./Services/UICore/classes/class.ilTemplateITX.php";
         }
         require_once "./Services/UICore/classes/class.ilTemplate.php";
         $loc = "[" . $cont_loc->getHTML() . "]";
         if ($counter > 1) {
             $txt .= $ntf->getBlockBorder();
         }
         $txt .= '#' . $counter . " - " . $loc . " " . $obj_title . "\n\n";
         $txt .= $title;
         if ($content) {
             $txt .= "\n" . $content;
         }
         $txt .= "\n\n";
         ++$counter;
     }
     $ntf->addAdditionalInfo("news", $txt, true);
     // #10044
     $mail = new ilMail($ilUser->getId());
     $mail->enableSOAP(false);
     // #10410
     $mail->sendMail(ilObjUser::_lookupLogin($a_user_id), null, null, $subject, $ntf->composeAndGetMessage($a_user_id, null, "read", true), null, array("system"));
 }
 function sendCodes($not_sent, $subject, $message, $lang = "en")
 {
     /*
      * 0 = all
      * 1 = not sent
      * 2 = finished
      * 3 = not finished
      */
     $check_finished = $not_sent > 1;
     include_once "./Services/Mail/classes/class.ilMail.php";
     $user_id = $this->getOwner();
     $mail = new ilMail($user_id);
     $recipients = $this->getExternalCodeRecipients($check_finished);
     foreach ($recipients as $data) {
         if ($data['email'] && $data['code']) {
             $do_send = false;
             switch ((int) $not_sent) {
                 case 1:
                     $do_send = !(bool) $data['sent'];
                     break;
                 case 2:
                     $do_send = $data['finished'];
                     break;
                 case 3:
                     $do_send = !$data['finished'];
                     break;
                 default:
                     $do_send = true;
                     break;
             }
             if ($do_send) {
                 // build text
                 $messagetext = $message;
                 $url = ILIAS_HTTP_PATH . "/goto.php?cmd=infoScreen&target=svy_" . $this->getRefId() . "&client_id=" . CLIENT_ID . "&accesscode=" . $data["code"] . "&lang=" . $lang;
                 $messagetext = str_replace('[url]', "<" . $url . ">", $messagetext);
                 foreach ($data as $key => $value) {
                     $messagetext = str_replace('[' . $key . ']', $value, $messagetext);
                 }
                 // send mail
                 $mail->sendMail($data['email'], "", "", $subject, $messagetext, array(), array('normal'));
             }
         }
     }
     global $ilDB;
     $ilDB->manipulateF("UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL", array('integer', 'integer'), array(1, $this->getSurveyId()));
 }
 /**
  * Sends the mail with its object properties as MimeMail
  * It first tries to read the mail body, subject and sender address from posted named formular fields. 
  * If no field values found the defaults are used.
  * Placehoders will be replaced by the appropriate data.
  * @access	public
  * @param object ilUser
  */
 function send()
 {
     global $ilSetting;
     // determine language and get account mail data
     // fall back to default language if acccount mail data is not given for user language.
     $amail = $this->readMailTemplate($this->data['language']);
     if ($amail['body'] == '' || $amail['subject'] == '') {
         $amail = $this->readMailTemplate($ilSetting->get('language'));
         $lang = $ilSetting->get('language');
     } else {
         $lang = $this->data['language'];
     }
     // fallback if mail data is still not given
     if ($this->areLangVariablesUsedAsFallback() && ($amail['body'] == '' || $amail['subject'] == '')) {
         $lang = $this->data['language'];
         $tmp_lang = $this->getLng($lang);
         // mail subject
         $mail_subject = $tmp_lang->txt('disk_quota_mail_subject');
         // mail body
         $mail_body = $tmp_lang->txt('disk_quota_mail_body_salutation') . ' ' . $data['firstname'] . ' ' . $data['lastname'] . ",\n\n" . $tmp_lang->txt('disk_quota_body_text1') . "\n\n" . $tmp_lang->txt('disk_quota_body_text2') . "\n" . ILIAS_HTTP_PATH . '/login.php?client_id=' . CLIENT_ID . "\n";
         $mail_body .= $tmp_lang->txt('login') . ': ' . $data['firstname'] . "\n";
         $mail_body .= "\n";
         $mail_body .= $tmp_lang->txt('disk_quota_mail_body_text3') . "\n\r";
         //$mail_body .= $user->getProfileAsString($tmp_lang);
     } else {
         // replace placeholders
         $mail_subject = $this->replacePlaceholders($amail['subject'], $amail, $lang);
         $mail_body = $this->replacePlaceholders($amail['body'], $amail, $lang);
     }
     // send the mail
     include_once 'Services/Mail/classes/class.ilMimeMail.php';
     $mmail = new ilMimeMail();
     $mmail->autoCheck(false);
     $mmail->From($ilSetting->get('admin_email'));
     $mmail->Subject($mail_subject);
     $mmail->To($this->data['email']);
     $mmail->Body($mail_body);
     $mmail->Send();
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     $mail->sendMail($this->data['login'], "", "", $mail_subject, $mail_body, array(), array("normal"));
     return true;
 }
 /**
  * adds applicant to group as member
  * @access	public
  */
 function refuseApplicantsObject()
 {
     $user_ids = $_POST["user_id"];
     if (empty($user_ids[0])) {
         $this->ilErr->raiseError($this->lng->txt("no_checkbox"), $this->ilErr->MESSAGE);
     }
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     foreach ($user_ids as $new_member) {
         $user =& $this->ilias->obj_factory->getInstanceByObjId($new_member);
         $this->object->deleteApplicationListEntry($new_member);
         $mail->sendMail($user->getLogin(), "", "", "Membership application refused: Group " . $this->object->getTitle(), "Your application has been refused.", array(), array('system'));
     }
     ilUtil::sendSuccess($this->lng->txt("grp_msg_applicants_removed"), true);
     $this->ctrl->redirect($this, 'members');
 }
 static function sendNotification($a_action, $a_type, $a_wiki_ref_id, $a_page_id, $a_comment = null)
 {
     global $ilUser, $ilObjDataCache, $ilAccess;
     include_once "./Services/Notification/classes/class.ilNotification.php";
     include_once "./Modules/Wiki/classes/class.ilObjWiki.php";
     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
     $wiki_id = $ilObjDataCache->lookupObjId($a_wiki_ref_id);
     $wiki = new ilObjWiki($a_wiki_ref_id, true);
     $page = new ilWikiPage($a_page_id);
     // #11138
     $ignore_threshold = $a_action == "comment";
     if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
         $users = ilNotification::getNotificationsForObject($a_type, $a_page_id, null, $ignore_threshold);
         $wiki_users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         $users = array_merge($users, $wiki_users);
         if (!sizeof($users)) {
             return;
         }
         include_once "./Modules/Wiki/classes/class.ilObjWikiGUI.php";
         $link = ILIAS_HTTP_PATH . "/" . ilObjWikiGui::getGotoLink($a_wiki_ref_id, $page->getTitle());
         ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI_PAGE, $a_page_id, $users);
     } else {
         $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_WIKI, $wiki_id, $a_page_id, $ignore_threshold);
         if (!sizeof($users)) {
             return;
         }
         include_once "./Services/Link/classes/class.ilLink.php";
         $link = ilLink::_getLink($a_wiki_ref_id);
     }
     ilNotification::updateNotificationTime(ilNotification::TYPE_WIKI, $wiki_id, $users, $a_page_id);
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     foreach (array_unique($users) as $idx => $user_id) {
         if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $a_wiki_ref_id)) {
             // use language of recipient to compose message
             $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
             $ulng->loadLanguageModule('wiki');
             $subject = sprintf($ulng->txt('wiki_change_notification_subject'), $wiki->getTitle());
             $message = sprintf($ulng->txt('wiki_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
             if ($a_type == ilNotification::TYPE_WIKI_PAGE) {
                 // update/delete
                 $message .= $ulng->txt('wiki_change_notification_page_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
                 // include comment/note text
                 if ($a_comment) {
                     $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
                 }
                 $message .= "\n" . $ulng->txt('wiki_change_notification_page_link') . ": " . $link;
             } else {
                 // new
                 $message .= $ulng->txt('wiki_change_notification_body_' . $a_action) . ":\n\n";
                 $message .= $ulng->txt('wiki') . ": " . $wiki->getTitle() . "\n";
                 $message .= $ulng->txt('page') . ": " . $page->getTitle() . "\n";
                 $message .= $ulng->txt('wiki_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
                 $message .= $ulng->txt('wiki_change_notification_link') . ": " . $link;
             }
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         } else {
             unset($users[$idx]);
         }
     }
 }
 /**
  * send notifications about new EContent
  */
 protected function sendNewContentNotification($a_server_id)
 {
     include_once 'Services/WebServices/ECS/classes/class.ilECSSetting.php';
     $settings = ilECSSetting::getInstanceByServerId($a_server_id);
     if (!count($rcps = $settings->getEContentRecipients())) {
         return;
     }
     include_once './Services/Mail/classes/class.ilMail.php';
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     $mail = new ilMail(self::MAIL_SENDER);
     $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
     $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
     if (strlen($desc = $this->getDescription())) {
         $message .= $lang->txt('desc') . ': ' . $desc . "\n";
     }
     include_once './Services/Link/classes/class.ilLink.php';
     $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
     $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
     $message .= ilMail::_getAutoGeneratedMessageString();
     $mail->sendMail($settings->getEContentRecipientsAsString(), '', '', $lang->txt('ecs_new_econtent_subject'), $message, array(), array('normal'));
 }
 /**
  * send exercise per mail to members
  */
 function sendAssignment($a_exc_id, $a_ass_id, $a_members)
 {
     include_once "./Modules/Exercise/classes/class.ilExAssignment.php";
     $ass_title = ilExAssignment::lookupTitle($a_ass_id);
     include_once "./Modules/Exercise/classes/class.ilFSStorageExercise.php";
     $storage = new ilFSStorageExercise($a_exc_id, $a_ass_id);
     $files = $storage->getFiles();
     if (count($files)) {
         include_once "./Services/Mail/classes/class.ilFileDataMail.php";
         $mfile_obj = new ilFileDataMail($_SESSION["AccountId"]);
         foreach ($files as $file) {
             $mfile_obj->copyAttachmentFile($file["fullpath"], $file["name"]);
             $file_names[] = $file["name"];
         }
     }
     include_once "Services/Mail/classes/class.ilMail.php";
     $tmp_mail_obj = new ilMail($_SESSION["AccountId"]);
     $message = $tmp_mail_obj->sendMail($this->__formatRecipients($a_members), "", "", $this->__formatSubject($ass_title), $this->__formatBody($a_ass_id), count($file_names) ? $file_names : array(), array("normal"));
     unset($tmp_mail_obj);
     if (count($file_names)) {
         $mfile_obj->unlinkFiles($file_names);
         unset($mfile_obj);
     }
     // SET STATUS SENT FOR ALL RECIPIENTS
     foreach ($a_members as $member_id => $value) {
         ilExAssignment::updateStatusSentForUser($a_ass_id, $member_id, 1);
     }
     return true;
 }
 protected function sendMails($res)
 {
     global $ilAccess, $ilDB, $lng;
     static $cache = array();
     static $attachments_cache = array();
     include_once 'Modules/Forum/classes/class.ilObjForum.php';
     include_once 'Services/Mail/classes/class.ilMail.php';
     include_once 'Services/User/classes/class.ilObjUser.php';
     include_once 'Services/Language/classes/class.ilLanguage.php';
     $forumObj = new ilObjForum();
     $frm = $forumObj->Forum;
     $numRows = 0;
     $mail_obj = new ilMail(ANONYMOUS_USER_ID);
     $mail_obj->enableSOAP(false);
     while ($row = $ilDB->fetchAssoc($res)) {
         // don not send a notification to the post author
         if ($row['pos_display_user_id'] != $row['user_id']) {
             // GET AUTHOR OF NEW POST
             if ($row['pos_display_user_id']) {
                 $row['pos_usr_name'] = ilObjUser::_lookupLogin($row['pos_display_user_id']);
             } else {
                 if (strlen($row['pos_usr_alias'])) {
                     $row['pos_usr_name'] = $row['pos_usr_alias'] . ' (' . $lng->txt('frm_pseudonym') . ')';
                 }
             }
             if ($row['pos_usr_name'] == '') {
                 $row['pos_usr_name'] = $lng->txt('forums_anonymous');
             }
             // get all references of obj_id
             if (!isset($cache[$row['obj_id']])) {
                 $cache[$row['obj_id']] = ilObject::_getAllReferences($row['obj_id']);
             }
             // check for attachments
             $has_attachments = false;
             if (!isset($attachments_cache[$row['obj_id']][$row['pos_pk']])) {
                 $fileDataForum = new ilFileDataForum($row['obj_id'], $row['pos_pk']);
                 $filesOfPost = $fileDataForum->getFilesOfPost();
                 foreach ($filesOfPost as $attachment) {
                     $attachments_cache[$row['obj_id']][$row['pos_pk']][] = $attachment['name'];
                     $has_attachments = true;
                 }
             } else {
                 $has_attachments = true;
             }
             // do rbac check before sending notification
             $send_mail = false;
             foreach ((array) $cache[$row['obj_id']] as $ref_id) {
                 if ($ilAccess->checkAccessOfUser($row['user_id'], 'read', '', $ref_id)) {
                     $row['ref_id'] = $ref_id;
                     $send_mail = true;
                     break;
                 }
             }
             $attached_files = array();
             if ($has_attachments == true) {
                 $attached_files = $attachments_cache[$row['obj_id']][$row['pos_pk']];
             }
             if ($send_mail) {
                 $frm->setLanguage(ilForum::_getLanguageInstanceByUsrId($row['user_id']));
                 $mail_obj->sendMail(ilObjUser::_lookupLogin($row['user_id']), '', '', $frm->formatNotificationSubject($row), $frm->formatNotification($row, 1, $attached_files, $row['user_id']), array(), array('normal'));
                 $numRows++;
             }
         }
     }
     return $numRows;
 }
Пример #18
0
 static function sendNotification($a_action, $a_in_wsp, $a_blog_node_id, $a_posting_id, $a_comment = null)
 {
     global $ilUser, $ilAccess;
     // get blog object id (repository or workspace)
     if ($a_in_wsp) {
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
         include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
         $tree = new ilWorkspaceTree($ilUser->getId());
         // owner of tree is irrelevant
         $blog_obj_id = $tree->lookupObjectId($a_blog_node_id);
         $access_handler = new ilWorkspaceAccessHandler($tree);
         $link = ilWorkspaceAccessHandler::getGotoLink($a_blog_node_id, $blog_obj_id, "_" . $a_posting_id);
     } else {
         $blog_obj_id = ilObject::_lookupObjId($a_blog_node_id);
         $access_handler = null;
         include_once "Services/Link/classes/class.ilLink.php";
         $link = ilLink::_getStaticLink($a_blog_node_id, "blog", true, "_" . $a_posting_id);
     }
     if (!$blog_obj_id) {
         return;
     }
     include_once "./Modules/Blog/classes/class.ilBlogPosting.php";
     $posting = new ilBlogPosting($a_posting_id);
     // #11138
     $ignore_threshold = $a_action == "comment";
     // approval handling
     $admin_only = false;
     if (!$posting->isApproved()) {
         $blog = new self($blog_obj_id, false);
         if ($blog->hasApproval()) {
             switch ($a_action) {
                 case "update":
                     // un-approved posting was updated - no notifications
                     return;
                 case "new":
                     // un-approved posting was activated - admin-only notification
                     $admin_only = true;
                     $ignore_threshold = true;
                     break;
             }
         }
     }
     // recipients
     include_once "./Services/Notification/classes/class.ilNotification.php";
     $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_BLOG, $blog_obj_id, $a_posting_id, $ignore_threshold);
     if (!sizeof($users)) {
         return;
     }
     // send mails
     include_once "./Services/Mail/classes/class.ilMail.php";
     include_once "./Services/User/classes/class.ilObjUser.php";
     include_once "./Services/Language/classes/class.ilLanguageFactory.php";
     include_once "./Services/User/classes/class.ilUserUtil.php";
     $posting_title = $posting->getTitle();
     $blog_title = ilObject::_lookupTitle($blog_obj_id);
     $author = $posting->getAuthor();
     $notified = array();
     foreach (array_unique($users) as $idx => $user_id) {
         // the user responsible for the action should not be notified
         if ($user_id == $ilUser->getId()) {
             continue;
         }
         // workspace
         if ($access_handler) {
             if ($admin_only && !$access_handler->checkAccessOfUser($tree, $user_id, 'write', '', $a_blog_node_id)) {
                 continue;
             }
             if (!$access_handler->checkAccessOfUser($tree, $user_id, 'read', '', $a_blog_node_id)) {
                 continue;
             }
         } else {
             if ($admin_only && !$ilAccess->checkAccessOfUser($user_id, 'write', '', $a_blog_node_id)) {
                 continue;
             }
             if (!$ilAccess->checkAccessOfUser($user_id, 'read', '', $a_blog_node_id)) {
                 continue;
             }
         }
         // use language of recipient to compose message
         $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
         $ulng->loadLanguageModule('blog');
         $subject = sprintf($ulng->txt('blog_change_notification_subject'), $blog_title);
         $message = sprintf($ulng->txt('blog_change_notification_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
         $message .= $ulng->txt('blog_change_notification_body_' . $a_action) . ":\n\n";
         $message .= $ulng->txt('obj_blog') . ": " . $blog_title . "\n";
         $message .= $ulng->txt('blog_posting') . ": " . $posting_title . "\n";
         $message .= $ulng->txt('blog_changed_by') . ": " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n";
         if ($a_comment) {
             $message .= "\n" . $ulng->txt('comment') . ":\n\"" . trim($a_comment) . "\"\n";
         }
         $message .= "\n" . $ulng->txt('blog_change_notification_link') . ": " . $link;
         $mail_obj = new ilMail(ANONYMOUS_USER_ID);
         $mail_obj->appendInstallationSignature(true);
         $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         $notified[] = $user_id;
     }
     if (sizeof($notified)) {
         ilNotification::updateNotificationTime(ilNotification::TYPE_BLOG, $blog_obj_id, $notified);
     }
 }
Пример #19
0
 public function sendAdvancedNotification($active_id)
 {
     include_once "./Services/Mail/classes/class.ilMail.php";
     $mail = new ilMail(ANONYMOUS_USER_ID);
     $usr_data = $this->userLookupFullName(ilObjTest::_getUserIdFromActiveId($active_id));
     $message = new ilTemplate("tpl.il_as_tst_finish_notification_simple.html", TRUE, TRUE, "Modules/Test");
     $message->setVariable('TEXT_TEST_TITLE', $this->lng->txt('title'));
     $message->setVariable('VALUE_TEST_TITLE', $this->getTitle());
     $message->setVariable('TEXT_USER_NAME', $this->lng->txt('username'));
     $message->setVariable('VALUE_USER_NAME', $usr_data);
     $message->setVariable('TEXT_FINISH_TIME', $this->lng->txt('tst_finished'));
     ilDatePresentation::setUseRelativeDates(false);
     $message->setVariable('VALUE_FINISH_TIME', ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX)));
     include_once "./Modules/Test/classes/class.ilTestExport.php";
     $exportObj = new ilTestExport($this, "results");
     $file = $exportObj->exportToExcel($deliver = FALSE, 'active_id', $active_id, $passedonly = FALSE);
     include_once "./Services/Mail/classes/class.ilFileDataMail.php";
     $fd = new ilFileDataMail(ANONYMOUS_USER_ID);
     $fd->copyAttachmentFile($file, "result_" . $active_id . ".xls");
     $file_names[] = "result_" . $active_id . ".xls";
     $result = $mail->sendMail(ilObjUser::_lookupLogin($this->getOwner()), "", "", sprintf($this->lng->txt('tst_user_finished_test'), $this->getTitle()), $message->get(), count($file_names) ? $file_names : array(), array('normal'));
     if (count($file_names)) {
         $fd->unlinkFiles($file_names);
         unset($fd);
         @unlink($file);
     }
 }
Пример #20
0
 /**
  * @param      $a_action
  * @param      $a_table_id
  * @param null $a_record_id
  */
 public static function sendNotification($a_action, $a_table_id, $a_record_id = NULL)
 {
     global $ilUser, $ilAccess;
     // If coming from trash, never send notifications and don't load dcl Object
     if ($_GET['ref_id'] == SYSTEM_FOLDER_ID) {
         return;
     }
     $dclObj = new ilObjDataCollection($_GET['ref_id']);
     if ($dclObj->getNotification() != 1) {
         return;
     }
     $obj_table = ilDataCollectionCache::getTableCache($a_table_id);
     $obj_dcl = $obj_table->getCollectionObject();
     // recipients
     require_once './Services/Notification/classes/class.ilNotification.php';
     $users = ilNotification::getNotificationsForObject(ilNotification::TYPE_DATA_COLLECTION, $obj_dcl->getId(), true);
     if (!sizeof($users)) {
         return;
     }
     ilNotification::updateNotificationTime(ilNotification::TYPE_DATA_COLLECTION, $obj_dcl->getId(), $users);
     //FIXME  $_GET['ref_id]
     require_once './Services/Link/classes/class.ilLink.php';
     $link = ilLink::_getLink($_GET['ref_id']);
     // prepare mail content
     // use language of recipient to compose message
     require_once './Services/Language/classes/class.ilLanguageFactory.php';
     // send mails
     require_once './Services/Mail/classes/class.ilMail.php';
     require_once './Services/User/classes/class.ilObjUser.php';
     require_once './Services/Language/classes/class.ilLanguageFactory.php';
     require_once './Services/User/classes/class.ilUserUtil.php';
     require_once './Services/User/classes/class.ilUserUtil.php';
     require_once './Modules/DataCollection/classes/class.ilDataCollectionTable.php';
     foreach (array_unique($users) as $idx => $user_id) {
         // the user responsible for the action should not be notified
         // FIXME  $_GET['ref_id]
         if ($user_id != $ilUser->getId() && $ilAccess->checkAccessOfUser($user_id, 'read', '', $_GET['ref_id'])) {
             // use language of recipient to compose message
             $ulng = ilLanguageFactory::_getLanguageOfUser($user_id);
             $ulng->loadLanguageModule('dcl');
             $subject = sprintf($ulng->txt('dcl_change_notification_subject'), $obj_dcl->getTitle());
             // update/delete
             $message = $ulng->txt("dcl_hello") . " " . ilObjUser::_lookupFullname($user_id) . ",\n\n";
             $message .= $ulng->txt('dcl_change_notification_dcl_' . $a_action) . ":\n\n";
             $message .= $ulng->txt('obj_dcl') . ": " . $obj_dcl->getTitle() . "\n\n";
             $message .= $ulng->txt('dcl_table') . ": " . $obj_table->getTitle() . "\n\n";
             $message .= $ulng->txt('dcl_record') . ":\n";
             $message .= "------------------------------------\n";
             if ($a_record_id) {
                 $record = ilDataCollectionCache::getRecordCache($a_record_id);
                 if (!$record->getTableId()) {
                     $record->setTableId($a_table_id);
                 }
                 //					$message .= $ulng->txt('dcl_record_id').": ".$a_record_id.":\n";
                 $t = "";
                 foreach ($record->getTable()->getVisibleFields() as $field) {
                     if ($record->getRecordField($field->getId())) {
                         $t .= $field->getTitle() . ": " . $record->getRecordField($field->getId())->getPlainText() . "\n";
                     }
                 }
                 $message .= $t . "\n";
             }
             $message .= "------------------------------------\n";
             $message .= $ulng->txt('dcl_changed_by') . ": " . $ilUser->getFullname() . " " . ilUserUtil::getNamePresentation($ilUser->getId()) . "\n\n";
             $message .= $ulng->txt('dcl_change_notification_link') . ": " . $link . "\n\n";
             $message .= $ulng->txt('dcl_change_why_you_receive_this_email');
             $mail_obj = new ilMail(ANONYMOUS_USER_ID);
             $mail_obj->appendInstallationSignature(true);
             $mail_obj->sendMail(ilObjUser::_lookupLogin($user_id), "", "", $subject, $message, array(), array("system"));
         } else {
             unset($users[$idx]);
         }
     }
 }
 /**
  * Send notification
  *
  * @access private
  * @param
  * 
  */
 private function sendNotification($user_obj)
 {
     if (!count($this->getCurrentServer()->getUserRecipients())) {
         return true;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     include_once './Services/Language/classes/class.ilLanguage.php';
     $lang = ilLanguageFactory::_getLanguage();
     $GLOBALS['lng'] = $lang;
     $GLOBALS['ilUser'] = $user_obj;
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($this->getCurrentServer()->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
 }
 /**
  * remove members from group
  * TODO: set return location to parent object if user removes himself
  * TODO: allow user to remove himself when he is not group admin
  * @access public
  */
 function confirmedRemoveMemberObject()
 {
     global $ilCtrl;
     $removed_self = false;
     include_once 'Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail($_SESSION["AccountId"]);
     //User needs to have administrative rights to remove members...
     foreach ($_SESSION["saved_post"]["user_id"] as $member_id) {
         $user_obj = new ilObjUser($member_id);
         if (!$this->object->removeMember($user_obj)) {
             ilUtil::sendInfo($this->lng->txt($this->object->getErrorMsg()), true);
             ilUtil::redirect($this->ctrl->getLinkTarget($this, "members", "", false, false));
         }
         $user_obj->dropDesktopItem($this->object->getRefId(), "icrs");
         if (!$removed_self and $user_obj->getId() == $this->ilias->account->getId()) {
             $removed_self = true;
         } else {
             $mail->sendMail($user_obj->getLogin(), "", "", $this->lng->txtlng("common", "ilinc_mail_subj_subscription_cancelled", $user_obj->getLanguage()) . ": " . $this->object->getTitle(), $this->lng->txtlng("common", "ilinc_mail_body_subscription_cancelled", $user_obj->getLanguage()), array(), array('normal'));
         }
     }
     unset($_SESSION["saved_post"]);
     ilUtil::sendInfo($this->lng->txt("ilinc_msg_membership_annulled"), true);
     if ($removed_self) {
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->tree->getParentId($this->ref_id));
         $ilCtrl->redirectByClass("ilrepositorygui", "");
     }
     ilUtil::redirect($this->ctrl->getLinkTarget($this, "members", "", false, false));
 }
 /**
  * send notification about new user accounts
  *
  * @access protected
  */
 protected static function _sendNotification(ilECSSetting $server, ilObjUser $user_obj)
 {
     if (!count($server->getUserRecipients())) {
         return true;
     }
     // If sub id is set => mail was send
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $import = new ilECSImport($server->getServerId(), $user_obj->getId());
     if ($import->getSubId()) {
         return false;
     }
     include_once './Services/Language/classes/class.ilLanguageFactory.php';
     $lang = ilLanguageFactory::_getLanguage();
     $lang->loadLanguageModule('ecs');
     include_once './Services/Mail/classes/class.ilMail.php';
     $mail = new ilMail(6);
     $mail->enableSoap(false);
     $subject = $lang->txt('ecs_new_user_subject');
     // build body
     $body = $lang->txt('ecs_new_user_body') . "\n\n";
     $body .= $lang->txt('ecs_new_user_profile') . "\n\n";
     $body .= $user_obj->getProfileAsString($lang) . "\n\n";
     $body .= ilMail::_getAutoGeneratedMessageString($lang);
     $mail->sendMail($server->getUserRecipientsAsString(), "", "", $subject, $body, array(), array("normal"));
     // Store sub_id = 1 in ecs import which means mail is send
     $import->setSubId(1);
     $import->save();
     return true;
 }
 function mailRatersActionObject()
 {
     global $ilUser;
     $appr_id = $this->handleRatersAccess();
     $this->ctrl->setParameter($this, "appr_id", $appr_id);
     $rec_ids = explode(";", $_POST["rtr_id"]);
     if (!sizeof($rec_ids)) {
         $this->ctrl->redirect($this, "editRaters");
     }
     $form = $this->initMailRatersForm($appr_id, $rec_ids);
     if ($form->checkInput()) {
         $txt_u = $form->getInput("message_u");
         $txt_a = $form->getInput("message_a");
         $subj = $form->getInput("subject");
         // #12743
         $sender_id = trim($ilUser->getEmail()) ? $ilUser->getId() : ANONYMOUS_USER_ID;
         include_once "./Services/Mail/classes/class.ilMail.php";
         $all_data = $this->object->getRatersData($appr_id);
         foreach ($rec_ids as $rec_id) {
             if (isset($all_data[$rec_id])) {
                 $user = $all_data[$rec_id];
                 // anonymous
                 if (substr($rec_id, 0, 1) == "a") {
                     $mytxt = $txt_a;
                     $url = $user["href"];
                     $rcp = $user["email"];
                 } else {
                     $mytxt = $txt_u;
                     $user["code"] = $this->lng->txt("survey_code_mail_on_demand");
                     $url = ilLink::_getStaticLink($this->object->getRefId());
                     $rcp = $user["login"];
                     // #15141
                 }
                 $mytxt = str_replace("[lastname]", $user["lastname"], $mytxt);
                 $mytxt = str_replace("[firstname]", $user["firstname"], $mytxt);
                 $mytxt = str_replace("[url]", $url, $mytxt);
                 $mytxt = str_replace("[code]", $user["code"], $mytxt);
                 $mail = new ilMail($sender_id);
                 $mail->sendMail($rcp, "", "", $subj, $mytxt, array(), array('normal'));
                 $this->object->set360RaterSent($appr_id, substr($rec_id, 0, 1) == "a" ? 0 : (int) substr($rec_id, 1), substr($rec_id, 0, 1) == "u" ? 0 : (int) substr($rec_id, 1));
             }
         }
         ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
         $this->ctrl->redirect($this, "editRaters");
     }
     $form->setValuesByPost();
     $this->mailRatersObject($form);
 }
 /**
  * mail via soap
  * @param object $sid
  * @param object $a_mail_xml
  * @return 
  */
 public function distributeMails($sid, $a_mail_xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     include_once 'Services/Mail/classes/class.ilMail.php';
     include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
     $parser = new ilSoapMailXmlParser($a_mail_xml);
     try {
         // Check if wellformed
         libxml_use_internal_errors(true);
         $ok = simplexml_load_string($a_mail_xml);
         if (!$ok) {
             foreach (libxml_get_errors() as $err) {
                 $error .= $err->message . ' ';
             }
             return $this->__raiseError($error, 'CLIENT');
         }
         $parser->start();
     } catch (InvalidArgumentException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
         return $this->__raiseError($e->getMessage(), 'CLIENT');
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
         return $this->__raiseError($e->getMessage(), 'CLIENT');
     }
     $mails = $parser->getMails();
     global $ilUser;
     foreach ($mails as $mail) {
         // Prepare attachments
         include_once './Services/Mail/classes/class.ilFileDataMail.php';
         $file = new ilFileDataMail($ilUser->getId());
         foreach ((array) $mail['attachments'] as $attachment) {
             // TODO: Error handling
             $file->storeAsAttachment($attachment['name'], $attachment['content']);
             $attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
         }
         $mail_obj = new ilMail($ilUser->getId());
         $mail_obj->setSaveInSentbox(true);
         $mail_obj->saveAttachments((array) $attachments);
         $mail_obj->sendMail(implode(',', (array) $mail['to']), implode(',', (array) $mail['cc']), implode(',', (array) $mail['bcc']), $mail['subject'], implode("\n", $mail['body']), (array) $attachments, array($mail['type']), (bool) $mail['usePlaceholders']);
         // Finally unlink attachments
         foreach ((array) $attachments as $att) {
             $file->unlinkFile($att);
         }
         $mail_obj->savePostData($ilUser->getId(), array(), '', '', '', '', '', '', '', '');
     }
     return true;
 }