Skip to content

Commit

Permalink
Simplify getting timer hash values.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 26, 2013
1 parent 320bbcd commit b499890
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
5 changes: 1 addition & 4 deletions hermes/lib/Ajax/Application/Handler.php
Expand Up @@ -27,7 +27,6 @@ public function addTimer()
{
$id = Hermes::newTimer($this->vars->desc, $this->vars);
$timer = Hermes::getTimer($id);
$timer['id'] = $id;

return $timer;
}
Expand Down Expand Up @@ -439,9 +438,7 @@ public function stopTimer()
$timer['time'] = $now;
Hermes::updateTimer($this->vars->t, $timer);
}
$text = Hermes::getCostObjectByID($timer['deliverable_id']);
$results['_deliverable_text'] = $text['name'];
$results['id'] = $this->vars->t;

return $results;
}

Expand Down
15 changes: 9 additions & 6 deletions hermes/lib/Hermes.php
Expand Up @@ -393,9 +393,10 @@ public static function listTimers($running_only = false)
$elapsed = (!$timer['paused'] ? time() - $timer['time'] : 0 ) + $timer['elapsed'];
$timer['elapsed'] = round((float)$elapsed / 3600, 2);
$timer['id'] = $id;
unset($timer['elapsed']);
$text = Hermes::getCostObjectByID($timer['deliverable_id']);
$timer['_deliverable_text'] = $text['name'];
try {
$text = Hermes::getCostObjectByID($timer['deliverable_id']);
$timer['deliverable_text'] = $text['name'];
} catch (Horde_Exception_NotFound $e) {}
$return[] = $timer;
}

Expand Down Expand Up @@ -450,13 +451,15 @@ public static function getTimer($id)
$timers = $GLOBALS['prefs']->getValue('running_timers');
if (!empty($timers)) {
$timers = @unserialize($timers);
} else {
$timers = array();
}

if (empty($timers[$id])) {
throw new Horde_Exception_NotFound(_("The requested timer was not found."));
}
$timers[$id]['id'] = $id;

try {
$timers[$id]['deliverable_text'] = Hermes::getCostObjectByID($timers[$id]['deliverable_id']);
} catch (Horde_Exception_NotFound $e) {}

return $timers[$id];
}
Expand Down

0 comments on commit b499890

Please sign in to comment.