<?php
Class ManageGroup extends Management {
private $group;
public function __construct(){
parent::__construct();
$this->group = new Group();
//observer object
$user = new User();
$privileges = new Privileges();
$this->group->registerObserver($user);
$this->group->registerObserver($privileges);
}
public function show(){
parent::show();
}
public function remove(){
parent::remove();
}
public function removeItem(){
$this->group->remove($_POST['id']);
}
public function populateShowContent(){
$array_column = array("Group Name");
$this->xml->addTable($this->group->select($this->offset,$this->pglimit),$array_column,'Table Available Group',
$this->navigator->getAccess($this),$this->offset,'rightcontent',0);
}
public function populateAddForm(){
$this->xml->addTextField('Group Name',null,'description','text');
}
public function populateEditForm(){
$this->group->selectByID($_POST['id']);
$this->xml->addTextField('Group Name',$this->group->getName(),'description','text');
}
//return string to set the title
public function getTitle(){
return SITENAME.' -group';
}
public function getFormPlace(){
return 'panel';
}
public function editItem(){
$array = array('name'=>$_POST['description']);
return $this->group->update($array,$_POST['id']);
}
public function getKeyVar(){
return 'description';
}
public function getTotal(){
return $this->group->getTotal();
}
public function addItem(){
$array = array('',$_POST['description']);
$this->group->add($array);
}
public function checkAdd(){
if($this->group->isGroupExist($_POST['description'])){
die('Group name is already exists');
}
}
public function checkEdit(){
$this->group->selectByID($_POST['id']);
if($this->group->getName()!=$_POST['description']){
$this->checkAdd();
}
}
}
?>