예제 #1
0
파일: User.php 프로젝트: ASDAFF/advboard
 public function indexAction()
 {
     global $structure;
     $uid = cot_import('uid', 'G', 'INT');
     if (empty($uid)) {
         $uid = cot::$usr['id'];
     }
     // Незарегов, если они не смотрят объявления другого пользователя перенаправляем
     if (!$uid) {
         cot_redirect(cot_url('advboard', '', '', true));
     }
     // Проверить существование пользователя
     $user = cot_user_data($uid);
     if (!$user) {
         cot_die_message(404, TRUE);
     }
     $maxrowsperpage = cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     $condition = array(array('user', $uid));
     if (!cot::$usr['isadmin'] && $uid != cot::$usr['id']) {
         $condition[] = array('state', advboard_model_Advert::PUBLISHED);
         $condition[] = array('begin', cot::$sys['now'], '<=');
         $condition[] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
     }
     $order = array(array('state', 'ASC'), array('sort', 'DESC'));
     cot::$out['canonical_uri'] = cot_url('advboard', array('m' => 'user', 'uid' => $uid));
     $urlParams = array('m' => 'user');
     if ($uid != cot::$usr['id']) {
         $urlParams['uid'] = $uid;
     }
     $title = '';
     $crumbs = array();
     if ($uid != cot::$usr['id']) {
         cot::$out['subtitle'] = $title = cot::$L['advboard_user_ads'] . ': ' . cot_user_full_name($user);
         $crumbs[] = array(cot_url("users"), cot::$L['Users']);
         $crumbs[] = array(cot_url("users", "m=details&id=" . $user["user_id"] . "&u=" . $user["user_name"]), cot_user_full_name($user));
         $crumbs[] = cot::$L['advboard_user_ads'];
         //            $advUrlParams['uid']  = $user['user_id'];
         $urlParams['uid'] = $user['user_id'];
     } else {
         cot::$out['subtitle'] = $title = cot::$L['advboard_my_ads'];
         $crumbs[] = array(cot_url('users', array('m' => 'details')), cot::$L['advboard_my_page']);
         $crumbs[] = cot::$L['advboard_my_ads'];
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.user.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, $d, $order);
     $addNewUrl = '';
     if ((cot::$usr['auth_write'] || cot::$usr['isadmin']) && !empty($structure['advboard'])) {
         // Ищем категорию куда пользователь может подать оьбъявление
         foreach ($structure['advboard'] as $catCode => $catRow) {
             $auth_write = cot_auth('advboard', $catCode, 'W');
             if ($auth_write) {
                 $addNewUrl = cot_url('advboard', array('a' => 'edit', 'c' => $catCode));
                 break;
             }
         }
     }
     $pagenav = cot_pagenav('advboard', $urlParams, $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $template = array('advboard', 'list', 'user');
     $pageUrlParams = $urlParams;
     if ($durl > 1) {
         $pageUrlParams['d'] = $durl;
     }
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($title);
     $view->advertisement = $advertisement;
     $view->allowComments = true;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.user.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
예제 #2
0
파일: Main.php 프로젝트: ASDAFF/advboard
 /**
  * Список объявлений
  * @param $c
  * @return string
  * @throws Exception
  */
 public function adList($c)
 {
     global $structure, $cot_extrafields, $db_structure, $Ls;
     if ($c == 'all') {
         cot_block(cot::$usr['isadmin']);
     } elseif (!in_array($c, array('unvalidated', 'saved-drafts'))) {
         if (!isset($structure['advboard'][$c])) {
             cot_die_message(404, TRUE);
         } else {
             list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', $c);
             cot_block(cot::$usr['auth_read']);
         }
     }
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $maxrowsperpage = cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] ? cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] : cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     list($pgc, $dc, $dcurl) = cot_import_pagenav('dc', cot::$cfg['advboard']['maxlistsperpage']);
     // page number for cats list
     // Фильтры для модератора
     $mf = array('period' => 0, 'state' => -2);
     if (cot::$usr['isadmin']) {
         $mf['period'] = isset($_GET['mf']['period']) ? cot_import($_GET['mf']['period'], 'D', 'ALP') : 0;
         $mf['state'] = isset($_GET['mf']['state']) ? cot_import($_GET['mf']['state'], 'D', 'INT') : -2;
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $category = array('config' => array());
     if (isset($structure['advboard'][$c])) {
         $category = $structure['advboard'][$c];
         $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     }
     $category['code'] = $c;
     $fields = advboard_model_Advert::getColumns();
     if (empty($sort)) {
         $sort = cot::$cfg['advboard']['cat_' . $c]['order'];
     } elseif (!in_array($sort, $fields)) {
         $sort = 'sort';
     }
     $way = empty($way) ? cot::$cfg['advboard']['cat_' . $c]['way'] : $way;
     $sort = empty($sort) ? cot::$cfg['advboard']['cat___default']['order'] : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? cot::$cfg['advboard']['cat___default']['way'] : $way;
     $urlParams = array('c' => $c);
     if ($sort != cot::$cfg['advboard']['cat_' . $c]['order']) {
         $urlParams['s'] = $sort;
     }
     if ($way != cot::$cfg['advboard']['cat_' . $c]['way']) {
         $urlParams['w'] = $way;
     }
     $canonicalUrlParams = array('c' => $c);
     if ($durl > 1) {
         $canonicalUrlParams['d'] = $durl;
     }
     if ($dcurl > 1) {
         $canonicalUrlParams['dc'] = $dcurl;
     }
     $template = array('advboard', 'list');
     $where = array();
     if ($c == 'unvalidated') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::AWAITING_MODERATION);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_validation'];
         $category['desc'] = cot::$L['page_validation_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'saved-drafts') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::DRAFT);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_drafts'];
         $category['desc'] = cot::$L['page_drafts_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'all') {
         $category['title'] = cot::$L['advboard_ads_board'];
     } else {
         $where['category'] = array('category', $c);
         $where['state'] = array('state', advboard_model_Advert::PUBLISHED);
         $where['begin'] = array('begin', cot::$sys['now'], '<=');
         $where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
         $template = array('advboard', 'list', $structure['advboard'][$c]['tpl']);
     }
     $moderatorFilters = array();
     if (cot::$usr['isadmin']) {
         if ($mf['state'] == -1) {
             unset($where['state']);
         } elseif ($mf['state'] >= 0 && $mf['state'] < 3) {
             $where['state'] = array('state', $mf['state']);
         }
         if ($mf['period'] == 'all') {
             unset($where['begin'], $where['expire']);
         } elseif ($mf['period'] == 'exp') {
             unset($where['begin']);
             $where['expire'] = array('SQL', "expire > 0 AND expire <= " . cot::$sys['now']);
         } elseif ($mf['period'] == 'fut') {
             unset($where['expire']);
             $where['begin'] = array('begin', cot::$sys['now'], '>');
         }
         $tmp = array(-2 => cot::$R['code_option_empty'], -1 => cot::$L['All'], 0 => cot::$L['advboard_state_0'], 1 => cot::$L['advboard_state_1'], 2 => cot::$L['advboard_state_2']);
         $moderatorFilters['state'] = cot_selectbox($mf['state'], 'mf[state]', array_keys($tmp), array_values($tmp), false);
         $tmp = array('0' => cot::$R['code_option_empty'], 'all' => cot::$L['All'], 'exp' => cot::$L['advboard_expired'], 'fut' => cot::$L['advboard_future']);
         $moderatorFilters['period'] = cot_selectbox(strval($mf['period']), 'mf[period]', array_keys($tmp), array_values($tmp), false);
         $moderatorFilters['action'] = cot_url('advboard', $urlParams);
         $moderatorFilters['hidden'] = '';
         foreach ($urlParams as $key => $val) {
             $moderatorFilters['hidden'] .= cot_inputbox('hidden', $key, $val);
         }
         $moderatorFilters['reset'] = cot_url('advboard', $urlParams);
     }
     cot_die(empty($category['title']) && !cot::$usr['isadmin']);
     cot::$out['desc'] = htmlspecialchars(strip_tags($category['desc']));
     cot::$out['subtitle'] = $category['title'];
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['keywords'])) {
         cot::$out['keywords'] = cot::$cfg['advboard']['cat_' . $c]['keywords'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metadesc'])) {
         cot::$out['desc'] = cot::$cfg['advboard']['cat_' . $c]['metadesc'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metatitle'])) {
         cot::$out['subtitle'] = cot::$cfg['advboard']['cat_' . $c]['metatitle'];
     }
     // Building the canonical URL
     cot::$out['canonical_uri'] = cot_url('advboard', $canonicalUrlParams);
     $condition = array();
     foreach ($where as $key => $val) {
         $condition[] = $val;
     }
     $order = array(array('sticky', 'desc'), array($sort, $way));
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = null;
     if ($totallines > 0) {
         $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, $d, $order);
     }
     $allowComments = cot_plugin_active('comments');
     if ($allowComments) {
         if (!isset(cot::$cfg['advboard']['cat_' . $c])) {
             $allowComments = false;
         } else {
             $allowComments = cot::$cfg['advboard']['cat_' . $c]['enable_comments'];
         }
     }
     $addNewUrl = '';
     if ((cot::$usr['auth_write'] || cot::$usr['isadmin']) && !empty($category['id'])) {
         $addNewUrl = cot_url('advboard', array('a' => 'edit', 'c' => $category['code']));
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.main') as $pl) {
         include $pl;
     }
     /* ===== */
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $kk = 0;
     $allsub = cot_structure_children('advboard', $c, false, false, true, false);
     $subcat = array_slice($allsub, $dc, cot::$cfg['advboard']['maxlistsperpage']);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.rowcat.first') as $pl) {
         include $pl;
     }
     /* ===== */
     /* === Hook - Part1 : Set === */
     $extp = cot_getextplugins('advboard.list.rowcat.loop');
     /* ===== */
     $subCategories = array();
     foreach ($subcat as $x) {
         $kk++;
         $cat_childs = cot_structure_children('advboard', $x);
         $sub_count = 0;
         foreach ($cat_childs as $cat_child) {
             $sub_count += (int) $structure['advboard'][$cat_child]['count'];
         }
         $sub_url_path = $urlParams;
         $sub_url_path['c'] = $x;
         $subCategories[$x] = $structure['advboard'][$x];
         $subCategories[$x]['config'] = cot::$cfg['advboard']['cat_' . $x];
         $subCategories[$x]['code'] = $x;
         $subCategories[$x]['count'] = $sub_count;
         $subCategories[$x]['num'] = $kk;
         // Extra fields for structure
         foreach ($cot_extrafields[$db_structure] as $exfld) {
             $uname = $exfld['field_name'];
             $val = $structure['advboard'][$x][$exfld['field_name']];
             $subCategories[$x][$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
             $subCategories[$x][$uname] = cot_build_extrafields_data('structure', $exfld, $val);
             $subCategories[$x][$uname . '_value'] = $val;
         }
         /* === Hook - Part2 : Include === */
         foreach ($extp as $pl) {
             include $pl;
         }
         /* ===== */
     }
     $crumbs = array();
     if (!empty($category['id'])) {
         $crumbs = cot_structure_buildpath('advboard', $c);
         if (cot::$cfg['advboard']['firstCrumb']) {
             array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
         }
     }
     // Фильтры для модератора
     if (cot::$usr['isadmin']) {
         if ($mf['period'] != '0') {
             $urlParams['mf[period]'] = $mf['period'];
         }
         if ($mf['state'] != -2) {
             $urlParams['mf[state]'] = $mf['state'];
         }
     }
     $pagenavCategory = cot_pagenav('advboard', $urlParams + array('d' => $durl), $dc, count($allsub), cot::$cfg['advboard']['maxlistsperpage'], 'dc');
     if (empty($pagenavCategory['current'])) {
         $pagenavCategory['current'] = 1;
     }
     $pagenav = cot_pagenav('advboard', $urlParams + array('dc' => $dcurl), $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $pageUrlParams = $urlParams;
     if ($durl > 1) {
         $pageUrlParams['d'] = $durl;
     }
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($category['title']);
     $view->category = $category;
     $view->subCategories = $subCategories;
     $view->condition = $condition;
     $view->order = $order;
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     $view->allowComments = $allowComments;
     $view->pagenav = $pagenav;
     $view->pagenavCategory = $pagenavCategory;
     $view->moderatorFilters = $moderatorFilters;
     $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
예제 #3
0
파일: Compare.php 프로젝트: ASDAFF/advboard
 public function indexAction()
 {
     Resources::linkFileFooter(cot::$cfg['modules_dir'] . '/advboard/js/advboard.compare.js');
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     //$maxrowsperpage = cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     $maxrowsperpage = 0;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.compare.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $sort = empty($sort) ? cot::$cfg['advboard']['cat___default']['order'] : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? cot::$cfg['advboard']['cat___default']['way'] : $way;
     $canonicalUrlParams = array('m' => 'compare');
     $where = array();
     if (!empty($_SESSION['advboard_compare']) && !empty($_SESSION['advboard_compare'][cot::$sys['site_id']])) {
         $where['id'] = array('id', array_keys($_SESSION['advboard_compare'][cot::$sys['site_id']]));
         $where['state'] = array('state', advboard_model_Advert::PUBLISHED);
         $where['begin'] = array('begin', cot::$sys['now'], '<=');
         $where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
     }
     $template = array('advboard', 'compare');
     cot::$out['subtitle'] = cot::$L['advboard_compare'];
     // Building the canonical URL
     cot::$out['canonical_uri'] = cot_url('advboard', $canonicalUrlParams);
     $condition = array();
     foreach ($where as $key => $val) {
         $condition[] = $val;
     }
     $order = array(array('sticky', 'desc'), array($sort, $way));
     /* === Hook === */
     foreach (cot_getextplugins('advboard.compare.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $advertisement = null;
     $totallines = 0;
     if (!empty($condition)) {
         $totallines = advboard_model_Advert::count($condition);
         if ($totallines > 0) {
             $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, 0, $order);
         }
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.compare.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $crumbs = array();
     if (cot::$cfg['advboard']['firstCrumb']) {
         $crumbs[] = array(cot_url('advboard'), cot::$L['advboard_ads']);
     }
     $crumbs[] = array(cot_url('advboard', array('m' => 'compare')), cot::$L['advboard_compare']);
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     //        $pageUrlParams = $urlParams;
     //        if($durl > 1) $pageUrlParams['d'] = $durl;
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars(cot::$L['advboard_compare']);
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     //        $view->urlParams = $urlParams;
     //        $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.compare.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
예제 #4
0
파일: Widget.php 프로젝트: ASDAFF/advboard
 public static function adsList($condition = array(), $tpl = 'advboard.widget.list', $items = 0, $order = '', $onlyActive = true, $pagination = 'pld', $params = array())
 {
     // Get pagination number if necessary
     if (!empty($pagination)) {
         list($pg, $d, $durl) = cot_import_pagenav($pagination, $items);
     } else {
         $d = 0;
     }
     if (empty($condition)) {
         $condition = array();
     }
     if ($onlyActive) {
         $condition[] = array('begin', cot::$sys['now'], '<=');
         $condition[] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
         $condition[] = array('state', advboard_model_Advert::PUBLISHED);
     }
     if (empty($order)) {
         $order = array(array('state', 'ASC'), array('sort', 'DESC'));
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.widget.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = advboard_model_Advert::find($condition, $items, $d, $order);
     // Render pagination
     if (empty($params['module'])) {
         $params['module'] = defined('COT_PLUG') ? 'plug' : cot::$env['ext'];
     }
     if (empty($params['urlParams'])) {
         if (defined('COT_LIST')) {
             global $list_url_path;
             $params['urlParams'] = $list_url_path;
         } elseif (defined('COT_PAGES')) {
             global $al, $id, $pag;
             $params['urlParams'] = empty($al) ? array('c' => $pag['page_cat'], 'id' => $id) : array('c' => $pag['page_cat'], 'al' => $al);
         } else {
             $params['urlParams'] = array();
         }
     }
     if (empty($params['ajax'])) {
         $params['ajax'] = false;
     }
     if (empty($params['target_div'])) {
         $params['target_div'] = '';
     }
     if (empty($params['ajax_module'])) {
         $params['ajax_module'] = '';
     }
     if (empty($params['ajax_params'])) {
         $params['ajax_params'] = array();
     }
     $pagenav = cot_pagenav($params['module'], $params['urlParams'], $d, $totallines, $items, $pagination, '', $params['ajax'], $params['target_div'], $params['ajax_module'], $params['ajax_params']);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $view = new View();
     /* === Hook === */
     foreach (cot_getextplugins('advboard.widget.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     return $view->render($tpl);
 }
예제 #5
0
// Объявления
$sitemap_where = array();
$sitemap_where['state'] = array('state', advboard_model_Advert::PUBLISHED);
$sitemap_where['begin'] = array('begin', cot::$sys['now'], '<=');
$sitemap_where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
/* === Hook === */
foreach (cot_getextplugins('sitemap.advboard.query') as $pl) {
    include $pl;
}
/* ===== */
$condition = array();
foreach ($sitemap_where as $key => $val) {
    $condition[] = $val;
}
$order = array(array('sort', 'DESC'));
$cnt = advboard_model_Advert::count($condition);
if ($cnt > 0) {
    $i = 0;
    while ($i <= $cnt) {
        $advertisement = advboard_model_Advert::find($condition, 20, $i, $order);
        if (!$advertisement) {
            break;
        }
        foreach ($advertisement as $advert) {
            $i++;
            if (!$auth_cache[$advert->category]) {
                continue;
            }
            sitemap_parse($t, $items, array('url' => $advert->url, 'date' => !empty($advert->updated) ? strtotime($advert->updated) : '', 'freq' => cot::$cfg['plugin']['sitemap']['freq'], 'prio' => cot::$cfg['plugin']['sitemap']['prio']));
            unset($advert);
        }
Hooks=users.details.tags
Tags=users.details.tpl:{USERS_DETAILS_ADVERT_SUBMITNEW}, {USERS_DETAILS_ADVERT_SUBMITNEW_URL}, {USERS_DETAILS_ADVERT_COUNT}, {USERS_DETAILS_ADVERT_URL}
[END_COT_EXT]
==================== */
/**
 * Ads board module for Cotonti Siena
 *
 * @package Advboard
 * @author Kalnov Alexey    <*****@*****.**>
 * @copyright (c) 2015 Portal30 Studio http://portal30.ru
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('advboard', 'module');
$submitNewAdv = '';
$submitNewAdvUrl = '';
if (cot_auth('advboard', 'any', 'W') || cot::$usr["isadmin"]) {
    $submitNewAdvUrl = cot_url('advboard', array('a' => 'edit'));
    $submitNewAdv = cot_rc_link($submitNewAdvUrl, cot::$L['advboard_add_new']);
}
$advUnValidated = $urr['user_id'] == cot::$usr['id'] || cot::$usr["isadmin"] || cot_auth('advboard', 'any', 'A');
$advCond = array(array('user', $urr['user_id']));
if (!$advUnValidated) {
    $advCond[] = array('begin', cot::$sys['now'], '<=');
    $advCond[] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
    $advCond[] = array('state', advboard_model_Advert::PUBLISHED);
}
//$advUrlParams = array('m'=>'details', 'id'=>$urr['user_id'],'u'=>$urr['user_name']);
//
//$advAjaxPParams = array('a'=>'userDetailsAdvList', 'uid'=>$urr['user_id']);
$t->assign(array("USERS_DETAILS_ADVERT_SUBMITNEW" => $submitNewAdv, "USERS_DETAILS_ADVERT_SUBMITNEW_URL" => $submitNewAdvUrl, "USERS_DETAILS_ADVERT_COUNT" => advboard_model_Advert::count($advCond), "USERS_DETAILS_ADVERT_URL" => cot_url('advboard', array('m' => 'user', 'uid' => $urr['user_id']))));
예제 #7
0
파일: Advert.php 프로젝트: ASDAFF/advboard
 protected function afterDelete()
 {
     // Обновить структуру
     // Наверное не учитываем состояние объявления, а считаем все.
     $count = advboard_model_Advert::count(array(array('category', $this->_data['category'])));
     static::$_db->update(cot::$db->structure, array('structure_count' => $count), "structure_area='advboard' AND structure_code = ?", $this->_data['category']);
     // Сбросим кеш структуры и главной страницы
     if (!empty(cot::$cache)) {
         cot::$cache->db->remove('structure', 'system');
         if (cot::$cfg['cache_index']) {
             cot::$cache->page->clear('index');
         }
     }
     return parent::afterDelete();
 }
예제 #8
0
/**
 * Количество объявлений пользователя
 * @param int $uid
 * @param bool $cache
 * @return int
 */
function cot_user_ads_count($uid = 0, $cache = true)
{
    static $stCache = array();
    if (empty($uid)) {
        $uid = cot::$usr['id'];
    }
    if ($cache && isset($stCache[$uid])) {
        return $stCache[$uid];
    }
    $cond = array(array('user', $uid));
    $stCache[$uid] = advboard_model_Advert::count($cond);
    return $stCache[$uid];
}