private function internalMessage($recipient, $requester)
 {
     $subject = $this->message_obj->message['subject'];
     $message = $this->message_obj->message['message'];
     $container_html = $this->message_obj->message['template'];
     if ($container_html != 'text_only') {
         // patching up message and subject in the email container
         $message = nl2br($message);
         $email_container = new Template(PA::$config_path . "/email_containers/{$container_html}");
         $email_container->set('subject', $subject);
         $email_container->set('message', $message);
         // actual message to be sent through the mail
         $body = $email_container->fetch();
     } else {
         $body = $message;
     }
     Message::add_message($requester, null, $recipient, $subject, $body);
 }
Exemplo n.º 2
0
 foreach ($login_names as $login_name) {
     try {
         $User = new User();
         $User->load($login_name);
         $valid_recipients['id'][] = $User->user_id;
         $valid_recipients['name'][] = $User->login_name;
         $valid_recipients['fname'][] = $User->first_name;
         $valid_recipients['email'][] = $User->email;
     } catch (PAException $e) {
         $invalid_recipients[] = $login_name;
     }
 }
 $message = null;
 if (count($valid_recipients)) {
     $is_draft = FALSE;
     Message::add_message($login_uid, $valid_recipients['id'], $valid_recipients['name'], $subject, $body, $is_draft, $in_reply_to);
     for ($counter = 0; $counter < count($valid_recipients['id']); $counter++) {
         $params = array('first_name_sender' => $_SESSION['user']['first_name'], 'first_name_recipient' => $valid_recipients['fname'][$counter], 'sender_id' => $login_uid, 'recipient_id' => $valid_recipients['id'][$counter], 'recipient_email' => $valid_recipients['email'][$counter], 'sender_url' => url_for('user_blog', array('login' => $_SESSION['user']['name'])), 'my_messages_url' => PA::$url . '/' . FILE_MYMESSAGE);
         auto_email_notification('msg_waiting', $params);
     }
     $message = 'Message sent successfully to ' . implode(",", $valid_recipients['name']) . '<br />';
 }
 if (count($invalid_recipients)) {
     //some of the recipients are invalid. So displaying the error message for them.
     $message .= 'Message sending failed for ' . implode(",", $invalid_recipients) . ' as user(s) doesn\'t exist';
     $error = true;
 } else {
     // message sent successfully to all the recipients. Redirecting user to inbox.
     header("Location: {$base_url}/mymessage.php?msg=message_sent");
     exit;
 }
 function switch_destination($destination)
 {
     $this->no_id = "";
     if (empty($this->mail_type)) {
         $this->mail_type = '';
         //none
     }
     if (empty($this->network_owner)) {
         // sometime group_owner param passed as recepient in this var - VERY BAD!
         $net_owner = new User();
         $net_owner->load((int) PA::$network_info->owner_id);
         $this->network_owner = $net_owner->login_name;
     }
     // checking whether subject or message is set or not
     $msg_data = EmailMessages::get($this->mail_type, $this->mail_sub_msg_array);
     $this->subject = @$msg_data['subject'];
     $this->message = @$msg_data['message'];
     if (empty($this->subject)) {
         $this->subject = 'none';
     }
     if (empty($this->message)) {
         $this->message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!';
     }
     if ($this->mail_type == 'friend_request') {
         $mail_from = $_SESSION['user']['email'];
     }
     switch ($destination) {
         case NET_EMAIL:
             //external mail
             $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from);
             break;
         case NET_MSG:
             //internal messageing
             Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message);
             $sender = new User();
             $sender->load((int) $this->from);
             $sender_id = $sender->user_id;
             $sender_name = $sender->login_name;
             $recipient_id = User::map_logins_to_ids($this->network_owner);
             $_sender_url = url_for('user_blog', array('login' => $sender->login_name));
             $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>";
             $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>';
             $recipient_obj = new User();
             foreach ($recipient_id as $key => $value) {
                 $recipient_obj->load((int) $value);
             }
             // send msg waiting blink message
             $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name);
             auto_email_notification('msg_waiting', $params);
             break;
         case NET_BOTH:
             // via both option
             // FIXME: $mail_from seems not be set on peepagg
             try {
                 $check = pa_mail($this->to, $this->mail_type, $this->mail_sub_msg_array, @$mail_from);
             } catch (PAEXception $e) {
                 Logger::log(__FILE__ . ": pa_mail: " . $e->getMessage());
             }
             Message::add_message($this->from, $this->no_id, $this->network_owner, $this->subject, $this->message);
             $sender = new User();
             $sender->load((int) $this->from);
             $sender_id = $sender->user_id;
             $sender_name = $sender->login_name;
             $recipient_id = User::map_logins_to_ids($this->network_owner);
             $_sender_url = url_for('user_blog', array('login' => $sender->login_name));
             $sender_url = "<a href=\"{$_sender_url}\">{$_sender_url}</a>";
             $my_messages_url = '<a href="' . PA::$url . '/' . FILE_MYMESSAGE . '">' . PA::$url . '/' . FILE_MYMESSAGE . '</a>';
             $recipient_obj = new User();
             foreach ($recipient_id as $key => $value) {
                 $recipient_obj->load((int) $value);
             }
             // send msg waiting blink message
             $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => PA::$site_name);
             // chnaged by Martin: this is NET_BOTH, the user is already recieving it as email
             // so why do we also trigger the ms_waiting here?
             // auto_email_notification('msg_waiting', $params);
             break;
     }
 }
Exemplo n.º 4
0
 public function add_message()
 {
     $content = trim($this->input['content']);
     if (!$content) {
         $this->errorOutput(NOCONTENT);
     }
     if (!get_magic_quotes_gpc()) {
         $content = addslashes($content);
     }
     //根据发布id查询信息
     $cmid = intval($this->input['cmid']);
     if (!$cmid) {
         //非发布库内容评论要传入应用标识和模块标识
         if (!$this->input['app_uniqueid'] || !$this->input['mod_uniqueid']) {
             $this->errorOutput(NOUNIQUEID);
         }
     }
     //评论设置
     $set = $this->comment_set();
     $contentid = intval($this->input['contentid']);
     if (!$contentid) {
         $this->errorOutput(NOCONTENTID);
     }
     $display = $set['display'];
     //是否审核显示
     $max_word = $set['max_word'];
     //评论最大字数
     $login = $set['is_login'];
     //是否登录评论
     $colation = $set['colation'];
     //是否过滤
     $is_open = $set['state'];
     //评论开启关闭
     $rate = $set['rate'];
     //评论频率限制
     $allow_reply = $set['allow_reply'];
     //回复设置
     $verify_mode = $set['verify_mode'];
     //验证码
     $is_credits = $set['is_credits'];
     //未审核获取积分
     $is_credits_extra = $set['is_credits_extra'];
     //审核获取积分
     $is_diy_credits = $set['is_diy_credits'];
     //自定义积分规则
     $same_user_same_record = $set['same_user_same_record'];
     //评论功能开启/关闭
     if (!$is_open) {
         $this->errorOutput(MESSAGECLOSED);
     }
     $fid = intval($this->input['fid']);
     if ($fid && !$allow_reply) {
         $this->errorOutput(REPLYCLOSED);
     }
     //登陆评论
     if ($login) {
         if ($this->user['user_id'] < 1) {
             $this->errorOutput(NOTLOGIN);
         }
     }
     if ($max_word) {
         //评论长度判断
         $len = '';
         $len = strlen($content);
         if ($len > $max_word * 3) {
             $this->errorOutput(MAXNUM);
         }
     }
     //审核显示
     $state = $display ? 0 : 1;
     if ($app_id = $this->input['app_id']) {
         $appconfig = $this->appconfig->detail($app_id);
         if ($appconfig['comment_audit'] == 0) {
             $state = 1;
         } else {
             $state = 0;
         }
     }
     //过滤敏感词
     if ($colation && $this->settings['App_banword']) {
         include_once ROOT_PATH . 'lib/class/banword.class.php';
         $this->banword = new banword();
         $banword = $this->banword->exists($content);
         if ($banword) {
             $colation_state = '';
             if ($colation == 1) {
                 $this->errorOutput(BANWORD);
             } elseif ($colation == 2) {
                 $colation_state = 3;
             } elseif ($colation == 3) {
                 $content = $this->banword->replace($content, '*');
                 $colation_state = 0;
                 //替换后状态为未审核
             }
             //如果存在敏感词,敏感词的设置高于普通设置
             if ($colation_state) {
                 $state = $colation_state;
             }
             //记录敏感词
             $banwords = array();
             foreach ($banword as $v) {
                 $banwords[] = $v['banname'];
             }
             $banwords = implode(',', $banwords);
         }
     }
     //验证码开启并且安装验证码
     if ($this->settings['App_verifycode'] && $verify_mode) {
         if (!$this->input['not_need_verifycode']) {
             include_once ROOT_PATH . 'lib/class/verifycode.class.php';
             $this->mVerifyCode = new verifycode();
             $verifycode = trim($this->input['verify_code']);
             $session_id = trim($this->input['session_id']);
             if (!$verifycode || !$session_id) {
                 $this->errorOutput(VERIFY);
             }
             $check_result = $this->mVerifyCode->check_verify_code($verifycode, $session_id);
             //验证验证码
             if ($check_result != 'SUCCESS') {
                 $data['error'] = $check_result;
                 $this->addItem($data);
                 $this->output();
             }
         }
     }
     //兼容user_name传递用户昵称
     if ($this->input['user_name'] && !$this->input['author']) {
         $this->input['author'] = $this->input['user_name'];
     }
     $data = array('title' => urldecode($this->input['title']), 'username' => $this->user['user_name'], 'author' => trim($this->input['author']), 'member_id' => $this->user['user_id'], 'content' => $content, 'pub_time' => TIMENOW, 'ip' => hg_getip(), 'state' => $state, 'contentid' => $contentid, 'content_title' => $this->input['content_title'], 'content_url' => $this->input['content_url'], 'cmid' => $cmid, 'app_uniqueid' => $this->input['app_uniqueid'], 'mod_uniqueid' => $this->input['mod_uniqueid'], 'site_id' => $this->input['site_id'], 'column_id' => $this->input['column_id'], 'appid' => $this->user['appid'], 'appname' => $this->user['display_name'], 'long' => $this->input['long'], 'lati' => $this->input['lati'], 'banword' => $banwords, 'fid' => $fid, 'member_type' => intval($this->input['member_type']), 'groupid' => intval($this->input['groupid']), 'baidu_longitude' => $this->input['baidu_longitude'], 'baidu_latitude' => $this->input['baidu_latitude'], 'address' => $this->input['address']);
     //获取ip的地域信息
     if (function_exists('hg_getIpInfo')) {
         $data['ip_info'] = hg_getIpInfo($data['ip']);
     }
     //入库
     $mes = new Message();
     $res = $mes->add_message($data, $rate);
     if (!$res) {
         $this->errorOutput(RATE);
     }
     $res['pub_time'] = date('Y-m-d H:i:s', $res['pub_time']);
     /***********************调用积分规则,给已审核评论增加积分START*****************/
     if ($this->input['iscreditsrule']) {
         include ROOT_PATH . 'lib/class/members.class.php';
         $Members = new members();
         if ($this->settings['App_members']) {
             if ($res['member_id'] && $same_user_same_record) {
                 $res_total = $mes->return_count(" AND contentid=" . $res['contentid'] . " AND cmid = " . $res['cmid'] . " AND app_uniqueid = '" . $res['app_uniqueid'] . "' AND mod_uniqueid = '" . $res['mod_uniqueid'] . "' AND member_id=" . $res['member_id'], $tableName);
             }
             if ($res_total['total'] - 1 < $same_user_same_record || empty($same_user_same_record)) {
                 $Members->Initoperation();
                 //初始化
                 $Members->Setoperation(APP_UNIQUEID);
                 /***未审核增加积分**/
                 if ($is_credits && $this->user['user_id']) {
                     $credit_rules = $Members->get_credit_rules($this->user['user_id'], $data['app_uniqueid'], $data['mod_uniqueid'], $data['column_id'], $data['contentid']);
                 }
                 /***审核增加积分**/
                 if ($is_credits_extra && $res['state'] == 1 && $this->user['user_id']) {
                     $Members->Initoperation();
                     //初始化
                     $Members->Setoperation(APP_UNIQUEID, '', '', 'extra');
                     $credit_rules_extra = $Members->get_credit_rules($this->user['user_id'], $data['app_uniqueid'], $data['mod_uniqueid'], $data['column_id'], $data['contentid']);
                     $field = 'is_credits=0';
                     //已经增加积分
                 } elseif (empty($is_credits_extra)) {
                     $field = 'is_credits=-1';
                     //禁止增加积分,因为未开启审核增加积分,所以即使审核也不增加
                 }
             } else {
                 $field = 'is_credits=-1';
                 //禁止增加积分,此会员此条记录评论超过限制次数
             }
         }
         /**积分文案处理**/
         $credit_copy = array();
         if ($credit_rules['updatecredit']) {
             $credit_copy[] = $credit_rules;
         }
         if ($credit_rules_extra['updatecredit']) {
             $credit_copy[] = $credit_rules_extra;
         }
         $res['copywriting_credit'] = $Members->copywriting_credit($credit_copy);
         /**积分文案处理结束**/
     } else {
         $field = 'is_credits=-1';
         //禁止增加积分,非新会员
     }
     /**更新获得积分字段**/
     if ($field) {
         $this->db->query("UPDATE " . DB_PREFIX . "{$res['tableame']} SET " . $field . " WHERE id=" . $res['id']);
     }
     /***********************调用积分规则,给已审核评论增加积分END*****************/
     //已审核状态
     if ($res['state'] == 1) {
         /***********************即时更新内容评论计数****************************/
         if ($this->settings['App_' . $data['app_uniqueid']]) {
             $path['host'] = $this->settings['App_' . $data['app_uniqueid']]['host'];
             $path['dir'] = $this->settings['App_' . $data['app_uniqueid']]['dir'] . 'admin/';
             if ($path) {
                 $host = $path['host'];
                 $dir = $path['dir'];
                 $filename = $data['app_uniqueid'];
                 if ($filename == 'livmedia') {
                     $filename = 'vod';
                 } else {
                     if ($filename == 'cheapbuy') {
                         $filename = 'product';
                     }
                 }
                 include_once ROOT_PATH . 'lib/class/curl.class.php';
                 $curl = new curl($host, $dir);
                 $curl->setSubmitType('post');
                 $curl->initPostData();
                 $curl->addRequestData('a', 'update_comment_count');
                 $curl->addRequestData('id', $data['contentid']);
                 $curl->addRequestData('type', 'audit');
                 $curl->request($filename . '_update.php');
             }
         }
         /***********************即时更新内容评论计数****************************/
         /***********************更新会员我的评论计数****************************/
         if ($this->settings['App_members']) {
             $path['host'] = $this->settings['App_members']['host'];
             $path['dir'] = $this->settings['App_members']['dir'];
             if ($path) {
                 include_once ROOT_PATH . 'lib/class/curl.class.php';
                 $curl = new curl($path['host'], $path['dir']);
                 $curl->setSubmitType('post');
                 $curl->initPostData();
                 $curl->addRequestData('a', 'create');
                 $curl->addRequestData('mark', 'mymessage');
                 $curl->addRequestData('totalsum', 1);
                 $curl->addRequestData('summath', 1);
                 $curl->addRequestData('access_token', $this->user['token']);
                 $curl->request('member_my_update.php');
             }
         }
         /***********************更新会员我的评论计数****************************/
     }
     //统计app下面的评论计数
     if ($data['appid']) {
         $sql = "SELECT appid FROM " . DB_PREFIX . "message_appinfo WHERE appid = " . $data['appid'];
         if ($this->db->query_first($sql)) {
             $sql = "UPDATE " . DB_PREFIX . "message_appinfo SET appname='" . $data['appname'] . "',comment_num = comment_num+1 WHERE appid=" . $data['appid'];
         } else {
             $sql = "INSERT INTO " . DB_PREFIX . "message_appinfo SET appid=" . $data['appid'] . ",appname='" . $data['appname'] . "',comment_num=comment_num+1";
         }
         $this->db->query($sql);
     }
     $res['copywriting'] = '评论成功';
     $this->addItem($res);
     $this->output();
 }
 function render_for_ajax()
 {
     $op = $this->params["op"];
     if ($op != 'paging' && empty(PA::$login_user)) {
         return __("Login required");
     }
     switch ($op) {
         case "send_message":
             // actual message sending
             do {
                 require_once PA::$path . "/web/includes/videoplay/common.php";
                 // videoplay-specific stuff
                 // TODO find a more compatoble way to generalize this from videoplay!
                 $subject = trim(strip_tags($this->params["subject"]));
                 if (empty($subject)) {
                     $this->err = "Please give your message a subject.";
                     break;
                 }
                 $body = trim($this->params["body"]);
                 if (empty($body)) {
                     $this->err = "Please enter a message!";
                     break;
                 }
                 $all_recipients = $this->params["recipients"];
                 if (empty($all_recipients)) {
                     $this->err = "The message has no recipiets!";
                     break;
                 }
                 $login_names = preg_split("/,\\s*/", $all_recipients);
                 $found = array();
                 // user id of all the valid login names
                 $valid_recipients = array();
                 // login name of all the valid login names.
                 $invalid_recipients = array();
                 // names of all the invalid recipients.
                 foreach ($login_names as $login_name) {
                     try {
                         $u = new User();
                         $u->load($login_name);
                         $valid_recipients[$u->user_id] = $u;
                         $valid_recipients['login_names'] = $u->login_name;
                         $valid_recipients['fnames'][] = $u->first_name;
                         $valid_recipients['emails'][] = $u->email;
                     } catch (PAException $e) {
                         $invalid_recipients[] = $login_name;
                     }
                 }
                 $in_reply_to = (int) $this->params['reply_to'] ? (int) $this->params['reply_to'] : 0;
                 $is_draft = FALSE;
                 // validation done - now save the comment
                 $sender_id = PA::$login_user->user_id;
                 if (count($valid_recipients)) {
                     $is_draft = FALSE;
                     // TODO: ensure that we can handle multiple recipients!
                     Message::add_message($sender_id, $valid_recipients['ids'], $valid_recipients['login_names'], $subject, $body, $is_draft, $in_reply_to);
                     // this is to ALSO send out emails
                     for ($counter = 0; $counter < count($valid_recipients['ids']); $counter++) {
                         $params = array('first_name_sender' => PA::$login_user->first_name, 'first_name_recipient' => $valid_recipients['fname'][$counter], 'sender_id' => $sender_id, 'recipient_id' => $valid_recipients['ids'][$counter], 'recipient_email' => $valid_recipients['emails'][$counter], 'sender_url' => url_for('user_blog', array('login' => PA::$login_user->login_name)), 'my_messages_url' => PA::$url . '/' . FILE_MYMESSAGE);
                         auto_email_notification('msg_waiting', $params);
                     }
                     $this->mode = "view_conversations";
                     unset($this->params['view']);
                     $this->note = __("Message sent - thank you for participating!");
                 }
                 $this->send_success = $valid_recipients;
                 $this->send_fail = $invalid_recipients;
                 if (count($invalid_recipients)) {
                     $this->err = __("Couldn't send message, some recipients are not valid.") . implode(', ', $invalid_recipients);
                     break;
                 }
             } while (0);
             break;
         default:
             // just ignore any others
             break;
     }
     return $this->render();
 }
function switch_destination($destination)
{
    global $to, $mail_type, $mail_sub_msg_array, $from, $no_id, $network_owner, $subject, $message, $config_site_name;
    // these should be instance vars, not globals!
    $no_id = "";
    if (empty($mail_type)) {
        $mail_type = '';
        //none
    }
    // checking whether subject or message is set or not
    $msg_data = EmailMessages::get($mail_type, $mail_sub_msg_array);
    $subject = $msg_data['subject'];
    $message = $msg_data['message'];
    if (empty($subject)) {
        $subject = 'none';
    }
    if (empty($message)) {
        $message = 'Message for internal mail is under construction. <br /><br /> We\'ll back with appropriate message soon!!!';
    }
    if ($mail_type == 'friend_request') {
        $mail_from = $_SESSION['user']['email'];
    }
    switch ($destination) {
        case NET_EMAIL:
            //external mail
            $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from);
            break;
        case NET_MSG:
            //internal messageing
            Message::add_message($from, $no_id, $network_owner, $subject, $message);
            $sender = new User();
            $sender->load((int) $from);
            $sender_id = $sender->user_id;
            $sender_name = $sender->login_name;
            $recipient_id = User::map_logins_to_ids($network_owner);
            $sender_url = url_for('user_blog', array('login' => $sender->login_name));
            $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE;
            $recipient_obj = new User();
            foreach ($recipient_id as $key => $value) {
                $recipient_obj->load((int) $value);
            }
            // send msg waiting blink message
            $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name);
            auto_email_notification('msg_waiting', $params);
            break;
        case NET_BOTH:
            // via both option
            // FIXME: $mail_from seems not be set on peepagg
            $check = pa_mail($to, $mail_type, $mail_sub_msg_array, @$mail_from);
            Message::add_message($from, $no_id, $network_owner, $subject, $message);
            $sender = new User();
            $sender->load((int) $from);
            $sender_id = $sender->user_id;
            $sender_name = $sender->login_name;
            $recipient_id = User::map_logins_to_ids($network_owner);
            $sender_url = url_for('user_blog', array('login' => $sender->login_name));
            $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE;
            $recipient_obj = new User();
            foreach ($recipient_id as $key => $value) {
                $recipient_obj->load((int) $value);
            }
            // send msg waiting blink message
            $params = array('first_name_sender' => $sender_name, 'first_name_recipient' => $recipient_obj->first_name, 'sender_id' => $sender_id, 'recipient_id' => $recipient_obj->user_id, 'recipient_email' => $recipient_obj->email, 'sender_url' => $sender_url, 'my_messages_url' => $my_messages_url, 'config_site_name' => $config_site_name);
            auto_email_notification('msg_waiting', $params);
            break;
    }
}
 $mail_message = $subject . '<br /><br />' . $message;
 $array_of_data = array('user_id' => $user->user_id, 'subject' => $mail_subject, 'message' => $mail_message, 'owner_image' => $owner_image, 'user_name' => $user->first_name, 'config_site_name' => $config_site_name);
 if (!empty($_POST['inbox'])) {
     // posting the bulletin to Inbox
     $count_user = $to_member['total_users'];
     $multiple_recipient = "";
     for ($counter = 0; $counter < $count_user; $counter++) {
         $to_uid = $to_member['users_data'][$counter]['user_id'];
         $to_name = $to_member['users_data'][$counter]['login_name'];
         $user_profile = User::load_user_profile($to_uid, $to_uid, 'notifications');
         if (!empty($user_profile)) {
             $notify = unserialize($user_profile[0]['value']);
             $destination = $notify['bulletin_sent']['value'];
             if ($destination == NET_MSG || $destination == NET_BOTH) {
                 try {
                     Message::add_message($from, $multiple_recipient, $to_name, $subject, $message);
                 } catch (PAException $e) {
                     // catch Nothing
                     // This block of code is added, so that if folder isn't exist for
                     // a user, then it skipped that user
                     // and continue to send bulletin to other users.
                 }
                 $my_messages_url = PA::$url . '/' . FILE_MYMESSAGE;
                 $sender_url = url_for('user_blog', array('login' => $user->login_name));
                 $params = array('first_name_sender' => $user->first_name, 'first_name_recipient' => $to_member['users_data'][$counter]['first_name'], 'sender_id' => $user->user_id, 'recipient_id' => $to_uid, 'recipient_email' => $to_member['users_data'][$counter]['email'], 'my_messages_url' => $my_messages_url, 'sender_url' => $sender_url, 'config_site_name' => $config_site_name);
                 auto_email_notification('msg_waiting', $params);
             }
         }
     }
 }
 if (!empty($_POST['mail'])) {
 private function send_approval_message_to_user($uid, $gid, $approved)
 {
     $site_name = PA::$site_name;
     $user = new User();
     $user->load((int) $uid);
     $group = Group::load_group_by_id((int) $gid);
     $group_owner_id = Group::get_owner_id((int) $gid);
     $group_owner = new User();
     $group_owner->load((int) $group_owner_id['user_id']);
     $group_name = $group->title;
     $network_name = PA::$network_info->name;
     $group_member_count = Group::get_member_count((int) $gid);
     $group_owner_name = $group_owner->login_name;
     $group_joinee = $user->login_name;
     $group_url = '<a href="' . PA::$url . PA_ROUTE_GROUP . '/gid=' . $gid . '">' . $group->title . '</a>';
     $approved_msg = $approved ? 'has approved' : 'has not approved';
     $subject = "{$group_owner_name} {$approved_msg} your request to join the \"{$group_name}\" Group";
     $msg = "\n          <br />Dear {$group_joinee},\n          <br />\n          <br />\n          <b>{$group_owner_name}</b> {$approved_msg} your request to join the \"{$group_name}\" Group on the \"{$network_name}\" network.\n          <br />\n          To view the \"{$group_name}\" Group, click on the following link: {$group_url}\n          <br />\n          There are now {$group_member_count} members in the \"{$group_name}\" Group.\n          <br />\n          Thanks,\n          The {$site_name} Team\n          <br />\n          <p>\n          Everyone at {$site_name} respects your privacy. Your information will\n          never be shared with third parties unless specifically requested by you.\n          <p/>";
     Message::add_message((int) $group_owner_id['user_id'], null, $group_joinee, $subject, $msg);
     simple_pa_mail($user->email, $subject, $msg);
     return;
 }
function peopleaggregator_sendMessage($args)
{
    $user = User::from_auth_token($args['authToken']);
    $recipients = $args['recipients'];
    $subject = $args['title'];
    $body = $args['content'];
    // actually send the message
    Message::add_message($user->user_id, NULL, $recipients, $subject, $body);
    return array('success' => TRUE);
}
Exemplo n.º 10
0
/**
   function is added for sending the mail of Abuse report 
   parameter required - sender name, subject of mail, message ..
*/
function send_message_to_user($user_name, $suject = null, $mail_sub_msg_array)
{
    // Adding the message for newtork owner
    global $network_info, $login_uid;
    $network_name = $network_info->name;
    $report_name = $_SESSION['user']['name'];
    $config_site_name = PA::$site_name;
    $message = $mail_sub_msg_array['message'];
    $content_url = '<a href="' . $mail_sub_msg_array['content_url'] . '">' . $mail_sub_msg_array['content_url'] . '</a>';
    $delete_url = '<a href="' . $mail_sub_msg_array['delete_url'] . '">' . $mail_sub_msg_array['delete_url'] . '</a>';
    if (empty($suject)) {
        $subject = " {$config_site_name} {$report_name} has reported an abuse about some content in your network {$network_name}";
    }
    $msg = "<br>\n      {$report_name} has reported an abuse about some comment in your network {$network_name}.<br>\n      <br>\n      {$report_name} reported:<br> {$message}\n      <br>\n      Click Here {$content_url} to view that comment as well as content.\n      <br>\n      <br>\n      Click here {$delete_url} to delete that comment.\n      <br>\n      <br>\n      Thanks<br>";
    Message::add_message((int) $login_uid, null, $user_name, $subject, $msg);
    return;
}
 /** !!
  * Takes the data submitted in the form and gets all of the useful data
  * necessary to send a message.  It takes the name that is being sent to and 
  * gets the id, email, and other assorted data.  It then sends the message and
  * tells the user what the outcome of that process is. It also makes sure the
  *  message is within the correct length.
  *
  *  @param array $request_data  The data to be operated on.
  */
 public function handlePOSTPageSubmit($request_data)
 {
     $error = false;
     if (!empty($request_data)) {
         if (isset($request_data['send'])) {
             $message = NULL;
             filter_all_post($request_data, TRUE);
             // applying input filter to the post data, this function is define in function.php
             $subject = $request_data['subject'];
             $body = $request_data['body'];
             $in_reply_to = $request_data['in_reply_to'];
             if (empty($request_data['to'])) {
                 $message = 8003;
                 $error = true;
             }
             if (strlen($body) > MAX_MESSAGE_LENGTH) {
                 $message = 8002;
                 $error = true;
             }
             if (!$error) {
                 if (empty($subject)) {
                     $subject = '[none]';
                 }
                 $login_names = preg_split("/,\\s*/", $request_data['to']);
                 $valid_recipients = array();
                 //login name of all the valid login names.
                 $invalid_recipients = array();
                 // names of all the invalid recipients.
                 foreach ($login_names as $login_name) {
                     try {
                         $User = new User();
                         $User->load($login_name);
                         $valid_recipients['id'][] = $User->user_id;
                         $valid_recipients['name'][] = $User->login_name;
                         $valid_recipients['display_name'][] = $User->display_name;
                         $valid_recipients['fname'][] = $User->first_name;
                         $valid_recipients['email'][] = $User->email;
                         $valid_recipients['user'][] = $User;
                         $notif_settings = null;
                         $recipient_profile = User::load_user_profile($User->user_id, $User->user_id, 'notifications');
                         if (!empty($recipient_profile)) {
                             $notif_settings = unserialize($recipient_profile[0]['value']);
                         }
                         $valid_recipients['notifications'][] = $notif_settings;
                     } catch (PAException $e) {
                         $invalid_recipients[] = $login_name;
                     }
                 }
                 $message = null;
                 if (count($valid_recipients)) {
                     $is_draft = FALSE;
                     // actually 'send' the message
                     Message::add_message(PA::$login_uid, $valid_recipients['id'], $valid_recipients['name'], $subject, $body, $is_draft, $in_reply_to);
                     // handle 'also send to email' and 'message_waiting_blink'
                     $valid_recipients_count = count($valid_recipients['id']);
                     for ($counter = 0; $counter < $valid_recipients_count; $counter++) {
                         if (!empty($valid_recipients['notifications'][$counter])) {
                             $rec_notif_settings = $valid_recipients['notifications'][$counter];
                             $as_email = false;
                             if (!empty($rec_notif_settings['user_send_message']['value'])) {
                                 switch ($rec_notif_settings['user_send_message']['value']) {
                                     case NET_EMAIL:
                                     case NET_BOTH:
                                         $as_email = true;
                                         PAMail::send("user_send_message", $valid_recipients['user'][$counter], PA::$login_user, array('subject' => $subject, 'message' => $body));
                                         break;
                                     default:
                                         break;
                                 }
                             }
                             // if they are not getting it in email already
                             if (empty($as_email) && !empty($rec_notif_settings['msg_waiting_blink']) && $rec_notif_settings['msg_waiting_blink'] == NET_EMAIL) {
                                 PAMail::send("msg_waiting_blink", $valid_recipients['email'][$counter], PA::$login_user, array());
                             }
                         }
                     }
                     $message = sprintf(__("Message sent successfully to %s"), implode(", ", $valid_recipients['display_name']));
                 }
                 if (count($invalid_recipients)) {
                     //some of the recipients are invalid. So displaying the error message for them.
                     $message .= sprintf(__("Message sending failed for %s  as user(s) doesn't exist"), implode(", ", $invalid_recipients));
                     $error = true;
                 } else {
                     // message sent successfully to all the recipients. Redirecting user to inbox
                     header('Location: ' . PA::$url . PA_ROUTE_MYMESSAGE . "/msg={$message}");
                     exit;
                 }
             }
             if (!empty($message)) {
                 $msg_array = array();
                 $msg_array['failure_msg'] = $message;
                 $msg_array['success_msg'] = NULL;
                 $redirect_url = NULL;
                 $query_str = NULL;
                 set_web_variables($msg_array, $redirect_url, $query_str);
             }
         }
     }
 }
Exemplo n.º 12
0
 function create()
 {
     //评论内容
     if (!$this->input['content']) {
         $this->errorOutput('请输入内容');
     }
     //评论类型  0是对发布库内容评论 1是对栏目评论
     $com_type = intval($this->input['com_type']);
     $cmid = intval($this->input['cmid']);
     if (!$cmid) {
         $this->errorOutput('请输入内容id');
     }
     $mes = new Message();
     //针对发布库内容评论
     if (!$com_type) {
         //被评论内容发布库中的id
         $mes->get_publish_content($cmid);
     } else {
         if ($com_type == 1) {
             $this->input['content_id'] = $cmid;
             $cmid = 0;
             $this->input['app_uniqueid'] = 'column';
             $this->input['mod_uniqueid'] = 'column';
         }
     }
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     /*if($this->input['groupid'] && $this->user['group_type'] >= MAX_ADMIN_TYPE)
     	 {
     		$sql = 'SELECT id, parents FROM '.DB_PREFIX.'message_node WHERE id IN('.$this->input['groupid'].')';
     		$query = $this->db->query($sql);
     		while($row = $this->db->fetch_array($query))
     		{
     		$nodes['nodes']['message_sort'][$row['id']] = $row['parents'];
     		}
     		}
     		else
     		{
     		$nodes = array('nodes'=>array('message_sort'=>array(0=>0)));
     		}
     		$this->verify_content_prms($nodes);*/
     #####节点权限认证需要将节点数据放在nodes=>标志=>节点id=>节点所有父级节点
     /********创建数据上限判断**********/
     $create_data_limit = $this->user['prms']['default_setting']['create_data_limit'];
     if ($create_data_limit) {
         $sql = "SELECT count(*) FROM " . DB_PREFIX . "message WHERE userid = " . $this->user['user_id'];
         $count = $this->db->query_first($sql);
         if ($count['count'] > $create_data_limit) {
             $this->errorOutput('您只能添加' . $create_data_limit . '条数据');
         }
     }
     $data = array('title' => $this->input['title'], 'author' => $this->input['username'], 'username' => $this->user['user_name'], 'userid' => $this->user['user_id'], 'member_id' => $this->input['member_id'], 'org_id' => $this->user['org_id'], 'content' => trim($this->input['content']), 'pub_time' => TIMENOW, 'ip' => hg_getip(), 'groupid' => $this->input['groupid'], 'site_id' => $this->input['site_id'], 'column_id' => $this->input['column_id'], 'contentid' => $this->input['content_id'], 'cmid' => $cmid, 'app_uniqueid' => $this->input['app_uniqueid'], 'mod_uniqueid' => $this->input['mod_uniqueid'], 'state' => $this->get_status_setting('create'), 'content_title' => $this->input['content_title'], 'content_url' => $this->input['content_url']);
     $res = $mes->add_message($data);
     if ($res) {
         //更新内容评论计数,除了栏目评论
         if ($res['app_uniqueid'] && $res['app_uniqueid'] != 'column' && $res['state'] == 1) {
             $this->update_comment_count($res['id'], 'audit', $res['tableame']);
         }
         $this->addLogs('添加评论', '', $res, '添加评论' . $res['id']);
         $this->addItem($res);
     }
     $this->output();
 }