Example #1
0
 /**
  * Update the DB based on previously recorded changes
  */
 function dbupdate()
 {
     global $DB;
     $DB->begin();
     parent::dbupdate();
     // Update/Insert/Delete custom fields
     $this->dbsave_custom_fields();
     $DB->commit();
 }
Example #2
0
 /**
  * Update the DB based on previously recorded changes
  */
 function dbupdate()
 {
     global $DB;
     $DB->begin();
     parent::dbupdate();
     if (isset($this->CollectionSettings)) {
         $this->CollectionSettings->dbupdate();
     }
     $DB->commit();
 }
Example #3
0
 /**
  * Update the DB based on previously recorded changes
  */
 function dbupdate()
 {
     global $DB;
     $DB->begin();
     parent::dbupdate();
     // Update group permissions/settings of the current group
     $GroupSettings =& $this->get_GroupSettings();
     $GroupSettings->dbupdate($this->ID);
     $DB->commit();
 }
Example #4
0
 /**
  * Update the DB based on previously recorded changes
  */
 function dbupdate()
 {
     global $DB, $Plugins, $servertimenow;
     $DB->begin();
     parent::dbupdate();
     // if this blog settings was modified we need to invalidate this blog's page caches
     // this way all existing cached page on this blog will be regenerated during next display
     // TODO: Ideally we want to detect if the changes are minor/irrelevant to caching and not invalidate the page cache if not necessary.
     // In case of doubt (and for unknown changes), it's better to invalidate.
     $this->set_setting('last_invalidation_timestamp', $servertimenow);
     if (isset($this->CollectionSettings)) {
         $this->CollectionSettings->dbupdate();
     }
     $Plugins->trigger_event('AfterCollectionUpdate', $params = array('Blog' => &$this));
     $DB->commit();
     // Thick grained invalidation:
     // This collection has been modified, cached content depending on it should be invalidated:
     BlockCache::invalidate_key('coll_ID', $this->ID);
     // Fine grained invalidation:
     // EXPERIMENTAL: Below are more granular invalidation dates:
     BlockCache::invalidate_key('set_coll_ID', $this->ID);
     // Settings have changed
     BlockCache::invalidate_key('set_coll_ID', 'any');
     // Settings of a have changed (for widgets tracking a change on ANY blog)
     // cont_coll_ID  // Content has not changed
 }
Example #5
0
    /**
     * Trigger event AfterCommentUpdate after calling parent method.
     *
     * @return boolean true on success
     */
    function dbupdate()
    {
        global $Plugins, $DB;
        $dbchanges = $this->dbchanges;
        if (count($dbchanges)) {
            $this->set_last_touched_date();
        }
        $DB->begin();
        if (($r = parent::dbupdate()) !== false) {
            $update_item_last_touched_date = false;
            if (isset($dbchanges['comment_content']) || isset($dbchanges['comment_renderers'])) {
                // Content is updated
                $this->delete_prerendered_content();
                $update_item_last_touched_date = true;
            }
            if ($this->check_publish_status_changed()) {
                // Comment is updated into/out some public status
                $update_item_last_touched_date = true;
            }
            if (!empty($this->previous_item_ID)) {
                // Comment is moved from another post
                $ItemCache =& get_ItemCache();
                $ItemCache->clear();
                if ($previous_Item =& $ItemCache->get_by_ID($this->previous_item_ID, false, false)) {
                    // Update last touched date of previous item
                    $previous_Item->update_last_touched_date(false);
                }
                // Also update new post
                $update_item_last_touched_date = true;
                // Also move all child comments to new post
                $child_comment_IDs = $this->get_child_comment_IDs();
                if (count($child_comment_IDs)) {
                    $DB->query('UPDATE T_comments
						  SET comment_item_ID = ' . $DB->quote($this->item_ID) . '
						WHERE comment_ID IN ( ' . $DB->quote($child_comment_IDs) . ' )');
                }
            }
            $this->update_last_touched_date($update_item_last_touched_date);
            $DB->commit();
            $Plugins->trigger_event('AfterCommentUpdate', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
        } else {
            $DB->rollback();
        }
        return $r;
    }
Example #6
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure / no changes
  */
 function dbupdate()
 {
     if ($this->meta == 'unknown') {
         debug_die('cannot update File if meta data has not been checked before');
     }
     global $DB;
     $DB->begin();
     // Let parent do the update:
     if (($r = parent::dbupdate()) !== false) {
         // Update field 'last_touched_ts' of each item that has a link with this edited file
         $LinkCache =& get_LinkCache();
         $links = $LinkCache->get_by_file_ID($this->ID);
         foreach ($links as $Link) {
             $LinkOwner =& $Link->get_LinkOwner();
             if ($LinkOwner != NULL) {
                 $LinkOwner->item_update_last_touched_date();
             }
         }
         $DB->commit();
     } else {
         $DB->rollback();
     }
     return $r;
 }
Example #7
0
    /**
     * Update the DB based on previously recorded changes.
     *
     * Triggers the plugin event AfterUserUpdate.
     */
    function dbupdate()
    {
        global $DB, $Plugins, $current_User, $localtimenow;
        $DB->begin();
        $result = parent::dbupdate();
        // Update existing fields:
        if (!empty($this->updated_fields)) {
            foreach ($this->updated_fields as $uf_ID => $uf_val) {
                // Note the updated_fields key values must be integers, so don't need casting or DB->quote()
                if (empty($uf_val)) {
                    // Delete field:
                    $DB->query('DELETE FROM T_users__fields
														 WHERE uf_ID = ' . $uf_ID);
                } else {
                    // Update field:
                    $DB->query('UPDATE T_users__fields
													SET uf_varchar = ' . $DB->quote($uf_val) . '
												WHERE uf_ID = ' . $uf_ID);
                }
            }
            // Reset updated fields in object:
            $this->updated_fields = array();
        }
        // Add new fields:
        if (!empty($this->new_fields)) {
            $sql = 'INSERT INTO T_users__fields( uf_user_ID, uf_ufdf_ID, uf_varchar )
							VALUES (' . $this->ID . ', ' . implode('), (' . $this->ID . ', ', $this->new_fields) . ' )';
            $DB->query($sql, 'Insert new fields');
            // Reset new fields in object:
            $this->new_fields = array();
        }
        // Notify plugins:
        // Example: An authentication plugin could synchronize/update the password of the user.
        $Plugins->trigger_event('AfterUserUpdate', $params = array('User' => &$this));
        $DB->commit();
        // BLOCK CACHE INVALIDATION:
        // This User has been modified, cached content depending on it should be invalidated:
        BlockCache::invalidate_key('user_ID', $this->ID);
        return true;
    }
Example #8
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $DB;
     // Start transaction because of urltitle validation
     $DB->begin('SERIALIZABLE');
     // validate url title / slug
     if (empty($this->urlname) || isset($this->dbchanges['cat_urlname'])) {
         // Url title has changed or is empty
         $this->set('urlname', urltitle_validate($this->urlname, $this->name, $this->ID, false, $this->dbprefix . 'urlname', $this->dbIDname, $this->dbtablename));
     }
     if (count($this->dbchanges) > 0 && !isset($this->dbchanges['last_touched_ts'])) {
         // Update last_touched_ts field only if it wasn't updated yet and the datemodified will be updated for sure.
         global $localtimenow;
         $this->set_param('last_touched_ts', 'date', date('Y-m-d H:i:s', $localtimenow));
     }
     if (parent::dbupdate() === false) {
         // The update was unsuccessful
         $DB->rollback();
         return false;
     }
     // The chapter was updated successful
     $DB->commit();
     return true;
 }
Example #9
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true
  */
 function dbupdate()
 {
     global $DB;
     $DB->begin();
     if (parent::dbupdate() !== false) {
         // Skin updated, also save containers:
         $this->db_save_containers();
     }
     $DB->commit();
     return true;
 }
Example #10
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure / no changes
  */
 function dbupdate()
 {
     if ($this->meta == 'unknown') {
         debug_die('cannot update File if meta data has not been checked before');
     }
     // Let parent do the update:
     return parent::dbupdate();
 }
Example #11
0
 /**
  * Update the DB based on previously recorded changes.
  *
  * @todo dh> this is very Item specific, and should get fixed probably.
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $DB, $Messages;
     $ItemCache =& get_ItemCache();
     $Item =& $ItemCache->get_by_id($this->itm_ID);
     $DB->begin();
     if ($Item->get('canonical_slug_ID') == $this->ID) {
         $Item->set('urltitle', $this->title);
         if (!$Item->dbupdate(true, false, false)) {
             $DB->rollback();
             return false;
         }
         $Messages->add(sprintf(T_('Warning: this change also changed the canonical slug of the post! (%s)'), $this->get_link_to_object()), 'warning');
     }
     parent::dbupdate();
     $DB->commit();
     return true;
 }
Example #12
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure to update, NULL if no update necessary
  */
 function dbupdate()
 {
     global $DB;
     $dbchanges = $this->dbchanges;
     $DB->begin();
     if (($r = parent::dbupdate()) !== false) {
         // Update types of the Files
         $this->update_file_types();
         $DB->commit();
     } else {
         $DB->rollback();
     }
     return $r;
 }
Example #13
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true on success, false on failure / no changes
  */
 function dbupdate()
 {
     if ($this->meta == 'unknown') {
         debug_die('cannot update File if meta data has not been checked before');
     }
     global $DB;
     $DB->begin();
     $file_path_hash = md5($this->_FileRoot->type . $this->_FileRoot->in_type_ID . $this->_rdfp_rel_path, true);
     if ($file_path_hash != $this->path_hash) {
         // The file path was changed
         $this->set_param('path_hash', 'string', $file_path_hash);
     }
     // Let parent do the update:
     if (($r = parent::dbupdate()) !== false) {
         // Update field 'last_touched_ts' of each item that has a link with this edited file
         $LinkCache =& get_LinkCache();
         $links = $LinkCache->get_by_file_ID($this->ID);
         foreach ($links as $Link) {
             $LinkOwner =& $Link->get_LinkOwner();
             if ($LinkOwner != NULL) {
                 $LinkOwner->update_last_touched_date();
             }
         }
         $DB->commit();
     } else {
         $DB->rollback();
     }
     return $r;
 }
Example #14
0
 /**
  * Trigger event AfterCommentUpdate after calling parent method.
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $Plugins;
     $dbchanges = $this->dbchanges;
     if ($r = parent::dbupdate()) {
         $Plugins->trigger_event('AfterCommentUpdate', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
     }
     return $r;
 }
Example #15
0
 /**
  * Trigger event AfterCommentUpdate after calling parent method.
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $Plugins, $DB;
     $dbchanges = $this->dbchanges;
     $DB->begin();
     if (($r = parent::dbupdate()) !== false) {
         if (isset($dbchanges['comment_content']) || isset($dbchanges['comment_renderers'])) {
             $this->delete_prerendered_content();
         }
         if ($this->check_publish_status_changed()) {
             // Update last touched date of item if comment is updated into/out some public status
             $comment_Item =& $this->get_Item();
             $comment_Item->update_last_touched_date();
         }
         $DB->commit();
         $Plugins->trigger_event('AfterCommentUpdate', $params = array('Comment' => &$this, 'dbchanges' => $dbchanges));
     } else {
         $DB->rollback();
     }
     return $r;
 }
Example #16
0
 /**
  * Update the DB based on previously recorded changes
  */
 function dbupdate()
 {
     global $DB;
     parent::dbupdate();
     // This widget has been modified, cached content depending on it should be invalidated:
     BlockCache::invalidate_key('wi_ID', $this->ID);
 }
Example #17
0
 /**
  * Update the DB based on previously recorded changes
  *
  * @return boolean true
  */
 function dbupdate()
 {
     global $DB;
     $DB->begin();
     if ($this->get_status() == 'pending') {
         // Update crob jobs only with "pending" status
         $result = parent::dbupdate();
     } else {
         // Don't update this cron job
         $DB->rollback();
         return false;
     }
     $DB->commit();
     return $result;
 }
Example #18
0
 /**
  * Update the DB based on previously recorded changes.
  *
  * Triggers the plugin event AfterUserUpdate.
  *
  * @return boolean true on success
  */
 function dbupdate()
 {
     global $DB, $Plugins;
     if ($result = parent::dbupdate()) {
         // We could update the user object..
         // Notify plugins:
         // Example: A authentication plugin could synchronize/update the password of the user.
         $Plugins->trigger_event('AfterUserUpdate', $params = array('User' => &$this));
     }
     return $result;
 }