Exemple #1
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(1);
     $options = "";
     EClassApi::getCats();
     $where = '';
     $group_id = Url::get('group_id', '');
     $group_name = Url::get('group_name', '');
     if ($group_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$group_id}' ";
         $arrVar['group_id'] = $group_id;
     }
     if ($group_name) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " name = '{$group_name}' ";
         $arrVar['group_name'] = $group_name;
     }
     $item_per_page = 50;
     $limit = '';
     $sql_count = "SELECT COUNT(*) AS total FROM products_extra_fields_group {$where}";
     $total = DB::fetch($sql_count, 'total', 0);
     if ($total) {
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Nhóm trường', 'Trang');
         $re = DB::query("SELECT * FROM products_extra_fields_group {$where} order by id desc  {$limit}");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $products_extra_fields_group[$row['id']] = $row;
             }
         }
     }
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     print_category($categories, 0, $options);
     //}
     $arrVar['options'] = $options;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['paging'] = $paging;
     $arrVar['products_extra_fields_group'] = $products_extra_fields_group;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterAdd', $arrVar);
     $this->endForm();
 }
Exemple #2
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(0);
     EClassApi::getCats();
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     $arrVar['zones'] = CGlobal::$allZones;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterSync', $arrVar);
     $this->endForm();
 }
Exemple #3
0
 function getItemVipCat()
 {
     EClassApi::getCities();
     EClassApi::getCats();
     //get ID VIP CAT
     if (MEMCACHE_ON) {
         $category_id = CGlobal::$curCategory;
         $id_vip_cat = eb_memcache::do_get("id_vip_cat:{$category_id}");
         if (!$id_vip_cat || $id_vip_cat['ex_time'] < TIME_NOW) {
             $id_vip_cat = $this->getIdVipCat();
             eb_memcache::do_put("id_vip_cat:{$category_id}", $id_vip_cat);
         }
     } else {
         $id_vip_cat = $this->getIdVipCat();
     }
     $str_item_id = '';
     if (isset($id_vip_cat['id'])) {
         foreach ($id_vip_cat['id'] as $val) {
             $str_item_id .= $str_item_id != '' ? ",{$val}" : "{$val}";
         }
     }
     $items = array();
     if ($str_item_id != '') {
         $sql = 'SELECT id, name, up_time, created_time, user_id, user_name, description, city_id, category_id, currency_id, price, original_image_url, img_server FROM item WHERE';
         $where = '';
         $where .= ($where != '' ? " AND " : "") . " id IN({$str_item_id})";
         $where .= ($where != '' ? " AND " : "") . " (status=1 OR status = 2)";
         $sql .= "{$where} ORDER BY up_time DESC";
         $items = array();
         $re = DB::query($sql);
         if ($re) {
             while ($value = mysql_fetch_assoc($re)) {
                 $value['price'] = EClassApi::convertCurrency($value['price'], $value['currency_id']);
                 $value['currency_id'] = 1;
                 if (isset(CGlobal::$allCategories[$value['category_id']])) {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']) . '&nice_name=' . CGlobal::$allCategories[$value['category_id']]['nice_name']);
                 } else {
                     $value['href'] = WEB_DIR . ECRewrite::formatUrl('?page=item_detail&id=' . $value['id'] . '&ebname=' . EClassApi::safe_title($value['name']));
                 }
                 $value['item_time'] = date('h:i | d.m', $value['created_time']);
                 $value['price_name'] = 'Giá bán';
                 $value['item_type'] = 'Giao dịch bán';
                 $value['name'] = strip_tags(EClassApi::filter_title($value['name']));
                 if ($value['price'] && $value['price'] > 0) {
                     $value['price'] = number_format($value['price'], 0, ',', '.');
                     $value['currency_id'] = CGlobal::$currency[$value['currency_id']];
                 } else {
                     $value['price'] = 'Liên hệ';
                     $value['currency_id'] = '';
                 }
                 if ($value['original_image_url']) {
                     $value['original_image_url'] = EClassApi::getImageThumb($value['original_image_url'], 80, 80, 0, $value['img_server']);
                 } else {
                     $value['original_image_url'] = 'style/images/no-images-69x53.jpg';
                 }
                 $value['profile_url'] = WEB_DIR . $value['user_name'];
                 $value['user_name_title'] = $value['user_name'];
                 $value['user_name'] = strlen($value['user_name']) > 10 ? substr($value['user_name'], 0, 10) . '...' : $value['user_name'];
                 if (isset(CGlobal::$cities[$value['city_id']])) {
                     $value['city'] = CGlobal::$cities[$value['city_id']]['name'];
                 } else {
                     $value['city'] = "Toàn quốc";
                 }
                 $value['vip_cat_img'] = "style/images/item-list/item_vip.gif";
                 $value['can_buy'] = 0;
                 $items[$value['id']] = $value;
             }
         }
     }
     //        $items['str_item_id'] = $str_item_id;
     return $items;
 }
Exemple #4
0
 function build_rss()
 {
     $arr_cat = array(293);
     // dinh nghia mang cho cac danh muc co so luong tin nhieu
     $limit = 100;
     // mac dinh ban dau
     $limits = 200;
     // so luong ban ghi cho danh muc co nhieu tin
     $category_name = EClassApi::getParam('ebname');
     $category_id = EClassApi::getParam('cat_id');
     EClassApi::getCats();
     if ($category_name != "" && $category_id == "") {
         foreach (CGlobal::$allCategories as $cat) {
             if ($cat['parent_id'] == 0 && EClassApi::safe_title($cat['name']) == $category_name) {
                 $category = $cat;
                 break;
             }
         }
         header("Location:" . WEB_ROOT . "rss/c" . $category['id'] . "_" . $category_name . ".rss");
     }
     foreach (CGlobal::$allCategories as $cat) {
         if ($cat['parent_id'] == 0 && $cat['id'] == $category_id) {
             $category = $cat;
             break;
         }
     }
     if ($category) {
         $cat_id = $category['id'];
         $cat_name = trim(XMLLib::_xml_encode_attribute($category['name']));
         $subDir = 'rss1';
         $cachefile = 'rss1_' . $cat_id;
         header("content-type: text/xml");
         if (StaticCache::notExistCache($cachefile, 3600, false, $subDir)) {
             if (in_array($cat_id, $arr_cat)) {
                 $limit = $limits;
             }
             StaticCache::startCache();
             $rss = $this->build_rss_cat($cat_id, $cat_name, $limit);
             echo $rss;
             StaticCache::endCache();
         }
         //echo 'a';
     } else {
         REWRITE_ON ? header("Location:" . WEB_ROOT . "rss/") : header("Location:" . WEB_ROOT . "?page=rss");
     }
     System::halt();
 }
Exemple #5
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm();
     EClassApi::getCats();
     $where = '';
     $filter_id = Url::get('filter_id', '');
     $filter_name = Url::get('filter_name', '');
     $cat_product_id = Url::get('cat_product_id', '');
     $zone_id = Url::get('zone_id', '');
     $arrVar['zone_id'] = $zone_id;
     $arrVar['cat_product_id'] = $cat_product_id;
     if ($filter_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " id = '{$filter_id}' ";
         $arrVar['filter_id'] = $filter_id;
     }
     if ($filter_name) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " filter_name = '{$filter_name}' ";
         $arrVar['filter_name'] = $filter_name;
     }
     if ($cat_product_id) {
         $where .= ($where != '' ? ' AND ' : 'WHERE ') . " cat_product_id = '{$cat_product_id}' ";
     } else {
         if ($zone_id) {
             $where .= ($where != '' ? ' AND ' : 'WHERE ') . " zone_id = '{$zone_id}' ";
         }
     }
     $item_per_page = 50;
     $limit = '';
     $item_vips = array();
     $sql_count = "SELECT COUNT(*) AS total FROM products_filter {$where} ";
     $total = DB::fetch($sql_count, 'total', 0);
     $paging = '';
     $filters = array();
     if ($total) {
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 20, 'page_no', true);
         $re = DB::query("SELECT * FROM products_filter {$where} order by orders {$limit}");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $filters[$row['id']] = $row;
             }
         }
     }
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     print_category($categories, 0, $options, $zone_id, $cat_product_id);
     $arrVar['options'] = $options;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['filters'] = $filters;
     $arrVar['paging'] = $paging;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilter', $arrVar);
     $this->endForm();
 }
Exemple #6
0
 function fn_del_tag_search()
 {
     if (!User::have_permit(ADMIN_TAG_SEARCH)) {
         echo "no_perm";
         exit;
     }
     EClassApi::getCats();
     $id = (int) Url::get('id', 0);
     $cat_id = (int) Url::get('cat_id', 0);
     $cat_parent_id = CGlobal::$allCategories[$cat_id]["parent_id"];
     if ($id > 0) {
         require_once 'modules/ItemDetail/forms/ItemDetail.php';
         $id_del = DB::query("DELETE FROM tag_search WHERE id=" . $id);
         if ($id_del) {
             ItemDetailForm::get_tag_search($cat_id, $cat_parent_id, 1, 0);
             echo $id;
             exit;
         }
     }
 }
Exemple #7
0
 function draw()
 {
     global $display;
     $arrVar = array();
     $this->beginForm(1);
     $arrVar['id'] = Url::get('id', 0);
     $options = "";
     if ($arrVar['id'] == 0) {
         Url::redirect_current();
     }
     EClassApi::getCats();
     $where = '';
     $filter = DB::fetch_all_array("select * from products_filter where id={$arrVar['id']}");
     $filte_value = json_decode($filter[0]['filter_value']);
     $arrVar['filter'] = $filter[0];
     $arrVar['filter_value'] = $filte_value;
     $item_per_page = 50;
     $limit = '';
     $sql_count = "SELECT COUNT(*) AS total FROM products_extra_fields_group {$where}";
     $total = DB::fetch($sql_count, 'total', 0);
     if ($total) {
         require_once ROOT_PATH . 'core/ECPagging.php';
         $paging = ECPagging::pagingSE($limit, $total, $item_per_page, 10, 'page_no', true, 'Nhóm trường', 'Trang');
         $re = DB::query("SELECT * FROM products_extra_fields_group {$where} order by id desc  {$limit}");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $products_extra_fields_group[$row['id']] = $row;
             }
         }
     }
     $filter_count = 0;
     foreach ($filte_value as $key => $val) {
         if ($filter_count < $val->order) {
             $filter_count = $val->order;
         }
     }
     if (count($filte_value) > $filter_count) {
         $filter_count = count($filte_value);
     }
     $categories = eb_memcache::do_get('categories_new');
     if (!is_array($categories)) {
         //if($total){
         require_once ROOT_PATH . 'core/ECPagging.php';
         $re = DB::query("SELECT * FROM products_category  order by orders");
         if ($re) {
             while ($row = mysql_fetch_assoc($re)) {
                 $categories[$row['parent_id']][$row['id']] = $row;
             }
         }
         eb_memcache::do_put('categories_new', $categories);
     }
     print_category($categories, 0, $options, $filter[0]['zone_id'], $filter[0]['cat_product_id']);
     $arrVar['options'] = $options;
     $arrVar['filter_count'] = $filter_count;
     $arrVar['zones'] = CGlobal::$allZones;
     $arrVar['paging'] = $paging;
     $arrVar['products_extra_fields_group'] = $products_extra_fields_group;
     $display->templateAdvance = TRUE;
     $display->setTemplate('ManageFilterEdit', $arrVar);
     $this->endForm();
 }
Exemple #8
0
 function show_all_notify()
 {
     global $display;
     EClassApi::getCats();
     $feed_follows = array();
     //hoạt động của các thành viên mà mình theo đuôi
     $follow_ids = '';
     //hoạt động của các thành viên mà mình theo đuôi
     $action = Url::get('action');
     $num_per_page = 20;
     $ajax_mod = (int) (Url::get('act') == 'shop_giaodich');
     $page_no = 1;
     $cur_group = 0;
     $all_feeds = array();
     //Lưu mảng tất cả các cập nhật
     $all_feed_ars = array();
     //mảng các cập nhật đã đc sắp xếp, xử lý
     $user_arr = array();
     //Mảng các user
     $item_arr = array();
     //Mảng các Giao dịch
     $entry_arr = array();
     //Mảng các Bài viết
     $item_ids_ar = array();
     //Mảng id các Giao dịch
     $user_ids_ar = array();
     //Mảng id các user
     $entry_ids_ar = array();
     //Mảng id các Bài viết
     $item_comment_ids = "";
     //Id các phản hồi giao dịch
     $item_comment_arr = array();
     //các phản hồi giao dịch
     $user_comment_ids = "";
     //Id các lưu bút
     $user_comment_arr = array();
     //các lưu bút
     $pm_ids = "";
     //Id các tin nhắn
     $pm_arr = array();
     //các tin nhắn
     $entry_comment_ids = "";
     //Id các bài viết
     $entry_comment_arr = array();
     //các bài viết
     $this->show_more = false;
     //các bài viết
     $where = "WHERE user_id = " . User::id();
     $limit = " LIMIT " . $num_per_page * ($page_no - 1) . "," . ($num_per_page + 1);
     $where .= " AND type IN(1,2,3,4,5,6)";
     $total_unread = 0;
     $sql = "SELECT * FROM feed {$where} ORDER BY time DESC {$limit}";
     $re = DB::query($sql);
     $stt = 0;
     if ($re) {
         while ($feed = mysql_fetch_assoc($re)) {
             if ($stt < $num_per_page) {
                 if ($feed['type'] == 1 || $feed['type'] == 2) {
                     $item_comment_ids .= ($item_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                     if (!in_array($feed['item_id'], $item_ids_ar)) {
                         $item_ids_ar[$feed['item_id']] = $feed['item_id'];
                     }
                 } elseif ($feed['type'] == 3) {
                     $user_comment_ids .= ($user_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                 } elseif ($feed['type'] == 4) {
                     $pm_ids .= ($pm_ids != '' ? ',' : '') . $feed['ref_id'];
                 } elseif ($feed['type'] == 5 || $feed['type'] == 6) {
                     $entry_comment_ids .= ($entry_comment_ids != '' ? ',' : '') . $feed['ref_id'];
                     if ($feed['item_id']) {
                         $entry_ids_ar[$feed['item_id']] = $feed['item_id'];
                     }
                 }
                 if ($feed['act_user_id'] && !in_array($feed['act_user_id'], $user_ids_ar)) {
                     $user_ids_ar[$feed['act_user_id']] = $feed['act_user_id'];
                 }
                 $all_feeds[$feed['id']] = $feed;
                 $stt++;
             } else {
                 $this->show_more = true;
             }
         }
     }
     if ($item_ids_ar) {
         $item_ids = implode(',', $item_ids_ar);
         if ($item_ids != '') {
             $re = DB::query("SELECT  id, name ,up_time, status, state, currency_id, category_id, img_server, original_image_url AS image_url FROM item WHERE id IN({$item_ids})");
             if ($re) {
                 while ($item = mysql_fetch_assoc($re)) {
                     if (isset(CGlobal::$allCategories[$item['category_id']])) {
                         $item['link_view'] = Url::build('item_detail', array('id' => $item['id'], 'ebname' => EClassApi::safe_title($item['name']), 'nice_name' => CGlobal::$allCategories[$item['category_id']]['nice_name']));
                     } else {
                         $item['link_view'] = Url::build('item_detail', array('id' => $item['id'], 'ebname' => EClassApi::safe_title($item['name'])));
                     }
                     if (!$item['status']) {
                         $total_unread++;
                     }
                     $item_arr[$item['id']] = $item;
                 }
             }
         }
     }
     if (!empty($entry_ids_ar)) {
         $entry_ids = implode(',', $entry_ids_ar);
         if ($entry_ids != '') {
             $re = DB::query("SELECT id, title, status, user_name, time_modify, image_url FROM user_entry WHERE id IN({$entry_ids})");
             if ($re) {
                 while ($entry = mysql_fetch_assoc($re)) {
                     $entry['link_view'] = WEB_DIR . ECRewrite::formatUrl('?page=user_entry&user_name=' . $entry['user_name'] . '&cmd_entry=view&entry_id=' . $entry['id'] . '&ebname=' . EClassApi::safe_title($entry['title']));
                     if (!$entry['status']) {
                         $total_unread++;
                     }
                     $entry_arr[$entry['id']] = $entry;
                 }
             }
         }
     }
     if ($user_ids_ar) {
         $user_ids = implode(',', $user_ids_ar);
         if ($user_ids != '') {
             $re = DB::query("SELECT id, user_name, blast, avatar_url,img_server FROM account WHERE id IN({$user_ids})");
             if ($re) {
                 while ($user = mysql_fetch_assoc($re)) {
                     if ($user['avatar_url']) {
                         $user['avatar_url'] = 'http://' . CGlobal::$img_server[$user['img_server']] . 'thumb/50_50/' . $user['avatar_url'];
                     } else {
                         $user['avatar_url'] = 'style/images/54x54.gif';
                     }
                     $user_arr[$user['id']] = $user;
                 }
             }
         }
     }
     //Phản hồi giao dịch
     if ($item_comment_ids != '') {
         $re = DB::query("SELECT * FROM comment WHERE id IN({$item_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = EClassApi::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = EClassApi::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = EClassApi::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = EClassApi::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $item_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     //Lưu bút
     if ($user_comment_ids != '') {
         $re = DB::query("SELECT * FROM comment_user WHERE id IN({$user_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = EClassApi::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = EClassApi::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = EClassApi::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = EClassApi::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $user_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     if ($pm_ids != '' && $pm_ids != 0) {
         //Tin nhắn
         $re = DB::query("SELECT mt.*, msg.msg_post as content FROM (SELECT mt_id AS id, mt_msg_id, mt_title, mt_ref_id , mt_from_id AS sender_user_id, mt_date AS time, mt_read AS status FROM message_topics WHERE mt_id IN({$pm_ids})) AS mt LEFT JOIN message_text AS msg ON mt.mt_msg_id = msg.msg_id");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = EClassApi::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = EClassApi::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = EClassApi::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = EClassApi::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $pm_arr[$comment['id']] = $comment;
             }
         }
     }
     if ($entry_comment_ids != '') {
         //Phản hồi bài viết
         $re = DB::query("SELECT id, entry_id, content, time, sender_user_id, sender_user_name, sender_email, status FROM user_entry_comment WHERE id IN({$entry_comment_ids})");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $comment['content'] = EClassApi::parseBBCode(stripslashes($comment['content']));
                 $comment['s_content'] = EClassApi::plainText($comment['content']);
                 if (strlen($comment['s_content']) > 20) {
                     $comment['s_content'] = EClassApi::word_limit($comment['s_content'], 10, '..');
                 }
                 $comment['time'] = EClassApi::duration_time($comment['time']);
                 if (!$comment['status']) {
                     $total_unread++;
                 }
                 $entry_comment_arr[$comment['id']] = $comment;
             }
         }
     }
     $item_ids_ar = array();
     //Mảng item_id cập nhật bỏ qua cho các feed chủ thể tương ứng khi giao dịch bị xoá hoặc khoá!
     $item_ids_ar2 = array();
     //Mảng item_id cập nhật bỏ qua cho các feed khách thể tương ứng khi giao dịch bị xoá hoặc khoá!
     $entry_ids_ar = array();
     $entry_ids_ar2 = array();
     $c_user_ids_ar = array();
     $pm_ids_ar = array();
     $unread_feed_ids = '';
     $del_feed_ids = '';
     if ($all_feeds) {
         foreach ($all_feeds as $feed) {
             if ($feed['type'] == 4) {
                 //Tin nhắn
                 if (isset($user_arr[$feed['act_user_id']])) {
                     $feed['sender_user_name'] = $user_arr[$feed['act_user_id']]['user_name'];
                 } else {
                     $feed['sender_user_name'] = '';
                 }
             }
             if ($feed['type'] == 1 || $feed['type'] == 2) {
                 //Phản hồi giao dịch hoặc Trả lời phản hồi giao dịch
                 if (isset($item_comment_arr[$feed['ref_id']])) {
                     $feed['item_id'] = $item_comment_arr[$feed['ref_id']]['item_id'];
                     $feed['content'] = $item_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $item_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $item_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $item_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $item_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $feed['sender_email'] = $item_comment_arr[$feed['ref_id']]['sender_email'];
                     $status = $feed['status'];
                     if ($feed['type'] == 1) {
                         $feed['status'] = $item_comment_arr[$feed['ref_id']]['status'];
                     } else {
                         $feed['status'] = $item_comment_arr[$feed['ref_id']]['replied_status'];
                     }
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['type'] == 1 && $feed['status'] == 0) {
                             //Mảng item_id cập nhật bỏ qua cho các feed chủ thể tương ứng khi giao dịch bị xoá hoặc khoá!
                             $item_ids_ar[$feed['item_id']] = $feed['item_id'];
                         } elseif ($feed['type'] == 2 && $feed['status'] == 0) {
                             //Mảng item_id cập nhật bỏ qua cho các feed khách thể tương ứng khi giao dịch bị xoá hoặc khoá!
                             $item_ids_ar2[$feed['item_id']] = $feed['item_id'];
                         }
                     }
                     if (isset($item_arr[$feed['item_id']]) && $item_arr[$feed['item_id']]['state'] == 0 && $item_arr[$feed['item_id']]['status'] != -1) {
                         $feed['item'] = $item_arr[$feed['item_id']];
                         $all_feed_ars[$feed['id']] = $feed;
                     } else {
                         $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                     }
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 3) {
                 //Lưu bút
                 if (isset($user_comment_arr[$feed['ref_id']])) {
                     $feed['content'] = $user_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $user_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $user_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $user_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $user_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $status = $feed['status'];
                     $feed['status'] = $user_comment_arr[$feed['ref_id']]['status'];
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['status'] == 0) {
                             //
                             $c_user_ids_ar[$feed['ref_id']] = $feed['ref_id'];
                         }
                     }
                     $all_feed_ars[$feed['id']] = $feed;
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 4) {
                 //Tin nhắn
                 if (isset($pm_arr[$feed['ref_id']])) {
                     $feed['content'] = $pm_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $pm_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $pm_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $pm_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['mt_title'] = $pm_arr[$feed['ref_id']]['mt_title'];
                     $id = $pm_arr[$feed['ref_id']]['mt_ref_id'] ? $pm_arr[$feed['ref_id']]['mt_ref_id'] : $pm_arr[$feed['ref_id']]['id'];
                     $feed['mt_title_link'] = "message.html?tab=gt#inbox/{$id}";
                     $status = $feed['status'];
                     $feed['status'] = $pm_arr[$feed['ref_id']]['status'];
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['status'] == 0) {
                             //
                             $pm_ids_ar[$feed['ref_id']] = $feed['ref_id'];
                         }
                     }
                     $all_feed_ars[$feed['id']] = $feed;
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             } elseif ($feed['type'] == 5 || $feed['type'] == 6) {
                 //Phản hồi Bài viết
                 if (isset($entry_comment_arr[$feed['ref_id']])) {
                     $feed['entry_id'] = $entry_comment_arr[$feed['ref_id']]['entry_id'];
                     $feed['content'] = $entry_comment_arr[$feed['ref_id']]['content'];
                     $feed['s_content'] = $entry_comment_arr[$feed['ref_id']]['s_content'];
                     $feed['time'] = $entry_comment_arr[$feed['ref_id']]['time'];
                     $feed['sender_user_id'] = $entry_comment_arr[$feed['ref_id']]['sender_user_id'];
                     $feed['sender_user_name'] = $entry_comment_arr[$feed['ref_id']]['sender_user_name'];
                     $feed['sender_email'] = $entry_comment_arr[$feed['ref_id']]['sender_email'];
                     $status = $feed['status'];
                     if ($feed['type'] == 5) {
                         $feed['status'] = $entry_comment_arr[$feed['ref_id']]['status'];
                     } else {
                         $feed['status'] = $entry_comment_arr[$feed['ref_id']]['replied_status'];
                     }
                     if ($feed['status'] == 0 || $status == 0) {
                         $unread_feed_ids .= ($unread_feed_ids != '' ? ',' : '') . $feed['id'];
                         if ($feed['type'] == 5 && $feed['status'] == 0) {
                             //Mảng entrry_id cập nhật bỏ qua cho các feed chủ thể tương ứng khi giao dịch bị xoá hoặc khoá!
                             $entry_ids_ar[$feed['entry_id']] = $feed['entry_id'];
                         }
                         if ($feed['type'] == 6 && $feed['status'] == 0) {
                             //Mảng entrry_id cập nhật bỏ qua cho các feed khách thể tương ứng khi giao dịch bị xoá hoặc khoá!
                             $entry_ids_ar2[$feed['entry_id']] = $feed['entry_id'];
                         }
                     }
                     if (isset($entry_arr[$feed['entry_id']])) {
                         $feed['entry'] = $entry_arr[$feed['entry_id']];
                         $all_feed_ars[$feed['id']] = $feed;
                     } else {
                         $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                     }
                 } else {
                     $del_feed_ids .= ($del_feed_ids != '' ? ',' : '') . $feed['id'];
                 }
             }
         }
     }
     $display->add('all_feed_ars', $all_feed_ars);
     $display->add('image_path', 'http://' . IMAGE_PATH);
     $display->add('get_page', EClass::$page['name']);
     $display->add('get_cmd', Url::get('cmd', 'office'));
     $display->add('get_act', $action);
     $display->add('user_name', User::user_name());
     $this->total_group = count($all_feed_ars);
     $display->add('total_group', $this->total_group);
     $display->add('cur_group', $cur_group);
     $display->add('show_more', $this->show_more);
     $display->add('cur_user_name', User::user_name());
     $display->add('more_notify', WEB_DIR . ECRewrite::formatUrl('?page=personal'));
     $transact_office = $display->output('tbl_notify_ajax', true, 'Personal');
     $display->add('transact_office', $transact_office);
     $display->add('total_comment_user', User::$current->data['total_comment_user']);
     $display->add('total_new_comment', User::$current->data['total_new_comment']);
     $display->add('total_pm', User::$current->data['total_pm']);
     $display->add('can_edit_blast', User::is_admin() || !User::is_block());
     $blast = User::$current->data['blast'];
     $avatar_link = '';
     $avatar_url = 'style/images/no_avatar_item.gif';
     if (User::$current->data['avatar_url'] != '') {
         $avatar_link = "http://" . CGlobal::$img_server[User::$current->data['img_server']] . User::$current->data['avatar_url'];
         $avatar_url = EClassApi::getImageThumb(User::$current->data['avatar_url'], 80, 80, 0, User::$current->data['img_server']);
     }
     if ($blast == '') {
         $blast = '...';
     } else {
         $blast = ' ' . $blast;
         if (strpos($blast, 'http://')) {
             $user_blast = $blast;
             while (strpos($user_blast, 'http://')) {
                 $tmp = substr($user_blast, strpos($user_blast, 'http://'));
                 if (strpos($tmp, ' ') || strpos($tmp, '<')) {
                     if (strpos($tmp, ' ') && strpos($tmp, '<') && strpos($tmp, ' ') > strpos($tmp, '<')) {
                         $blast_url = substr($tmp, 0, strpos($tmp, '<'));
                     } else {
                         $blast_url = substr($tmp, 0, strpos($tmp, ' '));
                     }
                 } else {
                     $blast_url = $tmp;
                 }
                 $user_blast = str_replace($blast_url, '', $user_blast);
             }
             $new_blast_url = ' <a rel="nofollow" href="' . $blast_url . '" target="_blank">Click here</a>';
             $blast = substr($user_blast . $new_blast_url, 1);
         }
     }
     $display->add('avatar_link', $avatar_link);
     $display->add('avatar_url', $avatar_url);
     $display->add('blast', $blast);
     $display->add('user_id', User::id());
     //Cập nhật sách theo đuôi
     if (isset($user_arr[$feed['act_user_id']]) && $user_arr[$feed['act_user_id']]['avatar_url']) {
         $feed['avatar_url'] = $user_arr[$feed['act_user_id']]['avatar_url'];
     } else {
         $feed['avatar_url'] = 'style/images/54x54.gif';
     }
     if ($feed_follows) {
         $tmp_feed_follows = $feed_follows;
         $feed_follows = array();
         foreach ($tmp_feed_follows as $feed) {
             if (isset($user_arr[$feed['user_id']])) {
                 if ($user_arr[$feed['user_id']]['avatar_url']) {
                     $avatar_url = $user_arr[$feed['user_id']]['avatar_url'];
                 } else {
                     $avatar_url = 'style/images/54x54.gif';
                 }
                 $user_name = $user_arr[$feed['user_id']]['user_name'];
                 if ($feed['type'] == 7) {
                     //entry
                     if (isset($entry_arr[$feed['item_id']])) {
                         $feed_follows[$feed['user_id']]['user_name'] = $user_name;
                         $feed_follows[$feed['user_id']]['avatar_url'] = $avatar_url;
                         $feed['entry_name'] = $entry_arr[$feed['item_id']]['title'];
                         $feed['entry_link'] = WEB_DIR . ECRewrite::formatUrl('?page=user_entry&user_name=' . $user_name . '&cmd_entry=view&entry_id=' . $feed['item_id'] . '&ebname=' . EClassApi::safe_title($feed['entry_name']));
                         $feed['time'] = date('H:i d/m/Y', $feed['time']);
                         $feed_follows[$feed['user_id']]['feeds'][$feed['id']] = $feed;
                     }
                 } else {
                     $feed_follows[$feed['user_id']]['user_name'] = $user_name;
                     $feed_follows[$feed['user_id']]['avatar_url'] = $avatar_url;
                     $feed['blast'] = $user_arr[$feed['user_id']]['blast'];
                     $feed['time'] = date('H:i d/m/Y', $feed['time']);
                     $feed_follows[$feed['user_id']]['feeds'][$feed['id']] = $feed;
                 }
             }
         }
     }
     $json = array();
     $active_notify = array();
     $active_notify['item_ids_ar'] = $item_ids_ar;
     $active_notify['item_ids_ar2'] = $item_ids_ar2;
     $active_notify['c_user_ids_ar'] = $c_user_ids_ar;
     $active_notify['pm_ids_ar'] = $pm_ids_ar;
     $json['active_notify'] = $active_notify;
     $json['total_unread'] = $total_unread;
     $json['total_notify'] = User::$current->data['total_comment_user'] + User::$current->data['total_new_comment'] + User::$current->data['total_pm'];
     $json['content'] = $display->output('tb_notify', true, 'Personal');
     echo json_encode($json);
     exit;
 }
Exemple #9
0
 function get_feed_notify_bar()
 {
     EClassApi::getCats();
     $json = "";
     if (!User::is_login()) {
         $json = '({"msg":"no_login"})';
         echo $json;
         exit;
     }
     $item_comment_ids = "";
     //Id các phản hồi giao dịch
     $user_comment_ids = "";
     //Id các lưu bút
     $entry_comment_ids = "";
     //Id các bài viết
     /*$follow_ids			= "";//Id các theo đuôi*/
     $blast_user_ids = "";
     // Id các balst
     $arr_data = array();
     $user = User::getUser(User::id());
     if ($user["total_pm"]) {
         // neu co PM moi
         $arr_data = array("new_pm" => $user["total_pm"]);
     }
     $where = "WHERE user_id = " . User::id();
     $limit = " LIMIT 20";
     $sql = "SELECT * FROM feed {$where} ORDER BY time DESC {$limit}";
     $re = DB::query($sql);
     if ($re) {
         while ($feed = mysql_fetch_assoc($re)) {
             if ($feed['type'] == 1 || $feed['type'] == 2) {
                 // phan hoi
                 $item_comment_ids .= ($item_comment_ids != '' ? ',' : '') . $feed['ref_id'];
             } elseif ($feed['type'] == 3) {
                 // luu but
                 $user_comment_ids .= ($user_comment_ids != '' ? ',' : '') . $feed['ref_id'];
             } elseif ($feed['type'] == 5 || $feed['type'] == 6) {
                 // bai viet
                 $entry_comment_ids .= ($entry_comment_ids != '' ? ',' : '') . $feed['ref_id'];
             }
             /*elseif($feed['type']==7){// theo duoi						
             			$follow_ids.=($follow_ids!=''?',':'').$feed['ref_id'];
             		}*/
         }
     }
     //Phản hồi giao dịch
     $item_comment_arr = array();
     if ($item_comment_ids != '') {
         $item_ids = "";
         $re = DB::query("SELECT time, item_id, parent_id, COUNT(item_id) AS total_comment FROM comment WHERE id IN({$item_comment_ids}) GROUP BY item_id");
         if ($re) {
             while ($comment = mysql_fetch_assoc($re)) {
                 $item_ids .= ($item_ids != '' ? ',' : '') . $comment['item_id'];
                 $comment['time'] = EClassApi::duration_time($comment['time']);
                 $item_comment_arr[$comment['item_id']] = $comment;
             }
             if ($item_comment_arr && $item_ids) {
                 // Query de lay ID va Tieu de tin
                 $re = DB::query("SELECT id, name, level_1_category_id FROM item WHERE id IN({$item_ids})");
                 while ($item = mysql_fetch_assoc($re)) {
                     if ($item["id"] == $item_comment_arr[$item["id"]]["item_id"]) {
                         $item_comment_arr[$item["id"]]["item_name"] = EClassApi::word_limit($item["name"], 7, '...');
                         $ebname = EClassApi::safe_title($item['name']);
                         if (isset(CGlobal::$allCategories[$item['level_1_category_id']])) {
                             $cat_name = CGlobal::$allCategories[$item['level_1_category_id']]['name'];
                             $item_comment_arr[$item["id"]]["url_link"] = WEB_DIR . EClassApi::safe_title($cat_name) . "/p{$item['id']}/{$ebname}.html";
                         } else {
                             $item_comment_arr[$item["id"]]["url_link"] = WEB_DIR . "/p{$item['id']}/{$ebname}.html";
                         }
                     }
                 }
             }
         }
         if ($item_comment_arr) {
             $item_comment_arrs["comment"] = $item_comment_arr;
             $arr_data += $item_comment_arrs;
         }
     }
     // End Phan hoi giao dich
     //Luu but
     $total_comment_arr = array();
     if ($user_comment_ids != '') {
         $re = DB::query("SELECT time, COUNT(id) AS total_comment_user FROM comment_user WHERE id IN({$user_comment_ids}) GROUP BY receiver_user_id ORDER BY time DESC");
         if ($re) {
             $comment_user = mysql_fetch_assoc($re);
             $total_comment_arr["total"] = $comment_user["total_comment_user"];
             $total_comment_arr['time'] = EClassApi::duration_time($comment_user['time']);
             $total_comment_arr["url_link"] = WEB_DIR . 'Shop/' . User::user_name() . '/Luu-but';
         }
         if ($total_comment_arr) {
             $total_comment_arrs["comment_user"] = $total_comment_arr;
             $arr_data += $total_comment_arrs;
         }
     }
     //End Luu but
     // Theo duoi
     /*$follow_arr = array();
     		if($follow_ids!=''){
     			$re = DB::query("SELECT id, follower_name, time FROM follow WHERE id IN($follow_ids) ORDER BY time DESC");			
     			if($re){				
     				while ($follow = mysql_fetch_assoc($re)){										
     					$follow['time'] = EClassApi::duration_time($follow['time']);
     					$follow["url_link"] = WEB_DIR.$follow['follower_name'];
     					$follow_arr[$follow['id']] = $follow;
     				}														
     			}							
     			if($follow_arr){
     				$follow_arrs["follow"] = $follow_arr;
     				$arr_data += $follow_arrs;
     			}
     		}*/
     // end Theo duoi
     // Phản hồi bài viết
     $entry_comment_arr = array();
     if ($entry_comment_ids != '') {
         $entry_ids = "";
         $re = DB::query("SELECT time, entry_id, parent_id FROM user_entry_comment WHERE id IN({$entry_comment_ids})");
         if ($re) {
             while ($comment_entry = mysql_fetch_assoc($re)) {
                 $entry_ids .= ($entry_ids != '' ? ',' : '') . $comment_entry['entry_id'];
                 $comment_entry['time'] = EClassApi::duration_time($comment_entry['time']);
                 $comment_entry['total_comment_entry'] = count(explode(',', $entry_comment_ids));
                 $entry_comment_arr[$comment_entry['entry_id']] = $comment_entry;
             }
             if ($entry_comment_arr && $entry_ids) {
                 // Query de lay ID va Tieu de bai viet
                 $re = DB::query("SELECT id, title FROM user_entry WHERE id IN({$entry_ids})");
                 while ($entry = mysql_fetch_assoc($re)) {
                     if ($entry["id"] == $entry_comment_arr[$entry["id"]]["entry_id"]) {
                         $entry_comment_arr[$entry["id"]]["title"] = EClassApi::word_limit($entry["title"], 7, '...');
                         $ebname = EClassApi::safe_title($entry['title']);
                         $entry_comment_arr[$entry["id"]]["url_link"] = WEB_DIR . "Bai-viet/" . User::user_name() . "/e{$entry['id']}/{$ebname}";
                     }
                 }
             }
         }
         if ($entry_comment_arr) {
             $item_comment_arrs["entry"] = $entry_comment_arr;
             $arr_data += $item_comment_arrs;
         }
     }
     // End Phan hoi bài viết
     $json = json_encode($arr_data);
     echo $json;
     exit;
 }