Example #1
0
 /**
  * notify by email the user of the reception of a message
  *
  * @param array of int: $userDataList user identificatin list
  * @param MessageToSend $message message envoy�
  * @param int $messageId identification of the message
  * 
  */
 public function notify($userDataList, $message, $messageId)
 {
     if (!get_conf('mailNotification', TRUE)) {
         return;
     }
     // sender name and email
     if ($message->getSender() == 0) {
         $userData = array('mail' => get_conf('no_reply_mail') ? get_conf('no_reply_mail') : get_conf('administrator_email'), 'firstName' => get_lang('Message from %platformName', array('%platformName' => get_conf('siteName'))), 'lastName' => '');
     } else {
         $userData = claro_get_current_user_data();
     }
     //************************************ IS MANAGER
     $stringManager = false;
     $courseManagers = claro_get_course_manager_id($message->getCourseCode());
     $nbrOfManagers = count($courseManagers);
     for ($countManager = 0; $countManager < $nbrOfManagers; $countManager++) {
         if ($message->getSender() == $courseManagers[$countManager]) {
             $courseData = claro_get_course_data($message->getCourseCode());
             $stringManager = get_block('Course manager of %course%(%courseCode%)', array('%course%' => $courseData['name'], '%courseCode%' => $courseData['officialCode']));
         }
     }
     //---------------------- email subject
     $emailSubject = '[' . get_conf('siteName');
     if (!is_null($message->getCourseCode())) {
         $courseData = claro_get_course_data($message->getCourseCode());
         if ($courseData) {
             $emailSubject .= ' - ' . $courseData['officialCode'];
         }
     }
     $emailSubject .= '] ' . $message->getSubject();
     //------------------------------subject
     /* $altBody = get_lang('If you can\'t read this message go to: ') . rtrim( get_path('rootWeb'), '/' ) . '/claroline/messaging/readmessage.php?messageId=' . $messageId . '&type=received' . "\n\n"
        . '-- '
        . claro_get_current_user_data('lastName') . " " . claro_get_current_user_data('firstName') . "\n"
        . $stringManager
        . "\n\n" . get_conf('siteName') ." <" . get_conf('rootWeb') . '>' . "\n"
        . '   ' . get_lang('Administrator') . ' : ' . get_conf('administrator_name') . ' <' . get_conf('administrator_email') . '>' . "\n"
        ; */
     //-------------------------BODY
     $msgContent = claro_parse_user_text($message->getMessage());
     $urlAppend = get_path('url');
     if (!empty($urlAppend)) {
         $msgContent = preg_replace('!href="' . get_path('url') . '!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent);
         $msgContent = preg_replace('!\\>' . get_path('url') . '!', '>' . get_path('rootWeb'), $msgContent);
     } else {
         $msgContent = preg_replace('!href="/!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent);
     }
     $emailBody = "<html><head></head><body>" . $msgContent . '<br /><br />' . '-- <br />' . get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName'])) . "<br />" . $stringManager . '<br /><br /><a href="' . get_conf('rootWeb') . '">' . get_conf('siteName') . '</a><br />' . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . get_lang('Administrator') . ': <a href="mailto:' . get_conf('administrator_email') . '">' . get_conf('administrator_name') . '</a><br />' . '</body></html>';
     //******************************** END BODY
     //******************************************
     if (empty($userData['mail']) || !is_well_formed_email_address($userData['mail'])) {
         // do not send email for a user with no mail address
         pushClaroMessage('Mail Notification Failed : User has no email or an invalid one : ' . var_export($userData, true) . '!');
         return claro_failure::set_failure(get_lang("Mail Notification Failed : You don't have any email address defined in your user profile or the defined email address is not valid."));
     }
     self::emailNotification($userDataList, $emailBody, $emailSubject, $userData['mail'], get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName'])));
 }
Example #2
0
     if (1 == $emailOption) {
         $courseSender = claro_get_current_user_data('firstName') . ' ' . claro_get_current_user_data('lastName');
         $courseOfficialCode = claro_get_current_course_data('officialCode');
         $subject = '';
         if (!empty($title)) {
             $subject .= $title;
         } else {
             $subject .= get_lang('Message from your lecturer');
         }
         $msgContent = $content;
         // Enclosed resource
         $body = $msgContent . "\n" . "\n" . ResourceLinker::renderLinkList($currentLocator, true);
         require_once dirname(__FILE__) . '/../messaging/lib/message/messagetosend.lib.php';
         require_once dirname(__FILE__) . '/../messaging/lib/recipient/courserecipient.lib.php';
         $courseRecipient = new CourseRecipient(claro_get_current_course_id());
         $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
         $message->setCourse(claro_get_current_course_id());
         $message->setTools('CLANN');
         $messageId = $courseRecipient->sendMessage($message);
         if ($failure = claro_failure::get_last_failure()) {
             $dialogBox->warning($failure);
         }
     }
     // end if $emailOption==1
 }
 // end if $submit Announcement
 if ($autoExportRefresh) {
     /**
      * in future, the 2 following calls would be pas by event manager.
      */
     // rss update
Example #3
0
/**
 * Send enroll to course succeded email to user
 * @author Mathieu Laurent <*****@*****.**>
 *
 * @param $userId integer
 * @param $data array
 * @return boolean
 */
function user_send_enroll_to_course_mail($userId, $data, $course = null)
{
    require_once dirname(__FILE__) . '/../../messaging/lib/message/messagetosend.lib.php';
    require_once dirname(__FILE__) . '/../../messaging/lib/recipient/singleuserrecipient.lib.php';
    $courseData = claro_get_course_data($course);
    $subject = get_lang('Your registration');
    $body = get_block('blockCourseSubscriptionNotification', array('%firstname' => $data['firstname'], '%lastname' => $data['lastname'], '%courseCode' => $courseData['officialCode'], '%courseName' => $courseData['name'], '%coursePath' => get_path('rootWeb') . 'claroline/course/index.php?cid=' . $courseData['sysCode'], '%siteName' => get_conf('siteName'), '%rootWeb' => get_path('rootWeb'), '%administratorName' => get_conf('administrator_name'), '%administratorPhone' => get_conf('administrator_phone'), '%administratorEmail' => get_conf('administrator_email')));
    $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
    $message->setCourse($courseData['sysCode']);
    $recipient = new SingleUserRecipient($userId);
    //$message->sendTo($recipient);
    $recipient->sendMessage($message);
    return true;
}
 /**
  * create an message to send with the information in parameters
  *
  * @param int $sender user identification
  *         if it's not defined it use the current user id
  * @param string $subject subject of the message
  * @param string $message content of the message
  */
 public function __construct($subject = parent::NOSUBJECT, $message = parent::NOMESSAGE)
 {
     parent::__construct(self::CLARO_SYSTEM_USER_ID, $subject, $message);
 }
Example #5
0
         * Select the students of the different groups
         */
        if (!empty($classIdList)) {
            $userIdList = array_merge($userIdList, get_class_list_user_id_list($classIdList));
        }
        if (!empty($groupIdList)) {
            $userIdList = array_merge($userIdList, get_group_list_user_id_list($groupIdList));
        }
        // subject
        $subject = $_REQUEST['subject'];
        if (empty($subject)) {
            $subject .= get_lang('Message from your lecturer');
        }
        // content
        $body = $_REQUEST['content'];
        $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
        $message->setCourse(claro_get_current_course_id());
        $recipient = new UserListRecipient();
        $recipient->addUserIdList($userIdList);
        $recipient->sendMessage($message);
        $dialogBox = new DialogBox();
        $dialogBox->success(get_lang('Message sent'));
        if ($failure = claro_failure::get_last_failure()) {
            $dialogBox->warning($failure);
        }
        $dialogBox->info('<a href="' . $_SERVER['PHP_SELF'] . '">&lt;&lt;&nbsp;' . get_lang('Back') . '</a>');
        $content .= $dialogBox->render();
    }
    // end cmd exSendMessage
} else {
    /*
Example #6
0
 } else {
     $message = trim($_POST['message']);
     $subject = trim($_POST['subject']);
     //test subject is fillin
     if ($subject == "") {
         $typeRecipient = strip_tags($_POST['typeRecipient']);
         $userRecipient = (int) $_POST['userRecipient'];
         $groupRecipient = (int) $_POST['groupRecipient'];
         $courseRecipient = strip_tags($_POST['courseRecipient']);
         $responseTo = (int) $_POST['responseTo'];
         $dialogBox = new DialogBox();
         $dialogBox->error(get_lang("Subject couldn't be empty"));
         $content .= $dialogBox->render();
         $addForm = TRUE;
     } else {
         $message = new MessageToSend(claro_get_current_user_id(), $subject, $message);
         if ($_REQUEST['typeRecipient'] == 'user') {
             $recipient = new SingleUserRecipient($_POST['userRecipient']);
             if (claro_is_in_a_group()) {
                 $message->setCourse(claro_get_current_course_id());
                 $message->setGroup(claro_get_current_group_id());
             } elseif (claro_is_in_a_course()) {
                 $message->setCourse(claro_get_current_course_id());
             } elseif (!empty($_POST['responseTo'])) {
                 if (can_answer_message((int) $_POST['responseTo'])) {
                     $messageParent = ReceivedMessage::fromId((int) $_POST['responseTo'], claro_get_current_user_id());
                     if (!is_null($messageParent->getCourseCode())) {
                         $message->setCourse($messageParent->getCourseCode());
                     }
                     if (!is_null($messageParent->getGroupId())) {
                         $message->setGroup($messageParent->getGroupId());