User field changes.

1.10.x
Julio Montoya 10 years ago
parent f8649ad532
commit 814f627c80
  1. 2
      main/admin/user_add.php
  2. 25
      main/admin/user_edit.php
  3. 55
      main/admin/user_list.php
  4. 20
      main/install/db_main.sql
  5. 11
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  6. 7
      main/install/update-db-1.9.0-1.10.0.inc.php

@ -307,7 +307,7 @@ if( $form->validate()) {
if ($user['radio_expiration_date'] == '1') {
$expiration_date = $user['expiration_date'];
} else {
$expiration_date = '0000-00-00 00:00:00';
$expiration_date = null;
}
$active = intval($user['active']);

@ -94,8 +94,7 @@ $user_data['send_mail'] = 0;
$user_data['old_password'] = $user_data['password'];
//Convert the registration date of the user
//@todo remove the date_default_timezone_get() see UserManager::create_user function
$user_data['registration_date'] = api_get_local_time($user_data['registration_date'], null, date_default_timezone_get());
$user_data['registration_date'] = api_get_local_time($user_data['registration_date']);
unset($user_data['password']);
$extra_data = UserManager :: get_extra_user_data($user_id, true);
$user_data = array_merge($user_data, $extra_data);
@ -273,7 +272,7 @@ if (!$user_data['platform_admin']) {
$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
$group = array ();
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('On'), 1);
$group[] = $form->createElement('DatePickerDate', 'expiration_date', null, array('form_name' => $form->getAttribute('name'), 'onchange' => 'javascript: enable_expiration_date();'));
$group[] = $form->createElement('DatePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();'));
$form->addGroup($group, 'max_member_group', null, '', false);
// Active account or inactive account
@ -300,22 +299,12 @@ $form->addElement('style_submit_button', 'submit', get_lang('ModifyInformation')
$user_data['reset_password'] = 0;
$expiration_date = $user_data['expiration_date'];
if ($expiration_date == '0000-00-00 00:00:00') {
if (empty($expiration_date)) {
$user_data['radio_expiration_date'] = 0;
$user_data['expiration_date'] = array();
$user_data['expiration_date']['d'] = date('d');
$user_data['expiration_date']['F'] = date('m');
$user_data['expiration_date']['Y'] = date('Y');
$user_data['expiration_date'] = date('Y-m-d');
} else {
$user_data['radio_expiration_date'] = 1;
$user_data['expiration_date'] = array();
$user_data['expiration_date']['d'] = substr($expiration_date, 8, 2);
$user_data['expiration_date']['F'] = substr($expiration_date, 5, 2);
$user_data['expiration_date']['Y'] = substr($expiration_date, 0, 4);
$user_data['expiration_date']['H'] = substr($expiration_date, 11, 2);
$user_data['expiration_date']['i'] = substr($expiration_date, 14, 2);
$user_data['expiration_date'] = $expiration_date;
}
$form->setDefaults($user_data);
@ -355,9 +344,9 @@ if ($form->validate()) {
$language = $user['language'];
if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
$expiration_date = return_datetime_from_array($user['expiration_date']);
$expiration_date = $user['expiration_date'];
} else {
$expiration_date = '0000-00-00 00:00:00';
$expiration_date = null;
}
$active = $user_data['platform_admin'] ? 1 : intval($user['active']);

@ -7,7 +7,7 @@
*/
// name of the language file that needs to be included
$language_file = array ('registration','admin');
$language_file = array('registration','admin');
$cidReset = true;
require_once '../inc/global.inc.php';
@ -466,7 +466,7 @@ function get_user_data($from, $number_of_items, $column, $direction) {
} else {
$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
}
if ($user[7] == 1 && $user[10] != '0000-00-00 00:00:00') {
if ($user[7] == 1 && !empty($user[10])) {
// check expiration date
$expiration_time = convert_sql_date($user[10]);
// if expiration date is passed, store a special value for active field
@ -474,9 +474,23 @@ function get_user_data($from, $number_of_items, $column, $direction) {
$user[7] = '-1';
}
}
// forget about the expiration date field
$users[] = array($user[0], $photo, $user[1],$user[2], $user[3], $user[4], $user[5], $user[6], $user[7], api_get_local_time($user[9]), $user[0]);
$users[] = array(
$user[0],
$photo,
$user[1],
$user[2],
$user[3],
$user[4],
$user[5],
$user[6],
$user[7],
api_get_local_time($user[9]),
$user[0]
);
}
return $users;
}
@ -635,7 +649,10 @@ function modify_filter($user_id, $url_params, $row) {
if (api_is_platform_admin()) {
$result .= ' <a href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&amp;user_id='.$user_id.'" class="agenda_opener">'.Display::return_icon('month.png', get_lang('FreeBusyCalendar'), array(), ICON_SIZE_SMALL).'</a>';
if ($delete_user_available) {
if ($user_id != api_get_user_id() && !$user_is_anonymous && api_global_admin_can_edit_admin($user_id)) {
if ($user_id != api_get_user_id() &&
!$user_is_anonymous &&
api_global_admin_can_edit_admin($user_id)
) {
// you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
$result .= ' <a href="user_list.php?action=delete_user&amp;user_id='.$user_id.'&amp;'.$url_params.'&amp;sec_token='.$_SESSION['sec_token'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
} else {
@ -652,26 +669,28 @@ function modify_filter($user_id, $url_params, $row) {
* lock = the user can no longer use this account
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @param int $active the current state of the account
* @param int $user_id The user id
* @param string $url_params
* @param string $params
* @param array $row
* @return string Some HTML-code with the lock/unlock button
*/
function active_filter($active, $url_params, $row) {
function active_filter($active, $params, $row)
{
global $_user;
if ($active=='1') {
$action='Lock';
$image='accept';
} elseif ($active=='-1') {
$action='edit';
$image='warning';
} elseif ($active=='0') {
$action='Unlock';
$image='error';
if ($active == '1') {
$action = 'Lock';
$image = 'accept';
} elseif ($active == '-1') {
$action = 'edit';
$image = 'warning';
} elseif ($active == '0') {
$action = 'Unlock';
$image = 'error';
}
$result = '';
if ($action=='edit') {
if ($action == 'edit') {
$result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16);
} elseif ($row['0']<>$_user['user_id']) {
// you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.

@ -21,7 +21,7 @@
DROP TABLE IF EXISTS user;
CREATE TABLE IF NOT EXISTS user (
id int unsigned NOT NULL auto_increment,
user_id int unsigned NOT NULL,
user_id int unsigned default NULL,
lastname varchar(60) default NULL,
firstname varchar(60) default NULL,
username varchar(100) NOT NULL default '',
@ -38,17 +38,17 @@ CREATE TABLE IF NOT EXISTS user (
openarea text,
teach text,
productions varchar(250) default NULL,
chatcall_user_id int unsigned NOT NULL default '0',
chatcall_date datetime NOT NULL default '0000-00-00 00:00:00',
chatcall_text varchar(50) NOT NULL default '',
chatcall_user_id int unsigned default '0',
chatcall_date datetime default NULL,
chatcall_text varchar(50) default NULL,
language varchar(40) default NULL,
registration_date datetime NOT NULL default '0000-00-00 00:00:00',
expiration_date datetime NOT NULL default '0000-00-00 00:00:00',
registration_date datetime NOT NULL,
expiration_date datetime default NULL,
active tinyint unsigned NOT NULL default 1,
openid varchar(255) DEFAULT NULL,
theme varchar(255) DEFAULT NULL,
hr_dept_id smallint unsigned NOT NULL default 0,
PRIMARY KEY (user_id),
PRIMARY KEY (id),
UNIQUE KEY username (username)
);
ALTER TABLE user ADD INDEX (status);
@ -59,9 +59,9 @@ ALTER TABLE user ADD INDEX (status);
/*!40000 ALTER TABLE user DISABLE KEYS */;
LOCK TABLES user WRITE;
INSERT INTO user (lastname, firstname, username, password, auth_source, email, status, official_code,phone, creator_id, registration_date, expiration_date,active,openid,language) VALUES ('{ADMINLASTNAME}','{ADMINFIRSTNAME}','{ADMINLOGIN}','{ADMINPASSWORD}','{PLATFORM_AUTH_SOURCE}','{ADMINEMAIL}',1,'ADMIN','{ADMINPHONE}',1,NOW(),'0000-00-00 00:00:00','1',NULL,'{ADMINLANGUAGE}');
INSERT INTO user (user_id, lastname, firstname, username, password, auth_source, email, status, official_code,phone, creator_id, registration_date, expiration_date,active,openid,language) VALUES (1, '{ADMINLASTNAME}','{ADMINFIRSTNAME}','{ADMINLOGIN}','{ADMINPASSWORD}','{PLATFORM_AUTH_SOURCE}','{ADMINEMAIL}',1,'ADMIN','{ADMINPHONE}',1,NOW(),'0000-00-00 00:00:00','1',NULL,'{ADMINLANGUAGE}');
-- Insert anonymous user
INSERT INTO user (lastname, firstname, username, password, auth_source, email, status, official_code, creator_id, registration_date, expiration_date,active,openid,language) VALUES ('Anonymous', 'Joe', '', '', 'platform', 'anonymous@localhost', 6, 'anonymous', 1, NOW(), '0000-00-00 00:00:00', 1,NULL,'{ADMINLANGUAGE}');
INSERT INTO user (user_id, lastname, firstname, username, password, auth_source, email, status, official_code, creator_id, registration_date, expiration_date,active,openid,language) VALUES (2, 'Anonymous', 'Joe', '', '', 'platform', 'anonymous@localhost', 6, 'anonymous', 1, NOW(), '0000-00-00 00:00:00', 1,NULL,'{ADMINLANGUAGE}');
UNLOCK TABLES;
/*!40000 ALTER TABLE user ENABLE KEYS */;
@ -884,7 +884,7 @@ VALUES
('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1),
('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1),
('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1),
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.13','DatabaseVersion','', NULL, NULL, 0);
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.14','DatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */;

@ -63,12 +63,19 @@ ALTER TABLE track_e_course_access ADD COLUMN user_ip varchar(39) NOT NULL defaul
ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT '';
ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT '';
ALTER TABLE user MODIFY COLUMN user_id int NOT NULL;
ALTER TABLE user MODIFY COLUMN user_id int DEFAULT NULL;
ALTER TABLE user DROP PRIMARY KEY;
ALTER TABLE user ADD COLUMN id int NOT NULL PRIMARY KEY AUTO_INCREMENT;
ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL;
ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL;
ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default '0';
ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL;
ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.13' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.14' WHERE variable = 'chamilo_database_version';
-- xxCOURSExx

@ -122,6 +122,7 @@ if (defined('SYSTEM_INSTALLATION')) {
}
}
// Updating user.id field
$res = iDatabase::query("SELECT user_id FROM $dbNameForm.user");
$result = iDatabase::query($sql);
$users = Database::store_result($result);
@ -130,6 +131,12 @@ if (defined('SYSTEM_INSTALLATION')) {
$sql = "UPDATE $dbNameForm.user SET id = $userId WHERE user_id = $userId";
iDatabase::query($sql);
}
// Set null registration_date = 0000-00-00 00:00:00
$sql = "UPDATE $dbNameForm.user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00'";
iDatabase::query($sql);
$sql = "UPDATE $dbNameForm.user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00'";
iDatabase::query($sql);
}
}

Loading…
Cancel
Save