<?php
/**
*
* Copyright (C) 2007 IVLOS
*
* This file is part of PDF Annotation Engine.
*
* PDF Annotation Engine 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.
*
* PDF Annotation Engine 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 PDF Annotation Engine. If not, see <http://www.gnu.org/licenses/>.
*
* PDF Annotation Engine was originaly made by Infi, The Netherlands.
*
* If you have any questions or suggestions, mail us at hide@address.com
*
**/
class group extends crud_db {
// regular methods
function check_owner() {
$course = $this->get_course();
return $course->check_owner();
}
function get_users() {
global $db;
$sql = 'SELECT user.* FROM user INNER JOIN user_group ON(user.id = user_group.user_id) WHERE user_group.group_id = ?';
$data = array($this->id);
$result = $db->getAll($sql, $data);
return crud_db::from_result($result, 'user');
}
function delete() {
$documents = $this->get_documents();
foreach($documents as $document) {
$document->delete();
}
return parent::delete(__CLASS__);
}
function get_documents() {
return document::select(array('group_id' => $this->id));
}
function check_create() {
return ($this->create_ok == 'true');
}
function contains($user_id) {
$rows = $this->get_all(array('group_id' => $this->id, 'user_id' => $user_id), 'user_group', false);
return isset($rows[0]['group_id']);
}
function add_user($user_id) {
return $this->auto_insert(array('group_id' => $this->id, 'user_id' => $user_id), 'user_group');
}
function del_user($user_id) {
return $this->auto_delete(array('group_id' => $this->id, 'user_id' => $user_id), 'user_group');
}
function get_course()
{
return course::from_id($this->course_id);
}
// inherited static methods
function from_row($row) {
return parent::from_row($row, __CLASS__);
}
function from_values($values) {
return parent::from_values($values, __CLASS__);
}
function array_from_id($id) {
return parent::array_from_id($id, __CLASS__);
}
function from_id($id) {
return parent::from_id($id, __CLASS__);
}
function select($filter=array()) {
return parent::select($filter, __CLASS__);
}
function assoc_list($field, $filter=array()) {
return parent::assoc_list($field, $filter, __CLASS__);
}
// inherited regular methods
function update() {
return parent::update(__CLASS__);
}
function insert() {
return parent::insert(__CLASS__);
}
}