diff --git a/lib/groups/Group.inc b/lib/groups/Group.inc index 81f693c..4bc0934 100644 --- a/lib/groups/Group.inc +++ b/lib/groups/Group.inc @@ -25,7 +25,6 @@ * @package lib.groups */ -require_once(KT_LIB_DIR . '/groups/GroupUnitLink.inc'); require_once(KT_LIB_DIR . '/unitmanagement/Unit.inc'); class Group extends KTEntity { @@ -47,23 +46,12 @@ class Group extends KTEntity { $this->bIsSysAdmin = $bNewIsSysAdmin; } - // {{{ ktentity requirements - // --------------------- - // KTEntity requirements - // --------------------- - function _fieldValues () { - return array( - 'name' => $this->sName, - 'is_sys_admin' => KTUtil::anyToBool($this->bIsSysAdmin), - 'is_unit_admin' => KTUtil::anyToBool($this->bIsUnitAdmin), - ); - } - var $_aFieldToSelect = array( 'iId' => 'id', 'sName' => 'name', 'bIsUnitAdmin' => 'is_unit_admin', 'bIsSysAdmin' => 'is_sys_admin', + 'iUnitId' => 'unit_id', ); function _table () { @@ -79,12 +67,12 @@ class Group extends KTEntity { function getUnitAdmin() { return $this->bIsUnitAdmin; } function setUnitAdmin($bNewValue) { $this->bIsUnitAdmin = $bNewValue; } - function setID($iNewValue) { $this->iId = $iNewValue; } - function getID() { return $this->iId; } function getSysAdmin() { return $this->bIsSysAdmin; } function setSysAdmin($bNewValue) { $this->bIsSysAdmin = $bNewValue; } function getName() { return $this->sName; } function setName($sNewValue) { $this->sName = $sNewValue; } + function getUnitId() { return $this->iUnitId; } + function setUnitId($iNewValue) { $this->iUnitId = $iNewValue; } // }}} @@ -102,61 +90,6 @@ class Group extends KTEntity { return false; } } - - /** - * Checks if this Group is in a Unit - */ - function hasUnit() { - global $default; - - $sql = $default->db; - $query = "SELECT id FROM $default->groups_units_table WHERE group_id = ?";/*ok*/ - $aParams = array($this->iId); - $sql->query(array($query, $aParams)); - $rows = $sql->num_rows(); - if ($rows > 0){ - return true; - } else { - return false; - } - } - - function _getUnitLink() { - $oldUnitLink = GroupUnitLink::getList('group_id = ' . $this->getID()); - if (count($oldUnitLink) != 0) { - return $oldUnitLink[0]; - } else { - return null; - } - } - - function setUnit($iUnitId) { - if ($this->hasUnit()) { - $oldUnitLink = $this->_getUnitLink(); - $oldUnitLink->setUnitID($iUnitId); - $oldUnitLink->update(); - } else { - $unitLink = new GroupUnitLink($this->iId, $iUnitId); - $unitLink->create(); - } - } - - function clearUnit() { - $oLink = $this->_getUnitLink(); - if ($oLink !== null) { - $oLink->delete(); - } - } - - function getUnit() { - $oLink = $this->_getUnitLink(); - if ($oLink !== null) { - $oUnit = Unit::get($oLink->getUnitID()); - return $oUnit; - } else { - return null; - } - } /** * Static function.