Skip to content

Commit

Permalink
Activity tasks - don't add invalid tasks
Browse files Browse the repository at this point in the history
Instead of 'handling the task code building invalid tasks - civicrm#20945' - this proposes to only attempt
to add a page if it is for a valid task. This keeps the grouchiness in the generic controller
to warn us of other mistakes.

This code is pretty fugly! However, it really is just called internally within this class.
  • Loading branch information
eileenmcnaughton committed Jul 25, 2021
1 parent c6fa16a commit edfaa5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions CRM/Activity/StateMachine/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) {
$this->_pages = [];

$this->_pages['CRM_Activity_Form_Search'] = NULL;
list($task, $result) = $this->taskName($controller, 'Search');
list($task) = $this->taskName($controller, 'Search');
$this->_task = $task;

if (is_array($task)) {
foreach ($task as $t) {
$this->_pages[$t] = NULL;
}
}
else {
$this->_pages[$task] = NULL;
foreach ($task as $t) {
$this->_pages[$t] = NULL;
}

$this->addSequentialPages($this->_pages, $action);
Expand Down
8 changes: 4 additions & 4 deletions CRM/Activity/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ public static function getTask($value) {
// make the print task by default
$value = self::TASK_PRINT;
}
if (isset(self::$_tasks[$value])) {
return [self::$_tasks[$value]['class']]];
}

return [
self::$_tasks[$value]['class'],
self::$_tasks[$value]['result'],
];
return [[]];
}

}

0 comments on commit edfaa5c

Please sign in to comment.