コード例 #1
0
 /**
  * Send a message to a user
  */
 function post_message($user, $from, $to, $cc, $subject, $body, $priority, $replyto_hash = '')
 {
     global $smarty, $userlib, $prefs;
     $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
     $foo = parse_url($_SERVER["REQUEST_URI"]);
     $machine = $this->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', $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));
             $mail = new TikiMail($user);
             $lg = $this->get_user_preference($user, 'language', $prefs['site_language']);
             $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);
             if ($userlib->get_user_preference($from, 'email is public', 'n') == 'y') {
                 $prefs['sender_email'] = $userlib->get_user_email($from);
             }
             if (strlen($prefs['sender_email']) > 1) {
                 $mail->setHeader("Reply-To", $prefs['sender_email']);
                 $mail->setHeader("From", $prefs['sender_email']);
             }
             if (!$mail->send(array($email), 'mail')) {
                 return false;
             }
             //TODO echo $mail->errors;
         }
     }
     return true;
 }
コード例 #2
0
 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));
         }
     }
 }
コード例 #3
0
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;
}
コード例 #4
0
						$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);
	}
   $smarty->assign('emails', $emails);
}


$smarty->assign('mid', 'tiki-invite.tpl');
$smarty->display("tiki.tpl");
コード例 #5
0
ファイル: nllib.php プロジェクト: Kraiany/kraiany_site_docker
 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"]);
 }
コード例 #6
0
ファイル: tiki-share.php プロジェクト: jkimdon/cohomeals
/**
 *
 * 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;
}
コード例 #7
0
     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"]) {
     check_ticket('webmail');
     $a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach3file"]);
     $mail->addAttachment($a3, $_REQUEST["attach3"], $_REQUEST["attach3type"]);
     @unlink('temp/mail_attachs/' . $_REQUEST["attach3file"]);
 }
 $mail->setSMTPParams($current["smtp"], $current["smtpPort"], '', $current["useAuth"], $current["username"], $current["pass"]);
 if (isset($_REQUEST["useHTML"]) && $_REQUEST["useHTML"] == 'on') {
     $mail->setHTML($_REQUEST["body"], strip_tags($_REQUEST["body"]));
 } else {
     $mail->setText($_REQUEST["body"]);
 }
 $to_array_1 = split('[, ;]', $_REQUEST["to"]);
 $to_array = array();
 foreach ($to_array_1 as $to_1) {
     if (!empty($to_1)) {
         $to_array[] = $to_1;
     }
 }
 $to_array = $contactlib->parse_nicknames($to_array);
 // Get email addresses not in the address book
 $not_contacts = $contactlib->are_contacts($to_array, $user);
 if (count($not_contacts) > 0) {
     $smarty->assign('notcon', 'y');
 } else {
     $smarty->assign('notcon', 'n');
コード例 #8
0
 /**
  *  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;
 }
コード例 #9
0
ファイル: userslib.php プロジェクト: railfuture/tiki-website
	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;
		}
	}
コード例 #10
0
ファイル: evlib.php プロジェクト: noikiy/owaspbwa
 function unsubscribe($code)
 {
     global $smarty;
     global $sender_email;
     global $userlib;
     global $tikilib;
     global $language;
     $foo = parse_url($_SERVER["REQUEST_URI"]);
     $url_subscribe = $tikilib->httpPrefix() . $foo["path"];
     $query = "select * from `tiki_event_subscriptions` where `code`=?";
     $result = $this->query($query, array($code));
     if (!$result->numRows()) {
         return false;
     }
     $res = $result->fetchRow();
     $info = $this->get_event($res["evId"]);
     $smarty->assign('info', $info);
     $smarty->assign('code', $res["code"]);
     $query = "delete from `tiki_event_subscriptions` where `code`=?";
     $result = $this->query($query, array($code));
     // Now send a bye bye email
     $smarty->assign('mail_date', date("U"));
     $user = $userlib->get_user_by_email($res["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 ? $language : $this->get_user_preference($user, "language", $language);
     if (!isset($_SERVER["SERVER_NAME"])) {
         $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
     }
     $mail = new TikiMail();
     $mail_data = $smarty->fetchLang($lg, 'mail/event_byebye_subject.tpl');
     $mail->setSubject(sprintf($mail_data, $info["name"], $_SERVER["SERVER_NAME"]));
     $mail_data = $smarty->fetchLang($lg, 'mail/event_byebye.tpl');
     $mail->setText($mail_data);
     $mail->send(array($res["email"]));
     $this->update_users($res["evId"]);
     return $this->get_event($res["evId"]);
 }
コード例 #11
0
ファイル: filegallib.php プロジェクト: rjsmelo/tiki
 function deleteOldFiles()
 {
     global $prefs;
     $smarty = TikiLib::lib('smarty');
     include_once 'lib/webmail/tikimaillib.php';
     $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
     $files = $this->fetchAll($query, array($this->now));
     foreach ($files as $fileInfo) {
         $definition = $this->getGalleryDefinition($fileInfo['galleryId']);
         $galInfo = $definition->getInfo();
         if (!empty($prefs['fgal_delete_after_email'])) {
             $wrapper = $definition->getFileWrapper($fileInfo['data'], $fileInfo['path']);
             $fileInfo['data'] = $wrapper->getContent();
             $smarty->assign('fileInfo', $fileInfo);
             $smarty->assign('galInfo', $galInfo);
             $mail = new TikiMail();
             $mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
             $mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
             $mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
             $to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
             $mail->send($to);
         }
         $this->remove_file($fileInfo, $galInfo, false);
     }
 }
コード例 #12
0
ファイル: cartlib.php プロジェクト: rjsmelo/tiki
 function request_payment()
 {
     global $prefs, $user;
     $tikilib = TikiLib::lib('tiki');
     $paymentlib = TikiLib::lib('payment');
     $total = $this->get_total();
     if ($total > 0 || $this->total_no_discount) {
         // if anonymous shopping to set pref as to which shopperinfo to show in description
         if (empty($user) && $prefs['payment_cart_anonymous'] === 'y') {
             $shopperinfo_descvar = 'email';
             // TODO: make this a pref
             if (!empty($_SESSION['shopperinfo'][$shopperinfo_descvar])) {
                 $shopperinfo_desc = $_SESSION['shopperinfo'][$shopperinfo_descvar];
                 $description = tra($prefs['payment_cart_heading']) . " ({$shopperinfo_desc})";
             } else {
                 $description = tra($prefs['payment_cart_heading']);
             }
         } else {
             $description = tra($prefs['payment_cart_heading']) . " ({$user})";
         }
         $invoice = $paymentlib->request_payment($description, $total, $prefs['payment_default_delay'], $this->get_description());
         foreach ($this->get_behaviors() as $behavior) {
             $paymentlib->register_behavior($invoice, $behavior['event'], $behavior['behavior'], $behavior['arguments']);
         }
     } else {
         $invoice = 0;
         foreach ($this->get_behaviors() as $behavior) {
             if ($behavior['event'] == 'complete') {
                 $name = $behavior['behavior'];
                 $file = dirname(__FILE__) . "/behavior/{$name}.php";
                 $function = 'payment_behavior_' . $name;
                 require_once $file;
                 call_user_func_array($function, $behavior['arguments']);
             }
         }
     }
     // Handle anonymous user (not logged in) shopping that require only email
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         if (!empty($_SESSION['shopperinfo'])) {
             // should also check for pref that this anonymous shopping feature is on
             // First create shopper info in shopper tracker
             global $record_profile_items_created;
             $record_profile_items_created = array();
             if (!empty($_SESSION['shopperinfoprofile'])) {
                 $shopper_profile_name = $_SESSION['shopperinfoprofile'];
             } else {
                 $shopper_profile_name = $prefs['payment_cart_anonshopper_profile'];
             }
             $shopperprofile = Tiki_Profile::fromDb($shopper_profile_name);
             $profileinstaller = new Tiki_Profile_Installer();
             $profileinstaller->forget($shopperprofile);
             // profile can be installed multiple times
             $profileinstaller->setUserData($_SESSION['shopperinfo']);
             $profileinstaller->install($shopperprofile);
             // Then set user to shopper ID
             $cartuser = $record_profile_items_created[0];
             $record_profile_items_created = array();
         } else {
             $this->empty_cart();
             return $invoice;
         }
     } else {
         $cartuser = $user;
     }
     $userInput = array('user' => $cartuser, 'time' => $tikilib->now, 'total' => $total, 'invoice' => $invoice, 'weight' => $this->get_total_weight());
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         $orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorders_profile']);
         $orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorderitems_profile']);
     } else {
         $orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_orders_profile']);
         $orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_orderitems_profile']);
     }
     if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
         if (!$orderprofile) {
             TikiLib::lib('errorreport')->report(tra('Advanced Shopping Cart setup error: Orders profile missing.'));
             return false;
         }
         $profileinstaller = new Tiki_Profile_Installer();
         $profileinstaller->forget($orderprofile);
         // profile can be installed multiple times
         $profileinstaller->setUserData($userInput);
     } else {
         $profileinstaller = '';
     }
     global $record_profile_items_created;
     $record_profile_items_created = array();
     if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
         $profileinstaller->install($orderprofile, 'none');
     }
     $content = $this->get_content();
     foreach ($content as $info) {
         if (!isset($info['is_gift_certificate']) || !$info['is_gift_certificate']) {
             $process_info = $this->process_item($invoice, $total, $info, $userInput, $cartuser, $profileinstaller, $orderitemprofile);
         }
     }
     $email_template_ids = array();
     if (isset($process_info['product_classes']) && is_array($process_info['product_classes'])) {
         $product_classes = array_unique($process_info['product_classes']);
     } else {
         $product_classes = array();
     }
     foreach ($product_classes as $pc) {
         if ($email_template_id = $this->get_tracker_value_custom($prefs['payment_cart_productclasses_tracker_name'], 'Email Template ID', $pc)) {
             $email_template_ids[] = $email_template_id;
         }
     }
     if (!empty($record_profile_items_created)) {
         if ($total > 0) {
             $paymentlib->register_behavior($invoice, 'complete', 'record_cart_order', array($record_profile_items_created));
             $paymentlib->register_behavior($invoice, 'cancel', 'cancel_cart_order', array($record_profile_items_created));
             if ($user) {
                 $paymentlib->register_behavior($invoice, 'complete', 'cart_send_confirm_email', array($user, $email_template_ids));
             }
         } else {
             require_once 'lib/payment/behavior/record_cart_order.php';
             payment_behavior_record_cart_order($record_profile_items_created);
             if ($user) {
                 require_once 'lib/payment/behavior/cart_send_confirm_email.php';
                 payment_behavior_cart_send_confirm_email($user, $email_template_ids);
             }
         }
     }
     if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
         $shopperurl = 'tiki-index.php?page=' . $prefs['payment_cart_anon_reviewpage'] . '&shopper=' . intval($cartuser);
         global $tikiroot, $prefs;
         $shopperurl = $tikilib->httpPrefix(true) . $tikiroot . $shopperurl;
         require_once 'lib/auth/tokens.php';
         $tokenlib = AuthTokens::build($prefs);
         $shopperurl = $tokenlib->includeToken($shopperurl, array($prefs['payment_cart_anon_group'], 'Anonymous'));
         if (!empty($_SESSION['shopperinfo']['email'])) {
             require_once 'lib/webmail/tikimaillib.php';
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('shopperurl', $shopperurl);
             $smarty->assign('email_template_ids', $email_template_ids);
             $mail_subject = $smarty->fetch('mail/cart_order_received_anon_subject.tpl');
             $mail_data = $smarty->fetch('mail/cart_order_received_anon.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($_SESSION['shopperinfo']['email']);
             // the field to use probably needs to be configurable as well
         }
     }
     $this->update_gift_certificate($invoice);
     $this->update_group_discount($invoice);
     $this->empty_cart();
     return $invoice;
 }
コード例 #13
0
ファイル: openpgplib.php プロジェクト: rjsmelo/tiki
 /**
  * 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;
 }
コード例 #14
0
ファイル: trackerlib.php プロジェクト: rjsmelo/tiki
 public function send_replace_item_notifications($args)
 {
     global $prefs, $user;
     // Don't send a notification if this operation is part of a bulk import
     if ($args['bulk_import']) {
         return;
     }
     $trackerId = $args['trackerId'];
     $itemId = $args['object'];
     $new_values = $args['values'];
     $old_values = $args['old_values'];
     $the_data = $this->generate_watch_data($old_values, $new_values, $trackerId, $itemId, $args['version']);
     if (empty($the_data) && $prefs['tracker_always_notify'] !== 'y') {
         return;
     }
     $tracker_definition = Tracker_Definition::get($trackerId);
     if (!$tracker_definition) {
         return;
     }
     $tracker_info = $tracker_definition->getInformation();
     $watchers = $this->get_notification_emails($trackerId, $itemId, $tracker_info, $new_values['status'], $old_values['status']);
     if (count($watchers) > 0) {
         $simpleEmail = isset($tracker_info['simpleEmail']) ? $tracker_info['simpleEmail'] : "n";
         $trackerName = $tracker_info['name'];
         if (!isset($_SERVER["SERVER_NAME"])) {
             $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
         }
         include_once 'lib/webmail/tikimaillib.php';
         if ($simpleEmail == "n") {
             $mail_main_value_fieldId = $this->get_main_field($trackerId);
             $mail_main_value_field = $tracker_definition->getField($mail_main_value_fieldId);
             if ($mail_main_value_field['type'] == 'r') {
                 // Item Link is special case as field value is not the displayed text. There might be other such field types.
                 $handler = $this->get_field_handler($mail_main_value_field);
                 $desc = $handler->getItemLabel($this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId));
             } else {
                 $desc = $this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId);
             }
             if ($tracker_info['doNotShowEmptyField'] === 'y') {
                 // remove empty fields if tracker says so
                 $the_data = preg_replace('/\\[-\\[.*?\\]-\\] -\\[\\(.*?\\)\\]-:\\n\\n----------\\n/', '', $the_data);
             }
             $smarty = TikiLib::lib('smarty');
             $smarty->assign('mail_date', $this->now);
             $smarty->assign('mail_user', $user);
             $smarty->assign('mail_itemId', $itemId);
             $smarty->assign('mail_item_desc', $desc);
             $smarty->assign('mail_trackerId', $trackerId);
             $smarty->assign('mail_trackerName', $trackerName);
             $smarty->assign('server_name', $_SERVER['SERVER_NAME']);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $this->httpPrefix(true) . $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', $this->httpPrefix(true) . implode('/', $parts));
             $smarty->assign_by_ref('status', $new_values['status']);
             foreach ($watchers as $watcher) {
                 $watcher['language'] = $this->get_user_preference($watcher['user'], 'language', $prefs['site_language']);
                 $label = $itemId ? tra('Item Modification', $watcher['language']) : tra('Item creation', $watcher['language']);
                 $mail_action = "\r\n{$label}\r\n\r\n";
                 $mail_action .= tra('Tracker', $watcher['language']) . ":\n   " . tra($trackerName, $watcher['language']) . "\r\n";
                 $mail_action .= tra('Item', $watcher['language']) . ":\n   {$itemId} {$desc}";
                 $smarty->assign('mail_action', $mail_action);
                 $subject = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification_subject.tpl');
                 list($watcher_data, $watcher_subject) = $this->translate_watch_data($the_data, $subject, $watcher['language']);
                 $smarty->assign('mail_data', $watcher_data);
                 if (isset($watcher['action'])) {
                     $smarty->assign('mail_action', $watcher['action']);
                 }
                 $smarty->assign('mail_to_user', $watcher['user']);
                 $mail_data = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification.tpl');
                 $mail = new TikiMail($watcher['user']);
                 $mail->setSubject($watcher_subject);
                 $mail->setText($mail_data);
                 $mail->send(array($watcher['email']));
             }
         } else {
             // Use simple email
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $this->httpPrefix(true) . $foo["path"];
             $parts = explode('/', $foo['path']);
             if (count($parts) > 1) {
                 unset($parts[count($parts) - 1]);
             }
             $machine = $this->httpPrefix(true) . implode('/', $parts);
             $userlib = TikiLib::lib('user');
             if (!empty($user)) {
                 $my_sender = $userlib->get_user_email($user);
             } else {
                 // look if a email field exists
                 $fieldId = $this->get_field_id_from_type($trackerId, 'm');
                 if (!empty($fieldId)) {
                     $my_sender = $this->get_item_value($trackerId, $itemId, $fieldId);
                 }
             }
             // Try to find a Subject in $the_data looking for strings marked "-[Subject]-" TODO: remove the tra (language translation by submitter)
             $the_string = '/^\\[-\\[' . tra('Subject') . '\\]-\\] -\\[[^\\]]*\\]-:\\n(.*)/m';
             $subject_test_unchanged = preg_match($the_string, $the_data, $unchanged_matches);
             $the_string = '/^\\[-\\[' . tra('Subject') . '\\]-\\]:\\n(.*)\\n(.*)\\n\\n(.*)\\n(.*)/m';
             $subject_test_changed = preg_match($the_string, $the_data, $matches);
             $subject = '';
             if ($subject_test_unchanged == 1) {
                 $subject = $unchanged_matches[1];
             }
             if ($subject_test_changed == 1) {
                 $subject = $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
             }
             $i = 0;
             foreach ($watchers as $watcher) {
                 $watcher['language'] = $this->get_user_preference($watcher['user'], 'language', $prefs['site_language']);
                 $mail = new TikiMail($watcher['user']);
                 list($watcher_data, $watcher_subject) = $this->translate_watch_data($the_data, $subject, $watcher['language']);
                 $mail->setSubject('[' . $trackerName . '] ' . str_replace('> ', '', $watcher_subject) . ' (' . tra('Tracker was modified at %0 by %1', $watcher['language'], false, array($_SERVER["SERVER_NAME"], $user)) . ')');
                 $mail->setText(tra('View the tracker item at:', $watcher['language']) . " {$machine}/tiki-view_tracker_item.php?itemId={$itemId}\n\n" . $watcher_data);
                 if (!empty($my_sender)) {
                     $mail->setReplyTo($my_sender);
                 }
                 $mail->send(array($watcher['email']));
                 $i++;
             }
         }
     }
 }
コード例 #15
0
function sendStructureEmailNotification($params)
{
    global $tikilib, $smarty, $prefs;
    global $structlib;
    include_once 'lib/structures/structlib.php';
    if ($params['action'] == 'move_up' || $params['action'] == 'move_down') {
        $nots = $structlib->get_watches('', $params['parent_id'], false);
    } else {
        $nots = $structlib->get_watches('', $params['page_ref_id']);
    }
    if (!empty($nots)) {
        $defaultLanguage = $prefs['site_language'];
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
        $smarty->assign_by_ref('mail_machine', $machine);
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $smarty->assign_by_ref('action', $params['action']);
        $smarty->assign_by_ref('page_ref_id', $params['page_ref_id']);
        if (!empty($params['name'])) {
            $smarty->assign('name', $params['name']);
        }
        foreach ($nots as $not) {
            $mail->setUser($not['user']);
            $not['language'] = $tikilib->get_user_preference($not['user'], 'language', $defaultLanguage);
            $mail_subject = $smarty->fetchLang($not['language'], 'mail/user_watch_structure_subject.tpl');
            $mail_data = $smarty->fetchLang($not['language'], 'mail/user_watch_structure.tpl');
            $mail->setSubject($mail_subject);
            $mail->setText($mail_data);
            $mail->buildMessage();
            $mail->send(array($not['email']));
        }
    }
}
コード例 #16
0
ファイル: wikiplugin_invite.php プロジェクト: rjsmelo/tiki
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~';
}
コード例 #17
0
ファイル: tiki-login.php プロジェクト: ameoba32/tiki
 $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');
     die;
 } elseif ($prefs['unsuccessful_logins'] > 0 && $nb_bad_logins >= $prefs['unsuccessful_logins']) {
     $msg = sprintf(tra('%d or more unsuccessful login attempts have been made.'), $prefs['unsuccessful_logins']);
     $smarty->assign('msg', $msg);
     if ($nb_bad_logins % $prefs['unsuccessful_logins'] == 0) {
コード例 #18
0
ファイル: wikiplugin_mail.php プロジェクト: rjsmelo/tiki
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~';
}
コード例 #19
0
ファイル: include_general.php プロジェクト: rjsmelo/tiki
    $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);
ask_ticket('admin-inc-general');
コード例 #20
0
ファイル: wikiplugin_tracker.php プロジェクト: ameoba32/tiki
function wikiplugin_tracker($data, $params)
{
    global $user, $group, $page, $prefs;
    $parserlib = TikiLib::lib('parser');
    $trklib = TikiLib::lib('trk');
    $userlib = TikiLib::lib('user');
    $tikilib = TikiLib::lib('tiki');
    $smarty = TikiLib::lib('smarty');
    $captchalib = TikiLib::lib('captcha');
    static $iTRACKER = 0;
    ++$iTRACKER;
    if (isset($params['itemId']) && empty($params['itemId'])) {
        return;
    }
    $smarty->assign('trackerEditFormId', $iTRACKER);
    $default = array('overwrite' => 'n', 'embedded' => 'n', 'showtitle' => 'n', 'showdesc' => 'n', 'showfieldsdesc' => 'y', 'sort' => 'n', 'showmandatory' => 'y', 'status' => '', 'transactionFinalStep' => 'y', 'registration' => 'n', 'chosenGroup' => 'Registered', 'validateusers' => '', 'emailformat' => 'text');
    $params = array_merge($default, $params);
    $item = array();
    extract($params, EXTR_SKIP);
    if (empty($transactionName) xor empty($transactionStep)) {
        return '<b>' . tra("You need to define both transaction name and transaction step, or none of the two.") . '</b>';
    } else {
        if (isset($transactionName) && !isset($_SESSION[$transactionName])) {
            $_SESSION[$transactionName] = array();
        }
        if (isset($transactionStep) && !isset($_SESSION[$transactionName][$transactionStep])) {
            $_SESSION[$transactionName][$transactionStep] = array();
        }
        if (!isset($_SESSION[$transactionName]['transactionStep'])) {
            $_SESSION[$transactionName]['transactionStep'] = 0;
        }
        if ($_SESSION[$transactionName]['transactionStep'] != $transactionStep) {
            return;
        }
    }
    if ($prefs['feature_trackers'] != 'y') {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    if (empty($trackerId) || !($definition = Tracker_Definition::get($trackerId))) {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    $tracker = $definition->getInformation();
    if (empty($trackerId) && !empty($view) && $view == 'user' && $prefs['userTracker'] == 'y') {
        // the user tracker item
        $utid = $userlib->get_tracker_usergroup($user);
        if (!empty($utid) && !empty($utid['usersTrackerId'])) {
            $itemId = $trklib->get_item_id($utid['usersTrackerId'], $utid['usersFieldId'], $user);
            $trackerId = $utid['usersTrackerId'];
            $usertracker = true;
        }
    } elseif (!empty($trackerId) && !empty($view) && $view == 'user') {
        // the user item of a tracker
        $itemId = $trklib->get_user_item($trackerId, $tracker, null, null, strlen($status) == 1 ? $status : '');
        $usertracker = true;
    } elseif (!empty($trackerId) && !empty($view) && $view == 'page' && !empty($_REQUEST['page']) && ($f = $trklib->get_page_field($trackerId))) {
        // the page item
        $itemId = $trklib->get_item_id($trackerId, $f['fieldId'], $_REQUEST['page']);
    } elseif (!empty($trackerId) && !empty($_REQUEST['view_user'])) {
        $itemId = $trklib->get_user_item($trackerId, $tracker, $_REQUEST['view_user']);
    } elseif (!empty($_REQUEST['itemId']) && (empty($ignoreRequestItemId) || $ignoreRequestItemId != 'y')) {
        $itemId = $_REQUEST['itemId'];
        $item = $trklib->get_tracker_item($itemId);
        $trackerId = $item['trackerId'];
    } elseif (!empty($view) && $view == 'group') {
        $gtid = $userlib->get_grouptrackerid($group);
        if (isset($gtid['groupTrackerId'])) {
            $trackerId = $gtid['groupTrackerId'];
            $itemId = $trklib->get_item_id($trackerId, $gtid['groupFieldId'], $group);
            $grouptracker = true;
        }
    }
    if (!isset($trackerId)) {
        return $smarty->fetch("wiki-plugins/error_tracker.tpl");
    }
    //test for validation errors for registration tracker calls
    if (isset($_REQUEST['register']) && ($_REQUEST['register'] == 'Register' || $_REQUEST['register'] == 'register')) {
        $regtracker = $userlib->get_usertrackerid('Registered');
        if ($trackerId == $regtracker['usersTrackerId'] && $_REQUEST['valerror'] !== false) {
            if (is_array($_REQUEST['valerror'])) {
                foreach ($_REQUEST['valerror'] as $valerror) {
                    if (is_a($valerror, 'RegistrationError')) {
                        return false;
                        break;
                    }
                }
            } elseif (is_a($_REQUEST['valerror'], 'RegistrationError')) {
                return false;
            }
        }
    }
    if (!isset($action)) {
        $action = array('Save');
    }
    if (!is_array($action)) {
        $action = array($action);
    }
    $dynamicSave = false;
    if (count($action) == 1 && reset($action) == 'NONE') {
        $action = array();
        $dynamicSave = true;
    }
    if (!isset($action_style)) {
        $action_style = array();
        foreach ($action as $ac) {
            $action_style[] = 'btn btn-primary';
        }
    }
    if (isset($preview)) {
        if (empty($preview)) {
            $preview = 'Preview';
        }
    } else {
        unset($_REQUEST['tr_preview']);
    }
    if (isset($reset)) {
        if (empty($reset)) {
            $reset = 'reset';
        }
    } else {
        unset($_REQUEST['tr_reset']);
    }
    $smarty->assign('showmandatory', empty($wiki) && empty($tpl) ? 'n' : $showmandatory);
    if (!empty($wiki)) {
        if (preg_match('/^wiki:(.+)$/', $wiki, $wiki_matches)) {
            $wiki = $wiki_matches[1];
        }
        $wiki = trim($wiki);
    }
    if (!isset($params['formtag'])) {
        $params['formtag'] = 'y';
    }
    $fields_prefix = 'ins_';
    if (isset($values)) {
        if (!is_array($values)) {
            $values = $parserlib->quotesplit(':', $values);
            foreach ($values as $i => $v) {
                $values[$i] = preg_replace('/^"(.*)"$/', '$1', $v);
            }
        }
    }
    if (isset($_REQUEST['values'])) {
        if (is_array($_REQUEST['values'])) {
            foreach ($_REQUEST['values'] as $i => $k) {
                $_REQUEST['values'][$i] = urldecode($k);
            }
        } else {
            $_REQUEST['values'] = urldecode($_REQUEST['values']);
        }
    }
    $perms = $tikilib->get_perm_object($trackerId, 'tracker', $tracker, false);
    if (empty($_SERVER['SCRIPT_NAME']) || strpos($_SERVER['SCRIPT_NAME'], 'tiki-register.php') === false) {
        if ($perms['tiki_p_create_tracker_items'] == 'n' && empty($itemId)) {
            return '<b>' . tra("You do not have permission to insert an item") . '</b>';
        } elseif (!empty($itemId)) {
            $item_info = $trklib->get_tracker_item($itemId);
            if (empty($item_info)) {
                return '<b>' . tra("Incorrect item") . '</b>';
            }
            $itemObject = Tracker_Item::fromInfo($item_info);
            if (!$itemObject->canModify()) {
                return '<b>' . tra("You do not have permission to modify an item") . '</b>';
            }
        }
    }
    if (!empty($itemId)) {
        $logslib = TikiLib::lib('logs');
        $logslib->add_action('Viewed', $itemId, 'trackeritem', $_SERVER['REQUEST_URI']);
    }
    if (isset($_REQUEST['removeattach']) && $tracker['useAttachments'] == 'y') {
        $owner = $trklib->get_item_attachment_owner($_REQUEST['removeattach']);
        if ($perms['tiki_p_admin_trackers'] == 'y' || $user && $user == $owner) {
            $trklib->remove_item_attachment($_REQUEST["removeattach"]);
            unset($_REQUEST['removeattach']);
        }
    }
    if (isset($_REQUEST['removeImage']) && !empty($_REQUEST['trackerId']) && !empty($_REQUEST['itemId']) && !empty($_REQUEST['fieldId']) && !empty($_REQUEST['fieldName'])) {
        $img_field = array('data' => array());
        $img_field['data'][] = array('fieldId' => $_REQUEST['fieldId'], 'type' => 'i', 'name' => $_REQUEST['fieldName'], 'value' => 'blank');
        $trklib->replace_item($_REQUEST['trackerId'], $_REQUEST['itemId'], $img_field);
    }
    $back = '';
    $thisIsThePlugin = isset($_REQUEST['iTRACKER']) && $_REQUEST['iTRACKER'] == $iTRACKER;
    if (!isset($_REQUEST["ok"]) || $_REQUEST["ok"] == "n" || !$thisIsThePlugin || isset($_REQUEST['tr_preview'])) {
        $field_errors = array('err_mandatory' => array(), 'err_value' => array());
        $notificationlib = TikiLib::lib('notification');
        $tracker = $trklib->get_tracker($trackerId);
        $tracker = array_merge($tracker, $trklib->get_tracker_options($trackerId));
        if (!empty($tracker['start']) && $tikilib->now < $tracker['start'] || !empty($tracker['end']) && $tikilib->now > $tracker['end']) {
            return;
        }
        $outf = array();
        $auto_fieldId = array();
        $hidden_fieldId = array();
        if (!empty($fields) || !empty($wiki) || !empty($tpl)) {
            if ($registration == 'y' && $prefs["user_register_prettytracker"] == 'y' && !empty($prefs["user_register_prettytracker_tpl"])) {
                $registrationlib = TikiLib::lib('registration');
                $smarty->assign('listgroups', $registrationlib->merged_prefs['choosable_groups']);
                $smarty->assign('register_login', $smarty->fetch('register-login.tpl'));
                $smarty->assign('register_email', $smarty->fetch('register-email.tpl'));
                $smarty->assign('register_pass', $smarty->fetch('register-pass.tpl'));
                $smarty->assign('register_pass2', $smarty->fetch('register-pass2.tpl'));
                $smarty->assign('register_passcode', $smarty->fetch('register-passcode.tpl'));
                $smarty->assign('register_groupchoice', $smarty->fetch('register-groupchoice.tpl'));
                if ($prefs['feature_antibot'] == 'y') {
                    $smarty->assign('showantibot', true);
                    $smarty->assign('form', 'register');
                    $smarty->assign('register_antibot', $smarty->fetch('antibot.tpl'));
                }
                $wiki = $prefs["user_register_prettytracker_tpl"];
            }
            if (!empty($wiki)) {
                $outf = $trklib->get_pretty_fieldIds($wiki, 'wiki', $prettyModifier, $trackerId);
            } elseif (!empty($tpl)) {
                $outf = $trklib->get_pretty_fieldIds($tpl, 'tpl', $prettyModifier, $trackerId);
            } elseif (!empty($fields)) {
                $outf = $fields;
            }
            if (!empty($_REQUEST['autosavefields'])) {
                $autosavefields = explode(':', $_REQUEST['autosavefields']);
                $autosavevalues = explode(':', $_REQUEST['autosavevalues']);
                if (isset($params['autosavefields'])) {
                    $autosavefields = array_merge($autosavefields, $params['autosavefields']);
                    $autosavevalues = array_merge($autosavevalues, $params['autosavevalues']);
                }
            }
            if (!empty($autosavefields)) {
                $auto_fieldId = array_merge($auto_fieldId, $autosavefields);
            }
            foreach ($definition->getFields() as $field) {
                // User and group on autoassign create/modify
                if (($user || $registration == 'y' || isset($_SESSION[$transactionName]) && isset($_SESSION[$transactionName]['registrationName'])) && ($field['type'] == 'u' || $field['type'] == 'g')) {
                    $autoassign = $field['options_map']['autoassign'];
                    if ($autoassign == 1 || $autoassign == 2) {
                        if ($user) {
                            $hidden_fieldId[] = $field['fieldId'];
                        }
                        $userField = $field['fieldId'];
                    }
                }
                // IP and page on autoassign
                if ($field['type'] == 'I' || $field['type'] == 'k') {
                    $autoassign = $field['options_map']['autoassign'];
                    if ($autoassign == 1) {
                        $hidden_fieldId[] = $field['fieldId'];
                    }
                }
                // Auto-increment
                if ($field['type'] == 'q') {
                    $auto_fieldId[] = $field['fieldId'];
                }
            }
            foreach ($auto_fieldId as $k => $v) {
                if (empty($v) || in_array($v, $outf)) {
                    unset($auto_fieldId[$k]);
                } else {
                    $outf[] = $v;
                }
            }
            foreach ($hidden_fieldId as $k => $v) {
                if (empty($v) || in_array($v, $outf)) {
                    unset($hidden_fieldId[$k]);
                } else {
                    $outf[] = $v;
                }
            }
        }
        $definition = Tracker_Definition::get($trackerId);
        $item_info = isset($item_info) ? $item_info : array();
        $factory = $definition->getFieldFactory();
        if (empty($item_info)) {
            $itemObject = Tracker_Item::newItem($trackerId);
        } elseif (!isset($itemObject)) {
            $itemObject = Tracker_Item::fromInfo($item_info);
        }
        if (empty($outf)) {
            $unfiltered = array('data' => $definition->getFields());
        } else {
            $unfiltered = array('data' => array());
            foreach ($outf as $fieldId) {
                $unfiltered['data'][] = $definition->getField($fieldId);
            }
        }
        $flds = array('data' => array());
        foreach ($unfiltered['data'] as $f) {
            if ($itemObject->canModifyField($f['fieldId']) || $registration == 'y' && empty($item_info)) {
                $flds['data'][] = $f;
            }
        }
        // If we create multiple items, get field Ids, default values and separator
        if (!empty($fieldsfill)) {
            $fill_fields = $fieldsfill;
            // Allow for superfluous spaces and ignore them
            $fill_flds = array('data' => array());
            $fill_defaults = array();
            $fill_flds_defaults = array();
            // May be different from fill_defaults if some fields are not editable
            $fieldsfillnames = array();
            if (trim($fieldsfilldefaults) != '') {
                $fill_defaults = preg_split('/ *: */', $fieldsfilldefaults);
            }
            foreach ($fill_fields as $k => $fieldId) {
                if ($itemObject->canModifyField($fieldId)) {
                    $tmp = $definition->getField($fieldId);
                    $fill_flds['data'][] = $tmp;
                    if (isset($fill_defaults[$k])) {
                        $fill_flds_defaults[] = $fill_defaults[$k];
                    } else {
                        $fill_flds_defaults[] = '';
                    }
                    $fieldsfillnames[] = $tmp['name'];
                }
            }
            $fill_line_cant = count($fill_flds['data']);
            if ($fieldsfillseparator == '') {
                $fieldsfillseparator = '|';
            }
        }
        $bad = array();
        $embeddedId = false;
        $onemandatory = false;
        $full_fields = array();
        $mainfield = '';
        if ($thisIsThePlugin) {
            /* ------------------------------------- Recup all values from REQUEST -------------- */
            if (!empty($autosavefields)) {
                foreach ($autosavefields as $i => $f) {
                    if (!($ff = $trklib->get_field($f, $flds['data']))) {
                        continue;
                    }
                    if (preg_match('/categories\\(([0-9]+)\\)/', $autosavevalues[$i], $matches)) {
                        if (ctype_digit($matches[1]) && $matches[1] > 0) {
                            $filter = array('identifier' => $matches[1], 'type' => 'descendants');
                        } else {
                            $filter = NULL;
                        }
                        $categlib = TikiLib::lib('categ');
                        $categs = $categlib->getCategories($filter, true, false);
                        $_REQUEST["{$fields_prefix}{$f}"][] = $categs[0]['categId'];
                    } elseif (preg_match('/preference\\((.*)\\)/', $autosavevalues[$i], $matches)) {
                        $_REQUEST["{$fields_prefix}{$f}"] = $prefs[$matches[1]];
                    } elseif (isset($transactionName) && preg_match('/#TSTEP\\[(\\d+)\\]\\[(\\d+|name|pass)\\]/', $autosavevalues[$i], $matches)) {
                        $traStep = $matches[1];
                        $traStepInsField = $matches[2];
                        if (preg_match('/\\d+/', $matches[2])) {
                            $traStepInsField = "{$fields_prefix}{$traStepInsField}";
                        }
                        $_REQUEST["{$fields_prefix}{$f}"] = str_replace($matches[0], $_SESSION[$transactionName][$traStep]['request'][$traStepInsField], $autosavevalues[$i]);
                    } elseif ($ff['type'] == 'e') {
                        $_REQUEST["{$fields_prefix}{$f}"][] = $autosavevalues[$i];
                    } else {
                        if (isset($params['levelupfields']) && in_array($f, $params['levelupfields'])) {
                            $current_levelup_val = $trklib->get_item_value($trackerId, $itemId, $f);
                            if ($autosavevalues[$i] <= $current_levelup_val) {
                                continue;
                            }
                        }
                        $_REQUEST["{$fields_prefix}{$f}"] = $autosavevalues[$i];
                    }
                }
            }
            if ($registration == 'y' && isset($userField) && isset($_REQUEST['name'])) {
                $_REQUEST["{$fields_prefix}{$userField}"] = $_REQUEST['name'];
            }
            foreach ($flds['data'] as $k => $field) {
                $handler = $factory->getHandler($field, $item_info);
                if ($handler) {
                    $value_field = $handler->getFieldData($_REQUEST);
                    $ins_fields['data'][$k] = array_merge($field, $value_field);
                    if (isset($ins_fields['data'][$k]['value'])) {
                        // add ins value into field if creating or editing item
                        $flds['data'][$k] = $ins_fields['data'][$k];
                        // to keep user input in case of errors (not only value)
                    }
                }
            }
            $cpt = 0;
            if (isset($fields)) {
                $fields_plugin = $fields;
            }
            if (!isset($itemId) && $tracker['oneUserItem'] == 'y' && $registration != 'y') {
                $itemId = $trklib->get_user_item($trackerId, $tracker);
            }
            if ($embedded == 'y' && isset($_REQUEST['page'])) {
                $ins_fields["data"][] = array('fieldId' => $embeddedId, 'value' => $_REQUEST['page']);
            }
            if (isset($userField) && ($registration == 'y' && isset($_REQUEST['name']) || isset($_SESSION[$transactionName]) && isset($_SESSION[$transactionName]['registrationName']))) {
                $userFieldDef = $definition->getField($userField);
                if (isset($_REQUEST['name'])) {
                    $userFieldDef['value'] = $_REQUEST['name'];
                    if (isset($_SESSION[$transactionName])) {
                        $_SESSION[$transactionName]['registrationName'] = $_REQUEST['name'];
                    }
                } elseif (isset($_SESSION[$transactionName]) && isset($_SESSION[$transactionName]['registrationName'])) {
                    $userFieldDef['value'] = $_SESSION[$transactionName]['registrationName'];
                }
                $ins_fields['data'][] = $userFieldDef;
            }
            $ins_categs = 0;
            // important: non-array ins_categs means categories should remain unchanged
            $parent_categs_only = array();
            foreach ($ins_fields['data'] as $current_field) {
                if ($current_field['type'] == 'e' && isset($current_field['selected_categories'])) {
                    if (!is_array($ins_categs)) {
                        $ins_categs = array();
                    }
                    $ins_categs = array_merge($ins_categs, $current_field['selected_categories']);
                    $parent_categs_only[] = $current_field['options_array'][0];
                }
            }
            $categorized_fields = $definition->getCategorizedFields();
            /* ------------------------------------- End recup all values from REQUEST -------------- */
            /* ------------------------------------- Check field values for each type and presence of mandatory ones ------------------- */
            $field_errors = $trklib->check_field_values($ins_fields, $categorized_fields, $trackerId, empty($itemId) ? '' : $itemId);
            if ($prefs['feature_antibot'] === 'y' && $registration === 'y' && isset($_REQUEST['valerror'])) {
                // in_tracker session var checking is for tiki-register.php
                if (isset($_REQUEST['valerror'])) {
                    $rve = $_REQUEST['valerror'];
                    if (is_array($rve)) {
                        foreach ($rve as $ve) {
                            if (is_a($ve, 'RegistrationError')) {
                                if (isset($ve->field) && $ve->field == 'antibotcode') {
                                    $field_errors['err_antibot'] = 'y';
                                    continue;
                                }
                            }
                        }
                    } elseif (is_a($rve, 'RegistrationError')) {
                        if (isset($rve->field) && $rve->field == 'antibotcode') {
                            $field_errors['err_antibot'] = 'y';
                        }
                    }
                } else {
                    if (!$captchalib->validate()) {
                        $field_errors['err_antibot'] = 'y';
                    }
                }
            }
            // check valid page name for wiki output if requested
            if (isset($outputtowiki) && !empty($outputwiki)) {
                $newpagename = '';
                foreach ($ins_fields["data"] as $fl) {
                    if ($fl["fieldId"] == $outputtowiki) {
                        $newpagename = $fl["value"];
                    }
                    if ($fl["type"] == 'F') {
                        $newpagefreetags = $fl["value"];
                    }
                    $newpagefields[] = $fl["fieldId"];
                }
                if ($newpagename) {
                    if ($prefs['namespace_enabled'] == 'y' && !empty($outputwikinamespace)) {
                        $newpagename = $outputwikinamespace . $prefs['namespace_separator'] . $newpagename;
                    }
                    if ($tikilib->page_exists($newpagename)) {
                        $field_errors['err_outputwiki'] = tra('The page to output the results to already exists. Try another name.');
                    }
                    $page_badchars_display = TikiLib::lib('wiki')->get_badchars();
                    if (TikiLib::lib('wiki')->contains_badchars($newName)) {
                        $field_errors['err_outputwiki'] = tr("The page to output the results to contains the following prohibited characters: %0. Try another name.", $page_badchars_display);
                    }
                } else {
                    unset($outputtowiki);
                }
            }
            if (count($field_errors['err_mandatory']) == 0 && count($field_errors['err_value']) == 0 && empty($field_errors['err_antibot']) && empty($field_errors['err_outputwiki']) && !isset($_REQUEST['tr_preview'])) {
                if (isset($_REQUEST['status'])) {
                    $status = $_REQUEST['status'];
                } elseif (isset($newstatus) && ($newstatus == 'o' || $newstatus == 'c' || $newstatus == 'p')) {
                    $status = $newstatus;
                } elseif (empty($itemId) && isset($tracker['newItemStatus'])) {
                    $status = $tracker['newItemStatus'];
                } else {
                    $status = '';
                }
                $saveThis = array('trackerId' => $trackerId, 'request' => $_REQUEST, 'chosenGroup' => $chosenGroup, 'registration' => $registration, 'registrationTrackerId' => $registrationTrackerId, 'validateusers' => $validateusers, 'status' => $status, 'ins_fields' => $ins_fields, 'itemId' => $itemId, 'ins_categs' => $ins_categs, 'newItemRate' => $newItemRate);
                //-- check if we are in a transaction
                if (isset($transactionName)) {
                    $_SESSION[$transactionName][$transactionStep] = $saveThis;
                    if ($transactionFinalStep == 'y') {
                        //-- final step: commit the transaction of registrations and tracker changes of all the transaction steps
                        foreach ($_SESSION[$transactionName] as $saveStep) {
                            $rid = wikiplugin_tracker_save($saveStep);
                        }
                        unset($_SESSION[$transactionName]);
                        // the tracker transaction can be closed
                    } else {
                        $_SESSION[$transactionName]['transactionStep'] += 1;
                        // switch to the next step
                    }
                } else {
                    // no transaction is used
                    $rid = wikiplugin_tracker_save($saveThis);
                }
                // now for wiki output if desired
                if (isset($outputtowiki) && !empty($outputwiki)) {
                    // note that values will be raw - that is the limit of the capability of this feature for now
                    $newpageinfo = $tikilib->get_page_info($outputwiki);
                    $wikioutput = $newpageinfo["data"];
                    $newpagefields = $trklib->get_pretty_fieldIds($outputwiki, 'wiki', $prettyModifier, $trackerId);
                    $tracker_definition = Tracker_Definition::get($trackerId);
                    foreach ($newpagefields as $lf) {
                        $field = $tracker_definition->getField($lf);
                        $lfpermname = $field['permName'];
                        $wikioutput = str_replace('{$f_' . $lf . '}', $trklib->get_item_value($trackerId, $rid, $lf), $wikioutput);
                        $wikioutput = str_replace('{$f_' . $lfpermname . '}', $trklib->get_item_value($trackerId, $rid, $lf), $wikioutput);
                    }
                    if (isset($registration)) {
                        $wikioutput = str_replace('{$register_login}', $user, $wikioutput);
                        $wikioutput = str_replace('{$register_email}', $_REQUEST['email'], $wikioutput);
                    }
                    $tikilib->create_page($newpagename, 0, $wikioutput, $tikilib->now, '', $user, $tikilib->get_ip_address());
                    $cat_desc = '';
                    $cat_type = 'wiki page';
                    $cat_name = $newpagename;
                    $cat_objid = $newpagename;
                    $cat_href = "tiki-index.php?page=" . urlencode($newpagename);
                    if (count($ins_categs)) {
                        $_REQUEST['cat_categories'] = $ins_categs;
                        $_REQUEST['cat_categorize'] = 'on';
                        include_once "categorize.php";
                    }
                    if (isset($newpagefreetags) && $newpagefreetags) {
                        $_REQUEST['freetag_string'] = $newpagefreetags;
                        include_once "freetag_apply.php";
                    }
                    if ($discarditem == 'y') {
                        $trklib->remove_tracker_item($rid);
                    } elseif ($outputwikirelation == 'y') {
                        TikiLib::lib('relation')->add_relation('tiki.wiki.linkeditem', 'wiki page', $newpagename, 'trackeritem', $rid);
                        TikiLib::lib('relation')->add_relation('tiki.wiki.linkedfield', 'wiki page', $newpagename, 'trackerfield', $outputtowiki);
                    }
                    if (empty($url)) {
                        $wikilib = TikiLib::lib('wiki');
                        $url[0] = $wikilib->sefurl($newpagename);
                    }
                }
                // end wiki output
                // send emails if email param is set and tracker_always_notify or something was changed (mail_data is set in \TrackerLib::send_replace_item_notifications)
                if (!empty($email) && ($prefs['tracker_always_notify'] === 'y' || !empty($smarty->getTemplateVars('mail_data')))) {
                    // expose the pretty tracker fields to the email tpls
                    foreach ($flds['data'] as $f) {
                        $prettyout = strip_tags(wikiplugin_tracker_render_value($f, $item));
                        $smarty->assign('f_' . $f['fieldId'], $prettyout);
                        $smarty->assign('f_' . $f['permName'], $prettyout);
                    }
                    $emailOptions = preg_split("#\\|#", $email);
                    if (is_numeric($emailOptions[0])) {
                        $emailOptions[0] = $trklib->get_item_value($trackerId, $rid, $emailOptions[0]);
                    }
                    if (empty($emailOptions[0])) {
                        // from
                        $emailOptions[0] = $prefs['sender_email'];
                    }
                    if (empty($emailOptions[1])) {
                        // to
                        $emailOptions[1][0] = $prefs['sender_email'];
                    } else {
                        $emailOptions[1] = preg_split('/ *, */', $emailOptions[1]);
                        foreach ($emailOptions[1] as $key => $email) {
                            if (is_numeric($email)) {
                                $emailOptions[1][$key] = $trklib->get_item_value($trackerId, $rid, $email);
                            }
                        }
                    }
                    include_once 'lib/webmail/tikimaillib.php';
                    $mail = new TikiMail();
                    $mail->setFrom($emailOptions[0]);
                    if (!empty($emailOptions[2])) {
                        //tpl
                        $emailOptions[2] = preg_split('/ *, */', $emailOptions[2]);
                        foreach ($emailOptions[2] as $ieo => $eo) {
                            if (!preg_match('/\\.tpl$/', $eo)) {
                                $emailOptions[2][$ieo] = $eo . '.tpl';
                            }
                            $tplSubject[$ieo] = str_replace('.tpl', '_subject.tpl', $emailOptions[2][$ieo]);
                        }
                    } else {
                        $emailOptions[2] = array('tracker_changed_notification.tpl');
                    }
                    if (empty($tplSubject)) {
                        $tplSubject = array('tracker_changed_notification_subject.tpl');
                    }
                    $itpl = 0;
                    $smarty->assign('mail_date', $tikilib->now);
                    $smarty->assign('mail_itemId', $rid);
                    foreach ($emailOptions[1] as $ieo => $ueo) {
                        @($mail_data = $smarty->fetch('mail/' . $tplSubject[$itpl]));
                        if (empty($mail_data)) {
                            $mail_data = tra('Tracker was modified at ') . $_SERVER["SERVER_NAME"];
                        }
                        $mail->setSubject($mail_data);
                        $mail_data = $smarty->fetch('mail/' . $emailOptions[2][$itpl]);
                        if ($emailformat == 'html') {
                            $mail->setHtml($mail_data);
                        } else {
                            $mail->setText($mail_data);
                        }
                        try {
                            $mail->send($ueo);
                            $title = 'mail';
                        } catch (Zend_Mail_Exception $e) {
                            $title = 'mail error';
                        }
                        if ($title == 'mail error') {
                            // Log the email error at the tiki syslog
                            $logslib = TikiLib::lib('logs');
                            $logslib->add_log('mail error', 'plugin tracker email error / ' . $emailOptions[1][$ieo] . ' / item' . $rid);
                        } elseif ($title == 'mail' && $prefs['log_mail'] == 'y') {
                            // Log the email at the tiki syslog
                            $logslib = TikiLib::lib('logs');
                            $logslib->add_log('mail', 'plugin tracker email sent / ' . $emailOptions[1][$ieo] . ' / item' . $rid);
                        }
                        if (isset($tplSubject[$itpl + 1])) {
                            ++$itpl;
                        }
                    }
                }
                if (empty($url)) {
                    if (!empty($_REQUEST['ajax_add'])) {
                        // called by tracker ItemLink fields when adding new list items
                        while (ob_get_level()) {
                            ob_end_clean();
                        }
                        if ($prefs['feature_obzip'] == 'y') {
                            ob_start('ob_gzhandler');
                        } else {
                            ob_start();
                        }
                        // Need to add newly created itemId for item link selector
                        $ins_fields['itemId'] = $rid;
                        $access = TikiLib::lib('access');
                        $access->output_serialized($ins_fields);
                        ob_end_flush();
                        die;
                    } else {
                        if (!empty($page)) {
                            $url = "tiki-index.php?page=" . urlencode($page);
                            if (!empty($itemId)) {
                                $url .= "&itemId=" . $itemId;
                            }
                            $url .= "&ok=y&iTRACKER={$iTRACKER}";
                            $url .= "#wikiplugin_tracker{$iTRACKER}";
                            TikiLib::lib('access')->redirect($url);
                            exit;
                        } else {
                            return '';
                        }
                    }
                } else {
                    $key = 0;
                    foreach ($action as $key => $act) {
                        if (!empty($_REQUEST["action{$key}"])) {
                            break;
                        }
                    }
                    $itemIdPos = strpos($url[$key], 'itemId');
                    if ($itemIdPos !== false) {
                        if (strstr($url[$key], '#itemId')) {
                            $url[$key] = str_replace('#itemId', $rid, $url[$key]);
                        } else {
                            if ($itemIdPos + strlen('itemId') >= strlen($url[$key]) - 1 || substr($url[$key], $itemIdPos + strlen('itemId'), 1) == "&") {
                                // replace by the itemId if in the end (or -1: for backward compatibility so that "&itemId=" also works) or if it is followed by an '&'
                                $url[$key] = str_replace('itemId', 'itemId=' . $rid, $url[$key]);
                            }
                        }
                    }
                    TikiLib::lib('access')->redirect($url[$key]);
                    exit;
                }
            } elseif (isset($_REQUEST['trackit']) and $_REQUEST['trackit'] == $trackerId) {
                $smarty->assign('wikiplugin_tracker', $trackerId);
                //used in vote plugin
            }
        } else {
            if ((empty($itemId) || $overwrite == 'y') && !empty($values) || (!empty($_REQUEST['values']) and empty($_REQUEST['prefills']))) {
                // assign default values for each filedId specify
                if (empty($values)) {
                    // url with values[]=x&values[] witouth the list of fields
                    $values = $_REQUEST['values'];
                }
                if (!is_array($values)) {
                    $values = array($values);
                }
                if (isset($fields)) {
                    $fl = $fields;
                    for ($j = 0, $count_fl = count($fl); $j < $count_fl; $j++) {
                        for ($i = 0, $count_flds = count($flds['data']); $i < $count_flds; $i++) {
                            if ($flds['data'][$i]['fieldId'] == $fl[$j]) {
                                $flds['data'][$i]['value'] = $values[$j];
                            }
                        }
                    }
                } else {
                    // values contains all the fields value in the default order
                    $i = 0;
                    foreach ($values as $value) {
                        $flds['data'][$i++]['value'] = $value;
                    }
                }
            } elseif (!empty($itemId)) {
                if (isset($fields)) {
                    $fl = $fields;
                    $filter = '';
                    foreach ($flds['data'] as $f) {
                        if (in_array($f['fieldId'], $fl)) {
                            $filter[] = $f;
                        }
                    }
                } else {
                    $filter =& $flds['data'];
                }
                if (!empty($filter)) {
                    foreach ($filter as $f) {
                        $filter2[$f['fieldId']] = $f;
                    }
                    $flds['data'] = $trklib->get_item_fields($trackerId, $itemId, $filter2, $itemUser, true);
                }
                // todo: apply the values for fields with no values
            } else {
                if (isset($_REQUEST['values']) && isset($_REQUEST['prefills'])) {
                    //url:prefills=1:2&values[]=x&values[]=y
                    if (!is_array($_REQUEST['values'])) {
                        $_REQUEST['values'] = array($_REQUEST['values']);
                    }
                    $fl = preg_split('/:/', $_REQUEST['prefills']);
                } else {
                    unset($fl);
                }
                for ($i = 0, $count_flds2 = count($flds['data']); $i < $count_flds2; $i++) {
                    if (isset($fl) && ($j = array_search($flds['data'][$i]['fieldId'], $fl)) !== false) {
                        $flds['data'][$i]['value'] = $_REQUEST['values'][$j];
                    } else {
                        // setting default value prevent dropdown default value working
                        $options = $flds['data'][$i]['options_array'];
                        if (!in_array($flds['data'][$i]['type'], array('d', 'D', 'R', 'M')) || count($options) === count(array_unique($options))) {
                            $flds['data'][$i]['value'] = '';
                            // initialize fields with blank values
                        }
                    }
                }
            }
        }
        // Check that individual fields are in the tracker
        if (!empty($fields)) {
            $fl = $fields;
            if ($sort == 'y') {
                $flds = $trklib->sort_fields($flds, $fl);
            }
            foreach ($fl as $l) {
                $ok = false;
                foreach ($flds['data'] as $f) {
                    if ($f['fieldId'] == $l) {
                        $ok = true;
                        break;
                    }
                }
                if (!$ok) {
                    $back .= '<div class="alert alert-warning"><strong>' . tra('Incorrect fieldId:') . ' ' . $l . '</strong>.<br> ' . tra("Please ensure you are using the correct field ID and that it is properly included in the template, if any.") . '</div>';
                }
            }
        } elseif (empty($fields) && empty($wiki) && empty($tpl)) {
            // in this case outf still be blank and needs to be filled
            foreach ($flds['data'] as $f) {
                $outf[] = $f['fieldId'];
            }
        }
        // Check that multiple fill fields are in the tracker
        if (!empty($fieldsfill)) {
            foreach ($fill_fields as $l) {
                $ok = false;
                foreach ($fill_flds['data'] as $f) {
                    if ($f['fieldId'] == $l) {
                        $ok = true;
                        break;
                    }
                }
                if (!$ok) {
                    $back .= '<div class="alert alert-warning">' . tra('Incorrect fieldId:') . ' ' . $l . '</div>';
                }
            }
        }
        // Display warnings when needed
        if (count($field_errors['err_mandatory']) > 0 || count($field_errors['err_value']) > 0) {
            $back .= $smarty->fetch('tracker_error.tpl');
            $_REQUEST['error'] = 'y';
            if (count($field_errors['err_mandatory']) > 0) {
                $msg = tra('Following mandatory fields are missing');
                foreach ($field_errors['err_mandatory'] as $err) {
                    $msg .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;' . $err['name'];
                }
                TikiLib::lib('errorreport')->report($msg);
            }
            if (count($field_errors['err_value']) > 0) {
                $msg = tra('Following fields are incorrect');
                foreach ($field_errors['err_value'] as $err) {
                    $msg .= '<br>&nbsp;&nbsp;&nbsp;&nbsp;' . $err['name'];
                }
                TikiLib::lib('errorreport')->report($msg);
            }
            if ($registration && !empty($userField) && isset($_REQUEST['name']) && $_REQUEST['name'] === $userField['value'] && $_REQUEST['name'] === $user) {
                // if in registration and creating a user tracker item for the new user
                // remove the user if they did not complete the tracker correctly
                $userlib->remove_user($userField['value']);
                if ($prefs['eponymousGroups'] == 'y') {
                    // eponymous group will contain only this (former) user so remove that too
                    $userlib->remove_group($userField['value']);
                }
                $user = '';
                // needed to re-include the captcha inputs
                $hidden_fieldId = array();
                // remove hidden user fields which are otherwise required
                foreach ($flds['data'] as $k => $v) {
                    // remove the login field otherwise it gets rendered in the form also required
                    if ($v['fieldId'] == $userField['fieldId']) {
                        unset($flds['data'][$k]);
                    }
                }
            }
            if (isset($field_errors['err_antibot'])) {
                $_REQUEST['error'] = 'y';
            }
            if (isset($field_errors['err_outputwiki'])) {
                $smarty->loadPlugin('smarty_function_icon');
                $icon = smarty_function_icon(['name' => 'warning'], $smarty);
                $back .= '<div class="alert alert-warning">' . $icon . ' ';
                $back .= $field_errors['err_outputwiki'];
                $back .= '</div><br />';
                $_REQUEST['error'] = 'y';
            }
            if (count($field_errors['err_mandatory']) > 0 || count($field_errors['err_value']) > 0 || isset($field_errors['err_antibot']) || isset($field_errors['err_outputwiki'])) {
                $smarty->assign('input_err', 'y');
            }
        }
        if (!empty($page)) {
            $back .= '~np~';
            $smarty->assign_by_ref('tiki_p_admin_trackers', $perms['tiki_p_admin_trackers']);
        }
        if (!empty($params['_ajax_form_ins_id'])) {
            $headerlib = TikiLib::lib('header');
            $old_js['js'] = $headerlib->js;
            // of tracker form JS into a function to initialise it when the dialog is created
            $old_js['jq_onready'] = $headerlib->jq_onready;
            $headerlib->clear_js();
            // so store existing js for later and clear
        }
        if ($prefs['feature_jquery'] == 'y' && $prefs['feature_jquery_validation'] == 'y') {
            $validatorslib = TikiLib::lib('validators');
            $customvalidation = '';
            $customvalidation_m = '';
            if ($registration == 'y') {
                // email validation
                $customvalidation .= 'email: { ';
                $customvalidation .= 'required: true, ';
                $customvalidation .= 'email: true }, ';
                $customvalidation_m .= 'email: { email: "' . tra("Invalid email") . '", required: "' . tra("This field is required") . '"}, ';
                // password validation
                $customvalidation .= 'pass: { ';
                $customvalidation .= 'required: true, ';
                $customvalidation .= 'remote: { ';
                $customvalidation .= 'url: "validate-ajax.php", ';
                $customvalidation .= 'type: "post", ';
                $customvalidation .= 'data: { ';
                $customvalidation .= 'validator: "password", ';
                $customvalidation .= 'input: function() { ';
                $customvalidation .= 'return $("#pass1").val(); ';
                $customvalidation .= '} } } ';
                $customvalidation .= '}, ';
                $customvalidation_m .= 'pass: { required: "' . tra("This field is required") . '"}, ';
                // password repeat validation
                $customvalidation .= 'passAgain: { equalTo: "#pass1" }, ';
                $customvalidation_m .= 'passAgain: { equalTo: "' . tra("Passwords do not match") . '"}, ';
                // username validation
                $customvalidation .= 'name: { ';
                $customvalidation .= 'required: true, ';
                $customvalidation .= 'remote: { ';
                $customvalidation .= 'url: "validate-ajax.php", ';
                $customvalidation .= 'type: "post", ';
                $customvalidation .= 'data: { ';
                $customvalidation .= 'validator: "username", ';
                $customvalidation .= 'input: function() { ';
                $customvalidation .= 'return $("#name").val(); ';
                $customvalidation .= '} } } ';
                $customvalidation .= '}, ';
                $customvalidation_m .= 'name: { required: "' . tra("This field is required") . '"}, ';
                if (extension_loaded('gd') && function_exists('imagepng') && function_exists('imageftbbox') && $prefs['feature_antibot'] == 'y' && empty($user) && $prefs['recaptcha_enabled'] != 'y') {
                    // antibot validation
                    $customvalidation .= '"captcha[input]": { ';
                    $customvalidation .= 'required: true, ';
                    $customvalidation .= 'remote: { ';
                    $customvalidation .= 'url: "validate-ajax.php", ';
                    $customvalidation .= 'type: "post", ';
                    $customvalidation .= 'data: { ';
                    $customvalidation .= 'validator: "captcha", ';
                    $customvalidation .= 'parameter: function() { ';
                    $customvalidation .= 'return $("#captchaId").val(); ';
                    $customvalidation .= '}, ';
                    $customvalidation .= 'input: function() { ';
                    $customvalidation .= 'return $("#antibotcode").val(); ';
                    $customvalidation .= '} } } ';
                    $customvalidation .= '}, ';
                    $customvalidation_m .= '"captcha[input]": { required: "' . tra("This field is required") . '"}, ';
                }
                if ($prefs['useRegisterPasscode'] == 'y') {
                    $customvalidation .= 'passcode: {
								required: true,
								remote: {
									url: "validate-ajax.php",
									type: "post",
									data: {
										validator: "passcode",
										input: function() {
											return $("#passcode").val();
											}
										}
									}
								}, ';
                    $customvalidation_m .= 'passcode: { required: "' . tra("This field is required") . '"}, ';
                }
            }
            $validationjs = $validatorslib->generateTrackerValidateJS($flds['data'], $fields_prefix, $customvalidation, $customvalidation_m);
            if (!empty($params['_ajax_form_ins_id']) && $params['_ajax_form_ins_id'] === 'group') {
                $headerlib->add_jq_onready("var ajaxTrackerValidation_group={validation:{" . $validationjs . '};');
                // return clean rules and messages object for ajax
            } else {
                $smarty->assign('validationjs', $validationjs);
                $back .= $smarty->fetch('tracker_validator.tpl');
            }
        }
        if ($params['formtag'] == 'y') {
            //check if tracker has custom form classes, else default to form-horizontal
            $formClasses = $tracker['useFormClasses'] == 'y' ? $tracker['formClasses'] : "form-horizontal";
            $back .= '<form class="' . $formClasses . '" name="editItemForm' . $iTRACKER . '" id="editItemForm' . $iTRACKER . '" enctype="multipart/form-data" method="post"' . (isset($target) ? ' target="' . $target . '"' : '') . ' action="' . $_SERVER['REQUEST_URI'] . '"><input type="hidden" name="trackit" value="' . $trackerId . '" />';
            $back .= '<input type="hidden" name="refresh" value="1" />';
        }
        $back .= '<input type="hidden" name="iTRACKER" value="' . $iTRACKER . '" />';
        if (isset($_REQUEST['page'])) {
            $back .= '<input type="hidden" name="page" value="' . $_REQUEST["page"] . '" />';
        }
        // for registration
        if (isset($_REQUEST['name'])) {
            $back .= '<input type="hidden" name="name" value="' . $_REQUEST["name"] . '" />';
        }
        if (isset($_REQUEST['pass'])) {
            $back .= '<input type="hidden" name="pass" value="' . $_REQUEST["pass"] . '" />';
            $back .= '<input type="hidden" name="passAgain" value="' . $_REQUEST["pass"] . '" />';
        }
        if (isset($_REQUEST['email'])) {
            $back .= '<input type="hidden" name="email" value="' . $_REQUEST["email"] . '" />';
        }
        if (isset($_REQUEST['antibotcode'])) {
            $back .= '<input type="hidden" name="antibotcode" value="' . $_REQUEST["antibotcode"] . '" />';
        }
        if (isset($_REQUEST['chosenGroup'])) {
            // for registration
            $back .= '<input type="hidden" name="chosenGroup" value="' . $_REQUEST["chosenGroup"] . '" />';
        }
        if (isset($_REQUEST['register'])) {
            $back .= '<input type="hidden" name="register" value="' . $_REQUEST["register"] . '" />';
        }
        if ($showtitle == 'y') {
            $back .= '<div class="h1">' . $tracker["name"] . '</div>';
        }
        if ($showdesc == 'y' && $tracker['description']) {
            if ($tracker['descriptionIsParsed'] == 'y') {
                $back .= '<div class="wikitext">' . $tikilib->parse_data($tracker['description']) . '</div><br />';
            } else {
                $back .= '<div class="wikitext">' . tra($tracker["description"]) . '</div><br />';
            }
        }
        if (isset($_REQUEST['tr_preview'])) {
            // use for the computed and join fields
            $assocValues = array();
            $assocNumerics = array();
            foreach ($flds['data'] as $f) {
                if (empty($f['value']) && ($f['type'] == 'u' || $f['type'] == 'g' || $f['type'] == 'I') && ($f['options_array'][0] == '1' || $f['options_array'][0] == '2')) {
                    //need to fill the selector fields for the join
                    $f['value'] = $f['type'] == 'I' ? $tikilib->get_ip_address() : ($f['type'] == 'g' ? $group : $user);
                }
                $assocValues[$f['fieldId']] = $f['value'];
                $assocNumerics[$f['fieldId']] = preg_replace('/[^0-9\\.\\+]/', '', $f['value']);
                // get rid off the $ and such unit
            }
        }
        if (!empty($itemId)) {
            $item = array('itemId' => $itemId, 'trackerId' => $trackerId);
        } else {
            $item = array('itemId' => '');
        }
        foreach ($flds['data'] as $i => $f) {
            // collect additional infos
            if (in_array($f['fieldId'], $outf)) {
                $flds['data'][$i]['ins_id'] = $f['type'] == 'e' ? 'ins_' . $f['fieldId'] : $fields_prefix . $f['fieldId'];
                if (($f['isHidden'] == 'c' || $f['isHidden'] == 'p') && !empty($itemId) && !isset($item['creator'])) {
                    $item['creator'] = $trklib->get_item_creator($trackerId, $itemId);
                }
            }
        }
        if (!empty($showstatus) && $showstatus == 'y') {
            $status_types = $trklib->status_types();
            $smarty->assign_by_ref('status_types', $status_types);
            $smarty->assign('form_status', 'status');
            $smarty->assign_by_ref('tracker', $tracker);
            if (!empty($item_info)) {
                $smarty->assign_by_ref('item', $item_info);
            }
            $status_input = $smarty->fetch('tracker_status_input.tpl');
        }
        $labelclass = 'col-md-3';
        $inputclass = 'col-md-9';
        $buttonclass = 'col-md-9 col-md-offset-3';
        if ($registration == "y") {
            $back .= '<input type="hidden" name="register" value="Register">';
            $labelclass = 'col-md-4 col-sm-3';
            $inputclass = 'col-md-4 col-sm-6';
            $buttonclass = 'col-md-8 col-md-offset-4';
        }
        // Loop on tracker fields and display form
        if (empty($tpl) && empty($wiki)) {
            $back .= '<div class="wikiplugin_tracker">';
            if (!empty($showstatus) && $showstatus == 'y') {
                $back .= '<div class="alert alert-info">' . tra('Status') . $status_input . '</div>';
                // <tr><td>'.tra('Status').'</td><td>'.$status_input.'</td></tr>
            }
            if ($registration == 'y' && $prefs["user_register_prettytracker"] != 'y') {
                $back .= $smarty->fetch('register-form.tpl');
            }
        } else {
            $back .= '<div class="wikiplugin_tracker">';
            if (!empty($showstatus) && $showstatus == 'y') {
                $smarty->assign_by_ref('f_status_input', $status_input);
            }
        }
        $backLength0 = strlen($back);
        foreach ($flds['data'] as $f) {
            if (!in_array($f['fieldId'], $auto_fieldId) && in_array($f['fieldId'], $hidden_fieldId)) {
                // Show in hidden form
                $back .= '<span style="display:none;">' . wikiplugin_tracker_render_input($f, $item, $dynamicSave) . '</span>';
            } elseif (!in_array($f['fieldId'], $auto_fieldId) && in_array($f['fieldId'], $outf)) {
                if ($showmandatory == 'y' and $f['isMandatory'] == 'y') {
                    $onemandatory = true;
                }
                if ($f['type'] == 'A') {
                    $smarty->assign_by_ref('tiki_p_attach_trackers', $perms['tiki_p_attach_trackers']);
                }
                if (!empty($tpl) || !empty($wiki)) {
                    if ($prettyModifier[$f['fieldId']] == "output") {
                        //check if modifier is set to "output" ( set in getPrettyFieldIds() in trackerlib )
                        $prettyout = '<span class="outputPretty" id="track_' . $f['fieldId'] . '" name="track_' . $f['fieldId'] . '">' . wikiplugin_tracker_render_value($f, $item) . '</span>';
                        $smarty->assign('f_' . $f['fieldId'], $prettyout);
                        $smarty->assign('f_' . $f['permName'], $prettyout);
                    } else {
                        $mand = ($showmandatory == 'y' and $f['isMandatory'] == 'y') ? "&nbsp;<strong class='mandatory_star'>*</strong>&nbsp;" : '';
                        if (!empty($f['description'])) {
                            $desc = $f['descriptionIsParsed'] == 'y' ? $tikilib->parse_data($f['description']) : tra($f['description']);
                            $desc = '<div class="trackerplugindesc">' . $desc . '</div>';
                        } else {
                            $desc = '';
                        }
                        if (!empty($prettyModifier[$f['fieldId']])) {
                            // check if a template was specified in prettyModifier
                            $smarty->assign("field_name", $f['name']);
                            $smarty->assign("field_id", $f['fieldId']);
                            $smarty->assign("permname", $f['permName']);
                            $smarty->assign("mandatory_sym", $mand);
                            $smarty->assign("field_input", wikiplugin_tracker_render_input($f, $item, $dynamicSave));
                            $smarty->assign("description", $desc);
                            $smarty->assign("field_type", $f['type']);
                            $prettyout = $smarty->fetch($prettyModifier[$f['fieldId']]);
                            //fetch template identified in prettyModifier
                        } else {
                            $prettyout = wikiplugin_tracker_render_input($f, $item, $dynamicSave) . $mand . $desc;
                        }
                        $smarty->assign('f_' . $f['fieldId'], $prettyout);
                        $smarty->assign('f_' . $f['permName'], $prettyout);
                    }
                } else {
                    $back .= '<div class="form-group tracker_input_label"';
                    // <tr><td class="tracker_input_label"
                    // If type is has a samerow param and samerow is "No", show text on one line and the input field on the next
                    $isTextOnSameRow = true;
                    switch ($f['type']) {
                        case 't':
                            // Text field
                        // Text field
                        case 'n':
                            // Numeric field
                        // Numeric field
                        case 'b':
                            // Currency
                            if (empty($f['options_array']) || isset($f['options_array']['0']) && strlen($f['options_array']['0']) == 0) {
                                // Use default
                                //	Pending: Unable to locate the object to check to determine the default (in the tracker field definitions). Hardcode true. Arild
                                $isTextOnSameRow = true;
                            } else {
                                $isTextOnSameRow = intval($f['options_array']['0']) == 0 ? false : true;
                            }
                            break;
                        case 'a':
                            // Text area
                            $isTextOnSameRow = true;
                            if (isset($f['options_array']['8'])) {
                                if (empty($f['options_array']) || isset($f['options_array']['8']) && strlen($f['options_array']['8']) == 0) {
                                    // Use default
                                    //	Pending: Unable to locate the object to check to determine the default (in the tracker field definitions). Hardcode true. Arild
                                    $isTextOnSameRow = true;
                                } else {
                                    $isTextOnSameRow = intval($f['options_array']['8']) == 0 ? false : true;
                                }
                            }
                            break;
                    }
                    if (!empty($colwidth)) {
                        $back .= " width='" . $colwidth . "'";
                    }
                    $back .= '><label class="' . $labelclass . ' control-label" for="' . $f['ins_id'] . '">' . wikiplugin_tracker_name($f['fieldId'], tra($f['name']), $field_errors);
                    //
                    if ($showmandatory == 'y' and $f['isMandatory'] == 'y' && $registration != 'y') {
                        $back .= " <strong class='mandatory_star'>*</strong> ";
                    }
                    $back .= '</label>';
                    // If use different lines, add a line break.
                    // Otherwise a new column
                    if (!$isTextOnSameRow) {
                        $back .= "<br/>";
                    } else {
                        $back .= '<div class="' . $inputclass . ' tracker_input_value tracker_field' . $f['fieldId'] . '">';
                        // '</td><td class="tracker_input_value">';
                    }
                    $back .= wikiplugin_tracker_render_input($f, $item, $dynamicSave) . "</div>";
                    // chibaguy added /divs
                    if ($showmandatory == 'y' and $f['isMandatory'] == 'y' && $registration == 'y') {
                        $back .= '<div class="col-md-1 col-sm-1"><span class="text-danger tips" title=":' . tra('This field is mandatory') . '">*</span></div>';
                    }
                    if ($isTextOnSameRow) {
                        $back .= '</div>';
                    }
                }
                if ($f['type'] != 'S' && empty($tpl) && empty($wiki)) {
                    if ($showfieldsdesc == 'y') {
                        $back .= '<div class="form-group tracker-help-block"><div class="' . $labelclass . ' control-label sr-only">Label</div><div class="' . $inputclass . ' trackerplugindesc help-block">';
                        if ($f['descriptionIsParsed'] == 'y') {
                            $back .= $tikilib->parse_data($f['description']);
                        } else {
                            $back .= tra($f['description']);
                        }
                        $back .= '</div></div>';
                    }
                }
            }
        }
        if (isset($params['fieldsfill']) && !empty($params['fieldsfill']) && empty($itemId)) {
            // $back.= '<tr><td><label for="ins_fill">' . tra("Create multiple items (one per line).") . '</label>';
            $back .= '<div class="form-group"><label class="col-md-3" for="ins_fill">' . tra("Insert one item per line:") . '<br />' . '<br />' . '<br />' . '</label>';
            $back .= <<<FILL
// </td><td>
<input type="hidden" value="" name="mode_wysiwyg"/>
<input type="hidden" value="" name="mode_normal"/>
<div class="edit-zone">
<textarea id="ins_fill" class="wikiedit class="form-control" data-syntax="" data-codemirror="" onkeyup="" rows="15" name="ins_fill" >
</textarea>
</div>
<input type="hidden" value="n" name="wysiwyg"/>
<div name="ins_fill_desc" class="trackerplugindesc" >
FILL;
            $back .= sprintf(tra('Each line is a list of %d field values separated with: %s'), $fill_line_cant, htmlspecialchars($fieldsfillseparator));
            $back .= '</div><div name="ins_fill_desc2" class="trackerplugindesc" >' . htmlspecialchars(implode($fieldsfillseparator, $fieldsfillnames));
            $back .= '</div>';
            //	$back .= '</td></tr>';
        }
        if ($prefs['feature_antibot'] == 'y' && (empty($user) || !empty($user) && isset($_REQUEST['error']) && $_REQUEST['error'] == 'y')) {
            $smarty->assign('showantibot', true);
        }
        if (!empty($tpl)) {
            $smarty->security = true;
            $back .= $smarty->fetch($tpl);
        } elseif (!empty($wiki)) {
            $smarty->security = true;
            if ($tikilib->page_exists($wiki)) {
                $back .= $smarty->fetch('wiki:' . $wiki);
            } else {
                $back .= '<span class="alert-warning">' . tr('Missing wiki template page "%0"', htmlspecialchars($wiki)) . '</span>';
            }
        }
        $smarty->assign('showmandatory', $showmandatory);
        if ($prefs['feature_antibot'] == 'y' && empty($user) && (!isset($transactionStep) || $transactionStep == 0) && $params['formtag'] != 'n' && ($registration != 'y' || $prefs["user_register_prettytracker"] != 'y')) {
            // in_tracker session var checking is for tiki-register.php
            $smarty->assign('antibot_table', empty($wiki) && empty($tpl) ? 'n' : 'y');
            $captchalib = TikiLib::lib('captcha');
            $smarty->assign('captchalib', $captchalib);
            if ($registration == 'y') {
                $smarty->assign('form', 'register');
            }
            $back .= $smarty->fetch('antibot.tpl');
        }
        $back .= '</div>';
        if ($params['formtag'] == 'y') {
            if (empty($wiki) && empty($tpl)) {
                $back .= '<div class="form-group"><div class="input_submit_container btn-bar ' . $buttonclass . '">';
            } else {
                $back .= '<div class="form-group"><div class="input_submit_container btn-bar">';
            }
            if (!empty($reset)) {
                $back .= '<input class="button submit preview" type="reset" name="tr_reset" value="' . tra($reset) . '" />';
            }
            if (!empty($preview)) {
                $back .= '<input class="btn btn-default button submit preview" type="submit" name="tr_preview" value="' . tra($preview) . '" />';
            }
            foreach ($action as $key => $act) {
                $back .= '<input class="button submit ' . $action_style[$key] . '" type="submit" name="action' . $key . '" value="' . tra($act) . '" onclick="needToConfirm=false" />';
            }
            $back .= '</div></div>';
        }
        if ($showmandatory == 'y' and $onemandatory) {
            if (empty($wiki) && empty($tpl)) {
                $back .= "<div class='form-group'><div class='" . $buttonclass . "'><div class='text-center alert alert-danger'><em>" . tra("Fields marked with an * are mandatory.") . "</em></div></div></div>";
            } else {
                $back .= "<div class='form-group'><div class='text-center alert alert-danger'><em>" . tra("Fields marked with an * are mandatory.") . "</em></div></div>";
            }
        }
        if ($params['formtag'] == 'y') {
            $back .= '</form>';
        }
        if (!empty($params['_ajax_form_ins_id'])) {
            // save new js in a function for the form init fn
            $headerlib->add_js(' var ajaxTrackerFormInit_' . $params['_ajax_form_ins_id'] . ' = function() {' . $headerlib->output_js(false) . '}', 10);
            // put back the pre-existing js
            $headerlib->js = array_merge($headerlib->js, $old_js['js']);
            $headerlib->jq_onready = array_merge($headerlib->jq_onready, $old_js['jq_onready']);
        }
        if (!empty($page)) {
            $back .= '~/np~';
        }
        $smarty->assign_by_ref('tiki_p_admin_trackers', $perms['tiki_p_admin_trackers']);
        return $back;
    } else {
        if (isset($_REQUEST['trackit']) and $_REQUEST['trackit'] == $trackerId) {
            $smarty->assign('wikiplugin_tracker', $trackerId);
        }
        //used in vote plugin
        $id = ' id="wikiplugin_tracker' . $iTRACKER . '"';
        if ($showtitle == 'y') {
            $back .= '<div class="h1"' . $id . '>' . $tracker["name"] . '</div>';
            $id = '';
        }
        if ($showdesc == 'y') {
            $back .= '<div class="wikitext"' . $id . '>' . $tracker["description"] . '</div><br />';
            $id = '';
        }
        $back .= "<div{$id}>" . $data . '</div>';
        return $back;
    }
}
コード例 #21
0
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;
}
コード例 #22
0
 function deleteOldFiles()
 {
     global $prefs, $smarty;
     include_once 'lib/webmail/tikimaillib.php';
     $query = 'select * from `tiki_files` where `deleteAfter` < ' . $this->now . ' - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
     $files = $this->fetchAll($query, array());
     foreach ($files as $fileInfo) {
         if (empty($galInfo) || $galInfo['galleryId'] != $fileInfo['galleryId']) {
             $galInfo = $this->get_file_gallery_info($fileInfo['galleryId']);
             if (!empty($prefs['fgal_delete_after_email'])) {
                 $smarty->assign_by_ref('galInfo', $galInfo);
             }
         }
         if (!empty($prefs['fgal_delete_after_email'])) {
             $savedir = $this->get_gallery_save_dir($galInfo['galleryId'], $galInfo);
             $fileInfo['data'] = file_get_contents($savedir . $fileInfo['path']);
             $smarty->assign_by_ref('fileInfo', $fileInfo);
             $mail = new TikiMail();
             $mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
             $mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
             $mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
             $to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
             $mail->send($to);
         }
         $this->remove_file($fileInfo, $galInfo, false);
     }
 }
コード例 #23
0
ファイル: tiki-remind_password.php プロジェクト: rjsmelo/tiki
 // 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 {
     $tmp = tra("An email with a link to reset your password has been sent ");
 }
コード例 #24
0
ファイル: calendarlib.php プロジェクト: linuxwhy/tiki-1
 /**
  * @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']));
         }
     }
 }
コード例 #25
0
			case 5:
				$mail_data.= tra("very high");
    			break;
		}
		$mail_data.= ".\n\n";
		if ($info['start'] !== NULL) {
			$mail_data.= tra("You've to start your work at least on") . ": " . $tikilib->date_format($prefs['short_date_format'] . ' ' . $prefs['short_time_format'], $info['end']) . "\n";
		}
		if ($info['end'] !== NULL) {
			$mail_data.= tra("You've to finish your work on") . ": " . $tikilib->date_format($prefs['short_date_format'] . ' ' . $prefs['short_time_format'], $info['end']) . "\n";
		}
		$mail_data.= "\n" . tra("Login and click the link below") . "\n";
		$mail_data.= "http://" . $_REQUEST['HTTP_HOST'] . $_REQUEST['REQUEST_URI'] . "?tiki_view_mode=view&taskId=" . $taskId . "\n\n";
		$mail_data.= tra("Please read the task and work on it!");
		$mail->setText($mail_data);
		$mail->send(array($email));
	}
	if (!isset($info['user'])) {
		unset($_REQUEST['taskId']);
		$smarty->assign('msg', tra("Sorry, there was an error while trying to write data into the database"));
		$smarty->display("error.tpl");
		die;
	}
	if ($send_message and $userlib->user_has_permission($msg_from, 'tiki_p_messages') and $userlib->user_has_permission($msg_to, 'tiki_p_messages')) {
		$msg_body = "__" . tra('Task') . ":__";
		$msg_body.= '^[tiki-user_tasks.php?taskId=' . $info['taskId'] . "|" . $info['title'] . "]^\n";
		$msg_body.= $task_info_message . $msg_changes_head . '^' . $msg_changes . '^';
		$messulib->post_message(
						$msg_to, //user
						$msg_from, //from
コード例 #26
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']));
        }
    }
}
コード例 #27
0
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~';
}
コード例 #28
0
ファイル: messulib.php プロジェクト: ameoba32/tiki
 /**
  * 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;
 }
コード例 #29
0
	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']);
			$smarty->assign('mid', 'tiki-change_password.tpl');
コード例 #30
0
ファイル: tiki-webmail.php プロジェクト: ameoba32/tiki
     $filegallib = TikiLib::lib('filegal');
     $filedata = $filegallib->get_file_info($_REQUEST['fattId']);
     $a4 = file_get_contents($prefs['fgal_use_dir'] . $filedata['path']);
     $mail->addAttachment($a4, $filedata['filename'], $filedata['filetype']);
 }
 if ($_REQUEST['fattId']) {
     $filegallib = TikiLib::lib('filegal');
     $filedata = $filegallib->get_file_info($_REQUEST['fattId']);
     $a4 = file_get_contents($prefs['fgal_use_dir'] . $filedata['path']);
     $mail->addAttachment($a4, $filedata['filename'], $filedata['filetype']);
 }
 //	$mail->setSMTPParams($current['smtp'], $current['smtpPort'], '', $current['useAuth'], $current['username'], $current['pass']);   // commented out as a temporary fix - might need to do more later
 if (isset($_REQUEST['useHTML']) && $_REQUEST['useHTML'] == 'on') {
     $mail->setHTML($_REQUEST['body'], strip_tags($_REQUEST['body']));
 } else {
     $mail->setText($_REQUEST['body']);
 }
 $to_array_1 = preg_split('/[, ;]/', $_REQUEST['to']);
 $to_array = array();
 foreach ($to_array_1 as $to_1) {
     if (!empty($to_1)) {
         $to_array[] = $to_1;
     }
 }
 $to_array = $contactlib->parse_nicknames($to_array);
 // Get email addresses not in the address book
 $not_contacts = $contactlib->are_contacts($to_array, $user);
 if (count($not_contacts) > 0) {
     $smarty->assign('notcon', 'y');
 } else {
     $smarty->assign('notcon', 'n');