[ Index ] |
PHP Cross Reference of Eventum |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 encoding=utf-8: */ 3 // +----------------------------------------------------------------------+ 4 // | Eventum - Issue Tracking System | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003, 2004, 2005, 2006, 2007 MySQL AB | 7 // | | 8 // | This program is free software; you can redistribute it and/or modify | 9 // | it under the terms of the GNU General Public License as published by | 10 // | the Free Software Foundation; either version 2 of the License, or | 11 // | (at your option) any later version. | 12 // | | 13 // | This program is distributed in the hope that it will be useful, | 14 // | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 // | GNU General Public License for more details. | 17 // | | 18 // | You should have received a copy of the GNU General Public License | 19 // | along with this program; if not, write to: | 20 // | | 21 // | Free Software Foundation, Inc. | 22 // | 59 Temple Place - Suite 330 | 23 // | Boston, MA 02111-1307, USA. | 24 // +----------------------------------------------------------------------+ 25 // | Authors: Bryan Alsdorf <bryan@mysql.com> | 26 // +----------------------------------------------------------------------+ 27 // 28 29 require_once (APP_INC_PATH . "workflow/class.abstract_workflow_backend.php"); 30 31 /** 32 * Example workflow backend class. For example purposes it will print what 33 * method is called. 34 * 35 * @author Bryan Alsdorf <bryan@mysql.com> 36 */ 37 class Example_Workflow_Backend extends Abstract_Workflow_Backend 38 { 39 /** 40 * Called when an issue is updated. 41 * 42 * @param integer $prj_id The project ID. 43 * @param integer $issue_id The ID of the issue. 44 * @param integer $usr_id The ID of the user. 45 * @param array $old_details The old details of the issues. 46 * @param array $changes The changes that were applied to this issue (the $_POST) 47 */ 48 function handleIssueUpdated($prj_id, $issue_id, $usr_id, $old_details, $changes) 49 { 50 echo "Workflow: Issue Updated<br />\n"; 51 } 52 53 54 /** 55 * Called when an issue is assigned. 56 * 57 * @param integer $prj_id The projectID 58 * @param integer $issue_id The ID of the issue. 59 * @param integer $usr_id The id of the user who assigned the issue. 60 */ 61 function handleAssignment($prj_id, $issue_id, $usr_id) 62 { 63 echo "Workflow: Issue Assigned<br />\n"; 64 } 65 66 67 /** 68 * Called when a file is attached to an issue. 69 * 70 * @param integer $prj_id The projectID 71 * @param integer $issue_id The ID of the issue. 72 * @param integer $usr_id The id of the user who locked the issue. 73 */ 74 function handleAttachment($prj_id, $issue_id, $usr_id) 75 { 76 echo "Workflow: File attached<br />\n"; 77 } 78 79 80 /** 81 * Called when the priority of an issue changes. 82 * 83 * @param integer $prj_id The projectID 84 * @param integer $issue_id The ID of the issue. 85 * @param integer $usr_id The id of the user who locked the issue. 86 * @param array $old_details The old details of the issue. 87 * @param array $changes The changes that were applied to this issue (the $_POST) 88 */ 89 function handlePriorityChange($prj_id, $issue_id, $usr_id, $old_details, $changes) 90 { 91 echo "Workflow: Priority Changed<br />\n"; 92 } 93 94 95 /** 96 * Called when an email is blocked. 97 * 98 * @param integer $prj_id The projectID 99 * @param integer $issue_id The ID of the issue. 100 * @param array $email_details Details of the issue 101 * @param string $type What type of blocked email this is. 102 */ 103 function handleBlockedEmail($prj_id, $issue_id, $email_details, $type) 104 { 105 echo "Workflow: Email Blocked<br />\n"; 106 } 107 108 109 /** 110 * Called when a note is routed. 111 * 112 * @param integer $prj_id The projectID 113 * @param integer $issue_id The ID of the issue. 114 * @param integer $usr_id The user ID of the person posting this new note 115 * @param boolean $closing If the issue is being closed 116 * @param integer $note_id The ID of the new note 117 */ 118 function handleNewNote($prj_id, $issue_id, $usr_id, $closing, $note_id) 119 { 120 echo "Workflow: New Note<br />\n"; 121 } 122 123 124 /** 125 * Called when the assignment on an issue changes. 126 * 127 * @param integer $prj_id The projectID 128 * @param integer $issue_id The ID of the issue. 129 * @param integer $usr_id The id of the user who locked the issue. 130 * @param array $issue_details The old details of the issue. 131 * @param array $new_assignees The new assignees of this issue. 132 * @param boolean $remote_assignment If this issue was remotely assigned. 133 */ 134 function handleAssignmentChange($prj_id, $issue_id, $usr_id, $issue_details, $new_assignees, $remote_assignment) 135 { 136 echo "Workflow: Assignment changed<br />\n"; 137 } 138 139 140 /** 141 * Called when a new issue is created. 142 * 143 * @param integer $prj_id The projectID 144 * @param integer $issue_id The ID of the issue. 145 * @param boolean $has_TAM If this issue has a technical account manager. 146 * @param boolean $has_RR If Round Robin was used to assign this issue. 147 */ 148 function handleNewIssue($prj_id, $issue_id, $has_TAM, $has_RR) 149 { 150 echo "Workflow: New Issue<br />\n"; 151 } 152 153 154 155 156 /** 157 * Updates the existing issue to a different status when an email is 158 * manually associated to an existing issue. 159 * 160 * @access public 161 * @param integer $prj_id The projectID 162 * @param integer $issue_id The issue ID 163 */ 164 function handleManualEmailAssociation($prj_id, $issue_id) 165 { 166 echo "Workflow: Manually associating email to issue<br />\n"; 167 } 168 169 170 /** 171 * Called when a new message is recieved. 172 * 173 * @param integer $prj_id The projectID 174 * @param integer $issue_id The ID of the issue. 175 * @param object $message An object containing the new email 176 * @param array $row The array of data that was inserted into the database. 177 * @param boolean $closing If we are closing the issue. 178 */ 179 function handleNewEmail($prj_id, $issue_id, $message, $row = false, $closing = false) 180 { 181 echo "Workflow: New"; 182 if ($closing) { 183 echo " closing"; 184 } 185 echo " Email<br />\n"; 186 } 187 188 189 /** 190 * Method is called to return the list of statuses valid for a specific issue. 191 * 192 * @param integer $prj_id The projectID 193 * @param integer $issue_id The ID of the issue. 194 * @return array An associative array of statuses valid for this issue. 195 */ 196 function getAllowedStatuses($prj_id, $issue_id) 197 { 198 echo "Workflow: Returning allowed statuses<br />\n"; 199 $statuses = Status::getAssocStatusList($prj_id, false); 200 unset($statuses[4], $statuses[3]); 201 // you should perform any logic and remove any statuses you need to here. 202 return $statuses; 203 } 204 205 206 /** 207 * Called when an attempt is made to add a user or email address to the 208 * notification list. 209 * 210 * @param integer $prj_id The project ID 211 * @param integer $issue_id The ID of the issue. 212 * @param integer $subscriber_usr_id The ID of the user to subscribe if this is a real user (false otherwise). 213 * @param string $email The email address to subscribe to subscribe (if this is not a real user). 214 * @param array $types The action types. 215 * @return mixed An array of information or true to continue unchanged or false to prevent the user from being added. 216 */ 217 function handleSubscription($prj_id, $issue_id, &$subscriber_usr_id, &$email, &$actions) 218 { 219 // prevent a certain email address from being added to the notification list. 220 if ($email == "invalidemail@example.com") { 221 return false; 222 } 223 // just for this example, if the usr_id is 99, change the usr_id to 100 224 if ($subscriber_usr_id == 99) { 225 $subscriber_usr_id = 100; 226 } 227 // another thing this workflow can do is change the actions a user is subscribed too. 228 // we will make sure all users are subscribed to the "email" action. 229 if (!in_array("emails", $actions)) { 230 $actions[] = "emails"; 231 } 232 // you can also change the email address being subscribed 233 if ($email == "changethis@example.com") { 234 $email = "changed@example.com"; 235 } 236 // if you want the subscription to be added with no changes, simply return true; 237 return true; 238 } 239 240 241 /** 242 * Called when issue is closed. 243 * 244 * @param integer $prj_id The project ID 245 * @param integer $issue_id The ID of the issue. 246 * @param boolean $send_notification Whether to send a notification about this action or not 247 * @param integer $resolution_id The resolution ID 248 * @param integer $status_id The status ID 249 * @param string $reason The reason for closing this issue 250 * @return void 251 */ 252 function handleIssueClosed($prj_id, $issue_id, $send_notification, $resolution_id, $status_id, $reason) 253 { 254 $sql = "UPDATE 255 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 256 SET 257 iss_percent_complete = '100%' 258 WHERE 259 iss_id = $issue_id"; 260 $res = $GLOBALS["db_api"]->dbh->query($sql); 261 if (PEAR::isError($res)) { 262 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 263 return false; 264 } 265 266 echo "Workflow: handleIssueClosed<br />\n"; 267 } 268 269 270 /** 271 * Called when custom fields are updated 272 * 273 * @param integer $prj_id The project ID 274 * @param integer $issue_id The ID of the issue 275 * @param array $old The custom fields before the update. 276 * @param array $new The custom fields after the update. 277 */ 278 function handleCustomFieldsUpdated($prj_id, $issue_id, $old, $new) 279 { 280 echo "Workflow: handleCustomFieldsUpdated<br />\n"; 281 } 282 283 284 /** 285 * Determines if the address should should be emailed. 286 * 287 * @param integer $prj_id The project ID 288 * @param string $address The email address to check 289 * @return boolean 290 */ 291 function shouldEmailAddress($prj_id, $address) 292 { 293 if ($address == "bad_email@example.com") { 294 return false; 295 } else { 296 return true; 297 } 298 } 299 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 19 21:21:33 2007 | Cross-referenced by PHPXref 0.7 |