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


PHP Request::checkToken方法代码示例

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


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

示例1: reorderTask

 /**
  * Move an item one down or own up int he ordering
  *
  * @param      string $move Direction to move
  * @return     void
  */
 protected function reorderTask($move = 'down')
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $id = Request::getVar('id', array());
     $id = $id[0];
     $pid = Request::getInt('event', 0);
     // Ensure we have an ID to work with
     if (!$id) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_PAGE_NO_ID'), 'error');
         return;
     }
     // Ensure we have a parent ID to work with
     if (!$pid) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_PAGE_NO_EVENT_ID'), 'error');
         return;
     }
     // Get the element moving down - item 1
     $page1 = new Page($this->database);
     $page1->load($id);
     // Get the element directly after it in ordering - item 2
     $page2 = clone $page1;
     $page2->getNeighbor($this->_task);
     switch ($move) {
         case 'up':
             // Switch places: give item 1 the position of item 2, vice versa
             $orderup = $page2->ordering;
             $orderdn = $page1->ordering;
             $page1->ordering = $orderup;
             $page2->ordering = $orderdn;
             break;
         case 'down':
             // Switch places: give item 1 the position of item 2, vice versa
             $orderup = $page1->ordering;
             $orderdn = $page2->ordering;
             $page1->ordering = $orderdn;
             $page2->ordering = $orderup;
             break;
     }
     // Save changes
     $page1->store();
     $page2->store();
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&id[]=' . $pid, false));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:52,代码来源:pages.php

示例2: _save

 /**
  * Save an entry
  *
  * @return    void
  */
 protected function _save()
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return $this->_login();
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $comment = Request::getVar('comment', array(), 'post', 'none', 2);
     // Instantiate a new comment object
     $row = new \Plugins\Hubzero\Comments\Models\Comment($comment['id']);
     // pass data to comment object
     if (!$row->bind($comment)) {
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     $row->set('uploadDir', $this->params->get('comments_uploadpath', '/site/comments'));
     $row->set('created', Date::toSql());
     if ($row->exists() && !$this->params->get('access-edit-comment')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($this->url)), Lang::txt('PLG_HUBZERO_COMMENTS_NOTAUTH'), 'warning');
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $key = 'failed_comment';
         $value = $row->content('raw');
         User::setState($key, $value);
         App::redirect($this->url, $row->getError(), 'error');
         return;
     }
     App::redirect($this->url, Lang::txt('PLG_HUBZERO_COMMENTS_SAVED'), 'message');
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:38,代码来源:comments.php

示例3: saveTask

 /**
  * Save
  *
  * @return     void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $step = Request::getInt('step', '0');
     // Where do we go next?
     if ($this->_identifier && !$this->model->exists()) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_CANNOT_LOAD'), 404);
         return;
     }
     // New project?
     $new = $this->model->exists() ? false : true;
     $setup = $new || $this->model->inSetup() ? true : false;
     // Determine setup steps
     $setupSteps = array('describe', 'team', 'finalize');
     if ($this->_setupComplete < 3) {
         array_pop($setupSteps);
     }
     // Next screen requested
     $this->next = $setup && isset($setupSteps[$step]) ? $setupSteps[$step] : $this->section;
     // Are we allowed to save this step?
     $current = array_search($this->section, $setupSteps);
     if ($new && $current > 0) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Cannot save a new project unless in setup
     if ($new && !$setup) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_CANNOT_LOAD'), 404);
         return;
     }
     // Get group ID
     if ($this->_gid) {
         // Load the group
         $this->group = \Hubzero\User\Group::getInstance($this->_gid);
         // Ensure we found the group info
         if (!is_object($this->group) || !$this->group->get('gidNumber') && !$this->group->get('cn')) {
             throw new Exception(Lang::txt('COM_PROJECTS_NO_GROUP_FOUND'), 404);
             return;
         }
         $this->_gid = $this->group->get('gidNumber');
         $this->model->set('owned_by_group', $this->_gid);
         // Make sure we have up-to-date group membership information
         if ($this->model->exists()) {
             $objO = $this->model->table('Owner');
             $objO->reconcileGroups($this->model->get('id'));
         }
     }
     // Check authorization
     if ($this->model->exists() && !$this->model->access('owner')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     } elseif (!$this->model->exists() && $this->_gid) {
         // Check group authorization to create a project
         if (!$this->group->is_member_of('members', User::get('id')) && !$this->group->is_member_of('managers', User::get('id'))) {
             throw new Exception(Lang::txt('COM_PROJECTS_ALERTNOTAUTH_GROUP'), 403);
             return;
         }
     }
     // Get group ID
     if ($this->_gid) {
         // Load the group
         $this->group = \Hubzero\User\Group::getInstance($this->_gid);
         // Ensure we found the group info
         if (!is_object($this->group) || !$this->group->get('gidNumber') && !$this->group->get('cn')) {
             throw new Exception(Lang::txt('COM_PROJECTS_NO_GROUP_FOUND'), 404);
             return;
         }
         $this->_gid = $this->group->get('gidNumber');
         $this->model->set('owned_by_group', $this->_gid);
     }
     if ($this->section == 'finalize') {
         // Complete project setup
         if ($this->_finalize()) {
             $this->_setNotification(Lang::txt('COM_PROJECTS_NEW_PROJECT_CREATED'), 'success');
             // Some follow-up actions
             $this->_onAfterProjectCreate();
             App::redirect(Route::url($this->model->link()));
             return;
         }
     } else {
         // Save
         $this->_process();
     }
     // Record setup stage and move on
     if ($setup && !$this->getError() && $step > $this->model->get('setup_stage')) {
         $this->model->set('setup_stage', $step);
         $this->model->store();
         // Did we actually complete setup?
         if (!$this->model->inSetup()) {
             // Complete project setup
             if ($this->_finalize()) {
                 $this->_setNotification(Lang::txt('COM_PROJECTS_NEW_PROJECT_CREATED'), 'success');
                 // Some follow-up actions
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:setup.php

示例4: _save

 /**
  * Save an entry
  *
  * @return     string HTML
  */
 private function _save()
 {
     // Check for request forgeries
     Request::checkToken();
     //verify were authorized
     if ($this->authorized != 'manager') {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_ONLY_MANAGERS_CAN_CREATE'));
         return $this->_list();
     }
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     $fields = array_map('trim', $fields);
     // email announcement
     $email = isset($fields['email']) && $fields['email'] == 1 ? true : false;
     //mark as not sent if we want to email again
     if ($email === true) {
         $fields['sent'] = 0;
     }
     // are we creating the announcement?
     if (!isset($fields['id']) || $fields['id'] == 0) {
         $fields['scope'] = 'group';
         $fields['scope_id'] = $this->group->get('gidNumber');
         $fields['created'] = Date::toSql();
         $fields['created_by'] = User::get('id');
     }
     //do we want to mark sticky?
     $fields['sticky'] = isset($fields['sticky']) && $fields['sticky'] == 1 ? 1 : 0;
     //do we want to mark as high priority
     $fields['priority'] = isset($fields['priority']) && $fields['priority'] == 1 ? 1 : 0;
     //format publish up
     if (isset($fields['publish_up']) && $fields['publish_up'] != '' && $fields['publish_up'] != '0000-00-00 00:00:00') {
         $fields['publish_up'] = Date::of(str_replace('@', '', $fields['publish_up']), Config::get('offset'))->toSql();
     }
     //format publish down
     if (isset($fields['publish_down']) && $fields['publish_down'] != '' && $fields['publish_down'] != '0000-00-00 00:00:00') {
         $fields['publish_down'] = Date::of(str_replace('@', '', $fields['publish_down']), Config::get('offset'))->toSql();
     }
     if ($fields['publish_up'] > $fields['publish_down']) {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_INVALID_PUBLISH_DATES'));
         return $this->_edit($fields);
     }
     //announcement model
     $announcement = new \Hubzero\Item\Announcement($this->database);
     //attempt to save
     if (!$announcement->save($fields)) {
         $this->setError($announcement->getError());
         return $this->_edit($fields);
     }
     // does user want to email and should we email yet?
     if ($email === true && $announcement->announcementPublishedForDate()) {
         // email announcement
         $announcement->emailAnnouncement();
         //set that we sent it and resave
         $announcement->sent = 1;
         $announcement->save($announcement);
     }
     //success!
     App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=announcements'), Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_SUCCESSFULLY_CREATED'), 'success');
     return;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:65,代码来源:announcements.php

示例5: _savesettings

 /**
  * Save blog settings
  *
  * @return     void
  */
 private function _savesettings()
 {
     if (User::isGuest()) {
         $this->setError(Lang::txt('GROUPS_LOGIN_NOTICE'));
         return;
     }
     if ($this->authorized != 'manager' && $this->authorized != 'admin') {
         $this->setError(Lang::txt('PLG_GROUPS_BLOG_NOT_AUTHORIZED'));
         return $this->_browse();
     }
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     $row = \Hubzero\Plugin\Params::blank()->set($settings);
     // Get parameters
     $p = new \Hubzero\Config\Registry(Request::getVar('params', array(), 'post'));
     $row->set('params', $p->toString());
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'blog.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_BLOG_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]);
     App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name . '&action=settings'), Lang::txt('PLG_GROUPS_BLOG_SETTINGS_SAVED'), 'passed');
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:35,代码来源:blog.php

示例6: _save

 /**
  * Save an entry
  *
  * @return  string  HTML
  */
 private function _save()
 {
     // Permissions check
     if (!$this->offering->access('manage', 'section')) {
         return $this->_list();
     }
     // Check for request forgeries
     Request::checkToken();
     $no_html = Request::getInt('no_html', 0);
     $response = new stdClass();
     $response->code = 0;
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     $fields = array_map('trim', $fields);
     // Get the model and bind the data
     $model = new \Components\Courses\Models\Announcement(0);
     if (!$model->bind($fields)) {
         $this->setError($model->getError());
         return $this->_edit($model);
     }
     // Incoming dates are in local time. We need to convert to UTC
     if ($model->get('publish_up') && $model->get('publish_up') != '0000-00-00 00:00:00') {
         $model->set('publish_up', Date::of($model->get('publish_up'), Config::get('offset'))->toSql());
     }
     // Incoming dates are in local time. We need to convert to UTC
     if ($model->get('publish_down') && $model->get('publish_down') != '0000-00-00 00:00:00') {
         $model->set('publish_down', Date::of($model->get('publish_down'), Config::get('offset'))->toSql());
     }
     if (!isset($fields['priority']) || !$fields['priority']) {
         $model->set('priority', 0);
     }
     // Store content
     if (!$model->store(true)) {
         $this->setError($model->getError());
         if (!$no_html) {
             return $this->_edit($model);
         }
     }
     if ($no_html) {
         if ($this->getError()) {
             $response->code = 1;
             $response->errors = $this->getErrors();
             $response->data = $fields;
         }
         ob_clean();
         header('Content-type: text/plain');
         echo json_encode($response);
         exit;
     }
     // Display listing
     return $this->_list();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:57,代码来源:announcements.php

示例7: saveCalendar

 /**
  * Save Group Calendar
  *
  * @return     string
  */
 private function saveCalendar()
 {
     Request::checkToken();
     //get request vars
     $calendarInput = Request::getVar('calendar', array());
     // get the calendar
     $calendar = \Components\Events\Models\Calendar::getInstance($calendarInput['id']);
     //add scope and scope id to calendar array
     $calendarInput['scope'] = 'group';
     $calendarInput['scope_id'] = $this->group->get('gidNumber');
     $calendarInput['url'] = trim($calendarInput['url']);
     $colors = array('red', 'orange', 'yellow', 'green', 'blue', 'purple', 'brown');
     if (!in_array($calendarInput['color'], $colors)) {
         $calendarInput['color'] = '';
     }
     //is this a remote calendar url
     if ($calendarInput['url'] != '' && filter_var($calendarInput['url'], FILTER_VALIDATE_URL)) {
         $calendarInput['readonly'] = 1;
         $needsRefresh = true;
     } else {
         $calendarInput['url'] = '';
         $calendarInput['readonly'] = 0;
         $needsRefresh = false;
     }
     // bind input
     if (!$calendar->bind($calendarInput)) {
         $this->setError($calendar->getError());
         return $this->editCalendar();
     }
     // attempt to save
     if (!$calendar->store(true)) {
         $this->setError($calendar->getError());
         return $this->editCalendar();
     }
     // should we refresh?
     if ($needsRefresh) {
         $calendar->refresh();
     }
     //inform and redirect
     App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=calendar&action=calendars'), Lang::txt('You have successfully added a new calendar.'), 'passed');
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:46,代码来源:calendar.php

示例8: _savesettings

 /**
  * Save blog settings
  *
  * @return  void
  */
 private function _savesettings()
 {
     // Login check
     if (User::isGuest()) {
         return $this->_login();
     }
     if ($this->authorized != 'manager' && $this->authorized != 'admin') {
         $this->setError(Lang::txt('PLG_GROUPS_COLLECTIONS_NOT_AUTH'));
         return $this->_collections();
     }
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     $row = \Hubzero\Plugin\Params::oneByPlugin($this->group->get('gidNumber'), $this->_type, $this->_name);
     $row->set('object_id', $this->group->get('gidNumber'));
     $row->set('folder', $this->_type);
     $row->set('element', $this->_name);
     // Get parameters
     $prms = Request::getVar('params', array(), 'post');
     $params = new \Hubzero\Config\Registry($prms);
     $row->set('params', $params->toString());
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->_settings();
     }
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => 'updated', 'scope' => 'collections.settings', 'scope_id' => $row->get('id'), 'description' => Lang::txt('PLG_GROUPS_COLLECTIONS_ACTIVITY_SETTINGS_UPDATED')], 'recipients' => $recipients]);
     App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->get('cn') . '&active=' . $this->_name), Lang::txt('PLG_GROUPS_COLLECTIONS_SETTINGS_SAVED'), 'passed');
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:39,代码来源:collections.php

示例9: _fileUpload

 /**
  * Upload a file to the wiki
  *
  * @return  void
  */
 public function _fileUpload()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->_files();
     }
     if (Request::getVar('no_html', 0)) {
         return $this->_ajaxUpload();
     }
     // Check for request forgeries
     Request::checkToken();
     // Ensure we have an ID to work with
     $listdir = Request::getInt('listdir', 0, 'post');
     if (!$listdir) {
         $this->setError(Lang::txt('PLG_COURSES_PAGES_ERROR_NO_ID_PROVIDED'));
         return $this->_files();
     }
     // Incoming file
     $file = Request::getVar('upload', '', 'files', 'array');
     if (!$file['name']) {
         $this->setError(Lang::txt('PLG_COURSES_PAGES_ERROR_NO_FILE_PROVIDED'));
         return $this->_files();
     }
     // Build the upload path if it doesn't exist
     $path = $this->_path();
     if (!is_dir($path)) {
         if (!Filesystem::makeDirectory($path)) {
             $this->setError(Lang::txt('PLG_COURSES_PAGES_ERROR_UNABLE_TO_MAKE_PATH'));
             return $this->_files();
         }
     }
     // Make the filename safe
     $file['name'] = urldecode($file['name']);
     $file['name'] = Filesystem::clean($file['name']);
     $file['name'] = str_replace(' ', '_', $file['name']);
     // Upload new files
     if (!Filesystem::upload($file['tmp_name'], $path . DS . $file['name'])) {
         $this->setError(Lang::txt('PLG_COURSES_PAGES_ERROR_UNABLE_TO_UPLOAD'));
     }
     if (!Filesystem::isSafe($path . DS . $file['name'])) {
         Filesystem::delete($path . DS . $file['name']);
         $this->setError(Lang::txt('PLG_COURSES_PAGES_ERROR_UNSAFE_FILE'));
     }
     // Push through to the media view
     return $this->_files();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:51,代码来源:pages.php

示例10: _save

 /**
  * Save an entry
  *
  * @return   mixed  An html view on error, redirects on success
  */
 private function _save()
 {
     // Check for request forgeries
     Request::checkToken();
     //verify were authorized
     if ($this->authorized != 'manager') {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_ONLY_MANAGERS_CAN_CREATE'));
         return $this->_list();
     }
     // Incoming
     $fields = Request::getVar('fields', array(), 'post', 'none', 2);
     $fields = array_map('trim', $fields);
     // email announcement
     $email = isset($fields['email']) && $fields['email'] == 1 ? true : false;
     //mark as not sent if we want to email again
     if ($email === true) {
         $fields['sent'] = 0;
     }
     // are we creating the announcement?
     if (!isset($fields['id']) || $fields['id'] == 0) {
         $fields['id'] = 0;
         $fields['scope'] = 'group';
         $fields['scope_id'] = $this->group->get('gidNumber');
         $fields['created'] = Date::toSql();
         $fields['created_by'] = User::get('id');
     }
     //do we want to mark sticky?
     $fields['sticky'] = isset($fields['sticky']) && $fields['sticky'] == 1 ? 1 : 0;
     //do we want to mark as high priority
     $fields['priority'] = isset($fields['priority']) && $fields['priority'] == 1 ? 1 : 0;
     //format publish up
     if (isset($fields['publish_up']) && $fields['publish_up'] != '' && $fields['publish_up'] != '0000-00-00 00:00:00') {
         $fields['publish_up'] = Date::of(str_replace('@', '', $fields['publish_up']), Config::get('offset'))->toSql();
     }
     //format publish down
     if (isset($fields['publish_down']) && $fields['publish_down'] != '' && $fields['publish_down'] != '0000-00-00 00:00:00') {
         $fields['publish_down'] = Date::of(str_replace('@', '', $fields['publish_down']), Config::get('offset'))->toSql();
     }
     // Bind data
     $model = \Hubzero\Item\Announcement::oneOrNew($fields['id'])->set($fields);
     if ($model->get('publish_down') != '0000-00-00 00:00:00' && $model->get('publish_up') > $model->get('publish_down')) {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_INVALID_PUBLISH_DATES'));
         return $this->_edit($model);
     }
     if (!$model->save()) {
         $this->setError($model->setError());
         return $this->_edit($model);
     }
     // Does user want to email and should we email yet?
     if ($email === true && $model->inPublishWindow()) {
         // Email announcement
         self::send($model, $this->group);
         // Set that we sent it and resave
         $model->set('sent', 1);
         $model->save();
     }
     $url = 'index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=' . $this->_name;
     // Record the activity
     $recipients = array(['group', $this->group->get('gidNumber')]);
     foreach ($this->group->get('managers') as $recipient) {
         $recipients[] = ['user', $recipient];
     }
     Event::trigger('system.logActivity', ['activity' => ['action' => $fields['id'] ? 'updated' : 'created', 'scope' => 'announcement', 'scope_id' => $model->get('id'), 'description' => Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_ACTIVITY_' . ($fields['id'] ? 'UPDATED' : 'CREATED'), '<a href="' . Route::url($url) . '">' . \Hubzero\Utility\String::truncate(strip_tags($model->get('content')), 70) . '</a>'), 'details' => array('url' => Route::url($url), 'id' => $this->group->get('gidNumber'), 'alias' => $this->group->get('cn'), 'title' => $this->group->get('description'))], 'recipients' => $recipients]);
     // Redirect to the main listing
     App::redirect(Route::url($url), Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_SUCCESSFULLY_SAVED'), 'success');
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:71,代码来源:announcements.php

示例11: stateTask

 /**
  * Set the state of a course
  *
  * @return  void
  */
 public function stateTask()
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     $state = $this->_task == 'publish' ? 1 : 0;
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Do we have any IDs?
     $num = 0;
     if (!empty($ids)) {
         //foreach course id passed in
         foreach ($ids as $id) {
             // Load the course page
             $model = \Components\Courses\Models\Offering::getInstance($id);
             // Ensure we found the course info
             if (!$model->exists()) {
                 continue;
             }
             //set the course to be published and update
             $model->set('state', $state);
             if (!$model->store()) {
                 $this->setError(Lang::txt('COM_COURSES_ERROR_UNABLE_TO_SET_STATE', $id));
                 continue;
             }
             // Log the course approval
             $model->log($model->get('id'), 'offering', $state ? 'published' : 'unpublished');
             $num++;
         }
     }
     if ($this->getErrors()) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&course=' . Request::getInt('course', 0), false), implode('<br />', $this->getErrors()), 'error');
     } else {
         // Output messsage and redirect
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&course=' . Request::getInt('course', 0), false), $state ? Lang::txt('COM_COURSES_ITEMS_PUBLISHED', $num) : Lang::txt('COM_COURSES_ITEMS_UNPUBLISHED', $num));
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:42,代码来源:offerings.php

示例12: removeTask

 /**
  * Remove one or more types
  *
  * @return     void Redirects back to main listing
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming (expecting an array)
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Ensure we have an ID to work with
     if (empty($ids)) {
         // Redirect with error message
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_NO_ITEM_SELECTED'), 'error');
         return;
     }
     $rt = new \Components\Publications\Tables\MasterType($this->database);
     foreach ($ids as $id) {
         // Check if the type is being used
         $total = $rt->checkUsage($id);
         if ($total > 0) {
             // Redirect with error message
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_TYPE_BEING_USED', $id), 'error');
             return;
         }
         // Delete the type
         $rt->delete($id);
     }
     // Redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_PUBLICATIONS_ITEMS_REMOVED', count($ids)));
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:33,代码来源:types.php

示例13: send

 /**
  * Send a message
  *
  * @return     mixed
  */
 public function send($database, $option, $member)
 {
     // Ensure the user is logged in
     if (User::isGuest()) {
         return false;
     }
     // Check for request forgeries
     Request::checkToken();
     // Incoming array of users to message
     $mbrs = array_map("trim", explode(',', Request::getVar('mbrs', array(), 'post')));
     //array to hold members
     $email_users = array();
     //
     foreach ($mbrs as $mbr) {
         if (is_numeric($mbr)) {
             $email_users[] = $mbr;
         } else {
             preg_match("/\\((\\d+)\\)/", $mbr, $matches);
             $email_users[] = $matches[1];
         }
     }
     // Incoming message and subject
     $subject = Request::getVar('subject', Lang::txt('PLG_MEMBERS_MESSAGES_SUBJECT_MESSAGE'));
     $message = Request::getVar('message', '');
     $no_html = Request::getInt('no_html', 0);
     if (!$subject || !$message) {
         if (!$no_html) {
             $this->addPluginMessage(Lang::txt('You must select a message recipient and enter a message.'), 'error');
             return $this->redirect(Route::url($member->getLink() . '&active=messages&action=new'));
         }
         return App::abort(500, Lang::txt('You must select a message recipient and enter a message.'));
     }
     // Build the "from" data for the e-mail
     $from = array();
     $from['name'] = $member->get('name');
     $from['email'] = $member->get('email');
     // Send the message
     if (!Event::trigger('xmessage.onSendMessage', array('member_message', $subject, $message, $from, $email_users, $option))) {
         $this->setError(Lang::txt('PLG_MEMBERS_MESSAGES_ERROR_MSG_USER_FAILED'));
     }
     // Determine if we're returning HTML or not
     // (if no - this is an AJAX call)
     if (!$no_html) {
         $this->addPluginMessage(Lang::txt('You have successfully sent a message.'), 'passed');
         return App::redirect(Route::url($member->getLink() . '&active=messages&task=inbox'));
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:52,代码来源:messages.php

示例14: stateTask

 /**
  * Sets the state of one or more entries
  *
  * @param   integer  The state to set entries to
  * @return  void
  */
 public function stateTask($state = 0)
 {
     // Check for request forgeries
     Request::checkToken(['get', 'post']);
     // Incoming
     $ids = Request::getVar('id', array());
     // Check for an ID
     if (count($ids) < 1) {
         $action = $state == 1 ? Lang::txt('PLG_RESOURCES_SPONSORS_UNPUBLISH') : Lang::txt('PLG_RESOURCES_SPONSORS_PUBLISH');
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=manage&plugin=sponsors', false), Lang::txt('PLG_RESOURCES_SPONSORS_SELECT_ITEM_TO', $action), 'error');
         return;
     }
     foreach ($ids as $id) {
         // Update record(s)
         $row = \Plugins\Resources\Sponsors\Models\Sponsor::oneOrFail((int) $id);
         $row->set('state', $state);
         if (!$row->save()) {
             $this->setError($row->getError());
             return $this->defaultTask();
         }
     }
     // set message
     if ($state == 1) {
         $message = Lang::txt('PLG_RESOURCES_SPONSORS_ITEMS_PUBLISHED', count($ids));
     } else {
         $message = Lang::txt('PLG_RESOURCES_SPONSORS_ITEMS_UNPUBLISHED', count($ids));
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=manage&plugin=sponsors', false), $message);
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:35,代码来源:sponsors.php

示例15: processAction

 /**
  * Process import selections
  *
  * @return  void
  */
 private function processAction()
 {
     // Check if they're logged in
     if (User::isGuest()) {
         return $this->loginAction();
     }
     if (!$this->params->get('access-manage')) {
         throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403);
     }
     Request::checkToken();
     $cites_require_attention = $this->importer->readRequiresAttention();
     $cites_require_no_attention = $this->importer->readRequiresNoAttention();
     // action for citations needing attention
     $citations_action_attention = Request::getVar('citation_action_attention', array());
     // action for citations needing no attention
     $citations_action_no_attention = Request::getVar('citation_action_no_attention', array());
     // check to make sure we have citations
     if (!$cites_require_attention && !$cites_require_no_attention) {
         App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=import'), Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error');
         return;
     }
     // vars
     $allow_tags = "yes";
     $allow_badges = "yes";
     $this->importer->set('user', User::get('id'));
     $this->importer->setTags($allow_tags == 'yes');
     $this->importer->setBadges($allow_badges == 'yes');
     $this->importer->set('scope_id', $this->member->get('uidNumber'));
     $this->importer->set('scope', 'member');
     // Process
     $results = $this->importer->process($citations_action_attention, $citations_action_no_attention);
     // success message a redirect
     Notify::success(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_SAVED', count($results['saved'])), 'plg_citations');
     // if we have citations not getting saved
     if (count($results['not_saved']) > 0) {
         Notify::warning(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_NOT_SAVED', count($results['not_saved'])), 'plg_citations');
     }
     if (count($results['error']) > 0) {
         Notify::error(Lang::txt('PLG_MEMBERS_CITATIONS_IMPORT_RESULTS_SAVE_ERROR', count($results['error'])), 'plg_citations');
     }
     //get the session object
     $session = App::get('session');
     //ids of sessions saved and not saved
     $session->set('citations_saved', $results['saved']);
     $session->set('citations_not_saved', $results['not_saved']);
     $session->set('citations_error', $results['error']);
     //delete the temp files that hold citation data
     $this->importer->cleanup(true);
     //redirect
     App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name . '&action=saved'));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:56,代码来源:citations.php


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