Hermes::updateCostObject PHP Method

updateCostObject() public static method

public static updateCostObject ( $slice )
    public static function updateCostObject($slice)
    {
        global $registry;
        list($app, $id) = explode(':', $slice['costobject']);
        if ($registry->hasMethod('updateCostObject', strtolower($app))) {
            $registry->callByPackage(strtolower($app), 'updateCostObject', array($id, $slice));
            $GLOBALS['notification']->push(sprintf(_("Successfully updated the hours of cost object \"%s\"." . $slice->_type_name)), 'horde.success');
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Update a slice. @see Hermes_Slice::readForm() for the data expeted in
  * the posted form.
  *
  * @return array  The new slice data.
  */
 public function updateSlice()
 {
     $slice = new Hermes_Slice();
     $slice->readForm();
     try {
         $GLOBALS['injector']->getInstance('Hermes_Driver')->updateTime(array($slice));
         if ($slice['employee'] == $GLOBALS['registry']->getAuth()) {
             $GLOBALS['notification']->push(_("Your time was successfully updated."), 'horde.success');
         } else {
             $GLOBALS['notification']->push(sprintf(_("The time was successfully updated and saved to the time sheet of %s."), $slice['employee']), 'horde.success');
         }
         $new = current($GLOBALS['injector']->getInstance('Hermes_Driver')->getHours(array('id' => $slice['id'])));
         Hermes::updateCostObject($new);
         return $new->toJson();
     } catch (Hermes_Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
     }
 }