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'; if( isset($_POST['associated_domain']) ) { if ( $_POST['associated_domain'] != "") { $sector_info['objectClass'][2] = 'domainRelatedObject'; $sector_info['associatedDomain'] = trim($_POST['associated_domain']); } } /* Insere as informações sobre quota total por usuários e por gigabytes de espaço em disco Se não vierem os dados, ele coloca 0 (Caso não exista controle de cota). */ if( isset($_POST['disk_quota']) ) { $sector_info['diskQuota'] = (trim($_POST['disk_quota']) != "") ? $_POST['disk_quota'] : "0"; } if( isset($_POST['users_quota']) ) { $sector_info['usersQuota'] = (trim($_POST['users_quota']) != "") ? $_POST['users_quota'] : "0"; } $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[0]['phpgwaccountvisible'][0] != '-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); } elseif($sector_info[0]['phpgwaccountvisible'][0] == '-1') { $ldap_mod_del['objectClass'] = 'phpgwAccount'; $ldap_mod_del['phpgwaccountvisible'] = array(); $this->so->remove_attribute($sector_info[0]['dn'], $ldap_mod_del); } //Modifica o conteúdo das cotas. if( (isset($_POST['disk_quota']) ) && (isset($_POST['users_quota']) ) ) { //se for passado alguma coisa, lógico $ldap_mod_replace = array(); $ldap_mod_replace['diskQuota'] = $_POST['disk_quota']; $ldap_mod_replace['usersQuota'] = $_POST['users_quota']; $this->so->replace_attribute($sector_info[0]['dn'], $ldap_mod_replace); } // 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); } } ?>