source: companies/serpro/admin/inc/class.uivoip.inc.php @ 903

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

Importacao inicial do Expresso do Serpro

Line 
1<?php
2
3 /**************************************************************************\
4  * Expresso Livre - Voip - administration                                   *
5  *                                                                                                                                      *
6  * --------------------------------------------                             *
7  *  This program is free software; you can redistribute it and/or modify it *
8  *  under the terms of the GNU General Public License as published by the   *
9  *  Free Software Foundation; either version 2 of the License, or (at your  *
10  *  option) any later version.                                              *
11  \**************************************************************************/
12
13class uivoip
14{
15        var $public_functions = array(
16                'add'      => True,
17                'edit_conf' => True,
18        );
19
20        var $bo;
21
22        final function __construct()
23        {
24                if(!isset($_SESSION['admin']['ldap_host']))
25                {
26                        $_SESSION['admin']['server']['ldap_host'] = $GLOBALS['phpgw_info']['server']['ldap_host'];
27                        $_SESSION['admin']['server']['ldap_root_dn'] = $GLOBALS['phpgw_info']['server']['ldap_root_dn'];
28                        $_SESSION['admin']['server']['ldap_root_pw'] = $GLOBALS['phpgw_info']['server']['ldap_root_pw'];
29                        $_SESSION['admin']['server']['ldap_context'] = $GLOBALS['phpgw_info']['server']['ldap_context'];
30                }
31                $this->bo = CreateObject('admin.bovoip');
32        }
33
34        final function edit_conf()
35        {
36                if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
37                {
38                        $GLOBALS['phpgw']->redirect_link('/index.php');
39                }               
40
41                $GLOBALS['phpgw_info']['flags']['app_header'] = lang('Admin') .' - ' . lang('Configuration Service VoIP');
42
43                if(!@is_object($GLOBALS['phpgw']->js))
44                {
45                        $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
46                }
47
48                $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
49                $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
50
51                if(strrpos($webserver_url,'/') === false || strrpos($webserver_url,'/') != (strlen($webserver_url)-1))
52                        $webserver_url .= '/';
53
54                $js = array('connector','xtools','functions');
55               
56                foreach( $js as $tmp )
57                        $GLOBALS['phpgw']->js->validate_file('voip',$tmp,'admin');
58               
59                $GLOBALS['phpgw']->common->phpgw_header();
60                echo parse_navbar();
61                echo '<script type="text/javascript">var path_adm="'.$webserver_url .'"</script>';
62
63                $ous = "<option value='Raiz'>-- ".lang('Select Organization')." --</option>";   
64                if( ($LdapOus = $this->bo->getOuLdap()) )
65                {
66                        foreach($LdapOus as $tmp )
67                                $ous .= "<option value='".$tmp."'>".$tmp."</option>";
68                }
69               
70                $groups_voip = $GLOBALS['phpgw_info']['server']['voip_groups'];
71
72                if( $groups_voip )
73                {
74                        $gvoip = explode(',', $groups_voip);
75                        natcasesort($gvoip);
76                       
77                        foreach( $gvoip as $tmp )
78                                $gvoip .= "<option value='".$tmp."'>".$tmp."</option>";
79                }
80
81                $GLOBALS['phpgw']->template->set_file(array('voip' => 'voip.tpl'));
82                $GLOBALS['phpgw']->template->set_block('voip','voip_page','voip_page');
83                $GLOBALS['phpgw']->template->set_var(array(
84                                                                                'action_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uivoip.add'),
85                                                                                'lang_VoIP_settings' => lang('Configuration Service VoIP'),
86                                                                                'lang_Enter_your_VoIP_server_address' => lang('Enter your VoIP server address'),       
87                                                                                'lang_Enter_your_VoIP_server_url' => lang('Enter your VoIP server url'),       
88                                                                                'lang_Enter_your_VoIP_server_port' => lang('Enter your VoIP server port'),
89                                                                                'lang_save' => lang('Save'),
90                                                                                'lang_cancel' => lang('Cancel'),
91                                                                                'value_voip_server' => ($GLOBALS['phpgw_info']['server']['voip_server']) ? $GLOBALS['phpgw_info']['server']['voip_server'] : '',
92                                                                                'value_voip_url' => ($GLOBALS['phpgw_info']['server']['voip_url']) ? $GLOBALS['phpgw_info']['server']['voip_url'] : '',
93                                                                                'value_voip_port' => ($GLOBALS['phpgw_info']['server']['voip_port']) ? $GLOBALS['phpgw_info']['server']['voip_port'] : '',
94                                                                                'lang_load' => lang('Wait Loading...!'),
95                                                                                'lang_grupos_ldap' => 'Grupos Ldap',
96                                                                                'lang_grupos_liberados' => 'Grupos Liberados',
97                                                                                'lang_groups_ldap' => lang('groups ldap'),
98                                                                                'lang_organizations' => lang('Organizations'),
99                                                                                'groups_voip' => $gvoip,
100                                                                                'ous_ldap' => $ous
101                                                                                ));
102       
103                $GLOBALS['phpgw']->template->pparse('out','voip_page');
104
105        }
106       
107        function display_row($label, $value)
108        {
109                $GLOBALS['phpgw']->template->set_var('tr_color',$this->nextmatchs->alternate_row_color());
110                $GLOBALS['phpgw']->template->set_var('label',$label);
111                $GLOBALS['phpgw']->template->set_var('value',$value);
112                $GLOBALS['phpgw']->template->parse('rows','row',True);
113        }
114
115        function add()
116        {
117               
118                if($GLOBALS['phpgw']->acl->check('applications_access',1,'admin'))
119                {
120                        $GLOBALS['phpgw']->redirect_link('/index.php');
121                }               
122               
123                if ($_POST['cancel'])
124                {
125                        $GLOBALS['phpgw']->redirect_link('/admin/index.php');
126                }
127
128                if ( $_POST['save'] )
129                {
130                        $conf['voip_server']= $_POST['voip_server'];
131                        $conf['voip_url']       = $_POST['voip_url'];
132                        $conf['voip_port']      = $_POST['voip_port'];
133                       
134                        if( is_array($_POST['voip_groups']) )
135                                foreach($_POST['voip_groups'] as $tmp)
136                                        $conf['voip_groups'] = (count($conf['voip_groups']) > 0 ) ? $conf['voip_groups'] . "," . $tmp : $tmp;
137                       
138                        $this->bo->setConfDB($conf);
139                }
140
141                $GLOBALS['phpgw']->redirect_link('/admin/index.php');
142        }
143}
144?>
Note: See TracBrowser for help on using the repository browser.