2008-11-05 05:32:47 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.");
|
|
|
|
|
/**
|
|
|
|
|
* Gallery - a web based photo album viewer and editor
|
2009-05-13 20:04:58 +00:00
|
|
|
* Copyright (C) 2000-2009 Bharat Mediratta
|
2008-11-05 05:32:47 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
|
* your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
2009-10-19 12:53:44 -07:00
|
|
|
class Group_Model extends ORM implements Group_Definition {
|
2008-11-14 05:09:07 +00:00
|
|
|
protected $has_and_belongs_to_many = array("users");
|
2008-11-18 00:38:36 +00:00
|
|
|
|
|
|
|
|
var $rules = array(
|
|
|
|
|
"name" => "required|length[4,255]");
|
2008-12-09 08:47:30 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @see ORM::delete()
|
|
|
|
|
*/
|
|
|
|
|
public function delete($id=null) {
|
2009-07-16 11:19:34 -07:00
|
|
|
$old = clone $this;
|
2008-12-09 08:47:30 +00:00
|
|
|
module::event("group_before_delete", $this);
|
|
|
|
|
parent::delete($id);
|
2009-07-16 11:19:34 -07:00
|
|
|
module::event("group_deleted", $old);
|
2008-12-09 08:47:30 +00:00
|
|
|
}
|
2009-07-16 12:29:16 -07:00
|
|
|
|
|
|
|
|
public function save() {
|
2009-11-25 13:22:24 -08:00
|
|
|
if (!$this->loaded()) {
|
2009-07-16 12:29:16 -07:00
|
|
|
$created = 1;
|
|
|
|
|
}
|
|
|
|
|
parent::save();
|
|
|
|
|
if (isset($created)) {
|
|
|
|
|
module::event("group_created", $this);
|
|
|
|
|
} else {
|
2009-08-02 12:09:00 -07:00
|
|
|
module::event("group_updated", $this->original(), $this);
|
2009-07-16 12:29:16 -07:00
|
|
|
}
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
2008-11-05 05:32:47 +00:00
|
|
|
}
|