*/
public function getTasks()
{
+ $app_list = array($this->_app);
+ $tasks = array();
+
switch ($this->_app) {
case 'horde':
- $app_list = isset($_SESSION['horde_logintasks']['horde'])
- ? array()
- : array('horde');
+ if (isset($_SESSION['horde_logintasks']['horde'])) {
+ return $tasks;
+ }
break;
default:
- $app_list = array($this->_app);
if (!isset($_SESSION['horde_logintasks']['horde'])) {
array_unshift($app_list, 'horde');
}
break;
}
- $tasks = array();
-
foreach ($app_list as $app) {
foreach (array_merge($GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_SystemTask'), $GLOBALS['registry']->getAppDrivers($app, 'LoginTasks_Task')) as $val) {
$tasks[$val] = $app;
public function getLastRun()
{
$lasttask_pref = @unserialize($GLOBALS['prefs']->getValue('last_logintasks'));
- if (!is_array($lasttask_pref)) {
- $lasttask_pref = array();
- }
- return $lasttask_pref;
+ return is_array($lasttask_pref)
+ ? $lasttask_pref
+ : array();
}
/**
$lasttasks['horde'] = time();
$_SESSION['horde_logintasks']['horde'] = true;
}
- $GLOBALS['prefs']->setValue('last_logintasks', serialize($lasttasks));
+ $this->setLastRun($lasttasks);
}
/**
{
return Horde::getServiceLink('logintasks', $this->_app);
}
+
}
/**
* Do login task (if it has been confirmed).
- *
- * @return boolean Whether the login task was successful.
*/
abstract public function execute();
public $active = true;
/**
- * The interval at which to run the task.
- *
- * @var integer
- */
- public $interval = Horde_LoginTasks::MONTHLY;
-
- /**
* The style of the page output.
*
* [1] Horde_LoginTasks::DISPLAY_CONFIRM_NO
public $display = Horde_LoginTasks::DISPLAY_CONFIRM_YES;
/**
+ * The interval at which to run the task.
+ *
+ * @var integer
+ */
+ public $interval = Horde_LoginTasks::MONTHLY;
+
+ /**
* The priority of the task.
*
* @var integer
/**
* Do login task (if it has been confirmed).
- *
- * @return boolean Whether the login task was successful.
*/
abstract public function execute();
/**
* Does the task require to be displayed?
*
- * @return boolean True in case the task should be displayed.
+ * @return boolean True if the task should be displayed.
*/
public function needsDisplay()
{
* Indicates if the display of the current task should be joined with the
* given previous task.
*
- * @param Horde_Login_Task $previous The previous task to display.
+ * @param Horde_Login_Task $previous The previous task to display.
*
- * @return boolean True in case both tasks should be displayed together.
+ * @return boolean True if both tasks should be displayed together.
*/
public function joinDisplayWith(Horde_LoginTasks_Task $previous)
{
- if ($this->display == $previous->display) {
- return true;
- }
- if ($this->_isConfirmTask($this) && $this->_isConfirmTask($previous)) {
- return true;
- }
- return false;
+ return (($this->display == $previous->display) ||
+ ($this->_isConfirmTask($this) &&
+ $this->_isConfirmTask($previous)));
}
+ /**
+ * Is this a confirmation task?
+ *
+ * @param Horde_Login_Task $task The task to analyze.
+ *
+ * @return boolean True if this is a confirmation task.
+ */
private function _isConfirmTask($task)
{
return in_array(
'Horde_LoginTasks_Stub_Notice',
)
);
- $tasks->runTasks(false, null);
+ $tasks->runTasks(false);
$this->assertEquals(
array(
'Horde_LoginTasks_Stub_High',
);
$this->assertContains(
'URL',
- (string) $tasks->runTasks(false, null)
+ (string) $tasks->runTasks(false)
);
}
'Horde_LoginTasks_Stub_Notice',
)
);
- $tasks->runTasks(false, null);
+ $tasks->runTasks(false);
$tasklist = $tasks->displayTasks();
$this->assertEquals(
'Horde_LoginTasks_Stub_Notice',
'Horde_LoginTasks_Stub_NoticeTwo',
)
);
- $tasks->runTasks(false, null);
+ $tasks->runTasks(false);
$tasklist = $tasks->displayTasks();
$classes = array();
foreach ($tasklist as $task) {
'Horde_LoginTasks_Stub_NoticeTwo',
)
);
- $tasks->runTasks(false, null);
+ $tasks->runTasks(false);
Horde_LoginTasks_Stub_Task::$executed = array();
$tasks->displayTasks();
- $tasks->runTasks(true, null);
+ $tasks->runTasks(true);
$this->assertEquals(
array(
'Horde_LoginTasks_Stub_Notice',