forked from extern/egroupware
Formatting
This commit is contained in:
parent
637b1c04b5
commit
e7dbba7698
@ -21,203 +21,260 @@
|
|||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/*!
|
/*!
|
||||||
@class applicatons
|
@class applicatons
|
||||||
@abstract functions for managing and installing apps
|
@abstract functions for managing and installing apps
|
||||||
@discussion Author: skeeter
|
@discussion Author: skeeter
|
||||||
*/
|
*/
|
||||||
class applications
|
class applications
|
||||||
{
|
{
|
||||||
var $account_id;
|
var $account_id;
|
||||||
var $data = Array();
|
var $data = Array();
|
||||||
var $db;
|
var $db;
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Standard constructor for setting $this->account_id *
|
* Standard constructor for setting $this->account_id *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
/*!
|
|
||||||
@function applications
|
/*!
|
||||||
@abstract standard constructor for setting $this->account_id
|
@function applications
|
||||||
@param $account_id account id
|
@abstract standard constructor for setting $this->account_id
|
||||||
*/
|
@param $account_id account id
|
||||||
function applications($account_id = '')
|
*/
|
||||||
{
|
function applications($account_id = '')
|
||||||
global $phpgw, $phpgw_info;
|
{
|
||||||
$this->db = $phpgw->db;
|
global $phpgw, $phpgw_info;
|
||||||
$this->account_id = get_account_id($account_id);
|
$this->db = $phpgw->db;
|
||||||
}
|
$this->account_id = get_account_id($account_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************\
|
||||||
|
* These are the standard $this->account_id specific functions *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
/**************************************************************************\
|
|
||||||
* These are the standard $this->account_id specific functions *
|
|
||||||
\**************************************************************************/
|
|
||||||
/*!
|
/*!
|
||||||
@function read_repository
|
@function read_repository
|
||||||
@abstract read from repository
|
@abstract read from repository
|
||||||
@discussion private should only be called from withing this class
|
@discussion private should only be called from withing this class
|
||||||
*/
|
*/
|
||||||
function read_repository()
|
function read_repository()
|
||||||
{
|
{
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
if (gettype($phpgw_info['apps']) != 'array') {
|
if (gettype($phpgw_info['apps']) != 'array')
|
||||||
$this->read_installed_apps();
|
{
|
||||||
}
|
$this->read_installed_apps();
|
||||||
$this->data = Array();
|
}
|
||||||
if($this->account_id == False) { return False; }
|
$this->data = Array();
|
||||||
$apps = $phpgw->acl->get_user_applications($this->account_id);
|
if($this->account_id == False) { return False; }
|
||||||
reset($phpgw_info['apps']);
|
$apps = $phpgw->acl->get_user_applications($this->account_id);
|
||||||
while ($app = each($phpgw_info['apps'])) {
|
reset($phpgw_info['apps']);
|
||||||
// $check = $phpgw->acl->check('run',1,$app[0]);
|
while ($app = each($phpgw_info['apps']))
|
||||||
$check = $apps[$app[0]];
|
{
|
||||||
if ($check) {
|
// $check = $phpgw->acl->check('run',1,$app[0]);
|
||||||
$this->data[$app[0]] = array('title' => $phpgw_info['apps'][$app[0]]['title'], 'name' => $app[0], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[0]]['status']);
|
$check = $apps[$app[0]];
|
||||||
}
|
if ($check)
|
||||||
}
|
{
|
||||||
reset($this->data);
|
$this->data[$app[0]] = array(
|
||||||
return $this->data;
|
'title' => $phpgw_info['apps'][$app[0]]['title'],
|
||||||
}
|
'name' => $app[0],
|
||||||
|
'enabled' => True,
|
||||||
|
'status' => $phpgw_info['apps'][$app[0]]['status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function read()
|
@function read()
|
||||||
@abstract read from the repository
|
@abstract read from the repository
|
||||||
@discussion pubic function that is used to determine what apps a user has rights to
|
@discussion pubic function that is used to determine what apps a user has rights to
|
||||||
*/
|
*/
|
||||||
function read() {
|
function read()
|
||||||
if (count($this->data) == 0){ $this->read_repository(); }
|
{
|
||||||
reset($this->data);
|
if (count($this->data) == 0){ $this->read_repository(); }
|
||||||
return $this->data;
|
reset($this->data);
|
||||||
}
|
return $this->data;
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
@function add
|
@function add
|
||||||
@abstract add an app to a user profile
|
@abstract add an app to a user profile
|
||||||
@discussion
|
@discussion
|
||||||
@param $apps array containing apps to add for a user
|
@param $apps array containing apps to add for a user
|
||||||
*/
|
*/
|
||||||
function add($apps) {
|
function add($apps)
|
||||||
global $phpgw_info;
|
{
|
||||||
if(gettype($apps) == 'array') {
|
global $phpgw_info;
|
||||||
while($app = each($apps)) {
|
if(gettype($apps) == 'array')
|
||||||
$this->data[$app[1]] = array('title' => $phpgw_info['apps'][$app[1]]['title'], 'name' => $app[1], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[1]]['status']);
|
{
|
||||||
}
|
while($app = each($apps))
|
||||||
} elseif(gettype($apps)) {
|
{
|
||||||
$this->data[$apps] = array('title' => $phpgw_info['apps'][$apps]['title'], 'name' => $apps, 'enabled' => True, 'status' => $phpgw_info['apps'][$apps]['status']);
|
$this->data[$app[1]] = array(
|
||||||
}
|
'title' => $phpgw_info['apps'][$app[1]]['title'],
|
||||||
reset($this->data);
|
'name' => $app[1],
|
||||||
return $this->data;
|
'enabled' => True,
|
||||||
}
|
'status' => $phpgw_info['apps'][$app[1]]['status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(gettype($apps))
|
||||||
|
{
|
||||||
|
$this->data[$apps] = array(
|
||||||
|
'title' => $phpgw_info['apps'][$apps]['title'],
|
||||||
|
'name' => $apps,
|
||||||
|
'enabled' => True,
|
||||||
|
'status' => $phpgw_info['apps'][$apps]['status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
@function delete
|
@function delete
|
||||||
@abstract delete an app from a user profile
|
@abstract delete an app from a user profile
|
||||||
@discussion
|
@discussion
|
||||||
@param $appname appname to remove
|
@param $appname appname to remove
|
||||||
*/
|
*/
|
||||||
function delete($appname) {
|
function delete($appname)
|
||||||
if($this->data[$appname]) {
|
{
|
||||||
unset($this->data[$appname]);
|
if($this->data[$appname])
|
||||||
}
|
{
|
||||||
reset($this->data);
|
unset($this->data[$appname]);
|
||||||
return $this->data;
|
}
|
||||||
}
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
@function update_data
|
@function update_data
|
||||||
@abstract update the array(?)
|
@abstract update the array(?)
|
||||||
@discussion
|
@discussion
|
||||||
@param $data update the repository array(?)
|
@param $data update the repository array(?)
|
||||||
*/
|
*/
|
||||||
function update_data($data) {
|
function update_data($data)
|
||||||
reset($data);
|
{
|
||||||
$this->data = Array();
|
reset($data);
|
||||||
$this->data = $data;
|
$this->data = Array();
|
||||||
reset($this->data);
|
$this->data = $data;
|
||||||
return $this->data;
|
reset($this->data);
|
||||||
}
|
return $this->data;
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
@function save_repository()
|
@function save_repository()
|
||||||
@abstract save the repository
|
@abstract save the repository
|
||||||
@discussion
|
@discussion
|
||||||
*/
|
*/
|
||||||
function save_repository(){
|
function save_repository()
|
||||||
global $phpgw;
|
{
|
||||||
$num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id);
|
global $phpgw;
|
||||||
reset($this->data);
|
$num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id);
|
||||||
while($app = each($this->data)) {
|
reset($this->data);
|
||||||
if(!$this->is_system_enabled($app[0])) { continue; }
|
while($app = each($this->data))
|
||||||
$phpgw->acl->add_repository($app[0],'run',$this->account_id,1);
|
{
|
||||||
}
|
if(!$this->is_system_enabled($app[0])) { continue; }
|
||||||
reset($this->data);
|
$phpgw->acl->add_repository($app[0],'run',$this->account_id,1);
|
||||||
return $this->data;
|
}
|
||||||
}
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* These are the non-standard $this->account_id specific functions *
|
* These are the non-standard $this->account_id specific functions *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
function app_perms()
|
function app_perms()
|
||||||
{
|
{
|
||||||
global $phpgw, $phpgw_info;
|
global $phpgw, $phpgw_info;
|
||||||
if (count($this->data) == 0) {
|
if (count($this->data) == 0)
|
||||||
$this->read_repository();
|
{
|
||||||
}
|
$this->read_repository();
|
||||||
@reset($this->data);
|
}
|
||||||
while (list ($key) = each ($this->data)) {
|
@reset($this->data);
|
||||||
$app[] = $this->data[$key]['name'];
|
while (list ($key) = each ($this->data))
|
||||||
}
|
{
|
||||||
return $app;
|
$app[] = $this->data[$key]['name'];
|
||||||
}
|
}
|
||||||
|
return $app;
|
||||||
|
}
|
||||||
|
|
||||||
function read_account_specific() {
|
function read_account_specific()
|
||||||
global $phpgw, $phpgw_info;
|
{
|
||||||
if (gettype($phpgw_info['apps']) != 'array') {
|
global $phpgw, $phpgw_info;
|
||||||
$this->read_installed_apps();
|
if (gettype($phpgw_info['apps']) != 'array')
|
||||||
}
|
{
|
||||||
$app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id);
|
$this->read_installed_apps();
|
||||||
if(!$app_list) {
|
}
|
||||||
reset($this->data);
|
$app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id);
|
||||||
return $this->data;
|
if(!$app_list)
|
||||||
}
|
{
|
||||||
@reset($app_list);
|
reset($this->data);
|
||||||
while ($app = each($app_list)) {
|
return $this->data;
|
||||||
if ($this->is_system_enabled($app[1])) {
|
}
|
||||||
$this->data[$app[1]] = array('title' => $phpgw_info['apps'][$app[1]]['title'], 'name' => $app[1], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[1]]['status']);
|
@reset($app_list);
|
||||||
}
|
while ($app = each($app_list))
|
||||||
}
|
{
|
||||||
reset($this->data);
|
if ($this->is_system_enabled($app[1]))
|
||||||
return $this->data;
|
{
|
||||||
}
|
$this->data[$app[1]] = array(
|
||||||
|
'title' => $phpgw_info['apps'][$app[1]]['title'],
|
||||||
|
'name' => $app[1],
|
||||||
|
'enabled' => True,
|
||||||
|
'status' => $phpgw_info['apps'][$app[1]]['status']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reset($this->data);
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************\
|
||||||
|
* These are the generic functions. Not specific to $this->account_id *
|
||||||
|
\**************************************************************************/
|
||||||
|
|
||||||
/**************************************************************************\
|
|
||||||
* These are the generic functions. Not specific to $this->account_id *
|
|
||||||
\**************************************************************************/
|
|
||||||
/*!
|
/*!
|
||||||
@function read_installed_apps()
|
@function read_installed_apps()
|
||||||
@abstract populate array with a list of installed apps
|
@abstract populate array with a list of installed apps
|
||||||
*/
|
*/
|
||||||
function read_installed_apps(){
|
function read_installed_apps()
|
||||||
global $phpgw_info;
|
{
|
||||||
$this->db->query("select * from phpgw_applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__);
|
global $phpgw_info;
|
||||||
if($this->db->num_rows()) {
|
$this->db->query("select * from phpgw_applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__);
|
||||||
while ($this->db->next_record()) {
|
if($this->db->num_rows())
|
||||||
$name = $this->db->f('app_name');
|
{
|
||||||
$title = $this->db->f('app_title');
|
while ($this->db->next_record())
|
||||||
$status = $this->db->f('app_enabled');
|
{
|
||||||
$phpgw_info['apps'][$name] = array('title' => $title, 'name' => $name, 'enabled' => True, 'status' => $status);
|
$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,
|
||||||
|
'name' => $name,
|
||||||
|
'enabled' => True,
|
||||||
|
'status' => $status
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/*!
|
/*!
|
||||||
@function is_system_enabled
|
@function is_system_enabled
|
||||||
@abstract check if an app is enabled
|
@abstract check if an app is enabled
|
||||||
@param $appname name of the app to check for
|
@param $appname name of the app to check for
|
||||||
*/
|
*/
|
||||||
function is_system_enabled($appname){
|
function is_system_enabled($appname)
|
||||||
global $phpgw_info;
|
{
|
||||||
if(gettype($phpgw_info['apps']) != 'array') {
|
global $phpgw_info;
|
||||||
$this->read_installed_apps();
|
if(gettype($phpgw_info['apps']) != 'array')
|
||||||
}
|
{
|
||||||
if ($phpgw_info['apps'][$appname]['enabled']) {
|
$this->read_installed_apps();
|
||||||
return True;
|
}
|
||||||
}else{
|
if ($phpgw_info['apps'][$appname]['enabled'])
|
||||||
return False;
|
{
|
||||||
}
|
return True;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user