$success &= $email->mark2unread($USER->id, $courseid, true);
     }
     if ($success) {
         notify(get_string('tounreadok', 'block_email_list'), 'notifysuccess');
     } else {
         notify(get_string('failmarkunreaded', 'block_email_list'));
     }
     break;
 case 'move2folder':
     // In variable folderid
     $success = true;
     // Move mails -- This variable is an array of ID's
     if (is_array($mailid)) {
         foreach ($mailid as $mail) {
             // Get foldermail reference
             $foldermail = email_get_reference2foldermail($mail, $folderoldid);
             // Move this mail into folder
             if (!email_move2folder($mail, $foldermail->id, $folderid)) {
                 $success = false;
             }
         }
         // Show
         if (!$success) {
             notify(get_string('movefail', 'block_email_list'));
         } else {
             notify(get_string('moveok', 'block_email_list'));
         }
     }
     // Show folders
     $options->folderid = $folderoldid;
     break;
Example #2
0
 /**
  * This function remove eMail, if this does in TRASH folder remove of BBDD else move to TRASH folder.
  *
  * @access public
  * @version 1.0
  * @param int $userid User Id
  * @param int $courseid Course Id
  * @param int $folderid Folder Id
  * @param boolean $silent Show or not show messages
  * @return boolean Success/Fail
  * @todo Finish documenting this function
  */
 function remove($userid, $courseid, $folderid, $silent = false)
 {
     // First, show if folder remove or not
     $deletemails = false;
     $success = true;
     if (email_isfolder_type(get_record('block_email_list_folder', 'id', $folderid), EMAIL_TRASH)) {
         $deletemails = true;
     }
     // FIXME: Esborrar els attachments quan no hagi cap referència al mail
     // If delete definity mails ...
     if ($deletemails) {
         // Delete reference mail
         if (!delete_records('block_email_list_send', 'mailid', $this->id, 'userid', $userid, 'course', $courseid)) {
             return false;
         }
     } else {
         // Get remove folder user
         $removefolder = email_get_root_folder($userid, EMAIL_TRASH);
         // Get actual folder
         $actualfolder = email_get_reference2foldermail($this->id, $folderid);
         if ($actualfolder) {
             // Move mails to trash
             if (!email_move2folder($this->id, $actualfolder->id, $removefolder->id)) {
                 $success = false;
             } else {
                 // Mark the message as read
                 set_field('block_email_list_send', 'readed', 1, 'mailid', $this->id, 'userid', $userid, 'course', $courseid);
                 //Thanks Ann
             }
         } else {
             $success = false;
         }
     }
     // Notify
     if ($success) {
         add_to_log($this->course, 'email_list', 'remove mail', '', 'Remove ' . $this->subject, 0, $this->userid);
         if (!$silent) {
             notify(get_string('removeok', 'block_email_list'), 'notifysuccess');
         }
         return true;
     } else {
         if (!$silent) {
             notify(get_string('removefail', 'block_email_list'));
         }
         return false;
     }
 }