コード例 #1
0
 public static function notification_add($username, $touid, $type, $note, $uid, $notevars = array(), $system = 0)
 {
     global $_G;
     if (!($tospace = getuserbyuid($touid))) {
         return false;
     }
     space_merge($tospace, 'field_home');
     $filter = empty($tospace['privacy']['filter_note']) ? array() : array_keys($tospace['privacy']['filter_note']);
     if ($filter && (in_array($type . '|0', $filter) || in_array($type . '|' . $_G['uid'], $filter))) {
         return false;
     }
     $notevars['actor'] = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">" . $username . "</a>";
     if (!is_numeric($type)) {
         $vars = explode(':', $note);
         if (count($vars) == 2) {
             $notestring = lang('plugin/' . $vars[0], $vars[1], $notevars);
         } else {
             $notestring = lang('notification', $note, $notevars);
         }
         $frommyapp = false;
     } else {
         $frommyapp = true;
         $notestring = $note;
     }
     $oldnote = array();
     if ($notevars['from_id'] && $notevars['from_idtype']) {
         $oldnote = C::t('home_notification')->fetch_by_fromid_uid($notevars['from_id'], $notevars['from_idtype'], $touid);
     }
     if (empty($oldnote['from_num'])) {
         $oldnote['from_num'] = 0;
     }
     $notevars['from_num'] = $notevars['from_num'] ? $notevars['from_num'] : 1;
     $setarr = array('uid' => $touid, 'type' => $type, 'new' => 1, 'authorid' => $uid, 'author' => $username, 'note' => $notestring, 'dateline' => $_G['timestamp'], 'from_id' => $notevars['from_id'], 'from_idtype' => $notevars['from_idtype'], 'from_num' => $oldnote['from_num'] + $notevars['from_num']);
     if ($system) {
         $setarr['authorid'] = 0;
         $setarr['author'] = '';
     }
     $pkId = 0;
     if ($oldnote['id']) {
         C::t('home_notification')->update($oldnote['id'], $setarr);
         $pkId = $oldnote['id'];
     } else {
         $oldnote['new'] = 0;
         $pkId = C::t('home_notification')->insert($setarr, true);
     }
     $banType = array('task');
     if ($_G['setting']['cloud_status'] && !in_array($type, $banType)) {
         $noticeService = Cloud::loadClass('Service_Client_Notification');
         if ($oldnote['id']) {
             $noticeService->update($touid, $pkId, $setarr['from_num'], $setarr['dateline']);
         } else {
             $extra = $type == 'post' ? array('pId' => $notevars['pid']) : array();
             $noticeService->add($touid, $pkId, $type, $setarr['authorid'], $setarr['author'], $setarr['from_id'], $setarr['from_idtype'], $setarr['note'], $setarr['from_num'], $setarr['dateline'], $extra);
         }
     }
     if (empty($oldnote['new'])) {
         C::t('common_member')->increase($touid, array('newprompt' => 1));
         require_once libfile('function/mail');
         $mail_subject = lang('notification', 'mail_to_user');
         sendmail_touser($touid, $mail_subject, $notestring, $frommyapp ? 'myapp' : $type);
     }
     if (!$system && $_G['uid'] && $touid != $_G['uid']) {
         C::t('home_friend')->update_num_by_uid_fuid(1, $_G['uid'], $touid);
     }
 }
コード例 #2
0
 private function _userFriendSetting($res, $uid, $gid, $note)
 {
     global $_G;
     require_once libfile('function/friend');
     require_once libfile('function/spacecp');
     require_once libfile('function/home');
     if (!checkperm('allowfriend')) {
         return $this->makeErrorInfo($res, 'no_privilege_addfriend');
     }
     if ($uid == $_G['uid']) {
         return $this->makeErrorInfo($res, 'friend_self_error');
     }
     if (friend_check($uid)) {
         return $this->makeErrorInfo($res, 'you_have_friends');
     }
     $tospace = getuserbyuid($uid);
     if (empty($tospace)) {
         return $this->makeErrorInfo($res, 'space_does_not_exist');
     }
     if (isblacklist($tospace['uid'])) {
         return $this->makeErrorInfo($res, 'is_blacklist');
     }
     // $res['body']['gidInfo'] = $this->_getFriendGroupList();
     space_merge($space, 'count');
     space_merge($space, 'field_home');
     $maxfriendnum = checkperm('maxfriendnum');
     if ($maxfriendnum && $space['friends'] >= $maxfriendnum + $space['addfriend']) {
         if ($_G['magic']['friendnum']) {
             return $this->makeErrorInfo($res, 'enough_of_the_number_of_friends_with_magic');
         } else {
             return $this->makeErrorInfo($res, 'enough_of_the_number_of_friends');
         }
     }
     if (friend_request_check($uid)) {
         // if(submitcheck('add2submit')) {
         $_POST['gid'] = intval($gid);
         friend_add($uid, $uid);
         if (ckprivacy('friend', 'feed')) {
             require_once libfile('function/feed');
             feed_add('friend', 'feed_friend_title', array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>"));
         }
         notification_add($uid, 'friend', 'friend_add');
         // showmessage('friends_add', dreferer(), array('username' => $tospace['username'], 'uid'=>$uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true));
         return $this->makeErrorInfo($res, 'friends_add', array('{username}' => $tospace['username']));
         // }
         // $op = 'add2';
         // $groupselect = empty($space['privacy']['groupname']) ? array(1 => ' checked') : array();
         // $navtitle = lang('core', 'title_friend_add');
         // include template('home/spacecp_friend');
         // exit();
     } else {
         if (C::t('home_friend_request')->count_by_uid_fuid($uid, $_G['uid'])) {
             return $this->makeErrorInfo($res, 'waiting_for_the_other_test');
         }
         $_POST['gid'] = $gid;
         $_POST['note'] = censor(htmlspecialchars(cutstr($note, strtolower(CHARSET) == 'utf-8' ? 30 : 20, '')));
         friend_add($uid, $_POST['gid'], $_POST['note']);
         $note = array('uid' => $_G['uid'], 'url' => 'home.php?mod=spacecp&ac=friend&op=add&uid=' . $_G['uid'] . '&from=notice', 'from_id' => $_G['uid'], 'from_idtype' => 'friendrequest', 'note' => !empty($_POST['note']) ? lang('spacecp', 'friend_request_note', array('note' => $_POST['note'])) : '');
         notification_add($uid, 'friend', 'friend_request', $note);
         require_once libfile('function/mail');
         $values = array('username' => $tospace['username'], 'url' => getsiteurl() . 'home.php?mod=spacecp&ac=friend&amp;op=request');
         sendmail_touser($uid, lang('spacecp', 'friend_subject', $values), '', 'friend_add');
         return $this->makeErrorInfo($res, 'request_has_been_sent');
     }
     return $res;
 }
コード例 #3
0
ファイル: function_core.php プロジェクト: Kingson4Wu/php_demo
function notification_add($touid, $type, $note, $notevars = array(), $system = 0)
{
    global $_G;
    $tospace = array('uid' => $touid);
    space_merge($tospace, 'field_home');
    $filter = empty($tospace['privacy']['filter_note']) ? array() : array_keys($tospace['privacy']['filter_note']);
    if ($filter && (in_array($type . '|0', $filter) || in_array($type . '|' . $_G['uid'], $filter))) {
        return false;
    }
    $notevars['actor'] = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">" . $_G['member']['username'] . "</a>";
    $notestring = lang('notification', $note, $notevars);
    $oldnote = array();
    if ($notevars['from_id'] && $notevars['from_idtype']) {
        $oldnote = db::fetch_first("SELECT * FROM " . db::table('home_notification') . "\n\t\t\tWHERE from_id='{$notevars['from_id']}' AND from_idtype='{$notevars['from_idtype']}'");
    }
    if (empty($oldnote['from_num'])) {
        $oldnote['from_num'] = 0;
    }
    $setarr = array('uid' => $touid, 'type' => $type, 'new' => 1, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'note' => addslashes($notestring), 'dateline' => $_G['timestamp'], 'from_id' => $notevars['from_id'], 'from_idtype' => $notevars['from_idtype'], 'from_num' => $oldnote['from_num'] + 1);
    if ($system) {
        $setarr['authorid'] = 0;
        $setarr['author'] = '';
    }
    if ($oldnote['id']) {
        db::update('home_notification', $setarr, array('id' => $oldnote['id']));
    } else {
        $oldnote['new'] = 0;
        DB::insert('home_notification', $setarr);
    }
    if (empty($oldnote['new'])) {
        DB::query("UPDATE " . DB::table('common_member_status') . " SET notifications=notifications+1 WHERE uid='{$touid}'");
        DB::query("UPDATE " . DB::table('common_member') . " SET newprompt=newprompt+1 WHERE uid='{$touid}'");
        require_once libfile('function/mail');
        $mail_subject = lang('notification', 'mail_to_user');
        sendmail_touser($touid, $mail_subject, $notestring, $type);
    }
    if (!$system && $_G['uid'] && $touid != $_G['uid']) {
        DB::query("UPDATE " . DB::table('home_friend') . " SET num=num+1 WHERE uid='{$_G['uid']}' AND fuid='{$touid}'");
    }
}
コード例 #4
0
ファイル: spacecp_friend.php プロジェクト: v998/discuzx-en
        exit;
    } else {
        if (getcount('home_friend_request', array('uid' => $uid, 'fuid' => $_G['uid']))) {
            showmessage('waiting_for_the_other_test');
        }
        if ($tospace['videophotostatus']) {
            ckvideophoto('friend', $tospace);
        }
        ckrealname('friend');
        if (submitcheck('addsubmit')) {
            $_POST['gid'] = intval($_POST['gid']);
            $_POST['note'] = censor($_POST['note']);
            friend_add($uid, $_POST['gid'], $_POST['note']);
            require_once libfile('function/mail');
            $values = array('username' => $tospace['username'], 'url' => getsiteurl() . 'home.php?mod=spacecp&ac=friend&amp;op=request');
            sendmail_touser($uid, lang('spacecp', 'friend_subject', $values), '', 'friend_add');
            showmessage('request_has_been_sent', dreferer(), array(), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true));
        } else {
            include_once template('home/spacecp_friend');
            exit;
        }
    }
} elseif ($op == 'ignore') {
    if ($uid) {
        if (submitcheck('friendsubmit')) {
            if (friend_check($uid)) {
                friend_delete($uid);
            } else {
                friend_request_delete($uid);
            }
            showmessage('do_success', 'home.php?mod=spacecp&ac=friend&op=request', array('uid' => $uid, 'from' => $_G['gp_from']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => 0));
コード例 #5
0
ファイル: UserAdminViewAction.php プロジェクト: caidongyun/CS
 private function _adminUser($act, $uid)
 {
     global $_G;
     $errorMsg = '';
     require_once libfile('function/spacecp');
     require_once libfile('function/home');
     require_once libfile('function/friend');
     if (friend_request_check($uid) && $act == 'add') {
         $act = 'add2';
     }
     if ($act == 'add' || $act == 'add2') {
         if ($uid == $_G['uid']) {
             $list = $this->makeErrorInfo($res, 'friend_self_error');
             $this->_exitWithHtmlAlert($list['errcode']);
         }
         if (friend_check($uid)) {
             $list = $this->makeErrorInfo($res, 'you_have_friends');
             $this->_exitWithHtmlAlert($list['errcode']);
         }
         $tospace = getuserbyuid($uid);
         if (empty($tospace)) {
             $list = $this->makeErrorInfo($res, 'space_does_not_exist');
             $this->_exitWithHtmlAlert($list['errcode']);
         }
         if (isblacklist($tospace['uid'])) {
             $list = $this->makeErrorInfo($res, 'is_blacklist');
             $this->_exitWithHtmlAlert($list['errcode']);
         }
         space_merge($space, 'count');
         space_merge($space, 'field_home');
         $maxfriendnum = checkperm('maxfriendnum');
         if ($maxfriendnum && $space['friends'] >= $maxfriendnum + $space['addfriend']) {
             if ($_G['magic']['friendnum']) {
                 $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends_with_magic');
                 $this->_exitWithHtmlAlert($list['errcode']);
             } else {
                 $list = $this->makeErrorInfo($res, 'enough_of_the_number_of_friends');
                 $this->_exitWithHtmlAlert($list['errcode']);
             }
         }
         if ($act == 'add') {
             if (!checkperm('allowfriend')) {
                 $list = $this->makeErrorInfo($res, 'no_privilege_addfriend');
                 $this->_exitWithHtmlAlert($list['errcode']);
             }
             if (C::t('home_friend_request')->count_by_uid_fuid($uid, $_G['uid'])) {
                 $list = $this->makeErrorInfo($res, 'waiting_for_the_other_test');
                 $this->_exitWithHtmlAlert($list['errcode']);
             }
         }
     }
     require_once libfile('function/friend');
     require_once libfile('function/spacecp');
     if (!empty($_POST)) {
         switch ($act) {
             case 'add':
                 $note = $_GET['note'];
                 if (!friend_request_check($uid)) {
                     $_POST['gid'] = $gid;
                     $_POST['note'] = censor(htmlspecialchars(cutstr($note, strtolower(CHARSET) == 'utf-8' ? 30 : 20, '')));
                     friend_add($uid, $_POST['gid'], $_POST['note']);
                     $note = array('uid' => $_G['uid'], 'url' => 'home.php?mod=spacecp&ac=friend&op=add&uid=' . $_G['uid'] . '&from=notice', 'from_id' => $_G['uid'], 'from_idtype' => 'friendrequest', 'note' => !empty($_POST['note']) ? lang('spacecp', 'friend_request_note', array('note' => $_POST['note'])) : '');
                     notification_add($uid, 'friend', 'friend_request', $note);
                     // ios push
                     UserUtils::pushIOSMessage($uid, 'friend', $_G['username'] . WebUtils::t(' 请求加您为好友') . $note['note']);
                     require_once libfile('function/mail');
                     $values = array('username' => $tospace['username'], 'url' => getsiteurl() . 'home.php?mod=spacecp&ac=friend&amp;op=request');
                     sendmail_touser($uid, lang('spacecp', 'friend_subject', $values), '', 'friend_add');
                     $list = $this->makeErrorInfo($res, 'request_has_been_sent');
                     $this->_exitWithHtmlAlert($list['errcode']);
                 }
                 $this->_exitWithHtmlAlert($res['errcode']);
             case 'add2':
                 global $_G;
                 require_once libfile('function/home');
                 $_POST['gid'] = intval($gid);
                 friend_add($uid, $uid);
                 if (ckprivacy('friend', 'feed')) {
                     require_once libfile('function/feed');
                     feed_add('friend', 'feed_friend_title', array('touser' => "<a href=\"home.php?mod=space&uid={$tospace['uid']}\">{$tospace['username']}</a>"));
                 }
                 notification_add($uid, 'friend', 'friend_add');
                 // showmessage('friends_add', dreferer(), array('username' => $tospace['username'], 'uid'=>$uid, 'from' => $_GET['from']), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true));
                 $list = $this->makeErrorInfo($res, 'friends_add', array('{username}' => $tospace['username']));
                 $this->_exitWithHtmlAlert($list['errcode']);
                 break;
             case 'ignore':
                 global $_G;
                 require_once libfile('function/friend');
                 friend_delete($uid);
                 $params['noError'] = 1;
                 $list = $this->makeErrorInfo($res, 'do_success', $params);
                 $this->_exitWithHtmlAlert($list['errcode']);
                 break;
             case 'shield':
                 global $_G, $space;
                 // $type = empty($_GET['type'])?'':preg_replace("/[^0-9a-zA-Z\_\-\.]/", '', $_GET['type']);
                 // if(submitcheck('ignoresubmit')) {
                 $authorid = empty($_POST['authorid']) ? 0 : intval($_POST['authorid']);
                 $type = 'friend';
                 if ($type) {
                     $type_uid = $type . '|' . $authorid;
                     if (empty($space['privacy']['filter_note']) || !is_array($space['privacy']['filter_note'])) {
                         $space['privacy']['filter_note'] = array();
                     }
                     $space['privacy']['filter_note'][$type_uid] = $type_uid;
                     privacy_update();
                 }
                 $this->_exitWithHtmlAlert('do_success');
                 // showmessage('do_success', dreferer(), array(), array('showdialog'=>1, 'showmsg' => true, 'closetime' => true));
                 // }
                 $formid = random(8);
                 break;
             default:
                 $errorMsg = '错误的动作参数';
                 break;
         }
     } else {
         if ($act == 'add') {
             require_once libfile('function/friend');
             $groups = $this->_getFriendGroupList();
             $tospace = getuserbyuid($uid);
         } elseif ($act == 'add2') {
             require_once libfile('function/friend');
             $groups = $this->_getFriendGroupList();
             $tospace = $this->_getFriendUserByUid($uid);
         }
     }
     $this->getController()->renderPartial('userAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('user/useradminview', array('uid' => $uid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'groups' => $groups, 'tospace' => $tospace));
 }
コード例 #6
0
 /**
  * 通知
  * @param Integer $touid: 通知给谁
  * @param String $type: 通知类型
  * @param String $note: 语言key
  * @param Array $notevars: 语言变量对应的值
  * @param Integer $system: 是否为系统通知 0:非系统通知; 1:系统通知
  */
 public static function notification_add($touid, $type, $note, $notevars = array(), $system = 0, $category = -1)
 {
     global $_G;
     //已经存档用户将不再接收通知
     if (!($tospace = getuserbyuid($touid))) {
         return false;
     }
     space_merge($tospace, 'field_home');
     $filter = empty($tospace['privacy']['filter_note']) ? array() : array_keys($tospace['privacy']['filter_note']);
     //检查用户屏蔽
     if ($filter && (in_array($type . '|0', $filter) || in_array($type . '|' . $_G['uid'], $filter))) {
         return false;
     }
     if ($category == -1) {
         $category = 0;
         $categoryname = '';
         if ($type == 'follow' || $type == 'follower') {
             switch ($type) {
                 case 'follow':
                     $category = 5;
                     break;
                 case 'follower':
                     $category = 6;
                     break;
             }
             $categoryname = $type;
         } else {
             foreach ($_G['notice_structure'] as $key => $val) {
                 if (in_array($type, $val)) {
                     switch ($key) {
                         case 'mypost':
                             $category = 1;
                             break;
                         case 'interactive':
                             $category = 2;
                             break;
                         case 'system':
                             $category = 3;
                             break;
                         case 'manage':
                             $category = 4;
                             break;
                         default:
                             $category = 0;
                     }
                     $categoryname = $key;
                     break;
                 }
             }
         }
     } else {
         switch ($category) {
             case 1:
                 $categoryname = 'mypost';
                 break;
             case 2:
                 $categoryname = 'interactive';
                 break;
             case 3:
                 $categoryname = 'system';
                 break;
             case 4:
                 $categoryname = 'manage';
                 break;
             case 5:
                 $categoryname = 'follow';
                 break;
             case 6:
                 $categoryname = 'follower';
                 break;
             default:
                 $categoryname = 'app';
         }
     }
     if ($category == 0) {
         $categoryname = 'app';
     } elseif ($category == 1 || $category == 2) {
         $categoryname = $type;
     }
     $notevars['actor'] = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">" . $_G['member']['username'] . "</a>";
     //非漫游通知
     if (!is_numeric($type)) {
         $vars = explode(':', $note);
         if (count($vars) == 2) {
             $notestring = lang('plugin/' . $vars[0], $vars[1], $notevars);
         } else {
             $notestring = lang('notification', $note, $notevars);
         }
         $frommyapp = false;
     } else {
         $frommyapp = true;
         $notestring = $note;
     }
     //去重
     $oldnote = array();
     if ($notevars['from_id'] && $notevars['from_idtype']) {
         $oldnote = C::t('home_notification')->fetch_by_fromid_uid($notevars['from_id'], $notevars['from_idtype'], $touid);
     }
     if (empty($oldnote['from_num'])) {
         $oldnote['from_num'] = 0;
     }
     $notevars['from_num'] = $notevars['from_num'] ? $notevars['from_num'] : 1;
     $setarr = array('uid' => $touid, 'type' => $type, 'new' => 1, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'note' => $notestring, 'dateline' => $_G['timestamp'], 'from_id' => $notevars['from_id'], 'from_idtype' => $notevars['from_idtype'], 'from_num' => $oldnote['from_num'] + $notevars['from_num'], 'category' => $category);
     if ($system) {
         $setarr['authorid'] = 0;
         $setarr['author'] = '';
     }
     $pkId = 0;
     if ($oldnote['id']) {
         C::t('home_notification')->update($oldnote['id'], $setarr);
         $pkId = $oldnote['id'];
     } else {
         $oldnote['new'] = 0;
         $pkId = C::t('home_notification')->insert($setarr, true);
     }
     $banType = array('task');
     //上报消息中心
     if ($_G['setting']['cloud_status'] && !in_array($type, $banType)) {
         $noticeService = Cloud::loadClass('Service_Client_Notification');
         if ($oldnote['id']) {
             $noticeService->update($touid, $pkId, $setarr['from_num'], $setarr['dateline'], $note);
         } else {
             $extra = $type == 'post' ? array('pId' => $notevars['pid']) : array();
             $extra['notekey'] = $note;
             $noticeService->add($touid, $pkId, $type, $setarr['authorid'], $setarr['author'], $setarr['from_id'], $setarr['from_idtype'], $setarr['note'], $setarr['from_num'], $setarr['dateline'], $extra);
         }
     }
     //更新用户通知
     if (empty($oldnote['new'])) {
         C::t('common_member')->increase($touid, array('newprompt' => 1));
         $newprompt = C::t('common_member_newprompt')->fetch($touid);
         if ($newprompt) {
             $newprompt['data'] = unserialize($newprompt['data']);
             if (!empty($newprompt['data'][$categoryname])) {
                 $newprompt['data'][$categoryname] = intval($newprompt['data'][$categoryname]) + 1;
             } else {
                 $newprompt['data'][$categoryname] = 1;
             }
             C::t('common_member_newprompt')->update($touid, array('data' => serialize($newprompt['data'])));
         } else {
             C::t('common_member_newprompt')->insert($touid, array($categoryname => 1));
         }
         require_once libfile('function/mail');
         $mail_subject = lang('notification', 'mail_to_user');
         sendmail_touser($touid, $mail_subject, $notestring, $frommyapp ? 'myapp' : $type);
     }
     //更新我的好友关系热度
     if (!$system && $_G['uid'] && $touid != $_G['uid']) {
         C::t('home_friend')->update_num_by_uid_fuid(1, $_G['uid'], $touid);
     }
 }
コード例 #7
0
ファイル: function_core.php プロジェクト: v998/discuzx-en
function notification_add($touid, $type, $note, $notevars = array(), $system = 0)
{
    global $_G;
    $tospace = array('uid' => $touid);
    space_merge($tospace, 'field_home');
    $filter = empty($tospace['privacy']['filter_note']) ? array() : array_keys($tospace['privacy']['filter_note']);
    if ($filter && (in_array($type . '|0', $filter) || in_array($type . '|' . $_G['uid'], $filter))) {
        return false;
    }
    $notevars['actor'] = "<a href=\"home.php?mod=space&uid={$_G['uid']}\">" . $_G['member']['username'] . "</a>";
    //vot Move this to DISPLAY notification !!!!!!!!!!!!!!!
    if (!is_numeric($type)) {
        $vars = explode(':', $note);
        if (count($vars) == 2) {
            $notestring = lang('plugin/' . $vars[0], $vars[1], $notevars);
        } else {
            $notestring = lang('notification', $note, $notevars);
        }
        $frommyapp = false;
    } else {
        $frommyapp = true;
        $notestring = $note;
    }
    $oldnote = array();
    if ($notevars['from_id'] && $notevars['from_idtype']) {
        /*vot*/
        $oldnote = DB::fetch_first("SELECT *\r\n\t\t\t\tFROM " . DB::table('home_notification') . "\r\n\t\t\t\tWHERE from_id='{$notevars['from_id']}'\r\n\t\t\t\t\tAND from_idtype='{$notevars['from_idtype']}'\r\n\t\t\t\t\tAND uid='{$touid}'");
    }
    if (empty($oldnote['from_num'])) {
        $oldnote['from_num'] = 0;
    }
    $notevars['from_num'] = $notevars['from_num'] ? $notevars['from_num'] : 1;
    /*vot*/
    $notevars['template'] = $note;
    /*vot*/
    $notestring = serialize($notevars);
    $setarr = array('uid' => $touid, 'type' => $type, 'new' => 1, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'note' => addslashes($notestring), 'dateline' => $_G['timestamp'], 'from_id' => $notevars['from_id'], 'from_idtype' => $notevars['from_idtype'], 'from_num' => $oldnote['from_num'] + $notevars['from_num']);
    if ($system) {
        $setarr['authorid'] = 0;
        $setarr['author'] = '';
    }
    //DEBUG
    //$log = 'notification_add::'."\n";
    //$log .= ' touid='.$touid.';'."\n";
    //$log .= ' type='.$type.';'."\n";
    //$log .= ' system='.$system.';'."\n";
    //$log .= ' note='.var_export($note,true).';'."\n";
    //$log .= ' notevars='.var_export($notevars,true).';'."\n";
    //$log .= ' setarr='.var_export($setarr,true).';'."\n";
    //$log .= "-----------------------------------------\n";
    //$log .= "\n";
    //writelog('notification', $log);
    if ($oldnote['id']) {
        DB::update('home_notification', $setarr, array('id' => $oldnote['id']));
    } else {
        $oldnote['new'] = 0;
        DB::insert('home_notification', $setarr);
    }
    if (empty($oldnote['new'])) {
        /*vot*/
        DB::query("UPDATE " . DB::table('common_member') . "\r\n\t\t\t   SET newprompt=newprompt+1\r\n\t\t\t   WHERE uid='{$touid}'");
        require_once libfile('function/mail');
        $mail_subject = lang('notification', 'mail_to_user');
        sendmail_touser($touid, $mail_subject, $notestring, $frommyapp ? 'myapp' : $type);
    }
    if (!$system && $_G['uid'] && $touid != $_G['uid']) {
        /*vot*/
        DB::query("UPDATE " . DB::table('home_friend') . "\r\n\t\t\t   SET num=num+1\r\n\t\t\t   WHERE uid='{$_G['uid']}' AND fuid='{$touid}'");
    }
}