Esempio n. 1
0
 function __sendMail()
 {
     global $ilUser;
     if (!count($notify = $this->__getNotifyLinks())) {
         // Nothing to do
         return true;
     }
     if (!$this->getMailStatus()) {
         return true;
     }
     include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
     $body = "";
     $obj_name = "";
     foreach (ilLinkCheckNotify::_getAllNotifiers($this->db) as $usr_id => $obj_ids) {
         if (!is_object($tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id, false))) {
             $this->__appendLogMessage('LinkChecker: Cannot find user with id: ' . $usr_id);
             continue;
         }
         $counter = 0;
         foreach ($obj_ids as $obj_id) {
             if (!isset($notify[$obj_id])) {
                 continue;
             }
             ++$counter;
             switch ($this->__getType()) {
                 case 'webr':
                     $obj_name = $this->__txt($tmp_user->getLanguage(), 'obj_webr');
                     break;
                 case 'lm':
                 default:
                     $obj_name = $this->__txt($tmp_user->getLanguage(), 'lo');
                     break;
             }
             $body .= $obj_name . ': ' . $this->__getTitle($obj_id) . "\r\n";
             $body .= $this->__txt($tmp_user->getLanguage(), 'link_check_perma_link', "mail") . ": " . $this->createPermanentLink($obj_id, $usr_id, $this->__getType()) . " \r\n";
             $body .= $this->__txt($tmp_user->getLanguage(), "link_check_affected_links", "mail") . ":\r\n";
             // Print all invalid
             foreach ($notify[$obj_id] as $data) {
                 $body .= $data['url'] . "\r\n";
             }
             $body .= "\r\n";
         }
         if ($counter) {
             include_once "./Services/Notification/classes/class.ilSystemNotification.php";
             $ntf = new ilSystemNotification();
             $ntf->setLangModules(array("mail", "common"));
             $ntf->setSubjectLangId("link_check_subject");
             $ntf->setIntroductionLangId("link_check_introduction");
             $ntf->setReasonLangId("link_check_reason");
             $ntf->addAdditionalInfo("additional_info", $body, true);
             $ntf->sendMail(array($tmp_user->getId()));
             $this->__appendLogMessage('LinkChecker: Sent mail to ' . $tmp_user->getEmail());
         }
         $body = "";
     }
 }
 function __sendMail()
 {
     global $ilUser;
     if (!count($notify = $this->__getNotifyLinks())) {
         // Nothing to do
         return true;
     }
     if (!$this->getMailStatus()) {
         return true;
     }
     include_once './Services/LinkChecker/classes/class.ilLinkCheckNotify.php';
     foreach (ilLinkCheckNotify::_getAllNotifiers($this->db) as $usr_id => $obj_ids) {
         if (!is_object($tmp_user =& ilObjectFactory::getInstanceByObjId($usr_id, false))) {
             $this->__appendLogMessage('LinkChecker: Cannot find user with id: ' . $usr_id);
             continue;
         }
         $counter = 0;
         foreach ($obj_ids as $obj_id) {
             if (!isset($notify[$obj_id])) {
                 continue;
             }
             ++$counter;
             switch ($this->__getType()) {
                 case 'webr':
                     $body .= $this->__txt($tmp_user->getLanguage(), 'obj_webr');
                     break;
                 case 'lm':
                 default:
                     $body .= $this->__txt($tmp_user->getLanguage(), 'lo');
                     break;
             }
             $body .= ': ';
             $body .= $this->__getTitle($obj_id) . "\r\n";
             // Print all invalid
             foreach ($notify[$obj_id] as $data) {
                 $body .= $data['url'] . "\r\n";
             }
             $body .= "\r\n";
         }
         if ($counter) {
             include_once "Services/Mail/classes/class.ilFormatMail.php";
             $umail = new ilFormatMail($tmp_user->getId());
             $subject = $this->__txt($tmp_user->getLanguage(), 'link_check_subject');
             $umail->sendMail($tmp_user->getLogin(), "", "", $subject, $body, array(), array("normal"));
             $this->__appendLogMessage('LinkChecker: Sent mail to ' . $tmp_user->getEmail());
         }
     }
 }