fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [8290] initial add of document classes


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [8290] initial add of document classes
Date: Wed, 14 Dec 2011 13:48:50 +0000

Revision: 8290
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8290
Author:   erikhl
Date:     2011-12-14 13:48:50 +0000 (Wed, 14 Dec 2011)
Log Message:
-----------
initial add of document classes

Added Paths:
-----------
    trunk/controller/inc/class.sodocument.inc.php
    trunk/controller/inc/class.uidocument.inc.php
    trunk/controller/inc/model/class.document.inc.php

Added: trunk/controller/inc/class.sodocument.inc.php
===================================================================
--- trunk/controller/inc/class.sodocument.inc.php                               
(rev 0)
+++ trunk/controller/inc/class.sodocument.inc.php       2011-12-14 13:48:50 UTC 
(rev 8290)
@@ -0,0 +1,358 @@
+<?php
+       /**
+       * phpGroupWare - controller: a part of a Facilities Management System.
+       *
+       * @author Erik Holm-Larsen <address@hidden>
+       * @author Torstein Vadla <address@hidden>
+       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare 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 phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+       * @package property
+       * @subpackage controller
+       * @version 
+       */
+
+phpgw::import_class('controller.socommon');
+
+class controller_sodocument extends controller_socommon
+{
+       public static $ROOT_FOR_DOCUMENTS = 'controller';
+       public static $PROCEDURE_DOCUMENTS = 'procedures';
+       
+       protected static $so;
+       protected $document_types; // Used for caching the values
+       
+       /**
+        * Get a static reference to the storage object associated with this 
model object
+        * 
+        * @return the storage object
+        */
+       public static function get_instance()
+       {
+               if (self::$so == null) {
+                       self::$so = CreateObject('controller.sodocument');
+               }
+               return self::$so;
+       }
+       
+       public function get_id_field_name($extended_info = false)
+       {
+               if(!$extended_info)
+               {
+                       $ret = 'document_id';
+               }
+               else
+               {
+                       $ret = array
+                       (
+                               'table'                 => 
'controller_document', // alias
+                               'field'                 => 'id',
+                               'translated'    => 'document_id'
+                       );
+               }
+               return $ret;
+       }
+       
+       protected function get_query(string $sort_field, boolean $ascending, 
string $search_for, string $search_type, array $filters, boolean $return_count)
+       {
+               
+               $clauses = array('1=1');
+               
+               $filter_clauses = array();
+               
+               // Search for based on search type
+               if($search_for)
+               {
+                       $search_for = $this->marshal($search_for,'field');
+                       $like_pattern = "'%".$search_for."%'";
+                       $like_clauses = array();
+                       switch($search_type){
+                               case "title":
+                                       $like_clauses[] = 
"controller_document.title $this->like $like_pattern";
+                                       break;
+                               case "name":
+                                       $like_clauses[] = 
"controller_document.name $this->like $like_pattern";
+                                       break;
+                               case "all":
+                                       $like_clauses[] = 
"controller_document.title $this->like $like_pattern";
+                                       $like_clauses[] = 
"controller_document.name $this->like $like_pattern";
+                                       break;
+                       }
+                       
+                       if(count($like_clauses))
+                       {
+                               $clauses[] = '(' . join(' OR ', $like_clauses) 
. ')';
+                       }
+               }
+               
+               if(isset($filters[$this->get_id_field_name()]))
+               {
+                       $filter_clauses[] = "controller_document.id = 
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
+               }
+               
+               if(isset($filters['procedure_id']))
+               {
+                       $filter_clauses[] = "controller_document.procedure_id = 
{$this->marshal($filters['procedure_id'],'int')}";
+               }
+/*             
+               if(isset($filters['party_id']))
+               {
+                       $filter_clauses[] = "controller_document.party_id = 
{$this->marshal($filters['party_id'],'int')}";
+               }
+*/             
+               if(isset($filters['document_type']) && 
$filters['document_type'] != 'all')
+               {
+                       $filter_clauses[] = "controller_document.type_id = 
{$this->marshal($filters['document_type'],'int')}";
+               }
+               
+               if(count($filter_clauses))
+               {
+                       $clauses[] = join(' AND ', $filter_clauses);
+               }
+               
+               
+               $condition =  join(' AND ', $clauses);
+
+               $tables = "controller_document";
+               $joins = " {$this->left_join} controller_document_types ON 
(controller_document.type_id = controller_document_types.id)";
+               
+               if($return_count)
+               {
+                       $cols = 'COUNT(DISTINCT(controller_document.id)) AS 
count';
+               }
+               else
+               {
+                       $cols = 'controller_document.id as document_id, 
controller_document.title as document_title, description, name, contract_id, 
party_id, controller_document_types.title as type_title';
+               }
+               
+               $dir = $ascending ? 'ASC' : 'DESC';
+               if($sort_field == 'title')
+               {
+                       $sort_field = 'controller_document.title';
+               }
+               else if($sort_field == 'type')
+               {
+                       $sort_field = 'controller_document_types.title';
+               }
+               $order = $sort_field ? "ORDER BY {$this->marshal($sort_field, 
'field')} $dir ": '';
+               
+               //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}");
+               return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
+       }       
+
+       function populate(int $document_id, &$document)
+       {
+               if($document == null)
+               {
+                       $document = new controller_document($document_id);
+                       
$document->set_title($this->unmarshal($this->db->f('document_title',true),'string'));
+                       
$document->set_description($this->unmarshal($this->db->f('description',true),'string'));
+                       
$document->set_name($this->unmarshal($this->db->f('name',true),'string'));
+                       
$document->set_type($this->unmarshal($this->db->f('type_title',true),'string'));
+                       
$document->set_contract_id($this->unmarshal($this->db->f('contract_id',true),'int'));
+               }
+               return $document;
+       }
+       
+       public function add(&$document)
+       {
+               $cols = array(
+                       'title',
+                       'description',
+                       'name',
+                       'procedure_id',
+                       'type_id'
+               );
+               
+               $procedure_id = 
$this->marshal($document->get_procedure_id(),'int');
+               $contract_id = $contract_id > 0 ? $contract_id : 'NULL';
+               
+               
+               $values = array(
+                       $this->marshal($document->get_title(),'string'),
+                       $this->marshal($document->get_description(),'string'),
+                       $this->marshal($document->get_name(),'string'),
+                       $procedure_id,
+                       $this->marshal($document->get_type_id(),'int')
+               );
+               
+               $query = "INSERT INTO controller_document (".join(',', 
$cols).") VALUES (".join(',',$values).")";
+               $result = $this->db->query($query);
+               
+               $document_id = 
$this->db->get_last_insert_id('controller_document','id');
+               $document->set_id($document_id);
+               return $document;
+       }
+       
+       public function update($document)
+       {
+               $id = intval($document->get_id());
+
+               $name_value_pairs = array (
+                       "title = 
{$this->marshal($document->get_title(),'string')}",
+                       "description = 
{$this->marshal($document->get_description(),'string')}",
+                       "name = 
{$this->marshal($document->get_name(),'string')}",
+                       "procedure_id = 
{$this->marshal($document->get_procedure_id(),'int')}",
+                       "type_id = 
{$this->marshal($document->get_type_id(),'int')}"
+               );
+               
+               $query = "UPDATE controller_document SET 
".join(',',$name_value_pairs)." WHERE id = {$id}";
+               $result = $this->db->query($query);
+               return $result != null;
+       }
+       
+       public function get_document_types()
+       {
+               if($this->document_types == null)
+               {
+                       $sql = "SELECT id, title FROM 
controller_document_types";
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       $results = array();
+                       while($this->db->next_record()){
+                               $location_id = $this->db->f('id', true);
+                               $results[$location_id] = $this->db->f('title', 
true);
+                       }
+                       $this->document_types = $results;
+               }
+               return $this->document_types;
+               
+       }
+       
+       private function get_document_path(string $document_type, $id)
+       {
+               $root_directory = self::$ROOT_FOR_DOCUMENTS;
+               $type_directory;
+               if($document_type == self::$PROCEDURE_DOCUMENTS)
+               {
+                       $type_directory = self::$PROCEDURE_DOCUMENTS;
+               }
+               else
+               {
+                       return false;
+               }
+               
+               $vfs = CreateObject('phpgwapi.vfs');
+               $vfs->override_acl = 1;
+               
+               $path = "/{$root_directory}";
+               $dir = array('string' => $path, RELATIVE_NONE);
+               if(!$vfs->file_exists($dir)){
+                       if(!$vfs->mkdir($dir))
+                       {
+                               return false;
+                       }
+               }
+               
+               $path .= "/{$type_directory}";
+               $dir = array('string' => $path, RELATIVE_NONE);
+               if(!$vfs->file_exists($dir)){
+                       if(!$vfs->mkdir($dir))
+                       {
+                               return false;
+                       }
+               }
+               
+               $path .= "/{$id}";
+               $dir = array('string' => $path, RELATIVE_NONE);
+               if(!$vfs->file_exists($dir)){
+                       if(!$vfs->mkdir($dir))
+                       {
+                               return false;
+                       }
+               }       
+               
+               return "/{$root_directory}/{$type_directory}/{$id}";
+       }
+       
+       public function write_document_to_vfs(string $document_type, 
$temporary_name, $id, $name)
+       {
+       
+               $path = $this->get_document_path($document_type,$id);
+               
+               if(!$path)
+               {
+                       return false;
+               }
+               
+               $vfs = CreateObject('phpgwapi.vfs');
+               $vfs->override_acl = 1;
+               $path .= "/{$name}";
+               $file = array('string' => $path, RELATIVE_NONE);
+               
+               return $vfs->write
+               (
+                       array
+                       (
+                               'string' => $path,
+                               RELATIVE_NONE,
+                               'content' => file_get_contents($temporary_name)
+                       )
+               );
+       } 
+       
+       public function read_document_from_vfs(string $document_type, $id, 
$name)
+       {
+               $path = $this->get_document_path($document_type,$id);
+
+               $path .= "/{$name}";
+               
+               $vfs = CreateObject('phpgwapi.vfs');
+               $vfs->override_acl = 1;
+               
+               return $vfs->read
+               (
+                       array
+                       (
+                               'string' => $path,
+                               RELATIVE_NONE
+                       )
+               );
+       }
+       
+       public function delete_document_from_vfs(string $document_type, $id, 
$name)
+       {
+               $path = $this->get_document_path($document_type,$id);
+
+               $path .= "/{$name}";
+               
+               $vfs = CreateObject('phpgwapi.vfs');
+               $vfs->override_acl = 1;
+               
+               return $vfs->rm
+               (
+                       array
+                       (
+                               'string' => $path,
+                               RELATIVE_NONE
+                       )
+               );
+       }
+       
+       public function delete_document($id)
+       {
+               $sql = "DELETE FROM controller_document WHERE id = {$id}";
+               
+               $result = $this->db->query($sql, __LINE__, __FILE__);
+               if($result)
+               {
+                       return true;
+               }
+               return false;           
+       }
+}

Added: trunk/controller/inc/class.uidocument.inc.php
===================================================================
--- trunk/controller/inc/class.uidocument.inc.php                               
(rev 0)
+++ trunk/controller/inc/class.uidocument.inc.php       2011-12-14 13:48:50 UTC 
(rev 8290)
@@ -0,0 +1,358 @@
+<?php
+       /**
+       * phpGroupWare - controller: a part of a Facilities Management System.
+       *
+       * @author Erink Holm-Larsen <address@hidden>
+       * @author Torstein Vadla <address@hidden>
+       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare 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 phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+       * @package property
+       * @subpackage controller
+       * @version 
+       */      
+
+       phpgw::import_class('controller.uicommon');
+       phpgw::import_class('controller.sodocument');
+       phpgw::import_class('controller.soprocedure');
+       include_class('controller', 'document', 'inc/model/');
+
+       class controller_uidocument extends controller_uicommon
+       {       
+               private $so;
+               private $so_procedure;
+               
+               public $public_functions = array
+               (
+                               'query'         => true,
+                               'add'           => true,
+                               'view'          => true,
+                               'delete'        => true
+                       );
+               
+               public function __construct()
+               {
+                       parent::__construct();
+                       $this->so = controller_sodocument::get_instance();
+                       $this->so_procedure = 
controller_soprocedure::get_instance();
+               }
+               
+               public function query()
+               {
+                       // YUI variables for paging and sorting
+                       $start_index    = phpgw::get_var('startIndex', 'int');
+                       $num_of_objects = phpgw::get_var('results', 'int', 
'GET', 10);
+                       $sort_field             = phpgw::get_var('sort');
+                       $sort_ascending = phpgw::get_var('dir') == 'desc' ? 
false : true;
+                       // Form variables
+                       $search_for     = phpgw::get_var('query');
+                       $search_type    = phpgw::get_var('search_option');
+                       // Create an empty result set
+                       $result_objects = array();
+                       $result_count = 0;
+                       
+                       //Retrieve a contract identifier and load corresponding 
contract
+                       $procedure_id = phpgw::get_var('procedure_id');
+                       if(isset($procedure_id))
+                       {
+                               $procedure = 
$this->so_procedure->get_single($procedure_id);
+                       }
+                       
+                       $type = phpgw::get_var('type');
+                       switch($type)
+                       {
+                               case 'documents_for_procedure':
+                                       $filters = array('procedure_id' => 
$procedure_id, 'document_type' => phpgw::get_var('document_type'));
+                                       break;
+                       }
+
+                       $result_objects = $this->so->get($start_index, 
$num_of_objects, $sort_field, $sort_ascending, $search_for, $search_type, 
$filters);
+                       $result_count = $this->so->get_count($search_for, 
$search_type, $filters);
+                       
+                       //Serialize the documents found
+                       $rows = array();
+                       foreach ($result_objects as $result) {
+                               if(isset($result))
+                               {
+                                       $rows[] = $result->serialize();
+                               }
+                       }
+                       
+                       $editable = phpgw::get_var('editable') == '1' ? true : 
false;
+                       
+                       //Add context menu columns (actions and labels)
+                       array_walk($rows, array($this, 'add_actions'), 
array($type, isset($procedure) ? $procedure->has_permission(PHPGW_ACL_EDIT) : 
false, $this->type_of_user, $editable));
+                               
+                       
+                       //Build a YUI result from the data
+                       $result_data = array('results' => $rows, 
'total_records' => $result_count);     
+                       return $this->yui_results($result_data, 
'total_records', 'results');
+               }
+               
+               /**
+                * Add data for context menu
+                *
+                * @param $value pointer to
+                * @param $key ?
+                * @param $params [type of query, editable]
+                */
+               public function add_actions(&$value, $key, $params)
+               {
+                       
+                       $value['ajax'] = array();
+                       $value['actions'] = array();
+                       $value['labels'] = array();
+
+                       //view/download
+                       $value['ajax'][] = false;
+                       $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uidocument.view', 'id' => $value['id'])));
+                       $value['labels'][] = lang('view');
+                       
+                       $type = $params[0];
+                       $edit_permission = $params[1];
+                       $user_is = $params[2];
+                       $editable = $params[3];
+                       
+                       switch($type)
+                       {
+                               case 'documents_for_procedure':
+                                       if($edit_permission && $editable) {
+                                               $value['ajax'][] = true;
+                                               $value['actions'][] = 
html_entity_decode(self::link(array('menuaction' => 
'controller.uidocument.delete', 'id' => $value['id'])));
+                                               $value['labels'][] = 
lang('delete');
+                                       }
+                                       break;
+                       }
+               }
+               
+               /**
+                * Public function to add a document.
+                * 
+                * @param HTTP::procedure_id    the procedure id
+                * @return unknown_type
+                */
+               public function add()
+               {       
+                       // Get target ids
+                       $procedure_id = intval(phpgw::get_var('procedure_id'));
+                       
+                       $data = array();
+                       // Check permissions if contract id is set
+                       if(isset($procedure_id) && $procedure_id > 0)
+                       {
+                               //Load contract
+                               $procedure = 
$this->so_procedure->get_single($procedure_id);
+                               if(!$procedure->has_permission(PHPGW_ACL_EDIT))
+                               {
+                                       $data['error'] = 
lang('permission_denied_add_document');
+                                       $this->render('permission_denied.php', 
$data);
+                                       return;
+                               }
+                       }
+                       
+                       // If no contract or party is loaded
+                       if(!isset($contract))
+                       {
+                               $data['error'] = lang('error_no_procedure');
+                               $this->render('permission_denied.php', $data);
+                               return;
+                       }
+                       
+                       
+                       if($_SERVER['REQUEST_METHOD'] == 'POST')
+                       {
+                               //Create a document object
+                               $document = new controller_document();
+                               
$document->set_title(phpgw::get_var('document_title'));
+                               
$document->set_name($_FILES["file_path"]["name"]);
+                               
$document->set_type_id(phpgw::get_var('document_type'));
+                               $document->set_contract_id($procedure_id);
+                               
+                               //Retrieve the document properties
+                               $document_properties = 
$this->get_type_and_id($document);
+                               
+                               // Move file from temporary storage to vfs
+                               $result = $this->so->write_document_to_vfs
+                               (
+                                       $document_properties['document_type'], 
+                                       $_FILES["file_path"]["tmp_name"],
+                                       $document_properties['id'],
+                                       $_FILES["file_path"]["name"]
+                               );
+                               
+                               if($result)
+                               {
+                                       if($this->so->store($document))
+                                       {
+                                               if(isset($procedure))
+                                               {
+                                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'rental.uiprocedure.edit', 'id' => $procedure->get_id(), 'tab' => 'documents'));
+                                               }
+                                       }
+                                       else
+                                       {
+                                               // Handle failure on storing 
document
+                                               $this->redirect($document, 
$document_propeties,'','');
+                                       }
+                               }
+                               else
+                               {
+                                       //Handle vfs failure to store document
+                                       $this->redirect($document, 
$document_propeties,'','');
+                               }
+                       }
+               }
+               
+               /**
+                * Public function for viewing/downloading a document.
+                * 
+                * @param HTTP::id      the document id
+                * @return document on success, error message on failure
+                */
+               public function view()
+               {
+                       $document_id = intval(phpgw::get_var('id'));
+                       $document = $this->so->get_single($document_id);
+                       if($document->has_permission(PHPGW_ACL_READ))
+                       {
+                               $document_properties = 
$this->get_type_and_id($document);
+                               
+                               header("Content-Disposition: attachment; 
filename={$document->get_name()}");
+                               header("Content-Type: $file_type");
+                               header("Cache-Control: must-revalidate, 
post-check=0, pre-check=0");
+                               
+                               echo 
rental_sodocument::get_instance()->read_document_from_vfs
+                               (
+                                       $document_properties['document_type'],  
+                                       $document_properties['id'],
+                                       $document->get_name()
+                               );
+                       }
+                       else
+                       {
+                               $this->redirect($document, 
$document_properties, lang('no_access'), '');
+                       }
+                       exit;
+               }
+               
+               /**
+                * Public function for deleting a document. Deletes the 
document from
+                * the database and the virtual file system (vfs).
+                * 
+                * @param HTTP::id      the document id
+                * @return true if successful, false if error, permission 
denied message on
+                *                      not enough privileges
+                */
+               public function delete()
+               {       
+                       $document_id = intval(phpgw::get_var('id'));
+                       $document = $this->so->get_single($document_id);
+                       $document_properties = 
$this->get_type_and_id($document);
+
+                       
if(!$this->check_permissions($document,$document_properties))
+                       {
+                               $this->render('permission_denied.php');
+                               return;
+                       }
+                       
+                       $result = 
rental_sodocument::get_instance()->delete_document_from_vfs
+                       (
+                               $document_properties['document_type'],  
+                               $document_properties['id'],
+                               $document->get_name()
+                       );
+                       
+                       if($result)
+                       {
+                               return $this->so->delete_document($document_id);
+                       } 
+                       // TODO: communicate error/message to user
+                       return false;
+               }
+               
+               /**
+                * Utitity function for redirecting to correct edit mode 
(procedure)
+                * 
+                * @param $document     the target document
+                * @param $document_properties  the document properies 
(name/value array)
+                * @param $error        an error message
+                * @param $message      a user message
+                */
+               public function redirect($document, $document_properties, 
$error, $message)
+               {
+                       if($document_properties['document_type'] == 
controller_sodocument::$PROCEDURE_DOCUMENTS)
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uiprocedure.edit', 'id' => 
$document_properties['id'], 'error' => $error, 'message' => $message));         
    
+                       }
+               }
+               
+               /**
+                * Utiity method for checking the users permission on this 
document. If the
+                * document is bound to a procedure, then the user must have 
edit privileges
+                * on the given procedure. If no procedure, the user must be an 
executive 
+                * officer or an administrator.
+                * 
+                * @param $document     the document in question
+                * @param $document_properties  the document type and object id
+                * @return true if correct privileges, false otherwise
+                */
+               private function check_permissions($document, 
$document_properties)
+               {
+                       if($document_properties == 
controller_sodocument::$PROCEDURE_DOCUMENTS)
+                       {
+                               $procedure = 
$this->so_procedure->get_single($document_properties['id']);
+                               if(!$procedure->has_permission(PHPGW_ACL_EDIT))
+                               {
+                                       return false;
+                               }
+                       } 
+                       else
+                       {
+                               if(!($this->isExecutiveOfficer() || 
$this->isAdministrator()))
+                               {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+               
+               /**
+                * Utility method for finding out whether a document is bound 
to a
+                * procedure.
+                * 
+                * @param $document     the given document
+                * @return name/value array ('document_type','id')
+                */
+               private function get_type_and_id($document)
+               {
+                       $document_type;
+                       $id;
+                       $procedure_id = $document->get_procedure_id();
+                       if(isset($procedure_id) && $procedure_id > 0)
+                       {
+                               $document_type = 
controller_sodocument::$PROCEDURE_DOCUMENTS;
+                               $id = $procedure_id;
+                       }
+                       return array
+                       (
+                               'document_type' => $document_type,
+                               'id' => $id
+                       );
+               }
+       }
\ No newline at end of file

Added: trunk/controller/inc/model/class.document.inc.php
===================================================================
--- trunk/controller/inc/model/class.document.inc.php                           
(rev 0)
+++ trunk/controller/inc/model/class.document.inc.php   2011-12-14 13:48:50 UTC 
(rev 8290)
@@ -0,0 +1,101 @@
+<?php
+       /**
+       * phpGroupWare - controller: a part of a Facilities Management System.
+       *
+       * @author Erik Holm-Larsen <address@hidden>
+       * @author Torstein Vadla <address@hidden>
+       * @copyright Copyright (C) 2011,2012 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * This file is part of phpGroupWare.
+       *
+       * phpGroupWare 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.
+       *
+       * phpGroupWare 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 phpGroupWare; if not, write to the Free Software
+       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
+       *
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/
+       * @package property
+       * @subpackage controller
+       * @version 
+       */
+
+include_class('controller', 'model', 'inc/model/');
+
+class controller_document extends controller_model
+{
+       protected $title;
+       protected $description;
+       protected $name;
+       protected $type;
+       protected $type_id;
+       protected $procedure_id;
+       
+       public function __construct(int $id = null)
+       {
+               $doc_id = intval($id);
+               parent::__construct($doc_id);
+       }
+       
+       public function set_title($title)
+       {
+               $this->title = $title;
+       }
+
+       public function get_title(){ return $this->title; }
+       
+       public function set_description($description)
+       {
+               $this->description = $description;
+       }
+
+       public function get_description(){ return $this->description; }
+       
+       public function set_name($name)
+       {
+               $this->name = $name;
+       }
+
+       public function get_name(){ return $this->name; }
+       
+       public function set_type($type)
+       {
+               $this->type = $type;
+       }
+
+       public function get_type(){ return $this->type; }
+       
+       public function set_type_id($type_id)
+       {
+               $this->type_id = $type_id;
+       }
+
+       public function get_type_id(){ return $this->type_id; }
+       
+       public function set_procedure_id($procedure_id)
+       {
+               $this->procedure_id = $procedure_id;
+       }
+
+       public function get_procedure_id(){ return $this->procedure_id; }
+       
+       public function serialize()
+       {
+               return array(
+                       'id' => $this->get_id(),
+                       'title' => $this->get_title(),
+                       'description' => $this->get_description(),
+                       'name' => $this->get_name(),
+                       'type' => lang($this->get_type())
+               );
+       }
+}
+?>
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]