
Untitled
By: a guest on
May 17th, 2012 | syntax:
None | size: 1.40 KB | hits: 13 | expires: Never
abstract class Example_Editable extends Example_PermissionableRecord
{
//Require these for every Br_Editable class.
public $id;
public $date_created;
public $date_edited;
public $owner_id;
public $creator_id;
function __construct($options = array())
{
//Check to see if we are editing this bro.
if (isset($options['model']) && get_called_class() != $options['model']) {
//We are not viewing this model, return.
return;
}
//An Id was not passed, so we are just making a new one.
if (!isset($options['id'])) {
return;
}
if (!$class = $this->getByID($options['id'])) {
throw new Exception("Could not find that", 400);
}
$this->synchronizeWithArray($class->toArray());
if (!Example_ACL::isAllowed(Br_Controller::getAccount(), $this, 'view')) {
throw new Exception("You do not have permission to view this object", 401);
}
if (isset($options['model']) && substr($options['model'], -5) != '_Edit') {
//We are not viewing the Edit model for this class, return.
return;
}
if (!Example_ACL::isAllowed(Br_Controller::getAccount(), $this, 'edit')) {
throw new Exception("You do not have permission to edit this.", 401);
}
}
}