summaryrefslogtreecommitdiff
path: root/app/Action
diff options
context:
space:
mode:
Diffstat (limited to 'app/Action')
-rw-r--r--app/Action/Base.php30
-rw-r--r--app/Action/TaskAssignCategoryColor.php2
-rw-r--r--app/Action/TaskAssignCategoryLabel.php2
-rw-r--r--app/Action/TaskAssignColorCategory.php2
-rw-r--r--app/Action/TaskAssignColorUser.php2
-rw-r--r--app/Action/TaskAssignCurrentUser.php6
-rw-r--r--app/Action/TaskAssignSpecificUser.php2
-rw-r--r--app/Action/TaskAssignUser.php2
-rw-r--r--app/Action/TaskCreation.php2
9 files changed, 35 insertions, 15 deletions
diff --git a/app/Action/Base.php b/app/Action/Base.php
index a2b07e3f..70dd871d 100644
--- a/app/Action/Base.php
+++ b/app/Action/Base.php
@@ -2,9 +2,8 @@
namespace Action;
+use Event\GenericEvent;
use Pimple\Container;
-use Core\Listener;
-use Core\Tool;
/**
* Base class for automatic actions
@@ -21,9 +20,17 @@ use Core\Tool;
* @property \Model\TaskFinder $taskFinder
* @property \Model\TaskStatus $taskStatus
*/
-abstract class Base implements Listener
+abstract class Base
{
/**
+ * Flag for called listener
+ *
+ * @access private
+ * @var boolean
+ */
+ private $called = false;
+
+ /**
* Project id
*
* @access private
@@ -114,6 +121,7 @@ abstract class Base implements Listener
$this->container = $container;
$this->project_id = $project_id;
$this->event_name = $event_name;
+ $this->called = false;
}
/**
@@ -136,7 +144,7 @@ abstract class Base implements Listener
*/
public function __get($name)
{
- return Tool::loadModel($this->container, $name);
+ return $this->container[$name];
}
/**
@@ -225,12 +233,20 @@ abstract class Base implements Listener
* Execute the action
*
* @access public
- * @param array $data Event data dictionary
- * @return bool True if the action was executed or false when not executed
+ * @param \Event\GenericEvent $event Event data dictionary
+ * @return bool True if the action was executed or false when not executed
*/
- public function execute(array $data)
+ public function execute(GenericEvent $event)
{
+ // Avoid infinite loop, a listener instance can be called only one time
+ if ($this->called) {
+ return false;
+ }
+
+ $data = $event->getAll();
+
if ($this->isExecutable($data)) {
+ $this->called = true;
return $this->doAction($data);
}
diff --git a/app/Action/TaskAssignCategoryColor.php b/app/Action/TaskAssignCategoryColor.php
index 4134b584..ba319a1f 100644
--- a/app/Action/TaskAssignCategoryColor.php
+++ b/app/Action/TaskAssignCategoryColor.php
@@ -67,7 +67,7 @@ class TaskAssignCategoryColor extends Base
'category_id' => $this->getParam('category_id'),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignCategoryLabel.php b/app/Action/TaskAssignCategoryLabel.php
index da41a313..19064526 100644
--- a/app/Action/TaskAssignCategoryLabel.php
+++ b/app/Action/TaskAssignCategoryLabel.php
@@ -67,7 +67,7 @@ class TaskAssignCategoryLabel extends Base
'category_id' => isset($data['category_id']) ? $data['category_id'] : $this->getParam('category_id'),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignColorCategory.php b/app/Action/TaskAssignColorCategory.php
index 68bca5d0..a362c68f 100644
--- a/app/Action/TaskAssignColorCategory.php
+++ b/app/Action/TaskAssignColorCategory.php
@@ -67,7 +67,7 @@ class TaskAssignColorCategory extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignColorUser.php b/app/Action/TaskAssignColorUser.php
index d419ab4d..6161514d 100644
--- a/app/Action/TaskAssignColorUser.php
+++ b/app/Action/TaskAssignColorUser.php
@@ -68,7 +68,7 @@ class TaskAssignColorUser extends Base
'color_id' => $this->getParam('color_id'),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignCurrentUser.php b/app/Action/TaskAssignCurrentUser.php
index 9317bf83..b2015100 100644
--- a/app/Action/TaskAssignCurrentUser.php
+++ b/app/Action/TaskAssignCurrentUser.php
@@ -62,12 +62,16 @@ class TaskAssignCurrentUser extends Base
*/
public function doAction(array $data)
{
+ if (! $this->acl->isLogged()) {
+ return false;
+ }
+
$values = array(
'id' => $data['task_id'],
'owner_id' => $this->acl->getUserId(),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignSpecificUser.php b/app/Action/TaskAssignSpecificUser.php
index c3b979c2..4c96f7f0 100644
--- a/app/Action/TaskAssignSpecificUser.php
+++ b/app/Action/TaskAssignSpecificUser.php
@@ -68,7 +68,7 @@ class TaskAssignSpecificUser extends Base
'owner_id' => $this->getParam('user_id'),
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskAssignUser.php b/app/Action/TaskAssignUser.php
index d01c4073..f24ff415 100644
--- a/app/Action/TaskAssignUser.php
+++ b/app/Action/TaskAssignUser.php
@@ -64,7 +64,7 @@ class TaskAssignUser extends Base
'owner_id' => $data['owner_id'],
);
- return $this->taskModification->update($values, false);
+ return $this->taskModification->update($values);
}
/**
diff --git a/app/Action/TaskCreation.php b/app/Action/TaskCreation.php
index 0c791688..9b7a0b13 100644
--- a/app/Action/TaskCreation.php
+++ b/app/Action/TaskCreation.php
@@ -63,7 +63,7 @@ class TaskCreation extends Base
'project_id' => $data['project_id'],
'title' => $data['title'],
'reference' => $data['reference'],
- 'description' => $data['description'],
+ 'description' => isset($data['description']) ? $data['description'] : '',
));
}