source: companies/serpro/expressoAdminSerpro/inc/class.institutional_accounts.inc.php @ 903

Revision 903, 5.0 KB checked in by niltonneto, 15 years ago (diff)

Importacao inicial do Expresso do Serpro

Line 
1<?php
2        /***********************************************************************************\
3        * Expresso Administração                                                                                                                        *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)       *
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        define('PHPGW_API_INC','../phpgwapi/inc');
13
14        class institutional_accounts
15        {
16                var $public_functions = array
17                (
18                        'index' => True
19                );
20               
21                var $functions;
22
23                function institutional_accounts()
24                {                       
25                        if (function_exists('CreateObject'))
26                        {
27                                $this->functions = CreateObject('expressoAdminSerpro.functions');
28                               
29                                if(!@is_object($GLOBALS['phpgw']->js))
30                                {
31                                        $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
32                                }
33                                $GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdminSerpro');#diretorio, arquivo.js, aplicacao
34                                $GLOBALS['phpgw']->js->validate_file('jscode','institutional_accounts','expressoAdminSerpro');
35                                $GLOBALS['phpgw']->js->validate_file('modal','modal','expressoAdminSerpro');
36                               
37                                /*
38                                Move this to expressoAdmin.index.
39                                $_SESSION['phpgw_info']['expressoAdmin']['user']['preferences']['common']['lang'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'];
40                               
41                                $fn = './expressoAdminSerpro/setup/phpgw_'.$_SESSION['phpgw_info']['expressoAdmin']['user']['preferences']['common']['lang'].'.lang';
42                                if (file_exists($fn)){
43                                        $fp = fopen($fn,'r');
44                                        while ($data = fgets($fp,16000)){
45                                                list($message_id,$app_name,$null,$content) = explode("\t",substr($data,0,-1));
46                                                $_SESSION['phpgw_info']['expressoAdmin']['lang'][$message_id] =  $content;
47                                        }
48                                        fclose($fp);
49                                }*/
50                        }
51                }
52
53                function make_lang($ram_lang)
54                {
55                        $a_lang = split("_", $ram_lang);
56                        $a_lang_reverse  = array_reverse ( $a_lang, true );
57                        array_pop ( $a_lang_reverse );
58                        $a_lang  = array_reverse ( $a_lang_reverse, true );
59                        $a_new_lang = implode ( " ", $a_lang );
60                        return lang($a_new_lang);
61                }
62
63                function make_dinamic_lang($template_obj, $block)
64                {
65                        $tpl_vars = $template_obj->get_undefined($block);
66                        foreach ($tpl_vars as $atribute)
67                        {
68                                $lang = strstr($atribute, 'lang_');
69                                if($lang !== false)
70                                {
71                                        $template_obj->set_var($atribute, $this->make_lang($atribute));
72                                }
73                        }
74                }
75               
76                function index()
77                {
78                        /* Begin:  Check manager access */
79                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
80                        $acl = $this->functions->read_acl($account_lid);
81                        $contexts = $acl['contexts'];
82                        foreach ($acl['contexts_display'] as $index=>$tmp_context) {
83                                $context_display .= '<br>'.$tmp_context;
84                        }
85                       
86                        if (!$this->functions->check_acl($account_lid,'list_institutional_accounts')) {
87                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdminSerpro/inc/access_denied.php'));
88                        }
89                        /* End: Check manager access */
90
91                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
92                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
93                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdminSerpro']['title'].' - '.lang('Institutional accounts');
94                        $GLOBALS['phpgw']->common->phpgw_header();
95
96                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
97
98                        $p->set_file(
99                                                Array(
100                                                                'institutional_accounts'                => 'institutional_accounts.tpl',
101                                                                'institutional_accounts_modal'  =>'institutional_accounts_modal.tpl'
102                                                        )
103                                                );
104                        $p->set_block('institutional_accounts','body');
105                       
106                        /* dinamic load lang */
107                        $this->make_dinamic_lang($p, 'body');
108                        $this->make_dinamic_lang($p, 'institutional_accounts_modal');
109
110
111                        /* Begin: set modal */
112
113                        $functions = CreateObject('expressoAdminSerpro.functions');
114                       
115                        //$organizations = $functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context']);
116                       
117                        foreach ($contexts as $index=>$context)
118                                $combo_manager_org .= $this->functions->get_organizations($context);
119                        $combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context']);
120                       
121                        $p->set_var('manager_organizations', $combo_manager_org);
122                        $p->set_var('all_organizations', $combo_all_orgs);
123                       
124                        $modal_id = 'institutional_accounts_modal';
125                        $p->set_var('modal_id', $modal_id);
126                        $institutional_accounts_modal_tpl = $p->fp('out','institutional_accounts_modal');
127                        /* End: set modal */
128                       
129                        $var = Array(
130                                'th_bg'                                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
131                                'back_url'                                      => $GLOBALS['phpgw']->link('/expressoAdminSerpro/index.php'),
132                                'context_display'                       => $context_display,
133                                'institutional_accounts_modal' => $institutional_accounts_modal_tpl,
134                                'onclick_create_institutional_account' => "modal(\"$modal_id\",\"create\")"
135                        );
136                        $p->set_var($var);
137                        $p->pfp('out','body');
138                }
139
140        }
141?>
Note: See TracBrowser for help on using the repository browser.