Thanks, but I get a blank page when I try to edit the content of the myadopts file to this:
PHP Code:
<?php
class AdoptGroupController extends AppController{
const PARAM = "aid";
const PARAM2 = "confirm";
private $view;
private $subController;
private $group;
private $image;
public function __construct(){
parent::__construct("member");
$mysidia = Registry::get("mysidia");
if($this->action != "index"){
$this->group = new AdoptableGroup($mysidia->input->get("gid"));
if($this->group->getGroupOwner() != $mysidia->user->username) throw new NoPermissionException("You do not have permission to manage the groups of other users.");
}
}
public function index(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->setTitle($mysidia->lang->title);
$adoptgroups = $mysidia->db->select("adoptgroups", array("gid"), "owner = '{$mysidia->user->username}'")->rowCount();
$pagination = new Pagination($adoptgroups, 20, "groups");
$pagination->setPage($mysidia->input->get("page"));
$stmt = $mysidia->db->select("adoptgroups", array("gid"), "owner = '{$mysidia->user->username}' ORDER BY gid LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
if($stmt->rowCount() == 0){
$document->addLangvar($mysidia->lang->empty);
return;
}
$groupTable = new TableBuilder("grouptable", 650);
$groupTable->setAlign(new Align("center", "middle"));
$groupTable->buildHeaders("Name", "Rename", "Delete");
while($gid = $stmt->fetchColumn()){
$group = new AdoptGroup($gid);
$name = new TCell($group->getGroupName));
$rename = new TCell(new Link("adoptgroup/rename/{$gid}", "Rename"));
$delete = new TCell(new Link("adoptgroup/delete/{$gid}", "Delete"));
$adoptTable->buildRow(array($name, $rename, $delete));
}
$document->add($groupTable);
$document->addLangvar($pagination->showPage());
}
?>
Here's the class file for it(database has been updated):
PHP Code:
<?php
class AdoptGroup extends Model{
protected $gid;
protected $gname;
protected $gowner;
public function __construct($gid, $gowner = ""){
$mysidia = Registry::get("mysidia");
$whereClause = "gid ='{$gid}'";
if(!empty($gowner)) $whereClause .= " and gowner = '{$gowner}'";
$row = $mysidia->db->select("adoptgroups", array(), $whereClause)->fetchObject();
if(!is_object($row)) throw new AdoptGroupNotfoundException("This group does not exist or does not belong to the owner specified...");
parent::__construct($row->type);
foreach($row as $key => $val){
$this->$key = $val;
}
}
public function getGroupID(){
return $this->gid;
}
public function getGroupName(){
return $this->gname;}
public function getGroupOwner(){
return $this->gowner;
}
protected function save($field, $value){
$mysidia = Registry::get("mysidia");
$mysidia->db->update("adoptgroups", array($field => $value), "gid='{$this->gid}'");
}
}
?>
I'm trying to create a pet grouping system, but I don't know what I'm doing wrong...