コード例 #1
0
ファイル: UserController.php プロジェクト: elvyrra/hawk
 /**
  * Display the tabs of the users page
  */
 public function index()
 {
     $tabs = array('users' => $this->listUsers(), 'roles' => RoleController::getInstance()->listRoles(), 'questions' => QuestionController::getInstance()->listQuestions());
     $this->addCss(Plugin::current()->getCssUrl('users.less'));
     $this->addJavaScript(Plugin::current()->getJsUrl('users.js'));
     $page = View::make(Plugin::current()->getViewsDir() . 'users.tpl', array('tabs' => $tabs));
     return NoSidebarTab::make(array('page' => $page, 'icon' => 'users', 'title' => 'Utilisateurs'));
 }
コード例 #2
0
ファイル: Question.php プロジェクト: lidijakralj/bober
 public function processImport($fileName)
 {
     $tmpdirname = tempnam(sys_get_temp_dir(), 'questionImport');
     $tmpdir = $tmpdirname . '_dir';
     mkdir($tmpdir);
     $error = false;
     $id = -1;
     try {
         if (is_dir($tmpdir)) {
             if (QuestionController::unzip($fileName, $tmpdir)) {
                 if (file_exists($tmpdir . '/Manifest.json')) {
                     $json = file_get_contents($tmpdir . '/Manifest.json');
                     $jsonValidation = $this->ValidateJSONMAnifestAgainstShema($json);
                     if ($jsonValidation['return']) {
                         $manifest = json_decode($json, true);
                         $id = $this->processJSONData($manifest, $tmpdir);
                     } else {
                         // json ni tak kot zahetva shema
                         throw new CHttpException(405, Yii::t('app', $jsonValidation['error']));
                     }
                 } else {
                     throw new CHttpException(405, Yii::t('app', 'Manifest.json does not exist.'));
                 }
                 QuestionController::delTree($tmpdir);
             } else {
                 throw new CHttpException(405, Yii::t('app', 'Unzip unsuccessful'));
             }
         }
     } catch (Exception $e) {
         $error = true;
         $exception = $e;
     }
     if (is_dir($tmpdir)) {
         QuestionController::delTree($tmpdir);
     }
     unlink($tmpdirname);
     if ($error) {
         throw $exception;
     }
     return $id;
 }
コード例 #3
0
    public function answerQuestion()
    {
        $qid = $_POST[self::QID];
        $content = $_POST['content'];
        $ans_user = $_SESSION[Controller::UID];
        $time = date(Controller::TIME);
        try {
            $this->advice->insert(array($qid, $content, $ans_user, $time));
            header("Location: ../../html/question.php?qid=" . $qid);
        } catch (Exception $e) {
            print_r($e);
        }
    }
    public function getQuestionAndAdvice()
    {
        $qid = $_GET[self::QID];
        $this->ajaxReturn($this->question->findByKey($qid));
        echo Controller::SEPARATOR;
        $this->ajaxReturn($this->advice->findByKey($qid));
    }
    public function getAll()
    {
        $questions = $this->question->findAll();
        $this->ajaxReturn($questions);
    }
}
if (defined('TEST_SUITE') && TEST_SUITE == __FILE__) {
    // run test suite here
    $analysis = new QuestionController();
    $analysis->distribute();
}