Commit 980a413aef60607d480f61d56b3975fda9cce8a6

Authored by Neil Blakey-Milner
1 parent 1b365927

Make unit_id directly part of Group - groups are members of one unit at

a maximum.  Remove all unused unit-related methods.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4717 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 3 additions and 70 deletions
lib/groups/Group.inc
@@ -25,7 +25,6 @@ @@ -25,7 +25,6 @@
25 * @package lib.groups 25 * @package lib.groups
26 */ 26 */
27 27
28 -require_once(KT_LIB_DIR . '/groups/GroupUnitLink.inc');  
29 require_once(KT_LIB_DIR . '/unitmanagement/Unit.inc'); 28 require_once(KT_LIB_DIR . '/unitmanagement/Unit.inc');
30 29
31 class Group extends KTEntity { 30 class Group extends KTEntity {
@@ -47,23 +46,12 @@ class Group extends KTEntity { @@ -47,23 +46,12 @@ class Group extends KTEntity {
47 $this->bIsSysAdmin = $bNewIsSysAdmin; 46 $this->bIsSysAdmin = $bNewIsSysAdmin;
48 } 47 }
49 48
50 - // {{{ ktentity requirements  
51 - // ---------------------  
52 - // KTEntity requirements  
53 - // ---------------------  
54 - function _fieldValues () {  
55 - return array(  
56 - 'name' => $this->sName,  
57 - 'is_sys_admin' => KTUtil::anyToBool($this->bIsSysAdmin),  
58 - 'is_unit_admin' => KTUtil::anyToBool($this->bIsUnitAdmin),  
59 - );  
60 - }  
61 -  
62 var $_aFieldToSelect = array( 49 var $_aFieldToSelect = array(
63 'iId' => 'id', 50 'iId' => 'id',
64 'sName' => 'name', 51 'sName' => 'name',
65 'bIsUnitAdmin' => 'is_unit_admin', 52 'bIsUnitAdmin' => 'is_unit_admin',
66 'bIsSysAdmin' => 'is_sys_admin', 53 'bIsSysAdmin' => 'is_sys_admin',
  54 + 'iUnitId' => 'unit_id',
67 ); 55 );
68 56
69 function _table () { 57 function _table () {
@@ -79,12 +67,12 @@ class Group extends KTEntity { @@ -79,12 +67,12 @@ class Group extends KTEntity {
79 67
80 function getUnitAdmin() { return $this->bIsUnitAdmin; } 68 function getUnitAdmin() { return $this->bIsUnitAdmin; }
81 function setUnitAdmin($bNewValue) { $this->bIsUnitAdmin = $bNewValue; } 69 function setUnitAdmin($bNewValue) { $this->bIsUnitAdmin = $bNewValue; }
82 - function setID($iNewValue) { $this->iId = $iNewValue; }  
83 - function getID() { return $this->iId; }  
84 function getSysAdmin() { return $this->bIsSysAdmin; } 70 function getSysAdmin() { return $this->bIsSysAdmin; }
85 function setSysAdmin($bNewValue) { $this->bIsSysAdmin = $bNewValue; } 71 function setSysAdmin($bNewValue) { $this->bIsSysAdmin = $bNewValue; }
86 function getName() { return $this->sName; } 72 function getName() { return $this->sName; }
87 function setName($sNewValue) { $this->sName = $sNewValue; } 73 function setName($sNewValue) { $this->sName = $sNewValue; }
  74 + function getUnitId() { return $this->iUnitId; }
  75 + function setUnitId($iNewValue) { $this->iUnitId = $iNewValue; }
88 // }}} 76 // }}}
89 77
90 78
@@ -102,61 +90,6 @@ class Group extends KTEntity { @@ -102,61 +90,6 @@ class Group extends KTEntity {
102 return false; 90 return false;
103 } 91 }
104 } 92 }
105 -  
106 - /**  
107 - * Checks if this Group is in a Unit  
108 - */  
109 - function hasUnit() {  
110 - global $default;  
111 -  
112 - $sql = $default->db;  
113 - $query = "SELECT id FROM $default->groups_units_table WHERE group_id = ?";/*ok*/  
114 - $aParams = array($this->iId);  
115 - $sql->query(array($query, $aParams));  
116 - $rows = $sql->num_rows();  
117 - if ($rows > 0){  
118 - return true;  
119 - } else {  
120 - return false;  
121 - }  
122 - }  
123 -  
124 - function _getUnitLink() {  
125 - $oldUnitLink = GroupUnitLink::getList('group_id = ' . $this->getID());  
126 - if (count($oldUnitLink) != 0) {  
127 - return $oldUnitLink[0];  
128 - } else {  
129 - return null;  
130 - }  
131 - }  
132 -  
133 - function setUnit($iUnitId) {  
134 - if ($this->hasUnit()) {  
135 - $oldUnitLink = $this->_getUnitLink();  
136 - $oldUnitLink->setUnitID($iUnitId);  
137 - $oldUnitLink->update();  
138 - } else {  
139 - $unitLink = new GroupUnitLink($this->iId, $iUnitId);  
140 - $unitLink->create();  
141 - }  
142 - }  
143 -  
144 - function clearUnit() {  
145 - $oLink = $this->_getUnitLink();  
146 - if ($oLink !== null) {  
147 - $oLink->delete();  
148 - }  
149 - }  
150 -  
151 - function getUnit() {  
152 - $oLink = $this->_getUnitLink();  
153 - if ($oLink !== null) {  
154 - $oUnit = Unit::get($oLink->getUnitID());  
155 - return $oUnit;  
156 - } else {  
157 - return null;  
158 - }  
159 - }  
160 93
161 /** 94 /**
162 * Static function. 95 * Static function.