egroupware/admin/inc/class.soapplications.inc.php

122 lines
3.6 KiB
PHP
Raw Normal View History

2001-09-14 21:45:06 +02:00
<?php
2005-10-14 19:03:16 +02:00
/**************************************************************************\
* eGroupWare - administration *
* http://www.egroupware.org *
* -------------------------------------------- *
* 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. *
\**************************************************************************/
2001-09-14 21:45:06 +02:00
2005-10-14 19:03:16 +02:00
/* $Id$ */
2001-09-14 21:45:06 +02:00
class soapplications
{
var $db;
var $applications_table = 'egw_applications';
var $hooks_table = 'phpgw_hooks';
2001-09-14 21:45:06 +02:00
function soapplications()
{
2005-10-14 19:03:16 +02:00
$this->db = clone($GLOBALS['egw']->db);
2001-09-14 21:45:06 +02:00
}
function read($app_name)
{
$sql = "SELECT * FROM $this->applications_table WHERE app_name='$app_name'";
2001-09-14 21:45:06 +02:00
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$app_info = array(
$this->db->f('app_name'),
2005-10-14 19:03:16 +02:00
$GLOBALS['egw_info']['apps'][$this->db->f('app_name')]['title'],
2001-09-14 21:45:06 +02:00
$this->db->f('app_enabled'),
$this->db->f('app_name'),
$this->db->f('app_order')
);
return $app_info;
}
function get_list()
{
$this->db->query("SELECT * FROM $this->applications_table WHERE app_enabled != 3",__LINE__,__FILE__);
2001-09-14 21:45:06 +02:00
if($this->db->num_rows())
{
while ($this->db->next_record())
{
2003-09-22 12:58:05 +02:00
$app = $this->db->f('app_name');
2005-10-14 19:03:16 +02:00
$title = @$GLOBALS['egw_info']['apps'][$app]['title'];
2003-09-22 12:58:05 +02:00
if (empty($title))
{
$title = lang($app) == $app.'*' ? $app : lang($app);
}
$apps[$app] = array(
'title' => $title,
'name' => $app,
2001-09-14 21:45:06 +02:00
'status' => $this->db->f('app_enabled')
);
}
}
return $apps;
}
2001-09-14 21:53:24 +02:00
function add($data)
{
2001-11-30 02:13:31 +01:00
/* Yes, the sequence should work, but after a mass import in setup (new install)
2005-10-14 19:03:16 +02:00
it does not work on pg
2001-11-30 02:13:31 +01:00
*/
$sql = "SELECT MAX(app_id) from $this->applications_table";
2001-11-30 02:13:31 +01:00
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$app_id = $this->db->f(0) + 1;
$sql = "INSERT INTO $this->applications_table (app_id,app_name,app_enabled,app_order) VALUES("
2002-10-27 00:40:09 +02:00
. $app_id . ",'" . addslashes($data['n_app_name']) . "','"
2001-09-14 21:53:24 +02:00
. $data['n_app_status'] . "','" . $data['app_order'] . "')";
$this->db->query($sql,__LINE__,__FILE__);
return True;
}
2001-09-14 21:45:06 +02:00
function save($data)
{
$sql = "UPDATE $this->applications_table SET "
. "app_enabled='" . $data['n_app_status'] . "',app_order='" . $data['app_order']
. "' WHERE app_name='" . $data['app_name'] . "'";
2001-09-14 21:45:06 +02:00
$this->db->query($sql,__LINE__,__FILE__);
return True;
}
function exists($app_name)
{
$this->db->query("SELECT COUNT(app_name) FROM $this->applications_table WHERE app_name='" . addslashes($app_name) . "'",__LINE__,__FILE__);
2001-09-14 21:45:06 +02:00
$this->db->next_record();
if ($this->db->f(0) != 0)
{
return True;
}
return False;
}
function app_order()
{
$this->db->query("SELECT MAX(app_order)+1 FROM $this->applications_table",__LINE__,__FILE__);
2001-09-14 21:45:06 +02:00
$this->db->next_record();
2002-04-14 16:51:25 +02:00
return $this->db->f(0);
2001-09-14 21:45:06 +02:00
}
function delete($app_name)
{
$this->db->query("DELETE FROM $this->applications_table WHERE app_name='$app_name'",__LINE__,__FILE__);
2001-09-14 21:45:06 +02:00
}
function register_hook($app)
{
$this->db->query("INSERT INTO $this->hooks_table (hook_appname,hook_location,hook_filename) "
. "VALUES ('".$app['app_name']."','".$app['hook']."','hook_".$app['hook'].".inc.php')",__LINE__,__FILE__
);
}
2001-09-14 21:45:06 +02:00
}