當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Survey::get_from_db方法代碼示例

本文整理匯總了PHP中Survey::get_from_db方法的典型用法代碼示例。如果您正苦於以下問題:PHP Survey::get_from_db方法的具體用法?PHP Survey::get_from_db怎麽用?PHP Survey::get_from_db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Survey的用法示例。


在下文中一共展示了Survey::get_from_db方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: elementFunction

function elementFunction()
{
    // get global user object
    global $user;
    // set connection var
    global $db;
    // get current time
    $time_now = date("Y-m-d H:i:s");
    // protect from unauthorized access
    if (!isset($user) or !isset($_POST['formElementFunction'])) {
        logout();
        die;
    }
    // set empty survey
    $session_question = new Question();
    $session_question = get_session_question();
    $question_id = $_POST['formElementFunction'];
    if ($question_id != "") {
        $session_question->get_from_db($question_id);
    }
    // get the function
    $function = '';
    foreach ($_POST as $key => $post) {
        if ($post != $question_id) {
            $function = substr($key, 11);
        }
    }
    if ($function == 'Edit') {
        // set security
        $survey = new Survey();
        $survey->get_from_db($session_question->getSurvey());
        if ($survey->getCreatedBy() != $user->getId()) {
            if ($user->getAdmin() != 1) {
                logout();
                die;
            }
        }
        $_SESSION['session_question'] = serialize($session_question);
        // get session answers
        $session_answers = array();
        $session_answer_ids = get_survey_answers($session_question->getId());
        foreach ($session_answer_ids as $answer_id) {
            $answer = new Answer();
            $answer->get_from_db($answer_id);
            array_push($session_answers, $answer);
        }
        $_SESSION['session_answers'] = serialize($session_answers);
        $cookie_key = 'msg';
        $cookie_value = 'Вие избрахте елемент от анкетата за редакция!<br />Отидете на раздел "Добавете или редактирайте елемент към анкетата"';
        setcookie($cookie_key, $cookie_value, time() + 1);
        header('Location: ' . ROOT_DIR . '?page=survey_edit');
        die;
    } elseif ($function == 'PrintExcel') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcel: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReport.php?question_id=' . $question_id);
        die;
    } elseif ($function == 'PrintExcelGroups') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcelGroups: unathorised access");
            $error->writeLog();
            logout();
            die;
        }
        header('Location: ' . ROOT_DIR . 'functions/print/excel/questionReportGroups.php?question_id=' . $question_id);
        die;
    } elseif ($function == 'PrintExcelGender') {
        // get global user object
        global $user;
        // get survey id
        $question_id = $_POST['formElementFunction'];
        // check if the user is the surveyCreator or systemAdmin
        $question = new Question();
        $question->get_from_db($question_id);
        $survey = new Survey();
        $survey->get_from_db($question->getSurvey());
        if (intval($survey->getCreatedBy()) != $user->getId() && $user->getAdmin() != 1) {
            $error = new Error("Question PrintExcelGender: unathorised access");
//.........這裏部分代碼省略.........
開發者ID:tttodorov13,項目名稱:suSurvey,代碼行數:101,代碼來源:functions.php

示例2: foreach

?>
<div class="ac info_box box_green">
    <h4>
        <?php 
echo USER_SURVEY_HOMEPAGE_AVAILABLE_SURVEYS;
?>
    </h4>
</div>
<div class="ac">
    <div class="accordion">
        <?php 
$surveys_by_user = get_available_by_user_surveys($user->getId());
if (!empty($surveys_by_user)) {
    foreach ($surveys_by_user as $survey_id) {
        $survey = new Survey();
        $survey->get_from_db($survey_id);
        ?>
                <h3 class="no-float ac"><?php 
        print_r($survey->getTitle());
        ?>
</h3>
                <div>
                    <div class="ac">
                        <div class="action no-margin ac">
                            <form id="formSurvey<?php 
        print_r($survey->getId());
        ?>
"
                                  class="form ac prefix_2" 
                                  action="./?page=user_survey&amp;funct=survey_funct" 
                                  method="POST">
開發者ID:tttodorov13,項目名稱:suSurvey,代碼行數:31,代碼來源:user_survey.php

示例3: logout

if (!isset($_SESSION)) {
    session_start();
}
// protect from unauthorized access
if (!isset($_SESSION['user'])) {
    logout();
    die;
}
// protect from error access
if (!isset($_SESSION['survey_id'])) {
    header('location: /?page=my_surveys');
    die;
}
global $user;
$survey = new Survey();
$survey->get_from_db($_SESSION['survey_id']);
$answers = get_survey_answers($survey->getId());
$groups = get_survey_staff_groups($survey->getId());
foreach (get_survey_student_groups($survey->getId()) as $group_id) {
    array_push($groups, $group_id);
}
foreach (get_survey_local_groups($survey->getId()) as $group_id) {
    array_push($groups, $group_id);
}
//-------------------------------------------------
// Include the main TCPDF library (search for installation path).
require_once ROOT_DIR . 'functions/print/tcpdf.php';
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF
{
    //Page header
開發者ID:tttodorov13,項目名稱:suSurvey,代碼行數:31,代碼來源:survey_print.php


注:本文中的Survey::get_from_db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。