public static function getSession()
 {
     if (!isset(self::$persistentSession)) {
         self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhquestionary'));
     }
     return self::$persistentSession;
 }
 public function __get($var)
 {
     switch ($var) {
         case 'votes':
             $this->votes = erLhcoreClassQuestionary::getCount(array('filter' => array('option_id' => $this->id)), 'lh_question_option_answer');
             return $this->votes;
             break;
         default:
             break;
     }
 }
 public function __get($var)
 {
     switch ($var) {
         case 'total_votes':
             $this->total_votes = erLhcoreClassQuestionary::getCount(array('filter' => array('question_id' => $this->id)), 'lh_question_option_answer');
             return $this->total_votes;
             break;
         case 'total_votes_for_percentange':
             $this->total_votes_for_percentange = $this->total_votes == 0 ? 1 : $this->total_votes;
             return $this->total_votes_for_percentange;
             break;
         case 'revote_seconds':
             $this->revote_seconds = $this->revote * 3600;
             return $this->revote_seconds;
             break;
         case 'options':
             $this->options = erLhcoreClassQuestionary::getList(array('sort' => 'priority DESC', 'filter' => array('question_id' => $this->id)), 'erLhcoreClassModelQuestionOption', 'lh_question_option');
             return $this->options;
             break;
         default:
             break;
     }
 }
Esempio n. 4
0
        $Option->question_id = $Question->id;
        $Option->saveThis();
        // Mark question as it's voting
        $Question->is_voting = 1;
        $Question->saveThis();
        erLhcoreClassModule::redirect('questionary/edit', '/' . $Question->id . '/(tab)/voting');
        exit;
    } else {
        $tpl->set('errors', $Errors);
    }
}
if (isset($_POST['CancelO'])) {
    erLhcoreClassModule::redirect('questionary/edit', '/' . $Question->id . '/(tab)/voting');
    exit;
}
// Answers
$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('questionary/edit') . '/' . $Question->id . '/(tab)/answers';
$pages->items_total = erLhcoreClassQuestionary::getCount(array('filter' => array('question_id' => $Question->id)), 'lh_question_answer');
$pages->setItemsPerPage(20);
$pages->paginate();
$items = array();
if ($pages->items_total > 0) {
    $items = erLhcoreClassQuestionary::getList(array('filter' => array('question_id' => $Question->id), 'offset' => $pages->low, 'limit' => $pages->items_per_page), 'erLhcoreClassModelQuestionAnswer', 'lh_question_answer');
}
$tpl->set('items', $items);
$tpl->set('pages', $pages);
$tpl->set('question', $Question);
$tpl->set('option', $Option);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('questionary/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/list', 'Questionary')), array('title' => erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Edit a question')));
Esempio n. 5
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhquestionary/list.tpl.php');
$pages = new lhPaginator();
$pages->serverURL = erLhcoreClassDesign::baseurl('questionary/list');
$pages->items_total = erLhcoreClassQuestionary::getCount();
$pages->setItemsPerPage(20);
$pages->paginate();
$items = array();
if ($pages->items_total > 0) {
    $items = erLhcoreClassQuestionary::getList(array('offset' => $pages->low, 'limit' => $pages->items_per_page));
}
$tpl->set('items', $items);
$tpl->set('pages', $pages);
$Result['content'] = $tpl->fetch();
$Result['path'] = array(array('url' => erLhcoreClassDesign::baseurl('questionary/list'), 'title' => erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/list', 'Questionary')));
 public function saveThis()
 {
     $this->ctime = time();
     $this->ip = ip2long(erLhcoreClassIPDetect::getIP());
     erLhcoreClassQuestionary::getSession()->saveOrUpdate($this);
 }
Esempio n. 7
0
<?php

if (!$currentUser->validateCSFRToken($Params['user_parameters_unordered']['csfr'])) {
    die('Invalid CSFR Token');
    exit;
}
$question = erLhcoreClassQuestionary::getSession()->load('erLhcoreClassModelQuestion', $Params['user_parameters']['id']);
$question->removeThis();
erLhcoreClassModule::redirect('questionary/list');
exit;
Esempio n. 8
0
            $answer->saveThis();
            erLhcoreClassChatEventDispatcher::getInstance()->dispatch('questionaire.feedback_left', array('feedback' => &$answer));
            $tpl->set('received', true);
        } else {
            $tpl->set('errors', $Errors);
        }
    }
}
if ($votingRelative !== false) {
    $baseFilter = array('filter' => array('question_id' => $votingRelative->id, 'ip' => ip2long(erLhcoreClassIPDetect::getIP())));
    if ($votingRelative->revote > 0) {
        $baseFilter['filtergt']['ctime'] = time() - $votingRelative->revote_seconds;
    }
    if ($votingRelative->is_voting == 1) {
        if (erLhcoreClassQuestionary::getCount($baseFilter, 'lh_question_option_answer') > 0) {
            $tpl->set('already_voted', true);
        }
    } elseif (erLhcoreClassQuestionary::getCount($baseFilter, 'lh_question_answer') > 0) {
        $tpl->set('already_voted', true);
    }
}
$tpl->set('voting', $votingRelative);
$tpl->set('answer', $answer);
$Result['content'] = $tpl->fetch();
$Result['pagelayout'] = 'widget';
$Result['dynamic_height'] = true;
$Result['dynamic_height_message'] = 'lhc_sizing_questionary';
if ($embedMode == true) {
    $Result['dynamic_height_message'] = 'lhc_sizing_questionary_page';
    $Result['pagelayout_css_append'] = 'embed-widget';
}
Esempio n. 9
0
?>
"/>
      <input type="submit" class="btn btn-default" name="CancelO" value="<?php 
echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Cancel');
?>
"/>
    </div>

	<?php 
include erLhcoreClassDesign::designtpl('lhkernel/csfr_token.tpl.php');
?>

</form>

<?php 
$optionsItems = erLhcoreClassQuestionary::getList(array('sort' => 'priority DESC', 'filter' => array('question_id' => $question->id)), 'erLhcoreClassModelQuestionOption', 'lh_question_option');
if (!empty($optionsItems)) {
    ?>
<table class="table" cellpadding="0" cellspacing="0">
<thead>
<tr>
    <th width="1%">ID</th>
    <th><?php 
    echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Option');
    ?>
</th>
    <th class="one"><?php 
    echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/edit', 'Position');
    ?>
</th>
    <th width="1%">&nbsp;</th>