2005-02-03 17:42:20 +01:00
|
|
|
|
<?php
|
|
|
|
|
/**************************************************************************\
|
|
|
|
|
* eGroupWare - resources - Resource Management System *
|
|
|
|
|
* http://www.egroupware.org *
|
2005-03-02 09:50:39 +01:00
|
|
|
|
* Written by Cornelius Weiss <egw@von-und-zu-weiss.de> *
|
|
|
|
|
* and Lukas Weiss <wnz_gh05t@users.sourceforge.net> *
|
2005-02-03 17:42:20 +01: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. *
|
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
2005-02-17 12:23:00 +01:00
|
|
|
|
/* $Id: */
|
2005-06-11 14:59:11 +02:00
|
|
|
|
include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
2005-02-17 12:23:00 +01:00
|
|
|
|
|
2005-06-11 14:59:11 +02:00
|
|
|
|
class so_resources extends so_sql
|
2005-02-03 17:42:20 +01:00
|
|
|
|
{
|
|
|
|
|
function so_resources()
|
|
|
|
|
{
|
2005-06-11 14:59:11 +02:00
|
|
|
|
$this->so_sql('resources','egw_resources');
|
2005-06-10 22:40:57 +02:00
|
|
|
|
$this->db = clone($GLOBALS['egw']->db);
|
|
|
|
|
$this->db->set_app('resources');
|
2005-02-03 17:42:20 +01:00
|
|
|
|
$this->rs_table = 'egw_resources';
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* gets the value of $key from resource of $id
|
|
|
|
|
*
|
|
|
|
|
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
|
|
|
|
* @param string $key key of value to get
|
|
|
|
|
* @param int $id resource id
|
|
|
|
|
* @return mixed value of key and resource, false if key or id not found.
|
|
|
|
|
*/
|
2005-02-03 17:42:20 +01:00
|
|
|
|
function get_value($key,$id)
|
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
|
if($this->db->select($this->rs_table,$key,array('id' => $id),__LINE__,__FILE__))
|
2005-02-03 17:42:20 +01:00
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
|
$value = $this->db->row(row);
|
2005-02-03 17:42:20 +01:00
|
|
|
|
return $value[$key];
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-02-17 16:27:43 +01:00
|
|
|
|
|
|
|
|
|
function delete($id)
|
2005-06-10 22:40:57 +02:00
|
|
|
|
{
|
|
|
|
|
$this->db->delete($this->rs_table,$id,__LINE__,__FILE__);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* reads a resource exept binary datas
|
|
|
|
|
*
|
|
|
|
|
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
|
|
|
|
* @param int $id resource id
|
|
|
|
|
* @return array with key => value or false if not found
|
|
|
|
|
*/
|
2005-02-03 17:42:20 +01:00
|
|
|
|
function read($id)
|
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
|
if($this->db->select($this->rs_table,'*',array('id' => $id),__LINE__,__FILE__))
|
2005-02-03 17:42:20 +01:00
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
|
return $this->db->row(true);
|
2005-02-03 17:42:20 +01:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2005-02-12 16:49:38 +01:00
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
|
/**
|
|
|
|
|
* saves a resource including binary datas
|
|
|
|
|
*
|
|
|
|
|
* Cornelius Wei<EFBFBD> <egw@von-und-zu-weiss.de>
|
|
|
|
|
* @param array $resource key => value
|
|
|
|
|
* @return mixed id of resource if all right, false if fale
|
|
|
|
|
*/
|
2005-02-12 16:49:38 +01:00
|
|
|
|
function save($resource)
|
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
|
return $this->db->insert($this->rs_table,$resource,array('id' => $resource['id']),__LINE__,__FILE__) ? $this->db->get_last_insert_id($this->rs_table, 'id') : false;
|
2005-02-12 16:49:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-03 17:42:20 +01:00
|
|
|
|
}
|