Hermes::pauseTimer PHP Method

pauseTimer() public static method

Pause a timer.
public static pauseTimer ( integer $id ) : boolean
$id integer The timer id.
return boolean
    public static function pauseTimer($id)
    {
        $timer = Hermes::getTimer($id);
        // Avoid pausing the same timer twice.
        if ($timer['paused'] || $timer['time'] == 0) {
            return true;
        }
        $timer['paused'] = true;
        $timer['elapsed'] += time() - $timer['time'];
        $timer['time'] = 0;
        Hermes::updateTimer($id, $timer);
        return true;
    }

Usage Example

示例#1
0
 /**
  * Pause a timer. Expects the following data in $this->vars:
  *   - t: The timer id
  *
  * @return boolean
  */
 public function pauseTimer()
 {
     try {
         return Hermes::pauseTimer($this->vars->t);
     } catch (Horde_Exception_NotFound $e) {
         $GLOBALS['notification']->push(_("Invalid timer requested"), 'horde.error');
         return false;
     }
 }