summaryrefslogtreecommitdiff
path: root/app/Helper/Task.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-05-24 16:02:25 -0400
committerFrederic Guillot <fred@kanboard.net>2015-05-24 16:02:25 -0400
commiteeac2329baab1fdae7cbf6c707ed2ffd8beb4c1b (patch)
tree511c2fe47f8fbb1ea90e59e7a7a7f5e3530aa9ed /app/Helper/Task.php
parent65e9e5d1bed9f88ecfd43eb2c1e780a7c22c151f (diff)
Helpers refactoring
Diffstat (limited to 'app/Helper/Task.php')
-rw-r--r--app/Helper/Task.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/Helper/Task.php b/app/Helper/Task.php
new file mode 100644
index 00000000..b3931cdb
--- /dev/null
+++ b/app/Helper/Task.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Helper;
+
+/**
+ * Task helpers
+ *
+ * @package helper
+ * @author Frederic Guillot
+ */
+class Task extends \Core\Base
+{
+ /**
+ * Get the age of an item in quasi human readable format.
+ * It's in this format: <1h , NNh, NNd
+ *
+ * @access public
+ * @param integer $timestamp Unix timestamp of the artifact for which age will be calculated
+ * @param integer $now Compare with this timestamp (Default value is the current unix timestamp)
+ * @return string
+ */
+ public function age($timestamp, $now = null)
+ {
+ if ($now === null) {
+ $now = time();
+ }
+
+ $diff = $now - $timestamp;
+
+ if ($diff < 3600) {
+ return t('<1h');
+ }
+ else if ($diff < 86400) {
+ return t('%dh', $diff / 3600);
+ }
+
+ return t('%dd', ($now - $timestamp) / 86400);
+ }
+
+ public function recurrenceTriggers()
+ {
+ return $this->task->getRecurrenceTriggerList();
+ }
+
+ public function recurrenceTimeframes()
+ {
+ return $this->task->getRecurrenceTimeframeList();
+ }
+
+ public function recurrenceBasedates()
+ {
+ return $this->task->getRecurrenceBasedateList();
+ }
+
+ public function canRemove(array $task)
+ {
+ return $this->taskPermission->canRemoveTask($task);
+ }
+}