Init Form/Page Controller in DefaultController
This commit is contained in:
parent
cce4394581
commit
d860c69d27
|
@ -5,7 +5,5 @@ spl_autoload_register(function ($class) {
|
|||
});
|
||||
|
||||
DefaultController::init();
|
||||
FormController::init();
|
||||
PageController::init();
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class DefaultController {
|
||||
protected static $logged=false, $config=array(), $alerts=array(),$server;
|
||||
protected static $config=array(), $alerts=array(),$server;
|
||||
public static function init() {
|
||||
self::$config = parse_ini_file('../config/config.ini', true);
|
||||
|
||||
|
@ -13,12 +13,12 @@ class DefaultController {
|
|||
|
||||
// Get content from LDAP
|
||||
if (!empty($_SESSION['login'])) {
|
||||
self::$logged = true;
|
||||
try {
|
||||
self::$server = new LdapServer($_SESSION['login'], self::$config['ldap']);
|
||||
} catch (Exception $e) {
|
||||
self::$alerts[] = array('type' => 2, 'message' => $e->getMessage());
|
||||
}
|
||||
FormController::init();
|
||||
} else {
|
||||
if (!empty($_POST['login'])) {
|
||||
try {
|
||||
|
@ -28,12 +28,12 @@ class DefaultController {
|
|||
));
|
||||
self::$server = new LdapServer($input['login'], self::$config['ldap']);
|
||||
self::$server->login($input['password']);
|
||||
self::$logged = true;
|
||||
$_SESSION['login'] = self::$server->getLogin();
|
||||
} catch (Exception $e) {
|
||||
self::$alerts[] = array('type' => 2, 'message' => $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
PageController::init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,61 +3,59 @@
|
|||
class FormController extends DefaultController {
|
||||
private static $form=array(), $domain, $account, $alias;
|
||||
public static function init() {
|
||||
if (self::$logged) {
|
||||
self::filterPost();
|
||||
// Get content from LDAP
|
||||
try {
|
||||
if (!empty(self::$form['domain'])) {
|
||||
self::$domain = new LdapDomain(self::$server, self::$form['domain']);
|
||||
if (!empty(self::$form['account'])) {
|
||||
self::$account = new LdapAccount(self::$domain, self::$form['account']);
|
||||
}
|
||||
if (!empty(self::$form['alias'])) {
|
||||
self::$alias = new LdapAlias(self::$domain, self::$form['alias']);
|
||||
}
|
||||
self::filterPost();
|
||||
// Get content from LDAP
|
||||
try {
|
||||
if (!empty(self::$form['domain'])) {
|
||||
self::$domain = new LdapDomain(self::$server, self::$form['domain']);
|
||||
if (!empty(self::$form['account'])) {
|
||||
self::$account = new LdapAccount(self::$domain, self::$form['account']);
|
||||
}
|
||||
if (!empty(self::$form['alias'])) {
|
||||
self::$alias = new LdapAlias(self::$domain, self::$form['alias']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
self::$alerts[] = array('type' => 2, 'message' => $e->getMessage());
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
self::$alerts[] = array('type' => 2, 'message' => $e->getMessage());
|
||||
}
|
||||
|
||||
if (!empty(self::$form['delete'])) {
|
||||
switch(self::$form['delete']) {
|
||||
case 'domain':
|
||||
FormController::delDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::delAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::delAlias();
|
||||
break;
|
||||
}
|
||||
} else if (!empty(self::$form['add'])) {
|
||||
switch(self::$form['add']) {
|
||||
case 'domain':
|
||||
FormController::addDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::addAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::addAlias();
|
||||
break;
|
||||
}
|
||||
} else if (!empty(self::$form['update'])) {
|
||||
switch(self::$form['update']) {
|
||||
case 'domain':
|
||||
FormController::updateDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::updateAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::updateAlias();
|
||||
break;
|
||||
}
|
||||
if (!empty(self::$form['delete'])) {
|
||||
switch(self::$form['delete']) {
|
||||
case 'domain':
|
||||
FormController::delDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::delAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::delAlias();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (!empty(self::$form['add'])) {
|
||||
switch(self::$form['add']) {
|
||||
case 'domain':
|
||||
FormController::addDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::addAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::addAlias();
|
||||
break;
|
||||
}
|
||||
} else if (!empty(self::$form['update'])) {
|
||||
switch(self::$form['update']) {
|
||||
case 'domain':
|
||||
FormController::updateDomain();
|
||||
break;
|
||||
case 'account':
|
||||
FormController::updateAccount();
|
||||
break;
|
||||
case 'alias':
|
||||
FormController::updateAlias();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function filterPassword() {
|
||||
|
|
|
@ -12,7 +12,7 @@ class PageController extends DefaultController {
|
|||
|
||||
ob_start();
|
||||
|
||||
if (self::$logged) {
|
||||
if (!empty(self::$server)) {
|
||||
PageController::filterGet();
|
||||
PageController::ldap();
|
||||
if (!empty(self::$params['page'])) {
|
||||
|
|
Loading…
Reference in a new issue