Commit d7d8a1d25190c083ea4452d6ae673b718f48745b
1 parent
044fc9c8
Add a TEXT field for notification storage area in the notification
entity. Make NotificationHandlers dispatchers, allowing the easy use of redispatch and subdispatch, if needed. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5663 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
33 additions
and
22 deletions
lib/dashboard/Notification.inc.php
| @@ -38,6 +38,7 @@ require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); | @@ -38,6 +38,7 @@ require_once(KT_LIB_DIR . '/foldermanagement/Folder.inc'); | ||
| 38 | require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); | 38 | require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php'); |
| 39 | 39 | ||
| 40 | require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | 40 | require_once(KT_LIB_DIR . '/templating/templating.inc.php'); |
| 41 | +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | ||
| 41 | 42 | ||
| 42 | /** | 43 | /** |
| 43 | * class Notification | 44 | * class Notification |
| @@ -61,8 +62,11 @@ class KTNotification extends KTEntity { | @@ -61,8 +62,11 @@ class KTNotification extends KTEntity { | ||
| 61 | // (i.e. you get very stupid subclassing semantics with up to 4 variables this way. | 62 | // (i.e. you get very stupid subclassing semantics with up to 4 variables this way. |
| 62 | var $iData1; | 63 | var $iData1; |
| 63 | var $iData2; | 64 | var $iData2; |
| 65 | + // sData1 and sData2 are 255-length character fields | ||
| 64 | var $sData1; | 66 | var $sData1; |
| 65 | var $sData2; | 67 | var $sData2; |
| 68 | + // sText1 is a 65535-length text field | ||
| 69 | + var $sText1; | ||
| 66 | 70 | ||
| 67 | var $_bUsePearError = true; | 71 | var $_bUsePearError = true; |
| 68 | 72 | ||
| @@ -81,6 +85,8 @@ class KTNotification extends KTEntity { | @@ -81,6 +85,8 @@ class KTNotification extends KTEntity { | ||
| 81 | function setStrData1($sData1) { $this->sData1 = $sData1; } | 85 | function setStrData1($sData1) { $this->sData1 = $sData1; } |
| 82 | function getStrData2() { return $this->sData2; } | 86 | function getStrData2() { return $this->sData2; } |
| 83 | function setStrData2($sData2) { $this->sData2 = $sData2; } | 87 | function setStrData2($sData2) { $this->sData2 = $sData2; } |
| 88 | + function getTextData1() { return $this->sText1; } | ||
| 89 | + function setTextData1($mValue) { $this->sText1 = $mValue; } | ||
| 84 | 90 | ||
| 85 | var $_aFieldToSelect = array( | 91 | var $_aFieldToSelect = array( |
| 86 | "iId" => "id", | 92 | "iId" => "id", |
| @@ -92,35 +98,36 @@ class KTNotification extends KTEntity { | @@ -92,35 +98,36 @@ class KTNotification extends KTEntity { | ||
| 92 | "iData2" => "data_int_2", | 98 | "iData2" => "data_int_2", |
| 93 | "sData1" => "data_str_1", | 99 | "sData1" => "data_str_1", |
| 94 | "sData2" => "data_str_2", | 100 | "sData2" => "data_str_2", |
| 95 | - ); | 101 | + "sText1" => "data_text_1", |
| 102 | + ); | ||
| 96 | 103 | ||
| 97 | function _table () { | 104 | function _table () { |
| 98 | return KTUtil::getTableName('notifications'); | 105 | return KTUtil::getTableName('notifications'); |
| 99 | } | 106 | } |
| 100 | - | ||
| 101 | - function render() { | ||
| 102 | - $notificationRegistry =& KTNotificationRegistry::getSingleton(); | ||
| 103 | - $handler = $notificationRegistry->getHandler($this->sType); | ||
| 104 | - | ||
| 105 | - if (is_null($handler)) { return null; } | ||
| 106 | - | ||
| 107 | - return $handler->handleNotification($this); | ||
| 108 | - } | ||
| 109 | - | ||
| 110 | - function resolve() { | ||
| 111 | - $notificationRegistry =& KTNotificationRegistry::getSingleton(); | ||
| 112 | - $handler = $notificationRegistry->getHandler($this->sType); | ||
| 113 | - return $handler->resolveNotification($this); | ||
| 114 | - } | 107 | + |
| 108 | + function render() { | ||
| 109 | + $notificationRegistry =& KTNotificationRegistry::getSingleton(); | ||
| 110 | + $handler = $notificationRegistry->getHandler($this->sType); | ||
| 111 | + | ||
| 112 | + if (is_null($handler)) { return null; } | ||
| 113 | + | ||
| 114 | + return $handler->handleNotification($this); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + function &getHandler() { | ||
| 118 | + $notificationRegistry =& KTNotificationRegistry::getSingleton(); | ||
| 119 | + $handler =& $notificationRegistry->getHandler($this->sType); | ||
| 120 | + return $handler; | ||
| 121 | + } | ||
| 115 | 122 | ||
| 116 | // Static function | 123 | // Static function |
| 117 | function &get($iId) { return KTEntityUtil::get('KTNotification', $iId); } | 124 | function &get($iId) { return KTEntityUtil::get('KTNotification', $iId); } |
| 118 | function &getList($sWhereClause = null, $aOptions = null ) { | 125 | function &getList($sWhereClause = null, $aOptions = null ) { |
| 119 | - if(!is_array($aOptions)) $aOptions = array($aOptions); | ||
| 120 | - $aOptions['orderby'] = KTUtil::arrayGet($aOptions, 'orderby', 'creation_date DESC'); | ||
| 121 | - return KTEntityUtil::getList2('KTNotification', $sWhereClause, $aOptions); | ||
| 122 | - } | ||
| 123 | - | 126 | + if(!is_array($aOptions)) $aOptions = array($aOptions); |
| 127 | + $aOptions['orderby'] = KTUtil::arrayGet($aOptions, 'orderby', 'creation_date DESC'); | ||
| 128 | + return KTEntityUtil::getList2('KTNotification', $sWhereClause, $aOptions); | ||
| 129 | + } | ||
| 130 | + | ||
| 124 | function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTNotification', $aOptions); } | 131 | function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTNotification', $aOptions); } |
| 125 | 132 | ||
| 126 | } | 133 | } |
| @@ -131,7 +138,7 @@ class KTNotification extends KTEntity { | @@ -131,7 +138,7 @@ class KTNotification extends KTEntity { | ||
| 131 | $notificationRegistry =& KTNotificationRegistry::getSingleton(); | 138 | $notificationRegistry =& KTNotificationRegistry::getSingleton(); |
| 132 | 139 | ||
| 133 | // abstract base-class for notification handler. | 140 | // abstract base-class for notification handler. |
| 134 | -class KTNotificationHandler { | 141 | +class KTNotificationHandler extends KTStandardDispatcher { |
| 135 | 142 | ||
| 136 | // FIXME rename this to renderNotification | 143 | // FIXME rename this to renderNotification |
| 137 | // called to _render_ the notification. | 144 | // called to _render_ the notification. |
| @@ -141,6 +148,10 @@ class KTNotificationHandler { | @@ -141,6 +148,10 @@ class KTNotificationHandler { | ||
| 141 | $aTemplateData = array("context" => $oKTNotification,); | 148 | $aTemplateData = array("context" => $oKTNotification,); |
| 142 | return $oTemplate->render($aTemplateData); | 149 | return $oTemplate->render($aTemplateData); |
| 143 | } | 150 | } |
| 151 | + | ||
| 152 | + function do_main() { | ||
| 153 | + $this->resolveNotification($this->notification); | ||
| 154 | + } | ||
| 144 | 155 | ||
| 145 | // called to resolve the notification (typically from /notify.php?id=xxxxx | 156 | // called to resolve the notification (typically from /notify.php?id=xxxxx |
| 146 | function resolveNotification($oKTNotification) { | 157 | function resolveNotification($oKTNotification) { |