Query(" SELECT * FROM " . PREFIX . "_module_unicalendar WHERE id = '" . $id . "' "); $unicalendars = array(); while ($row = $sql->FetchAssocArray()) { array_push($unicalendars, $row); } foreach ( $unicalendars as $k=>$v ) { $uevents = $v['uca_events']; $urubric_id = $v['uca_rubric_id']; $udoc_id = $v['uca_doc_id']; } // Если выбрали вывести все документы из заданной рубрики - документы с Id=1 и Id=2 - выводиться не будут! if ($uevents !='' && $uevents == '1'){ $sql = $AVE_DB->Query(" SELECT Id, document_alias, document_title, document_published, document_meta_description FROM " . PREFIX . "_documents WHERE rubric_id = '" . $urubric_id . "' AND Id > 2 "); $results = array(); while ($row = $sql->FetchAssocArray()) { array_push($results, $row); } } // Если выбрали вывести выбранные документы из заданной рубрики if ($uevents !='' && $uevents == '2'){ $sql = $AVE_DB->Query(" SELECT Id, document_alias, document_title, document_published, document_meta_description FROM " . PREFIX . "_documents WHERE rubric_id = '" . $urubric_id . "' AND Id > 2 AND $udoc_id "); $results = array(); while ($row = $sql->FetchAssocArray()) { array_push($results, $row); } } $AVE_Template->assign('unicalendars', $unicalendars); $AVE_Template->assign('results', $results); $AVE_Template->display($tpl_dir . 'unicalendar.tpl'); } /** * ФУНКЦИИ АДМИНИСТРАТИВНОЙ ЧАСТИ */ /** * Вывод списка календарей * * @param string $tpl_dir - путь к папке с шаблонами модуля */ function unicalendarList($tpl_dir) { global $AVE_DB, $AVE_Template; $unicalendars = array(); $limit = 20; $start = get_current_page() * $limit - $limit; $sql = $AVE_DB->Query(" SELECT SQL_CALC_FOUND_ROWS u.*, COUNT(u.id) AS uca_count FROM " . PREFIX . "_module_unicalendar AS u GROUP BY u.id ORDER BY u.id ASC LIMIT " . $start . "," . $limit . " "); $sql_num = $AVE_DB->Query("SELECT FOUND_ROWS()"); $num = $sql_num->GetCell(); while($row = $sql->FetchAssocArray()) { array_push($unicalendars, $row); } if ($num > $limit) { $page_nav = "
  • {t}
  • "; $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav); } else { $page_nav = ''; } $AVE_Template->assign('page_nav', $page_nav); if (!empty($_REQUEST['alert'])) { $AVE_Template->assign('alert', htmlspecialchars(stripslashes($_REQUEST['alert']))); } $AVE_Template->assign('unicalendars', $unicalendars); $AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=new&sub=save&cp=' . SESSION); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_unicalendar_list.tpl')); } /** * Создание календаря * */ function unicalendarNew() { if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'save') { global $AVE_DB; $cont = true; $alert = ''; if (empty($_POST['uca_title'])) { $alert = '&alert=empty_uca_title'; $cont = false; } if ($cont) { $AVE_DB->Query(" INSERT INTO " . PREFIX . "_module_unicalendar SET id = '', uca_title = '" . $_POST['uca_title'] . "', uca_events = '" . $_POST['uca_events'] . "', uca_rubric_id = '" . $_POST['uca_rubric_id'] . "', uca_doc_id = '" . $_POST['uca_doc_id'] . "', uca_link = '" . $_POST['uca_link'] . "', uca_day = '" . $_POST['uca_day'] . "', uca_scroll = '" . $_POST['uca_scroll'] . "', uca_descript = '" . $_POST['uca_descript'] . "' "); } header('Location:index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1'. $alert); exit; } } /** * Удаление календаря * * @param int $unicalendar_id - идентификатор календаря */ function unicalendarDelete($unicalendar_id) { global $AVE_DB; $AVE_DB->Query("DELETE FROM " . PREFIX . "_module_unicalendar WHERE id = '" . $unicalendar_id . "'"); header('Location:index.php?do=modules&action=modedit&mod=unicalendar&moduleaction=1&cp=' . SESSION); exit; } } ?>