本文整理汇总了PHP中UserManager::delete_user方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::delete_user方法的具体用法?PHP UserManager::delete_user怎么用?PHP UserManager::delete_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::delete_user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_inactive_student
/**
*
* @param int student id
* @param int years
* @param bool show warning_message
* @param bool return_timestamp
*/
public static function delete_inactive_student($student_id, $years = 2, $warning_message = false, $return_timestamp = false)
{
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
WHERE login_user_id = ' . intval($student_id) . '
ORDER BY login_date DESC LIMIT 0,1';
if (empty($years)) {
$years = 1;
}
$inactive_time = $years * 31536000;
//1 year
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($last_login_date = Database::result($rs, 0, 0)) {
$last_login_date = api_get_local_time($last_login_date, null, date_default_timezone_get());
if ($return_timestamp) {
return api_strtotime($last_login_date);
} else {
if (!$warning_message) {
return api_format_date($last_login_date, DATE_FORMAT_SHORT);
} else {
$timestamp = api_strtotime($last_login_date);
$currentTimestamp = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds 63072000= 2 ans
// if ($currentTimestamp - $timestamp > 184590 )
if ($currentTimestamp - $timestamp > $inactive_time && UserManager::delete_user($student_id)) {
Display::display_normal_message(get_lang('UserDeleted'));
echo '<p>', 'id', $student_id, ':', $last_login_date, '</p>';
}
}
}
}
}
return false;
}
示例2: WSHelperActionOnUsers
function WSHelperActionOnUsers($params, $type)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$original_user_ids = $params['ids'];
foreach ($original_user_ids as $original_user_id) {
$user_id = UserManager::get_user_id_from_original_id($original_user_id['original_user_id_value'], $original_user_id['original_user_id_name']);
if ($user_id > 0) {
if ($type == "delete") {
UserManager::delete_user($user_id);
} else {
if ($type == "disable") {
UserManager::disable($user_id);
} else {
if ($type == "enable") {
UserManager::enable($user_id);
}
}
}
}
}
}
示例3: count
} else {
$message = Display::return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
}
} else {
$message = Display::return_message(get_lang('CannotDeleteUser'), 'error');
}
}
break;
case 'delete':
if (api_is_platform_admin()) {
$number_of_selected_users = count($_POST['id']);
$number_of_deleted_users = 0;
if (is_array($_POST['id'])) {
foreach ($_POST['id'] as $index => $user_id) {
if ($user_id != $_user['user_id']) {
if (UserManager::delete_user($user_id)) {
$number_of_deleted_users++;
}
}
}
}
if ($number_of_selected_users == $number_of_deleted_users) {
$message = Display::return_message(get_lang('SelectedUsersDeleted'), 'confirmation');
} else {
$message = Display::return_message(get_lang('SomeUsersNotDeleted'), 'error');
}
}
break;
}
Security::clear_token();
}
示例4: api_not_allowed
<?php
/* For licensing terms, see /license.txt */
//require_once '../inc/global.inc.php';
if (api_get_setting('platform_unsubscribe_allowed') != 'true') {
api_not_allowed();
}
$tool_name = get_lang('Unsubscribe');
$message = Display::return_message(get_lang('UnsubscribeFromPlatform'), 'warning');
$form = new FormValidator('user_add');
$form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm"))) . "')) return false;"));
$content = $form->returnForm();
if ($form->validate()) {
$user_info = api_get_user_info();
$result = UserManager::delete_user($user_info['user_id']);
if ($result) {
$message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username'])));
$content = null;
online_logout($user_info['user_id'], false);
api_not_allowed(true, $message);
}
}
//$tpl = new Template($tool_name);
echo $actions;
echo $message;
echo $content;
示例5: transaction_2
static function transaction_2($data)
{
$uidIdPersonaId = strtoupper($data['item_id']);
global $data_list;
$user_id = self::get_user_id_by_persona_id($uidIdPersonaId, $data_list);
if ($user_id) {
$chamilo_user_info_before = api_get_user_info($user_id, false, false, true);
$result = UserManager::delete_user($user_id);
$chamilo_user_info = api_get_user_info($user_id, false, false, true);
if ($result) {
$data_list['users'][$uidIdPersonaId] = null;
return array('entity' => 'user', 'before' => $chamilo_user_info_before, 'after' => $chamilo_user_info, 'message' => "User was deleted : {$user_id}", 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
} else {
return array('message' => "User was NOT deleted : {$user_id} error while calling function UserManager::delete_user", 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
}
} else {
return array('message' => "User was not found with uidIdPersona: {$uidIdPersonaId}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
}
示例6: deleteUserHelper
/**
* Deletes a user (helper method)
*
* @param string User id field name. Use "chamilo_user_id" as the field name if you want to use the internal user_id
* @param string User id value
* @return mixed True if user was successfully deleted, WSError otherwise
*/
protected function deleteUserHelper($user_id_field_name, $user_id_value)
{
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if ($user_id instanceof WSError) {
return $user_id;
} else {
if (!UserManager::delete_user($user_id)) {
return new WSError(101, "There was a problem while deleting this user");
} else {
return true;
}
}
}
示例7: testDelete_user2
/**
* @depends testCreateUser
*/
public function testDelete_user2()
{
$user_info = UserManager::get_user_info('jmontoya666');
$this->assertSame(false, UserManager::delete_user($user_info['user_id']));
}