[ 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: João Prado Maia <jpm@mysql.com> | 26 // +----------------------------------------------------------------------+ 27 // 28 // @(#) $Id: class.status.php 3246 2007-02-09 09:10:12Z glen $ 29 // 30 31 require_once (APP_INC_PATH . "class.error_handler.php"); 32 33 /** 34 * Class to handle all business logic related to the way statuses 35 * are represented in the system. 36 * 37 * @version 1.0 38 * @author João Prado Maia <jpm@mysql.com> 39 */ 40 41 class Status 42 { 43 /** 44 * Returns the label and date field associated with the customization of 45 * the given project and status IDs. 46 * 47 * @access public 48 * @param integer $prj_id The project ID 49 * @param array $sta_ids The list of status IDs 50 * @return array The label and date field 51 */ 52 function getProjectStatusCustomization($prj_id, $sta_ids) 53 { 54 $sta_ids = array_unique($sta_ids); 55 $stmt = "SELECT 56 psd_sta_id, 57 psd_label, 58 psd_date_field 59 FROM 60 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date 61 WHERE 62 psd_prj_id=" . Misc::escapeInteger($prj_id) . " AND 63 psd_sta_id IN (" . implode(', ', Misc::escapeInteger($sta_ids)) . ")"; 64 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 65 if (PEAR::isError($res)) { 66 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 67 return array(); 68 } else { 69 return $res; 70 } 71 } 72 73 74 /** 75 * Returns the details of a given project status customization entry. 76 * 77 * @access public 78 * @param integer $psd_id The customization entry ID 79 * @return array The details 80 */ 81 function getCustomizationDetails($psd_id) 82 { 83 $stmt = "SELECT 84 * 85 FROM 86 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date 87 WHERE 88 psd_id=" . Misc::escapeInteger($psd_id); 89 $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC); 90 if (PEAR::isError($res)) { 91 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 92 return ""; 93 } else { 94 return $res; 95 } 96 } 97 98 99 /** 100 * Removes a given set of customizations. 101 * 102 * @access public 103 * @param array $items The customization entry IDs 104 * @return boolean 105 */ 106 function removeCustomization($items) 107 { 108 $items = @implode(", ", Misc::escapeInteger($items)); 109 $stmt = "DELETE FROM 110 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date 111 WHERE 112 psd_id IN ($items)"; 113 $res = $GLOBALS["db_api"]->dbh->query($stmt); 114 if (PEAR::isError($res)) { 115 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 116 return false; 117 } else { 118 return true; 119 } 120 } 121 122 123 /** 124 * Method used to update the details of a customization entry in the system. 125 * 126 * @access public 127 * @param integer $psd_id The customization entry ID 128 * @param integer $prj_id The project ID 129 * @param integer $sta_id The status ID 130 * @param string $date_field The date field name 131 * @param string $label The label that should appear in the issue listing screen 132 * @return integer 1 if the insert worked properly, any other value otherwise 133 */ 134 function updateCustomization($psd_id, $prj_id, $sta_id, $date_field, $label) 135 { 136 $stmt = "UPDATE 137 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date 138 SET 139 psd_prj_id=" . Misc::escapeInteger($prj_id) . ", 140 psd_sta_id=" . Misc::escapeInteger($sta_id) . ", 141 psd_date_field='" . Misc::escapeString($date_field) . "', 142 psd_label='" . Misc::escapeString($label) . "' 143 WHERE 144 psd_id=" . Misc::escapeInteger($psd_id); 145 $res = $GLOBALS["db_api"]->dbh->query($stmt); 146 if (PEAR::isError($res)) { 147 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 148 return -1; 149 } else { 150 return 1; 151 } 152 } 153 154 155 /** 156 * Method used to add a new customization entry to the system. 157 * 158 * @access public 159 * @param integer $prj_id The project ID 160 * @param integer $sta_id The status ID 161 * @param string $date_field The date field name 162 * @param string $label The label that should appear in the issue listing screen 163 * @return integer 1 if the insert worked properly, any other value otherwise 164 */ 165 function insertCustomization($prj_id, $sta_id, $date_field, $label) 166 { 167 $stmt = "INSERT INTO 168 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date 169 ( 170 psd_prj_id, 171 psd_sta_id, 172 psd_date_field, 173 psd_label 174 ) VALUES ( 175 " . Misc::escapeInteger($prj_id) . ", 176 " . Misc::escapeInteger($sta_id) . ", 177 '" . Misc::escapeString($date_field) . "', 178 '" . Misc::escapeString($label) . "' 179 )"; 180 $res = $GLOBALS["db_api"]->dbh->query($stmt); 181 if (PEAR::isError($res)) { 182 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 183 return -1; 184 } else { 185 return 1; 186 } 187 } 188 189 190 /** 191 * Method used to get a list of all existing customizations. 192 * 193 * @access public 194 * @return array The list of available customizations 195 */ 196 function getCustomizationList() 197 { 198 $stmt = "SELECT 199 psd_id, 200 psd_prj_id, 201 psd_sta_id, 202 psd_label, 203 psd_date_field, 204 prj_title, 205 sta_title 206 FROM 207 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status_date, 208 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project, 209 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 210 WHERE 211 prj_id=psd_prj_id AND 212 sta_id=psd_sta_id 213 ORDER BY 214 prj_title ASC"; 215 $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); 216 if (PEAR::isError($res)) { 217 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 218 return ""; 219 } else { 220 $date_fields = Issue::getDateFieldsAssocList(TRUE); 221 for ($i = 0; $i < count($res); $i++) { 222 $res[$i]['date_field'] = $date_fields[$res[$i]['psd_date_field']]; 223 } 224 return $res; 225 } 226 } 227 228 229 /** 230 * Method used to check whether the given status has a closed context or 231 * not. 232 * 233 * @access public 234 * @return boolean 235 */ 236 function hasClosedContext($sta_id) 237 { 238 $stmt = "SELECT 239 sta_is_closed 240 FROM 241 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 242 WHERE 243 sta_id=" . Misc::escapeInteger($sta_id); 244 $res = $GLOBALS["db_api"]->dbh->getOne($stmt); 245 if (PEAR::isError($res)) { 246 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 247 return false; 248 } else { 249 if (empty($res)) { 250 return false; 251 } else { 252 return true; 253 } 254 } 255 } 256 257 258 /** 259 * Method used to add a new custom status to the system. 260 * 261 * @access public 262 * @return integer 1 if the insert worked properly, any other value otherwise 263 */ 264 function insert() 265 { 266 if (Validation::isWhitespace($_POST['title'])) { 267 return -2; 268 } 269 $stmt = "INSERT INTO 270 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 271 ( 272 sta_title, 273 sta_abbreviation, 274 sta_rank, 275 sta_color, 276 sta_is_closed 277 ) VALUES ( 278 '" . Misc::escapeString($_POST['title']) . "', 279 '" . Misc::escapeString($_POST['abbreviation']) . "', 280 " . Misc::escapeInteger($_POST['rank']) . ", 281 '" . Misc::escapeString($_POST['color']) . "', 282 " . Misc::escapeInteger($_POST['is_closed']) . " 283 )"; 284 $res = $GLOBALS["db_api"]->dbh->query($stmt); 285 if (PEAR::isError($res)) { 286 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 287 return -1; 288 } else { 289 $new_status_id = $GLOBALS["db_api"]->get_last_insert_id(); 290 // now populate the project-status mapping table 291 foreach ($_POST['projects'] as $prj_id) { 292 Status::addProjectAssociation($new_status_id, $prj_id); 293 } 294 return 1; 295 } 296 } 297 298 299 /** 300 * Method used to update the details of a given custom status. 301 * 302 * @access public 303 * @return integer 1 if the update worked properly, any other value otherwise 304 */ 305 function update() 306 { 307 if (Validation::isWhitespace($_POST["title"])) { 308 return -2; 309 } 310 $stmt = "UPDATE 311 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 312 SET 313 sta_title='" . Misc::escapeString($_POST["title"]) . "', 314 sta_abbreviation='" . Misc::escapeString($_POST["abbreviation"]) . "', 315 sta_rank=" . Misc::escapeInteger($_POST['rank']) . ", 316 sta_color='" . Misc::escapeString($_POST["color"]) . "', 317 sta_is_closed=" . Misc::escapeInteger($_POST['is_closed']) . " 318 WHERE 319 sta_id=" . Misc::escapeInteger($_POST["id"]); 320 $res = $GLOBALS["db_api"]->dbh->query($stmt); 321 if (PEAR::isError($res)) { 322 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 323 return -1; 324 } else { 325 $projects = Status::getAssociatedProjects($_POST['id']); 326 $current_projects = array_keys($projects); 327 // remove all of the associations with projects, then add them all again 328 Status::removeProjectAssociations($_POST['id']); 329 foreach ($_POST['projects'] as $prj_id) { 330 Status::addProjectAssociation($_POST['id'], $prj_id); 331 } 332 // need to update all issues that are not supposed to have the changed sta_id to '0' 333 $removed_projects = array(); 334 foreach ($current_projects as $project_id) { 335 if (!in_array($project_id, $_POST['projects'])) { 336 $removed_projects[] = $project_id; 337 } 338 } 339 if (count($removed_projects) > 0) { 340 $stmt = "UPDATE 341 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 342 SET 343 iss_sta_id=0 344 WHERE 345 iss_sta_id=" . Misc::escapeInteger($_POST['id']) . " AND 346 iss_prj_id IN (" . implode(', ', $removed_projects) . ")"; 347 $res = $GLOBALS["db_api"]->dbh->query($stmt); 348 if (PEAR::isError($res)) { 349 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 350 } 351 } 352 return 1; 353 } 354 } 355 356 357 /** 358 * Method used to remove a set of custom statuses. 359 * 360 * @access public 361 * @return boolean 362 */ 363 function remove() 364 { 365 $items = @implode(", ", Misc::escapeInteger($_POST["items"])); 366 $stmt = "DELETE FROM 367 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 368 WHERE 369 sta_id IN ($items)"; 370 $res = $GLOBALS["db_api"]->dbh->query($stmt); 371 if (PEAR::isError($res)) { 372 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 373 return false; 374 } else { 375 Status::removeProjectAssociations($_POST['items']); 376 // also set all issues currently set to these statuses to status '0' 377 $stmt = "UPDATE 378 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue 379 SET 380 iss_sta_id=0 381 WHERE 382 iss_sta_id IN ($items)"; 383 $GLOBALS["db_api"]->dbh->query($stmt); 384 return true; 385 } 386 } 387 388 389 /** 390 * Method used to add a project association to a status. 391 * 392 * @access public 393 * @param integer $sta_id The status ID 394 * @param integer $prj_id The project ID 395 * @return void 396 */ 397 function addProjectAssociation($sta_id, $prj_id) 398 { 399 $stmt = "INSERT INTO 400 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 401 ( 402 prs_sta_id, 403 prs_prj_id 404 ) VALUES ( 405 " . Misc::escapeInteger($sta_id) . ", 406 " . Misc::escapeInteger($prj_id) . " 407 )"; 408 $GLOBALS["db_api"]->dbh->query($stmt); 409 } 410 411 412 /** 413 * Method used to remove the project associations for a given 414 * custom status. 415 * 416 * @access public 417 * @param integer $sta_id The custom status ID 418 * @param integer $prj_id The project ID 419 * @return boolean 420 */ 421 function removeProjectAssociations($sta_id, $prj_id=FALSE) 422 { 423 if (!is_array($sta_id)) { 424 $sta_id = array($sta_id); 425 } 426 $items = @implode(", ", Misc::escapeInteger($sta_id)); 427 $stmt = "DELETE FROM 428 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 429 WHERE 430 prs_sta_id IN ($items)"; 431 if ($prj_id) { 432 $stmt .= " AND prs_prj_id=" . Misc::escapeInteger($prj_id); 433 } 434 $res = $GLOBALS["db_api"]->dbh->query($stmt); 435 if (PEAR::isError($res)) { 436 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 437 return false; 438 } else { 439 return true; 440 } 441 } 442 443 444 /** 445 * Method used to get the details of a given status ID. 446 * 447 * @access public 448 * @param integer $sta_id The custom status ID 449 * @return array The status details 450 */ 451 function getDetails($sta_id) 452 { 453 $stmt = "SELECT 454 * 455 FROM 456 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 457 WHERE 458 sta_id=" . Misc::escapeInteger($sta_id); 459 $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC); 460 if (PEAR::isError($res)) { 461 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 462 return ""; 463 } else { 464 // get all of the project associations here as well 465 $res['projects'] = array_keys(Status::getAssociatedProjects($res['sta_id'])); 466 return $res; 467 } 468 } 469 470 471 /** 472 * Method used to get the list of statuses ordered by title. 473 * 474 * @access public 475 * @return array The list of statuses 476 */ 477 function getList() 478 { 479 $stmt = "SELECT 480 * 481 FROM 482 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 483 ORDER BY 484 sta_rank ASC, 485 sta_title"; 486 $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); 487 if (PEAR::isError($res)) { 488 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 489 return ""; 490 } else { 491 // get the list of associated projects 492 for ($i = 0; $i < count($res); $i++) { 493 $res[$i]['projects'] = implode(", ", array_values(Status::getAssociatedProjects($res[$i]['sta_id']))); 494 } 495 return $res; 496 } 497 } 498 499 500 /** 501 * Method used to get the list of associated projects for a given 502 * custom status. 503 * 504 * @access public 505 * @param integer $sta_id The custom status ID 506 * @return array The list of projects 507 */ 508 function getAssociatedProjects($sta_id) 509 { 510 $stmt = "SELECT 511 prj_id, 512 prj_title 513 FROM 514 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project, 515 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 516 WHERE 517 prj_id=prs_prj_id AND 518 prs_sta_id=" . Misc::escapeInteger($sta_id); 519 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 520 if (PEAR::isError($res)) { 521 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 522 return array(); 523 } else { 524 return $res; 525 } 526 } 527 528 529 /** 530 * Method used to get the status ID for a given status title. 531 * 532 * @access public 533 * @param string $sta_title The status title 534 * @return integer The status ID 535 */ 536 function getStatusID($sta_title) 537 { 538 static $returns; 539 540 if (!empty($returns[$sta_title])) { 541 return $returns[$sta_title]; 542 } 543 544 $stmt = "SELECT 545 sta_id 546 FROM 547 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 548 WHERE 549 sta_title='" . Misc::escapeString($sta_title) . "'"; 550 $res = $GLOBALS["db_api"]->dbh->getOne($stmt); 551 if (PEAR::isError($res)) { 552 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 553 return ""; 554 } else { 555 $returns[$sta_title] = $res; 556 return $res; 557 } 558 } 559 560 561 /** 562 * Method used to get the status title for a given status ID. 563 * 564 * @access public 565 * @param integer $sta_id The status ID 566 * @return string The status title 567 */ 568 function getStatusTitle($sta_id) 569 { 570 $stmt = "SELECT 571 sta_title 572 FROM 573 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 574 WHERE 575 sta_id=" . Misc::escapeInteger($sta_id); 576 $res = $GLOBALS["db_api"]->dbh->getOne($stmt); 577 if (PEAR::isError($res)) { 578 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 579 return ""; 580 } else { 581 return $res; 582 } 583 } 584 585 586 /** 587 * Method used to get the list of available closed-context statuses as an 588 * associative array in the style of (abbreviation => title) 589 * 590 * @access public 591 * @param array $prj_id List of project IDs 592 * @return array The list of closed-context statuses 593 */ 594 function getClosedAbbreviationAssocList($prj_id) 595 { 596 if (!is_array($prj_id)) { 597 $prj_id = array($prj_id); 598 } 599 $items = @implode(", ", Misc::escapeInteger($prj_id)); 600 $stmt = "SELECT 601 UPPER(sta_abbreviation), 602 sta_title 603 FROM 604 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status, 605 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 606 WHERE 607 prs_prj_id IN ($items) AND 608 prs_sta_id=sta_id AND 609 sta_is_closed=1 610 ORDER BY 611 sta_rank ASC"; 612 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 613 if (PEAR::isError($res)) { 614 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 615 return ""; 616 } else { 617 return $res; 618 } 619 } 620 621 622 /** 623 * Method used to get the list of available statuses as an associative array 624 * in the style of (abbreviation => title) 625 * 626 * @access public 627 * @param array $prj_id List of project IDs 628 * @param boolean $show_closed Whether to also return closed-context statuses or not 629 * @return array The list of statuses 630 */ 631 function getAbbreviationAssocList($prj_id, $show_closed) 632 { 633 if (!is_array($prj_id)) { 634 $prj_id = array($prj_id); 635 } 636 $items = @implode(", ", Misc::escapeInteger($prj_id)); 637 $stmt = "SELECT 638 UPPER(sta_abbreviation), 639 sta_title 640 FROM 641 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status, 642 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 643 WHERE 644 prs_prj_id IN ($items) AND 645 prs_sta_id=sta_id"; 646 if (!$show_closed) { 647 $stmt .= " AND sta_is_closed=0 "; 648 } 649 $stmt .= " 650 ORDER BY 651 sta_rank ASC"; 652 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 653 if (PEAR::isError($res)) { 654 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 655 return ""; 656 } else { 657 return $res; 658 } 659 } 660 661 662 /** 663 * Method used to get the list of available statuses as an associative array 664 * in the style of (id => title) 665 * 666 * @access public 667 * @param array $prj_id List of project IDs 668 * @param boolean $show_closed Whether to show closed context statuses or not 669 * @return array The list of statuses 670 */ 671 function getAssocStatusList($prj_id, $show_closed = TRUE) 672 { 673 if (!is_array($prj_id)) { 674 $prj_id = array($prj_id); 675 } 676 $items = @implode(", ", Misc::escapeInteger($prj_id)); 677 $stmt = "SELECT 678 sta_id, 679 sta_title 680 FROM 681 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status, 682 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 683 WHERE 684 prs_prj_id IN ($items) AND 685 prs_sta_id=sta_id"; 686 if (!$show_closed) { 687 $stmt .= " AND sta_is_closed=0 "; 688 } 689 $stmt .= " 690 ORDER BY 691 sta_rank ASC"; 692 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 693 if (PEAR::isError($res)) { 694 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 695 return ""; 696 } else { 697 return $res; 698 } 699 } 700 701 702 /** 703 * Method used to get the list of available statuses as an associative array 704 * in the style of (id => title) 705 * 706 * @access public 707 * @return array The list of statuses 708 */ 709 function getAssocList() 710 { 711 $stmt = "SELECT 712 sta_id, 713 sta_title 714 FROM 715 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 716 ORDER BY 717 sta_rank ASC"; 718 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 719 if (PEAR::isError($res)) { 720 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 721 return ""; 722 } else { 723 return $res; 724 } 725 } 726 727 728 /** 729 * Method used to get the list of available statuses as an associative array 730 * in the style of (id => title). Only return the list of statuses that have 731 * a 'closed' context. 732 * 733 * @access public 734 * @param integer $prj_id The project ID 735 * @return array The list of statuses 736 */ 737 function getClosedAssocList($prj_id) 738 { 739 $stmt = "SELECT 740 sta_id, 741 sta_title 742 FROM 743 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status, 744 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_status 745 WHERE 746 prs_prj_id=" . Misc::escapeInteger($prj_id) . " AND 747 prs_sta_id=sta_id AND 748 sta_is_closed=1 749 ORDER BY 750 sta_rank ASC"; 751 $res = $GLOBALS["db_api"]->dbh->getAssoc($stmt); 752 if (PEAR::isError($res)) { 753 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 754 return ""; 755 } else { 756 return $res; 757 } 758 } 759 760 761 /** 762 * Method used to get the list of statuses and their respective colors 763 * 764 * @access public 765 * @return array List of statuses 766 */ 767 function getStatusColors() 768 { 769 $stmt = "SELECT 770 sta_color, 771 sta_title 772 FROM 773 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status 774 ORDER BY 775 sta_rank ASC"; 776 $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC); 777 if (PEAR::isError($res)) { 778 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); 779 return ""; 780 } else { 781 return $res; 782 } 783 } 784 } 785 786 // benchmarking the included file (aka setup time) 787 if (APP_BENCHMARK) { 788 $GLOBALS['bench']->setMarker('Included Status Class'); 789 }
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 |