phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] admin/inc/class.uiapplications.inc.php, 1.10


From: nomail
Subject: [Phpgroupware-cvs] admin/inc/class.uiapplications.inc.php, 1.10
Date: Thu, 30 Dec 2004 08:38:14 +0100

Update of /admin/inc
Modified Files:
        Branch: 
          class.uiapplications.inc.php

date: 2004/12/30 07:38:14;  author: skwashd;  state: Exp;  lines: +113 -68

Log Message:
new HEAD admin - sans GIFs
=====================================================================
Index: admin/inc/class.uiapplications.inc.php
diff -u admin/inc/class.uiapplications.inc.php:1.9 
admin/inc/class.uiapplications.inc.php:1.10
--- admin/inc/class.uiapplications.inc.php:1.9  Sun Apr 27 22:26:04 2003
+++ admin/inc/class.uiapplications.inc.php      Thu Dec 30 07:38:14 2004
@@ -32,15 +32,26 @@
 
                function get_list()
                {
+                       if 
($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
+                       $can_add    = 
!$GLOBALS['phpgw']->acl->check('applications_access',2,'admin');
+                       $can_edit   = 
!$GLOBALS['phpgw']->acl->check('applications_access',4,'admin');
+                       $can_delete = 
!$GLOBALS['phpgw']->acl->check('applications_access',8,'admin');
+                       
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin').' - '.lang('Installed applications');
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
                        
$GLOBALS['phpgw']->template->set_file(array('applications' => 
'applications.tpl'));
                        
$GLOBALS['phpgw']->template->set_block('applications','list','list');
                        
$GLOBALS['phpgw']->template->set_block('applications','row','row');
-
-                       $start = $GLOBALS['HTTP_POST_VARS']['start'];
-                       $sort  = $GLOBALS['HTTP_GET_VARS']['sort'];
-                       $order = $GLOBALS['HTTP_GET_VARS']['order'];
+                       
$GLOBALS['phpgw']->template->set_block('applications','add','add');
+                       
+                       $start = get_var('start',array('POST','GET'));
+                       $sort  = $_GET['sort'];
+                       $order = $_GET['order'];
                        $offset = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
 
                        $apps = $this->bo->get_list();
@@ -91,7 +102,8 @@
                                $i++;
                        }
 
-                       
$GLOBALS['phpgw']->template->set_var('lang_installed',lang('Installed 
applications'));
+                       
$GLOBALS['phpgw']->template->set_var('bg_color',$GLOBALS['phpgw_info']['theme']['bg_color']);
+                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
 
                        
$GLOBALS['phpgw']->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),'&menuaction=admin.uiapplications.get_list'));
                        
$GLOBALS['phpgw']->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start));
@@ -106,29 +118,15 @@
                        
$GLOBALS['phpgw']->template->set_var('lang_note',lang('(To install new 
applications use<br><a href="setup/" target="setup">Setup</a> [Manage 
Applications] !!!)'));
                        
$GLOBALS['phpgw']->template->set_var('lang_add',lang('add'));
 
-                       @reset($applications);
-                       while (list($key,$app) = @each($applications))
+                       foreach($applications as $app)
                        {
                                $tr_color = 
$this->nextmatchs->alternate_row_color($tr_color);
 
-                               if($app['title'])
-                               {
-                                       $name = $app['title'];
-                               }
-                               elseif($app['name'])
-                               {
-                                       $name = $app['name'];
-                               }
-                               else
-                               {
-                                       $name = '&nbsp;';
-                               }
-
                                
$GLOBALS['phpgw']->template->set_var('tr_color',$tr_color);
-                               
$GLOBALS['phpgw']->template->set_var('name',$name);
+                               
$GLOBALS['phpgw']->template->set_var('name',$app['title']);
 
-                               $GLOBALS['phpgw']->template->set_var('edit','<a 
href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.edit&app_name='
 . urlencode($app['name'])) . '"> ' . lang('Edit') . ' </a>');
-                               
$GLOBALS['phpgw']->template->set_var('delete','<a href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.delete&app_name='
 . urlencode($app['name'])) . '"> ' . lang('Delete') . ' </a>');
+                               
$GLOBALS['phpgw']->template->set_var('edit',$can_edit ? '<a href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.edit&app_name='
 . urlencode($app['name'])) . '&start='.$start.'"> ' . lang('Edit') . ' </a>' : 
'&nbsp;');
+                               
$GLOBALS['phpgw']->template->set_var('delete',$can_delete ? '<a href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.delete&app_name='
 . urlencode($app['name'])) . '&start='.$start.'"> ' . lang('Delete') . ' </a>' 
: '&nbsp;');
 
                                if ($app['status'])
                                {
@@ -142,6 +140,14 @@
 
                                
$GLOBALS['phpgw']->template->parse('rows','row',True);
                        }
+                       if ($can_add)
+                       {
+                               
$GLOBALS['phpgw']->template->parse('addbutton','add');
+                       }
+                       else
+                       {
+                               
$GLOBALS['phpgw']->template->set_var('addbutton','');
+                       }
 
                        $GLOBALS['phpgw']->template->pparse('out','list');
                }
@@ -156,18 +162,30 @@
 
                function add()
                {
+                       if 
($GLOBALS['phpgw']->acl->check('applications_access',2,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
+                       $start = get_var('start',array('POST','GET'));
+       
                        
$GLOBALS['phpgw']->template->set_file(array('application' => 
'application_form.tpl'));
                        
$GLOBALS['phpgw']->template->set_block('application','form','form');
                        
$GLOBALS['phpgw']->template->set_block('application','row','row');
+                       
$GLOBALS['phpgw']->template->set_block('form','delete_button');
+                       
$GLOBALS['phpgw']->template->set_var('delete_button','');
 
-                       if ($GLOBALS['HTTP_POST_VARS']['submit'])
+                       if ($_POST['cancel'])
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
+                       }
+
+                       if ($_POST['save'])
                        {
                                $totalerrors = 0;
 
-                               $app_order    = 
$GLOBALS['HTTP_POST_VARS']['app_order'] ? 
$GLOBALS['HTTP_POST_VARS']['app_order'] : 0;
-                               $n_app_name   = 
chop($GLOBALS['HTTP_POST_VARS']['n_app_name']);
-                               $n_app_title  = 
chop($GLOBALS['HTTP_POST_VARS']['n_app_title']);
-                               $n_app_status = 
$GLOBALS['HTTP_POST_VARS']['n_app_status'];
+                               $app_order    = $_POST['app_order'] ? 
$_POST['app_order'] : 0;
+                               $n_app_name   = chop($_POST['n_app_name']);
+                               $n_app_status = $_POST['n_app_status'];
 
                                if ($this->bo->exists($n_app_name))
                                {
@@ -190,9 +208,8 @@
                                                'app_order'    => $app_order
                                        ));
 
-                                       Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.get_list'));
-                                       
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
-                                       exit;
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
+                                       $GLOBALS['phpgw']->common->phpgw_exit();
                                }
                                else
                                {
@@ -204,11 +221,13 @@
                                
$GLOBALS['phpgw']->template->set_var('error','');
                        }
 
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin').' - '.lang('Add new application');
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
-                       
$GLOBALS['phpgw']->template->set_var('lang_header',lang('Add new application'));
+                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
 
-                       $GLOBALS['phpgw']->template->set_var('hidden_vars','');
+                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="start" value="'.$start.'">');
                        
$GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.add'));
 
                        $this->display_row(lang('application name'),'<input 
name="n_app_name" value="' . $n_app_name . '">');
@@ -231,33 +250,48 @@
 
                        $this->display_row(lang('Select which location this app 
should appear on the navbar, lowest (left) to highest (right)'),'<input 
name="app_order" value="' . $app_order . '">');
 
-                       
$GLOBALS['phpgw']->template->set_var('lang_submit_button',lang('add'));
-                       $GLOBALS['phpgw']->template->pparse('out','form');
+                       
$GLOBALS['phpgw']->template->set_var('lang_save_button',lang('Add'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_cancel_button',lang('Cancel'));
+                       
$GLOBALS['phpgw']->template->pparse('phpgw_body','form');
                }
 
                function edit()
                {
-                       $app_name = $GLOBALS['HTTP_GET_VARS']['app_name'];
+                       if 
($GLOBALS['phpgw']->acl->check('applications_access',4,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
+                       $app_name = get_var('app_name',array('POST','GET'));
+                       $start = get_var('start',array('POST','GET'));
 
                        
$GLOBALS['phpgw']->template->set_file(array('application' => 
'application_form.tpl'));
                        
$GLOBALS['phpgw']->template->set_block('application','form','form');
                        
$GLOBALS['phpgw']->template->set_block('application','row','row');
 
-                       if ($GLOBALS['HTTP_POST_VARS']['submit'])
+                       if ($_POST['cancel'])
+                       {
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
+                       }
+                       
+                       if ($_POST['delete'])
+                       {
+                               return $this->delete();
+                       }
+
+                       if ($_POST['save'])
                        {
                                $totalerrors = 0;
 
-                               $old_app_name = 
$GLOBALS['HTTP_POST_VARS']['old_app_name'];
-                               $app_order    = 
$GLOBALS['HTTP_POST_VARS']['app_order'] ? 
$GLOBALS['HTTP_POST_VARS']['app_order'] : 0;
-                               $n_app_name   = 
chop($GLOBALS['HTTP_POST_VARS']['n_app_name']);
-                               $n_app_status = 
$GLOBALS['HTTP_POST_VARS']['n_app_status'];
+                               $app_order    = $_POST['app_order'] ? 
$_POST['app_order'] : 0;
+                               $n_app_name   = chop($_POST['n_app_name']);
+                               $n_app_status = $_POST['n_app_status'];
 
                                if (! $n_app_name)
                                {
                                        $error[$totalerrors++] = lang('You must 
enter an application name.');
                                }
 
-                               if ($old_app_name != $n_app_name)
+                               if ($app_name != $n_app_name)
                                {
                                        if ($this->bo->exists($n_app_name))
                                        {
@@ -271,16 +305,16 @@
                                                'n_app_name'   => $n_app_name,
                                                'n_app_status' => $n_app_status,
                                                'app_order'    => $app_order,
-                                               'old_app_name' => $old_app_name
+                                               'old_app_name' => $app_name
                                        ));
 
-                                       Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.get_list'));
-                                       
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
-                                       exit;
+                                       
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
                                }
                        }
 
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin').' - '.lang('Edit application');
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
                        if ($totalerrors)
                        {
@@ -291,15 +325,17 @@
                                
$GLOBALS['phpgw']->template->set_var('error','');
                                
list($n_app_name,$n_app_title,$n_app_status,$old_app_name,$app_order) = 
$this->bo->read($app_name);
                        }
-
-                       
$GLOBALS['phpgw']->template->set_var('lang_header',lang('Edit application'));
-                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="old_app_name" value="' . $old_app_name . '">');
+                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="start" value="'.$start.'">'.
+                               '<input type="hidden" name="app_name" value="' 
. $app_name . '">');
+                       
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
                        
$GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.edit'));
 
                        $this->display_row(lang('application name'),'<input 
name="n_app_name" value="' . $n_app_name . '">');
 
                        
$GLOBALS['phpgw']->template->set_var('lang_status',lang('Status'));
-                       
$GLOBALS['phpgw']->template->set_var('lang_submit_button',lang('edit'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_save_button',lang('Save'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_cancel_button',lang('Cancel'));
+                       
$GLOBALS['phpgw']->template->set_var('lang_delete_button',lang('Delete'));
 
                        $selected[$n_app_status] = ' selected';
                        $status_html = '<option value="0"' . $selected[0] . '>' 
. lang('Disabled') . '</option>'
@@ -310,38 +346,47 @@
                        $this->display_row(lang("Select which location this app 
should appear on the navbar, lowest (left) to highest (right)"),'<input 
name="app_order" value="' . $app_order . '">');
 
                        
$GLOBALS['phpgw']->template->set_var('select_status',$status_html);
-                       $GLOBALS['phpgw']->template->pparse('out','form');
+                       
$GLOBALS['phpgw']->template->pparse('phpgw_body','form');
                }
 
                function delete()
                {
-                       $app_name = $GLOBALS['HTTP_GET_VARS']['app_name'];
-
-                       if (!$app_name)
+                       if 
($GLOBALS['phpgw']->acl->check('applications_access',8,'admin'))
                        {
-                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.get_list'));
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
                        }
-
-                       $GLOBALS['phpgw']->template->set_file(array('body' => 
'delete_common.tpl'));
-
-                       if ($GLOBALS['HTTP_GET_VARS']['confirm'])
+                       $app_name = get_var('app_name',array('POST','GET'));
+                       $start = get_var('start',array('POST','GET'));
+                       
+                       if (!$app_name || $_POST['no'] || $_POST['yes'])
                        {
-                               $this->bo->delete($app_name);
-                               Header('Location: ' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.get_list'));
-                               $GLOBALS['phpgw_info']['flags']['nodisplay'] = 
True;
-                               exit;
+                               if ($_POST['yes'])
+                               {
+                                       $this->bo->delete($app_name);
+                               }
+                               
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction=admin.uiapplications.get_list&start='.$start);
                        }
 
+                       $GLOBALS['phpgw']->template->set_file(array('body' => 
'delete_common.tpl'));
+
                        $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
-                       
$GLOBALS['phpgw']->template->set_var('messages',lang('Are you sure you want to 
delete this application ?'));
-                       $GLOBALS['phpgw']->template->set_var('no','<a href="' . 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.get_list')
 . '">' . lang('No') . '</a>');
-                       $GLOBALS['phpgw']->template->set_var('yes','<a href="' 
. 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.delete&app_name='
 . urlencode($app_name) . "&confirm=True") . '">' . lang('Yes') . '</a>');
-                       $GLOBALS['phpgw']->template->pparse('out','body');
+                       
$GLOBALS['phpgw']->template->set_var('messages',lang('Are you sure you want to 
delete the application %1 
?',$GLOBALS['phpgw_info']['apps'][$app_name]['title']));
+                       $GLOBALS['phpgw']->template->set_var('no',lang('No'));
+                       $GLOBALS['phpgw']->template->set_var('yes',lang('Yes'));
+                       
$GLOBALS['phpgw']->template->set_var('form_action',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiapplications.delete'));
+                       
$GLOBALS['phpgw']->template->set_var('hidden_vars','<input type="hidden" 
name="start" value="'.$start.'">'.
+                               '<input type="hidden" name="app_name" value="'. 
urlencode($app_name) . '">');
+                       
$GLOBALS['phpgw']->template->pparse('phpgw_body','body');
                }
                
                function register_all_hooks()
                {
+                       if 
($GLOBALS['phpgw']->acl->check('applications_access',16,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
                        if (!is_object($GLOBALS['phpgw']->hooks))
                        {
                                $GLOBALS['phpgw']->hooks = 
CreateObject('phpgwapi.hooks');




reply via email to

[Prev in Thread] Current Thread [Next in Thread]