Index: branches/5.2.x/core/kernel/db/dbitem.php =================================================================== diff -u -N -r15729 -r15733 --- branches/5.2.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 15729) +++ branches/5.2.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 15733) @@ -1,6 +1,6 @@ Application->GetTopmostWid($this->Prefix); return $this->Prefix . '_file_pending_actions' . $window_id; } /** + * Returns pending actions + * + * @param mixed $id + * @return Array + * @access public + */ + public function getPendingActions($id = null) + { + if ( !isset($id) ) { + $id = $this->GetID(); + } + + $pending_actions = $this->Application->RecallVar($this->_getPendingActionVariableName()); + $pending_actions = $pending_actions ? unserialize($pending_actions) : Array (); + + if ( is_numeric($id) ) { + // filter by given/current id + $ret = Array (); + + foreach ($pending_actions as $pending_action) { + if ( $pending_action['id'] == $id ) { + $ret[] = $pending_action; + } + } + + return $ret; + } + + return $pending_actions; + } + + /** + * Sets new pending actions + * + * @param Array|null $new_pending_actions + * @param mixed $id + * @return void + * @access public + */ + public function setPendingActions($new_pending_actions = null, $id = null) + { + if ( !isset($new_pending_actions) ) { + $new_pending_actions = Array (); + } + + if ( !isset($id) ) { + $id = $this->GetID(); + } + + $pending_actions = Array (); + $old_pending_actions = $this->getPendingActions(true); + + if ( is_numeric($id) ) { + // remove old actions for this id + foreach ($old_pending_actions as $pending_action) { + if ( $pending_action['id'] != $id ) { + $pending_actions[] = $pending_action; + } + } + + // add new actions for this id + $pending_actions = array_merge($pending_actions, $new_pending_actions); + } + else { + $pending_actions = $new_pending_actions; + } + + // save changes + $var_name = $this->_getPendingActionVariableName(); + + if ( !$pending_actions ) { + $this->Application->RemoveVar($var_name); + } + else { + $this->Application->StoreVar($var_name, serialize($pending_actions)); + } + } + + /** * Allows to skip certain fields from getting into sql queries * * @param string $field_name