Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
viewtimers.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * View Attached timer
8  *
9  * @author Anakeen
10  * @version $Id: viewtimers.php,v 1.4 2009/01/02 17:43:50 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 /**
19  * View timers attached to a document
20  * @param Action &$action current action
21  * @global id int Http var : document identifier to see
22  */
23 function viewtimers(Action & $action)
24 {
25  $docid = getHttpVars("id");
26  $szone = (getHttpVars("szone") == "Y");
27  $dbaccess = $action->dbaccess;
28  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/resizeimg.js");
29  $doc = new_Doc($dbaccess, $docid, true);
30  if (!$doc->isAlive()) {
31  $action->exitError(sprintf(_("document not alive %s") , $docid));
32  }
33  $err = $doc->control('view');
34  if ($err) $action->exitError($err);
35  $prev = array();
36  $timers = $doc->getAttachedTimers();
37  foreach ($timers as $k => $v) {
38  /**
39  * @var \Dcp\Core\Timer $timer
40  */
41  $timer = new_doc($dbaccess, $v["timerid"]);
42  if ($timer->isAlive()) {
43  $iprev = $timer->getPrevisions($v["attachdate"], $v["tododate"], $v["level"]);
44  foreach ($iprev as $pk => $pv) {
45  $iprev[$pk]["timerid"] = $timer->id;
46  $iprev[$pk]["timertitle"] = $timer->getHTMLTitle();
47  }
48  $prev = array_merge($prev, $iprev);
49  }
50  }
51 
52  foreach ($prev as $k => $v) {
53  $prev[$k]["tmaila"] = "";
54  $prev[$k]["state"] = "";
55  $prev[$k]["method"] = "";
56  if ($v["actions"]["state"]) $prev[$k]["state"] = htmlspecialchars(_($v["actions"]["state"]) , ENT_QUOTES);
57  else $prev[$k]["state"] = false;
58  if ($v["actions"]["tmail"]) {
59  $prev[$k]["tmail"] = true;
60  $prev[$k]["tmaila"] = $timer->getHtmlValue($timer->getAttribute("tm_tmail") , $v["actions"]["tmail"]);
61  } else $prev[$k]["tmail"] = false;
62  if ($v["actions"]["method"]) $prev[$k]["method"] = htmlspecialchars(($v["actions"]["method"]) , ENT_QUOTES);
63  else $prev[$k]["method"] = false;
64  $prev[$k]["hdelay"] = htmlspecialchars(humandelay($v["execdelay"]) , ENT_QUOTES);
65  $prev[$k]["oddoreven"] = htmlspecialchars((($k % 2 == 0) ? "even" : "odd") , ENT_QUOTES);
66  }
67 
68  usort($prev, "sortprevision");
69  $action->lay->setBlockData("PREV", $prev);
70  $action->lay->rSet("docid", $doc->id);
71  $action->lay->eSet("iconsrc", $doc->getIcon());
72  $action->lay->eSet("doctitle", $doc->getTitle());
73  $action->lay->rSet("szone", $szone);
74 }
75 
76 function sortprevision($a, $b)
77 {
78  if ($a["execdelay"] > $b["execdelay"]) return 1;
79  elseif ($a["execdelay"] < $b["execdelay"]) return -1;
80  return 0;
81 }
82 
83 function humandelay($dd)
84 {
85  $s = "";
86  if ($dd > 1) {
87  $j = intval($dd);
88  if ($j > 1) $s.= sprintf(_("%d days") , $j);
89  else $s.= sprintf(_("%d day") , $j);
90  $s.= " ";
91  $dd = $dd - $j;
92  }
93  $dd = $dd * 24;
94 
95  if ($dd > 1) {
96  $j = intval($dd);
97  if ($j > 1) $s.= sprintf(_("%d hours") , $j);
98  else $s.= sprintf(_("%d hour") , $j);
99  $s.= " ";
100  $dd = $dd - $j;
101  }
102  $dd = $dd * 60;
103  if ($dd > 1) {
104  $j = intval($dd);
105  if ($j > 1) $s.= sprintf(_("%d minutes") , $j);
106  else $s.= sprintf(_("%d minute") , $j);
107  $s.= " ";
108  $dd = $dd - $j;
109  }
110  return $s;
111 }
sortprevision($a, $b)
Definition: viewtimers.php:76
global $action
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
if($famId) $s
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
humandelay($dd)
Definition: viewtimers.php:83
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen