function del($id, $mid)
 {
     $map = "(fromUserId = {$mid} OR uid = {$mid}) AND (id = {$id})";
     $r = $this->where($map)->delete();
     setScore($mid, 'delete_wall');
     if ($r) {
         $map_r[replyWallId] = $id;
         $this->where($map_r)->delete();
     }
     return 1;
 }
 private function __getNotifyData($data)
 {
     //发送两条消息
     $dao = D("Mini");
     $need = $dao->where('id=' . intval($data['appid']))->field('uid,content')->find();
     $result['uids'] = $need['uid'];
     $result['toUid'] = intval($data['comm_uid']) ? intval($data['comm_uid']) : 0;
     if ($result['toUid'] != $this->mid && $this->mid != $need['uid']) {
         $result['toUid'] != 0 && setScore($result['toUid'], 'replayed_mini');
         setScore($result['uids'], 'replayed_mini');
         setScore($this->mid, 'replay_mini');
     }
     $result['url'] = sprintf('{SITE_URL}/Index/friends/uid/%s#Fli%s', intval($data['mini_uid']), intval($data['appid']));
     $result['title_body']['comment'] = t($data['comment']);
     $result['title_data']['title'] = sprintf("<a href='%s'>%s</a>", $result['url'], $need['content']);
     $result['title_data']['type'] = "心情";
     return $result;
 }
 /**
  * addMentionModel 
  * 增加日志提及到的人
  * @param mixed $data 
  * @access public
  * @return void
  */
 public function addMention($blogid, $data)
 {
     foreach ($data as $value) {
         $user = $this->getOneName($value);
         if (!$user['name']) {
             $user['name'] = "没这个人";
         }
         $select[] = "SELECT '{$blogid}','{$value}','{$user['name']}','{$this->_type}'";
         setScore($value, 'mentioned');
     }
     $select = implode(' UNION ALL ', $select);
     $sql = "INSERT INTO `{$this->tablePrefix}blog_mention` ( `blogid` , `uid` , `name`,`type` )\n                    {$select}";
     if ($result = $this->execute($sql)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * doArgeUser
  * 同意申请
  * @param mixed $data
  * @access public
  * @return void
  */
 public function doArgeUser($data)
 {
     $userDao = self::factoryModel('user');
     if ($userDao->where('id=' . $data['id'])->setField('status', 1)) {
         $this->setInc('joinCount', 'id=' . $data['eventId']);
         $this->setDec('limitCount', 'id=' . $data['eventId']);
         setScore($data['uid'], 'join_event');
         //如果有参与的情况。删除单于的数据集
         $data['action'] = 'attention';
         if ($id = $userDao->where($data)->getField('id')) {
             $userDao->delete($id);
             $this->setDec('attentionCount', 'id=' . $data['eventId']);
         }
         return 1;
     }
     return 0;
 }
 /**
  * doAddMini 
  * 添加心情
  * @param mixed $map 条件
  * @access public
  * @return void
  */
 public function doAddMini($map)
 {
     $map['cTime'] = time();
     $name = $this->getOneName($map['uid']);
     $map['name'] = $name['name'];
     $map['type'] = $this->_type;
     $map = $this->merge($map);
     //$content = $this->replaceContent( $map['content'] );//替换文本表情
     $result = $this->add($map);
     if (!$result) {
         return false;
     }
     setScore($map['uid'], 'add_mini');
     //发送通知。如果发送失败,则返回false
     //$temp = substr( __PUBLIC__,4,strlen( __PUBLIC__ )-4 );
     $title['content'] = $this->replaceContent($map['content']);
     $body_data["id"] = $result;
     $body_data["uid"] = $map['uid'];
     $body_data["con"] = $map['content'];
     //发出动态,并更新feedId
     $map2 = $this->doFeed("mini", $title, $body_data);
     if (false != $map2) {
         $result = $this->where('id =' . $result)->setField("feedId", $map2);
     }
     if ($this->config->delete) {
         $count = $this->where('uid=' . $map['uid'] . ' AND status <> 1')->count();
     } else {
         $count = $this->where('uid=' . $map['uid'])->count();
     }
     $result = $this->api->space_changeCount('mini', $count);
     return str_replace('{PUBLIC_URL}', __PUBLIC__, $this->replaceContent($map['content']));
 }
 function _addScoure($uid, $id)
 {
     $isDone = browseCount('share_scoure', $id, $this->mid, $lifttime = 30);
     if ($this->mid != $uid && $isDone) {
         setScore($uid, 'visit_share');
     }
 }
 public function doWall()
 {
     $dao = D("Wall");
     $strContent = t($_POST['content']);
     $r = $dao->create();
     if (false === $r) {
         echo 0;
         return;
     }
     $dao->fromUserId = $this->mid;
     $dao->fromUserName = $this->my_name;
     $dao->content = $strContent;
     $dao->cTime = time();
     $rr = $dao->add();
     if ($rr) {
         //通知
         $uid = intval($_POST["uid"]);
         if ($uid != $this->mid) {
             $cate = "wall";
             $title_data = null;
             $body_data['data'] = $strContent;
             exit;
             $url = '__TS__/space/' . $uid . '#wall';
             $this->api->notify_send($uid, $type, $title_data, $body_data, $url, $cate);
             setScore($this->mid, 'wall');
             setScore($uid, 'walled');
         }
         echo $rr;
     } else {
         echo 0;
     }
 }
Esempio n. 8
0
function calculateRanksPlayers($sqlServerKey, $winnerKey, $gameType)
{
    $sql = "select distinct ge_playera from game_event where ge_serverkey='{$sqlServerKey}' and ge_playera is not null and ge_playera <> '{$winnerKey}' and (ge_eventtype = " . WINBOLO_NET_EVENT_BASE_CAPTURE . " or ge_eventtype = " . WINBOLO_NET_EVENT_PILL_CAPTURE . " or ge_eventtype = " . WINBOLO_NET_EVENT_BASE_STEAL . " or ge_eventtype = " . WINBOLO_NET_EVENT_PILL_STEAL . ")";
    $result = mysql_query($sql);
    $loserKey = mysql_result($result, 0, 0);
    $winnerPid = getPidFromKey($winnerKey, $sqlServerKey);
    $loserPid = getPidFromKey($loserKey, $sqlServerKey);
    if ($winnerPid == 0 || $loserPid == 0) {
        return;
    }
    # Get player Ranks
    $winnerScore = getScore($winnerPid, $gameType, false);
    $loserScore = getScore($loserPid, $gameType, false);
    # Calclulate New Scores
    $newWinnerScore = calculateElo($winnerScore, $loserScore, true);
    $newLoserScore = calculateElo($loserScore, $winnerScore, false);
    # Update ranks
    setScore($winnerPid, $gameType, $newWinnerScore, false);
    setScore($loserPid, $gameType, $newLoserScore, false);
    updateWinsLoses($winnerPid, $gameType, true, false);
    updateWinsLoses($loserPid, $gameType, false, false);
}
Esempio n. 9
0
 /**
  * doAddBlog
  * 添加文章
  * @param mixed $map 文章内容
  * @param mixed $feed 是否发送动态
  * @access public
  * @return void
  */
 public function doAddBlog($map, $import)
 {
     $map['private'] = '0';
     $map['cTime'] = isset($map['cTime']) ? $map['cTime'] : time();
     $map['mTime'] = $map['cTime'];
     $map['type'] = isset($map['type']) ? $map['type'] : $this->_type;
     $map['private_data'] = md5($map['password']);
     $map['category_title'] = M('blog_category')->where("`id`={$map['category']}")->getField('name');
     $content = $map['content'];
     // 用于发通知截取
     $map['content'] = t(h($map['content']));
     unset($map['password']);
     $friendsId = isset($map['mention']) ? explode(',', $map['mention']) : null;
     //解析提到的好友
     unset($map['mention']);
     $map = $this->merge($map);
     $addId = $this->add($map);
     $temp = array_filter($friendsId);
     //$appid = A('Index')->getAppId();
     //添加文章提到的好友
     if (!empty($friendsId) && !empty($temp)) {
         $mention = self::factoryModel('mention');
         $result = $mention->addMention($addId, $temp);
         for ($i = 0; $i < count($temp); $i++) {
             setScore($map['uid'], 'mention');
         }
         //发送通知给提到的好友
         $body['content'] = getBlogShort(t($content), 40);
         $url = sprintf("%s/Index/show/id/%s/mid/%s", '{' . $appid . '}', $addId, $map['uid']);
         $title_data['title'] = sprintf("<a href='%s'>%s</a>", $url, $map['title']);
         $this->doNotify($temp, "blog_mention", $title_data, $body, $url);
     }
     if (!$addId) {
         return false;
     }
     //获得配置信息
     $config = $this->config['delete'];
     if ($config) {
         //修改空间中的计数
         $count = $this->where('uid =' . $map['uid'])->count();
     } else {
         //修改空间中的计数
         $count = $this->where('uid =' . $map['uid'] . ' AND status <> 2')->count();
     }
     //$this->api->space_changeCount( 'blog',$count );
     //发送动态
     if ($import) {
         //$title['title']   = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>",__APP__,$addId,$map['uid'],$map['title']);
         $title['title'] = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>", '{SITE_URL}', $addId, $map['uid'], $map['title']);
         $title['title'] = stripslashes($title['title']);
         //setScore($map['uid'],'add_blog');
         //            $body['content'] = getBlogShort($this->replaceSpecialChar(t($map['content'])),80);
         $body['content'] = $this->getBlogShort($this->replaceSpecialChar(t($map['content'])), 80);
         $body['title'] = stripslashes($body['title']);
         //$this->doFeed("blog",$title,$body);
     } else {
         //setScore($map['uid'],'add_blog');
         $result['appid'] = $addId;
         $result['title'] = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>", '{SITE_URL}', $addId, $map['uid'], $map['title']);
         return $result;
     }
     return $addId;
 }
 function saveThumb()
 {
     //头像大方快的宽高
     $targ_w = 120;
     $targ_h = 120;
     //头像小方块的宽高
     $small_w = 50;
     $small_h = 50;
     //图像质量
     $jpeg_quality = 80;
     $src_arr = explode("?", $_POST['bigImage']);
     $src = $src_arr[0];
     $src = str_ireplace(SITE_URL, '.', $src);
     //获取图片的扩展名。来选择使用什么函数
     if ($arr = @getimagesize($src)) {
         $ext = image_type_to_extension($arr[2], false);
     } else {
         $this->error('对不起,GD库不存在或远程图片不存在');
     }
     $func = $ext != 'jpg' ? 'imagecreatefrom' . $ext : 'imagecreatefromjpeg';
     $img_r = call_user_func($func, $src);
     //开始切割大方块头像
     $dst_r = ImageCreateTrueColor($targ_w, $targ_h);
     $x = $targ_h / $_POST['txt_Zoom'];
     imagecopyresampled($dst_r, $img_r, 0, 0, $_POST['txt_left'] / $_POST['txt_Zoom'], $_POST['txt_top'] / $_POST['txt_Zoom'], $targ_w, $targ_h, $x, $x);
     $path = SITE_PATH . "data/thumb/";
     $filename = $path . 'xxx_s.jpg';
     $face_path = getFacePath($this->mid);
     mkdir($face_path, 0777, true);
     $middle_name = $face_path . $this->mid . "_middle_face.jpg";
     //中图
     imagejpeg($dst_r, $middle_name);
     //生成中图
     imagedestroy($dst_r);
     imagedestroy($img_r);
     $small_name = $face_path . $this->mid . "_small_face.jpg";
     //小图
     vendor("yu_image");
     $img = new yu_image();
     $img->param($middle_name)->thumb($small_name, $small_w, $small_h, 0);
     //缩出小图
     //添加一条动态
     $body_data["src"] = getUserFace($this->mid);
     $this->api->feed_publish("head", $title_data, $body_data);
     setScore($this->mid, 'update_face');
     $this->redirect("/Home/index");
 }
Esempio n. 11
0
     $_SESSION['streak']++;
     if ($_SESSION['streak'] > 5) {
         $streakBonus = round(pow($_SESSION['streak'], 1.1));
     }
     incrStat('sumcfc', $userID);
     incrStat('sumc' . $vstyle, $userID);
     //incrUserDeckStat('stats_correct', $cvset, $vstyle, $userID);
     setStat('conf', $userID, getStat('conf', $userID) + $confCorrGain);
     //overall conf stat
     setSkill($progressVoc, $userID, getSkill($progressVoc, $userID) + $skillCorrGain + $streakBonus);
     //cvset prog skill
     setStat('gold', $userID, getStat('gold', $userID) + $gcRw);
     //gold
     $changeLog[] = "<li><span class='label label-warning'>Gold Coins</span>:<b>+<span class='text-success'>{$gcRw}</span></b></li>";
     for ($i = 0; $i < sizeof($skills); $i++) {
         setScore($skills[$i], $userID, getScore($skills[$i], $userID) + $scoreIncr);
         $changeLog[] = "<li>" . getStatInfo($skills[$i], 'display_name') . ":<b> +{$scoreIncr}</b> Confidence points</li>";
     }
     //$changeLog[] = "<li>Overall Player Confidence:<b>+$confCorrGain</b> Confidence points</span></li>";
     //$changeLog[] = "<li>Quiz Mode:<b> +$skillCorrGain</b> Confidence points</span></li>";
     //$changeLog[] = "<li>Streak Bonus: <b>+$streakBonus</b> Confidence points</span></li>";
     //------------------INCREMENT GENERAL SKILLS
     $result = "<span style='color:green;'>CORRECT!</span>";
 } elseif ($wordIDGuess != $answerID) {
     $correct = false;
     setStat('conf', $userID, getStat('conf', $userID) - $confWrongPen);
     //overall conf stat
     setSkill($progressVoc, $userID, getSkill($progressVoc, $userID) - $skillWrongPen);
     //cvset prog skill
     setStat('gold', $userID, getStat('gold', $userID) - $gcPen);
     //gold
 public function delPhoto()
 {
     $map['id'] = intval($_POST['id']);
     $map['albumId'] = intval($_POST['albumId']);
     $map['gid'] = $this->gid;
     $photo = D('Photo')->field('id,is_del')->where($map)->find();
     if ($photo && $photo['is_del'] == 0) {
         $result = D('Album')->deletePhoto($map['id'], $this->gid);
         if ($result) {
             //删除成功
             setScore($this->mid, 'group_photo_delete');
             echo "1";
         } else {
             //删除失败
             echo "0";
         }
     } else {
         //不存在或已被删除
         echo "-1";
     }
 }
 public function notify(array $type, array $data, $appid)
 {
     $dao = TS_D('Notify');
     $dao->setAppId($appid);
     if ($this->mid != $data['uids']) {
         switch (true) {
             case $data['uids'] == $data['toUid'] && !empty($data['toUid']):
                 //发布者的回复的回复
                 setScore($data['toUid'], 'comment_comment');
                 $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']);
                 break;
             case $data['uids'] != $data['toUid'] && !empty($data['toUid']):
                 //回复的回复
                 setScore($this->mid, 'commented');
                 if ($data['toUid'] != $this->mid) {
                     setScore($data['toUid'], 'comment_comment');
                     $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']);
                 }
                 setScore($data['uids'], 'commented');
                 $notify = $dao->send($data['uids'], $type . '_comment', $data['title_data'], $data['title_body'], $data['url']);
                 break;
             default:
                 //评论
                 setScore($this->mid, 'comment');
                 setScore($data['uids'], 'commented');
                 $notify = $dao->send($data['uids'], $type . '_comment', $data['title_data'], $data['title_body'], $data['url']);
         }
         return $notify;
     } else {
         if ($data['uids'] != $data['toUid'] && !empty($data['toUid'])) {
             setScore($data['toUid'], 'comment_comment');
             $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']);
         }
     }
 }
 function del()
 {
     //权限判读  注意权限
     $id = isset($_POST['tid']) && intval($_POST['tid']) > 0 ? intval($_POST['tid']) : 0;
     if ($id == 0) {
         exit;
     }
     if ($_POST['type'] == 'thread') {
         $topicInfo = $this->topic->where('id=' . $id)->find();
         //设置日志
         $content = "把话题“{$topicInfo['title']}”,作者 " . "<a href='__TS__/space/{$topicInfo['uid']}'>" . getUserName($topicInfo['uid']) . "</a>" . ",删除";
         D('Log')->writeLog($this->gid, $this->mid, $content);
         $this->topic->remove($id);
         setScore($this->mid, 'group_topic_delete');
         redirect(__APP__ . "/Topic/index/gid/{$this->gid}");
     } elseif ($_POST['type'] == 'post') {
         $tid = $this->post->getField('tid', 'id=' . $id);
         //获取要删除的帖子id
         $this->post->remove($id);
         //删除回复
         //帖子回复数目减少1个
         $this->topic->setDec('replycount', 'id=' . $tid);
         redirect(__APP__ . "/Topic/topic/gid/{$this->gid}/tid/" . $tid);
     }
 }
 function _addScoure($mid, $data, $type)
 {
     setScore($mid, 'add_share');
     //发起分享
     $uid = $this->_getUid($data, $type);
     if (!empty($uid)) {
         setScore($uid, 'shared');
         //被分享
     }
 }
 function delfile()
 {
     $fid = intval($_POST['fid']) > 0 ? intval($_POST['fid']) : 0;
     $file = $this->dir->find($fid);
     if ($fid == 0 || empty($file)) {
         exit;
     }
     //权限判读 管理者,或者用户自己删除
     if (!($this->isadmin || $this->mid == $file['uid'])) {
         exit('你没有权限');
     }
     if ($this->dir->remove($fid)) {
         setScore($this->mid, 'group_file_delete');
         $this->redirect('Dir/index/gid/' . $this->gid);
     } else {
         $this->error('删除失败');
     }
 }
 /**
  * doAddEvent
  * 添加活动
  * @access public
  * @return void
  */
 public function doAddEvent()
 {
     $map['title'] = t($_POST['title']);
     $map['address'] = t($_POST['address']);
     $map['limitCount'] = intval(t($_POST['limitCount']));
     $map['type'] = $_POST['type'];
     $map['explain'] = h($_POST['explain']);
     $map['contact'] = $_POST['contact'];
     $map['deadline'] = $deadline = $this->_paramDate($_POST['deadline']);
     $map['sTime'] = $stime = $this->_paramDate($_POST['sTime']);
     $map['eTime'] = $etime = $this->_paramDate($_POST['eTime']);
     $map['uid'] = $this->mid;
     $map['name'] = $this->my_name;
     if ($stime > $etime && $stime < time()) {
         $this->error("结束时间不允许小于开始时间,并且开始时间不得小于当前时间");
         exit;
     }
     if ($deadline < time()) {
         $this->error("结束时间不得小于当前时间");
     }
     //处理省份,市,区
     list($opts['province'], $opts['city'], $opts['area']) = explode(" ", $_POST['city']);
     //得到上传的图片
     $option = array();
     $option['save_photo']['albumId'] = intval($_POST['albumId']);
     $option['max_size'] = $this->event->getConfig('limitphoto') * 1024 * 1024;
     $option['allow_exts'] = $this->event->getConfig('limitsuffix');
     $cover = $this->api->attach_upload('event_cover', $option);
     //处理选项
     $opts['cost'] = intval($_POST['cost']);
     $opts['costExplain'] = t($_POST['costExplain']);
     $friend = isset($_POST['friend']) ? 1 : 0;
     $alow = isset($_POST['alow']) ? 1 : 0;
     $opts['opts'] = array('friend' => $friend, 'alow' => $alow);
     if ($addId = $this->event->doAddEvent($map, $opts, $cover)) {
         setScore($this->mid, 'creat_event');
         $this->redirect('Index/eventDetail/id/' . $addId . '/uid/' . $this->mid);
     }
 }
 function relation($code, $uid)
 {
     $Group = D('Group');
     $Friend = D('Friend');
     $User = D('User');
     D("LoginRecord")->record($user["id"]);
     $code = jiemi($code);
     $code = json_decode($code);
     $fuid = 0;
     $gid = 0;
     if ($code) {
         $fuid = $code[0];
         $fusername = $code[1];
         $fgid = $code[2];
         $gid = $code[3];
         D("Friend")->makeFriend($fuid, $fusername, $fgid, $uid, getUserName($uid), 1);
         //添加动态
         $title['fuid'] = $fuid;
         $title['fuser'] = getUserName($fuid);
         $title['uid'] = $uid;
         $title['user'] = getUserName($uid);
         $title['site_name'] = $this->opts['site_name'];
         $this->api->feed_publish('invite_reg', $title, $body = '');
         //添加积分
         setScore($fuid, 'invite_reg');
         if ($gid > 0) {
             D('Group')->joingroup($uid, $gid, 3, $incMemberCount = true);
         }
     }
     $relationFriend = explode(',', $this->opts['reg_relation_friend']);
     //朋友关联
     $relationGroup = explode(',', $this->opts['reg_relation_group']);
     //群众默认关联
     if (!empty($relationFriend) && is_array($relationFriend)) {
         foreach ($relationFriend as $v) {
             $v = intval($v);
             if ($User->where('id=' . $v)->count()) {
                 if ($fuid != $v) {
                     $Friend->makeFriend($v, getUserName($v), 1, $uid, getUserName($uid), 1);
                 }
             }
         }
     }
     if (!empty($relationGroup) && is_array($relationGroup)) {
         foreach ($relationGroup as $v) {
             $v = intval($v);
             if ($Group->where('id=' . $v . ' AND is_del=0')->count()) {
                 if ($gid != $v) {
                     $Group->joingroup($uid, $v, 3, $incMemberCount = true);
                 }
             }
         }
     }
 }
 function del()
 {
     $dao = D("UserApp");
     $data["uid"] = $this->mid;
     $data["appid"] = intval($_GET["id"]);
     if ($dao->where($data)->delete()) {
         setScore($this->mid, 'delete_app');
         $this->redirect("index");
     } else {
         $this->error('您提交了错误参数');
     }
 }
 function vote()
 {
     //用户投票信息
     $voteUserDao = D("VoteUser");
     //先看看有无权限投
     $vote_id = intval($_POST["vote_id"]);
     //检查ID是否合法
     if (empty($vote_id) || 0 == $vote_id) {
         $this->error("错误的投票ID");
         exit;
     }
     $voteDao = D("Vote");
     $the_vote = $voteDao->where("id={$vote_id}")->find();
     $onlyfriend = $the_vote['onlyfriend'];
     $vote_user_id = $the_vote['uid'];
     $deadline = $the_vote['deadline'];
     if ($deadline <= time()) {
         echo -3;
         return;
     }
     if ($onlyfriend == "1" && $this->mid != $vote_user_id) {
         if (false == $this->api->friend_areFriends($vote_user_id, $this->mid)) {
             echo -3;
             return;
         }
     }
     //再看看投过没
     $vote_id = intval($_POST["vote_id"]);
     $count = $voteUserDao->where("vote_id={$vote_id} AND uid={$this->mid} AND opts <>''")->count();
     if ($count > 0) {
         echo -1;
         return;
     }
     //如果没投过,就添加
     $data["vote_id"] = $vote_id;
     $data["uid"] = $this->mid;
     $data["opts"] = rtrim(t($_POST["opts"]), ",");
     $data["cTime"] = time();
     $data['name'] = $this->name;
     $addid = $voteUserDao->add($data);
     //投票选项信息的num+1
     $dao = D("VoteOpt");
     $opts_ids = rtrim(t($_POST["opts_ids"]), ",");
     $opts_ids = explode(",", $opts_ids);
     foreach ($opts_ids as $v) {
         $v = intval($v);
         $dao->setInc("num", "id={$v}");
     }
     //投票信息的vote_num+1
     D("Vote")->setInc("vote_num", "id={$vote_id}");
     //动态
     $url = sprintf('%s/Index/pollDetail/id/%s', '{SITE_URL}', $vote_id);
     $vote_info["title"] = "<a href='" . $url . "'>" . t($the_vote['title']) . "</a>";
     $result = $this->api->feed_publish("vote_in", $vote_info, null, $this->appId);
     if (false != $result) {
         $map['feedId'] = $result;
         $voteUserDao->where('id =' . $addid)->save($map);
     }
     setScore($this->mid, 'join_vote');
     setScore($vote_user_id, 'joined_vote');
     //通知
     if ($this->mid != $vote_user_id) {
         $notify['opts'] = $data['opts'];
         $this->api->notify_setAppId($this->appId);
         $result = $this->api->notify_send($vote_user_id, 'vote_in', $vote_info, $notify, $url);
     }
     echo 1;
 }
Esempio n. 21
0
 /**
  * doAddTask
  * 添加任务
  * @param mixed $map 任务内容
  * @param mixed $feed 是否发送动态
  * @access public
  * @return void
  */
 public function doAddTask($map, $import)
 {
     $map['cTime'] = isset($map['cTime']) ? $map['cTime'] : time();
     $map['mTime'] = $map['cTime'];
     $map['type'] = isset($map['type']) ? $map['type'] : $this->_type;
     $map['tags'] = $map['tags'];
     $map['private'] = $map['private'];
     $map['private_data'] = md5($map['password']);
     $map['category_title'] = M('task_category')->where("`id`={$map['category']}")->getField('name');
     $content = $map['content'];
     // 用于发通知截取
     //$map['content'] 	 = t(h($map['content']));
     $map['content'] = $map['content'];
     unset($map['password']);
     $friendsId = isset($map['mention']) ? explode(',', $map['mention']) : null;
     //解析提到的好友
     unset($map['mention']);
     $map['share_type'] = isset($map['share_type']) ? $map['share_type'] : $this->_share_type;
     $map['share_source'] = isset($map['share_source']) ? $map['share_source'] : $this->_share_source;
     $map['share_target'] = isset($map['share_target']) ? $map['share_target'] : $this->_share_target;
     $map['parent_id'] = isset($map['parent_id']) ? $map['parent_id'] : $this->_parent_id;
     $map['level'] = isset($map['level']) ? $map['level'] : $this->_level;
     $map['task_type'] = isset($map['task_type']) ? $map['task_type'] : $this->_task_type;
     $map['task_status'] = isset($map['task_status']) ? $map['task_status'] : $this->_task_status;
     $map['task_priority'] = isset($map['task_priority']) ? $map['task_priority'] : $this->_task_priority;
     $map['start_date'] = isset($map['start_date']) ? $map['start_date'] : $this->_start_date;
     $map['due_date'] = isset($map['due_date']) ? $map['due_date'] : $this->_due_date;
     $map['estimated_time'] = isset($map['estimated_time']) ? $map['estimated_time'] : $this->_estimated_time;
     $map['spent_time'] = isset($map['spent_time']) ? $map['spent_time'] : $this->_spent_time;
     $map['done_ratio'] = isset($map['done_ratio']) ? $map['done_ratio'] : $this->_done_ratio;
     $map['detail_summary'] = isset($map['detail_summary']) ? $map['detail_summary'] : $this->_detail_summary;
     $map['rel_digest'] = isset($map['rel_digest']) ? $map['rel_digest'] : $this->_rel_digest;
     $map['rel_tasks'] = isset($map['rel_tasks']) ? $map['rel_tasks'] : $this->_rel_tasks;
     $map = $this->merge($map);
     $addId = $this->add($map);
     $temp = array_filter($friendsId);
     //$appid = A('Index')->getAppId();
     //添加任务提到的好友
     if (!empty($friendsId) && !empty($temp)) {
         $mention = self::factoryModel('mention');
         $result = $mention->addMention($addId, $temp);
         for ($i = 0; $i < count($temp); $i++) {
             setScore($map['uid'], 'mention');
         }
         //发送通知给提到的好友
         $body['content'] = getTaskShort(t($content), 40);
         $url = sprintf("%s/Index/show/id/%s/mid/%s", '{' . $appid . '}', $addId, $map['uid']);
         $title_data['title'] = sprintf("<a href='%s'>%s</a>", $url, $map['title']);
         $this->doNotify($temp, "task_mention", $title_data, $body, $url);
     }
     if (!$addId) {
         return false;
     }
     //获得配置信息
     $config = $this->config->delete;
     if ($config) {
         //修改空间中的计数
         $count = $this->where('uid =' . $map['uid'])->count();
     } else {
         //修改空间中的计数
         $count = $this->where('uid =' . $map['uid'] . ' AND status <> 2')->count();
     }
     //$this->api->space_changeCount( 'task',$count );
     //发送动态
     if ($import) {
         //$title['title']   = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>",__APP__,$addId,$map['uid'],$map['title']);
         $title['title'] = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>", '{SITE_URL}', $addId, $map['uid'], $map['title']);
         $title['title'] = stripslashes($title['title']);
         //setScore($map['uid'],'add_task');
         $body['content'] = getTaskShort($this->replaceSpecialChar(t($map['content'])), 80);
         $body['title'] = stripslashes($body['title']);
         $this->doFeed("task", $title, $body);
     } else {
         //setScore($map['uid'],'add_task');
         $result['appid'] = $addId;
         $result['title'] = sprintf("<a href=\"%s/Index/show/id/%s/mid/%s\">%s</a>", '{SITE_URL}', $addId, $map['uid'], $map['title']);
         return $result;
     }
     return $addId;
 }
 function doAdd()
 {
     if (trim($_POST['dosubmit'])) {
         if (!t($_POST['name']) || strlen(t($_POST['name'])) > 60) {
             $this->error('标题不能为空或者标题过长!!');
         }
         if (!t($_POST['intro'])) {
             $this->error('群组简介不能为空!');
         }
         $group = $this->group->create();
         $group['name'] = t($_POST['name']);
         $group['type'] = $_POST['type'];
         $group['intro'] = t($_POST['intro']);
         $group['anno'] = intval($_POST['anno']);
         $group['uid'] = $this->mid;
         $group['need_invite'] = intval($this->config[$group['type'] . '_isInvite']);
         //是否需要邀请
         $group['need_verify'] = intval($this->config[$group['type'] . '_review']);
         //申请是否需要同意
         $group['actor_level'] = intval($this->config[$group['type'] . '_sayMember']);
         //发表话题权限
         $group['brower_level'] = intval($this->config[$group['type'] . '_viewMember']);
         //浏览权限
         //$group['brower_level'] = intval($this->config[$group['type'].'_viewMember']); //浏览权限
         $group['openUploadFile'] = intval($this->config['openUploadFile']);
         $group['whoUploadFile'] = intval($this->config['whoUploadFile']);
         $group['openAlbum'] = intval($this->config['openAlbum']);
         $group['whoCreateAlbum'] = intval($this->config['whoCreateAlbum']);
         $group['whoUploadPic'] = intval($this->config['whoUploadPic']);
         //exit;
         $group['ctime'] = time();
         $info = $this->api->attach_upload('group_logo');
         if ($info['status']) {
             $group['logo'] = $info['info'][0]['savepath'] . $info['info'][0]['savename'];
         } else {
             $group['logo'] = 'default.gif';
         }
         $gid = $this->group->add($group);
         if ($gid) {
             //把自己添加到成员里面
             $this->group->joingroup($this->mid, $gid, 1, $incMemberCount = true);
             $title_data['actor'] = getUserName($this->mid);
             $body_data['gid'] = $gid;
             $body_data['group_name'] = $group['name'];
             $this->api->feed_publish('group_create', $title_data, $body_data, $this->appId, 0, $gid);
             setScore($this->mid, 'group_create');
             //跟新空间计数
             //$count = D('Member')->where( 'uid='.$this->mid )->count();
             //$this->api->space_changeCount( 'group',$count );
             redirect(__APP__ . "Invite/create/gid/{$gid}/from/create");
         }
         $this->error('创建失败');
     }
 }