4require_once 
'Services/User/classes/class.ilObjUser.php';
 
  238                require_once 
"./Services/Mail/classes/class.ilFileDataMail.php";
 
  239                require_once 
"Services/Mail/classes/class.ilMailOptions.php";
 
  243                $lng->loadLanguageModule(
"mail");
 
  248                $this->table_mail = 
'mail';
 
  249                $this->table_mail_saved = 
'mail_saved';
 
  250                $this->user_id = $a_user_id;
 
  272                if(isset($this->properties[$name]))
 
  274                        return $this->properties[$name];
 
  278                if($name == 
'mlists')
 
  282                                require_once 
'Services/Contact/classes/class.ilMailingLists.php';
 
  284                                return $this->properties[$name];
 
  291                if(self::_usePearMail())
 
  294                        if(is_a($recipients, 
'PEAR_Error'))
 
  300                                foreach($recipients as $rcp)
 
  302                                        if (substr($rcp->mailbox, 0, 1) != 
'#')
 
  304                                                if(trim($rcp->mailbox) == trim($a_recipient) ||
 
  305                                                   trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
 
  310                                        else if (substr($rcp->mailbox, 0, 7) == 
'#il_ml_')
 
  312                                                if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
 
  319                                                if(trim($rcp->mailbox.
'@'.$rcp->host) == trim($a_recipient))
 
  330                        if(count($recipients))
 
  332                                foreach($recipients as $recipient)
 
  334                                        if(trim($recipient) == trim($a_recipient))
 
  354                $this->soap_enabled = $a_status;
 
  360                if(!extension_loaded(
'curl') || !
$ilSetting->get(
'soap_user_administration'))
 
  377                $this->save_in_sentbox = $a_save_in_sentbox;
 
  392                $this->mail_send_type = $a_types;
 
  402                $this->mail_rcp_to = $a_rcp_to;
 
  412                $this->mail_rcp_cc = $a_rcp_cc;
 
  422                $this->mail_rcp_bc = $a_rcp_bc;
 
  432                $this->mail_subject = $a_subject;
 
  442                $this->mail_message = $a_message;
 
  451                include_once 
'Services/Mail/classes/class.ilMailGlobalServices.php';
 
  472                $users = trim($users);
 
  475                        if(strstr($users, 
','))
 
  477                                $rcp_to_array = array();
 
  479                                $recipients = explode(
',', $users);
 
  480                                foreach($recipients as $recipient)
 
  482                                        $recipient = trim($recipient);
 
  488                                                        $rcp_to_array[] = $tmp_obj->getFullname().
' ['.$recipient.
']';
 
  492                                                        $rcp_to_array[] = $recipient;
 
  497                                                $rcp_to_array[] = $recipient;
 
  501                                return trim(implode(
', ', $rcp_to_array));
 
  510                                                return $tmp_obj->getFullname().
' ['.$users.
']';
 
  525                        return $this->lng->txt(
'not_available');
 
  535                        SELECT b.* FROM " . $this->table_mail .
" a 
  536                        INNER JOIN ".$this->table_mail .
" b ON b.folder_id = a.folder_id 
  537                        AND b.user_id = a.user_id AND b.send_time > a.send_time 
  539                        AND a.mail_id = %s ORDER BY b.send_time ASC",
 
  540                        array(
'integer', 
'integer'),
 
  541                        array($this->user_id, $a_mail_id));
 
  554                        SELECT b.* FROM " . $this->table_mail .
" a 
  555                        INNER JOIN ".$this->table_mail .
" b ON b.folder_id = a.folder_id 
  556                        AND b.user_id = a.user_id AND b.send_time < a.send_time 
  558                        AND a.mail_id = %s ORDER BY b.send_time DESC",
 
  559                        array(
'integer', 
'integer'),
 
  560                        array($this->user_id, $a_mail_id));
 
  578                $this->mail_counter = array();
 
  579                $this->mail_counter[
'read'] = 0;
 
  580                $this->mail_counter[
'unread'] = 0;
 
  582        $query = 
"SELECT sender_id, m_subject, mail_id, m_status, send_time FROM ". $this->table_mail .
" 
  583                        LEFT JOIN object_data ON obj_id = sender_id 
  586                        AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ";
 
  588        if($filter[
'status'])
 
  590            $query .= 
' AND m_status = '.$ilDB->quote($filter[
'status'], 
'text');
 
  594            $query .= 
' AND '.$ilDB->like(
'm_type', 
'text', 
'%%:"'.$filter[
'type'].
'"%%', 
false);
 
  597        $query .= 
" ORDER BY send_time DESC";
 
  600                        array(
'integer', 
'integer'),
 
  601                        array($this->user_id, $a_folder_id));
 
  607                        if($tmp[
'm_status'] == 
'read')
 
  609                                ++$this->mail_counter[
'read'];
 
  612                        if($tmp[
'm_status'] == 
'unread')
 
  614                                ++$this->mail_counter[
'unread'];
 
  620                $this->mail_counter[
'total'] = count($output);
 
  622                return $output ? $output : array();
 
  636                        SELECT COUNT(*) FROM ". $this->table_mail .
" 
  639                        array(
'integer', 
'integer'),
 
  640                        array($this->user_id, $a_folder_id));
 
  642                return $res->numRows();
 
  683                return is_array($this->mail_counter) ? $this->mail_counter : array(
 
  700                        SELECT * FROM ". $this->table_mail .
" 
  703                        array(
'integer', 
'integer'),
 
  704                        array($this->user_id, $a_mail_id));
 
  723                $data_types = array();
 
  725                $query = 
"UPDATE ". $this->table_mail .
" 
  727                                WHERE user_id = %s ";
 
  728                array_push($data_types, 
'text', 
'integer');
 
  729                array_push(
$data, 
'read', $this->user_id);
 
  731                $cnt_mail_ids = count($a_mail_ids);
 
  733                        if (is_array($a_mail_ids) &&
 
  734                        count($a_mail_ids) > 0)
 
  737                        $in = 
'mail_id IN (';
 
  739                        foreach($a_mail_ids as $a_mail_id)
 
  741                                array_push(
$data, $a_mail_id);
 
  742                                array_push($data_types, 
'integer');
 
  744                                if($counter > 0) 
$in .= 
',';
 
  769                $data_types = array();
 
  771                $query = 
"UPDATE ". $this->table_mail .
" 
  773                                WHERE user_id = %s ";
 
  774                array_push($data_types, 
'text', 
'integer');
 
  775                array_push(
$data, 
'unread', $this->user_id);
 
  777                $cnt_mail_ids = count($a_mail_ids);
 
  779                        if (is_array($a_mail_ids) &&
 
  780                        count($a_mail_ids) > 0)
 
  783                        $in = 
'mail_id IN (';
 
  785                        foreach($a_mail_ids as $a_mail_id)
 
  787                                array_push(
$data, $a_mail_id);
 
  788                                array_push($data_types, 
'integer');
 
  790                                if($counter > 0) 
$in .= 
',';
 
  816                $data_types = array();
 
  818                $query = 
"UPDATE ". $this->table_mail .
" 
  820                                WHERE user_id = %s ";
 
  821                array_push($data_types, 
'text', 
'integer');
 
  822                array_push(
$data, $a_folder_id, $this->user_id);
 
  824                $cnt_mail_ids = count($a_mail_ids);
 
  826                        if (is_array($a_mail_ids) &&
 
  827                        count($a_mail_ids) > 0)
 
  830                        $in = 
'mail_id IN (';
 
  832                        foreach($a_mail_ids as $a_mail_id)
 
  834                                array_push(
$data, $a_mail_id);
 
  835                                array_push($data_types, 
'integer');
 
  837                                if($counter > 0) 
$in .= 
',';
 
  860                foreach($a_mail_ids as $id)
 
  863                                DELETE FROM ". $this->table_mail .
" 
  866                                array(
'integer', 
'integer'),
 
  867                                array($this->user_id, $id)
 
  869                        $this->mfile->deassignAttachmentFromDirectory($id);
 
  886                        "mail_id"         => $a_row->mail_id,
 
  887                        "user_id"         => $a_row->user_id,
 
  888                        "folder_id"       => $a_row->folder_id,
 
  889                        "sender_id"       => $a_row->sender_id,
 
  890                        "attachments"     => unserialize(stripslashes($a_row->attachments)),
 
  891                        "send_time"       => $a_row->send_time,
 
  892                        "rcp_to"          => $a_row->rcp_to,
 
  893                        "rcp_cc"          => $a_row->rcp_cc,
 
  894                        "rcp_bcc"         => $a_row->rcp_bcc,
 
  895                        "m_status"        => $a_row->m_status,
 
  896                        "m_type"          => unserialize(stripslashes($a_row->m_type)),
 
  897                        "m_email"         => $a_row->m_email,
 
  898                        "m_subject"       => $a_row->m_subject,
 
  899                        "m_message"       => $a_row->m_message,
 
  900                        "import_name"     => $a_row->import_name,
 
  901                        "use_placeholders"=> $a_row->use_placeholders,
 
  902                        "tpl_ctx_id"      => $a_row->tpl_ctx_id,
 
  903                        "tpl_ctx_params"  => (array)(@json_decode($a_row->tpl_ctx_params, 
true))
 
  916                $next_id = 
$ilDB->nextId($this->table_mail);
 
  917                $ilDB->insert($this->table_mail, array(
 
  918                        'mail_id'        => array(
'integer', $next_id),
 
  919                        'user_id'        => array(
'integer', $usrId),
 
  920                        'folder_id'      => array(
'integer', $folderId),
 
  921                        'sender_id'      => array(
'integer', $usrId)
 
  928                $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc,
 
  929                $a_m_type, $a_m_email, $a_m_subject,  $a_m_message, $a_draft_id = 0,
 
  930                $a_use_placeholders = 0, $a_tpl_context_id = 
null, $a_tpl_context_params = array()
 
  935                $ilDB->update($this->table_mail,
 
  937                                'folder_id'                     => array(
'integer', $a_folder_id),
 
  938                                'attachments'           => array(
'clob', serialize($a_attachments)),
 
  939                                'send_time'                     => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
 
  940                                'rcp_to'                        => array(
'clob', $a_rcp_to), 
 
  941                                'rcp_cc'                        => array(
'clob', $a_rcp_cc),
 
  942                                'rcp_bcc'                       => array(
'clob', $a_rcp_bcc),
 
  943                                'm_status'                      => array(
'text', 
'read'),
 
  944                                'm_type'                        => array(
'text', serialize($a_m_type)),
 
  945                                'm_email'                       => array(
'integer', $a_m_email),
 
  946                                'm_subject'                     => array(
'text', $a_m_subject),
 
  947                                'm_message'                     => array(
'clob', $a_m_message),
 
  948                                'use_placeholders'      => array(
'integer', $a_use_placeholders),
 
  949                                'tpl_ctx_id'        => array(
'text', $a_tpl_context_id),
 
  950                                'tpl_ctx_params'        => array(
'blob', @json_encode((array)$a_tpl_context_params))
 
  953                                'mail_id'                       => array(
'integer', $a_draft_id)
 
  992                                                          $a_use_placeholders = 0,
 
  993                                                          $a_tpl_context_id = 
null,
 
  994                                                          $a_tpl_context_params = array()
 
 1001                if ($a_use_placeholders)
 
 1007                if(!$a_user_id)         $a_user_id = 
'0';
 
 1008                if(!$a_folder_id)       $a_folder_id = 
'0';
 
 1009                if(!$a_sender_id)       $a_sender_id = NULL;
 
 1010                if(!$a_attachments)     $a_attachments = NULL;
 
 1011                if(!$a_rcp_to)          $a_rcp_to = NULL;
 
 1012                if(!$a_rcp_cc)          $a_rcp_cc = NULL;
 
 1013                if(!$a_rcp_bcc)         $a_rcp_bcc = NULL;
 
 1014                if(!$a_status)          $a_status = NULL;
 
 1015                if(!$a_m_type)          $a_m_type = NULL;
 
 1016                if(!$a_m_email)         $a_m_email = NULL;
 
 1017                if(!$a_m_subject)       $a_m_subject = NULL;
 
 1018                if(!$a_m_message)       $a_m_message = NULL;
 
 1021                $next_id = 
$ilDB->nextId($this->table_mail);
 
 1022                $ilDB->insert($this->table_mail, array(
 
 1023                        'mail_id'               => array(
'integer', $next_id),
 
 1024                        'user_id'               => array(
'integer', $a_user_id),
 
 1025                        'folder_id'             => array(
'integer', $a_folder_id),
 
 1026                        'sender_id'             => array(
'integer', $a_sender_id),
 
 1027                        'attachments'   => array(
'clob', serialize($a_attachments)),
 
 1028                        'send_time'             => array(
'timestamp', date(
'Y-m-d H:i:s', time())),
 
 1029                        'rcp_to'                => array(
'clob', $a_rcp_to),
 
 1030                        'rcp_cc'                => array(
'clob', $a_rcp_cc),
 
 1031                        'rcp_bcc'               => array(
'clob', $a_rcp_bcc),
 
 1032                        'm_status'              => array(
'text', $a_status),
 
 1033                        'm_type'                => array(
'text', serialize($a_m_type)),
 
 1034                        'm_email'               => array(
'integer', $a_m_email),
 
 1035                        'm_subject'             => array(
'text', $a_m_subject),
 
 1036                        'm_message'             => array(
'clob', $a_m_message),
 
 1037                        'tpl_ctx_id'        => array(
'text', $a_tpl_context_id),
 
 1038                        'tpl_ctx_params'        => array(
'blob', @json_encode((array)$a_tpl_context_params))
 
 1054                        include_once 
'Services/Mail/classes/class.ilMailFormCall.php';
 
 1058                                require_once 
'Services/Mail/classes/class.ilMailTemplateService.php';
 
 1063                                require_once 
'Services/Mail/classes/class.ilMailTemplateGenericContext.php';
 
 1068                        foreach($context->getPlaceholders() as $key => $ph_definition)
 
 1071                                $a_message = str_replace(
'[' . $ph_definition[
'placeholder'] . 
']', 
$result, $a_message);
 
 1076                        require_once 
'./Services/Logging/classes/public/class.ilLoggerFactory.php';
 
 1096        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)
 
 1100                include_once 
'Services/Mail/classes/class.ilMailbox.php';
 
 1101                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 1103                if (!ilMail::_usePearMail())
 
 1113                if (!$a_use_placeholders) # No Placeholders
 
 1115                        $rcp_ids = $this->
getUserIds(trim($a_rcp_to).
','.trim($a_rcp_cc).
','.trim($a_rcp_bcc));
 
 1118                                "Parsed TO/CC/BCC user ids from given recipients: %s", implode(
', ', $rcp_ids)
 
 1121                        $as_email = array();
 
 1123                        foreach($rcp_ids as $id)
 
 1129                                $user_is_active = $tmp_user->getActive();
 
 1130                                $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
 
 1133                                if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
 
 1144                                        if (!$user_can_read_internal_mails ||
 
 1145                                                $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
 
 1147                                                $as_email[] = $tmp_user->getEmail();
 
 1151                                        if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
 
 1153                                                $as_email[] = $tmp_user->getEmail();
 
 1156                                $mbox->setUserId($id);
 
 1157                                $inbox_id = $mbox->getInboxFolder();
 
 1160                                                                          $a_attachments, $a_rcp_to,
 
 1161                                                                          $a_rcp_cc, 
'', 
'unread', $a_type,
 
 1162                                                                          0, $a_subject, $a_message, $id, 0);
 
 1165                                        $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
 
 1173                        if(count($as_email) == 1)
 
 1175                                $to[] = $as_email[0];
 
 1179                                foreach ($as_email as $email)
 
 1185                        if(count($to) > 0 || count($bcc) > 0)
 
 1187                                $this->
sendMimeMail(implode(
',', $to), 
'', implode(
',', $bcc), $a_subject, $a_message, $a_attachments);
 
 1190                else # Use Placeholders
 
 1193                        $rcp_ids_replace = $this->
getUserIds(trim($a_rcp_to));
 
 1196                        $rcp_ids_no_replace = $this->
getUserIds(trim($a_rcp_cc).
','.trim($a_rcp_bcc));
 
 1199                                "Parsed TO user ids from given recipients for serial letter notification: %s", implode(
', ', $rcp_ids_replace)
 
 1202                                "Parsed CC/BCC user ids from given recipients for serial letter notification: %s", implode(
', ', $rcp_ids_no_replace)
 
 1205                        $as_email = array();
 
 1208                        foreach($rcp_ids_replace as $id)
 
 1214                                $user_is_active = $tmp_user->getActive();
 
 1215                                $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
 
 1218                                if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
 
 1229                                        if (!$user_can_read_internal_mails ||
 
 1230                                                $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
 
 1232                                                $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
 
 1236                                        if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
 
 1238                                                $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
 
 1241                                $mbox->setUserId($id);
 
 1242                                $inbox_id = $mbox->getInboxFolder();
 
 1245                                                                          $a_attachments, $a_rcp_to,
 
 1246                                                                          $a_rcp_cc, 
'', 
'unread', $a_type,
 
 1247                                                                          0, $a_subject, $a_message, $id, 1);
 
 1250                                        $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
 
 1254                        if (count($as_email))
 
 1256                                foreach ($as_email as $id => $email)
 
 1262                        $as_email = array();
 
 1265                        foreach($rcp_ids_no_replace as $id)
 
 1271                                $user_is_active = $tmp_user->getActive();
 
 1272                                $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
 
 1278                                        if (in_array(
'system', $a_type) && !$user_can_read_internal_mails)
 
 1285                                        if (!$user_can_read_internal_mails ||
 
 1286                                                $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
 
 1288                                                $as_email[] = $tmp_user->getEmail();
 
 1292                                        if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
 
 1294                                                $as_email[] = $tmp_user->getEmail();
 
 1297                                $mbox->setUserId($id);
 
 1298                                $inbox_id = $mbox->getInboxFolder();
 
 1301                                                                          $a_attachments, $a_rcp_to,
 
 1302                                                                          $a_rcp_cc, 
'', 
'unread', $a_type,
 
 1303                                                                          0, $a_subject, $a_message, $id, 0);
 
 1306                                        $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
 
 1310                        if (count($as_email))
 
 1312                                $this->
sendMimeMail(
'', 
'', implode(
',', $as_email), $a_subject, $a_message, $a_attachments);
 
 1326                global 
$log, $rbacreview;
 
 1330                if (ilMail::_usePearMail() && $this->
getUsePear() == 
true)
 
 1333                        if (! is_a($tmp_names, 
'PEAR_Error'))
 
 1335                                for ($i = 0;$i < count($tmp_names); $i++)
 
 1337                                        if (substr($tmp_names[$i]->mailbox,0,1) == 
'#' || substr($tmp_names[$i]->mailbox,0,2) == 
'"#')
 
 1339                                                $role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host);
 
 1340                                                $foundUserIds = array();
 
 1341                                                foreach($role_ids as $role_id)
 
 1343                                                        foreach($rbacreview->assignedUsers($role_id) as $usr_id)
 
 1346                                                                $foundUserIds[] = $usr_id;
 
 1351                                                        "Found the following user ids by role assignments for address '%s': %s", $tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host, implode(
', ', $foundUserIds)
 
 1354                                        else if (strtolower($tmp_names[$i]->host) == self::ILIAS_HOST)
 
 1360                                                                "Found the following user ids for address '%s': %s", addslashes($tmp_names[$i]->mailbox), $id
 
 1363                                                else if(strlen($tmp_names[$i]->mailbox) > 0)
 
 1366                                                                "Did not find any user account for address '%s'", addslashes($tmp_names[$i]->mailbox)
 
 1377                                                                "Found the following user ids for address '%s': %s", $tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host, $id
 
 1383                                                                "Did not find any user account for address '%s'", $tmp_names[$i]->mailbox.
'@'.$tmp_names[$i]->host
 
 1393                        for ($i = 0;$i < count($tmp_names); $i++)
 
 1395                                if (substr($tmp_names[$i],0,1) == 
'#' || substr($tmp_names[$i], 0, 2) == 
'"#')
 
 1399                                                include_once(
"./Services/Object/classes/class.ilObjectFactory.php");
 
 1400                                                include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
 
 1407                                                $foundUserIds = array();
 
 1409                                                foreach ($grp_object->getGroupMemberIds() as $id)
 
 1412                                                        $foundUserIds[] = $id;
 
 1416                                                        "Found the following user ids by group member assignment for address '%s': %s", addslashes(substr($tmp_names[$i],1)), implode(
', ', $foundUserIds)
 
 1422                                                $possible_role_id = addslashes(substr($tmp_names[$i], 1));
 
 1423                                                $role_id          = $rbacreview->roleExists($possible_role_id);
 
 1426                                                        $foundUserIds = array();
 
 1427                                                        foreach($rbacreview->assignedUsers($role_id) as $usr_id)
 
 1430                                                                $foundUserIds[] = $usr_id;
 
 1434                                                                "Found the following user ids by role assignments for address '%s': %s", addslashes(substr($tmp_names[$i], 1)), implode(
', ', $foundUserIds)
 
 1439                                                if(substr($possible_role_id, 0, 8) == 
'il_role_')
 
 1441                                                        $role_id = substr($possible_role_id, 8);
 
 1442                                                        $roles_object_id = $rbacreview->getObjectOfRole($role_id);
 
 1443                                                        if($roles_object_id > 0)
 
 1445                                                                $foundUserIds = array();
 
 1446                                                                foreach($rbacreview->assignedUsers($role_id) as $usr_id)
 
 1449                                                                        $foundUserIds[] = $usr_id;
 
 1452                                                                        "Found the following user ids by role assignments for address '%s': %s", $possible_role_id, implode(
', ', $foundUserIds)
 
 1459                                                        "Found no user ids for address '%s'", $possible_role_id
 
 1463                                else if (!empty($tmp_names[$i]))
 
 1469                                                        "Found the following user ids for address '%s': %s", addslashes($tmp_names[$i]), $id
 
 1472                                        else if(strlen(addslashes($tmp_names[$i])) > 0)
 
 1475                                                        "Did not find any user account for address '%s'", addslashes($tmp_names[$i])
 
 1481                return array_unique($ids);
 
 1494        function checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_type)
 
 1496                $error_message = 
'';
 
 1498                $a_m_subject = trim($a_m_subject);
 
 1499                $a_rcp_to = trim($a_rcp_to);
 
 1501                if (empty($a_m_subject))
 
 1503                        $error_message .= $error_message ? 
"<br>" : 
'';
 
 1504                        $error_message .= $this->lng->txt(
"mail_add_subject");
 
 1507                if (empty($a_rcp_to))
 
 1509                        $error_message .= $error_message ? 
"<br>" : 
'';
 
 1510                        $error_message .= $this->lng->txt(
"mail_add_recipient");
 
 1513                return $error_message;
 
 1526                $addresses = array();
 
 1529                if (ilMail::_usePearMail() && $this->
getUsePear())
 
 1532                        if (! is_a($tmp_rcp, 
'PEAR_Error'))
 
 1534                                foreach ($tmp_rcp as $rcp)
 
 1537                                        if (substr($rcp->mailbox,0,1) != 
'#' && substr($rcp->mailbox,0, 2) != 
'"#')
 
 1539                                                if (strtolower($rcp->host) != self::ILIAS_HOST)
 
 1541                                                        $addresses[] = $rcp->mailbox.
'@'.$rcp->host;
 
 1548                                                        $addresses[] = $tmp_user->getEmail();
 
 1555                                                $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
 
 1556                                                foreach($role_ids as $role_id)
 
 1558                                                        foreach($rbacreview->assignedUsers($role_id) as $usr_id)
 
 1561                                                                $addresses[] = $tmp_user->getEmail();
 
 1572                        foreach ($tmp_rcp as $rcp)
 
 1575                                if (substr($rcp,0,1) != 
'#' && substr($rcp,0,2) != 
'"#')
 
 1577                                        if (strpos($rcp,
'@'))
 
 1579                                                $addresses[] = $rcp;
 
 1586                                                $addresses[] = $tmp_user->getEmail();
 
 1593                                        include_once(
"./Services/Object/classes/class.ilObjectFactory.php");
 
 1594                                        include_once(
'./Modules/Group/classes/class.ilObjGroup.php');
 
 1603                                        foreach ($grp_object->getGroupMemberIds() as $id)
 
 1606                                                $addresses[] = $tmp_user->getEmail();
 
 1624                global $rbacsystem,$rbacreview;
 
 1628                if (ilMail::_usePearMail() && $this->
getUsePear())
 
 1632                        if (is_a($tmp_rcp, 
'PEAR_Error'))
 
 1634                                $colon_pos = strpos($tmp_rcp->message, 
':');
 
 1635                                $wrong_rcps = 
'<br />'.(($colon_pos === 
false) ? $tmp_rcp->message : substr($tmp_rcp->message, $colon_pos+2));
 
 1639                                foreach ($tmp_rcp as $rcp)
 
 1642                                        if (substr($rcp->mailbox,0,1) != 
'#' && substr($rcp->mailbox,0,2) != 
'"#')
 
 1646                                                if (
$user_id == 
false && $rcp->host == self::ILIAS_HOST)
 
 1648                                                        $wrong_rcps .= 
"<br />".htmlentities($rcp->mailbox);
 
 1655                                                        if(!$rbacsystem->checkAccessOfUser(
$user_id, 
"internal_mail", $this->getMailObjectReferenceId()))
 
 1657                                                                $wrong_rcps .= 
"<br />".htmlentities($rcp->mailbox).
 
 1658                                                                        " (".$this->lng->txt(
"user_cant_receive_mail").
")";
 
 1663                                        else if (substr($rcp->mailbox, 0, 7) == 
'#il_ml_')
 
 1665                                                if (!$this->mlists->mailingListExists($rcp->mailbox))
 
 1667                                                        $wrong_rcps .= 
"<br />".htmlentities($rcp->mailbox).
 
 1668                                                                " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
 
 1676                                                $role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.
'@'.$rcp->host);
 
 1678                                                if(!$this->mail_to_global_roles && is_array($role_ids))
 
 1680                                                        foreach($role_ids as $role_id)
 
 1682                                                                if($rbacreview->isGlobalRole($role_id))
 
 1684                                                                        include_once(
'Services/Mail/exceptions/class.ilMailException.php');
 
 1690                                                if (count($role_ids) == 0)
 
 1692                                                        $wrong_rcps .= 
'<br />'.htmlentities($rcp->mailbox).
 
 1693                                                                ' ('.$this->lng->txt(
'mail_no_recipient_found').
')';
 
 1696                                                else if (count($role_ids) > 1)
 
 1698                                                        $wrong_rcps .= 
'<br/>'.htmlentities($rcp->mailbox).
 
 1699                                                                ' ('.sprintf($this->lng->txt(
'mail_multiple_recipients_found'), implode(
',', $role_ids)).
')';
 
 1709                        foreach ($tmp_rcp as $rcp)
 
 1716                                if (substr($rcp,0,1) != 
'#' && substr($rcp,0,2) != 
'"#')
 
 1721                                                $wrong_rcps .= 
"<br />".htmlentities($rcp);
 
 1728                                                if(!$rbacsystem->checkAccessOfUser($usr_id, 
"internal_mail", $this->getMailObjectReferenceId()))
 
 1730                                                        $wrong_rcps .= 
"<br />".htmlentities($rcp).
 
 1731                                                                " (".$this->lng->txt(
"user_cant_receive_mail").
")";
 
 1736                                else if(substr($rcp, 0, 7) == 
'#il_ml_')
 
 1738                                        if (!$this->mlists->mailingListExists($rcp))
 
 1740                                                $wrong_rcps .= 
"<br />".htmlentities($rcp).
 
 1741                                                        " (".$this->lng->txt(
"mail_no_valid_mailing_list").
")";
 
 1752                                        $role_id = $rbacreview->roleExists(addslashes(substr($rcp, 1)));
 
 1755                                                if(!$this->mail_to_global_roles && $rbacreview->isGlobalRole($role_id))
 
 1757                                                        include_once(
'Services/Mail/exceptions/class.ilMailException.php');
 
 1763                                        if(substr(addslashes($rcp), 1, 8) == 
'il_role_')
 
 1765                                                $role_id         = substr(addslashes($rcp), 9);
 
 1766                                                $roles_object_id = $rbacreview->getObjectOfRole($role_id);
 
 1767                                                if($roles_object_id > 0)
 
 1769                                                        if(!$this->mail_to_global_roles && $rbacreview->isGlobalRole($role_id))
 
 1771                                                                include_once(
'Services/Mail/exceptions/class.ilMailException.php');
 
 1778                                        $wrong_rcps .= 
"<br />" . htmlentities($rcp) . 
" (" . $this->lng->txt(
"mail_no_valid_group_role") . 
")";
 
 1812                                                  $a_use_placeholders,
 
 1813                                                  $a_tpl_context_id = 
null,
 
 1814                                                  $a_tpl_ctx_params = array()
 
 1820                if(!$a_attachments) $a_attachments = NULL;
 
 1821                if(!$a_rcp_to) $a_rcp_to = NULL;
 
 1822                if(!$a_rcp_cc) $a_rcp_cc = NULL;
 
 1823                if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
 
 1824                if(!$a_m_type) $a_m_type = NULL;
 
 1825                if(!$a_m_email) $a_m_email = NULL;
 
 1826                if(!$a_m_message) $a_m_message = NULL;
 
 1827                if(!$a_use_placeholders) $a_use_placeholders = 
'0';
 
 1831                        $this->table_mail_saved,
 
 1833                                'user_id'                       => array(
'integer', $this->user_id)
 
 1836                                'attachments'           => array(
'clob', serialize($a_attachments)),
 
 1837                                'rcp_to'                        => array(
'clob', $a_rcp_to),
 
 1838                                'rcp_cc'                        => array(
'clob', $a_rcp_cc),
 
 1839                                'rcp_bcc'                       => array(
'clob', $a_rcp_bcc),
 
 1840                                'm_type'                        => array(
'text', serialize($a_m_type)),
 
 1841                                'm_email'                       => array(
'integer', $a_m_email),
 
 1842                                'm_subject'                     => array(
'text', $a_m_subject),
 
 1843                                'm_message'                     => array(
'clob', $a_m_message),
 
 1844                                'use_placeholders'      => array(
'integer', $a_use_placeholders),
 
 1845                                'tpl_ctx_id'        => array(
'text', $a_tpl_context_id),
 
 1846                                'tpl_ctx_params'        => array(
'blob', json_encode((array)$a_tpl_ctx_params))
 
 1865                        SELECT * FROM '. $this->table_mail_saved .
' 
 1866                        WHERE user_id = %s',
 
 1868                        array($this->user_id));
 
 1889                                $message .= $error_message;
 
 1893                                $message .= $error_message;
 
 1897                                $message .= $error_message;
 
 1900                        if(strlen($message) > 0)
 
 1902                                return $this->lng->txt(
'mail_following_rcp_not_valid') . $message;
 
 1909                        return $this->lng->txt(
'mail_following_rcp_not_valid') . $this->lng->txt($e->getMessage());
 
 1926        function sendMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$a_type, $a_use_placeholders = 0)
 
 1928                global 
$lng,$rbacsystem;
 
 1931                        "New mail system task:" .
 
 1932                        " To: " . $a_rcp_to .
 
 1933                        " | CC: " . $a_rcp_cc .
 
 1934                        " | BCC: " . $a_rcp_bc .
 
 1935                        " | Subject: " . $a_m_subject
 
 1938                $this->mail_to_global_roles = 
true;
 
 1939                if($this->user_id != ANONYMOUS_USER_ID)
 
 1941                        $this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id, 
'mail_to_global_roles', $this->mail_obj_ref_id);
 
 1944                if (in_array(
"system",$a_type))
 
 1946                        $a_type = array(
'system');
 
 1951                        if (!$this->mfile->checkFilesExist($a_attachment))
 
 1953                                return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
 
 1957                if ($error_message = $this->
checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
 
 1959                        return $error_message;
 
 1963                if(strlen($error_message) > 0)
 
 1965                        return $error_message;
 
 1977                $rcp_to = $rcp_cc = $rcp_bc = array();          
 
 1978                foreach($rcp_to_list as $mlist_id => $mlist_rec)
 
 1983                                $mlist_id = substr($mlist_id, 7);
 
 1986                                        $rcp_bc = array_merge($rcp_bc, $mlist_rec);
 
 1991                        $rcp_to = array_merge($rcp_to, $mlist_rec);                     
 
 1993                foreach($rcp_cc_list as $mlist_id => $mlist_rec)
 
 1998                                $mlist_id = substr($mlist_id, 7);
 
 2001                                        $rcp_bc = array_merge($rcp_bc, $mlist_rec);
 
 2006                        $rcp_cc = array_merge($rcp_cc, $mlist_rec);                     
 
 2008                foreach($rcp_bc_list as $mlist_id => $mlist_rec)
 
 2010                        $rcp_bc = array_merge($rcp_bc, $mlist_rec);                     
 
 2013                $rcp_to = implode(
',', $rcp_to);
 
 2014                $rcp_cc = implode(
',', $rcp_cc);
 
 2015                $rcp_bc = implode(
',', $rcp_bc);
 
 2018                if (! ilMail::_usePearMail() )
 
 2042                if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
 
 2043                   !$rbacsystem->checkAccessOfUser($this->user_id, 
'smtp_mail', $this->mail_obj_ref_id))
 
 2045                        return $this->lng->txt(
'mail_no_permissions_write_smtp');
 
 2054                $sent_id = $this->
saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
 
 2055                                                                                $a_m_subject,$a_m_message);
 
 2059                        $this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
 
 2061                        if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
 
 2076                                "Parsed external mail addresses from given recipients:" .
 
 2077                                " To: " . $externalMailRecipientsTo .
 
 2078                                " | CC: " . $externalMailRecipientsCc .
 
 2079                                " | BCC: " . $externalMailRecipientsBcc .
 
 2080                                " | Subject: " . $a_m_subject
 
 2084                                $externalMailRecipientsTo,
 
 2085                                $externalMailRecipientsCc,
 
 2086                                $externalMailRecipientsBcc,
 
 2098                if (in_array(
'system',$a_type))
 
 2100                        if (!$this->
distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,
'system', $a_use_placeholders))
 
 2102                                return $lng->txt(
"mail_send_error");
 
 2106                if (in_array(
'normal',$a_type))
 
 2109                        if (!$this->
distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,
'normal', $a_use_placeholders))
 
 2111                                return $lng->txt(
"mail_send_error");
 
 2128                        if(!$maintain_lists)
 
 2139                if (!is_array($arrRcpt) || empty($arrRcpt))
 
 2141                        if(!$maintain_lists)
 
 2151                $new_rcpt = array();
 
 2153                foreach ($arrRcpt as $item)
 
 2155                        if (ilMail::_usePearMail())
 
 2157                                if (substr($item->mailbox, 0, 7) == 
'#il_ml_')
 
 2159                                        if ($this->mlists->mailingListExists($item->mailbox))
 
 2161                                                foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
 
 2164                                                        if(!$maintain_lists)
 
 2166                                                                $new_rcpt[] = $login;
 
 2170                                                                $new_rcpt[$item->mailbox][] = $login;
 
 2178                                        if($item->host == self::ILIAS_HOST)
 
 2180                                                $tmp_rcpt = $item->mailbox;
 
 2184                                                $tmp_rcpt = $item->mailbox.
'@'.$item->host;
 
 2187                                        if(!$maintain_lists)
 
 2189                                                $new_rcpt[] = $tmp_rcpt;
 
 2193                                                $new_rcpt[0][] = $tmp_rcpt;
 
 2199                                if (substr($item, 0, 7) == 
'#il_ml_')
 
 2201                                        if ($this->mlists->mailingListExists($item))
 
 2203                                                foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
 
 2206                                                        if(!$maintain_lists)
 
 2208                                                                $new_rcpt[] = $login;
 
 2212                                                                $new_rcpt[$item][] = $login;
 
 2219                                        if(!$maintain_lists)
 
 2221                                                $new_rcpt[] = $item;
 
 2225                                                $new_rcpt[0][] = $item;
 
 2231                if(!$maintain_lists)
 
 2233                        return implode(
',', $new_rcpt);
 
 2254                                                   $a_m_subject,$a_m_message)
 
 2256                include_once 
"Services/Mail/classes/class.ilMailbox.php";
 
 2259                $sent_id = $mbox->getSentFolder();
 
 2262                return $this->
sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
 
 2263                                                                                $a_rcp_bcc,
'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
 
 2274                include_once 
'Services/Mail/classes/class.ilMimeMail.php';
 
 2284        public function getMimeMailSender()
 
 2291                include_once 
"Services/Mail/classes/class.ilMimeMail.php";
 
 2293                if($this->user_id && $this->user_id != ANONYMOUS_USER_ID)
 
 2296                        $fullname = 
$ilUser->getFullname();
 
 2297                        if(
$ilUser->getId() != $this->user_id)
 
 2300                                $email = $user->getEmail();
 
 2301                                $fullname = $user->getFullname();
 
 2304                        $sender = array($email, $fullname);
 
 2327                include_once 
'Services/Mail/classes/class.ilMimeMail.php';
 
 2329                $no_reply_adress = trim(
$ilSetting->get(
'mail_external_sender_noreply'));
 
 2330                if(strlen($no_reply_adress))
 
 2332                        if(strpos($no_reply_adress, 
'@') === 
false)
 
 2333                                $no_reply_adress = 
'noreply@'.$no_reply_adress;
 
 2337                                $no_reply_adress = 
'noreply@'.$_SERVER[
'SERVER_NAME'];
 
 2340                        $sender = array($no_reply_adress, self::_getIliasMailerName());
 
 2344                        $sender = array(
'noreply@'.
$_SERVER[
'SERVER_NAME'], self::_getIliasMailerName());
 
 2363        function sendMimeMail($a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,$a_no_soap = 
false)
 
 2365                include_once 
"Services/Mail/classes/class.ilMimeMail.php";
 
 2367                #var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
 
 2369                #$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 4";
 
 2370                #$a_m_subject = "[".$inst_name."] ".$a_m_subject;
 
 2374                $sender = $this->getMimeMailSender();
 
 2380                        include_once 
'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
 
 2383                        $soap_client->setResponseTimeout(5);
 
 2384                        $soap_client->enableWSDL(
true);
 
 2385                        $soap_client->init();
 
 2387                        $attachments = array();
 
 2388                        $a_attachments = $a_attachments ? $a_attachments : array();
 
 2389                        foreach($a_attachments as $attachment)
 
 2391                                $attachments[] = $this->mfile->getAbsolutePath($attachment);
 
 2394                        $attachments = implode(
'#:#',$attachments);
 
 2396                        if(strlen($attachments))  
 
 2397                                $attachments = 
"#:#".$attachments;
 
 2399                        $soap_client->call(
'sendMail',array(session_id().
'::'.
$_COOKIE[
'ilClientId'],   
 
 2403                                                                                                is_array($sender) ? implode(
'#:#', $sender) : $sender,
 
 2413                        include_once 
"Services/Mail/classes/class.ilMimeMail.php";
 
 2416                        $mmail->autoCheck(
false);
 
 2417                        $mmail->From($sender);
 
 2418                        $mmail->To($a_rcp_to);
 
 2420                        $mmail->Subject($a_m_subject);
 
 2421                        $mmail->Body($a_m_message);
 
 2425                                $mmail->Cc($a_rcp_cc);
 
 2430                                $mmail->Bcc($a_rcp_bcc);
 
 2433                        if (is_array($a_attachments))
 
 2435                                foreach ($a_attachments as $attachment)
 
 2437                                        $mmail->Attach($this->mfile->getAbsolutePath($attachment), 
'', 
'inline', $attachment);
 
 2452                $sender = $umail->getEmail();
 
 2474                $ilDB->update($this->table_mail_saved,
 
 2477                                'attachments' => array(
'clob', serialize($a_attachments))
 
 2481                                'user_id' => array(
'integer', $this->user_id)
 
 2495                return $this->mail_data[
"attachments"] ? $this->mail_data[
"attachments"] : array();
 
 2513                $a_recipients = trim($a_recipients);
 
 2516                #$a_recipients = preg_replace("/ /",",",$a_recipients);
 
 2517                $a_recipients = preg_replace(
"/;/",
",",$a_recipients);
 
 2519                if (ilMail::_usePearMail() && 
$use_pear == 
true)
 
 2521                        if (strlen(trim($a_recipients)) > 0)
 
 2524                                        "Started Mail_RFC822 parsing of recipient string: %s", $a_recipients
 
 2527                                require_once 
'./Services/PEAR/lib/Mail/RFC822.php';
 
 2529                                $addresses = $parser->parseAddressList($a_recipients, self::ILIAS_HOST, 
false, 
true);
 
 2531                                if(!is_a($a_recipients, 
'PEAR_Error'))
 
 2534                                                "Parsed addresses: %s", implode(
',', array_map(
function($address) {
 
 2535                                                        return $address->mailbox . 
'@' . $address->host;
 
 2542                                                "Parsing with Mail_RFC822 failed  ..." 
 2554                        foreach(explode(
',',$a_recipients) as $tmp_rec)
 
 2558                                        $rcps[] = trim($tmp_rec);
 
 2561                        if(strlen($a_recipients) > 0)
 
 2564                                        "Parsed recipient string %s with result: %s", $a_recipients, implode(
',', $rcps)
 
 2567                        return is_array($rcps) ? $rcps : array();
 
 2576                if (ilMail::_usePearMail() && $this->
getUsePear())
 
 2579                        if (! is_a($tmp_rcp, 
'PEAR_Error'))
 
 2581                                foreach ($tmp_rcp as $to)
 
 2594                                                if ($to->host != self::ILIAS_HOST && substr($to->mailbox,0,1) != 
'#' && substr($to->mailbox,0,2) != 
'"#')
 
 2613                                        if (strpos($to,
'@'))
 
 2643                if (ilMail::_usePearMail())
 
 2647                        if (! is_a($tmp_rcp, 
'PEAR_Error'))
 
 2649                                foreach ($tmp_rcp as $to)
 
 2651                                        if(substr($to->mailbox,0,1) != 
'#' && substr($to->mailbox,0,2) != 
'"#' && $to->host != self::ILIAS_HOST)
 
 2659                                                $rcp[] = $to->mailbox.
'@'.$to->host;
 
 2663                        return implode(
',',$rcp);
 
 2681                        return implode(
',',$rcp ? $rcp : array());
 
 2687                $inst_name = $this->
ilias->getSetting(
"inst_name") ? $this->
ilias->getSetting(
"inst_name") : 
"ILIAS 3";
 
 2689                $message = $inst_name.
" To:".$rcp_to.
"\n";
 
 2693                        $message .= 
"Cc: ".$rcp_cc;
 
 2697                $message .= $a_m_message;
 
 2711                $new_name = array();
 
 2716                foreach($tmp_names as $name)
 
 2718                        if(strpos($name,
"#") === 0)
 
 2720                                $new_name[] = $name;
 
 2728                                                $new_name[] = preg_replace(
"/@/",
"�#�",$name);
 
 2732                                                $new_name[] = $name;
 
 2736                                case "resubstitute":
 
 2737                                        if(stristr($name,
"�#�"))
 
 2739                                                $new_name[] = preg_replace(
"/�#�/",
"@",$name);
 
 2743                                                $new_name[] = $name;
 
 2748                return implode(
",",$new_name);
 
 2768                if (ilMail::_usePearMail())
 
 2772                                require_once 
'./Services/User/classes/class.ilObjUser.php';
 
 2774                                $login = $usr_obj->getLogin();
 
 2775                                $firstname = $usr_obj->getFirstname();
 
 2776                                $lastname = $usr_obj->getLastname();
 
 2786                        return $login.
'hhho';
 
 2799        public static function _usePearMail()
 
 2806                return $ilSetting->get(
'pear_mail_enable', 0);
 
 2823                        include_once(
'./Services/Language/classes/class.ilLanguageFactory.php');
 
 2828                $lang->loadLanguageModule(
'mail');
 
 2829                return sprintf(
$lang->txt(
'mail_auto_generated_info'),
 
 2840        public static function _getIliasMailerName()
 
 2847                if(strlen(
$ilSetting->get(
'mail_system_sender_name')))
 
 2849                        return $ilSetting->get(
'mail_system_sender_name');
 
 2851                else if(strlen(
$ilSetting->get(
'short_inst_name')))
 
 2869                if(
null === $a_flag) {
 
 2888                global $ilClientIniFile;
 
 2890                $signature = 
"\n\n* * * * *\n";
 
 2892                $signature .= $ilClientIniFile->readVariable(
'client', 
'name').
"\n";
 
 2893                if(strlen($desc = $ilClientIniFile->readVariable(
'client', 
'description')))
 
 2895                        $signature .= $desc.
"\n";
 
 2901                if(is_array($clientdirs) && count($clientdirs) > 1)
 
 2904                        $signature .= 
'/login.php?client_id='.CLIENT_ID;
 
 2907                $signature .= 
"\n\n";
 
 2919                static $prefix = 
null;
 
 2921                return $prefix == 
null ? 
$ilSetting->get(
'mail_subject_prefix',
'') : $prefix;
 
 2933                $lang = $a_language ? $a_language : 
$lng;
 
 2935                $lang->loadLanguageModule(
'mail');
 
 2937                $gender = $gender ? $gender : 
'n';
 
 2940                if(!strlen($name[
'firstname']))
 
 2942                        return $lang->txt(
'mail_salutation_anonymous').
',';
 
 2945                return $lang->txt(
'mail_salutation_'.$gender).
' '.
 
 2946                        ($name[
'title'] ? $name[
'title'].
' ' : 
'').
 
 2947                        ($name[
'firstname'] ? $name[
'firstname'].
' ' : 
'').
 
 2948                        $name[
'lastname'].
',';
 
 2953                $this->use_pear = $bool;
 
 2968                if(ilMail::_usePearMail())
 
 2972                        if(is_a($tmp_names, 
'PEAR_Error'))
 
 2993                if(isset(self::$userInstances[$a_usr_id]))
 
 2995                        return self::$userInstances[$a_usr_id];
 
 2998                self::$userInstances[$a_usr_id] = 
new ilObjUser($a_usr_id);
 
 2999                return self::$userInstances[$a_usr_id];
 
const DB_FETCHMODE_OBJECT
static getType()
Get context type.
This class handles all operations on files (attachments) in directory ilias_data/mail.
static _getLanguage($a_lang_key='')
Get langauge object.
static getLogger($a_component_id)
Get component logger.
ILIAS Exception for Service Mail.
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
Class UserMail this class handles user mails.
static getTemplateContextById($a_id)
Class Mail this class handles base functions for mail handling.
static getCachedUserInstance($a_usr_id)
Returns a cached instance of ilObjUser.
static getSalutation($a_usr_id, $a_language=null)
Get salutation.
doesRecipientStillExists($a_recipient, $a_existing_recipients)
parseRcptOfMailingLists($rcpt='', $maintain_lists=false)
replacePlaceholders($a_message, $a_user_id=0)
deleteMails(array $a_mail_ids)
Delete mails.
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)
send internal message to recipients @access private
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
sendMimeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments, $a_no_soap=false)
send mime mail using class.ilMimeMail.php All external mails are send to SOAP::sendMail starting a ki...
setSaveInSentbox($a_save_in_sentbox)
__getEmailRecipients($a_rcp)
getMail($a_mail_id)
get data of one mail @access public
markUnread($a_mail_ids)
mark mails as unread @access public
checkRecipients($a_recipients)
check if recipients are valid @access public
formatNamesForOutput($users='')
Prepends the fullname of each ILIAS login name (is user has a public profile) found in the passed str...
moveMailsToFolder($a_mail_ids, $a_folder_id)
move mail to folder @access public
__getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
explodeRecipients($a_recipients, $use_pear=true)
explode recipient string allowed seperators are ',' ';' ' '
updateDraft( $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_draft_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
static getIliasMailerAddress()
Builds an email address used for system notifications.
static addFullname($a_email, $a_fullname)
getEmailsOfRecipients($a_rcp)
get email addresses of recipients @access public
countMailsOfFolder($a_folder_id)
count all mails of a specific folder @access public
getUserIds($a_recipients)
get user_ids
savePostData($a_user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_use_placeholders, $a_tpl_context_id=null, $a_tpl_ctx_params=array())
save post data in table @access public
getMailsOfFolder($a_folder_id, $filter=array())
__substituteRecipients($a_rcp, $direction)
Note: This function can only be used, when ILIAS is configured to not use standards compliant mail ad...
saveAttachments($a_attachments)
set attachments
static getSubjectPrefix()
Get text that will be prepended to auto generated mails.
setMailSubject($a_subject)
setMailMessage($a_message)
getNewDraftId($usrId, $folderId)
getEmailOfSender()
get email of sender @access public
__getCountRecipient($rcp, $a_only_email=true)
getAttachments()
get attachments @access public
static _getInstallationSignature()
Static getter for the installation signature.
static _getUserInternalMailboxAddress($usr_id, $login=null, $firstname=null, $lastname=null)
static _getAutoGeneratedMessageString($lang=null)
get auto generated info string
fetchMailData($a_row)
fetch all query data from table mail @access public
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
send mime mail using class.ilMimeMail.php
getPreviousMail($a_mail_id)
getMailCounterData()
get mail counter data returns data array with indexes "total","read","unread" @access public
__construct($a_user_id)
Constructor setup an mail object @access public.
deleteMailsOfFolder($a_folder_id)
delete all mails of a specific folder @access public
setMailSendType($a_types)
$appendInstallationSignature
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
check if mail is complete, recipients are valid @access public
getMailObjectReferenceId()
markRead($a_mail_ids)
mark mails as read @access public
validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
sendMail($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
send external mail using class.ilMimeMail.php
readMailObjectReferenceId()
read and set mail object id @access private
__get($name)
Magic interceptor method __get Used to include files / instantiate objects at runtime.
sendInternalMail($a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder @access private
__prependMessage($a_m_message, $rcp_to, $rcp_cc)
validatePear($a_recipients)
getSavedData()
get saved data @access public
Mail Box class Base class for creating and handling mail boxes.
this class encapsulates the PHP mail() function.
_lookupIdByTitle($a_title)
static _lookupLogin($a_user_id)
lookup login
getUserIdByLogin($a_login)
static _lookupId($a_user_str)
Lookup id by login.
static _lookupGender($a_user_id)
Lookup gender.
static _lookupName($a_user_id)
lookup user name
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
_lookupPref($a_usr_id, $a_keyword)
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences($a_id)
get all reference ids of object
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.
redirection script todo: (a better solution should control the processing via a xml file)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']