Example #1
0
 /**
  * Send a message to a user
  */
 function post_message($user, $from, $to, $cc, $subject, $body, $priority, $replyto_hash = '')
 {
     global $smarty, $userlib, $sender_email, $language, $tikilib, $sender_email;
     $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;
     }
     $now = date('U');
     $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) $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() . $foo["path"];
     $machine = str_replace('messu-compose', 'messu-mailbox', $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 ($email) {
             include_once 'lib/webmail/tikimaillib.php';
             $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
             $smarty->assign('mail_machine', $machine);
             $smarty->assign('mail_date', date("U"));
             $smarty->assign('mail_user', stripslashes($user));
             $smarty->assign('mail_from', stripslashes($from));
             $smarty->assign('mail_subject', stripslashes($subject));
             $smarty->assign('mail_body', stripslashes($body));
             $mail = new TikiMail($user);
             $lg = $this->get_user_preference($user, 'language', $this->get_preference("language", "en"));
             $s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl');
             $mail->setSubject(sprintf($s, $_SERVER["SERVER_NAME"]));
             $mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl');
             $mail->setText($mail_data);
             $local_sender_email = $userlib->get_user_email($from);
             if (strlen($sender_email) < 1) {
                 $local_sender_email = $sender_email;
             }
             $mail->setHeader("Reply-To", $local_sender_email);
             $mail->setHeader("From", $local_sender_email);
             if (!$mail->send(array($email), 'mail')) {
                 return false;
             }
             //TODO echo $mail->errors;
         }
     }
     return true;
 }
function payment_behavior_cart_send_confirm_email($u, $email_template_ids = array())
{
    global $prefs, $smarty, $userlib;
    require_once 'lib/webmail/tikimaillib.php';
    $email = $userlib->get_user_email($u);
    if (!$email) {
        return false;
    }
    $smarty->assign("email_template_ids", $email_template_ids);
    $mail_subject = $smarty->fetch('mail/cart_order_received_reg_subject.tpl');
    $mail_data = $smarty->fetch('mail/cart_order_received_reg.tpl');
    $mail = new TikiMail();
    $mail->setSubject($mail_subject);
    if ($mail_data == strip_tags($mail_data)) {
        $mail->setText($mail_data);
    } else {
        $mail->setHtml($mail_data);
    }
    $mail->send($email);
    return true;
}
 function Notify($ListUserToAlert, $URI)
 {
     global $tikilib, $userlib;
     if (!is_array($ListUserToAlert)) {
         return;
     }
     $project = $tikilib->get_preference("browsertitle");
     $foo = parse_url($_SERVER["REQUEST_URI"]);
     $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
     $URL = $machine . "/" . $URI;
     foreach ($ListUserToAlert as $user) {
         $email = $userlib->get_user_email($user);
         if (!empty($email)) {
             include_once 'lib/webmail/tikimaillib.php';
             $mail = new TikiMail();
             $mail->setText(tra("You are alerted by the server ") . $project . "\n" . tra("You can check the modifications at : ") . $URL);
             $mail->setSubject(tra("You are alerted of a change on ") . $project);
             $mail->send(array($email));
         }
     }
 }
Example #4
0
/**
 * @param $mod_reference
 * @param $module_params
 */
function module_contributors($mod_reference, $module_params)
{
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $headerlib = TikiLib::lib('header');
    $wikilib = TikiLib::lib('wiki');
    $currentObject = current_object();
    if ($currentObject['type'] == 'wiki page') {
        $objectperms = Perms::get(array('type' => 'wiki page', 'object' => $currentObject['object']));
        if ($objectperms->view) {
            $contributors = $wikilib->get_contributors($currentObject['object']);
            $contributors_details = array();
            $headerlib->add_css('div.contributors div br {clear: both;}');
            // Avoid avatar conflicts with lines below
            foreach ($contributors as $contributor) {
                $details = array('login' => $contributor);
                $details['realName'] = $userlib->get_user_preference($contributor, 'realName');
                $country = $tikilib->get_user_preference($contributor, 'country');
                if (!is_null($country) && $country != 'Other') {
                    $details['country'] = $country;
                }
                $email_isPublic = $tikilib->get_user_preference($contributor, 'email is public');
                if ($email_isPublic != 'n') {
                    $details['email'] = $userlib->get_user_email($contributor);
                    $details['scrambledEmail'] = TikiMail::scrambleEmail($details['email'], $email_isPublic);
                }
                $details['homePage'] = $tikilib->get_user_preference($contributor, 'homePage');
                $details['avatar'] = $tikilib->get_user_avatar($contributor);
                $contributors_details[] = $details;
            }
            $smarty->assign_by_ref('contributors_details', $contributors_details);
            $hiddenContributors = count($contributors_details) - 5;
            if ($hiddenContributors > 0) {
                $smarty->assign('hiddenContributors', $hiddenContributors);
            }
        }
    }
}
Example #5
0
							$_REQUEST['wikicontent'],
							empty($_REQUEST['wikipageafter']) ? NULL : $_REQUEST['wikipageafter']
						)
		);
      $res=$tikilib->query("SELECT MAX(id) as `id` FROM `tiki_invite` WHERE `inviter`=? AND `ts`=?", array($user, $tikilib->now));
        $row=$res->fetchRow(); $id=$row['id'];
        
      foreach ($emails as $m)
						$tikilib->query(
										"INSERT INTO `tiki_invited` (id_invite, email, firstname, lastname, used) VALUES (?,?,?,?,?)",
										array($id, $m['email'], $m['firstname'], $m['lastname'], "no")
						);

		  $_SERVER['SCRIPT_URI'] =  empty($_SERVER['SCRIPT_URI']) ? 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_URI'];			        
        foreach ($emails as $m) {
            $mail = new TikiMail();
            $mail->setFrom($prefs['sender_email']);
            $mail->setSubject($_REQUEST["emailsubject"]);
            $mail->setCrlf("\n");
            $url=str_replace('tiki-invite.php', 'tiki-invited.php', $_SERVER['SCRIPT_URI'])
                .'?invite='.$id.'&email='.urlencode($m['email']);
            $text=$_text;
            $text=str_replace('{link}', $url, $text);
            $text=str_replace('{email}', $m['email'], $text);
            $text=str_replace('{firstname}', $m['firstname'], $text);
            $text=str_replace('{lastname}', $m['lastname'], $text);
            $mail->setText($text);
            $mail->send(array($m['email']));
        }
		
        $smarty->assign('sentresult', true);
Example #6
0
 function unsubscribe($code, $mailit = false)
 {
     global $smarty, $prefs, $userlib, $tikilib;
     $foo = parse_url($_SERVER["REQUEST_URI"]);
     $url_subscribe = $tikilib->httpPrefix() . $foo["path"];
     $query = "select * from `tiki_newsletter_subscriptions` where `code`=?";
     $result = $this->query($query, array($code));
     if (!$result->numRows()) {
         return false;
     }
     $res = $result->fetchRow();
     $info = $this->get_newsletter($res["nlId"]);
     $smarty->assign('info', $info);
     $smarty->assign('code', $res["code"]);
     if ($res["isUser"] == 'g') {
         $query = "update `tiki_newsletter_subscriptions` set `valid`='x' where `code`=?";
     } else {
         $query = "delete from `tiki_newsletter_subscriptions` where `code`=?";
     }
     $result = $this->query($query, array($code), -1, -1, false);
     // Now send a bye bye email
     $smarty->assign('mail_date', $this->now);
     if ($res["isUser"] == "y") {
         $user = $res["email"];
         $email = $userlib->get_user_email($user);
     } else {
         $email = $res["email"];
         $user = $userlib->get_user_by_email($email);
         //global $user is not necessary defined as the user is not necessary logged in
     }
     $smarty->assign('mail_user', $user);
     $smarty->assign('url_subscribe', $url_subscribe);
     $lg = !$user ? $prefs['site_language'] : $this->get_user_preference($user, "language", $prefs['site_language']);
     if (!isset($_SERVER["SERVER_NAME"])) {
         $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
     }
     if ($mailit) {
         $mail = new TikiMail();
         $mail_data = $smarty->fetchLang($lg, 'mail/newsletter_byebye_subject.tpl');
         $mail->setSubject(sprintf($mail_data, $info["name"], $_SERVER["SERVER_NAME"]));
         $mail_data = $smarty->fetchLang($lg, 'mail/newsletter_byebye.tpl');
         $mail->setText($mail_data);
         $mail->send(array($email));
     }
     /*$this->update_users($res["nlId"]);*/
     return $this->get_newsletter($res["nlId"]);
 }
Example #7
0
             $smarty->assign('mail_date', date("U"));
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_title', $_REQUEST["comments_title"]);
             $smarty->assign('mail_comment', $_REQUEST["comments_data"]);
             $smarty->assign('mail_hash', $not['hash']);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
             $smarty->assign('mail_machine', $machine);
             $parts = explode('/', $foo['path']);
             if (count($parts) > 1) {
                 unset($parts[count($parts) - 1]);
             }
             $smarty->assign('mail_machine_raw', $tikilib->httpPrefix() . implode('/', $parts));
             // TODO: mail_machine_site may be required for some sef url with rewrite to sub-directory. To refine. (nkoth)
             $smarty->assign('mail_machine_site', $tikilib->httpPrefix());
             $mail = new TikiMail();
         }
         global $prefs;
         // TODO: optimise by grouping user by language
         $languageEmail = $tikilib->get_user_preference($not['user'], "language", $prefs['site_language']);
         $mail->setUser($not['user']);
         $mail_data = $smarty->fetchLang($languageEmail, 'mail/user_watch_wiki_page_comment_subject.tpl');
         $mail->setSubject(sprintf($mail_data, $_REQUEST["page"]));
         $mail_data = $smarty->fetchLang($languageEmail, 'mail/user_watch_wiki_page_comment.tpl');
         $mail->setText($mail_data);
         $mail->buildMessage();
         $mail->send(array($not['email']));
     }
 }
 // redirect back to parent after edit/post to create GET request instead of POST to allow proper bookmarking/refreshing, etc.
 if (isset($forum_mode) && $forum_mode == 'y') {
Example #8
0
 }
 $languageEmail = $tikilib->get_user_preference($name, "language", $prefs['site_language']);
 // Now check if the user should be notified by email
 $foo = parse_url($_SERVER["REQUEST_URI"]);
 $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
 $machine = preg_replace("!/\$!", "", $machine);
 // just incase
 $smarty->assign('mail_machine', $machine);
 $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
 $smarty->assign('mail_user', $name);
 $smarty->assign('mail_same', $prefs['feature_clear_passwords']);
 $smarty->assign('mail_pass', $pass);
 $smarty->assign('mail_apass', md5($pass));
 $smarty->assign('mail_ip', $tikilib->get_ip_address());
 $mail_data = sprintf($smarty->fetchLang($languageEmail, 'mail/password_reminder_subject.tpl'), $_SERVER["SERVER_NAME"]);
 $mail = new TikiMail($name);
 $mail->setSubject($mail_data);
 $mail->setText(stripslashes($smarty->fetchLang($languageEmail, 'mail/password_reminder.tpl')));
 // grab remote IP through forwarded-for header when served by cache
 $mail->setHeader('X-Password-Reset-From', $tikilib->get_ip_address());
 if (!$mail->send(array($_REQUEST['email']))) {
     $smarty->assign('msg', tra("The mail can't be sent. Contact the administrator"));
     $smarty->display("error.tpl");
     die;
 }
 // Just show "success" message and no form
 $smarty->assign('showmsg', 'y');
 $smarty->assign('showfrm', 'n');
 if ($prefs['feature_clear_passwords'] == 'y') {
     $tmp = tra("A password reminder email has been sent ");
 } else {
$smarty->assign('country', $country);
$anonpref = $tikilib->get_preference('userbreadCrumb', 4);
$userbreadCrumb = $tikilib->get_user_preference($userwatch, 'userbreadCrumb', $anonpref);
$smarty->assign_by_ref('realName', $realName);
$smarty->assign_by_ref('gender', $gender);
$smarty->assign_by_ref('userbreadCrumb', $userbreadCrumb);
$homePage = $tikilib->get_user_preference($userwatch, 'homePage', '');
$smarty->assign_by_ref('homePage', $homePage);
$avatar = $tikilib->get_user_avatar($userwatch);
$smarty->assign('avatar', $avatar);
$user_information = $tikilib->get_user_preference($userwatch, 'user_information', 'public');
$smarty->assign('user_information', $user_information);
$userinfo = $userlib->get_user_info($userwatch);
$email_isPublic = $tikilib->get_user_preference($userwatch, 'email is public', 'n');
if ($email_isPublic != 'n') {
    $smarty->assign('scrambledEmail', TikiMail::scrambleEmail($userinfo['email'], $email_isPublic));
}
$userinfo['score'] = TikiLib::lib('score')->get_user_score($userwatch);
$smarty->assign_by_ref('userinfo', $userinfo);
$smarty->assign_by_ref('email_isPublic', $email_isPublic);
$userPage = $prefs['feature_wiki_userpage_prefix'] . $userinfo['login'];
$exist = $tikilib->page_exists($userPage);
$smarty->assign("userPage_exists", $exist);
if ($prefs['feature_display_my_to_others'] == 'y') {
    if ($prefs['feature_wiki'] == 'y') {
        $wikilib = TikiLib::lib('wiki');
        $user_pages = $wikilib->get_user_all_pages($userwatch, 'pageName_asc');
        $smarty->assign_by_ref('user_pages', $user_pages);
    }
    if ($prefs['feature_blogs'] == 'y') {
        $bloglib = TikiLib::lib('blog');
 /**
  *  A default Tikiwiki callback that sends the welcome email on user registraion
  *  @access private
  *  @returns true on success, false to halt event proporgation
  */
 function callback_tikiwiki_send_email($raisedBy, $data)
 {
     global $_REQUEST, $_SESSION, $_SERVER, $prefs, $registrationlib_apass, $email_valid, $smarty, $tikilib, $userlib, $Debug;
     if ($Debug) {
         print "::send_email";
     }
     $sender_email = $prefs['sender_email'];
     $mail_user = $data['user'];
     $mail_site = $data['mail_site'];
     if ($email_valid != 'no') {
         if ($prefs['validateUsers'] == 'y') {
             //$apass = addslashes(substr(md5($tikilib->genPass()),0,25));
             $apass = $registrationlib_apass;
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $foo1 = str_replace("tiki-register", "tiki-login_validate", $foo["path"]);
             $machine = $tikilib->httpPrefix() . $foo1;
             $smarty->assign('mail_machine', $machine);
             $smarty->assign('mail_site', $mail_site);
             $smarty->assign('mail_user', $mail_user);
             $smarty->assign('mail_apass', $apass);
             $registrationlib_apass = "";
             $smarty->assign('mail_email', $_REQUEST['email']);
             include_once "lib/notifications/notificationemaillib.php";
             if (isset($prefs['validateRegistration']) and $prefs['validateRegistration'] == 'y') {
                 $smarty->assign('msg', $smarty->fetch('mail/user_validation_waiting_msg.tpl'));
                 if ($sender_email == NULL or !$sender_email) {
                     include_once 'lib/messu/messulib.php';
                     $mail_data = $smarty->fetch('mail/moderate_validation_mail.tpl');
                     $mail_subject = $smarty->fetch('mail/moderate_validation_mail_subject.tpl');
                     $messulib->post_message($prefs['contact_user'], $prefs['contact_user'], $prefs['contact_user'], '', $mail_subject, $mail_data, 5);
                 } else {
                     $mail_data = $smarty->fetch('mail/moderate_validation_mail.tpl');
                     $mail = new TikiMail();
                     $mail->setText($mail_data);
                     $mail_data = $smarty->fetch('mail/moderate_validation_mail_subject.tpl');
                     $mail->setSubject($mail_data);
                     if (!$mail->send(array($sender_email))) {
                         $smarty->assign('msg', tra("The registration mail can't be sent. Contact the administrator"));
                     }
                 }
             } else {
                 $mail_data = $smarty->fetch('mail/user_validation_mail.tpl');
                 $mail = new TikiMail();
                 $mail->setText($mail_data);
                 $mail_data = $smarty->fetch('mail/user_validation_mail_subject.tpl');
                 $mail->setSubject($mail_data);
                 if (!$mail->send(array($_REQUEST["email"]))) {
                     $smarty->assign('msg', tra("The registration mail can't be sent. Contact the administrator"));
                 } else {
                     $smarty->assign('msg', $smarty->fetch('mail/user_validation_msg.tpl'));
                 }
             }
             $smarty->assign('showmsg', 'y');
         } else {
             $smarty->assign('msg', $smarty->fetch('mail/user_welcome_msg.tpl'));
             $smarty->assign('showmsg', 'y');
         }
     }
     return true;
 }
Example #11
0
     $smarty->assign('sendFrom', trim($userlib->get_user_email($user)));
 }
 if (!$current) {
     handleWebmailRedirect('locSection=settings');
 }
 $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');
Example #12
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;
 }
Example #13
0
function sendFileGalleryEmailNotification($event, $galleryId, $galleryName, $name, $filename, $description, $action, $user)
{
    global $tikilib, $feature_user_watches, $smarty, $userlib, $sender_email;
    $nots = array();
    $defaultLanguage = $tikilib->get_preference("language", "en");
    // Users watching this gallery
    if ($feature_user_watches == 'y') {
        $nots = $tikilib->get_event_watches($event, $galleryId);
        for ($i = count($nots) - 1; $i >= 0; --$i) {
            $nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
        }
    }
    if (count($nots)) {
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $smarty->assign('galleryName', $galleryName);
        $smarty->assign('mail_date', date("U"));
        $smarty->assign('author', $user);
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
        $smarty->assign('mail_machine', $machine);
        foreach ($nots as $not) {
            $mail->setUser($not['user']);
            $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_file_gallery_changed_subject.tpl");
            $mail->setSubject(sprintf($mail_data, $galleryName));
            if ($action == 'upload file') {
                $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_file_gallery_upload.tpl");
            } elseif ($action == 'remove file') {
                $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_file_gallery_remove_file.tpl");
            }
            $mail->setText($mail_data);
            $mail->buildMessage();
            $mail->send(array($not['email']));
        }
    }
}
Example #14
0
 /**
  * @param $calitemId
  * @param $data
  */
 function watch($calitemId, $data)
 {
     global $prefs, $user;
     $smarty = TikiLib::lib('smarty');
     $tikilib = TikiLib::lib('tiki');
     $nots = $tikilib->get_event_watches('calendar_changed', $data['calendarId']);
     if ($prefs['calendar_watch_editor'] != "y" || $prefs['user_calendar_watch_editor'] != "y") {
         for ($i = count($nots) - 1; $i >= 0; --$i) {
             if ($nots[$i]['user'] == $data["user"]) {
                 unset($nots[$i]);
                 break;
             }
         }
     }
     if ($prefs['feature_daily_report_watches'] == 'y') {
         $reportsManager = Reports_Factory::build('Reports_Manager');
         $reportsManager->addToCache($nots, array('event' => 'calendar_changed', 'calitemId' => $calitemId, 'user' => $user));
     }
     if ($nots) {
         include_once 'lib/webmail/tikimaillib.php';
         $mail = new TikiMail();
         $smarty->assign('mail_new', $new);
         $smarty->assign('mail_data', $data);
         $smarty->assign('mail_calitemId', $calitemId);
         $foo = parse_url($_SERVER["REQUEST_URI"]);
         $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
         $machine = preg_replace("!/\$!", "", $machine);
         // just incase
         $smarty->assign('mail_machine', $machine);
         $defaultLanguage = $prefs['site_language'];
         foreach ($nots as $not) {
             $mail->setUser($not['user']);
             $mail_data = $smarty->fetchLang($defaultLanguage, "mail/user_watch_calendar_subject.tpl");
             $mail->setSubject($mail_data);
             $mail_data = $smarty->fetchLang($defaultLanguage, "mail/user_watch_calendar.tpl");
             $mail->setText($mail_data);
             $mail->send(array($not['email']));
         }
     }
 }
$i = 0;
foreach ($listevents as $leDay) {
    foreach ($leDay as $le) {
        $id = 'c' . $le['calitemId'];
        if ($id == 'c0') {
            $id = 'r' . $le['recurrenceId'];
        }
        if (!array_key_exists($id, $absent_tmp)) {
            $absent_tmp[$id]['startTimeStamp'] = $le['startTimeStamp'];
            $absent_tmp[$id]['endTimeStamp'] = $le['endTimeStamp'];
            $absent_tmp[$id]['name'] = $le['name'];
            $absent_tmp[$id]['description'] = $le['description'];
        }
    }
}
$absent = array();
foreach ($absent_tmp as $vi) {
    $absent[] = $vi;
}
$smarty->assign('absent', $absent);
$mail = new TikiMail();
$mail_data = $smarty->fetch("mail/weekly_calendar_subject.tpl");
$mail->setSubject($mail_data);
$mail_data = $smarty->fetch("mail/weekly_calendar_email.tpl");
$mail->setHtml($mail_data, strip_tags($mail_data));
$mail->buildMessage();
$mail->send(array($prefs['weekly_calendar_to_email']));
//$smarty->display("mail/weekly_calendar_subject.tpl");
//$smarty->display("mail/weekly_calendar_email.tpl");
header('Location: tiki-calendar.php?todate=' . $start_date);
exit;
Example #16
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));
     }
 }
Example #17
0
 /**
  * Shared 'File download' case
  */
 if (isset($_GET['fileId']) && $detailtoken['parameters'] == '{"fileId":"' . $_GET['fileId'] . '"}') {
     $_SESSION['allowed'][$_GET['fileId']] = true;
 }
 // If notification then alert
 if ($prefs['share_token_notification'] == 'y') {
     $nots = $tikilib->get_event_watches('auth_token_called', $detailtoken['tokenId']);
     $smarty->assign('prefix_url', $base_host);
     // Select in db the tokenId
     $notificationPage = '';
     $smarty->assign_by_ref('page_token', $notificationPage);
     if (is_array($nots)) {
         include_once 'lib/webmail/tikimaillib.php';
         $mail = new TikiMail();
         $mail->setSubject($detailtoken['email'] . ' ' . tra(' has accessed your temporary shared content'));
         foreach ($nots as $i => $not) {
             $notificationPage = $not['url'];
             // Delete token from url
             $notificationPage = preg_replace('/[\\?&]TOKEN=' . $detailtoken['token'] . '/', '', $notificationPage);
             // If file Gallery
             $smarty->assign('filegallery', 'n');
             if (preg_match("/\\btiki-download_file.php\\b/i", $notificationPage)) {
                 $filegallib = TikiLib::lib('filegal');
                 $smarty->assign('filegallery', 'y');
                 $aParams = (array) json_decode($detailtoken['parameters']);
                 $smarty->assign('fileId', $aParams['fileId']);
                 $aFileInfos = $filegallib->get_file_info($aParams['fileId']);
                 $smarty->assign('filegalleryId', $aFileInfos['galleryId']);
                 $smarty->assign('filename', $aFileInfos['name']);
Example #18
0
    } else {
        $parsed = $tikilib->parse_data($_REQUEST["data"]);
    }
    if (stristr($parsed, "<body>") === false) {
        $parsed = "<html><body>{$parsed}</body></html>";
    }
    $smarty->assign('dataparsed', $parsed);
    $smarty->assign('subject', $_REQUEST["subject"]);
    $cant = count($subscribers);
    $smarty->assign('subscribers', $cant);
}
$smarty->assign('emited', 'n');
if (isset($_REQUEST["send"])) {
    include_once 'lib/webmail/tikimaillib.php';
    check_ticket('send-newsletter');
    $mail = new TikiMail();
    $txt = strip_tags(str_replace(array("\r\n", "&nbsp;"), array("\n", " "), $_REQUEST["data"]));
    if (stristr($_REQUEST["dataparsed"], "<body>") === false) {
        $html = "<html><body>" . $tikilib->parse_data($_REQUEST["dataparsed"]) . "</body></html>";
    } else {
        $html = $_REQUEST["dataparsed"];
    }
    $sent = 0;
    $unsubmsg = '';
    $errors = array();
    $users = $nllib->get_all_subscribers($_REQUEST["nlId"], $nl_info["unsubMsg"]);
    foreach ($users as $us) {
        $userEmail = $us["login"];
        $email = $us["email"];
        if ($email == "") {
            $errors[] = array("user" => $userEmail, "email" => "");
function payment_behavior_cart_gift_certificate_purchase($productId = 0, $giftcertemail = '', $quantity = 1, $orderId = 0, $orderItemId = 0)
{
    $trklib = TikiLib::lib('trk');
    global $prefs;
    $params['trackerId'] = $prefs['payment_cart_giftcert_tracker'];
    $redeemCodeFieldId = $trklib->get_field_id($params['trackerId'], 'Redeem Code');
    $nameFieldId = $trklib->get_field_id($params['trackerId'], 'Name');
    $modeFieldId = $trklib->get_field_id($params['trackerId'], 'Mode');
    $onelineDescriptionFieldId = $trklib->get_field_id($params['trackerId'], 'One line description');
    $longDescriptionFieldId = $trklib->get_field_id($params['trackerId'], 'Long Description');
    $origbalanceFieldId = $trklib->get_field_id($params['trackerId'], 'Original Balance or Percentage');
    $curbalanceFieldId = $trklib->get_field_id($params['trackerId'], 'Current Balance or Percentage');
    $params['copyFieldIds'][] = $nameFieldId;
    $params['copyFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Type');
    $params['copyFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Type Reference');
    $params['copyFieldIds'][] = $origbalanceFieldId;
    $params['copyFieldIds'][] = $modeFieldId;
    $params['copyFieldIds'][] = $onelineDescriptionFieldId;
    $params['updateFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Gift Certificate ID');
    $params['updateFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Origination');
    $params['updateFieldIds'][] = $redeemCodeFieldId;
    $params['updateFieldIds'][] = $curbalanceFieldId;
    $params['updateFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Admin notes');
    $params['updateFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Order ID');
    $params['updateFieldIds'][] = $trklib->get_field_id($params['trackerId'], 'Order Item ID');
    $balancefield = 'f_' . $origbalanceFieldId;
    $params['updateFieldValues'] = array('', 'Order', '-randomstring-', $balancefield, "Purchased by {$giftcertemail}", $orderId, $orderItemId);
    // Product tracker info
    $productsTrackerId = $prefs['payment_cart_product_tracker'];
    $giftcertTemplateFieldId = $trklib->get_field_id($productsTrackerId, $prefs['payment_cart_giftcerttemplate_fieldname']);
    if (!$productId) {
        return false;
    }
    $giftcertId = $trklib->get_item_value($productsTrackerId, $productId, $giftcertTemplateFieldId);
    $params['itemId'] = $giftcertId;
    $params['copies_on_load'] = $quantity;
    $params['return_array'] = 'y';
    include_once 'lib/wiki-plugins/wikiplugin_trackeritemcopy.php';
    $return_array = wikiplugin_trackeritemcopy('', $params);
    $giftcerts = array();
    // Get additional information
    foreach ($return_array['items'] as $newItemId) {
        $newItem = $trklib->get_tracker_item($newItemId);
        $newGiftcert['name'] = $newItem[$nameFieldId];
        $newGiftcert['redeemCode'] = $newItem[$redeemCodeFieldId];
        $newGiftcert['onelineDescription'] = $newItem[$onelineDescriptionFieldId];
        $newGiftcert['longDescription'] = $newItem[$longDescriptionFieldId];
        $newGiftcert['value'] = $newItem[$curbalanceFieldId];
        if (strpos($newItem[$modeFieldId], 'Percentage') !== false) {
            $newGiftcert['isPercentage'] = true;
        } else {
            $newGiftcert['isPercentage'] = false;
        }
        $giftcerts[] = $newGiftcert;
    }
    // Send email to user with gift cert
    require_once 'lib/webmail/tikimaillib.php';
    global $prefs;
    $smarty = TikiLib::lib('smarty');
    $smarty->assign('giftcerts', $giftcerts);
    $smarty->assign('numberCodes', count($return_array['items']));
    $mail_subject = $smarty->fetch('mail/cart_gift_cert_subject.tpl');
    $mail_data = $smarty->fetch('mail/cart_gift_cert.tpl');
    $mail = new TikiMail();
    $mail->setSubject($mail_subject);
    $mail->setText($mail_data);
    $mail->send($giftcertemail);
    return true;
}
Example #20
0
function wikiplugin_invite($data, $params)
{
    global $prefs, $user, $tiki_p_invite_to_my_groups;
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    if ($tiki_p_invite_to_my_groups != 'y') {
        return;
    }
    $userGroups = $userlib->get_user_groups_inclusion($user);
    if (!empty($params['including'])) {
        $groups = $userlib->get_including_groups($params['including']);
        foreach ($userGroups as $gr => $inc) {
            if (!in_array($gr, $groups)) {
                unset($userGroups[$gr]);
            }
        }
    }
    $errors = array();
    $feedbacks = array();
    if (isset($_REQUEST['invite'])) {
        if (empty($_REQUEST['email'])) {
            $errors[] = tra('The following mandatory fields are missing') . ' ' . tra('Email address');
        }
        if (!validate_email($_REQUEST['email'])) {
            $errors[] = tra('Invalid Email') . ' ' . $_REQUEST['email'];
        }
        if (!empty($_REQUEST['groups'])) {
            foreach ($_REQUEST['groups'] as $group) {
                if (empty($userGroups[$group])) {
                    $errors[] = tra('Incorrect param') . ' ' . $group;
                }
            }
        }
        if (empty($errors)) {
            $email = $_REQUEST['email'];
            if (!($invite = $userlib->get_user_by_email($email))) {
                $new_user = true;
                $password = '******';
                //$tikilib->genPass();
                $codedPassword = md5($password);
                if ($prefs['login_autogenerate'] == 'y') {
                    $uname = '';
                } else {
                    $uname = $email;
                }
                $uname = $userlib->add_user($uname, $password, $email, $password, true, NULL);
                $smarty->assign('codedPassword', $codedPassword);
                $invite = $email;
            } else {
                $new_user = false;
            }
            $smarty->assign_by_ref('new_user', $new_user);
            $smarty->assign_by_ref('invite', $invite);
            if (!empty($_REQUEST['groups'])) {
                foreach ($_REQUEST['groups'] as $group) {
                    $userlib->assign_user_to_group($uname, $group);
                    $invitedGroups[] = $userlib->get_group_info($group);
                }
            }
            include_once 'lib/webmail/tikimaillib.php';
            $mail = new TikiMail();
            $machine = parse_url($_SERVER['REQUEST_URI']);
            $machine = $tikilib->httpPrefix(true) . dirname($machine['path']);
            $smarty->assign_by_ref('machine', $machine);
            $subject = sprintf($smarty->fetch('mail/mail_invite_subject.tpl'), $_SERVER['SERVER_NAME']);
            $mail->setSubject($subject);
            if (!empty($_REQUEST['message'])) {
                $smarty->assign('message', $_REQUEST['message']);
            }
            $smarty->assign_by_ref('groups', $invitedGroups);
            $txt = $smarty->fetch('mail/mail_invite.tpl');
            $mail->setText($txt);
            $mail->send(array($email));
            return $data;
        } else {
            $smarty->assign_by_ref('errors', $errors);
            $smarty->assign_by_ref('email', $_REQUEST['email']);
            if (!empty($_REQUEST['groups'])) {
                $smarty->assign_by_ref('groups', $_REQUEST['groups']);
            }
            if (!empty($_REQUEST['message'])) {
                $smarty->assign_by_ref('message', $_REQUEST['message']);
            }
        }
    }
    if (!empty($_REQUEST['itemId'])) {
        $params['itemId'] = $_REQUEST['itemId'];
    }
    if (!empty($params['itemId'])) {
        $item = Tracker_Item::fromId($params['itemId']);
        $params['defaultgroup'] = $item->getOwnerGroup();
    }
    $smarty->assign_by_ref('params', $params);
    $smarty->assign_by_ref('userGroups', $userGroups);
    return '~np~' . $smarty->fetch('wiki-plugins/wikiplugin_invite.tpl') . '~/np~';
}
/*************** Compose *********************************************************************************************/
if ($_REQUEST["locSection"] == 'compose') {
    $current = $webmaillib->get_current_webmail_account($user);
    if (!$current) {
        header("location: tiki-webmail.php?locSection=settings");
        die;
    }
    // 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"]);
        }
Example #22
0
            $message = tra("You must make sure to have a valid email address in the From field.");
        } else {
            $message = $captchalib->getErrors();
        }
        $smarty->assign('errorMessage', $message);
    } else {
        $access->check_ticket();
        $body = tr("%0 sent you a message:", $from) . "\n" . $body;
        $messulib->post_message($prefs['contact_user'], $from, $_REQUEST['to'], '', $_REQUEST['subject'], $body, $priority);
        $contact_name = $userlib->get_user_preference($prefs['contact_user'], 'realName');
        if ($contact_name == '') {
            $contact_name = $prefs['contact_user'];
        }
        $message = tra('Message sent to') . ': ' . $contact_name . '<br />';
        $smarty->assign('sent', 1);
        $smarty->assign('message', $message);
    }
}
$email = $userlib->get_user_email($prefs['contact_user']);
if ($email == '') {
    $email = $userlib->get_admin_email();
}
$smarty->assign('email0', $email);
$email = TikiMail::scrambleEmail($email, $tikilib->get_user_preference('admin', "email is public"));
$smarty->assign('email', $email);
$smarty->assign('priority', $priority);
$smarty->assign('from', $from);
$smarty->assign('subject', $subject);
$smarty->assign('body', $body);
$smarty->assign('mid', 'tiki-contact.tpl');
$smarty->display("tiki.tpl");
Example #23
0
/**
 *
 * Sends a promotional email to the given recipients
 * @param string        $sender        Sender e-Mail address
 * @param string|array    $recipients    List of recipients either as array or comma/semi colon separated string
 * @param string        $subject    E-Mail subject
 * @param array            $tokenlist
 * @internal param string $url_for_friend URL to share
 * @return bool                        true on success / false if the supplied parameters were incorrect/missing or an error occurred sending the mail
 */
function sendMail($sender, $recipients, $subject, $tokenlist = array())
{
    global $errors, $prefs, $smarty, $user, $userlib, $logslib;
    global $registrationlib;
    include_once 'lib/registration/registrationlib.php';
    if (empty($sender)) {
        $errors[] = tra('Your email is mandatory');
        return false;
    }
    if (function_exists('validate_email')) {
        $ok = validate_email($sender, $prefs['validateEmail']);
    } else {
        $ret = $registrationlib->SnowCheckMail($sender, '', 'mini');
        $ok = $ret[0];
    }
    if ($ok) {
        $from = str_replace(array("\r", "\n"), '', $sender);
    } else {
        $errors[] = tra('Invalid email') . ': ' . $_REQUEST['email'];
        return false;
    }
    $recipients = checkAddresses($recipients);
    if ($recipients === false) {
        return false;
    }
    include_once 'lib/webmail/tikimaillib.php';
    $smarty->assign_by_ref('mail_site', $_SERVER['SERVER_NAME']);
    $applyFrom = !empty($user) && $from == $userlib->get_user_email($user);
    $ok = true;
    foreach ($recipients as $i => $recipient) {
        $mail = new TikiMail();
        $mail->setSubject($subject);
        if ($applyFrom) {
            $mail->setFrom($from);
            $mail->setReplyTo("<{$from}>");
        }
        if (count($tokenlist) > 1) {
            $url_for_friend = $tokenlist[$i];
        } else {
            $url_for_friend = $tokenlist[0];
            // only one token if not "subscribing"
        }
        $smarty->assign('url_for_friend', $url_for_friend);
        $txt = $smarty->fetch('mail/share.tpl');
        // Rebuild email message texte
        $mail->setText($txt);
        $mailsent = $mail->send(array($recipient));
        if (!$mailsent) {
            $errors[] = tra('Error sending mail to') . " {$recipient}";
            $logslib->add_log('share', tra('Error sending mail to') . " {$recipient} " . tra('by') . ' ' . $user);
        } else {
            $logslib->add_log('share', tra('Share page') . ': ' . $url_for_friend . ' ' . tra('to') . ' ' . $recipient . ' ' . tra('by') . ' ' . $user);
        }
        $ok = $ok && $mailsent;
    }
    return $ok;
}
Example #24
0
 $module_params['show_register'] = $prefs['allowRegister'] === 'y' ? 'y' : 'n';
 $smarty->assign('module_params', $module_params);
 if ($error == PASSWORD_INCORRECT && ($prefs['unsuccessful_logins'] >= 0 || $prefs['unsuccessful_logins_invalid'] >= 0)) {
     $nb_bad_logins = $userlib->unsuccessful_logins($requestedUser);
     $nb_bad_logins++;
     $userlib->set_unsuccessful_logins($requestedUser, $nb_bad_logins);
     if ($prefs['unsuccessful_logins_invalid'] > 0 && $nb_bad_logins >= $prefs['unsuccessful_logins_invalid']) {
         $info = $userlib->get_user_info($requestedUser);
         $userlib->change_user_waiting($requestedUser, 'a');
         $msg = sprintf(tra('%d or more unsuccessful login attempts have been made.'), $prefs['unsuccessful_logins_invalid']);
         $msg .= ' ' . tra('Your account has been suspended.') . ' ' . tra('Contact your site administrator to reactivate it.');
         $smarty->assign('msg', $msg);
         if ($nb_bad_logins % $prefs['unsuccessful_logins_invalid'] == 0) {
             //don't send an email after every failed login
             include_once 'lib/webmail/tikimaillib.php';
             $mail = new TikiMail();
             $smarty->assign('mail_user', $requestedUser);
             $foo = parse_url($_SERVER['REQUEST_URI']);
             $mail_machine = $tikilib->httpPrefix(true) . str_replace('tiki-login.php', '', $foo['path']);
             $smarty->assign('mail_machine', $mail_machine);
             $mail->setText($smarty->fetch('mail/unsuccessful_logins_suspend.tpl'));
             $mail->setSubject($smarty->fetch('mail/unsuccessful_logins_suspend_subject.tpl'));
             $emails = !empty($prefs['validator_emails']) ? preg_split('/,/', $prefs['validator_emails']) : (!empty($prefs['sender_email']) ? array($prefs['sender_email']) : '');
             if (!$mail->send(array($info['email'])) || !$mail->send($emails)) {
                 $smarty->assign('msg', tra("The mail can't be sent. Contact the administrator"));
                 $smarty->display("error.tpl");
                 die;
             }
         }
         $smarty->assign('mid', 'tiki-information.tpl');
         $smarty->display('tiki.tpl');
				$msg_to = $info['user'];
				$save['accepted_user'] = null;
				$save['accepted_creator'] = null;
			}
		}
		$msg_from = $user;
		$tasklib->update_task($info['taskId'], $user, $save, $save_head, $admin_mode);
		$taskId = $info['taskId'];
		$msg_title = tra("Changes on Task") . ': "' . $info['title'] . '" by ' . $user;
	}
	$info = $tasklib->get_task($user, $taskId, null, $admin_mode);
	//send email to task user
	if ((isset($_REQUEST['send_email_newtask'])) && $send_message && ($_REQUEST['task_user'] != $user)) {
		include_once ('lib/newsletters/nllib.php');
		$email = $userlib->get_user_email($msg_to);
		$mail = new TikiMail($msg_to);
		$mail->setSubject($msg_title);
		$mail_data = tra("You received a new task") . "\n\n" . $info['title'] . "\n" . tra("from") . " :$user\n";
		$mail_data.= tra("The priority is") . ": ";
		switch ($info['priority']) {
			case 1:
				$mail_data.= tra("very low");
    			break;

			case 2:
				$mail_data.= tra("low");
    			break;

			case 3:
				$mail_data.= tra("normal");
    			break;
Example #26
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']];
     }
 }
function wikiplugin_mail($data, $params)
{
	global $userlib, $smarty, $tikilib, $user;
	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);
	$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;
	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['to'] = $to;
		$preview = true;
		$smarty->assign('preview', $preview);
		$smarty->assign('nbTo', count($to));
	}
	if (isset($_REQUEST["mail_send$ipluginmail"])) { // send something
		$to = $_SESSION['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']);
			if ($mail->send($to)) {
				//echo '<pre>MAIL'; print_r($to); echo '</pre>';
				$smarty->assign_by_ref('sents', $to);
			} else {
				$mail_error = true;
			}
		}
		unset($_SESSION['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']);
	}
	
	$smarty->assign_by_ref('params', $params);
	return '~np~'.$smarty->fetch('wiki-plugins/wikiplugin_mail.tpl').'~/np~';
}
Example #28
0
	function send_confirm_email($user,$tpl='confirm_user_email')
	{
		global $smarty, $prefs, $tikilib;
		include_once ('lib/webmail/tikimaillib.php');
		$languageEmail = $this->get_user_preference($_REQUEST['username'], 'language', $prefs['site_language']);
		$apass = $this->renew_user_password($user);
		$apass = md5($apass);
		$smarty->assign('mail_apass', $apass);
		$smarty->assign('mail_pass', $_REQUEST['pass']);
		$smarty->assign('mail_ip', $tikilib->get_ip_address());
		$smarty->assign('user', $user);
		$mail = new TikiMail();
		$mail_data = $smarty->fetchLang($languageEmail, "mail/$tpl".'_subject.tpl');
		$mail_data = sprintf($mail_data, $_SERVER['SERVER_NAME']);
		$mail->setSubject($mail_data);
		$foo = parse_url($_SERVER['REQUEST_URI']);
		$mail_machine = $tikilib->httpPrefix(true) . str_replace('tiki-login.php', 'tiki-confirm_user_email.php', $foo['path']);
		$smarty->assign('mail_machine', $mail_machine);
		$mail_data = $smarty->fetchLang($languageEmail, "mail/$tpl.tpl");
		$mail->setText($mail_data);

		if (!($email = $this->get_user_email($user)) || !$mail->send(array($email))) {
			$smarty->assign('msg', tra("The user email confirmation can't be sent. Contact the administrator"));
			return false;
		} else {
			$smarty->assign('msg', 'It is time to confirm your email. You will receive an mail with the instruction to follow');
			return true;
		}
	}
	$info = $userlib->get_user_info($_REQUEST['user']);
	if ($info['waiting'] == 'a' && $prefs['validateUsers'] == 'y') { // admin validating -> need user email validation now
		$userlib->send_validation_email($_REQUEST['user'], $info['valid'], $info['email'], '', 'y');
		$userlib->change_user_waiting($_REQUEST['user'], 'u');
		$logslib->add_log('register', 'admin validation ' . $_REQUEST['user']);
	} elseif ($info['waiting'] == 'a' && $prefs['validateRegistration'] == 'y') { //admin validating -> user can log in
		$userlib->confirm_user($_REQUEST['user']);
		$foo = parse_url($_SERVER["REQUEST_URI"]);
		$foo1 = str_replace('tiki-login_validate', 'tiki-login_scr', $foo['path']);
		$machine = $tikilib->httpPrefix(true) . $foo1;
		$smarty->assign('mail_machine', $machine);
		$smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
		$smarty->assign('mail_user', $_REQUEST['user']);
		$email = $userlib->get_user_email($_REQUEST['user']);
		include_once ("lib/webmail/tikimaillib.php");
		$mail = new TikiMail();
		$mail->setText($smarty->fetch('mail/moderate_activation_mail.tpl'));
		$mail->setSubject($smarty->fetch('mail/moderate_activation_mail_subject.tpl'));
		$mail->send(array($email));
		$logslib->add_log('register', 'validated account ' . $_REQUEST['user']);
	} elseif (empty($user)) {
		$userlib->confirm_user($_REQUEST['user']);
		if ($info['pass_confirm'] == 0) {
			if (!empty($info['provpass'])) {
				$_SESSION['last_validation']['pass'] = $info['provpass'];
			}
			if (!empty($_SESSION['last_validation']['pass'])) {
				$smarty->assign('oldpass', $_SESSION['last_validation']['pass']);
			}
			$smarty->assign('new_user_validation', 'y');
			$smarty->assign('userlogin', $_REQUEST['user']);
Example #30
0
    check_ticket('admin-inc-general');
    $pref_toggles = array('feature_wiki_1like_redirection');
    foreach ($pref_toggles as $toggle) {
        simple_set_toggle($toggle);
    }
    $pref_byref_values = array('server_timezone');
    foreach ($pref_byref_values as $britem) {
        byref_set_value($britem);
    }
    $tikilib->set_preference('display_timezone', $tikilib->get_preference('server_timezone'));
    // Special handling for tied fields: tikiIndex, urlIndex and useUrlIndex
}
$smarty->assign('now', $tikilib->now);
if (!empty($_REQUEST['testMail'])) {
    include_once 'lib/webmail/tikimaillib.php';
    $mail = new TikiMail();
    $mail->setSubject(tra('Tiki Email Test'));
    $mail->setText(tra('Tiki Test email from:') . ' ' . $_SERVER['SERVER_NAME']);
    if (!$mail->send(array($_REQUEST['testMail']))) {
        $msg = tra('Unable to send mail');
        if ($tiki_p_admin == 'y') {
            $mailerrors = print_r($mail->errors, true);
            $msg .= $mailerrors;
        }
        $smarty->assign('error_msg', $msg);
    } else {
        add_feedback('testMail', tra('Test mail sent to') . ' ' . $_REQUEST['testMail'], 3);
    }
}
$engine_type = getCurrentEngine();
$smarty->assign('db_engine_type', $engine_type);