<?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 document extends crud_db {
// static methods
function from_heading_id($id) {
$heading = heading::from_id($id);
return document::from_id($heading->document_id);
}
// regular methods
function check_owner() {
return ($this->owner_id == user::id());
}
function is_visible() {
return ($this->visible == 'true');
}
function delete() {
$headings = $this->get_headings();
foreach($headings as $heading) {
$heading->delete();
}
shell_exec("rm -rf upload/document-$this->id");
return parent::delete(__CLASS__);
}
function owner() {
return user::from_id($this->owner_id);
}
function get_group() {
return group::from_id($this->group_id);
}
function get_headings() {
return heading::select(array('document_id' => $this->id));
}
function add_heading($array) {
$heading = new heading();
$fields = array('title');
foreach($fields as $field) {
$heading->$field = $array[$field];
}
$heading->document_id = $this->id;
return $heading->insert();
}
// 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__);
}
}