2001-01-19 05:10:45 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare API - Applications manager functions *
|
|
|
|
* This file written by Mark Peters <skeeter@phpgroupware.org> *
|
|
|
|
* Copyright (C) 2001 Mark Peters *
|
|
|
|
* -------------------------------------------------------------------------*
|
|
|
|
* This library is part of the phpGroupWare API *
|
|
|
|
* http://www.phpgroupware.org/api *
|
|
|
|
* ------------------------------------------------------------------------ *
|
|
|
|
* This library is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2.1 of the License, *
|
|
|
|
* or any later version. *
|
|
|
|
* This library 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 Lesser General Public License for more details. *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License *
|
|
|
|
* along with this library; if not, write to the Free Software Foundation, *
|
|
|
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class applications
|
|
|
|
{
|
|
|
|
var $account_id;
|
2001-01-28 13:07:20 +01:00
|
|
|
var $account_type;
|
|
|
|
var $account_apps = Array();
|
|
|
|
var $db;
|
2001-01-19 05:10:45 +01:00
|
|
|
|
2001-01-29 03:17:08 +01:00
|
|
|
function applications($params)
|
2001-01-27 17:32:09 +01:00
|
|
|
{
|
2001-01-26 12:58:00 +01:00
|
|
|
global $phpgw, $phpgw_info;
|
2001-01-28 13:07:20 +01:00
|
|
|
$this->db = $phpgw->db;
|
2001-01-29 03:17:08 +01:00
|
|
|
if (is_array($params)) {
|
|
|
|
if (isset($app_params[1])){
|
|
|
|
$this->account_type = $app_params[1];
|
|
|
|
}else{
|
|
|
|
$this->account_type = "u";
|
|
|
|
}
|
|
|
|
if ($params[0] == ""){
|
|
|
|
$this->account_id = $phpgw_info["user"]["account_id"];
|
|
|
|
}elseif (is_long($params[0])) {
|
|
|
|
$this->account_id = $params[0];
|
|
|
|
} elseif(is_string($params[0])) {
|
|
|
|
if ($this->account_type = "u"){
|
|
|
|
$this->account_id = $phpgw->accounts->username2userid($params[0]);
|
|
|
|
}else{
|
|
|
|
$this->account_id = $phpgw->accounts->groupname2groupid($params[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
2001-01-28 13:07:20 +01:00
|
|
|
$this->account_id = $phpgw_info["user"]["account_id"];
|
2001-01-29 03:17:08 +01:00
|
|
|
$this->account_type = "u";
|
2001-01-21 22:34:36 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
//echo "Account ID (Initializing applications) = ".$this->account_id."<br>\n";
|
2001-01-26 12:58:00 +01:00
|
|
|
}
|
2001-01-21 22:34:36 +01:00
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function enabled_apps()
|
|
|
|
{
|
2001-01-26 12:58:00 +01:00
|
|
|
global $phpgw, $phpgw_info;
|
2001-01-28 13:07:20 +01:00
|
|
|
if (gettype($phpgw_info["apps"]) != "array") {
|
|
|
|
$this->read_installed_apps();
|
2001-01-26 12:58:00 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
while (list($app) = each($phpgw_info["apps"])) {
|
|
|
|
if ($this->account_type == "g") {
|
|
|
|
$check = $phpgw->acl->check_specific("run",1,$app, $this->account_id, "g");
|
|
|
|
}else{
|
|
|
|
$check = $phpgw->acl->check("run",1,$app, $this->account_id);
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
if ($check) {
|
|
|
|
$this->account_apps[$app] = array("title" => $phpgw_info["apps"][$app]["title"], "name" => $app, "enabled" => True, "status" => $phpgw_info["apps"][$app]["status"]);
|
|
|
|
}
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
2001-01-28 13:24:38 +01:00
|
|
|
return $this->account_apps;
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function app_perms()
|
|
|
|
{
|
2001-01-26 12:58:00 +01:00
|
|
|
global $phpgw, $phpgw_info;
|
2001-01-28 13:07:20 +01:00
|
|
|
if (count($this->account_apps) == 0) {
|
|
|
|
$this->enabled_apps();
|
2001-01-26 12:58:00 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
while (list ($key) = each ($this->account_apps)) {
|
|
|
|
$app[] = $this->account_apps[$key]["name"];
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
return $app;
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function read_account_specific() {
|
|
|
|
global $phpgw, $phpgw_info;
|
|
|
|
if (gettype($phpgw_info["apps"]) != "array") {
|
2001-01-26 12:58:00 +01:00
|
|
|
$this->read_installed_apps();
|
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
while (list($app) = each($phpgw_info["apps"])) {
|
|
|
|
if ($phpgw->acl->check_specific("run",1,$app, $this->account_id, $this->account_type)) {
|
|
|
|
$this->account_apps[$app] = array("title" => $phpgw_info["apps"][$app]["title"], "name" => $app, "enabled" => True, "status" => $phpgw_info["apps"][$app]["status"]);
|
|
|
|
}
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
2001-01-29 03:17:08 +01:00
|
|
|
return $this->account_apps;
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function add_app($apps) {
|
2001-01-26 12:58:00 +01:00
|
|
|
if(gettype($appname) == "array") {
|
2001-01-21 02:26:23 +01:00
|
|
|
while($app = each($appname)) {
|
2001-01-28 13:07:20 +01:00
|
|
|
$this->account_apps[] = $app[0];
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
2001-01-26 12:58:00 +01:00
|
|
|
} elseif(gettype($appname) == "string") {
|
2001-01-28 13:07:20 +01:00
|
|
|
$this->account_apps[] = $appname;
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
reset($this->account_apps);
|
|
|
|
return $this->account_apps;
|
2001-01-21 02:26:23 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function delete_app($appname) {
|
|
|
|
unset($this->account_apps[$appname]);
|
|
|
|
reset($this->account_apps);
|
|
|
|
return $this->account_apps;
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_apps(){
|
2001-01-26 12:58:00 +01:00
|
|
|
global $phpgw, $phpgw_info;
|
2001-01-28 13:07:20 +01:00
|
|
|
$phpgw->acl->delete("%", "run", $this->account_id, $this->account_type);
|
|
|
|
reset($this->account_apps[$group_id]);
|
|
|
|
while($app = each($this->account_apps)) {
|
|
|
|
$phpgw->acl->add($app["name"],'run',$this->account_id,$this->account_type,1);
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
reset($this->account_apps);
|
|
|
|
return $this->account_apps;
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function read_installed_apps(){
|
2001-01-26 12:58:00 +01:00
|
|
|
global $phpgw, $phpgw_info;
|
2001-01-28 13:07:20 +01:00
|
|
|
$this->db->query("select * from applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__);
|
|
|
|
if($this->db->num_rows()) {
|
|
|
|
while ($this->db->next_record()) {
|
|
|
|
$name = $this->db->f("app_name");
|
|
|
|
$title = $this->db->f("app_title");
|
|
|
|
$status = $this->db->f("app_enabled");
|
|
|
|
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
|
2001-01-21 22:34:36 +01:00
|
|
|
}
|
2001-01-19 14:16:30 +01:00
|
|
|
}
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
|
2001-01-28 13:07:20 +01:00
|
|
|
function is_system_enabled($appname){
|
|
|
|
if(gettype($phpgw_info["apps"]) != "array") {
|
|
|
|
$this->read_installed_apps();
|
|
|
|
}
|
|
|
|
if ($phpgw_info["apps"][$appname]["enabled"] == True) {
|
|
|
|
return True;
|
|
|
|
}else{
|
|
|
|
return False;
|
2001-01-19 05:10:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-01-28 13:07:20 +01:00
|
|
|
?>
|