示例#1
0
文件: update.php 项目: sany217/WeiXin
    if ($SMS_REMIND1 == "on" && $USER_ID_STR != "") {
        send_sms($SEND_TIME, $_SESSION['LOGIN_USER_ID'], $USER_ID_STR, 1, $SMS_CONTENT, $REMIND_URL);
    }
    if ($SMS2_REMIND1 == "on") {
        $SMS_CONTENT = sprintf(_("OA公告,来自%s标题:%s"), $USER_NAME, $SUBJECT);
        if ($SUMMARY) {
            $SMS_CONTENT .= _("内容简介:") . $SUMMARY;
        }
        if ($USER_ID_STR != "") {
            send_mobile_sms_user($SEND_TIME, $_SESSION['LOGIN_USER_ID'], $USER_ID_STR, $SMS_CONTENT, 1);
        }
    }
    include_once "inc/itask/itask.php";
    mobile_push_notification(userid2uid($USER_ID_STR), $_SESSION['LOGIN_USER_NAME'] . _(":") . _("请查看公告通知") . _("标题:") . csubstr($SUBJECT, 0, 20), "notify");
    $WX_OPTIONS = array("module" => "notify", "module_action" => "notify.read", "user" => $USER_ID_STR, "content" => $_SESSION['LOGIN_USER_NAME'] . _(":") . _("请查看公告通知") . _("标题:") . csubstr($SUBJECT, 0, 20), "params" => array("NOTIFY_ID" => $NOTIFY_ID));
    wxqy_sms($WX_OPTIONS);
}
if ($PUBLISH == "2") {
    $SMS_CONTENT = _("请审批公告通知!") . "\n" . _("标题:") . csubstr($SUBJECT, 0, 100);
    if (compare_date($BEGIN_DATE1, $CUR_DATE) == 1) {
        $SEND_TIME = $BEGIN_DATE1;
    }
    $REMIND_URL = "1:notify/auditing/unaudited.php";
    if ($SMS_REMIND == "on" && $AUDITER != "" && $AUDITER != $_SESSION['LOGIN_USER_ID']) {
        send_sms($SEND_TIME, $_SESSION['LOGIN_USER_ID'], $AUDITER, 1, $SMS_CONTENT, $REMIND_URL);
    }
    if ($SMS2_REMIND == "on") {
        $SMS_CONTENT = sprintf(_("请审批OA公告,来自%s"), $_SESSION['LOGIN_USER_NAME'] . ":" . $SUBJECT);
        if ($SUMMARY) {
            $SMS_CONTENT .= _("内容简介:") . $SUMMARY;
        }
示例#2
0
文件: itask.php 项目: sany217/WeiXin
function mobile_push_notification($uid_sent, $content, $module, $options = NULL)
{
    $org_content = $content;
    $PARA_ARRAY = get_sys_para("MOBILE_PUSH_OPTION,PCONLINE_MOBILE_PUSH", FALSE);
    while (list($PARA_NAME, $PARA_VALUE) = each(&$PARA_ARRAY)) {
        ${$PARA_NAME} = $PARA_VALUE;
    }
    if ($MOBILE_PUSH_OPTION == "1") {
        if ($uid_sent == "") {
            return;
        }
        if (substr($uid_sent, -1) != ",") {
            $uid_sent .= ",";
        }
        $module = strtolower($module);
        $mp_to_uids = td_trim($uid_sent);
        $a_uid_sent = $a_unpush_uid = array();
        $a_uid_sent = explode(",", $mp_to_uids);
        if ($PCONLINE_MOBILE_PUSH == "0") {
            $query = "select DISTINCT(UID) from user_online where UID in(" . $mp_to_uids . ") and CLIENT!=5 and CLIENT!=6";
            $cursor = exequery(TD::conn(), $query);
            while ($ROW = mysql_fetch_array($cursor)) {
                $a_unpush_uid[] = $ROW['UID'];
            }
            foreach ($a_uid_sent as $k => $v) {
                if (!($PCONLINE_MOBILE_PUSH == "0") && !is_array($a_unpush_uid) && !in_array($v, $a_unpush_uid)) {
                    unset($a_uid_sent[$k]);
                }
            }
            $a_uid_sent = array_filter($a_uid_sent);
            $uid_sent = implode(",", $a_uid_sent);
            $uid_sent .= ",";
        }
        if ($module == "message") {
            include_once "task/message_push/funcs.php";
            $C_MOBILE_DEVICES = TD::get_cache("C_MOBILE_DEVICES");
            if ($C_MOBILE_DEVICES === FALSE) {
                rebuildmobilecache();
                $C_MOBILE_DEVICES = TD::get_cache("C_MOBILE_DEVICES");
            }
            if ($C_MOBILE_DEVICES && 0 < count($C_MOBILE_DEVICES)) {
                $M_STA = $M_ENT = array();
                foreach ($a_uid_sent as $k => $v) {
                    if ($C_MOBILE_DEVICES[$v]) {
                        if ($C_MOBILE_DEVICES[$v]['client_ver'] == 1) {
                            $M_STA[$v][] = array("content" => $content, "module" => "message");
                        } else {
                            if ($C_MOBILE_DEVICES[$v]['client_ver'] == 2) {
                                $M_ENT[$v][] = array("content" => $content, "module" => "message");
                            }
                        }
                    }
                }
            }
            tdmobilepush(array("sta" => $M_STA, "ent" => $M_ENT));
        }
        $content = $org_content = strip_tags($content);
        if (strtolower(MYOA_CHARSET) != "utf-8") {
            $content = td_iconv($content, MYOA_CHARSET, "UTF-8");
        }
        imtask("C^m^n^" . $uid_sent . "^" . $module . "^" . $content);
        if (!$MYOA_WEIXINQY_PUSH_ACTIVE) {
            $useble_module = array("email", "news", "notify");
            if (!in_array($module, $useble_module)) {
                $uid_sents = td_trim($uid_sent);
                $query = "SELECT USER_ID FROM USER WHERE UID IN (" . $uid_sents . ")";
                $cursor = exequery(TD::conn(), $query);
                while ($ROW = mysql_fetch_array($cursor)) {
                    $user_id_arr[] = $ROW['USER_ID'];
                }
                wxqy_sms(array("user" => $user_id_arr, "module" => $module, "content" => $org_content));
            }
        }
    }
}