/** * Process an edit action * * Overrides the default edit action updating both master and child rows. */ public function _onEdit(&$row, $old_row) { $child =& $this->_getChildModule(); if (is_null($child)) { // No child module: chain-up the parent method return parent::_onEdit($row, $old_row); } elseif (!$child) { // An error occurred somewhere: do nothing return false; } $engine =& $this->data->getProperty('engine'); if (!$engine->startTransaction()) { // This error must be caught here to avoid the rollback return false; } // The class_field MUST NOT be changed (only deleting allowed) unset($row[$this->class_field]); $done = parent::_onEdit($row, $old_row) && $child->getProperty('data')->updateRow($row); $done = $engine->endTransaction($done) && $done; return $done; }
/** * Update the cookie on password changed * * @param array &$row The subject row * @param array $old_row The old row * @return bool true on success, false on errors */ public function _onEdit(&$row, $old_row = null) { // Ensure $old_row is properly populated is_array($old_row) || ($old_row =& $this->_old_row); if (!is_array($old_row) || !parent::_onEdit($row, $old_row)) { return false; } // Update the internal data $this->_row = $row; $this->_old_row = $row; // The cookie must be updated on password change if (array_key_exists('password', $row) && array_key_exists('password', $old_row) && strcmp($row['password'], $old_row['password']) != 0) { $this->_updateCookie(); } return true; }