True, 'save_sector' => True, 'delete_sector' => True ); var $so; var $functions; var $db_functions; function bosectors() { $this->so = createobject('expressoAdmin1_2.sosectors'); $this->functions = $this->so->functions; $this->db_functions = $this->so->db_functions; $this->group = createobject('expressoAdmin1_2.group'); $this->user = createobject('expressoAdmin1_2.user'); } function create_sector() { // Verifica o acesso do gerente if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'create_sectors')) { $return['status'] = false; $return['msg'] = lang('you do not have access to create sectors') . '.'; return $return; } // Cria array para incluir no LDAP $dn = 'ou=' . $_POST['sector'] . ',' . $_POST['context']; $sector_info = array(); $sector_info['ou'] = $_POST['sector']; $sector_info['objectClass'][0] = 'top'; $sector_info['objectClass'][1] = 'organizationalUnit'; $systemName = $GLOBALS['phpgw_info']['server']['system_name']; if ($systemName != '') $sector_info['phpgwSystem'] = strtolower($systemName); if ($_POST['sector_visible']) { $sector_info['objectClass'][2] = 'phpgwAccount'; $sector_info['phpgwaccountvisible'] = '-1'; } // Chama funcao para escrever no OpenLDAP, case de erro, volta com msg de erro. if (!$this->so->write_ldap($dn, $sector_info)) { $_POST['error_messages'] = lang('Error in OpenLDAP recording.'); ExecMethod('expressoAdmin1_2.uisectors.add_sector'); return false; } //Escreve no log $this->db_functions->write_log("created sector", "$dn"); // Volta para o ListSectors $url = ($GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors')); $GLOBALS['phpgw']->redirect($url); } function save_sector() { $sector_info = $this->so->get_info($_POST['context']); if (($_POST['sector_visible'] == 'on') && ($sector_info['phpgwaccountvisible'] != '-1')) { foreach ($sector_info[0]['objectclass'] as $objectClass) { if ($objectClass == 'phpgwAccount') $phpgwAccount = true; else $phpgwAccount = false; } if (!$phpgwAccount) { $ldap_mod_add['objectClass'][] = 'phpgwAccount'; } $ldap_mod_add['phpgwaccountvisible'] = '-1'; $this->so->add_attribute($sector_info[0]['dn'], $ldap_mod_add); } else { $ldap_mod_del['objectClass'] = 'phpgwAccount'; $ldap_mod_del['phpgwaccountvisible'] = array(); $this->so->remove_attribute($sector_info[0]['dn'], $ldap_mod_del); } // Volta para o ListSectors ExecMethod('expressoAdmin1_2.uisectors.list_sectors'); } function delete_sector() { // Verifica o acesso do gerente if (!$this->functions->check_acl($_SESSION['phpgw_session']['session_lid'], 'delete_sectors')) { $return['status'] = false; $return['msg'] = lang('you do not have access to delete sectors') . '.'; return $return; } $sector_dn = $_POST['dn']; $manager_context = $_POST['manager_context']; $sector_users = $this->so->get_sector_users($sector_dn); for ($i=0; $iuser->delete(Array('uid' => $uid , 'uidnumber' => $account_id)); } $sector_groups = $this->so->get_sector_groups($sector_dn); for ($i=0; $igroup->delete(Array('gidnumber' => $gidnumber, 'cn' => $dn)); } if ( (!empty($GLOBALS['phpgw_info']['server']['ldap_master_host'])) && (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_dn'])) && (!empty($GLOBALS['phpgw_info']['server']['ldap_master_root_pw'])) ) { $connection = $GLOBALS['phpgw']->common->ldapConnect($GLOBALS['phpgw_info']['server']['ldap_master_host'], $GLOBALS['phpgw_info']['server']['ldap_master_root_dn'], $GLOBALS['phpgw_info']['server']['ldap_master_root_pw']); } else { $connection = $GLOBALS['phpgw']->common->ldapConnect(); } $this->so->delete_sector_ldap_recursively($connection, $sector_dn); ldap_close($connection); // Volta para o ListGroups $url = ($GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uisectors.list_sectors')); $GLOBALS['phpgw']->redirect($url); } } ?>