source: trunk/admin/inc/class.uimenuclass.inc.php @ 2

Revision 2, 4.0 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /**************************************************************************\
3  * eGroupWare - Administration                                              *
4  * http://www.egroupware.org                                                *
5  * --------------------------------------------                             *
6  *  This program is free software; you can redistribute it and/or modify it *
7  *  under the terms of the GNU General Public License as published by the   *
8  *  Free Software Foundation; either version 2 of the License, or (at your  *
9  *  option) any later version.                                              *
10  \**************************************************************************/
11 
12
13        class uimenuclass
14        {
15                var $t;
16                var $rowColor = Array();
17               
18                function uimenuclass()
19                {
20                        $this->t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('admin'));
21
22                        $this->t->set_file(array('menurow' => 'menurow.tpl'));
23                        $this->t->set_block('menurow','menu_links','menu_links');
24                        $this->t->set_block('menurow','link_row','link_row');
25
26                        $this->rowColor[0] = $GLOBALS['phpgw_info']['theme']['row_on'];
27                        $this->rowColor[1] = $GLOBALS['phpgw_info']['theme']['row_off'];
28                }
29
30                function section_item($pref_link='',$pref_text='', $bgcolor)
31                {
32                        $this->t->set_var('row_link',$pref_link);
33                        $this->t->set_var('row_text',$pref_text);
34                        $this->t->set_var('tr_color',$bgcolor);
35                        $this->t->parse('all_rows','link_row',True);
36                }
37
38                // $file must be in the following format:
39                // $file = array(
40                //  'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list')
41                // );
42                // This allows extra data to be sent along
43                function display_section($_menuData)
44                {
45                        $i=0;
46
47                        // reset the value of all_rows
48                        $this->t->set_var('all_rows','');
49
50                        while(list($key,$value) = each($_menuData))
51                        {
52                                if (!empty($value['extradata']))
53                                {
54                                        $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . get_var('account_id',array('GET','POST')) . '&' . $value['extradata']);
55                                }
56                                else
57                                {
58                                        $link = $GLOBALS['phpgw']->link($value['url'],'account_id=' . get_var('account_id',array('GET','POST')));
59                                }
60                                $this->section_item($link,lang($value['description']),$this->rowColor[($i % 2)]);
61                                $i++;
62                        }
63
64                        $this->t->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
65
66                        if(strpos($_menuData[0]['extradata'],'user'))
67                        {
68                                $destination = 'users';
69                        }
70                        else
71                        {
72                                $destination = 'groups';
73                        }
74                        $this->t->set_var('link_done',$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_'.$destination));
75                        $this->t->set_var('lang_done',lang('Back'));
76
77                        $this->t->set_var('row_on',$this->rowColor[0]);
78
79                        $this->t->parse('out','menu_links');
80                       
81                        return $this->t->get('out','menu_links');
82                }
83
84                // create the html code for the menu
85                function createHTMLCode($_hookname)
86                {
87                        switch ($_hookname)
88                        {
89                                case 'edit_user':
90                                        $GLOBALS['menuData'][] = array(
91                                                'description' => 'User Data',
92                                                'url'         => '/index.php',
93                                                'extradata'   => 'menuaction=admin.uiaccounts.edit_user'
94                                        );
95                                        break;
96                                case 'view_user':
97                                        $GLOBALS['menuData'][] = array(
98                                                'description' => 'User Data',
99                                                'url'         => '/index.php',
100                                                'extradata'   => 'menuaction=admin.uiaccounts.view_user'
101                                        );
102                                        break;
103                                case 'edit_group':
104                                        $GLOBALS['menuData'][] = array(
105                                                'description' => 'Edit Group',
106                                                'url'         => '/index.php',
107                                                'extradata'   => 'menuaction=admin.uiaccounts.edit_group'
108                                        );
109                                        break;
110                                case 'group_manager':
111                                        $GLOBALS['menuData'][] = array(
112                                                'description' => 'Group Manager',
113                                                'url'         => '/index.php',
114                                                'extradata'   => 'menuaction=admin.uiaccounts.group_manager'
115                                        );
116                                        break;
117                        }
118
119                        $GLOBALS['phpgw']->hooks->process($_hookname);
120                        if (count($GLOBALS['menuData']) >= 1)
121                        {
122                                $result = $this->display_section($GLOBALS['menuData']);
123                                //clear $menuData
124                                $GLOBALS['menuData'] = '';
125                                return $result;
126                        }
127                        else
128                        {
129                                // clear $menuData
130                                $GLOBALS['menuData'] = '';
131                                return '';
132                        }
133                }
134        }
135?>
Note: See TracBrowser for help on using the repository browser.