public function fundTask() { // get the id of the citation $id = Request::getInt('id', ''); $row = new Citation($this->database); $row->load($id); // toggle the affiliation if ($row->fundedby == 1) { $row->fundedby = 0; } elseif ($row->fundedby == 0) { $row->fundedby = 1; } if (!$row->save($row)) { $this->setError($row->getError()); $this->displayTask(); return; } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('CITATION_FUNDED')); }
/** * Get a list of citations requiring attention * * @param array $action_attention * @param array $action_no_attention * @return array */ public function process($action_attention = array(), $action_no_attention = array()) { $results = array('saved' => array(), 'not_saved' => array(), 'error' => array()); $now = with(new Date('now'))->toSql(); $user = $this->get('user'); $scope = $this->get('scope'); $scope_id = $this->get('scope_id'); $published = $this->get('published', null); // loop through each citation that required attention from user if ($cites_require_attention = $this->readRequiresAttention()) { foreach ($cites_require_attention as $k => $cra) { $cc = new Tables\Citation($this->database); // add a couple of needed keys $cra['uid'] = $user; $cra['created'] = $now; // reset tags and badges $tags = ''; $badges = ''; // remove errors unset($cra['errors']); // if tags were sent over if (array_key_exists('tags', $cra)) { $tags = $cra['tags']; unset($cra['tags']); } // if badges were sent over if (array_key_exists('badges', $cra)) { $badges = $cra['badges']; unset($cra['badges']); } //take care fo type $ct = new Tables\Type($this->database); $types = $ct->getType(); $type = ''; foreach ($types as $t) { if (strtolower($t['type_title']) == strtolower($cra['type'])) { $type = $t['id']; } } $cra['type'] = $type ? $type : '1'; switch ($action_attention[$k]) { case 'overwrite': $cra['id'] = $cra['duplicate']; break; case 'both': break; case 'discard': $results['not_saved'][] = $cra; continue 2; break; } // remove duplicate flag unset($cra['duplicate']); //sets group if set if ($scope) { $cra['scope'] = $scope; } if ($scope_id) { $cra['scope_id'] = $scope_id; } if (!is_null($published)) { $cra['published'] = $published; } // save the citation if (!$cc->save($cra)) { $results['error'][] = $cra; } else { // tags if ($this->tags && isset($tags)) { $this->tag($user, $cc->id, $tags, ''); } // badges if ($this->badges && isset($badges)) { $this->tag($user, $cc->id, $badges, 'badge'); } // add the citattion to the saved $results['saved'][] = $cc->id; } } } if ($cites_require_no_attention = $this->readRequiresNoAttention()) { foreach ($cites_require_no_attention as $k => $crna) { // new citation object $cc = new Tables\Citation($this->database); // add a couple of needed keys $crna['uid'] = $user; $crna['created'] = $now; // reset tags and badges $tags = ''; $badges = ''; // remove errors unset($crna['errors']); // if tags were sent over if (array_key_exists('tags', $crna)) { $tags = $crna['tags']; unset($crna['tags']); } // if badges were sent over if (array_key_exists('badges', $crna)) { $badges = $crna['badges']; unset($crna['badges']); } // verify we haad this one checked to be submitted if ($action_no_attention[$k] != 1) { $results['not_saved'][] = $crna; continue; } // take care fo type $ct = new Tables\Type($this->database); $types = $ct->getType(); $type = ''; foreach ($types as $t) { // TODO: undefined index type? I just suppressed the error b/c I'm not sure what the logic is supposed to be /SS if (strtolower($t['type_title']) == strtolower($crna['type'])) { $type = $t['id']; } } $crna['type'] = $type ? $type : '1'; // remove duplicate flag unset($crna['duplicate']); // sets group if set if ($scope) { $crna['scope'] = $scope; } if ($scope_id) { $crna['scope_id'] = $scope_id; } if (!is_null($published)) { $crna['published'] = $published; } // save the citation if (!$cc->save($crna)) { $results['error'][] = $crna; } else { // tags if ($this->tags && isset($tags)) { $this->tag($user, $cc->id, $tags, ''); } // badges if ($this->badges && isset($badges)) { $this->tag($user, $cc->id, $badges, 'badge'); } // add the citattion to the saved $results['saved'][] = $cc->id; } } } $this->cleanup(); return $results; }