Beispiel #1
0
 public function parent_action()
 {
     $this->crumb(AWS_APP::lang()->_t('根话题'), 'admin/topic/parent/');
     $topic_list = $this->model('topic')->get_topic_list('is_parent = 1', 'topic_id DESC', $this->per_page, $_GET['page']);
     $total_rows = $this->model('topic')->found_rows();
     if ($topic_list) {
         foreach ($topic_list as $key => $topic_info) {
             $action_log = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 1, ACTION_LOG::CATEGORY_TOPIC, implode(',', array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_RELATED_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC)), -1);
             $action_log = $action_log[0];
             $topic_list[$key]['last_edited_uid'] = $action_log['uid'];
             $topic_list[$key]['last_edited_time'] = $action_log['add_time'];
             $last_edited_uids[] = $topic_list[$key]['last_edited_uid'];
         }
         $users_info_query = $this->model('account')->get_user_info_by_uids($last_edited_uids);
         foreach ($users_info_query as $user_info) {
             $users_info[$user_info['uid']] = $user_info;
         }
     }
     TPL::assign('pagination', AWS_APP::pagination()->initialize(array('base_url' => get_js_url('/admin/topic/parent/'), 'total_rows' => $total_rows, 'per_page' => $this->per_page))->create_links());
     TPL::assign('list', $topic_list);
     TPL::assign('users_info', $users_info);
     TPL::output('admin/topic/parent');
 }
Beispiel #2
0
 public function modify_question_action()
 {
     if (!($question_info = $this->model('question')->get_question_info_by_id($_POST['question_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题不存在')));
     }
     if ($question_info['lock'] and !($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题已锁定, 不能编辑')));
     }
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and !$this->user_info['permission']['edit_question']) {
         if ($question_info['published_uid'] != $this->user_id) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限编辑这个问题')));
         }
     }
     if (!$_POST['category_id'] and get_setting('category_enable') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择分类')));
     }
     if (cjk_strlen($_POST['question_content']) < 5) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得少于 5 个字')));
     }
     if (get_setting('question_title_limit') > 0 and cjk_strlen($_POST['question_content']) > get_setting('question_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得大于') . ' ' . get_setting('question_title_limit') . ' ' . AWS_APP::lang()->_t('字节')));
     }
     if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($_POST['question_detail'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     if (!$this->model('publish')->insert_attach_is_self_upload($_POST['question_detail'], $_POST['attach_ids'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
     }
     if (human_valid('question_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('draft')->delete_draft(1, 'question', $this->user_id);
     if ($_POST['do_delete'] and !$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('对不起, 你没有删除问题的权限')));
     }
     if ($_POST['do_delete']) {
         if ($this->user_id != $question_info['published_uid']) {
             $this->model('account')->send_delete_message($question_info['published_uid'], $question_info['question_content'], $question_info['question_detail']);
         }
         $this->model('question')->remove_question($question_info['question_id']);
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/home/explore/')), 1, null));
     }
     $IS_MODIFY_VERIFIED = TRUE;
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator'] and $question_info['published_uid'] != $this->user_id) {
         $IS_MODIFY_VERIFIED = FALSE;
     }
     $this->model('question')->update_question($question_info['question_id'], $_POST['question_content'], $_POST['question_detail'], $this->user_id, $IS_MODIFY_VERIFIED, $_POST['modify_reason'], $question_info['anonymous'], $_POST['category_id']);
     if ($this->user_id != $question_info['published_uid']) {
         $this->model('question')->add_focus_question($question_info['question_id'], $this->user_id);
         $this->model('notify')->send($this->user_id, $question_info['published_uid'], notify_class::TYPE_MOD_QUESTION, notify_class::CATEGORY_QUESTION, $question_info['question_id'], array('from_uid' => $this->user_id, 'question_id' => $question_info['question_id']));
         $this->model('email')->action_email('QUESTION_MOD', $question_info['published_uid'], get_js_url('/question/' . $question_info['question_id']), array('user_name' => $this->user_info['user_name'], 'question_title' => $question_info['question_content']));
     }
     if ($_POST['category_id'] and $_POST['category_id'] != $question_info['category_id']) {
         $category_info = $this->model('system')->get_category_info($_POST['category_id']);
         ACTION_LOG::save_action($this->user_id, $question_info['question_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::MOD_QUESTION_CATEGORY, $category_info['title'], $category_info['id']);
     }
     if ($_POST['attach_access_key'] and $IS_MODIFY_VERIFIED) {
         if ($this->model('publish')->update_attach('question', $question_info['question_id'], $_POST['attach_access_key'])) {
             ACTION_LOG::save_action($this->user_id, $question_info['question_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::MOD_QUESTION_ATTACH);
         }
     }
     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/question/' . $question_info['question_id'] . '?column=log&rf=false')), 1, null));
 }
Beispiel #3
0
 public function get_user_actions($uid, $limit = 10, $actions = false, $this_uid = 0)
 {
     $cache_key = 'user_actions_' . md5($uid . $limit . $actions . $this_uid);
     if ($user_actions = AWS_APP::cache()->get($cache_key)) {
         return $user_actions;
     }
     $associate_action = ACTION_LOG::ADD_QUESTION;
     if (strstr($actions, ',')) {
         $associate_action = explode(',', $actions);
         array_walk_recursive($associate_action, 'intval_string');
         $associate_action = implode(',', $associate_action);
     } else {
         if ($actions) {
             $associate_action = intval($actions);
         }
     }
     if (!$uid) {
         $where[] = "(associate_type = " . ACTION_LOG::CATEGORY_QUESTION . " AND associate_action IN(" . $this->quote($associate_action) . "))";
     } else {
         $where[] = "(associate_type = " . ACTION_LOG::CATEGORY_QUESTION . " AND uid = " . intval($uid) . " AND associate_action IN(" . $this->quote($associate_action) . "))";
     }
     if ($this_uid == $uid) {
         $show_anonymous = true;
     }
     $action_list = ACTION_LOG::get_action_by_where(implode($where, ' OR '), $limit, $show_anonymous);
     // 重组信息
     foreach ($action_list as $key => $val) {
         $uids[] = $val['uid'];
         switch ($val['associate_type']) {
             case ACTION_LOG::CATEGORY_QUESTION:
                 if (in_array($val['associate_action'], array(ACTION_LOG::ADD_ARTICLE, ACTION_LOG::ADD_COMMENT_ARTICLE))) {
                     $article_ids[] = $val['associate_id'];
                 } else {
                     $question_ids[] = $val['associate_id'];
                 }
                 if (in_array($val['associate_action'], array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_TOPIC_FOCUS)) and $val['associate_attached']) {
                     $associate_topic_ids[] = $val['associate_attached'];
                 }
                 break;
         }
     }
     if ($uids) {
         $action_list_users = $this->model('account')->get_user_info_by_uids($uids, true);
     }
     if ($question_ids) {
         $action_questions_info = $this->model('question')->get_question_info_by_ids($question_ids);
     }
     if ($associate_topic_ids) {
         $associate_topics = $this->model('topic')->get_topics_by_ids($associate_topic_ids);
     }
     if ($article_ids) {
         $action_articles_info = $this->model('article')->get_article_info_by_ids($article_ids);
     }
     foreach ($action_list as $key => $val) {
         $action_list[$key]['user_info'] = $action_list_users[$val['uid']];
         switch ($val['associate_type']) {
             case ACTION_LOG::CATEGORY_QUESTION:
                 switch ($val['associate_action']) {
                     case ACTION_LOG::ADD_ARTICLE:
                     case ACTION_LOG::ADD_COMMENT_ARTICLE:
                         $article_info = $action_articles_info[$val['associate_id']];
                         $action_list[$key]['title'] = $article_info['title'];
                         $action_list[$key]['link'] = get_js_url('/article/' . $article_info['id']);
                         $action_list[$key]['article_info'] = $article_info;
                         $action_list[$key]['last_action_str'] = ACTION_LOG::format_action_data($val['associate_action'], $val['uid'], $action_list_users[$val['uid']]['user_name']);
                         break;
                     default:
                         $question_info = $action_questions_info[$val['associate_id']];
                         $action_list[$key]['title'] = $question_info['question_content'];
                         $action_list[$key]['link'] = get_js_url('/question/' . $question_info['question_id']);
                         if (in_array($val['associate_action'], array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_TOPIC_FOCUS)) and $val['associate_attached']) {
                             $topic_info = $associate_topics[$val['associate_attached']];
                         } else {
                             unset($topic_info);
                         }
                         if (in_array($val['associate_action'], array(ACTION_LOG::ADD_QUESTION)) and $question_info['has_attach']) {
                             $question_info['attachs'] = $question_attachs[$question_info['question_id']];
                         }
                         if ($val['uid']) {
                             $action_list[$key]['last_action_str'] = ACTION_LOG::format_action_data($val['associate_action'], $val['uid'], $action_list_users[$val['uid']]['user_name'], $question_info, $topic_info);
                         }
                         if (in_array($val['associate_action'], array(ACTION_LOG::ANSWER_QUESTION)) and $question_info['answer_count']) {
                             if ($answer_list = $this->model('answer')->get_answer_by_id($val['associate_attached'])) {
                                 $action_list[$key]['answer_info'] = $answer_list;
                             }
                         }
                         $action_list[$key]['question_info'] = $question_info;
                         break;
                 }
                 break;
         }
     }
     AWS_APP::cache()->set($cache_key, $action_list, get_setting('cache_level_normal'));
     return $action_list;
 }
Beispiel #4
0
 public function article_vote($type, $item_id, $rating, $uid, $reputation_factor, $item_uid)
 {
     $this->delete('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . ' AND uid = ' . intval($uid));
     if ($rating) {
         if ($article_vote = $this->fetch_row('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = " . intval($rating) . ' AND uid = ' . intval($uid))) {
             $this->update('article_vote', array('rating' => intval($rating), 'time' => time(), 'reputation_factor' => $reputation_factor), 'id = ' . intval($article_vote['id']));
         } else {
             $this->insert('article_vote', array('type' => $type, 'item_id' => intval($item_id), 'rating' => intval($rating), 'time' => time(), 'uid' => intval($uid), 'item_uid' => intval($item_uid), 'reputation_factor' => $reputation_factor));
         }
     }
     switch ($type) {
         case 'article':
             $this->update('article', array('votes' => $this->count('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = 1")), 'id = ' . intval($item_id));
             switch ($rating) {
                 case 1:
                     ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_AGREE_ARTICLE);
                     break;
                 case -1:
                     ACTION_LOG::delete_action_history('associate_type = ' . ACTION_LOG::CATEGORY_QUESTION . ' AND associate_action = ' . ACTION_LOG::ADD_AGREE_ARTICLE . ' AND uid = ' . intval($uid) . ' AND associate_id = ' . intval($item_id));
                     break;
             }
             break;
         case 'comment':
             $this->update('article_comments', array('votes' => $this->count('article_vote', "`type` = '" . $this->quote($type) . "' AND item_id = " . intval($item_id) . " AND rating = 1")), 'id = ' . intval($item_id));
             break;
     }
     $this->model('account')->sum_user_agree_count($item_uid);
     return true;
 }
Beispiel #5
0
 public function redirect($uid, $item_id, $target_id = NULL)
 {
     if ($item_id == $target_id) {
         return false;
     }
     if (!$target_id) {
         if ($this->delete('redirect', 'item_id = ' . intval($item_id))) {
             return ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::DEL_REDIRECT_QUESTION);
         }
     } else {
         if ($question = $this->get_question_info_by_id($item_id)) {
             if (!$this->fetch_row('redirect', 'item_id = ' . intval($item_id) . ' AND target_id = ' . intval($target_id))) {
                 $redirect_id = $this->insert('redirect', array('item_id' => intval($item_id), 'target_id' => intval($target_id), 'time' => time(), 'uid' => intval($uid)));
                 ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::REDIRECT_QUESTION, $question['question_content'], $target_id);
                 return $redirect_id;
             }
         }
     }
 }
Beispiel #6
0
 public function remove_user_by_uid($uid, $remove_user_data = false)
 {
     $delete_tables = array('active_data', 'answer_uninterested', 'draft', 'education_experience', 'favorite', 'favorite_tag', 'integral_log', 'invitation', 'question_focus', 'question_uninterested', 'report', 'reputation_category', 'reputation_topic', 'related_links', 'topic_focus', 'weixin_login', 'work_experience', 'users_attrib', 'users_online', 'users_qq', 'users_sina', 'users_ucenter', 'users_weixin', 'users_google', 'users');
     $update_tables = array('redirect', 'topic_merge', 'topic_relation');
     if ($remove_user_data) {
         if ($user_answers = $this->query_all("SELECT answer_id FROM " . get_table('answer') . " WHERE uid = " . intval($uid))) {
             foreach ($user_answers as $key => $val) {
                 $answer_ids[] = $val['answer_id'];
             }
             $this->update('attach', array('item_id' => 0), "item_id IN (" . implode(',', $answer_ids) . ") AND item_type = 'answer'");
         }
         if ($user_articles = $this->query_all("SELECT id FROM " . get_table('article') . " WHERE uid = " . intval($uid))) {
             foreach ($user_articles as $key => $val) {
                 $this->model('article')->remove_article($val['id']);
             }
         }
         if ($user_questions = $this->query_all("SELECT question_id FROM " . get_table('question') . " WHERE published_uid = " . intval($uid))) {
             foreach ($user_questions as $key => $val) {
                 $this->model('question')->remove_question($val['question_id']);
             }
         }
         $update_tables[] = 'answer';
         $update_tables[] = 'article';
         $delete_tables[] = 'answer_comments';
         $delete_tables[] = 'answer_thanks';
         $delete_tables[] = 'article_comments';
         $delete_tables[] = 'article_vote';
         $delete_tables[] = 'question_comments';
         $delete_tables[] = 'question_thanks';
         if ($inbox_dialog = $this->fetch_all('inbox_dialog', 'recipient_uid = ' . intval($uid) . ' OR sender_uid = ' . intval($uid))) {
             foreach ($inbox_dialog as $key => $val) {
                 $this->delete('inbox', 'dialog_id = ' . $val['id']);
                 $this->delete('inbox_dialog', 'id = ' . $val['id']);
             }
         }
     } else {
         $update_tables[] = 'answer';
         $update_tables[] = 'answer_comments';
         $update_tables[] = 'answer_thanks';
         $update_tables[] = 'article';
         $update_tables[] = 'article_comments';
         $update_tables[] = 'article_vote';
         $update_tables[] = 'question_comments';
         $update_tables[] = 'question_thanks';
         $delete_tables[] = 'inbox';
         $this->update('question', array('published_uid' => '-1'), 'published_uid = ' . intval($uid));
     }
     foreach ($delete_tables as $key => $table) {
         $this->delete($table, 'uid = ' . intval($uid));
     }
     foreach ($update_tables as $key => $table) {
         $this->update($table, array('uid' => '-1'), 'uid = ' . intval($uid));
     }
     $this->update('answer_vote', array('vote_uid' => '-1'), 'vote_uid = ' . intval($uid));
     $this->model('verify')->remove_apply($uid);
     $this->model('notify')->delete_notify('sender_uid = ' . intval($uid) . ' OR recipient_uid = ' . intval($uid));
     $this->delete('question_invite', 'sender_uid = ' . intval($uid) . ' OR recipients_uid = ' . intval($uid));
     ACTION_LOG::delete_action_history('uid = ' . intval($uid));
     $this->delete('user_follow', 'fans_uid = ' . intval($uid) . ' OR friend_uid = ' . intval($uid));
     return true;
 }
 public function add_focus_question($question_id, $uid, $anonymous = 0, $save_action = true)
 {
     if (!$question_id or !$uid) {
         return false;
     }
     if (!$this->has_focus_question($question_id, $uid)) {
         if ($this->insert('question_focus', array('question_id' => intval($question_id), 'uid' => intval($uid), 'add_time' => time()))) {
             $this->update_focus_count($question_id);
         }
         // 璁板綍鏃ュ織
         if ($save_action) {
             ACTION_LOG::save_action($uid, $question_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_REQUESTION_FOCUS, '', '', 0, intval($anonymous));
         }
         return 'add';
     } else {
         // 鍑忓皯闂鍏虫敞鏁伴噺
         if ($this->delete_focus_question($question_id, $uid)) {
             $this->update_focus_count($question_id);
         }
         return 'remove';
     }
 }
Beispiel #8
0
 public function add_product_order_action()
 {
     if (!($project_info = $this->model('project')->get_project_info_by_id($_POST['project_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('项目不存在')));
     }
     if ($project_info['approved'] != 1) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目未通过审核')));
     }
     if ($project_info['start_time'] > time()) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目处于预热中,尚未开始')));
     }
     if ($project_info['end_time'] < time()) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('当前项目已经结束')));
     }
     switch ($project_info['project_type']) {
         case 'DEFAULT':
             if (!($product_info = $this->model('project')->get_product_info_by_id($_POST['product_id']))) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('指定商品不存在')));
             }
             if ($_POST['is_donate'] != 1 and (!$_POST['shipping_name'] or !$_POST['shipping_address'] or !$_POST['shipping_province'] or !$_POST['shipping_city'] or !$_POST['shipping_mobile'] or !$_POST['shipping_zipcode'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善收货信息')));
             }
             if (intval($product_info['amount']) == 0 and isset($_POST['amount']) and (!preg_match('/^\\d+(\\.\\d{1,2})?$/', $_POST['amount']) or intval($_POST['amount']) <= 0)) {
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入正确的金额')));
             }
             if ($order_id = $this->model('project')->add_project_order($this->user_id, $product_info['id'], $_POST['shipping_name'], $_POST['shipping_province'], $_POST['shipping_city'], $_POST['shipping_address'], $_POST['shipping_zipcode'], $_POST['shipping_mobile'], $_POST['is_donate'], $_POST['note'], $_POST['amount'])) {
                 // Modify by wecenter
                 ACTION_LOG::save_action($this->user_id, $product_info['project_id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_SUPPORT_PROJECT, '', $product_info['id']);
                 if ($this->model('project')->get_like_status_by_uid($product_info['project_id'], $this->user_id)) {
                     $this->model('project')->unset_project_like($product_info['project_id'], $this->user_id);
                 }
                 if (intval($product_info['amount']) == 0 and intval($_POST['amount']) == 0) {
                     $this->model('payment')->set_order_payment_time($order_id);
                     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/project/sponsored/')), 1, null));
                 } else {
                     /*if (is_mobile())
                     		{
                     			$url = get_js_url('/m/add_project_order/' . $order_id);
                     		}
                     		else
                     		{*/
                     $url = get_js_url('/project/order/init_payment/' . $order_id);
                     //}
                     H::ajax_json_output(AWS_APP::RSM(array('url' => $url), 1, null));
                 }
             } else {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('订单生产失败,库存不足')));
             }
             break;
         case 'EVENT':
             if (!$_POST['name'] or !$_POST['mobile'] or !$_POST['email'] or !$_POST['address']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善报名信息')));
             }
             if ($this->model('project')->get_single_project_order_by_uid($this->user_id, $project_info['id'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个活动只允许报名一次, 你已经报名')));
             }
             $this->model('project')->add_project_event($project_info['id'], $this->user_id, 0, $_POST['name'], $_POST['mobile'], $_POST['email'], $_POST['address']);
             H::ajax_json_output(AWS_APP::RSM(null, 1, null));
             break;
         case 'STOCK':
             if (!$_POST['amount'] or !$_POST['name'] or !$_POST['mobile'] or !$_POST['email']) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请完善报名信息')));
             }
             if ($this->model('project')->get_single_project_order_by_uid($this->user_id, $project_info['id'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('一个活动只允许报名一次, 你已经报名')));
             }
             $this->model('project')->add_project_event($project_info['id'], $this->user_id, $_POST['amount'], $_POST['name'], $_POST['mobile'], $_POST['email']);
             H::ajax_json_output(AWS_APP::RSM(null, 1, null));
             break;
     }
     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('项目类型错误')));
 }
Beispiel #9
0
 public function publish_article($title, $message, $uid, $topics = null, $category_id = null, $attach_access_key = null, $create_topic = true)
 {
     if ($article_id = $this->insert('article', array('uid' => intval($uid), 'title' => htmlspecialchars($title), 'message' => htmlspecialchars($message), 'category_id' => intval($category_id), 'add_time' => time()))) {
         set_human_valid('question_valid_hour');
         if (is_array($topics)) {
             foreach ($topics as $key => $topic_title) {
                 $topic_id = $this->model('topic')->save_topic($topic_title, $uid, $create_topic);
                 $this->model('topic')->save_topic_relation($uid, $topic_id, $article_id, 'article');
             }
         }
         if ($attach_access_key) {
             $this->model('publish')->update_attach('article', $article_id, $attach_access_key);
         }
         $this->model('search_fulltext')->push_index('article', $title, $article_id);
         // 记录日志
         ACTION_LOG::save_action($uid, $article_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_ARTICLE, htmlspecialchars($title), htmlspecialchars($message), 0);
         $this->model('posts')->set_posts_index($article_id, 'article');
     }
     return $article_id;
 }
Beispiel #10
0
 public function publish_article_comment($article_id, $message, $uid, $at_uid = null)
 {
     if (!($article_info = $this->model('article')->get_article_info_by_id($article_id))) {
         return false;
     }
     $comment_id = $this->insert('article_comments', array('uid' => intval($uid), 'article_id' => intval($article_id), 'message' => htmlspecialchars($message), 'add_time' => time(), 'at_uid' => intval($at_uid)));
     $this->update('article', array('comments' => $this->count('article_comments', 'article_id = ' . intval($article_id))), 'id = ' . intval($article_id));
     if ($at_uid and $at_uid != $uid) {
         $this->model('notify')->send($uid, $at_uid, notify_class::TYPE_ARTICLE_COMMENT_AT_ME, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $comment_id));
     }
     if ($at_users = $this->model('question')->parse_at_user($message, false, true)) {
         foreach ($at_users as $user_id) {
             if ($user_id != $uid) {
                 $this->model('notify')->send($uid, $user_id, notify_class::TYPE_ARTICLE_COMMENT_AT_ME, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $answer_id));
             }
         }
     }
     set_human_valid('answer_valid_hour');
     if ($article_info['uid'] != $uid) {
         $this->model('notify')->send($uid, $article_info['uid'], notify_class::TYPE_ARTICLE_NEW_COMMENT, notify_class::CATEGORY_ARTICLE, $article_info['id'], array('from_uid' => $uid, 'article_id' => $article_info['id'], 'item_id' => $comment_id));
     }
     if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_uid($article_info['uid']) and $article_info['uid'] != $uid) {
         $weixin_user_info = $this->model('account')->get_user_info_by_uid($weixin_user['uid']);
         if ($weixin_user_info['weixin_settings']['NEW_ARTICLE_COMMENT'] != 'N') {
             $this->model('weixin')->send_text_message($weixin_user['openid'], "您的文章 [" . $article_info['title'] . "] 收到了新的评论:\n\n" . strip_tags($message), $this->model('openid_weixin_weixin')->redirect_url('/article/' . $article_info['id']));
         }
     }
     ACTION_LOG::save_action($uid, $article_info['id'], ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_COMMENT_ARTICLE, $message, $comment_id);
     $this->model('posts')->set_posts_index($article_info['id'], 'article');
     return $comment_id;
 }
 public function save_topic_relation($uid, $topic_id, $item_id, $type)
 {
     if (!$topic_id or !$item_id or !$type) {
         return false;
     }
     if (!($topic_info = $this->get_topic_by_id($topic_id))) {
         return false;
     }
     if ($flag = $this->check_topic_relation($topic_id, $item_id, $type)) {
         return $flag;
     }
     switch ($type) {
         case 'question':
             ACTION_LOG::save_action($uid, $item_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_TOPIC, $topic_info['topic_title'], $topic_id);
             ACTION_LOG::save_action($uid, $topic_id, ACTION_LOG::CATEGORY_TOPIC, ACTION_LOG::ADD_TOPIC, $topic_info['topic_title'], $item_id);
             break;
     }
     $this->model('account')->save_recent_topics($uid, $topic_info['topic_title']);
     $insert_id = $this->insert('topic_relation', array('topic_id' => intval($topic_id), 'item_id' => intval($item_id), 'add_time' => time(), 'uid' => intval($uid), 'type' => $type));
     $this->model('topic')->update_discuss_count($topic_id);
     return $insert_id;
 }
Beispiel #12
0
 public function user_rate($type, $answer_id, $uid, $user_name)
 {
     switch ($type) {
         default:
             return false;
             break;
         case 'thanks':
         case 'uninterested':
             break;
     }
     if ($user_rated = $this->user_rated($type, $answer_id, $uid)) {
         if ($type == 'thanks') {
             return true;
         }
         $this->delete('answer_' . $type, 'uid = ' . intval($uid) . ' AND answer_id = ' . intval($answer_id));
     } else {
         $this->insert('answer_' . $type, array('uid' => $uid, 'answer_id' => $answer_id, 'user_name' => $user_name, 'time' => time()));
     }
     $this->update_user_rate_count($type, $answer_id);
     $answer_info = $this->get_answer_by_id($answer_id);
     if ($type == 'thanks') {
         $this->model('integral')->process($uid, 'ANSWER_THANKS', get_setting('integral_system_config_thanks'), '感谢回复 #' . $answer_info['answer_id'], $answer_info['answer_id']);
         $this->model('integral')->process($answer_info['uid'], 'THANKS_ANSWER', -get_setting('integral_system_config_thanks'), '回复被感谢 #' . $answer_info['answer_id'], $answer_info['answer_id']);
     } else {
         if ($answer_info['uninterested_count'] >= get_setting('uninterested_fold')) {
             if (!$this->model('integral')->fetch_log($answer_info['uid'], 'ANSWER_FOLD_' . $answer_info['answer_id'])) {
                 ACTION_LOG::set_fold_action_history($answer_info['answer_id'], 1);
                 $this->model('integral')->process($answer_info['uid'], 'ANSWER_FOLD_' . $answer_info['answer_id'], get_setting('integral_system_config_answer_fold'), '回复折叠 #' . $answer_info['answer_id']);
             }
         }
     }
     $this->model('account')->update_thanks_count($answer_info['uid']);
     return !$user_rated;
 }
Beispiel #13
0
 public function index_action()
 {
     if (is_mobile()) {
         HTTP::redirect('/m/topic/' . $_GET['id']);
     }
     if (is_digits($_GET['id'])) {
         if (!($topic_info = $this->model('topic')->get_topic_by_id($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_title($_GET['id']);
         }
     } else {
         if (!($topic_info = $this->model('topic')->get_topic_by_title($_GET['id']))) {
             $topic_info = $this->model('topic')->get_topic_by_url_token($_GET['id']);
         }
     }
     if (!$topic_info) {
         header('HTTP/1.1 404 Not Found');
         H::redirect_msg(AWS_APP::lang()->_t('话题不存在'), '/');
     }
     if ($topic_info['merged_id'] and $topic_info['merged_id'] != $topic_info['topic_id']) {
         if ($this->model('topic')->get_topic_by_id($topic_info['merged_id'])) {
             HTTP::redirect('/topic/' . $topic_info['merged_id'] . '?rf=' . $topic_info['topic_id']);
         } else {
             $this->model('topic')->remove_merge_topic($topic_info['topic_id'], $topic_info['merged_id']);
         }
     }
     if (urldecode($topic_info['url_token']) != $_GET['id']) {
         HTTP::redirect('/topic/' . $topic_info['url_token'] . '?rf=' . $_GET['rf']);
     }
     if (is_digits($_GET['rf']) and $_GET['rf']) {
         if ($from_topic = $this->model('topic')->get_topic_by_id($_GET['rf'])) {
             $redirect_message[] = AWS_APP::lang()->_t('话题 (%s) 已与当前话题合并', $from_topic['topic_title']);
         }
     }
     if ($topic_info['seo_title']) {
         TPL::assign('page_title', $topic_info['seo_title']);
     } else {
         $this->crumb($topic_info['topic_title'], '/topic/' . $topic_info['url_token']);
     }
     if ($this->user_id) {
         $topic_info['has_focus'] = $this->model('topic')->has_focus_topic($this->user_id, $topic_info['topic_id']);
     }
     if ($topic_info['topic_description']) {
         TPL::set_meta('description', $topic_info['topic_title'] . ' - ' . cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...'));
     }
     $topic_info['topic_description'] = nl2br(FORMAT::parse_bbcode($topic_info['topic_description']));
     TPL::assign('topic_info', $topic_info);
     TPL::assign('best_answer_users', $this->model('topic')->get_best_answer_users_by_topic_id($topic_info['topic_id'], 5));
     switch ($topic_info['model_type']) {
         default:
             $related_topics_ids = array();
             $page_keywords[] = $topic_info['topic_title'];
             if ($related_topics = $this->model('topic')->related_topics($topic_info['topic_id'])) {
                 foreach ($related_topics as $key => $val) {
                     $related_topics_ids[$val['topic_id']] = $val['topic_id'];
                     $page_keywords[] = $val['topic_title'];
                 }
             }
             TPL::set_meta('keywords', implode(',', $page_keywords));
             TPL::set_meta('description', cjk_substr(str_replace("\r\n", ' ', strip_tags($topic_info['topic_description'])), 0, 128, 'UTF-8', '...'));
             if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($topic_info['topic_id'])) {
                 foreach ($child_topic_ids as $key => $topic_id) {
                     $related_topics_ids[$topic_id] = $topic_id;
                 }
             }
             TPL::assign('related_topics', $related_topics);
             $log_list = ACTION_LOG::get_action_by_event_id($topic_info['topic_id'], 10, ACTION_LOG::CATEGORY_TOPIC, implode(',', array(ACTION_LOG::ADD_TOPIC, ACTION_LOG::MOD_TOPIC, ACTION_LOG::MOD_TOPIC_DESCRI, ACTION_LOG::MOD_TOPIC_PIC, ACTION_LOG::DELETE_TOPIC, ACTION_LOG::ADD_RELATED_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC)), -1);
             $log_list = $this->model('topic')->analysis_log($log_list);
             $contents_topic_id = $topic_info['topic_id'];
             $contents_topic_title = $topic_info['topic_title'];
             if ($merged_topics = $this->model('topic')->get_merged_topic_ids($topic_info['topic_id'])) {
                 foreach ($merged_topics as $key => $val) {
                     $merged_topic_ids[] = $val['source_id'];
                 }
                 $contents_topic_id .= ',' . implode(',', $merged_topic_ids);
                 if ($merged_topics_info = $this->model('topic')->get_topics_by_ids($merged_topic_ids)) {
                     foreach ($merged_topics_info as $key => $val) {
                         $merged_topic_title[] = $val['topic_title'];
                     }
                 }
                 if ($merged_topic_title) {
                     $contents_topic_title .= ',' . implode(',', $merged_topic_title);
                 }
             }
             $contents_related_topic_ids = array_merge($related_topics_ids, explode(',', $contents_topic_id));
             TPL::assign('contents_related_topic_ids', implode(',', $contents_related_topic_ids));
             if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), 'new', $contents_related_topic_ids)) {
                 foreach ($posts_list as $key => $val) {
                     if ($val['answer_count']) {
                         $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
                     }
                 }
             }
             TPL::assign('posts_list', $posts_list);
             TPL::assign('all_list_bit', TPL::output('explore/ajax/list', false));
             if ($posts_list = $this->model('posts')->get_posts_list(null, 1, get_setting('contents_per_page'), null, $contents_related_topic_ids, null, null, 30, true)) {
                 foreach ($posts_list as $key => $val) {
                     if ($val['answer_count']) {
                         $posts_list[$key]['answer_users'] = $this->model('question')->get_answer_users_by_question_id($val['question_id'], 2, $val['published_uid']);
                     }
                 }
             }
             TPL::assign('topic_recommend_list', $posts_list);
             TPL::assign('posts_list', $posts_list);
             TPL::assign('recommend_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('list', $this->model('topic')->get_topic_best_answer_action_list($contents_topic_id, $this->user_id, get_setting('contents_per_page')));
             TPL::assign('best_questions_list_bit', TPL::output('home/ajax/index_actions', false));
             TPL::assign('posts_list', $this->model('posts')->get_posts_list('question', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             TPL::assign('all_questions_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('posts_list', $this->model('posts')->get_posts_list('article', 1, get_setting('contents_per_page'), 'new', explode(',', $contents_topic_id)));
             TPL::assign('articles_list_bit', TPL::output('explore/ajax/list', false));
             TPL::assign('contents_topic_id', $contents_topic_id);
             TPL::assign('contents_topic_title', $contents_topic_title);
             TPL::assign('log_list', $log_list);
             TPL::assign('redirect_message', $redirect_message);
             if ($topic_info['parent_id']) {
                 TPL::assign('parent_topic_info', $this->model('topic')->get_topic_by_id($topic_info['parent_id']));
             }
             TPL::output('topic/index');
             break;
     }
 }
Beispiel #14
0
 public function set_project_like($project_id, $uid)
 {
     if (!$project_id or !$uid) {
         return false;
     }
     if ($this->get_like_status_by_uid($project_id, $uid)) {
         return false;
     }
     $like_id = $this->insert('project_like', array('project_id' => intval($project_id), 'uid' => intval($uid), 'add_time' => time()));
     $this->update('project', array('like_count' => $this->count('project_like', 'project_id = ' . intval($project_id))), 'id = ' . intval($project_id));
     // Modify by wecenter
     ACTION_LOG::save_action($uid, $project_id, ACTION_LOG::CATEGORY_QUESTION, ACTION_LOG::ADD_LIKE_PROJECT);
     return $like_id;
 }
Beispiel #15
0
 public function remove_related_topic_action()
 {
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         if (!$this->user_info['permission']['edit_topic']) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
         } else {
             if ($this->model('topic')->has_lock_topic($_GET['topic_id'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定的话题不能编辑')));
             }
         }
     }
     $this->model('topic')->remove_related_topic($_GET['topic_id'], $_GET['related_id']);
     ACTION_LOG::save_action($this->user_id, $_GET['topic_id'], ACTION_LOG::CATEGORY_TOPIC, ACTION_LOG::DELETE_RELATED_TOPIC, '', $_GET['related_id']);
     H::ajax_json_output(AWS_APP::RSM(null, 1, null));
 }
Beispiel #16
0
 public function process_list_data($favorite_items)
 {
     if (!$favorite_items) {
         return false;
     }
     foreach ($favorite_items as $key => $data) {
         switch ($data['type']) {
             case 'answer':
                 $answer_ids[] = $data['item_id'];
                 break;
             case 'article':
                 $article_ids[] = $data['item_id'];
                 break;
         }
     }
     if ($answer_ids) {
         if ($answer_infos = $this->model('answer')->get_answers_by_ids($answer_ids)) {
             foreach ($answer_infos as $key => $data) {
                 $question_ids[$val['question_id']] = $data['question_id'];
                 $favorite_uids[$data['uid']] = $data['uid'];
             }
             $answer_attachs = $this->model('publish')->get_attachs('answer', $answer_ids, 'min');
             $question_infos = $this->model('question')->get_question_info_by_ids($question_ids);
         }
     }
     if ($article_ids) {
         if ($article_infos = $this->model('article')->get_article_info_by_ids($article_ids)) {
             foreach ($article_infos as $key => $data) {
                 $favorite_uids[$data['uid']] = $data['uid'];
             }
         }
     }
     $users_info = $this->model('account')->get_user_info_by_uids($favorite_uids);
     foreach ($favorite_items as $key => $data) {
         switch ($data['type']) {
             case 'answer':
                 $favorite_list_data[$key]['title'] = $question_infos[$answer_infos[$data['item_id']]['question_id']]['question_content'];
                 $favorite_list_data[$key]['link'] = get_js_url('/question/' . $answer_infos[$data['item_id']]['question_id'] . '?rf=false&item_id=' . $data['item_id'] . '#!answer_' . $data['item_id']);
                 $favorite_list_data[$key]['add_time'] = $question_infos[$answer_infos[$data['item_id']]['question_id']]['add_time'];
                 $favorite_list_data[$key]['answer_info'] = $answer_infos[$data['item_id']];
                 if ($favorite_list_data[$key]['answer_info']['has_attach']) {
                     $favorite_list_data[$key]['answer_info']['attachs'] = $answer_attachs[$data['item_id']];
                 }
                 $favorite_list_data[$key]['question_info'] = $question_infos[$answer_infos[$data['item_id']]['question_id']];
                 $favorite_list_data[$key]['user_info'] = $users_info[$answer_infos[$data['item_id']]['uid']];
                 break;
             case 'article':
                 $favorite_list_data[$key]['title'] = $article_infos[$data['item_id']]['title'];
                 $favorite_list_data[$key]['link'] = get_js_url('/article/' . $data['item_id']);
                 $favorite_list_data[$key]['add_time'] = $article_infos[$data['item_id']]['add_time'];
                 $favorite_list_data[$key]['article_info'] = $article_infos[$data['item_id']];
                 $favorite_list_data[$key]['last_action_str'] = ACTION_LOG::format_action_data(ACTION_LOG::ADD_ARTICLE, $data['uid'], $users_info[$data['uid']]['user_name']);
                 $favorite_list_data[$key]['user_info'] = $users_info[$article_infos[$data['item_id']]['uid']];
                 break;
         }
         $favorite_list_data[$key]['item_id'] = $data['item_id'];
         $favorite_list_data[$key]['item_type'] = $data['type'];
     }
     return $favorite_list_data;
 }
Beispiel #17
0
 public function answer_force_fold_action()
 {
     if (!$this->user_info['permission']['is_moderator'] and !$this->user_info['permission']['is_administortar']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限进行此操作')));
     }
     $answer_info = $this->model('answer')->get_answer_by_id($_POST['answer_id']);
     if (!$answer_info) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('回复不存在')));
     }
     if (!$answer_info['force_fold']) {
         $this->model('answer')->update_answer_by_id($_POST['answer_id'], array('force_fold' => 1));
         if (!$this->model('integral')->fetch_log($answer_info['uid'], 'ANSWER_FOLD_' . $answer_info['answer_id'])) {
             ACTION_LOG::set_fold_action_history($answer_info['answer_id'], 1);
             $this->model('integral')->process($answer_info['uid'], 'ANSWER_FOLD_' . $answer_info['answer_id'], get_setting('integral_system_config_answer_fold'), AWS_APP::lang()->_t('回复折叠') . ' #' . $answer_info['answer_id']);
         }
         H::ajax_json_output(AWS_APP::RSM(array('action' => 'fold'), 1, AWS_APP::lang()->_t('强制折叠回复')));
     } else {
         $this->model('answer')->update_answer_by_id($_POST['answer_id'], array('force_fold' => 0));
         H::ajax_json_output(AWS_APP::RSM(array('action' => 'unfold'), 1, AWS_APP::lang()->_t('撤销折叠回复')));
     }
 }