コード例 #1
0
ファイル: entries.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Copy all tag associations from one tag to another
  *
  * @return     void
  */
 public function pierceTask()
 {
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     $step = Request::getInt('step', 1);
     $step = $step ? $step : 1;
     // Make sure we have some IDs to work with
     if ($step == 1 && (!$ids || count($ids) < 1)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false));
         return;
     }
     $idstr = implode(',', $ids);
     switch ($step) {
         case 1:
             Request::setVar('hidemainmenu', 1);
             $this->view->step = 2;
             $this->view->idstr = $idstr;
             $this->view->tags = array();
             // Loop through the IDs of the tags we want to merge
             foreach ($ids as $id) {
                 // Load the tag's info
                 $this->view->tags[] = new Tag(intval($id));
             }
             // Get all tags
             $cloud = new Cloud();
             // Set any errors
             if ($this->getError()) {
                 $this->view->setError($this->getError());
             }
             // Output the HTML
             $this->view->display();
             break;
         case 2:
             // Check for request forgeries
             Request::checkToken();
             // Get the string of tag IDs we plan to merge
             $ind = Request::getVar('ids', '', 'post');
             if ($ind) {
                 $ids = explode(',', $ind);
             } else {
                 $ids = array();
             }
             // Incoming
             $tag_exist = Request::getInt('existingtag', 0, 'post');
             $tag_new = Request::getVar('newtag', '', 'post');
             // Are we merging tags into a totally new tag?
             if ($tag_new) {
                 // Yes, we are
                 $newtag = new Tag($tag_new);
                 if (!$newtag->exists()) {
                     $newtag->set('raw_tag', $tag_new);
                 }
                 if (!$newtag->store(true)) {
                     $this->setError($newtag->getError());
                 }
                 $mtag = $newtag->get('id');
             } else {
                 // No, we're merging into an existing tag
                 $mtag = $tag_exist;
             }
             foreach ($ids as $id) {
                 if ($mtag == $id) {
                     continue;
                 }
                 $oldtag = new Tag(intval($id));
                 if (!$oldtag->copyTo($mtag)) {
                     $this->setError($oldtag->getError());
                 }
             }
             App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_TAGS_TAGS_COPIED'));
             break;
     }
 }
コード例 #2
0
ファイル: tags.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Save a tag
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Check that the user is authorized
     if (!$this->config->get('access-edit-tag')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
     }
     $tag = Request::getVar('fields', array(), 'post');
     // Bind incoming data
     $row = new Tag(intval($tag['id']));
     if (!$row->bind($tag)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     // Store new content
     if (!$row->store(true)) {
         $this->setError($row->getError());
         $this->editTask($row);
         return;
     }
     $limit = Request::getInt('limit', 0);
     $start = Request::getInt('limitstart', 0);
     $sortby = Request::getInt('sortby', '');
     $search = urldecode(Request::getString('search', ''));
     // Redirect to main listing
     App::redirect(Route::url('index.php?option=' . $this->_option . '&task=browse&search=' . urlencode($search) . '&sortby=' . $sortby . '&limit=' . $limit . '&limitstart=' . $start));
 }
コード例 #3
0
 /**
  * Update an entry
  *
  * @return  void
  */
 public function updateTask()
 {
     $this->requiresAuthentication();
     $id = Request::getInt('id', 0);
     $tag = Request::getVar('tag', null);
     $raw = Request::getVar('raw_tag', null);
     $label = Request::getVar('label', null);
     $admin = Request::getInt('admin', 0);
     $subs = Request::getVar('substitutes', null);
     if (!$id) {
         throw new Exception(Lang::txt('COM_TAGS_ERROR_MISSING_DATA'), 500);
     }
     $record = new Tag($id);
     if (!$record->exists()) {
         $record->set('admin', $admin ? 1 : 0);
         if ($raw_tag) {
             $record->set('raw_tag', $raw_tag);
         }
         if ($tag) {
             $record->set('tag', $tag);
         }
         $record->set('label', $label);
         $record->set('substitutions', $subs);
         if (!$record->store(true)) {
             throw new Exception($record->getError(), 500);
         }
     }
     $this->send($record->toObject());
 }