Overview

Packages

  • LoginTasks

Classes

  • Horde_LoginTasks
  • Horde_LoginTasks_Backend
  • Horde_LoginTasks_SystemTask
  • Horde_LoginTasks_Task
  • Horde_LoginTasks_Tasklist
  • Horde_LoginTasks_Translation
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Abstract class to allow for modularization of specific login tasks.
  4:  *
  5:  * Copyright 2001-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (LGPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
  9:  *
 10:  * @author   Michael Slusarz <slusarz@horde.org>
 11:  * @category Horde
 12:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 13:  * @package  LoginTasks
 14:  */
 15: abstract class Horde_LoginTasks_Task
 16: {
 17:     /**
 18:      * Should the task be run?
 19:      *
 20:      * @var boolean
 21:      */
 22:     public $active = true;
 23: 
 24:     /**
 25:      * The style of the page output.
 26:      *
 27:      * [1] Horde_LoginTasks::DISPLAY_CONFIRM_NO
 28:      *     Horde_LoginTasks::DISPLAY_CONFIRM_YES
 29:      *     Each output from describe() will have a checkbox associated
 30:      *     with it. For each checkbox selected, execute() for that task will
 31:      *     be run. More than 1 confirmation message can be displayed on the
 32:      *     confirmation page at once.
 33:      *
 34:      *     DISPLAY_CONFIRM_YES will be checked by default, DISPLAY_CONFIRM_NO
 35:      *     will be unchecked by default.
 36:      *
 37:      * [2] Horde_LoginTasks::DISPLAY_AGREE
 38:      *     The output from describe() should be text asking the user to
 39:      *     agree/disagree to specified terms. If 'yes' is selected, the POST
 40:      *     variable 'agree' will be set. If 'no' is selected, the POST variable
 41:      *     'not_agree' will be set. In either case, execute() will ALWAYS be
 42:      *     run.
 43:      *     This style will be displayed on its own confirmation page.
 44:      *
 45:      * [3] Horde_LoginTasks::DISPLAY_NOTICE
 46:      *     The output from describe() should be any non-interactive text
 47:      *     desired. There will be a single 'Click to Continue' button below
 48:      *     this text. execute() will ALWAYS be run.
 49:      *     This style will be displayed on its own confirmation page.
 50:      *
 51:      * [4] Horde_LoginTasks::DISPLAY_NONE
 52:      *     Don't display any confirmation to the user.
 53:      *
 54:      * @var integer
 55:      */
 56:     public $display = Horde_LoginTasks::DISPLAY_CONFIRM_YES;
 57: 
 58:     /**
 59:      * The interval at which to run the task.
 60:      *
 61:      * @var integer
 62:      */
 63:     public $interval = Horde_LoginTasks::MONTHLY;
 64: 
 65:     /**
 66:      * The priority of the task.
 67:      *
 68:      * @var integer
 69:      */
 70:     public $priority = Horde_LoginTasks::PRIORITY_NORMAL;
 71: 
 72:     /**
 73:      * Do login task (if it has been confirmed).
 74:      */
 75:     abstract public function execute();
 76: 
 77:     /**
 78:      * Return description information for the login task.
 79:      *
 80:      * @return string  Description that will be displayed on the login task
 81:      *                 confirmation page.
 82:      */
 83:     public function describe()
 84:     {
 85:         return '';
 86:     }
 87: 
 88:     /**
 89:      * Does the task need to be displayed?
 90:      *
 91:      * @return boolean  True if the task should be displayed.
 92:      */
 93:     public function needsDisplay()
 94:     {
 95:         return $this->display != Horde_LoginTasks::DISPLAY_NONE;
 96:     }
 97: 
 98:     /**
 99:      * Indicates if the display of the current task should be joined with the
100:      * given previous task.
101:      *
102:      * @param Horde_Login_Task $previous  The previous task to display.
103:      *
104:      * @return boolean  True if both tasks should be displayed together.
105:      */
106:     public function joinDisplayWith(Horde_LoginTasks_Task $previous)
107:     {
108:         return (($this->display == $previous->display) ||
109:                 ($this->_isConfirmTask($this) &&
110:                  $this->_isConfirmTask($previous)));
111:     }
112: 
113:     /**
114:      * Is this a confirmation task?
115:      *
116:      * @param Horde_Login_Task $task  The task to analyze.
117:      *
118:      * @return boolean  True if this is a confirmation task.
119:      */
120:     private function _isConfirmTask($task)
121:     {
122:         return in_array(
123:             $task->display,
124:             array(Horde_LoginTasks::DISPLAY_CONFIRM_YES,
125:                   Horde_LoginTasks::DISPLAY_CONFIRM_NO)
126:         );
127:     }
128: 
129: }
130: 
API documentation generated by ApiGen