True,
'add_groups' => True,
'edit_groups' => True,
'css' => True
);
var $nextmatchs;
var $group;
var $functions;
var $ldap_functions;
var $db_functions;
function uigroups()
{
$this->group = CreateObject('expressoAdmin1_2.group');
$this->nextmatchs = createobject('phpgwapi.nextmatchs');
$this->functions = CreateObject('expressoAdmin1_2.functions');
$this->ldap_functions = CreateObject('expressoAdmin1_2.ldap_functions');
$this->db_functions = CreateObject('expressoAdmin1_2.db_functions');
$c = CreateObject('phpgwapi.config','expressoAdmin1_2');
$c->read_repository();
$this->current_config = $c->config_data;
if(!@is_object($GLOBALS['phpgw']->js))
{
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
}
$GLOBALS['phpgw']->js->validate_file('jscode','connector','expressoAdmin1_2');#diretorio, arquivo.js, aplicacao
$GLOBALS['phpgw']->js->validate_file('jscode','expressoadmin','expressoAdmin1_2');
$GLOBALS['phpgw']->js->validate_file('jscode','groups','expressoAdmin1_2');
}
function list_groups()
{
$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
$manager_acl = $this->functions->read_acl($account_lid);
$raw_context = $acl['raw_context'];
$contexts = $manager_acl['contexts'];
foreach ($manager_acl['contexts_display'] as $index=>$tmp_context)
{
$context_display .= '
'.$tmp_context;
}
// Verifica se tem acesso a este modulo
if (!$this->functions->check_acl($account_lid,'list_groups'))
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
}
if(isset($_POST['query']))
{
// limit query to limit characters
if(eregi('^[a-z_0-9_-].+$',$_POST['query']))
$GLOBALS['query'] = $_POST['query'];
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('User groups');
$GLOBALS['phpgw']->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(array('groups' => 'groups.tpl'));
$p->set_block('groups','list','list');
$p->set_block('groups','row','row');
$p->set_block('groups','row_empty','row_empty');
// Seta as variaveis padroes.
$var = Array(
'th_bg' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'back_url' => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
'add_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.add_groups'),
'add_group_disabled' => $this->functions->check_acl($account_lid,'add_groups') ? '' : 'disabled',
'context_display' => $context_display
);
$p->set_var($var);
$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
// Save query
$p->set_var('query', $GLOBALS['query']);
//Admin make a search
if ($GLOBALS['query'] != '')
{
$groups_info = $this->functions->get_list('groups', $GLOBALS['query'], $contexts);
}
$total = count($groups_info);
if (!count($total) && $GLOBALS['query'] != '')
{
$p->set_var('message',lang('No matches found'));
}
else if ($total)
{
if ($this->functions->check_acl($account_lid,'edit_groups'))
{
$can_edit = True;
}
if ($this->functions->check_acl($account_lid,'delete_groups'))
{
$can_delete = True;
}
foreach($groups_info as $group)
{
$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
$var = Array(
'tr_color' => $tr_color,
'row_cn' => $group['cn'],
'row_description' => $group['description']
);
$p->set_var($var);
if ($can_edit)
{
$p->set_var('edit_link',$this->row_action('edit','groups',$group['gidnumber'],$group['cn']));
}
else
{
$p->set_var('edit_link',' ');
}
if ($can_delete)
{
$p->set_var('delete_link',"".lang('to delete')."");
}
else
{
$p->set_var('delete_link',' ');
}
$p->fp('rows','row',True);
}
}
$p->parse('rows','row_empty',True);
$p->set_var($var);
if (! $GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
{
$p->set_var('input_add','');
}
if (! $GLOBALS['phpgw']->acl->check('group_access',2,'admin'))
{
$p->set_var('input_search',lang('Search') . ' ');
}
$p->pfp('out','list');
}
function add_groups()
{
$GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
if ($this->current_config['expressoAdmin_samba_support'] == 'true')
$GLOBALS['phpgw']->js->set_onload('get_available_sambadomains(document.forms[0].context.value, \'create_group\');');
$manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
$manager_acl = $this->functions->read_acl($manager_lid);
$manager_contexts = $manager_acl['contexts'];
// Verifica se tem acesso a este modulo
if (!$this->functions->check_acl($manager_lid,'add_groups'))
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
}
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Create Group');
$GLOBALS['phpgw']->common->phpgw_header();
// Set o template
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(Array('create_group' => 'groups_form.tpl'));
$p->set_block('create_group','list','list');
// Pega combo das organizações e seleciona um dos setores em caso de um erro na validaçao dos dados.
//$combo_manager_org = $this->functions->get_organizations($manager_context, trim(strtolower($group_info['context'])));
foreach ($manager_contexts as $index=>$context)
$combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($group_info['context'])));
$combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
// Chama funcao para criar lista de aplicativos disponiveis.
$apps = $this->functions->make_list_app($manager_lid);
// Cria combo de dominio samba
if ($this->current_config['expressoAdmin_samba_support'] == 'true')
{
$a_sambadomains = $this->db_functions->get_sambadomains_list();
$sambadomainname_options = '';
if (count($a_sambadomains))
{
foreach ($a_sambadomains as $a_sambadomain)
{
// So mostra os sambaDomainName do contexto do manager
if ($this->ldap_functions->exist_sambadomains($manager_contexts, $a_sambadomain['samba_domain_name']))
$sambadomainname_options .= "";
}
}
}
// Seta variaveis utilizadas pelo tpl.
$var = Array(
'color_bg1' => "#E8F0F0",
'color_bg2' => "#D3DCE3",
'type' => 'create_group',
'cn' => '',
'restrictionsOnGroup' => $this->current_config['expressoAdmin_restrictionsOnGroup'],
'type' => 'create_group',
'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'],
'ufn_ldap_context' => ldap_dn2ufn($GLOBALS['phpgw_info']['server']['ldap_context']),
'concatenateDomain' => $this->current_config['expressoAdmin_concatenateDomain'],
'defaultDomain' => $this->current_config['expressoAdmin_defaultDomain'],
'apps' => $apps,
'use_attrs_samba_checked' => '',
'disabled_samba' => 'disabled',
'display_samba_options' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '' : '"display:none"',
'disable_email_groups' => $this->functions->check_acl($manager_lid,'edit_email_groups') ? '' : 'disabled',
'sambadomainname_options' => $sambadomainname_options,
'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'),
'combo_manager_org' => $combo_manager_org,
'combo_all_orgs' => $combo_all_orgs
);
$p->set_var($var);
$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
$p->pfp('out','create_group');
}
function edit_groups()
{
$GLOBALS['phpgw']->js->set_onload('get_available_users(document.forms[0].org_context.value, document.forms[0].ea_check_allUsers.checked);');
$manager_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
$manager_acl = $this->functions->read_acl($manager_lid);
$manager_contexts = $manager_acl['contexts'];
// Verifica se tem acesso a este modulo
if (!$this->functions->check_acl($manager_lid,'edit_groups'))
{
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
}
// GET all infomations about the group.
$group_info = $this->group->get_info($_GET['gidnumber']);
unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
$GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Edit Group');
$GLOBALS['phpgw']->common->phpgw_header();
// Set o template
$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$p->set_file(Array('create_group' => 'groups_form.tpl'));
$p->set_block('create_group','list','list');
// Obtem combo das organizações e seleciona a org do grupo.
foreach ($manager_contexts as $index=>$context)
$combo_manager_org .= $this->functions->get_organizations($context, trim(strtolower($group_info['context'])));
$combo_all_orgs = $this->functions->get_organizations($GLOBALS['phpgw_info']['server']['ldap_context'], trim(strtolower($group_info['context'])));
// Usuarios do grupo.
$user_count = 0;
if (count($group_info['memberuid_info']) > 0)
{
foreach ($group_info['memberuid_info'] as $uid=>$user_data)
{
if ($user_data['uidnumber'])
{
$array_users[$user_data['uidnumber']] = $user_data['cn'];
$array_users_uid[$user_data['uidnumber']] = $uid;
$array_users_type[$user_data['uidnumber']] = $user_data['type'];
}
else
{
$array_users[$uid] = $user_data['cn'];
}
}
natcasesort($array_users);
foreach ($array_users as $uidnumber=>$cn)
{
$user_count++;
if ($array_users_type[$uidnumber] == 'u')
{
$users .= "";
}
else
{
$unknow .= "";
}
}
$opt_tmp_users = ''."\n";
$opt_tmp_unknow = ''."\n";
$ea_select_usersInGroup = $unknow != '' ? $opt_tmp_unknow . $unknow . $opt_tmp_users . $users : $opt_tmp_users . $users;
}
// Chama funcao para criar lista de aplicativos disponiveis.
$apps = $this->functions->make_list_app($manager_lid, $group_info['apps']);
// Cria combo de dominios do samba
if ($this->current_config['expressoAdmin_samba_support'] == 'true')
{
$a_sambadomains = $this->db_functions->get_sambadomains_list();
$sambadomainname_options = '';
if (count($a_sambadomains))
{
foreach ($a_sambadomains as $a_sambadomain)
{
if ($a_sambadomain['samba_domain_sid'] == $group_info['sambasid'])
$sambadomainname_options .= "";
else
$sambadomainname_options .= "";
}
}
}
// Seta variaveis utilizadas pelo tpl.
$var = Array(
'color_bg1' => "#E8F0F0",
'color_bg2' => "#D3DCE3",
'type' => 'edit_group',
'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'],
'gidnumber' => $group_info['gidnumber'],
'cn' => $group_info['cn'],
'user_count' => $user_count,
'email' => $group_info['email'],
'description' => $group_info['description'],
'apps' => $apps,
'use_attrs_samba_checked' => $group_info['sambaGroup'] ? 'CHECKED' : '',
'disabled_samba' => $group_info['sambaGroup'] ? '' : 'disabled',
'disable_email_groups' => $this->functions->check_acl($manager_lid,'edit_email_groups') ? '' : 'disabled',
'sambadomainname_options' => $sambadomainname_options,
'phpgwaccountvisible_checked' => $group_info['phpgwaccountvisible'] == '-1' ? 'CHECKED' : '',
'back_url' => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uigroups.list_groups'),
'combo_manager_org' => $combo_manager_org,
'combo_all_orgs' => $combo_all_orgs,
'ea_select_usersInGroup' => $ea_select_usersInGroup
);
$p->set_var($var);
$p->set_var($this->functions->make_dinamic_lang($p, 'list'));
$p->pfp('out','create_group');
}
function row_action($action,$type,$gidnumber,$group_name)
{
return ' '.lang($action).' ';
}
function css()
{
$appCSS = '';
return $appCSS;
}
}
?>