本文整理汇总了PHP中Vote::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::setId方法的具体用法?PHP Vote::setId怎么用?PHP Vote::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::setId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_action
public function edit_action($questionnaire_id = null)
{
if (!$GLOBALS['perm']->have_perm("autor")) {
throw new AccessDeniedException("Only for authors.");
}
$this->questionnaire = new Questionnaire($questionnaire_id);
if ($this->questionnaire->isNew()) {
PageLayout::setTitle(_("Neuer Fragebogen"));
} else {
PageLayout::setTitle(_("Fragebogen bearbeiten: ") . $this->questionnaire['title']);
}
if (!$this->questionnaire->isEditable()) {
throw new AccessDeniedException("Fragebogen ist nicht bearbeitbar.");
}
if ($this->questionnaire->isStarted() && $this->questionnaire->countAnswers() > 0) {
throw new Exception("Fragebogen ist gestartet worden und kann jetzt nicht mehr bearbeitet werden. Stoppen oder löschen Sie den Fragebogen stattdessen.");
}
if (Request::isPost()) {
$questionnaire_data = Request::getArray("questionnaire");
$questionnaire_data['startdate'] = $questionnaire_data['startdate'] ? strtotime($questionnaire_data['startdate']) ?: time() : null;
$questionnaire_data['stopdate'] = strtotime($questionnaire_data['stopdate']) ?: null;
$questionnaire_data['anonymous'] = (int) $questionnaire_data['anonymous'];
$questionnaire_data['editanswers'] = (int) $questionnaire_data['editanswers'];
if ($this->questionnaire->isNew()) {
$questionnaire_data['visible'] = $questionnaire_data['startdate'] <= time() && (!$questionnaire_data['stopdate'] || $questionnaire_data['stopdate'] >= time()) ? 1 : 0;
}
$this->questionnaire->setData($questionnaire_data);
foreach (Request::getArray("question_types") as $question_id => $question_type) {
$question = null;
foreach ($this->questionnaire->questions as $index => $q) {
if ($q->getId() === $question_id) {
$question = $q;
break;
}
}
if (!$question) {
$question = new $question_type($question_id);
$question['questiontype'] = $question_type;
$this->questionnaire->questions[] = $question;
}
$question['position'] = $index + 1;
$question->createDataFromRequest();
}
if (Request::submitted("questionnaire_store")) {
//save everything
$this->questionnaire['user_id'] = $GLOBALS['user']->id;
$is_new = $this->questionnaire->isNew();
$this->questionnaire->store();
if ($is_new && Request::get("range_id") && Request::get("range_type")) {
if (Request::get("range_id") === "start" && !$GLOBALS['perm']->have_perm("root")) {
throw new Exception("Der Fragebogen darf nicht von Ihnen auf die Startseite eingehängt werden, sondern nur von einem Admin.");
}
if (Request::get("range_type") === "course" && !$GLOBALS['perm']->have_studip_perm("tutor", Request::get("range_id"))) {
throw new Exception("Der Fragebogen darf nicht in die ausgewählte Veranstaltung eingebunden werden.");
}
$assignment = new QuestionnaireAssignment();
$assignment['questionnaire_id'] = $this->questionnaire->getId();
$assignment['range_id'] = Request::option("range_id");
$assignment['range_type'] = Request::get("range_type");
$assignment['user_id'] = $GLOBALS['user']->id;
$assignment->store();
}
if ($is_new) {
$message = MessageBox::success(_("Der Fragebogen wurde erfolgreich erstellt."));
} else {
$message = MessageBox::success(_("Der Fragebogen wurde gespeichert."));
}
if (Request::isAjax()) {
$this->questionnaire->restore();
$this->questionnaire->resetRelation("assignments");
$output = array('func' => "STUDIP.Questionnaire.updateOverviewQuestionnaire", 'payload' => array('questionnaire_id' => $this->questionnaire->getId(), 'overview_html' => $this->render_template_as_string("questionnaire/_overview_questionnaire.php"), 'widget_html' => $this->questionnaire->isStarted() ? $this->render_template_as_string("questionnaire/_widget_questionnaire.php") : "", 'message' => $this->questionnaire->isStarted() ? "" : $message->__toString()));
$this->response->add_header("X-Dialog-Close", 1);
$this->response->add_header("X-Dialog-Execute", json_encode(studip_utf8encode($output)));
} else {
PageLayout::postMessage($message);
if (Request::get("range_type") === "user") {
$this->redirect("profile");
} elseif (Request::get("range_type") === "course") {
$this->redirect("course/overview");
} elseif (Request::get("range_id") === "start") {
$this->redirect("start");
} else {
$this->redirect("questionnaire/overview");
}
$this->redirect("questionnaire/overview");
}
}
}
if ($this->questionnaire->isNew() && count($this->questionnaire->questions) === 0) {
$question = new Vote();
$question->setId($question->getNewId());
$question['questiontype'] = "Vote";
$this->questionnaire->questions[] = $question;
}
}