@@ 14-43 (lines=30) @@ | ||
11 | * |
|
12 | * @link http://github.com/boboldehampsink |
|
13 | */ |
|
14 | class TaskManager_DeleteElementAction extends BaseElementAction |
|
15 | { |
|
16 | /** |
|
17 | * Get element action name. |
|
18 | * |
|
19 | * @return string |
|
20 | */ |
|
21 | public function getName() |
|
22 | { |
|
23 | return Craft::t('Delete task(s)'); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * Delete given task. |
|
28 | * |
|
29 | * @param ElementCriteriaModel $criteria |
|
30 | * |
|
31 | * @return bool |
|
32 | */ |
|
33 | public function performAction(ElementCriteriaModel $criteria) |
|
34 | { |
|
35 | foreach ($criteria->id as $taskId) { |
|
36 | craft()->tasks->deleteTaskById($taskId); |
|
37 | } |
|
38 | ||
39 | $this->setMessage(Craft::t('Task(s) deleted.')); |
|
40 | ||
41 | return true; |
|
42 | } |
|
43 | } |
|
44 |
@@ 14-43 (lines=30) @@ | ||
11 | * |
|
12 | * @link http://github.com/boboldehampsink |
|
13 | */ |
|
14 | class TaskManager_RestartElementAction extends BaseElementAction |
|
15 | { |
|
16 | /** |
|
17 | * Get element action name. |
|
18 | * |
|
19 | * @return string |
|
20 | */ |
|
21 | public function getName() |
|
22 | { |
|
23 | return Craft::t('Restart task(s)'); |
|
24 | } |
|
25 | ||
26 | /** |
|
27 | * Restart given tasks. |
|
28 | * |
|
29 | * @param ElementCriteriaModel $criteria |
|
30 | * |
|
31 | * @return bool |
|
32 | */ |
|
33 | public function performAction(ElementCriteriaModel $criteria) |
|
34 | { |
|
35 | foreach ($criteria->id as $taskId) { |
|
36 | craft()->tasks->rerunTaskById($taskId); |
|
37 | } |
|
38 | ||
39 | $this->setMessage(Craft::t('Task(s) restarted.')); |
|
40 | ||
41 | return true; |
|
42 | } |
|
43 | } |
|
44 |