function polls() { $model = new cms_model_polls(); global $_LANG; $do = cmsCore::getInstance()->do; //========================================================================================================================// //========================================================================================================================// if ($do == 'view') { $answer = cmsCore::request('answer', 'str', ''); $poll_id = cmsCore::request('poll_id', 'int'); if (!$answer || !$poll_id) { if (cmsCore::isAjax()) { cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['SELECT_THE_OPTION'])); } else { cmsCore::error404(); } } $poll = $model->getPoll($poll_id); if (!$poll) { cmsCore::jsonOutput(array('error' => true, 'text' => '')); } if ($model->isUserVoted($poll_id)) { cmsCore::jsonOutput(array('error' => true, 'text' => '')); } if (!cmsUser::checkCsrfToken()) { cmsCore::halt(); } $model->votePoll($poll, $answer); cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['VOTE_ACCEPTED'])); } }
function mod_polls($module_id, $cfg) { cmsCore::loadModel('polls'); $model = new cms_model_polls(); if ($cfg['poll_id'] > 0) { $poll = $model->getPoll($cfg['poll_id']); } else { $poll = $model->getPoll(0, 'RAND()'); } if (!$poll) { return false; } cmsPage::initTemplate('modules', 'mod_polls')->assign('poll', $poll)->assign('is_voted', $model->isUserVoted($poll['id']))->assign('module_id', $module_id)->assign('cfg', $cfg)->display('mod_polls.tpl'); return true; }
die('ACCESS DENIED'); } /******************************************************************************/ // // // InstantCMS v1.10.6 // // http://www.instantcms.ru/ // // // // written by InstantCMS Team, 2007-2015 // // produced by InstantSoft, (www.instantsoft.ru) // // // // LICENSED BY GNU/GPL v2 // // // /******************************************************************************/ $opt = cmsCore::request('opt', 'str', 'list'); cmsCore::loadModel('polls'); $model = new cms_model_polls(); if ($opt == 'list') { $toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_ADD_POLL'], 'link' => '?view=components&do=config&id=' . $id . '&opt=add'); } else { $toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();'); $toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => '?view=components&do=config&id=' . $id); } cpToolMenu($toolmenu); //=================================================================================================// //=================================================================================================// if ($opt == 'list') { $fields[] = array('title' => 'id', 'field' => 'id', 'width' => '30'); $fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'filter' => '15', 'link' => '?view=components&do=config&id=' . $id . '&opt=edit&poll_id=%id%'); $fields[] = array('title' => $_LANG['DATE'], 'field' => 'pubdate', 'width' => '110', 'prc' => array('cmsCore', 'dateFormat')); $actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=components&do=config&id=' . $id . '&opt=edit&poll_id=%id%'); $actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_DELETE_POLL'], 'link' => '?view=components&do=config&id=' . $id . '&opt=delete&poll_id=%id%');