| 1 | <?php
|
| 2 |
|
| 3 | /**
|
| 4 | * =======================================
|
| 5 | * ###################################
|
| 6 | * SWIFT Framework
|
| 7 | *
|
| 8 | * @package SWIFT
|
| 9 | * @author Kayako Infotech Ltd.
|
| 10 | * @copyright Copyright (c) 2001-2009, Kayako Infotech Ltd.
|
| 11 | * @license http://www.kayako.com/license
|
| 12 | * @link http://www.kayako.com
|
| 13 | * @filesource
|
| 14 | * ###################################
|
| 15 | * =======================================
|
| 16 | */
|
| 17 |
|
| 18 | /**
|
| 19 | * The CustomFieldGroup API Controller
|
| 20 | *
|
| 21 | * @author Ruchi Kothari
|
| 22 | */
|
| 23 | class Controller_CustomFieldGroup extends Controller_api implements SWIFT_REST_Interface
|
| 24 | {
|
| 25 |
|
| 26 | /**
|
| 27 | * Constructor
|
| 28 | *
|
| 29 | * @author Ruchi Kothari
|
| 30 | * @return bool "true" on Success, "false" otherwise
|
| 31 | */
|
| 32 | public function __construct()
|
| 33 | {
|
| 34 | parent::__construct();
|
| 35 |
|
| 36 | return true;
|
| 37 | }
|
| 38 |
|
| 39 | /**
|
| 40 | * Destructor
|
| 41 | *
|
| 42 | * @author Ruchi Kothari
|
| 43 | * @return bool "true" on Success, "false" otherwise
|
| 44 | */
|
| 45 | public function __destruct()
|
| 46 | {
|
| 47 | parent::__destruct();
|
| 48 |
|
| 49 | return true;
|
| 50 | }
|
| 51 |
|
| 52 | /**
|
| 53 | * GetList
|
| 54 | *
|
| 55 | * @author Ruchi Kothari
|
| 56 | * @return bool "true" on Success, "false" otherwise
|
| 57 | * @throws SWIFT_Exception If the Class is not Loaded
|
| 58 | */
|
| 59 | public function GetList()
|
| 60 | {
|
| 61 | if (!$this->GetIsClassLoaded()) {
|
| 62 | throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED);
|
| 63 |
|
| 64 | return false;
|
| 65 | }
|
| 66 | $this->ProcessCustomFieldGroups();
|
| 67 |
|
| 68 | $this->XML->EchoXML();
|
| 69 |
|
| 70 | return true;
|
| 71 | }
|
| 72 |
|
| 73 | /**
|
| 74 | * Retrieve custom field groups based on departments
|
| 75 | *
|
| 76 | * @author Amarjeet Kaur
|
| 77 | * @param int $_departmentID department ID
|
| 78 | * @return bool "true" on Success, "false" otherwise
|
| 79 | * @throws SWIFT_Exception If the Class is not Loaded
|
| 80 | */
|
| 81 | public function Get($_departmentID)
|
| 82 | {
|
| 83 | if (!$this->GetIsClassLoaded()) {
|
| 84 | throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED);
|
| 85 | return false;
|
| 86 | }
|
| 87 |
|
| 88 | $this->ProcessCustomFieldGroups(intval($_departmentID));
|
| 89 |
|
| 90 | $this->XML->EchoXML();
|
| 91 |
|
| 92 | return true;
|
| 93 | }
|
| 94 |
|
| 95 | /**
|
| 96 | * Process CustomField Groups
|
| 97 | *
|
| 98 | * @author Amarjeet Kaur
|
| 99 | * @param int $_departmentID department ID
|
| 100 | * @return bool "true" on Success, "false" otherwise
|
| 101 | * @throws SWIFT_Exception If the Class is not Loaded
|
| 102 | */
|
| 103 | protected function ProcessCustomFieldGroups($_departmentID = false)
|
| 104 | {
|
| 105 | if (!$this->GetIsClassLoaded()) {
|
| 106 | throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED);
|
| 107 | return false;
|
| 108 | }
|
| 109 |
|
| 110 | if(!empty($_departmentID))
|
| 111 | {
|
| 112 | $this->Database->Query("SELECT * FROM " . TABLE_PREFIX . "customfieldgroups AS customfieldgroups INNER JOIN " . TABLE_PREFIX . "customfielddeplinks AS customfielddeplinks
|
| 113 | ON customfieldgroups.customfieldgroupid = customfielddeplinks.customfieldgroupid WHERE customfielddeplinks.departmentid = '".$_departmentID."' ORDER BY displayorder ASC");
|
| 114 | } else {
|
| 115 | $this->Database->Query("SELECT * FROM " . TABLE_PREFIX . "customfieldgroups ORDER BY displayorder ASC");
|
| 116 | }
|
| 117 |
|
| 118 | $this->XML->AddParentTag('customfieldgroups');
|
| 119 | while ($this->Database->NextRecord()) {
|
| 120 | $this->XML->AddTag('customfieldgroup', '', $this->Database->Record);
|
| 121 | }
|
| 122 | $this->XML->EndParentTag('customfieldgroups');
|
| 123 |
|
| 124 | return true;
|
| 125 | }
|
| 126 | }
|
| 127 | ?> |