Пример #1
0
 /**
  * Send notification by email that a plugin is waiting to be
  * approved to everyone with permission to approve it.
  *
  * @param string $plugin_name
  * @param string $body plugin body
  * @param array $arguments plugin arguments
  * @param array $context object type and id
  * @return void
  */
 private function plugin_pending_notification($plugin_name, $body, $arguments, $context)
 {
     require_once 'lib/webmail/tikimaillib.php';
     global $prefs, $base_url;
     $mail = new TikiMail(null, $prefs['sender_email']);
     $mail->setSubject(tr("Plugin %0 pending approval", $plugin_name));
     $smarty = TikiLib::lib('smarty');
     $smarty->assign('plugin_name', $plugin_name);
     $smarty->assign('type', $context['type']);
     $smarty->assign('objectId', $context['object']);
     $smarty->assign('arguments', $arguments);
     $smarty->assign('body', $body);
     $mail->setHtml(nl2br($smarty->fetch('mail/plugin_pending_notification.tpl')));
     $recipients = $this->plugin_get_email_users_with_perm();
     $mail->setBcc($recipients);
     if (!empty($prefs['sender_email'])) {
         $mail->send(array($prefs['sender_email']));
     } elseif ($admin_email = TikiLib::lib('user')->get_user_email('admin')) {
         $recipients = array_diff($recipients, array($admin_email));
         $mail->setBcc($recipients);
         $mail->send(array($admin_email));
     }
 }
Пример #2
0
 // Send a message
 if (isset($_REQUEST["reply"]) || isset($_REQUEST["replyall"])) {
     check_ticket('webmail');
     $webmaillib->set_mail_flag($current["accountId"], $user, $_REQUEST["realmsgid"], 'isReplied', 'y');
 }
 $smarty->assign('sent', 'n');
 $smarty->assign('attaching', 'n');
 if (isset($_REQUEST["send"])) {
     $mail = new TikiMail($user);
     $email = $userlib->get_user_email($user);
     $mail->setFrom($email);
     if (!empty($_REQUEST["cc"])) {
         $mail->setCc($_REQUEST["cc"]);
     }
     if (!empty($_REQUEST["bcc"])) {
         $mail->setBcc($_REQUEST["bcc"]);
     }
     $mail->setSubject($_REQUEST["subject"]);
     if ($_REQUEST["attach1"]) {
         check_ticket('webmail');
         $a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach1file"]);
         $mail->addAttachment($a1, $_REQUEST["attach1"], $_REQUEST["attach1type"]);
         @unlink('temp/mail_attachs/' . $_REQUEST["attach1file"]);
     }
     if ($_REQUEST["attach2"]) {
         check_ticket('webmail');
         $a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach2file"]);
         $mail->addAttachment($a2, $_REQUEST["attach2"], $_REQUEST["attach2type"]);
         @unlink('temp/mail_attachs/' . $_REQUEST["attach2file"]);
     }
     if ($_REQUEST["attach3"]) {
Пример #3
0
 $headerlib->add_js('if (webmailTimeoutId) {window.clearTimeout(webmailTimeoutId);}', 0);
 // Send a message
 if (isset($_REQUEST['reply']) || isset($_REQUEST['replyall'])) {
     check_ticket('webmail');
     $webmaillib->set_mail_flag($current['accountId'], $user, $_REQUEST['realmsgid'], 'isReplied', 'y');
 }
 $smarty->assign('sent', 'n');
 $smarty->assign('attaching', 'n');
 if (isset($_REQUEST['send'])) {
     $email = empty($current['fromEmail']) ? $userlib->get_user_email($user) : $current['fromEmail'];
     $mail = new TikiMail($user, $email);
     if (!empty($_REQUEST['cc'])) {
         $mail->setCc($_REQUEST['cc']);
     }
     if (!empty($_REQUEST['bcc'])) {
         $mail->setBcc($_REQUEST['bcc']);
     }
     $mail->setSubject($_REQUEST['subject']);
     if ($_REQUEST['attach1']) {
         check_ticket('webmail');
         $a1 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach1file']);
         $mail->addAttachment($a1, $_REQUEST['attach1'], $_REQUEST['attach1type']);
         @unlink('temp/mail_attachs/' . $_REQUEST['attach1file']);
     }
     if ($_REQUEST['attach2']) {
         check_ticket('webmail');
         $a2 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach2file']);
         $mail->addAttachment($a2, $_REQUEST['attach2'], $_REQUEST['attach2type']);
         @unlink('temp/mail_attachs/' . $_REQUEST['attach2file']);
     }
     if ($_REQUEST['attach3']) {
Пример #4
0
 function action_email_wikipage($input)
 {
     Services_Exception_Disabled::check('feature_wiki');
     Services_Exception_Denied::checkGlobal('admin_users');
     $check = Services_Exception_BadRequest::checkAccess();
     //first pass - show confirm popup
     if (!empty($check['ticket'])) {
         $users = $input->asArray('checked');
         if (count($users) > 0) {
             //provide redirect if js is not enabled
             $referer = Services_Utilities_Controller::noJsPath();
             return ['title' => tra('Send wiki page content by email to selected users'), 'confirmAction' => $input->action->word(), 'confirmController' => 'user', 'customMsg' => tra('For these selected users:'), 'items' => $users, 'extra' => ['referer' => $referer], 'ticket' => $check['ticket'], 'modal' => '1', 'confirm' => 'y'];
         } else {
             throw new Services_Exception(tra('No users were selected. Please select one or more users.'), 409);
         }
         //after confirm submit - perform action and return success feedback
     } elseif ($check === true && $_SERVER['REQUEST_METHOD'] === 'POST') {
         $wikiTpl = $input['wikiTpl'];
         $tikilib = TikiLib::lib('tiki');
         $pageinfo = $tikilib->get_page_info($wikiTpl);
         if (!$pageinfo) {
             throw new Services_Exception_NotFound(tra('Page not found'));
         }
         if (empty($pageinfo['description'])) {
             throw new Services_Exception(tra('The page does not have a description, which is mandatory to perform this action.'));
         }
         $bcc = $input['bcc'];
         include_once 'lib/webmail/tikimaillib.php';
         $mail = new TikiMail();
         if (!empty($bcc)) {
             if (!validate_email($bcc)) {
                 throw new Services_Exception(tra('Invalid bcc email address.'));
             }
             $mail->setBcc($bcc);
             $bccmsg = tr('and blind copied to %0', $bcc);
         }
         $foo = parse_url($_SERVER['REQUEST_URI']);
         $machine = $tikilib->httpPrefix(true) . dirname($foo['path']);
         $machine = preg_replace('!/$!', '', $machine);
         // just in case
         global $smarty, $user;
         $smarty->assign_by_ref('mail_machine', $machine);
         $users = json_decode($input['items'], true);
         $logslib = TikiLib::lib('logs');
         foreach ($users as $mail_user) {
             $smarty->assign_by_ref('user', $mail_user);
             $mail->setUser($mail_user);
             $mail->setSubject($pageinfo['description']);
             $text = $smarty->fetch('wiki:' . $wikiTpl);
             if (empty($text)) {
                 throw new Services_Exception(tra('The template page has no text or it cannot be extracted.'));
             }
             $mail->setHtml($text);
             if (!$mail->send($this->lib->get_user_email($mail_user))) {
                 $errormsg = tra('Unable to send mail');
                 if (Perms::get()->admin) {
                     $mailerrors = print_r($mail->errors, true);
                     $errormsg .= $mailerrors;
                 }
                 throw new Services_Exception($errormsg);
             } else {
                 if (!empty($bcc)) {
                     $logmsg = sprintf(tra('Mail sent to user %s'), $mail_user);
                 }
                 $logmsg = !empty($bccmsg) ? $logmsg . ' ' . $bccmsg : $logmsg;
                 if (!empty($msg)) {
                     $logslib->add_log('adminusers', $logmsg, $user);
                 }
             }
             $smarty->assign_by_ref('user', $user);
         }
         //return to page
         //if javascript is not enabled
         $extra = json_decode($input['extra'], true);
         if (!empty($extra['referer'])) {
             $this->access->redirect($extra['referer'], tra('Page sent'), null, 'feedback');
         }
         $msg = count($users) === 1 ? tr('The page %0 has been emailed to the following user:'******'The page %0 has been emailed to the following users:', $wikiTpl);
         $toMsg = !empty($bcc) ? tr('And blind copied to %0.', $bcc) : '';
         return ['extra' => 'post', 'feedback' => ['ajaxtype' => 'feedback', 'ajaxheading' => tra('Success'), 'ajaxitems' => $users, 'ajaxmsg' => $msg, 'ajaxtoMsg' => $toMsg, 'modal' => '1']];
     }
 }
Пример #5
0
 /**
  * Send a message to a user
  *
  * @param string $user		username
  * @param string $from		from username
  * @param string $to		to username (again?)
  * @param string $cc		cc username
  * @param string $subject
  * @param string $body
  * @param int    $priority
  * @param string $replyto_hash
  * @param string $replyto_email y/n
  * @param string $bcc_sender	y/n send blind copy email to from user's
  * @return bool				success
  */
 function post_message($user, $from, $to, $cc, $subject, $body, $priority, $replyto_hash = '', $replyto_email = '', $bcc_sender = '')
 {
     global $prefs;
     $userlib = TikiLib::lib('user');
     $smarty = TikiLib::lib('smarty');
     $subject = strip_tags($subject);
     $body = strip_tags($body, '<a><b><img><i>');
     // Prevent duplicates
     $hash = md5($subject . $body);
     if ($this->getOne('select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?', array($user, $from, $hash))) {
         return false;
     }
     $query = 'insert into `messu_messages`' . ' (`user`, `user_from`, `user_to`, `user_cc`, `subject`, `body`, `date`' . ', `isRead`, `isReplied`, `isFlagged`, `priority`, `hash`, `replyto_hash`)' . ' values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $this->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $this->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash));
     // Now check if the user should be notified by email
     $magId = $this->getOne('select LAST_INSERT_ID() from `messu_messages`', array());
     $foo = parse_url($_SERVER['REQUEST_URI']);
     $machine = $this->httpPrefix(true) . $foo['path'];
     $machine = str_replace('messu-compose', 'messu-mailbox', $machine);
     $machine = str_replace('messu-broadcast', 'messu-mailbox', $machine);
     // For non-sefurl calls, replace tiki-ajax_services with messu-mailbox if
     // service called is user > send_message
     if ($foo['query'] == "controller=user&action=send_message") {
         $machine = str_replace('tiki-ajax_services', 'messu-mailbox', $machine);
     }
     //For sefurl service call user > send_message, redirect to messu-mailbox.php
     $machine = str_replace('tiki-user-send_message', 'messu-mailbox.php', $machine);
     if ($this->get_user_preference($user, 'minPrio', 6) <= $priority) {
         if (!isset($_SERVER['SERVER_NAME'])) {
             $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
         }
         $email = $userlib->get_user_email($user);
         if ($userlib->user_exists($from)) {
             $from_email = $userlib->get_user_email($from);
             // $from_email required for TikiMail constructor
         } elseif ($from == 'tiki-contact.php' && !empty($prefs['sender_email'])) {
             $from_email = $prefs['sender_email'];
         } else {
             return false;
             // non-existent users can't send messages (etc)
         }
         if ($email) {
             include_once 'lib/webmail/tikimaillib.php';
             $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
             $smarty->assign('mail_machine', $machine);
             $smarty->assign('mail_date', $this->now);
             $smarty->assign('mail_user', stripslashes($user));
             $smarty->assign('mail_from', stripslashes($from));
             $smarty->assign('mail_subject', stripslashes($subject));
             $smarty->assign('mail_body', stripslashes($body));
             $smarty->assign('mail_truncate', $prefs['messu_truncate_internal_message']);
             $smarty->assign('messageid', $magId);
             try {
                 $mail = new TikiMail($user, $from_email);
                 $lg = $this->get_user_preference($user, 'language', $prefs['site_language']);
                 if (empty($subject)) {
                     $s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl');
                     $mail->setSubject(sprintf($s, $_SERVER['SERVER_NAME']));
                 } else {
                     $mail->setSubject($subject);
                 }
                 $mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl');
                 $mail->setText($mail_data);
                 if ($from_email) {
                     if ($bcc_sender === 'y' && !empty($from_email)) {
                         $mail->setBcc($from_email);
                     }
                     if ($replyto_email !== 'y' && $userlib->get_user_preference($from, 'email is public', 'n') == 'n') {
                         $from_email = '';
                         // empty $from_email if not to be used - saves getting it twice
                     }
                     if (!empty($from_email)) {
                         $mail->setReplyTo($from_email);
                     }
                 }
                 if (!$mail->send(array($email), 'mail')) {
                     return false;
                     //TODO echo $mail->errors;
                 }
             } catch (Zend_Mail_Exception $e) {
                 TikiLib::lib('errorreport')->report($e->getMessage());
                 return false;
             }
         }
     }
     return true;
 }
Пример #6
0
function wikiplugin_mail($data, $params)
{
    global $user;
    $userlib = TikiLib::lib('user');
    $smarty = TikiLib::lib('smarty');
    $tikilib = TikiLib::lib('tiki');
    static $ipluginmail = 0;
    $smarty->assign_by_ref('ipluginmail', $ipluginmail);
    $default = array('showuser' => 'y', 'showuserdd' => 'n', 'showrealnamedd' => 'n', 'showgroupdd' => 'n', 'group' => array(), 'recurse' => 'y', 'recurseuser' => 0, 'popup' => 'n', 'label_name' => tra('Send mail'), 'mail_subject' => '', 'bypass_preview' => 'n', 'debug' => 'n');
    $params = array_merge($default, $params);
    $default = array('mail_subject' => '', 'mail_mess' => '', 'mail_user_dd' => '', 'mail_group_dd' => array());
    $_REQUEST = array_merge($default, $_REQUEST);
    $mail_error = false;
    $preview = false;
    $smarty->assign('mail_popup', $params['popup']);
    $smarty->assign('mail_label_name', $params['label_name']);
    $smarty->assign('mail_subject', $params['mail_subject']);
    $smarty->assign('bypass_preview', $params['bypass_preview']);
    if ($params['showrealnamedd'] == 'y') {
        $users = $tikilib->list_users(0, -1, 'pref:realName_asc', '', true);
        $smarty->assign('names', $users['data']);
    }
    if ($params['showuserdd'] == 'y') {
        $users = $tikilib->list_users(0, -1, 'login_asc');
        $smarty->assign_by_ref('users', $users['data']);
    }
    if ($params['showgroupdd'] == 'y') {
        if (!empty($params['group'])) {
            foreach ($params['group'] as $g) {
                $groups[$g] = $userlib->get_including_groups($g, $params['recurse']);
            }
        } else {
            $groups[] = $userlib->list_all_groups();
        }
        $smarty->assign_by_ref('groups', $groups);
    }
    if (isset($_REQUEST["mail_preview{$ipluginmail}"])) {
        $to = wikiplugin_mail_to(array_merge($_REQUEST, $params));
        $_SESSION['wikiplugin_mail_to'] = $to;
        $preview = true;
        $smarty->assign('preview', $preview);
        $smarty->assign('nbTo', count($to));
    }
    if (isset($_REQUEST["mail_send{$ipluginmail}"])) {
        // send something
        if ($params['bypass_preview'] == 'y') {
            $to = wikiplugin_mail_to(array_merge($_REQUEST, $params));
        } else {
            $to = $_SESSION['wikiplugin_mail_to'];
        }
        if (!empty($to)) {
            include_once 'lib/webmail/tikimaillib.php';
            $mail = new TikiMail(null, $userlib->get_user_email($user));
            $mail->setSubject($_REQUEST['mail_subject']);
            $mail->setText($_REQUEST['mail_mess']);
            $myself = array($userlib->get_user_email($GLOBALS['user']));
            $mail->setBcc(array_diff($to, $myself));
            if ($mail->send($myself)) {
                $smarty->assign('nbSentTo', count($to));
                if ($userlib->user_has_permission($user, 'tiki_p_admin') && $params['debug'] == 'y') {
                    $smarty->assign('sents', $to);
                } else {
                    $smarty->assign('sents', array());
                }
            } else {
                $mail_error = true;
            }
        }
        unset($_SESSION['wikiplugin_mail_to']);
    }
    $smarty->assign_by_ref('mail_error', $mail_error);
    if ($preview || $mail_error) {
        $smarty->assign('mail_user', isset($_REQUEST['mail_user']) ? $_REQUEST['mail_user'] : '');
        $smarty->assign('mail_user_dd', isset($_REQUEST['mail_user_dd']) ? $_REQUEST['mail_user_dd'] : array());
        $smarty->assign('mail_group_dd', isset($_REQUEST['mail_group_dd']) ? $_REQUEST['mail_group_dd'] : array());
        $smarty->assign('mail_subject', $_REQUEST['mail_subject']);
        $smarty->assign('mail_mess', $_REQUEST['mail_mess']);
    }
    // Convert the array of mail_user into a string of emails separated by comma, and expose the values to the smarty tpl
    $smarty->assign('mail_user', isset($_REQUEST['mail_user']) ? implode(", ", $_REQUEST['mail_user']) : '');
    $smarty->assign_by_ref('params', $params);
    return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_mail.tpl') . '~/np~';
}
Пример #7
0
 /**
  * Send a message to a user with gpg-armor block etc included
  * A changed encryption-related version was copied/changed from lib/messu/messulib.pgp
  * into lib/openpgp/openpgplib.php for prepending/appending content into
  * message body
  * @param  string	$user
  * @param  string	$from
  * @param  string	$to
  * @param  string	$cc
  * @param  string	$subject
  * @param  string	$body
  * @param  string	$prepend_email_body
  * @param  string	$user_pubkeyarmor
  * @param  string	$priority
  * @param  string	$replyto_hash
  * @param  string	$replyto_email
  * @param  string	$bcc_sender
  * @access public
  * @return boolean	true/false
  */
 function post_message_with_pgparmor_attachment($user, $from, $to, $cc, $subject, $body, $prepend_email_body, $user_pubkeyarmor, $priority, $replyto_hash = '', $replyto_email = '', $bcc_sender = '')
 {
     global $prefs;
     $userlib = TikiLib::lib('user');
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     $subject = strip_tags($subject);
     $body = strip_tags($body, '<a><b><img><i>');
     // Prevent duplicates
     $hash = md5($subject . $body);
     if ($tikilib->getOne("select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?", array($user, $from, $hash))) {
         return false;
     }
     $query = "insert into `messu_messages`(`user`,`user_from`,`user_to`,`user_cc`,`subject`,`body`,`date`,`isRead`,`isReplied`,`isFlagged`,`priority`,`hash`,`replyto_hash`) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
     $tikilib->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $tikilib->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash));
     // Now check if the user should be notified by email
     $foo = parse_url($_SERVER["REQUEST_URI"]);
     $machine = $tikilib->httpPrefix(true) . $foo["path"];
     $machine = str_replace('messu-compose', 'messu-mailbox', $machine);
     if ($tikilib->get_user_preference($user, 'minPrio', 6) <= $priority) {
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
         }
         $email = $userlib->get_user_email($user);
         if ($email) {
             include_once 'lib/webmail/tikimaillib.php';
             $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
             $smarty->assign('mail_machine', $machine);
             $smarty->assign('mail_date', $tikilib->now);
             $smarty->assign('mail_user', stripslashes($user));
             $smarty->assign('mail_from', stripslashes($from));
             $smarty->assign('mail_subject', stripslashes($subject));
             ////////////////////////////////////////////////////////////////////////
             //                                                                    //
             // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION      //
             // USING lib/openpgp/opepgplib.php                                    //
             //                                                                    //
             // prepend original headers into email                                //
             $aux_body = $prepend_email_body . $body;
             $body = $aux_body;
             //                                                                    //
             ////////////////////////////////////////////////////////////////////////
             $smarty->assign('mail_body', stripslashes($body));
             $mail = new TikiMail($user);
             $lg = $tikilib->get_user_preference($user, 'language', $prefs['site_language']);
             if (empty($subject)) {
                 $s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl');
                 $mail->setSubject(sprintf($s, $_SERVER["SERVER_NAME"]));
             } else {
                 $mail->setSubject($subject);
             }
             $mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl');
             ////////////////////////////////////////////////////////////////////////
             //                                                                    //
             // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION      //
             // USING lib/openpgp/opepgplib.php                                    //
             //                                                                    //
             // append pgparmor block and fingerprint into email                   //
             $mail_data .= $user_pubkeyarmor;
             //                                                                    //
             ////////////////////////////////////////////////////////////////////////
             $mail->setText($mail_data);
             if ($userlib->user_exists($from)) {
                 $from_email = $userlib->get_user_email($from);
                 if ($bcc_sender === 'y' && !empty($from_email)) {
                     $mail->setBcc($from_email);
                 }
                 if ($replyto_email !== 'y' && $userlib->get_user_preference($from, 'email is public', 'n') == 'n') {
                     $from_email = '';
                     // empty $from_email if not to be used - saves getting it twice
                 }
                 if (!empty($from_email)) {
                     $mail->setReplyTo($from_email);
                 }
             }
             if (!empty($from_email)) {
                 $mail->setFrom($from_email);
             }
             if (!$mail->send(array($email), 'mail')) {
                 return false;
                 //TODO echo $mail->errors;
             }
         }
     }
     return true;
 }
Пример #8
0
 /**
  * This is a function to invite users to temporarily access the site via a token
  * @param array $emails Emails to send the invite to
  * @param array $groups Groups that the temporary user should have (Registered is not included unless explicitly added)
  * @param int $timeout How long the invitation is valid for, in seconds.
  * @param string $prefix Username of the created users will be the token ID prefixed with this
  * @param string $path Users will have to autologin using this path on the site using the token
  * @throws Exception
  */
 function invite_tempuser($emails, $groups, $timeout, $prefix = 'guest', $path = 'index.php')
 {
     global $smarty, $user, $prefs;
     include_once 'lib/webmail/tikimaillib.php';
     $mail = new TikiMail();
     foreach ($emails as $email) {
         if (!validate_email($email)) {
             throw new Exception(tr('Invalid email address "%0"', $email));
         }
     }
     $foo = parse_url($_SERVER['REQUEST_URI']);
     $machine = $this->httpPrefix(true) . dirname($foo['path']);
     $machine = preg_replace('!/$!', '', $machine);
     // just in case
     $smarty->assign_by_ref('mail_machine', $machine);
     $smarty->assign('mail_sender', $user);
     $smarty->assign('expiry', $user);
     $mail->setBcc($this->get_user_email($user));
     $smarty->assign('token_expiry', $this->get_long_datetime($this->now + $timeout));
     require_once 'lib/auth/tokens.php';
     foreach ($emails as $email) {
         $tokenlib = AuthTokens::build($prefs);
         $token_url = $tokenlib->includeToken($machine . "/{$path}", $groups, $email, $timeout, -1, true, $prefix);
         include_once 'tiki-sefurl.php';
         $token_url = filter_out_sefurl($token_url);
         $smarty->assign('token_url', $token_url);
         $mail->setUser($user);
         $mail->setSubject($smarty->fetch('mail/invite_tempuser_subject.tpl'));
         $mail->setHtml($smarty->fetch('mail/invite_tempuser.tpl'));
         if (!$mail->send($email)) {
             throw new Exception(tr('Unable to send mail to invite "%0"', $email));
         }
         $smarty->assign_by_ref('user', $user);
     }
 }
Пример #9
0
	/**
	 * Send notification by email that a plugin is waiting to be
	 * approved to everyone with permission to approve it.
	 * 
	 * @param string $plugin_name
	 * @param string $body plugin body
	 * @param array $arguments plugin arguments
	 * @param array $context object type and id
	 * @return void
	 */
	private function plugin_pending_notification($plugin_name, $body, $arguments, $context)
	{
		require_once('lib/webmail/tikimaillib.php');
		global $prefs, $base_url, $smarty;
		
		$mail = new TikiMail(null, $prefs['sender_email']);
		$mail->setSubject(tr("Plugin %0 pending approval", $plugin_name));
		
		$smarty->assign('plugin_name', $plugin_name);
		$smarty->assign('type', $context['type']);
		$smarty->assign('objectId', $context['object']);
		$smarty->assign('arguments', $arguments);
		$smarty->assign('body', $body);
		
		$mail->setHtml(nl2br($smarty->fetch('mail/plugin_pending_notification.tpl')));
		
		$recipients = $this->plugin_get_email_users_with_perm();
		
		$mail->setBcc(join(', ', $recipients));
		
		$mail->send(array($prefs['sender_email']));
	}