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;
 }
 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));
 }
Exemple #3
0
 }
 if (isblacklist($tospace['uid'])) {
     showmessage('is_blacklist');
 }
 $groups = friend_group_list();
 space_merge($space, 'count');
 space_merge($space, 'field_home');
 $maxfriendnum = checkperm('maxfriendnum');
 if ($maxfriendnum && $space['friends'] >= $maxfriendnum + $space['addfriend']) {
     if ($_G['magic']['friendnum']) {
         showmessage('enough_of_the_number_of_friends_with_magic');
     } else {
         showmessage('enough_of_the_number_of_friends');
     }
 }
 if (friend_request_check($uid)) {
     if (submitcheck('add2submit')) {
         $_POST['gid'] = intval($_POST['gid']);
         friend_add($uid, $_POST['gid']);
         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' => $_G['gp_from']), array('showdialog' => 1, 'showmsg' => true, 'closetime' => true));
     }
     $op = 'add2';
     $groupselect = empty($space['privacy']['groupname']) ? array(1 => ' checked') : array();
     $navtitle = lang('core', 'title_friend_add');
     include template('home/spacecp_friend');
     exit;
Exemple #4
0
 private function checkOutput()
 {
     ///////////////////////////////////////
     // check操作类型(1:加好友,2:同意好友请求,3:拒绝好友请求)
     $optype = isset($_GET["optype"]) ? $_GET["optype"] : 1;
     ///////////////////////////////////////
     //echo json_encode($GLOBALS); exit(0);
     global $_G;
     $groups = array();
     if (isset($GLOBALS["groups"])) {
         foreach ($GLOBALS["groups"] as $gid => $gname) {
             $gname = preg_replace('/<.*?\\>/', '', $gname);
             $groups[] = array("gid" => $gid, "group" => $gname);
         }
     }
     if (isset($GLOBALS['show_message'])) {
         $messageval = isset($_G['messageparam'][0]) ? $_G['messageparam'][0] : "";
         $msg = preg_replace("'<script[^>]*?>.*?</script>'si", "", $GLOBALS['show_message']);
         $variable = array("status" => 1, "groups" => $groups, "show_message" => strip_tags($msg), "messageval" => $messageval);
         /////////////////////////////////////////////////
         // 当前用户组无加好友权限,但是可以拒绝别人的请求
         if ($optype == 3) {
             if ($messageval == "no_privilege_addfriend") {
                 $variable["status"] = 0;
             }
         }
         /////////////////////////////////////////////////
     } else {
         /////////////////////////////////////////////////
         // 检查该用户是否已向自己发出好友申请请求
         require_once libfile('function/friend');
         if (friend_request_check($_GET['uid'])) {
             $variable = array("status" => 2, "groups" => $groups, "show_message" => iconv('UTF-8', CHARSET . '//ignore', '该用户已向您发出好友申请,请到新的好友页面审核'));
         } else {
             $variable = array("status" => 0, "groups" => $groups, "show_message" => "");
         }
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }