Hermes::newTimer PHP Method

newTimer() public static method

- client_id: (string) The client id. - deliverable_id: (string) The delverable id. - deliverable_text: (string) Descriptive text for deliverable. - jobtype_id: (string) The jobtype id. - time: (integer) Contains the timestamp of the last time this timer was started. Contains zero if paused. - paused: (boolean) Flag to indicate the timer is paused. - elapsed: (integer) Total elapsed time since the timer was created or reset. Updated when timer is paused. - exclusive: (boolean) Whether or not this timer should cause other timers to stop when it is started.
public static newTimer ( string $description, stdClass $details = null ) : integer
$description string The timer description.
$details stdClass Additional, optional details for the ti.
return integer The timer id.
    public static function newTimer($description, stdClass $details = null)
    {
        $now = time();
        $timer = array('id' => $now, 'name' => $description, 'client_id' => empty($details->client_id) ? null : $details->client_id, 'deliverable_id' => empty($details->deliverable_id) ? null : $details->deliverable_id, 'jobtype_id' => empty($details->jobtype_id) ? null : $details->jobtype_id, 'time' => $now, 'paused' => false, 'elapsed' => 0, 'exclusive' => !empty($details['exclusive']) ? true : false);
        self::updateTimer($now, $timer);
        return $now;
    }

Usage Example

Beispiel #1
0
<?php

/**
 * Copyright 2005-2015 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (BSD). If you
 * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 *
 * @author Chuck Hagenbuch <*****@*****.**>
 * @author Jan Schneider <*****@*****.**>
 */
require_once __DIR__ . '/lib/Application.php';
$hermes = Horde_Registry::appInit('hermes');
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, _("Stop Watch"));
$form->addVariable(_("Stop watch description"), 'description', 'text', true);
if ($form->validate($vars)) {
    Hermes::newTimer($vars->get('description'));
    echo Horde::wrapInlineScript(array('var t = ' . Horde_Serialize::serialize(sprintf(_("The stop watch \"%s\" has been started and will appear in the menu at the next refresh."), $vars->get('description')), Horde_Serialize::JSON) . ';', 'alert(t);', 'window.close();'));
    exit;
}
$page_output->topbar = $page_output->sidebar = false;
$page_output->header(array('title' => _("Stop Watch")));
$form->renderActive(new Horde_Form_Renderer(), $vars, Horde::url('start.php'), 'post');
$page_output->footer();
All Usage Examples Of Hermes::newTimer