Exemplo n.º 1
0
function editPoll($uid = 0, $option = 'com_poll')
{
    global $database, $my, $adminLanguage;
    $row = new mosPoll($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        mosRedirect("index2.php?option=" . $option, $adminLanguage->A_COMP_POLL_THE . " " . $row->title . " " . $adminLanguage->A_COMP_POLL_BEING);
    }
    $options = array();
    if ($uid) {
        $row->checkout($my->id);
        $query = "SELECT id, text FROM #__poll_data" . "\n WHERE pollid='{$uid}'" . "\n ORDER BY id";
        $database->setQuery($query);
        $options = $database->loadObjectList();
    } else {
        $row->lag = 3600 * 24;
    }
    // get selected pages
    if ($uid) {
        $database->setQuery("SELECT menuid AS value FROM #__poll_menu WHERE pollid='{$row->id}'");
        $lookup = $database->loadObjectList();
    } else {
        $lookup = array(mosHTML::makeOption(0, 'All'));
    }
    // build the html select list
    $lists['select'] = mosAdminMenus::MenuLinks($lookup, 1, 1);
    HTML_poll::editPoll($row, $options, $lists);
}
Exemplo n.º 2
0
function editPoll($uid = 0, $option = 'com_poll')
{
    global $database, $my;
    $row = new mosPoll($database);
    // load the row from the db table
    $row->load($uid);
    // fail if checked out not by 'me'
    if ($row->checked_out && $row->checked_out != $my->id) {
        $msg = sprintf(T_('The poll %s is currently being edited by another administrator.'), $row->title);
        mosRedirect('index2.php?option=' . $option, $msg);
    }
    $options = array();
    if ($uid) {
        $row->checkout($my->id);
        $query = "SELECT id, text FROM #__poll_data" . "\n WHERE pollid='{$uid}'" . "\n ORDER BY id";
        $database->setQuery($query);
        $options = $database->loadObjectList();
    } else {
        $row->lag = 3600 * 24;
    }
    // get selected pages
    if ($uid) {
        $database->setQuery("SELECT menuid AS value FROM #__poll_menu WHERE pollid='{$row->id}'");
        $lookup = $database->loadObjectList();
    } else {
        $lookup = array(mosHTML::makeOption(0, 'All'));
    }
    // build the html select list
    $lists['select'] = mosAdminMenus::MenuLinks($lookup, 1, 1);
    HTML_poll::editPoll($row, $options, $lists);
}
Exemplo n.º 3
0
function editPoll($uid = 0, $option = 'com_poll')
{
    global $database, $my;
    $row = new mosPoll($database);
    // load the row from the db table
    $row->load((int) $uid);
    // fail if checked out not by 'me'
    if ($row->isCheckedOut($my->id)) {
        mosRedirect('index2.php?option=' . $option, 'The poll ' . $row->title . ' is currently being edited by another administrator.');
    }
    $options = array();
    if ($uid) {
        $row->checkout($my->id);
        $query = "SELECT id, text" . "\n FROM #__poll_data" . "\n WHERE pollid = " . (int) $uid . "\n ORDER BY id";
        $database->setQuery($query);
        $options = $database->loadObjectList();
    } else {
        $row->lag = 3600 * 24;
        $row->published = 1;
    }
    // get selected pages
    if ($uid) {
        $query = "SELECT menuid AS value" . "\n FROM #__poll_menu" . "\n WHERE pollid = " . (int) $row->id;
        $database->setQuery($query);
        $lookup = $database->loadObjectList();
    } else {
        $lookup = array(mosHTML::makeOption(0, 'All'));
    }
    // build the html select list
    $lists['select'] = mosAdminMenus::MenuLinks($lookup, 1, 1);
    // build the html select list for published
    $lists['published'] = mosAdminMenus::Published($row);
    HTML_poll::editPoll($row, $options, $lists);
}
Exemplo n.º 4
0
function pollresult($uid)
{
    global $database, $mosConfig_offset, $mosConfig_live_site, $Itemid;
    global $mainframe;
    $poll = new mosPoll($database);
    $poll->load($uid);
    if (empty($poll->title)) {
        $poll->id = '';
        $poll->title = T_('Select Poll from the list');
    }
    $first_vote = '';
    $last_vote = '';
    if (isset($poll->id) && $poll->id != "") {
        $query = "SELECT MIN(date) AS mindate, MAX(date) AS maxdate" . "\n FROM #__poll_date" . "\n WHERE poll_id='{$poll->id}'";
        $database->setQuery($query);
        $dates = $database->loadObjectList();
        if (isset($dates[0]->mindate)) {
            $first_vote = mosFormatDate($dates[0]->mindate, _DATE_FORMAT_LC2);
            $last_vote = mosFormatDate($dates[0]->maxdate, _DATE_FORMAT_LC2);
        }
    }
    $query = "SELECT a.id, a.text, count( DISTINCT b.id ) AS hits, count( DISTINCT b.id )/COUNT( DISTINCT a.id )*100.0 AS percent" . "\n FROM #__poll_data AS a" . "\n LEFT JOIN #__poll_date AS b ON b.vote_id = a.id" . "\n WHERE a.pollid='{$poll->id}' AND a.text <> ''" . "\n GROUP BY a.id" . "\n ORDER BY a.id";
    $database->setQuery($query);
    $votes = $database->loadObjectList();
    $query = "SELECT id, title" . "\n FROM #__polls" . "\n WHERE published=1" . "\n ORDER BY id";
    $database->setQuery($query);
    $polls = $database->loadObjectList();
    reset($polls);
    $link = sefRelToAbs('index.php?option=com_poll&amp;task=results&amp;id=\' + this.options[selectedIndex].value + \'&amp;Itemid=' . $Itemid . '\' + \'');
    $pollist = '<select name="id" class="inputbox" size="1" style="width:200px" onchange="if (this.options[selectedIndex].value != \'\') {document.location.href=\'' . $link . '\'}">';
    $pollist .= '<option value="">' . T_('Select Poll from the list') . '</option>';
    for ($i = 0, $n = count($polls); $i < $n; $i++) {
        $k = $polls[$i]->id;
        $t = $polls[$i]->title;
        $sel = $k == intval($poll->id) ? " selected=\"selected\"" : '';
        $pollist .= "\n\t<option value=\"" . $k . "\"{$sel}>" . $t . "</option>";
    }
    $pollist .= '</select>';
    // Adds parameter handling
    $menu =& new mosMenu($database);
    $menu->load($Itemid);
    $params =& new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('header', $menu->name);
    $mainframe->SetPageTitle($poll->title);
    poll_html::showResults($poll, $votes, $first_vote, $last_vote, $pollist, $params);
}
Exemplo n.º 5
0
function pollresult($uid)
{
    global $database, $Itemid;
    global $mainframe;
    $poll = new mosPoll($database);
    $poll->load((int) $uid);
    // if id value is passed and poll not published then exit
    if ($poll->id != '' && !$poll->published) {
        mosNotAuth();
        return;
    }
    $first_vote = '';
    $last_vote = '';
    $votes = '';
    /*
    Check if there is a poll corresponding to id
    and if poll is published
    */
    if (isset($poll->id) && $poll->id != '' && $poll->published == 1) {
        if (empty($poll->title)) {
            $poll->id = '';
            $poll->title = _SELECT_POLL;
        }
        $query = "SELECT MIN( date ) AS mindate, MAX( date ) AS maxdate" . "\n FROM #__poll_date" . "\n WHERE poll_id = " . (int) $poll->id;
        $database->setQuery($query);
        $dates = $database->loadObjectList();
        if (isset($dates[0]->mindate)) {
            $first_vote = mosFormatDate($dates[0]->mindate, _DATE_FORMAT_LC2);
            $last_vote = mosFormatDate($dates[0]->maxdate, _DATE_FORMAT_LC2);
        }
        $query = "SELECT a.id, a.text, a.hits, b.voters" . "\n FROM #__poll_data AS a" . "\n INNER JOIN #__polls AS b ON b.id = a.pollid" . "\n WHERE a.pollid = " . (int) $poll->id . "\n AND a.text != ''" . "\n AND b.published = 1";
        $database->setQuery($query);
        $votes = $database->loadObjectList();
    }
    // list of polls for dropdown selection
    $query = "SELECT id, title" . "\n FROM #__polls" . "\n WHERE published = 1" . "\n ORDER BY id";
    $database->setQuery($query);
    $polls = $database->loadObjectList();
    // Itemid for dropdown
    $_Itemid = '';
    if ($Itemid && $Itemid != 99999999) {
        $_Itemid = '&amp;Itemid=' . $Itemid;
    }
    // dropdown output
    $link = sefRelToAbs('index.php?option=com_poll&amp;task=results&amp;id=\' + this.options[selectedIndex].value + \'' . $_Itemid . '\' + \'');
    $pollist = '<select name="id" class="inputbox" size="1" style="width:200px" onchange="if (this.options[selectedIndex].value != \'\') {document.location.href=\'' . $link . '\'}">';
    $pollist .= '<option value="">' . _SELECT_POLL . '</option>';
    for ($i = 0, $n = count($polls); $i < $n; $i++) {
        $k = $polls[$i]->id;
        $t = $polls[$i]->title;
        $sel = $k == intval($poll->id) ? " selected=\"selected\"" : '';
        $pollist .= "\n\t<option value=\"" . $k . "\"{$sel}>" . $t . "</option>";
    }
    $pollist .= '</select>';
    // Adds parameter handling
    $menu = $mainframe->get('menu');
    $params = new mosParameters($menu->params);
    $params->def('page_title', 1);
    $params->def('pageclass_sfx', '');
    $params->def('back_button', $mainframe->getCfg('back_button'));
    $params->def('header', $menu->name);
    $mainframe->SetPageTitle($poll->title);
    poll_html::showResults($poll, $votes, $first_vote, $last_vote, $pollist, $params);
}