Exemplo n.º 1
0
 /**
  * Perform an update action
  *
  * Generates and executes a TIP_Form instance to update a new row,
  * that is duplicating a row and adding history management so the
  * new row will be a considered as a new version of the duplicated one.
  *
  * @param  mixed $id      The identifier of the row to update
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionUpdate($id, $options = array())
 {
     // Enable the history
     $this->_row_id = $id;
     TIP::arrayDefault($options, 'action_id', 'update');
     $done = $this->master->actionAdd($id, $options);
     // Disable the history
     unset($this->_row_id);
     return $done;
 }
Exemplo n.º 2
0
 /**
  * Perform an add action
  *
  * Overrides the default add action, assuring the 'browse_field' has a
  * valid value.
  *
  * @param  mixed $id      The identifier of the row to duplicate
  * @param  array $options Options to pass to the form() call
  * @return bool           true on success or false on errors
  */
 protected function actionAdd($id, $options = array())
 {
     // Merge the argument before the parent actionAdd(), so also
     // the defaults here defined can be overriden in configuration
     if (isset($this->form_options['add'])) {
         $options = array_merge($this->form_options['add'], $options);
     }
     // Check for the default value of 'browse_field' (the parent id)
     if (!isset($options['defaults'], $options['defaults'][$this->browse_field])) {
         // Try to get the parent id from GET or POST
         if (is_null($parent_id = $this->fromGetOrPost($this->browse_field))) {
             return false;
         }
         $options['defaults'][$this->browse_field] = $parent_id;
     } else {
         $parent_id = $options['defaults'][$this->browse_field];
     }
     TIP::arrayDefault($options, 'follower', TIP::buildActionUri($this->master, 'view', $parent_id));
     return parent::actionAdd($id, $options);
 }