Пример #1
0
 /**
  * Save an entry
  *
  * @return  void
  */
 public function saveTask()
 {
     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('index.php?option=' . $this->_option . '&task=import'), Lang::txt('COM_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error');
         return;
     }
     // vars
     $allow_tags = $this->config->get('citation_allow_tags', 'no');
     $allow_badges = $this->config->get('citation_allow_badges', 'no');
     $this->importer->set('user', User::get('id'));
     if ($group = Request::getVar('group')) {
         $this->importer->set('scope', 'group');
         $this->importer->set('scope_id', $group);
     }
     $this->importer->setTags($allow_tags == 'yes');
     $this->importer->setBadges($allow_badges == 'yes');
     // Process
     $results = $this->importer->process($citations_action_attention, $citations_action_no_attention);
     if (isset($group) && $group != '') {
         require_once PATH_CORE . DS . 'components' . DS . 'com_groups' . DS . 'tables' . DS . 'group.php';
         $gob = new \Components\Groups\Tables\Group($this->database);
         $cn = $gob->getName($group);
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $cn . '&active=citations&action=dashboard'));
     } else {
         // success message a redirect
         Notify::success(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_SAVED', count($results['saved'])), 'citations');
         // if we have citations not getting saved
         if (count($results['not_saved']) > 0) {
             Notify::warning(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_NOT_SAVED', count($results['not_saved'])), 'citations');
         }
         if (count($results['error']) > 0) {
             Notify::error(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_SAVE_ERROR', count($results['error'])), '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('index.php?option=' . $this->_option . '&task=import_saved'));
     }
     return;
 }
Пример #2
0
 /**
  * Upload task
  * @return [object] [description]
  **/
 private function _process()
 {
     // instansiate the view
     $view = $this->view('saved', 'import');
     $view->group = $this->group;
     $view->messages = NULL;
     $config = new \Hubzero\Config\Registry($this->group->get('params'));
     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('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations&action=import'), Lang::txt('COM_CITATIONS_IMPORT_MISSING_FILE_CONTINUE'), 'error');
         return;
     }
     // vars
     $allow_tags = "yes";
     $allow_badges = "yes";
     $this->importer->set('user', User::get('id'));
     $this->importer->set('scope', 'group');
     $this->importer->set('scope_id', $this->group->get('gidNumber'));
     $this->importer->setTags($allow_tags == 'yes');
     $this->importer->setBadges($allow_badges == 'yes');
     // Process
     $results = $this->importer->process($citations_action_attention, $citations_action_no_attention);
     if (isset($group) && $group != '') {
         require_once PATH_CORE . DS . 'components' . DS . 'com_groups' . DS . 'tables' . DS . 'group.php';
         $gob = new \Components\Groups\Tables\Group($this->database);
         $cn = $gob->getName($group);
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $cn . '&active=citations&action=dashboard'));
     } else {
         // success message a redirect
         Notify::success(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_SAVED', count($results['saved'])), 'citations');
         // view variables
         $view->citations_require_attention = isset($citations_action_attention) ? $citations_action_attention : null;
         $view->citation_require_no_attention = isset($citation_action_no_attention) ? $citations_action_no_attention : null;
         // if we have citations not getting saved
         if (count($results['not_saved']) > 0) {
             Notify::warning(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_NOT_SAVED', count($results['not_saved'])), 'citations');
         }
         if (count($results['error']) > 0) {
             Notify::error(Lang::txt('COM_CITATIONS_IMPORT_RESULTS_SAVE_ERROR', count($results['error'])), '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 after save
         App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_CITATION_SAVED'), 'success');
         return;
     }
 }