Formatting

This commit is contained in:
Miles Lott 2001-05-02 12:40:33 +00:00
parent 637b1c04b5
commit e7dbba7698

View File

@ -35,6 +35,7 @@
/**************************************************************************\ /**************************************************************************\
* Standard constructor for setting $this->account_id * * Standard constructor for setting $this->account_id *
\**************************************************************************/ \**************************************************************************/
/*! /*!
@function applications @function applications
@abstract standard constructor for setting $this->account_id @abstract standard constructor for setting $this->account_id
@ -50,6 +51,7 @@
/**************************************************************************\ /**************************************************************************\
* 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
@ -58,18 +60,26 @@
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(); $this->data = Array();
if($this->account_id == False) { return False; } if($this->account_id == False) { return False; }
$apps = $phpgw->acl->get_user_applications($this->account_id); $apps = $phpgw->acl->get_user_applications($this->account_id);
reset($phpgw_info['apps']); reset($phpgw_info['apps']);
while ($app = each($phpgw_info['apps'])) { while ($app = each($phpgw_info['apps']))
{
// $check = $phpgw->acl->check('run',1,$app[0]); // $check = $phpgw->acl->check('run',1,$app[0]);
$check = $apps[$app[0]]; $check = $apps[$app[0]];
if ($check) { if ($check)
$this->data[$app[0]] = array('title' => $phpgw_info['apps'][$app[0]]['title'], 'name' => $app[0], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[0]]['status']); {
$this->data[$app[0]] = array(
'title' => $phpgw_info['apps'][$app[0]]['title'],
'name' => $app[0],
'enabled' => True,
'status' => $phpgw_info['apps'][$app[0]]['status']
);
} }
} }
reset($this->data); reset($this->data);
@ -81,7 +91,8 @@
@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(); } if (count($this->data) == 0){ $this->read_repository(); }
reset($this->data); reset($this->data);
return $this->data; return $this->data;
@ -92,14 +103,29 @@
@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; global $phpgw_info;
if(gettype($apps) == 'array') { if(gettype($apps) == 'array')
while($app = each($apps)) { {
$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))
{
$this->data[$app[1]] = array(
'title' => $phpgw_info['apps'][$app[1]]['title'],
'name' => $app[1],
'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']); 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); reset($this->data);
return $this->data; return $this->data;
@ -110,8 +136,10 @@
@discussion @discussion
@param $appname appname to remove @param $appname appname to remove
*/ */
function delete($appname) { function delete($appname)
if($this->data[$appname]) { {
if($this->data[$appname])
{
unset($this->data[$appname]); unset($this->data[$appname]);
} }
reset($this->data); reset($this->data);
@ -123,7 +151,8 @@
@discussion @discussion
@param $data update the repository array(?) @param $data update the repository array(?)
*/ */
function update_data($data) { function update_data($data)
{
reset($data); reset($data);
$this->data = Array(); $this->data = Array();
$this->data = $data; $this->data = $data;
@ -135,11 +164,13 @@
@abstract save the repository @abstract save the repository
@discussion @discussion
*/ */
function save_repository(){ function save_repository()
{
global $phpgw; global $phpgw;
$num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id); $num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id);
reset($this->data); reset($this->data);
while($app = each($this->data)) { while($app = each($this->data))
{
if(!$this->is_system_enabled($app[0])) { continue; } if(!$this->is_system_enabled($app[0])) { continue; }
$phpgw->acl->add_repository($app[0],'run',$this->account_id,1); $phpgw->acl->add_repository($app[0],'run',$this->account_id,1);
} }
@ -154,30 +185,42 @@
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); @reset($this->data);
while (list ($key) = each ($this->data)) { while (list ($key) = each ($this->data))
{
$app[] = $this->data[$key]['name']; $app[] = $this->data[$key]['name'];
} }
return $app; return $app;
} }
function read_account_specific() { function read_account_specific()
{
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();
} }
$app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id); $app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id);
if(!$app_list) { if(!$app_list)
{
reset($this->data); reset($this->data);
return $this->data; return $this->data;
} }
@reset($app_list); @reset($app_list);
while ($app = each($app_list)) { while ($app = each($app_list))
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']); 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($this->data); reset($this->data);
@ -187,19 +230,28 @@
/**************************************************************************\ /**************************************************************************\
* 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; global $phpgw_info;
$this->db->query("select * from phpgw_applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__); $this->db->query("select * from phpgw_applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__);
if($this->db->num_rows()) { if($this->db->num_rows())
while ($this->db->next_record()) { {
while ($this->db->next_record())
{
$name = $this->db->f('app_name'); $name = $this->db->f('app_name');
$title = $this->db->f('app_title'); $title = $this->db->f('app_title');
$status = $this->db->f('app_enabled'); $status = $this->db->f('app_enabled');
$phpgw_info['apps'][$name] = array('title' => $title, 'name' => $name, 'enabled' => True, 'status' => $status); $phpgw_info['apps'][$name] = array(
'title' => $title,
'name' => $name,
'enabled' => True,
'status' => $status
);
} }
} }
} }
@ -208,14 +260,19 @@
@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; global $phpgw_info;
if(gettype($phpgw_info['apps']) != 'array') { if(gettype($phpgw_info['apps']) != 'array')
{
$this->read_installed_apps(); $this->read_installed_apps();
} }
if ($phpgw_info['apps'][$appname]['enabled']) { if ($phpgw_info['apps'][$appname]['enabled'])
{
return True; return True;
}else{ }
else
{
return False; return False;
} }
} }