Example #1
0
 function do_recd()
 {
     Load::logic('topic_recommend');
     $TopicRecommendLogic = new TopicRecommendLogic();
     $tid = intval($this->Post['tid']);
     $topic = DB::fetch_first("SELECT * FROM " . DB::table("topic") . " WHERE tid='{$tid}'");
     if (empty($topic)) {
         json_error("当前微博不存在或者已经被删除了");
     }
     if ($topic['item'] == 'channel' && $topic['item_id'] > 0) {
         if (!function_exists('item_topic_from')) {
             jfunc('item');
         }
         $topic = item_topic_from($topic);
     }
     if (!($this->MemberHandler->HasPermission('topic', 'do_recd') || $topic['ismanager'])) {
         json_error("您的角色没有推荐微博的权限!");
     }
     $recd = intval($this->Post['recd'][0]);
     if ($recd > 4 || $recd < 0) {
         json_error("推荐类型错误");
     }
     if ($topic['item'] == 'qun' && $topic['item_id'] > 0) {
         Load::logic('qun');
         $QunLogic = new QunLogic();
         $tmp_perm = $QunLogic->chk_perm($topic['item_id'], MEMBER_ID);
         if (!('admin' == MEMBER_ROLE_TYPE || in_array($tmp_perm, array(1, 2)))) {
             json_error("你没有权限推荐群内微博");
         }
     }
     if ($recd == 0) {
         $topic_recd = $TopicRecommendLogic->delete(array($tid));
         json_result("0|||取消推荐成功!");
     } else {
         $expiration = jstrtotime(trim($this->Post['expiration']));
         $tag_id = intval($this->Post['tag_id']);
         $r_title = strip_tags(trim($this->Post['r_title']));
         if (!empty($tag_id)) {
             $count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('topic_tag') . " WHERE item_id='{$tid}' AND tag_id='{$tag_id}' ");
             if (!empty($count)) {
                 $topic['item'] = 'tag';
                 $topic['item_id'] = $tag_id;
             }
         }
         $item = $this->Post['item_id'] ? 'channel' : $topic['item'];
         $item_id = $this->Post['item_id'] ? intval($this->Post['item_id']) : $topic['item_id'];
         if (empty($r_title)) {
             json_error("推荐标题为空或内容不合法");
         }
         if ($expiration && $expiration < time()) {
             json_error("时间设置无效,请重新设置");
         }
         $data = array('expiration' => $expiration, 'item' => $item, 'item_id' => $item_id, 'tid' => $tid, 'recd' => $recd, 'dateline' => TIMESTAMP, 'r_uid' => MEMBER_ID, 'r_nickname' => MEMBER_NICKNAME, 'r_title' => $r_title);
         if ($TopicRecommendLogic->is_exists($tid)) {
             unset($data['tid']);
             $TopicRecommendLogic->modify($data, array('tid' => $tid));
             json_result("2|||重新推荐成功!");
         } else {
             $TopicRecommendLogic->add($data);
             feed_msg('recommend', 'recommend', $tid, $r_title, $item_id);
             if ($recd == 4) {
                 $iphone_msg = cut_str($topic['content'], 30, '');
                 ios_push_msg('all', $r_title . ':' . $iphone_msg);
             }
             $credits = jconf::get('credits');
             update_credits_by_action('recommend', $topic['uid']);
             json_result("1|||推荐成功!被推荐者因:" . $this->js_show_msg(1));
         }
     }
 }
Example #2
0
 function doedit()
 {
     $tid = intval($this->Post['tid']);
     $recd = intval($this->Post['recd'][0]);
     $r_title = strip_tags(trim($this->Post['r_title']));
     if (empty($r_title)) {
         $this->Messager("推荐标题为空或内容不合法");
     }
     if ($recd > 4 || $recd < 0) {
         $this->Messager("推荐等级错误");
     }
     $expiration = jstrtotime(trim($this->Post['expiration']));
     $data = array('recd' => $recd, 'expiration' => $expiration, 'r_title' => $r_title);
     if ($this->Post['item_id']) {
         $data['item'] = 'channel';
         $data['item_id'] = intval($this->Post['item_id']);
     }
     $this->TopicRecommendLogic->modify($data, array('tid' => $tid));
     $this->Messager("操作成功了", 'admin.php?mod=recdtopic');
 }
Example #3
0
 function modify_expiration($vid, $expiration)
 {
     $vid = (int) $vid;
     $expiration = jstrtotime(trim($expiration));
     if ($expiration <= TIMESTAMP) {
         return -1;
     }
     DB::update('vote', array('expiration' => $expiration), array('vid' => $vid));
     return 1;
 }