True,
'add_groups' => True,
'edit_groups' => True,
'css' => True
);
var $nextmatchs;
var $group;
var $functions;
function uigroups()
{
$this->group = CreateObject('expressoAdmin1_2.group');
$this->nextmatchs = createobject('phpgwapi.nextmatchs');
$this->functions = CreateObject('expressoAdmin1_2.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'];
$acl = $this->functions->read_acl($account_lid);
$context = $acl[0]['context'];
$context_display = $acl[0]['context_display'];
// 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' => $context,
'context_display' => $context_display,
'lang_groups_names' => lang('Groups Names'),
'lang_description' => lang('Description'),
'lang_add_groups' => lang('Add Groups'),
'lang_edit' => lang('Edit'),
'lang_delete' => lang('Delete'),
'lang_back' => lang('back'),
'lang_context' => lang('context'),
'lang_search' => lang('search')
);
$p->set_var($var);
// Save query
$p->set_var('query', $GLOBALS['query']);
//Admin make a search
if ($GLOBALS['query'] != '')
{
$groups_info = $this->functions->get_list('groups', $GLOBALS['query'], $context);
}
$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',"Excluir");
}
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);');
$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
$acl = $this->functions->read_acl($account_lid);
$manager_context = $acl[0]['context'];
// Verifica se tem acesso a este modulo
if (!$this->functions->check_acl($account_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'));
// 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'])));
$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($account_lid, $manager_context, '');
// Seta variaveis utilizadas pelo tpl.
$var = Array(
'color_bg1' => "#E8F0F0",
'color_bg2' => "#D3DCE3",
'type' => 'create_group',
'cn' => '',
'restrictionsOnGroup' => $this->current_config['expressoAdmin_restrictionsOnGroup'],
'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'],
'lang_back' => lang('Back'),
'lang_save' => lang('save'),
'lang_org' => lang('Organizations'),
'lang_group_name' => lang('group name'),
'lang_group_users' => lang('Group users'),
'lang_applications' => lang('Applications'),
'lang_add_user' => lang('Add User'),
'lang_rem_user' => lang('Remove User'),
'lang_all_users' => lang('Select users from all sub-organizations'),
'apps' => $apps,
'use_attrs_samba_checked' => $this->current_config['expressoAdmin_samba_support'] == 'true' ? '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
);
$p->set_var($var);
$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);');
$account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
$acl = $this->functions->read_acl($account_lid);
$manager_context = $acl[0]['context'];
// Verifica se tem acesso a este modulo
if (!$this->functions->check_acl($account_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'], $manager_context);
//_debug_array($group_info);
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'));
// Pega combo das organizações e seleciona a org do grupo.
$combo_manager_org = $this->functions->get_organizations($manager_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.
if (count($group_info['memberuid_info']) > 0)
{
foreach ($group_info['memberuid_info'] as $user)
{
$array_users[$user['uidnumber']] = $user['cn'];
$array_users_uid[$user['uidnumber']] = $user['uid'];
}
natcasesort($array_users);
foreach ($array_users as $uidnumber=>$cn)
{
$ea_select_usersInGroup .= "";
}
}
// Chama funcao para criar lista de aplicativos disponiveis.
$apps = $this->functions->make_list_app($account_lid, $manager_context, $group_info['apps']);
// Seta variaveis utilizadas pelo tpl.
$var = Array(
'color_bg1' => "#E8F0F0",
'color_bg2' => "#D3DCE3",
'type' => 'edit_group',
'ldap_context' => $GLOBALS['phpgw_info']['server']['ldap_context'],
'lang_back' => lang('Back'),
'lang_save' => lang('save'),
'lang_org' => lang('Organizations'),
'lang_group_name' => lang('group name'),
'lang_group_users' => lang('Group users'),
'lang_applications' => lang('Applications'),
'lang_add_user' => lang('Add User'),
'lang_rem_user' => lang('Remove User'),
'lang_all_users' => lang('Select users from all sub-organizations'),
'gidnumber' => $group_info['gidnumber'],
'manager_context' => $manager_context,
'cn' => $group_info['cn'],
'description' => $group_info['description'],
'apps' => $apps,
'use_attrs_samba_checked' => $group_info['sambaGroup'] ? '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->pfp('out','create_group');
}
function row_action($action,$type,$gidnumber,$group_name)
{
return ' '.lang($action).' ';
}
function css()
{
$appCSS = '';
/* 'th.activetab
{
color:#000000;
background-color:#D3DCE3;
border-top-width : 1px;
border-top-style : solid;
border-top-color : Black;
border-left-width : 1px;
border-left-style : solid;
border-left-color : Black;
border-right-width : 1px;
border-right-style : solid;
border-right-color : Black;
}
th.inactivetab
{
color:#000000;
background-color:#E8F0F0;
border-bottom-width : 1px;
border-bottom-style : solid;
border-bottom-color : Black;
}
.td_left { border-left : 1px solid Gray; border-top : 1px solid Gray; }
.td_right { border-right : 1px solid Gray; border-top : 1px solid Gray; }
div.activetab{ display:inline; }
div.inactivetab{ display:none; }';*/
return $appCSS;
}
}
?>