Пример #1
0
 /**
  * Method to save records (insert or update)
  * @see application/controllers/ICrudController#save()
  */
 public function save(array $data, array $unlockedData)
 {
     try {
         if (isset($this->_post->Insert)) {
             $this->_model->insert($data);
         } else {
             $fieldKey = $this->_model->getFieldKey();
             $this->_model->update($data, "{$fieldKey} = {$unlockedData[$fieldKey]}");
         }
     } catch (Exception $e) {
         Fgsl_Session_Namespace::set('exception', $e);
         $this->_redirect('error/message');
     }
     return true;
 }
Пример #2
0
 /**
  * Perform term count update immediately.
  *
  * @since 2.5.0
  *
  * @param array $terms The term_taxonomy_id of terms to update.
  * @param string $taxonomy The context of the term.
  * @return bool Always true when complete.
  */
 function update_term_count_now($terms, $taxonomy)
 {
     $terms = array_map('intval', $terms);
     $taxonomy = $this->get_taxonomy($taxonomy);
     if (!empty($taxonomy->update_count_callback)) {
         call_user_func($taxonomy->update_count_callback, $terms);
     } else {
         // Default count updater
         foreach ((array) $terms as $term) {
             $count = $this->db->get_var($this->db->prepare("SELECT COUNT(*) FROM {$this->db->term_relationships} WHERE term_taxonomy_id = %d", $term));
             $this->db->update($this->db->term_taxonomy, compact('count'), array('term_taxonomy_id' => $term));
         }
     }
     $this->clean_term_cache($terms);
     return true;
 }
Пример #3
0
 /**
  * Add the specified page to the specified tree
  * Remember to also call StructuredData::addWatch if you call this function
  *
  * @param unknown_type $dbw
  * @param unknown_type $treeId
  * @param unknown_type $title
  * @param unknown_type $revid
  * @param unknown_type $talkRevid
  * @param unknown_type $dataVersion
  * @param unknown_type $uid
  * @param unknown_type $flags
  * @return unknown
  */
 public static function addPage($dbw, &$user, $treeId, $title, $revid, $talkRevid, $dataVersion = 0, $uid = '', $flags = 0)
 {
     $result = true;
     // should this be the primary person?
     // TODO get rid of this test - the primary person can be set when the user opens the tree for the first time
     if ($title->getNamespace() == NS_PERSON) {
         $res = $dbw->select('familytree_page', 'fp_title', array('fp_tree_id' => $treeId, 'fp_namespace' => NS_PERSON), 'FamilyTreeUtil::addPage', array('LIMIT' => 1));
         if ($res === false || !$dbw->numRows($res)) {
             // make this person the primary page if it's the first person
             $dbw->update('familytree', array('ft_primary_namespace' => $title->getNamespace(), 'ft_primary_title' => $title->getDBkey()), array('ft_tree_id' => $treeId));
             FamilyTreeUtil::deleteFamilyTreesCache($user->getName());
             $errno = $dbw->lastErrno();
             if ($errno > 0) {
                 $result = false;
             }
         }
         $dbw->freeResult($res);
     }
     // insert familytree_page
     $record = array('fp_tree_id' => $treeId, 'fp_user_id' => $user->getID(), 'fp_namespace' => $title->getNamespace(), 'fp_title' => $title->getDBkey(), 'fp_oldid' => $revid, 'fp_latest' => $revid, 'fp_talk_oldid' => $talkRevid, 'fp_talk_latest' => $talkRevid, 'fp_data_version' => $dataVersion, 'fp_uid' => $uid, 'fp_flags' => $flags);
     $dbw->insert('familytree_page', $record, 'FamilyTreeUtil::addPage', array('ignore'));
     $errno = $dbw->lastErrno();
     if ($errno != 0 && $errno != 1062) {
         // 1062 = duplicate key
         $result = false;
     }
     return $result;
 }