当前位置: 首页>>代码示例>>PHP>>正文


PHP CSRFProtection::verifyUnsafeRequest方法代码示例

本文整理汇总了PHP中CSRFProtection::verifyUnsafeRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP CSRFProtection::verifyUnsafeRequest方法的具体用法?PHP CSRFProtection::verifyUnsafeRequest怎么用?PHP CSRFProtection::verifyUnsafeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSRFProtection的用法示例。


在下文中一共展示了CSRFProtection::verifyUnsafeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit_action

 /**
  * This method edits an existing semester or creates a new semester.
  *
  * @param mixed $id Id of the semester or null to create a semester.
  */
 public function edit_action($id = null)
 {
     $this->semester = new Semester($id);
     PageLayout::setTitle($this->semester->isNew() ? _('Semester anlegen') : _('Semester bearbeiten'));
     if (Request::isPost()) {
         CSRFProtection::verifyUnsafeRequest();
         // Extract values
         $this->semester->name = Request::get('name');
         $this->semester->description = Request::get('description');
         $this->semester->semester_token = Request::get('token');
         $this->semester->beginn = $this->getTimeStamp('beginn');
         $this->semester->ende = $this->getTimeStamp('ende', '23:59:59');
         $this->semester->vorles_beginn = $this->getTimeStamp('vorles_beginn');
         $this->semester->vorles_ende = $this->getTimeStamp('vorles_ende', '23:59:59');
         // Validate
         $errors = $this->validateSemester($this->semester);
         // If valid, try to store the semester
         if (empty($errors) && $this->semester->isDirty() && !$this->semester->store()) {
             $errors[] = _('Fehler bei der Speicherung Ihrer Daten. Bitte überprüfen Sie Ihre Angaben.');
         }
         // Output potential errors or show success message and relocate
         if (count($errors) === 1) {
             $error = reset($errors);
             PageLayout::postMessage(MessageBox::error($error));
         } elseif (!empty($errors)) {
             $message = _('Ihre eingegebenen Daten sind ungültig.');
             PageLayout::postMessage(MessageBox::error($message, $errors));
         } else {
             $message = _('Das Semester wurde erfolgreich gespeichert.');
             PageLayout::postMessage(MessageBox::success($message));
             $this->relocate('admin/semester');
         }
         $this->errors = $errors;
     }
 }
开发者ID:ratbird,项目名称:hope,代码行数:40,代码来源:semester.php

示例2: edit_action

 /**
  * This method edits existing holidays or creates new holidays
  *
  * @param mixed $id Id of the holiday or null to create one
  */
 public function edit_action($id = null)
 {
     $this->holiday = new SemesterHoliday($id);
     PageLayout::setTitle($this->holiday->isNew() ? _('Ferien anlegen') : _('Ferien bearbeiten'));
     if (Request::isPost()) {
         CSRFProtection::verifyUnsafeRequest();
         $this->holiday->name = Request::get('name');
         $this->holiday->description = Request::get('description');
         $this->holiday->beginn = $this->getTimeStamp('beginn');
         $this->holiday->ende = $this->getTimeStamp('ende', '23:59:59');
         $errors = array();
         if (!$this->holiday->name) {
             $errors[] = _('Bitte geben Sie einen Namen ein.');
         }
         if (!$this->holiday->beginn) {
             $errors[] = _('Bitte geben Sie einen Ferienbeginn ein.');
         }
         if (!$this->holiday->ende) {
             $errors[] = _('Bitte geben Sie ein Ferienende ein.');
         }
         if ($this->holiday->beginn > $this->holiday->ende) {
             $errors[] = _('Das Ferienende liegt vor dem Beginn.');
         }
         if (!empty($errors)) {
             PageLayout::postMessage(MessageBox::error(_('Ihre eingegebenen Daten sind ungültig.'), $errors));
         } elseif ($this->holiday->isDirty() && !$this->holiday->store()) {
             PageLayout::postMessage(MessageBox::error(_('Die Ferien konnten nicht gespeichert werden.')));
         } else {
             PageLayout::postMessage(MessageBox::success(_('Die Ferien wurden erfolgreich gespeichert.')));
             $this->relocate('admin/holidays');
         }
     }
 }
开发者ID:ratbird,项目名称:hope,代码行数:38,代码来源:holidays.php

示例3: delete_action

 public function delete_action($plugin_id)
 {
     $this->marketplugin = MarketPlugin::find($plugin_id);
     if (Request::submitted('delete') && $this->marketplugin->isWritable()) {
         CSRFProtection::verifyUnsafeRequest();
         $this->marketplugin->delete();
         $this->redirect('myplugins/overview');
     }
 }
开发者ID:studip,项目名称:PluginMarket,代码行数:9,代码来源:myplugins.php

示例4: edit_action

 /**
  * Edits or creates a page.
  *
  * @param mixed $id Id of the page to edit; a new page will be created if
  *                  this parameter is omitted.
  */
 public function edit_action($id = null)
 {
     if (Request::submitted('submit')) {
         CSRFProtection::verifyUnsafeRequest();
         $scm = new StudipScmEntry($id);
         $scm->tab_name = Request::get('tab_name_template') ?: Request::get('tab_name');
         $scm->content = Studip\Markup::purifyHtml(Request::get('content'));
         $scm->user_id = $GLOBALS['user']->id;
         $scm->range_id = $GLOBALS['SessSemName'][1];
         if ($scm->isNew()) {
             $temp = StudipScmEntry::findByRange_id($GLOBALS['SessSemName'][1], 'ORDER BY position ASC');
             $scms = SimpleORMapCollection::createFromArray($temp);
             $max = max($scms->pluck('position'));
             $scm->position = $max + 1;
         }
         if ($scm->store() !== false) {
             $message = MessageBox::success(_('Die Änderungen wurden übernommen.'));
             PageLayout::postMessage($message);
         }
         $this->redirect('course/scm/' . $scm->id);
     }
     $this->scm = new StudipScmEntry($id);
     $this->set_title(_('Informationsseite bearbeiten') . ': ' . $this->scm->tab_name);
     Navigation::activateItem('/course/scm/' . $this->scm->id);
 }
开发者ID:ratbird,项目名称:hope,代码行数:31,代码来源:scm.php

示例5: ruleApplies

 /**
  * Does the current rule allow the given user to register as participant
  * in the given course? Here, a given password (via the getInput method) is
  * compared to the stored encrypted one.
  *
  * @param  String userId
  * @param  String courseId
  * @return Boolean
  */
 public function ruleApplies($userId, $courseId)
 {
     $errors = array();
     if ($this->checkTimeFrame()) {
         if (Request::get('pwarule_password') === null) {
             $errors[] = _('Die Eingabe eines Passwortes ist erforderlich.');
         } else {
             CSRFProtection::verifyUnsafeRequest();
             $pwcheck = $this->hasher->CheckPassword(Request::get('pwarule_password'), $this->getPassword());
             //migrated passwords
             $pwcheck_m = $this->hasher->CheckPassword(md5(Request::get('pwarule_password')), $this->getPassword());
             if (!($pwcheck || $pwcheck_m)) {
                 $errors[] = $this->getMessage();
             }
         }
     }
     return $errors;
 }
开发者ID:ratbird,项目名称:hope,代码行数:27,代码来源:PasswordAdmission.class.php

示例6: save_action

 /**
  * Saves the given user list to database.
  * 
  * @param String $userlistId user list to save
  */
 public function save_action($userlistId = '')
 {
     CSRFProtection::verifyUnsafeRequest();
     $userlist = new AdmissionUserList($userlistId);
     $userlist->setName(Request::get('name'))->setFactor(Request::float('factor'))->setUsers(Request::getArray('users'))->setOwnerId($GLOBALS['user']->id);
     if ($userlist->store()) {
         PageLayout::postSuccess(_('Die Personenliste wurde gespeichert.'));
     } else {
         PageLayout::postError(_('Die Personenliste konnte nicht gespeichert werden.'));
     }
     $this->redirect('admission/userlist');
 }
开发者ID:ratbird,项目名称:hope,代码行数:17,代码来源:userlist.php

示例7: save_action

 /**
  * Saves the given rule.
  *
  * @param String $ruleType The class name of the configured rule.
  * @param String $ruleId   ID of the rule to save, or empty if this is a new rule.
  */
 public function save_action($ruleType, $ruleId = '')
 {
     CSRFProtection::verifyUnsafeRequest();
     $rules = AdmissionRule::getAvailableAdmissionRules();
     $this->rule = new $ruleType($ruleId);
     $requestData = Request::getInstance();
     // Check for start and end date and parse the String values to timestamps.
     if ($requestData['start_date']) {
         $parsed = date_parse($requestData['start_date']);
         $timestamp = mktime($parsed['hour'], $parsed['minute'], 0, $parsed['month'], $parsed['day'], $parsed['year']);
         $requestData['start_time'] = $timestamp;
     }
     if ($requestData['end_date']) {
         $parsed = date_parse($requestData['end_date']);
         $timestamp = mktime($parsed['hour'], $parsed['minute'], 0, $parsed['month'], $parsed['day'], $parsed['year']);
         $requestData['end_time'] = $timestamp;
     }
     $this->rule->setAllData($requestData);
 }
开发者ID:ratbird,项目名称:hope,代码行数:25,代码来源:rule.php

示例8: process_form

 /**
  * handle common tasks for the romm request form
  * (set properties, searching etc.)
  */
 public static function process_form($request, $admission_turnout = null)
 {
     if (Request::submitted('room_request_form')) {
         CSRFProtection::verifyUnsafeRequest();
         if (Request::submitted('send_room')) {
             $request->setResourceId(Request::option('select_room'));
         } else {
             $request->setResourceId(Request::option('selected_room'));
         }
         if (Request::submitted('reset_resource_id')) {
             $request->setResourceId('');
         }
         if (Request::submitted('reset_room_type')) {
             $request->setCategoryId('');
         }
         if (Request::get('comment') !== null) {
             $request->setComment(Request::get('comment'));
         }
         if (Request::get('reply_recipients') !== null) {
             $request->reply_recipients = Request::get('reply_recipients');
         }
         if (!Request::submitted('reset_room_type')) {
             $request->setCategoryId(Request::option('select_room_type'));
         }
         //Property Requests
         if ($request->getCategoryId()) {
             $request_property_val = Request::getArray('request_property_val');
             foreach ($request->getAvailableProperties() as $prop) {
                 if ($prop["system"] == 2) {
                     //it's the property for the seat/room-size!
                     if (Request::get('seats_are_admission_turnout') && $admission_turnout) {
                         $request->setPropertyState($prop['property_id'], $admission_turnout);
                     } else {
                         if (!Request::submitted('send_room_type')) {
                             $request->setPropertyState($prop['property_id'], abs($request_property_val[$prop['property_id']]));
                         }
                     }
                 } else {
                     $request->setPropertyState($prop['property_id'], $request_property_val[$prop['property_id']]);
                 }
             }
         }
         if (Request::get('search_exp_room') && Request::submitted('search_room') || Request::submitted('search_properties')) {
             $tmp_search_result = $request->searchRoomsToRequest(Request::get('search_exp_room'), Request::submitted('search_properties'));
             $search_by_properties = Request::submitted('search_properties');
             $search_result = array();
             if (count($tmp_search_result)) {
                 $timestamps = $events = array();
                 foreach ($request->getAffectedDates() as $date) {
                     if (!isset($date->room_assignment)) {
                         $timestamps[] = $date->date;
                         $timestamps[] = $date->end_time;
                         $event = new AssignEvent($date->id, $date->date, $date->end_time, null, null, '');
                         $events[$event->getId()] = $event;
                     }
                 }
                 $check_result = array();
                 if (count($events)) {
                     $checker = new CheckMultipleOverlaps();
                     $checker->setTimeRange(min($timestamps), max($timestamps));
                     foreach (array_keys($tmp_search_result) as $room) {
                         $checker->addResource($room);
                     }
                     $checker->checkOverlap($events, $check_result, "assign_id");
                 }
                 foreach ($tmp_search_result as $room_id => $name) {
                     if (isset($check_result[$room_id])) {
                         $details = $check_result[$room_id];
                         if (count($details) >= round(count($events) * Config::get()->RESOURCES_ALLOW_SINGLE_ASSIGN_PERCENTAGE / 100)) {
                             $overlap_status = 'status-red';
                         } elseif (count($details)) {
                             $overlap_status = 'status-yellow';
                         }
                     } else {
                         $overlap_status = 'status-green';
                     }
                     $search_result[$room_id] = array('name' => $name, 'overlap_status' => $overlap_status);
                 }
             }
         }
     }
     return compact('search_result', 'search_by_properties', 'request', 'admission_turnout');
 }
开发者ID:ratbird,项目名称:hope,代码行数:87,代码来源:room_requests.php

示例9: test_action

 function test_action()
 {
     if (Request::submitted('ok')) {
         CSRFProtection::verifyUnsafeRequest();
         $test_api_key = trim(Request::get("test_api_key"));
         $test_method = trim(Request::get("test_method"));
         $test_ip = trim(Request::get("test_ip"));
         if ($test_api_key && $test_method && $test_ip) {
             if (WebserviceAccessRule::checkAccess($test_api_key, $test_method, $test_ip)) {
                 PageLayout::postMessage(MessageBox::success(_("Zugriff erlaubt.")));
             } else {
                 PageLayout::postMessage(MessageBox::error(_("Zugriff verboten.")));
             }
         }
     }
 }
开发者ID:ratbird,项目名称:hope,代码行数:16,代码来源:webservice_access.php

示例10: claim_action

 /**
  * Prioritize courses.
  */
 function claim_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     $user_id = $GLOBALS['user']->id;
     $courseset = CourseSet::getSetForCourse($this->course_id);
     if ($courseset->isSeatDistributionEnabled() && !count($courseset->checkAdmission($user_id, $this->course_id))) {
         if ($limit = $courseset->getAdmissionRule('LimitedAdmission')) {
             $admission_user_limit = Request::int('admission_user_limit');
             if ($admission_user_limit && $admission_user_limit <= $limit->getMaxNumber()) {
                 $limit->setCustomMaxNumber($user_id, $admission_user_limit);
             }
             $admission_prio = Request::getArray('admission_prio');
             $max_prio = max($admission_prio);
             $admission_prio = array_map(function ($a) use(&$max_prio) {
                 return $a > 0 ? $a : ++$max_prio;
             }, $admission_prio);
             if (count(array_unique($admission_prio)) != count(Request::getArray('admission_prio'))) {
                 PageLayout::postMessage(MessageBox::info(_("Sie dürfen jede Priorität nur einmal auswählen. Überprüfen Sie bitte Ihre Auswahl!")));
             }
             $old_prio_count = AdmissionPriority::unsetAllPrioritiesForUser($courseset->getId(), $user_id);
             if ($order_up = key(Request::getArray('admission_prio_order_up'))) {
                 $prio_to_move = $admission_prio[$order_up];
                 $change_with = array_search($prio_to_move - 1, $admission_prio);
                 $admission_prio[$order_up] = $prio_to_move - 1;
                 $admission_prio[$change_with] = $prio_to_move;
             }
             if ($order_down = key(Request::getArray('admission_prio_order_down'))) {
                 $prio_to_move = $admission_prio[$order_down];
                 $change_with = array_search($prio_to_move + 1, $admission_prio);
                 $admission_prio[$order_down] = $prio_to_move + 1;
                 $admission_prio[$change_with] = $prio_to_move;
             }
             if ($delete = key(Request::getArray('admission_prio_delete'))) {
                 unset($admission_prio[$delete]);
                 $changed = 1;
                 $admission_prio = array_map(function ($a) {
                     static $c = 1;
                     return $c++;
                 }, $admission_prio);
             }
             foreach ($admission_prio as $course_id => $p) {
                 $changed += AdmissionPriority::setPriority($courseset->getId(), $user_id, $course_id, $p);
             }
             if ($changed || $old_prio_count && !count($admission_prio)) {
                 if (count(AdmissionPriority::getPrioritiesByUser($courseset->getId(), $user_id))) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Priorisierung wurde gespeichert.")));
                 } else {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde zurückgezogen.")));
                 }
             }
         } else {
             if (Request::int('courseset_claimed')) {
                 if (AdmissionPriority::setPriority($courseset->getId(), $user_id, $this->course_id, 1)) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde gespeichert.")));
                 }
             } else {
                 if (AdmissionPriority::unsetPriority($courseset->getId(), $user_id, $this->course_id)) {
                     PageLayout::postMessage(MessageBox::success(_("Ihre Anmeldung zur Platzvergabe wurde zurückgezogen.")));
                 }
             }
         }
     }
     $this->redirect($this->url_for('/apply/' . $this->course_id));
 }
开发者ID:ratbird,项目名称:hope,代码行数:67,代码来源:enrolment.php

示例11: configure_courses_action


//.........这里部分代码省略.........
             $row[] = join(', ', $course->members->findBy('status', 'dozent')->orderBy('position')->pluck('Nachname'));
             $row[] = $course->admission_turnout;
             $row[] = $course->getNumParticipants();
             $row[] = $this->applications[$course->id]['c'];
             $row[] = $this->applications[$course->id]['h'];
             $row[] = $course->admission_disable_waitlist ? _("nein") : _("ja");
             $row[] = $course->admission_waitlist_max > 0 ? $course->admission_waitlist_max : '';
             $row[] = $course->admission_prelim ? _("ja") : _("nein");
             $row[] = $course->admission_binding ? _("ja") : _("nein");
             $data[] = $row;
         }
         $tmpname = md5(uniqid('tmp'));
         if (array_to_csv($data, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions)) {
             $this->redirect(GetDownloadLink($tmpname, 'Veranstaltungen_' . $courseset->getName() . '.csv', 4, 'force'));
             return;
         }
     }
     if (in_array($csv, words('download_all_members download_multi_members'))) {
         $liste = array();
         $multi_members = $all_participants = array();
         foreach ($this->courses as $course) {
             $participants = $course->members->findBy('status', words('user autor'))->toGroupedArray('user_id', words('username vorname nachname email status'));
             $participants += $course->admission_applicants->findBy('status', words('accepted awaiting'))->toGroupedArray('user_id', words('username vorname nachname email status'));
             $all_participants += $participants;
             foreach (array_keys($participants) as $one) {
                 $multi_members[$one][] = $course->name . ($course->veranstaltungsnummer ? '|' . $course->veranstaltungsnummer : '');
             }
             foreach ($participants as $user_id => $part) {
                 $liste[] = array($part['username'], $part['vorname'], $part['nachname'], $part['email'], $course->name . ($course->veranstaltungsnummer ? '|' . $course->veranstaltungsnummer : ''), $part['status']);
             }
         }
         if ($csv == 'download_all_members') {
             $captions = array(_("Username"), _("Vorname"), _("Nachname"), _("Email"), _("Veranstaltung"), _("Status"));
             if (count($liste)) {
                 $tmpname = md5(uniqid('tmp'));
                 if (array_to_csv($liste, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions)) {
                     $this->redirect(GetDownloadLink($tmpname, 'Gesamtteilnehmerliste_' . $courseset->getName() . '.csv', 4, 'force'));
                     return;
                 }
             }
         } else {
             $liste = array();
             $multi_members = array_filter($multi_members, function ($a) {
                 return count($a) > 1;
             });
             $c = 0;
             $max_count = array();
             foreach ($multi_members as $user_id => $courses) {
                 $member = $all_participants[$user_id];
                 $liste[$c] = array($member['username'], $member['vorname'], $member['nachname'], $member['email']);
                 foreach ($courses as $one) {
                     $liste[$c][] = $one;
                 }
                 $max_count[] = count($courses);
                 $c++;
             }
             $captions = array(_("Nutzername"), _("Vorname"), _("Nachname"), _("Email"));
             foreach (range(1, max($max_count)) as $num) {
                 $captions[] = _("Veranstaltung") . ' ' . $num;
             }
             if (count($liste)) {
                 $tmpname = md5(uniqid('tmp'));
                 if (array_to_csv($liste, $GLOBALS['TMP_PATH'] . '/' . $tmpname, $captions)) {
                     $this->redirect(GetDownloadLink($tmpname, 'Mehrfachanmeldungen_' . $courseset->getName() . '.csv', 4, 'force'));
                     return;
                 }
             }
         }
     }
     if (Request::submitted('configure_courses_save')) {
         CSRFProtection::verifyUnsafeRequest();
         $admission_turnouts = Request::intArray('configure_courses_turnout');
         $admission_waitlists = Request::intArray('configure_courses_disable_waitlist');
         $admission_waitlists_max = Request::intArray('configure_courses_waitlist_max');
         $admission_bindings = Request::intArray('configure_courses_binding');
         $admission_prelims = Request::intArray('configure_courses_prelim');
         $hidden = Request::intArray('configure_courses_hidden');
         $ok = 0;
         foreach ($this->courses as $course) {
             if ($GLOBALS['perm']->have_studip_perm('admin', $course->id)) {
                 $do_update_admission = $course->admission_turnout < $admission_turnouts[$course->id];
                 $course->admission_turnout = $admission_turnouts[$course->id];
                 $course->admission_disable_waitlist = isset($admission_waitlists[$course->id]) ? 0 : 1;
                 $course->admission_waitlist_max = $course->admission_disable_waitlist ? 0 : $admission_waitlists_max[$course->id];
                 $course->admission_binding = @$admission_bindings[$course->id] ?: 0;
                 $course->admission_prelim = @$admission_prelims[$course->id] ?: 0;
                 $course->visible = @$hidden[$course->id] ? 0 : 1;
                 $ok += $course->store();
                 if ($do_update_admission) {
                     update_admission($course->id);
                 }
             }
         }
         if ($ok) {
             PageLayout::postMessage(MessageBox::success(_("Die zugeordneten Veranstaltungen wurden konfiguriert.")));
         }
         $this->redirect($this->url_for('admission/courseset/configure/' . $courseset->getId()));
         return;
     }
 }
开发者ID:ratbird,项目名称:hope,代码行数:101,代码来源:courseset.php

示例12: verifyWritePermission

 /**
  * TODO documentation
  */
 public static function verifyWritePermission($permission)
 {
     self::verifyPostRequest();
     \CSRFProtection::verifyUnsafeRequest();
     self::verifyStudipPermission($permission);
 }
开发者ID:ratbird,项目名称:hope,代码行数:9,代码来源:WysiwygRequest.php

示例13: instant_course_set_action

 function instant_course_set_action()
 {
     $this->response->add_header('X-Title', _('Neue Anmelderegel'));
     list($type, $another_type) = explode('_', Request::option('type'));
     list($rule_id, $another_rule_id) = explode('_', Request::option('rule_id'));
     $rule_types = AdmissionRule::getAvailableAdmissionRules(true);
     if (isset($rule_types[$type])) {
         $rule = new $type($rule_id);
         if (isset($rule_types[$another_type])) {
             $another_rule = new $another_type($another_rule_id);
         }
         $course_set = CourseSet::getSetForRule($rule_id) ?: new CourseSet();
         if (Request::isPost() && Request::submitted('save') || $rule instanceof LockedAdmission) {
             if ($rule instanceof LockedAdmission) {
                 $course_set_id = CourseSet::getGlobalLockedAdmissionSetId();
                 CourseSet::addCourseToSet($course_set_id, $this->course_id);
                 PageLayout::postMessage(MessageBox::success(_("Die Veranstaltung wurde gesperrt.")));
                 $this->redirect($this->url_for('/index'));
                 return;
             } else {
                 CSRFProtection::verifyUnsafeRequest();
                 $rule->setAllData(Request::getInstance());
                 $errors = $rule->validate(Request::getInstance());
                 if ($another_rule) {
                     $another_rule->setAllData(Request::getInstance());
                     $errors = array_merge($errors, $another_rule->validate(Request::getInstance()));
                 }
                 if (!strlen(trim(Request::get('instant_course_set_name')))) {
                     $errors[] = _("Bitte geben Sie einen Namen für die Anmelderegel ein!");
                 } else {
                     $course_set->setName(trim(Request::get('instant_course_set_name')));
                 }
                 if (count($errors)) {
                     PageLayout::postMessage(MessageBox::error(_("Speichern fehlgeschlagen"), array_map('htmlready', $errors)));
                 } else {
                     $rule->store();
                     $course_set->setPrivate(true);
                     $course_set->addAdmissionRule($rule);
                     $course_set->setAlgorithm(new RandomAlgorithm());
                     //TODO
                     $course_set->setCourses(array($this->course_id));
                     if ($another_rule) {
                         $course_set->addAdmissionRule($another_rule);
                     }
                     $course_set->store();
                     PageLayout::postMessage(MessageBox::success(_("Die Anmelderegel wurde erzeugt und der Veranstaltung zugewiesen.")));
                     $this->redirect($this->url_for('/index'));
                     return;
                 }
             }
         }
         if (!$course_set->getId()) {
             $course_set->setName($rule->getName() . ': ' . $this->course->name);
         }
         $this->rule_template = $rule->getTemplate();
         $this->type = $type;
         $this->rule_id = $rule_id;
         if ($another_rule) {
             $this->type = $this->type . '_' . $another_type;
             $this->rule_id = $this->rule_id . '_' . $another_rule->getId();
             $this->rule_template = $this->rule_template . $another_rule->getTemplate();
         }
         $this->course_set_name = $course_set->getName();
     } else {
         throw new Trails_Exception(400);
     }
 }
开发者ID:ratbird,项目名称:hope,代码行数:67,代码来源:admission.php

示例14: set_lock_rule_action

 /**
  * set the lock rule
  *
  * @return void
  */
 public function set_lock_rule_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     if (!$GLOBALS['perm']->have_studip_perm('admin', $GLOBALS['SessionSeminar'])) {
         throw new AccessDeniedException();
     }
     $course = Course::findCurrent();
     if ($course) {
         $rule_id = Request::get('lock_sem') != 'none' ? Request::get('lock_sem') : null;
         $course->lock_rule = $rule_id;
         if ($course->store()) {
             if (!is_null($rule_id)) {
                 $lock_rule = LockRule::find($rule_id);
                 $msg = sprintf(_('Die Sperrebene %s wurde erfolgreich übernommen!'), $lock_rule->name);
             } else {
                 $msg = _('Die Sperrebene wurde erfolgreich zurückgesetzt!');
             }
             PageLayout::postMessage(MessageBox::success($msg));
         }
     }
     $this->relocate($this->url_for('/index'));
 }
开发者ID:ratbird,项目名称:hope,代码行数:27,代码来源:management.php

示例15: update_action

 /**
  * Updates the activation status of user's homepage plugins.
  */
 public function update_action()
 {
     CSRFProtection::verifyUnsafeRequest();
     $manager = PluginManager::getInstance();
     $modules = Request::optionArray('modules');
     $success = null;
     // Plugins
     foreach ($this->plugins as $plugin) {
         // Check local activation status.
         $id = $plugin->getPluginId();
         $state_before = $manager->isPluginActivatedForUser($id, $this->user_id);
         $state_after = in_array($id, $modules);
         if ($state_before !== $state_after) {
             $updated = $manager->setPluginActivated($id, $this->user_id, $state_after, 'user');
             $success = $success || $updated;
         }
     }
     if ($success === true) {
         $message = MessageBox::success(_('Ihre Änderungen wurden gespeichert.'));
     } elseif ($success === false) {
         $message = MessageBox::error(_('Ihre Änderungen konnten nicht gespeichert werden.'));
     }
     if ($message) {
         PageLayout::postMessage($message);
     }
     $this->redirect($this->url_for('profilemodules/index', array('username' => $this->username)));
 }
开发者ID:ratbird,项目名称:hope,代码行数:30,代码来源:profilemodules.php


注:本文中的CSRFProtection::verifyUnsafeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。