webui code cleanup

This commit is contained in:
SJ 2012-06-22 15:22:02 +02:00
parent 16b01b9b37
commit 9900f0aed2
24 changed files with 87 additions and 129 deletions

View File

@ -66,7 +66,7 @@ $mail = new ModelMailMail();
list($totalmem, $meminfo, $totalswap, $swapinfo) = $health->meminfo();
$shortdiskinfo = $health->diskinfo();
list($archive_size, $counters) = $counter->getCounters();
list($archive_size, $counters) = $counter->get_counters();
$sysinfo = $health->sysinfo();

View File

@ -55,19 +55,19 @@ extract($language->data);
foreach ($cfg as $ldap_params) {
$users = $import->model_user_import->queryRemoteUsers($ldap_params, $ldap_params['domain']);
$rc = $import->model_user_import->fillRemoteTable($ldap_params, $ldap_params['domain']);
$users = $import->model_user_import->query_remote_users($ldap_params, $ldap_params['domain']);
$rc = $import->model_user_import->fill_remote_table($ldap_params, $ldap_params['domain']);
$totalusers += count($users);
list($newusers, $deletedusers) = $import->model_user_import->processUsers($users, $ldap_params);
list($a1, $a2) = $import->model_user_import->processUsers($users, $ldap_params);
list($newusers, $deletedusers) = $import->model_user_import->process_users($users, $ldap_params);
list($a1, $a2) = $import->model_user_import->process_users($users, $ldap_params);
$totalnewusers += $newusers;
$totaldeletedusers += $deletedusers;
if($trash_passwords == 1) {
$import->model_user_import->trashPassword($users);
$import->model_user_import->trash_password($users);
}
}

View File

@ -17,7 +17,7 @@ class ControllerGroupAdd extends Controller {
$this->load->model('group/group');
$this->document->title = $this->data['text_group_management'];
$this->document->title = $this->data['text_add_new_group'];
/* check if we are admin */

View File

@ -20,7 +20,7 @@ class ControllerGroupEdit extends Controller {
$this->load->model('group/group');
$this->document->title = $language->get('text_group_management');
$this->document->title = $language->get('text_edit_group');
$this->data['domains'] = array();
@ -38,7 +38,10 @@ class ControllerGroupEdit extends Controller {
if(Registry::get('admin_user') == 1) {
$this->data['group'] = $this->model_group_group->get_domain_by_id($this->data['id']);
if($this->request->server['REQUEST_METHOD'] == 'POST') {
if($this->validate() == true){
$ret = $this->model_group_group->update_group($this->request->post);
@ -50,20 +53,13 @@ class ControllerGroupEdit extends Controller {
$this->data['errorstring'] = $this->data['text_failed_to_modify'] . ": " . $ret;
}
//$__groupname = $this->request->post['groupname'];
}
else {
$this->template = "common/error.tpl";
$this->data['errorstring'] = array_pop($this->error);
}
}
else {
$this->data['group'] = $this->model_group_group->get_domain_by_id($this->data['id']);
$this->data['email'] = $this->model_group_group->get_emails_by_group_id($this->data['id']);
//$this->data['user']['group_membership'] = $this->model_user_user->get_additional_uids($this->data['uid']);
//$this->data['emails'] = $this->model_user_user->getEmails($this->data['user']['username']);
}
}
else {
@ -84,6 +80,10 @@ class ControllerGroupEdit extends Controller {
$this->error['group'] = $this->data['text_missing_data'];
}
if(!isset($this->request->post['email']) || $this->request->post['email'] == '') {
$this->error['email'] = $this->data['text_missing_data'];
}
if(!isset($this->request->post['id']) || !is_numeric($this->request->post['id']) || (int)$this->request->post['id'] < 0) {
$this->error['id'] = $this->data['text_invalid_data'];
}

View File

@ -61,7 +61,7 @@ class ControllerHealthWorker extends Controller {
if($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['resetcounters']) && $this->request->post['resetcounters'] == 1) {
if(isset($this->request->post['confirmed']) && $this->request->post['confirmed'] == 1 && Registry::get('admin_user') == 1) {
$this->model_stat_counter->resetCounters();
$this->model_stat_counter->reset_counters();
header("Location: index.php?route=health/health");
exit;
}
@ -71,7 +71,7 @@ class ControllerHealthWorker extends Controller {
}
list($this->data['archive_size'], $this->data['counters']) = $this->model_stat_counter->getCounters();
list($this->data['archive_size'], $this->data['counters']) = $this->model_stat_counter->get_counters();
$this->data['prefix'] = '';
if(isset($this->data['counters'][MEMCACHED_PREFIX . 'rcvd'])) { $this->data['prefix'] = MEMCACHED_PREFIX; }

View File

@ -27,11 +27,11 @@ class ControllerStatChart extends Controller {
/* let the admin users see the whole statistics */
if(Registry::get('admin_user') == 0 && Registry::get('readonly_admin') == 0) {
$uid = $this->model_user_user->getUidByName($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$uid)) . "')";
$uid = $this->model_user_user->get_uid_by_name($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$uid)) . "')";
}
else if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0){
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$this->request->get['uid'])) . "')";
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$this->request->get['uid'])) . "')";
}
$aa = new ModelStatChart();

View File

@ -24,12 +24,12 @@ class ControllerStatCounter extends Controller {
if(Registry::get('admin_user') == 1) {
if($this->request->server['REQUEST_METHOD'] == 'POST' && @$this->request->post['reset'] == 1) {
$this->model_stat_counter->resetCounters();
$this->model_stat_counter->reset_counters();
header("Location: index.php?route=stat/counter");
exit;
}
$this->data['counters'] = $this->model_stat_counter->getCounters();
$this->data['counters'] = $this->model_stat_counter->get_counters();
$this->data['prefix'] = '';

View File

@ -28,11 +28,11 @@ class ControllerStatGraph extends Controller {
/* let the admin users see the whole statistics */
if(Registry::get('admin_user') == 0 && Registry::get('readonly_admin') == 0) {
$uid = $this->model_user_user->getUidByName($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$uid)) . "')";
$uid = $this->model_user_user->get_uid_by_name($this->data['username']);
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$uid)) . "')";
}
else if(isset($this->request->get['uid']) && is_numeric($this->request->get['uid']) && $this->request->get['uid'] > 0){
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->getEmailsByUid((int)$this->request->get['uid'])) . "')";
$emails = "AND rcpt IN ('" . preg_replace("/\n/", "','", $this->model_user_user->get_emails_by_uid((int)$this->request->get['uid'])) . "')";
}

View File

@ -18,7 +18,7 @@ class ControllerUserAdd extends Controller {
$this->load->model('user/user');
$this->load->model('group/group');
$this->document->title = $this->data['text_user_management'];
$this->document->title = $this->data['text_add_new_user_alias'];
$this->data['domains'] = array();
@ -37,7 +37,7 @@ class ControllerUserAdd extends Controller {
$ret = 0;
if($this->validate() == true){
$ret = $this->model_user_user->addUser($this->request->post);
$ret = $this->model_user_user->add_user($this->request->post);
$_SESSION['last_domain'] = $this->request->post['domain'];
@ -54,12 +54,12 @@ class ControllerUserAdd extends Controller {
if($ret == 0) {
$this->data['post'] = $this->request->post;
$this->data['next_user_id'] = $this->model_user_user->getNextUid();
$this->data['next_user_id'] = $this->model_user_user->get_next_uid();
}
}
else {
$this->data['next_user_id'] = $this->model_user_user->getNextUid();
$this->data['next_user_id'] = $this->model_user_user->get_next_uid();
$this->data['groups'] = $this->model_group_group->get_groups();
}
}
@ -114,7 +114,7 @@ class ControllerUserAdd extends Controller {
$this->error['username'] = $this->data['text_invalid_username'];
}
if(isset($this->request->post['username']) && $this->model_user_user->getUidByName($this->request->post['username']) > 0) {
if(isset($this->request->post['username']) && $this->model_user_user->get_uid_by_name($this->request->post['username']) > 0) {
$this->error['username'] = $this->data['text_existing_user'];
}

View File

@ -22,7 +22,7 @@ class ControllerUserEdit extends Controller {
$this->load->model('group/group');
$this->document->title = $language->get('text_user_management');
$this->document->title = $language->get('text_edit_user');
$this->data['domains'] = array();
@ -53,7 +53,7 @@ class ControllerUserEdit extends Controller {
if($this->request->server['REQUEST_METHOD'] == 'POST') {
if($this->validate() == true){
$ret = $this->model_user_user->updateUser($this->request->post);
$ret = $this->model_user_user->update_user($this->request->post);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_modified'];
@ -75,7 +75,7 @@ class ControllerUserEdit extends Controller {
$this->data['user']['group_membership'] = $this->model_user_user->get_additional_uids($this->data['uid']);
$this->data['emails'] = $this->model_user_user->getEmails($this->data['user']['username']);
$this->data['emails'] = $this->model_user_user->get_emails($this->data['user']['username']);
}
}

View File

@ -59,10 +59,10 @@ class ControllerUserList extends Controller {
if(Registry::get('admin_user') == 1) {
$users = $this->model_user_user->getUsers($this->data['search'], $this->data['page'], $this->data['page_len'],
$users = $this->model_user_user->get_users($this->data['search'], $this->data['page'], $this->data['page_len'],
$this->data['sort'], $this->data['order']);
$this->data['total_users'] = $this->model_user_user->howManyUsers($this->data['search']);
$this->data['total_users'] = $this->model_user_user->count_users($this->data['search']);
foreach ($users as $user) {
$policy_group = DEFAULT_POLICY;

View File

@ -31,7 +31,7 @@ class ControllerUserRemove extends Controller {
if($this->validate() == true) {
if($this->data['confirmed'] == 1) {
$ret = $this->model_user_user->deleteUser($this->data['uid']);
$ret = $this->model_user_user->delete_user($this->data['uid']);
if($ret == 1){
$this->data['x'] = $this->data['text_successfully_removed'];
}

View File

@ -33,7 +33,7 @@ class ControllerUserSettings extends Controller {
if($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) {
if($this->model_user_auth->changePassword(Registry::get('username'), $this->request->post['password']) == 1) {
if($this->model_user_auth->change_password(Registry::get('username'), $this->request->post['password']) == 1) {
$this->data['x'] = $this->data['text_password_changed'];
}
else {

View File

@ -74,6 +74,8 @@ $_['text_download_message'] = "Download message (EML)";
$_['text_download_message2'] = "download message";
$_['text_edit'] = "Edit";
$_['text_edit_group'] = "Edit group";
$_['text_edit_user'] = "Edit user";
$_['text_edit_or_view'] = "Edit/view";
$_['text_email'] = "Email address";
$_['text_email_addresses'] = "Email addresses";
@ -297,7 +299,7 @@ $_['text_users'] = "Users";
$_['text_user_id'] = "User id";
$_['text_user_auditor'] = "Auditor";
$_['text_user_domainadmin'] = "Domain admin";
$_['text_user_management'] = "User";
$_['text_user_management'] = "User management";
$_['text_user_masteradmin'] = "Master admin";
$_['text_user_read_only_admin'] = "Read-only admin";
$_['text_user_regular'] = "Regular user";

View File

@ -74,6 +74,8 @@ $_['text_download_message'] = "Lev
$_['text_download_message2'] = "levél letöltése";
$_['text_edit'] = "Szerkeszt";
$_['text_edit_group'] = "Csoport szerkesztése";
$_['text_edit_user'] = "Felhasználó szerkesztése";
$_['text_edit_or_view'] = "Szerkeszt/Megnéz";
$_['text_email'] = "Email cím";
$_['text_email_addresses'] = "Email címek";
@ -120,7 +122,7 @@ $_['text_home'] = "Kezd
$_['text_group_id'] = "Csoport azonosító";
$_['text_groupname'] = "Csoportnév";
$_['text_groups'] = "Csoportok";
$_['text_group_management'] = "Csoport";
$_['text_group_management'] = "Csoportok";
$_['text_group_membership'] = "Csoport tagság";
$_['text_image'] = "kép";
@ -298,7 +300,7 @@ $_['text_users'] = "Felhaszn
$_['text_user_id'] = "Felhasználó azonosító";
$_['text_user_auditor'] = "Auditor";
$_['text_user_domainadmin'] = "Domain admin";
$_['text_user_management'] = "Felhasználó";
$_['text_user_management'] = "Felhasználók";
$_['text_user_masteradmin'] = "Mester admin";
$_['text_user_read_only_admin'] = "Read-only admin";
$_['text_user_regular'] = "Sima felhasználó";

View File

@ -74,6 +74,8 @@ $_['text_download_message'] = "Levél letöltése (EML)";
$_['text_download_message2'] = "levél letöltése";
$_['text_edit'] = "Szerkeszt";
$_['text_edit_group'] = "Csoport szerkesztése";
$_['text_edit_user'] = "Felhasználó szerkesztése";
$_['text_edit_or_view'] = "Szerkeszt/Megnéz";
$_['text_email'] = "Email cím";
$_['text_email_addresses'] = "Email címek";
@ -120,7 +122,7 @@ $_['text_home'] = "Kezdőlap";
$_['text_group_id'] = "Csoport azonosító";
$_['text_groupname'] = "Csoportnév";
$_['text_groups'] = "Csoportok";
$_['text_group_management'] = "Csoport";
$_['text_group_management'] = "Csoportok";
$_['text_group_membership'] = "Csoport tagság";
$_['text_image'] = "kép";
@ -298,7 +300,7 @@ $_['text_users'] = "Felhasználók";
$_['text_user_id'] = "Felhasználó azonosító";
$_['text_user_auditor'] = "Auditor";
$_['text_user_domainadmin'] = "Domain admin";
$_['text_user_management'] = "Felhasználó";
$_['text_user_management'] = "Felhasználók";
$_['text_user_masteradmin'] = "Mester admin";
$_['text_user_read_only_admin'] = "Read-only admin";
$_['text_user_regular'] = "Sima felhasználó";

View File

@ -2,7 +2,7 @@
class ModelStatCounter extends Model {
public function getCounters(){
public function get_counters(){
$counter = array();
$asize = 0;
@ -32,7 +32,7 @@ class ModelStatCounter extends Model {
}
public function resetCounters(){
public function reset_counters(){
if(MEMCACHED_ENABLED) {
$memcache = Registry::get('memcache');

View File

@ -50,7 +50,7 @@ class ModelUserAuth extends Model {
$_SESSION['admin_user'] = 0;
$_SESSION['email'] = $user['username'];
$this->changePassword($user['username'], $password);
$this->change_password($user['username'], $password);
AUDIT(ACTION_LOGIN, $user['username'], '', '', 'changed password in local table');
@ -64,7 +64,7 @@ class ModelUserAuth extends Model {
}
public function changePassword($username = '', $password = '') {
public function change_password($username = '', $password = '') {
if($username == "" || $password == ""){ return 0; }
$query = $this->db->query("UPDATE " . TABLE_USER . " SET password=? WHERE username=?", array(crypt($password), $username));

View File

@ -4,18 +4,10 @@
class ModelUserImport extends Model {
public function getLdapParameters() {
$my_domain = $this->model_user_user->getDomains();
$query = $this->db->query("SELECT remotehost, basedn, binddn FROM " . TABLE_REMOTE . " WHERE remotedomain=?", array($my_domain[0]));
return $query->row;
}
public function queryRemoteUsers($host) {
public function query_remote_users($host) {
$data = array();
LOGGER("running queryRemoteUsers() ...");
LOGGER("running query_remote_users() ...");
$attrs = array("cn", "mail", "mailAlternateAddress", "memberdn", "memberaddr");
$mailAttr = 'mail';
@ -111,7 +103,7 @@ class ModelUserImport extends Model {
public function fillRemoteTable($host = array(), $domain = '') {
public function fill_remote_table($host = array(), $domain = '') {
if($domain == '') { return 0; }
/*
@ -141,7 +133,7 @@ class ModelUserImport extends Model {
public function processUsers($users = array(), $globals = array()) {
public function process_users($users = array(), $globals = array()) {
$late_add = array();
$uids = array();
$exclude = array();
@ -149,7 +141,7 @@ class ModelUserImport extends Model {
$deleteduser = 0;
$n = 0;
LOGGER("running processUsers() ...");
LOGGER("running process_users() ...");
/* build a list of DNs to exclude from the import */
@ -170,7 +162,7 @@ class ModelUserImport extends Model {
/* Does this DN exist in the user table ? */
$__user = $this->model_user_user->getUserByDN($_user['dn']);
$__user = $this->model_user_user->get_user_by_dn($_user['dn']);
if(isset($__user['uid'])) {
@ -180,7 +172,7 @@ class ModelUserImport extends Model {
/* if so, then verify the email addresses */
$changed = 0;
$emails = $this->model_user_user->getEmailsByUid($__user['uid']);
$emails = $this->model_user_user->get_emails_by_uid($__user['uid']);
/* first let's add the new email addresses */
@ -189,7 +181,7 @@ class ModelUserImport extends Model {
foreach ($ldap_emails as $email) {
if(!in_array($email, $sql_emails)) {
$rc = $this->model_user_user->addEmail($__user['uid'], $email);
$rc = $this->model_user_user->add_email($__user['uid'], $email);
$changed++;
/* in case of an error add it to the $late_add array() */
@ -208,7 +200,7 @@ class ModelUserImport extends Model {
foreach ($sql_emails as $email) {
if(!in_array($email, $ldap_emails)) {
$rc = $this->model_user_user->removeEmail($__user['uid'], $email);
$rc = $this->model_user_user->remove_email($__user['uid'], $email);
$changed++;
}
}
@ -224,7 +216,7 @@ class ModelUserImport extends Model {
$user = $this->createNewUserArray($_user['dn'], $_user['username'], $_user['realname'], $_user['emails'], $globals);
array_push($uids, $user['uid']);
$rc = $this->model_user_user->addUser($user);
$rc = $this->model_user_user->add_user($user);
if($rc == 1) { $newuser++; }
}
}
@ -233,7 +225,7 @@ class ModelUserImport extends Model {
/* add the rest to the email table */
foreach ($late_add as $new) {
$rc = $this->model_user_user->addEmail($new['uid'], $new['email']);
$rc = $this->model_user_user->add_email($new['uid'], $new['email']);
if($rc == 1) { $newuser++; }
}
@ -258,7 +250,7 @@ class ModelUserImport extends Model {
foreach ($users as $user) {
if($user['members']) {
$group = $this->model_user_user->getUserByDN($user['dn']);
$group = $this->model_user_user->get_user_by_dn($user['dn']);
$members = explode("\n", $user['members']);
if(count($members) > 0) {
@ -269,9 +261,9 @@ class ModelUserImport extends Model {
foreach ($members as $member) {
if(validemail($member)) {
$__user = $this->model_user_user->getUserByEmail($member);
$__user = $this->model_user_user->get_user_by_email($member);
} else {
$__user = $this->model_user_user->getUserByDN($member);
$__user = $this->model_user_user->get_user_by_dn($member);
}
if(isset($group['uid']) && isset($__user['uid'])) {
@ -291,7 +283,7 @@ class ModelUserImport extends Model {
private function createNewUserArray($dn = '', $username = '', $realname = '', $emails = '', $globals = array()) {
$user = array();
$user['uid'] = $this->model_user_user->getNextUid();
$user['uid'] = $this->model_user_user->get_next_uid();
$user['gid'] = $globals['gid'];
$user['email'] = $emails;
@ -322,7 +314,7 @@ class ModelUserImport extends Model {
}
public function trashPassword($users = array()) {
public function trash_password($users = array()) {
foreach ($users as $user) {
$query = $this->db->query("UPDATE " . TABLE_USER . " SET password='*' WHERE dn=?", array($user['dn']));
$rc = $this->db->countAffected();

View File

@ -3,7 +3,7 @@
class ModelUserUser extends Model {
public function checkUID($uid) {
public function check_uid($uid) {
if($uid == "") { return 0; }
if(!is_numeric($uid)) { return 0; }
@ -14,7 +14,7 @@ class ModelUserUser extends Model {
}
public function getUidByName($username = '') {
public function get_uid_by_name($username = '') {
if($username == ""){ return -1; }
$query = $this->db->query("SELECT uid FROM " . TABLE_USER . " WHERE username=?", array($username));
@ -27,18 +27,6 @@ class ModelUserUser extends Model {
}
public function getUsernameByUid($uid = 0) {
$query = $this->db->query("SELECT username FROM " . TABLE_USER . " WHERE uid=?", array((int)$uid));
if(isset($query->row['username'])){
return $query->row['username'];
}
return "";
}
public function get_uid_by_email($email = '') {
$query = $this->db->query("SELECT uid FROM " . TABLE_EMAIL . " WHERE email=?", array($email));
@ -109,19 +97,7 @@ class ModelUserUser extends Model {
}
public function getEmailAddress($username = '') {
$query = $this->db->query("SELECT " . TABLE_EMAIL . ".email AS email FROM " . TABLE_EMAIL . "," . TABLE_USER . " WHERE " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid AND " . TABLE_USER . ".username=? LIMIT 1", array($username));
if(isset($query->row['email'])){
return $query->row['email'];
}
return "";
}
public function getEmails($username = '') {
public function get_emails($username = '') {
$emails = "";
$query = $this->db->query("SELECT " . TABLE_EMAIL . ".email AS email FROM " . TABLE_EMAIL . "," . TABLE_USER . " WHERE " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid AND " . TABLE_USER . ".username=?", array($username));
@ -134,7 +110,7 @@ class ModelUserUser extends Model {
}
public function getEmailsByUid($uid = 0) {
public function get_emails_by_uid($uid = 0) {
$emails = "";
$query = $this->db->query("SELECT email FROM " . TABLE_EMAIL . " WHERE uid=?", array((int)$uid));
@ -146,7 +122,7 @@ class ModelUserUser extends Model {
}
public function getUserByDN($dn = '') {
public function get_user_by_dn($dn = '') {
if($dn == '') { return array(); }
$query = $this->db->query("SELECT * FROM " . TABLE_USER . " WHERE dn=?", array($dn));
@ -170,7 +146,7 @@ class ModelUserUser extends Model {
}
public function getUserByEmail($email = '') {
public function get_user_by_email($email = '') {
if($email == '') {
return array();
}
@ -181,20 +157,7 @@ class ModelUserUser extends Model {
}
public function getUsernameByEmail($email = '') {
$username = "";
if($email == '') { return $username; }
$query = $this->db->query("SELECT username FROM " . TABLE_USER . " WHERE uid IN (SELECT uid FROM " . TABLE_EMAIL . " WHERE email=?)", array($email));
if(isset($query->row['username'])) { $username = $query->row['username']; }
return $username;
}
public function getUsers($search = '', $page = 0, $page_len = 0, $sort = 'username', $order = 0) {
public function get_users($search = '', $page = 0, $page_len = 0, $sort = 'username', $order = 0) {
$where_cond = " WHERE " . TABLE_USER . ".uid=" . TABLE_EMAIL . ".uid ";
$_order = "";
$users = array();
@ -240,7 +203,7 @@ class ModelUserUser extends Model {
}
public function howManyUsers($search = '') {
public function count_users($search = '') {
$where_cond = "";
if($search){
@ -279,7 +242,7 @@ class ModelUserUser extends Model {
}
public function getNextUid() {
public function get_next_uid() {
$query = $this->db->query("SELECT MAX(uid) AS last_id FROM " . TABLE_USER);
@ -291,11 +254,11 @@ class ModelUserUser extends Model {
}
public function addUser($user) {
public function add_user($user) {
LOGGER("add user: " . $user['username'] . ", uid=" . (int)$user['uid']);
if(!isset($user['domain']) || $user['domain'] == "") { return -1; }
if(!isset($user['username']) || $user['username'] == "" || $this->getUidByName($user['username']) > 0) { return -1; }
if(!isset($user['username']) || $user['username'] == "" || $this->get_uid_by_name($user['username']) > 0) { return -1; }
$emails = explode("\n", $user['email']);
foreach ($emails as $email) {
@ -330,7 +293,7 @@ class ModelUserUser extends Model {
foreach ($emails as $email) {
$email = rtrim($email);
$ret = $this->addEmail((int)$user['uid'], $email);
$ret = $this->add_email((int)$user['uid'], $email);
if($ret == 0) { return -2; }
}
@ -339,7 +302,7 @@ class ModelUserUser extends Model {
}
public function addEmail($uid = 0, $email = '') {
public function add_email($uid = 0, $email = '') {
if($uid < 1 || $email == ""){ return 0; }
$query = $this->db->query("INSERT INTO " . TABLE_EMAIL . " (uid, email) VALUES(?,?)", array((int)$uid, $email));
@ -352,7 +315,7 @@ class ModelUserUser extends Model {
}
public function removeEmail($uid = 0, $email = '') {
public function remove_email($uid = 0, $email = '') {
if((int)$uid < 1 || $email == ""){ return 0; }
$query = $this->db->query("DELETE FROM " . TABLE_EMAIL . " WHERE uid=? AND email=?", array((int)$uid, $email));
@ -365,7 +328,7 @@ class ModelUserUser extends Model {
}
public function updateUser($user) {
public function update_user($user) {
LOGGER("update user: " . $user['username'] . ", uid=" . (int)$user['uid']);
$emails = explode("\n", $user['email']);
@ -413,8 +376,8 @@ class ModelUserUser extends Model {
}
public function deleteUser($uid) {
if(!$this->checkUID($uid)){ return 0; }
public function delete_user($uid) {
if(!$this->check_uid($uid)){ return 0; }
$query = $this->db->query("DELETE FROM " . TABLE_EMAIL . " WHERE uid=?", array((int)$uid));
$query = $this->db->query("DELETE FROM " . TABLE_USER . " WHERE uid=?", array((int)$uid));

View File

@ -1,6 +1,4 @@
<h4><?php print $text_add_new_group; ?></h4>
<?php if(isset($errorstring)){ ?><p class="loginfailed"><?php print $text_error; ?>: <?php print $errorstring; ?></p><?php } ?>

View File

@ -1,4 +1,5 @@
<?php if(isset($errorstring)){ ?><p class="loginfailed"><?php print $text_error; ?>: <?php print $errorstring; ?></p><?php } ?>
<?php if(isset($group)) { ?>

View File

@ -1,6 +1,4 @@
<h4><?php print $text_add_new_user_alias; ?></h4>
<?php if(isset($errorstring)){ ?><p class="loginfailed"><?php print $text_error; ?>: <?php print $errorstring; ?></p><?php } ?>

View File

@ -85,7 +85,7 @@
<div class="domaincell"><?php print $text_group_membership; ?>:</div>
<div class="domaincell">
<?php foreach ($user['group_membership'] as $_group_uid) { ?>
<?php $a = preg_split("/\s/", $this->model_user_user->getEmailsByUid($_group_uid)); print $a[0]; ?></br />
<?php $a = preg_split("/\s/", $this->model_user_user->get_emails_by_uid($_group_uid)); print $a[0]; ?></br />
<?php } ?>
</div>
</div>