, Ghent University, Belgium
+ */
+function status_filter($status)
+{
+ $statusname = api_get_status_langvars();
+
+ return $statusname[$status];
+}
+
+if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) {
+ $interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('PlatformAdmin')];
+ $interbreadcrumb[] = ["url" => 'user_list.php', "name" => get_lang('UserList')];
+ $tool_name = get_lang('SearchUsers');
+} else {
+ $interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('PlatformAdmin')];
+ $tool_name = get_lang('UserList');
+}
+
+$message = '';
+
+if (!empty($action)) {
+ $check = Security::check_token('get');
+ if ($check) {
+ switch ($action) {
+ case 'delete_terms':
+ $extraFieldValue = new ExtraFieldValue('user');
+ $value = $extraFieldValue->get_values_by_handler_and_field_variable(
+ $_GET['user_id'],
+ 'legal_accept'
+ );
+ $result = $extraFieldValue->delete($value['id']);
+
+ $value = $extraFieldValue->get_values_by_handler_and_field_variable(
+ $_GET['user_id'],
+ 'request_for_legal_agreement_consent_removal'
+ );
+ $result = $extraFieldValue->delete($value['id']);
+
+ Display::addFlash(Display::return_message(get_lang('Deleted')));
+ header('Location: '.api_get_self());
+ exit;
+
+ break;
+ case 'delete_user':
+ $message = UserManager::deleteUserWithVerification($_GET['user_id']);
+ Display::addFlash($message);
+ header('Location: '.api_get_self());
+ exit;
+ break;
+ case 'delete':
+ if (api_is_platform_admin()) {
+ $number_of_selected_users = count($_POST['id']);
+ $number_of_affected_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_affected_users++;
+ }
+ }
+ }
+ }
+ if ($number_of_selected_users == $number_of_affected_users) {
+ $message = Display::return_message(
+ get_lang('SelectedUsersDeleted'),
+ 'confirmation'
+ );
+ } else {
+ $message = Display::return_message(
+ get_lang('SomeUsersNotDeleted'),
+ 'error'
+ );
+ }
+ }
+ break;
+ case 'anonymize':
+ $message = UserManager::anonymizeUserWithVerification($_GET['user_id']);
+ Display::addFlash($message);
+ header('Location: '.api_get_self());
+ exit;
+ break;
+ }
+ Security::clear_token();
+ }
+}
+
+// Create a search-box
+$form = new FormValidator('search_simple', 'get', null, null, null, 'inline');
+$form->addText(
+ 'keyword',
+ get_lang('Search'),
+ false,
+ [
+ 'aria-label' => get_lang("SearchUsers"),
+ ]
+);
+$form->addButtonSearch(get_lang('Search'));
+
+$actionsLeft = '';
+$actionsCenter = '';
+$actionsRight = '';
+$actionsLeft .= $form->returnForm();
+
+if (isset($_GET['keyword'])) {
+ $parameters = ['keyword' => Security::remove_XSS($_GET['keyword'])];
+} elseif (isset($_GET['keyword_firstname'])) {
+ $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']);
+ $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']);
+ $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']);
+ $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']);
+ $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']);
+ $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']);
+ $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']);
+ $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']);
+}
+// Create a sortable table with user-data
+$parameters['sec_token'] = Security::get_token();
+
+$_admins_list = array_keys(UserManager::get_all_administrators());
+Session::write('admin_list', $_admins_list);
+// Display Advanced search form.
+$form = new FormValidator(
+ 'advanced_search',
+ 'get',
+ '',
+ '',
+ [],
+ FormValidator::LAYOUT_HORIZONTAL
+);
+
+$form->addElement('html', '');
+$form->addElement('header', get_lang('AdvancedSearch'));
+$form->addText('keyword_firstname', get_lang('FirstName'), false);
+$form->addText('keyword_lastname', get_lang('LastName'), false);
+$form->addText('keyword_username', get_lang('LoginName'), false);
+$form->addText('keyword_email', get_lang('Email'), false);
+$form->addText('keyword_officialcode', get_lang('OfficialCode'), false);
+
+$status_options = [];
+$status_options['%'] = get_lang('All');
+$status_options[STUDENT] = get_lang('Student');
+$status_options[COURSEMANAGER] = get_lang('Teacher');
+$status_options[DRH] = get_lang('Drh');
+$status_options[SESSIONADMIN] = get_lang('SessionsAdmin');
+$status_options[PLATFORM_ADMIN] = get_lang('Administrator');
+
+$form->addElement(
+ 'select',
+ 'keyword_status',
+ get_lang('Profile'),
+ $status_options
+);
+$form->addButtonSearch(get_lang('SearchUsers'));
+
+$defaults = [];
+$defaults['keyword_active'] = 1;
+$defaults['keyword_inactive'] = 1;
+$form->setDefaults($defaults);
+$form->addElement('html', '
');
+
+$form = $form->returnForm();
+
+$table = new SortableTable(
+ 'users',
+ 'get_number_of_users',
+ 'get_user_data',
+ (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2
+);
+$table->set_additional_parameters($parameters);
+$table->set_header(0, '', false, 'width="18px"');
+$table->set_header(1, get_lang('Photo'), false);
+$table->set_header(2, get_lang('OfficialCode'));
+
+if (api_is_western_name_order()) {
+ $table->set_header(3, get_lang('FirstName'));
+ $table->set_header(4, get_lang('LastName'));
+} else {
+ $table->set_header(3, get_lang('LastName'));
+ $table->set_header(4, get_lang('FirstName'));
+}
+$table->set_header(5, get_lang('LoginName'));
+$table->set_header(6, get_lang('Email'));
+$table->set_header(7, get_lang('Profile'));
+$table->set_header(8, get_lang('Active'), true, 'width="15px"');
+$table->set_header(9, get_lang('RegistrationDate'), true, 'width="90px"');
+$table->set_header(10, get_lang('Action'), false, 'width="220px"');
+
+$table->set_column_filter(3, 'user_filter');
+$table->set_column_filter(4, 'user_filter');
+$table->set_column_filter(6, 'email_filter');
+$table->set_column_filter(7, 'status_filter');
+$table->set_column_filter(8, 'active_filter');
+$table->set_column_filter(10, 'modify_filter');
+
+// Only show empty actions bar if delete users has been blocked
+$actionsList = [];
+if (api_is_platform_admin() &&
+ !api_get_configuration_value('deny_delete_users')
+) {
+ $actionsList['delete'] = get_lang('DeleteFromPlatform');
+}
+$actionsList['disable'] = get_lang('Disable');
+$actionsList['enable'] = get_lang('Enable');
+$table->set_form_actions($actionsList);
+
+$table_result = $table->return_table();
+$extra_search_options = '';
+$toolbarActions = Display::toolbarAction(
+ 'toolbarUser',
+ [$actionsLeft, $actionsCenter, $actionsRight],
+ [4, 4, 4]
+);
+
+$notice = Display::return_message(get_lang('InformationRightToBeForgottenText'), 'normal', false);
+
+$tpl = new Template($tool_name);
+$tpl->assign('actions', $toolbarActions);
+$tpl->assign('message', $message);
+$tpl->assign('content', $form.$table_result.$extra_search_options.$notice);
+$tpl->display_one_col_template();
diff --git a/main/auth/inscription.php b/main/auth/inscription.php
index 923b95ea8f..7b0ce68d19 100755
--- a/main/auth/inscription.php
+++ b/main/auth/inscription.php
@@ -898,7 +898,7 @@ if ($form->validate()) {
Event::addEvent(
LOG_TERM_CONDITION_ACCEPTED,
LOG_USER_OBJECT,
- api_get_user_info(),
+ api_get_user_info($user_id),
api_get_utc_datetime()
);
diff --git a/main/badge/issued.php b/main/badge/issued.php
index 3b61f6b975..df9962150e 100644
--- a/main/badge/issued.php
+++ b/main/badge/issued.php
@@ -3,6 +3,7 @@
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
+use SkillRelUser as SkillRelUserManager;
/**
* Show information about the issued badge.
@@ -107,7 +108,7 @@ $skillIssueInfo = [
'skill_short_code' => $skillIssue->getSkill()->getShortCode(),
'skill_description' => $skillIssue->getSkill()->getDescription(),
'skill_criteria' => $skillIssue->getSkill()->getCriteria(),
- 'badge_assertion' => $skillIssue->getAssertionUrl(),
+ 'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue),
'comments' => [],
'feedback_average' => $skillIssue->getAverage(),
];
@@ -120,7 +121,6 @@ $skillId = $skillIssueInfo['skill_id'];
/** @var SkillRelUserComment $comment */
foreach ($skillIssueComments as $comment) {
$commentDate = api_get_local_time($comment->getFeedbackDateTime());
-
$skillIssueInfo['comments'][] = [
'text' => $comment->getFeedbackText(),
'value' => $comment->getFeedbackValue(),
@@ -157,7 +157,6 @@ if (!$profile) {
if ($profile) {
$profileId = $profile->getId();
-
$levels = $skillLevelRepo->findBy([
'profile' => $profileId,
]);
@@ -168,7 +167,6 @@ if ($profile) {
}
ksort($profileLevels); // Sort the array by Position.
-
foreach ($profileLevels as $profileLevel) {
$profileId = key($profileLevel);
$acquiredLevel[$profileId] = $profileLevel[$profileId];
@@ -193,7 +191,7 @@ if ($showLevels && $allowToEdit) {
$entityManager->flush();
Display::addFlash(Display::return_message(get_lang('Saved')));
- header("Location: ".$skillIssue->getIssueUrl());
+ header('Location: '.SkillRelUserManager::getIssueUrl($skillIssue));
exit;
}
}
@@ -226,7 +224,7 @@ if ($form->validate() && $allowComment && $allowToEdit) {
$entityManager->flush();
Display::addFlash(Display::return_message(get_lang('Added')));
- header("Location: ".$skillIssue->getIssueUrl());
+ header('Location: '.SkillRelUserManager::getIssueUrl($skillIssue));
exit;
}
diff --git a/main/badge/issued_all.php b/main/badge/issued_all.php
index 477a1cd51a..a1e17f0bde 100644
--- a/main/badge/issued_all.php
+++ b/main/badge/issued_all.php
@@ -4,6 +4,7 @@
use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\UserBundle\Entity\User;
+use SkillRelUser as SkillRelUserManager;
/**
* Show information about all issued badges with same skill by user.
@@ -14,8 +15,8 @@ use Chamilo\UserBundle\Entity\User;
*/
require_once __DIR__.'/../inc/global.inc.php';
-$userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
-$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
+$userId = isset($_GET['user']) ? (int) $_GET['user'] : 0;
+$skillId = isset($_GET['skill']) ? (int) $_GET['skill'] : 0;
if (!$userId || !$skillId) {
api_not_allowed(true);
@@ -26,7 +27,6 @@ Skill::isAllowed($userId);
$em = Database::getManager();
$user = api_get_user_entity($userId);
$skill = $em->find('ChamiloCoreBundle:Skill', $skillId);
-
$currentUserId = api_get_user_id();
if (!$user || !$skill) {
@@ -80,7 +80,10 @@ foreach ($userSkills as $index => $skillIssue) {
'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT),
'acquired_level' => $currentSkillLevel,
'argumentation_author_id' => $skillIssue->getArgumentationAuthorId(),
- 'argumentation_author_name' => api_get_person_name($argumentationAuthor['firstname'], $argumentationAuthor['lastname']),
+ 'argumentation_author_name' => api_get_person_name(
+ $argumentationAuthor['firstname'],
+ $argumentationAuthor['lastname']
+ ),
'argumentation' => $skillIssue->getArgumentation(),
'source_name' => $skillIssue->getSourceName(),
'user_id' => $skillIssue->getUser()->getId(),
@@ -91,7 +94,7 @@ foreach ($userSkills as $index => $skillIssue) {
'skill_short_code' => $skillIssue->getSkill()->getShortCode(),
'skill_description' => $skillIssue->getSkill()->getDescription(),
'skill_criteria' => $skillIssue->getSkill()->getCriteria(),
- 'badge_assertion' => $skillIssue->getAssertionUrl(),
+ 'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue),
'comments' => [],
'feedback_average' => $skillIssue->getAverage(),
];
@@ -156,7 +159,7 @@ foreach ($userSkills as $index => $skillIssue) {
$formAcquiredLevel = new FormValidator(
'acquired_level'.$skillIssue->getId(),
'post',
- $skillIssue->getIssueUrlAll()
+ SkillRelUserManager::getIssueUrlAll($skillIssue)
);
$formAcquiredLevel->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel);
$formAcquiredLevel->addHidden('user', $skillIssue->getUser()->getId());
@@ -172,14 +175,14 @@ foreach ($userSkills as $index => $skillIssue) {
$em->persist($skillIssue);
$em->flush();
- header("Location: ".$skillIssue->getIssueUrlAll());
+ header('Location: '.SkillRelUserManager::getIssueUrlAll($skillIssue));
exit;
}
$form = new FormValidator(
'comment'.$skillIssue->getId(),
'post',
- $skillIssue->getIssueUrlAll()
+ SkillRelUserManager::getIssueUrlAll($skillIssue)
);
$form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]);
$form->applyFilter('comment', 'trim');
@@ -207,7 +210,7 @@ foreach ($userSkills as $index => $skillIssue) {
$em->persist($skillUserComment);
$em->flush();
- header("Location: ".$skillIssue->getIssueUrlAll());
+ header('Location: '.SkillRelUserManager::getIssueUrlAll($skillIssue));
exit;
}
diff --git a/main/cron/lang/langstats.class.php b/main/cron/lang/langstats.class.php
index 6d0ad415ac..60c630d125 100755
--- a/main/cron/lang/langstats.class.php
+++ b/main/cron/lang/langstats.class.php
@@ -139,6 +139,7 @@ class langstats
return $this->db->lastInsertRowID();
}
}
+
return true;
}
diff --git a/main/cron/lang/list_unused_langvars.php b/main/cron/lang/list_unused_langvars.php
index 9ff99b3934..68154b99e5 100755
--- a/main/cron/lang/list_unused_langvars.php
+++ b/main/cron/lang/list_unused_langvars.php
@@ -61,7 +61,6 @@ foreach ($files as $file) {
}
$usedTerms[$term] = $shortFile;
}
-
}
} else {
$myTerms = [];
diff --git a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
index 482ccd34be..e07d0d8020 100644
--- a/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
+++ b/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
@@ -1311,7 +1311,7 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
.api_get_cidreq()
."&id=$exeId'>";
$exerciseTitle = $objExercise->title;
-
+
$message .= sprintf(
get_lang('MessageQuestionCertainty'),
$exerciseTitle,
diff --git a/main/extra/myStudents.php b/main/extra/myStudents.php
index ebedee26c5..55e1192db8 100644
--- a/main/extra/myStudents.php
+++ b/main/extra/myStudents.php
@@ -64,7 +64,6 @@ if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
$this_section = SECTION_COURSES;
}
-
$nameTools = get_lang('StudentDetails');
$em = Database::getManager();
@@ -592,7 +591,7 @@ if (!empty($studentId)) {
'absmiddle', 'hspace' => '3px']
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index d10d8b0726..9dded82e33 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -273,6 +273,7 @@ define('LOG_MY_FOLDER_NEW_PATH', 'new_path');
define('LOG_TERM_CONDITION_ACCEPTED', 'term_condition_accepted');
define('LOG_USER_CONFIRMED_EMAIL', 'user_confirmed_email');
+define('LOG_USER_REMOVED_LEGAL_ACCEPT', 'user_removed_legal_accept');
define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.]/');
@@ -3875,13 +3876,13 @@ function convert_sql_date($last_post_datetime)
* the only one that is actually from the session, in case there are results from
* session 0 *AND* session n).
*
- * @param array Course properties array (result of api_get_course_info())
- * @param string Tool (learnpath, document, etc)
- * @param int The item ID in the given tool
- * @param int The session ID (optional)
- * @param string $tool
+ * @param array $_course Course properties array (result of api_get_course_info())
+ * @param string $tool Tool (learnpath, document, etc)
+ * @param int $id The item ID in the given tool
+ * @param int $session The session ID (optional)
* @param int $user_id
* @param string $type
+ * @param string $group_id
*
* @return int -1 on error, 0 if invisible, 1 if visible
*/
@@ -3939,7 +3940,7 @@ function api_get_item_visibility(
}
$row = Database::fetch_array($res);
- return $row['visibility'];
+ return (int) $row['visibility'];
}
/**
diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php
index db9333b0ea..65ef3f17dc 100755
--- a/main/inc/lib/formvalidator/FormValidator.class.php
+++ b/main/inc/lib/formvalidator/FormValidator.class.php
@@ -296,12 +296,19 @@ EOT;
* @param string $name
* @param string $label
* @param array $attributes
+ * @param bool $required
*
* @return HTML_QuickForm_textarea
*/
- public function addTextarea($name, $label, $attributes = [])
+ public function addTextarea($name, $label, $attributes = [], $required = false)
{
- return $this->addElement('textarea', $name, $label, $attributes);
+ $element = $this->addElement('textarea', $name, $label, $attributes);
+
+ if ($required) {
+ $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
+ }
+
+ return $element;
}
/**
diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php
index 4510bd621d..9cfa2ed407 100755
--- a/main/inc/lib/message.lib.php
+++ b/main/inc/lib/message.lib.php
@@ -2598,6 +2598,22 @@ class MessageManager
}
}
+ /**
+ * @param int $senderId
+ * @param string $subject
+ * @param string $message
+ */
+ public static function sendMessageToAllAdminUsers(
+ $senderId,
+ $subject,
+ $message
+ ) {
+ $admins = UserManager::get_all_administrators();
+ foreach ($admins as $admin) {
+ self::send_message_simple($admin['user_id'], $subject, $message, $senderId);
+ }
+ }
+
/**
* Execute the SQL necessary to know the number of messages in the database.
*
diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php
index 974bbffb12..3d2c59fd34 100755
--- a/main/inc/lib/skill.lib.php
+++ b/main/inc/lib/skill.lib.php
@@ -3,6 +3,7 @@
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use Chamilo\CoreBundle\Entity\Skill as SkillEntity;
+use Chamilo\CoreBundle\Entity\SkillRelUser as SkillRelUserEntity;
use Chamilo\SkillBundle\Entity\SkillRelCourse;
use Chamilo\SkillBundle\Entity\SkillRelItem;
use Chamilo\UserBundle\Entity\User;
@@ -12,6 +13,8 @@ use Fhaculty\Graph\Vertex;
/**
* Class SkillProfile.
*
+ * @todo break the file in different classes
+ *
* @package chamilo.library
*/
class SkillProfile extends Model
@@ -614,6 +617,51 @@ class SkillRelUser extends Model
'where' => $where,
], 'first');
}
+
+ /**
+ * Get the URL for the issue.
+ *
+ * @param SkillRelUserEntity $skillIssue
+ *
+ * @return string
+ */
+ public static function getIssueUrl(SkillRelUserEntity $skillIssue)
+ {
+ return api_get_path(WEB_PATH)."badge/{$skillIssue->getId()}";
+ }
+
+ /**
+ * Get the URL for the All issues page.
+ *
+ * @param SkillRelUserEntity $skillIssue
+ *
+ * @return string
+ */
+ public static function getIssueUrlAll(SkillRelUserEntity $skillIssue)
+ {
+ return api_get_path(WEB_PATH)."skill/{$skillIssue->getSkill()->getId()}/user/{$skillIssue->getUser()->getId()}";
+ }
+
+ /**
+ * Get the URL for the assertion.
+ *
+ * @param SkillRelUserEntity $skillIssue
+ *
+ * @return string
+ */
+ public static function getAssertionUrl(SkillRelUserEntity $skillIssue)
+ {
+ $url = api_get_path(WEB_CODE_PATH).'badge/assertion.php?';
+
+ $url .= http_build_query([
+ 'user' => $skillIssue->getUser()->getId(),
+ 'skill' => $skillIssue->getSkill()->getId(),
+ 'course' => $skillIssue->getCourse() ? $skillIssue->getCourse()->getId() : 0,
+ 'session' => $skillIssue->getSession() ? $skillIssue->getSession()->getId() : 0,
+ ]);
+
+ return $url;
+ }
}
/**
diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php
index 6bda632326..24ce8cf73d 100755
--- a/main/inc/lib/template.lib.php
+++ b/main/inc/lib/template.lib.php
@@ -1376,6 +1376,7 @@ class Template
{
$queryString = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING'];
$requestURI = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
+
return [
'web' => api_get_path(WEB_PATH),
'web_url' => api_get_web_url(),
diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php
index ad24cf8e3f..e7adda5a19 100755
--- a/main/inc/lib/usermanager.lib.php
+++ b/main/inc/lib/usermanager.lib.php
@@ -6157,6 +6157,98 @@ SQL;
return true;
}
+ /**
+ * @param int $userId
+ *
+ * @throws Exception
+ *
+ * @return string
+ */
+ public static function anonymizeUserWithVerification($userId)
+ {
+ $allowDelete = api_get_configuration_value('allow_delete_user_for_session_admin');
+
+ $message = '';
+ if (api_is_platform_admin() ||
+ ($allowDelete && api_is_session_admin())
+ ) {
+ $userToUpdateInfo = api_get_user_info($userId);
+ $currentUserId = api_get_user_id();
+
+ if ($userToUpdateInfo &&
+ api_global_admin_can_edit_admin($userId, null, $allowDelete)
+ ) {
+ if ($userId != $currentUserId &&
+ self::anonymize($userId)
+ ) {
+ $message = Display::return_message(
+ sprintf(get_lang('UserXAnonymized'), $userToUpdateInfo['complete_name_with_username']),
+ 'confirmation'
+ );
+ } else {
+ $message = Display::return_message(
+ sprintf(get_lang('CannotAnonymizeUserX'), $userToUpdateInfo['complete_name_with_username']),
+ 'error'
+ );
+ }
+ } else {
+ $message = Display::return_message(
+ sprintf(get_lang('NoPermissionToAnonymizeUserX'), $userToUpdateInfo['complete_name_with_username']),
+ 'error'
+ );
+ }
+ }
+
+ return $message;
+ }
+
+ /**
+ * @param int $userId
+ *
+ * @throws Exception
+ *
+ * @return string
+ */
+ public static function deleteUserWithVerification($userId)
+ {
+ $allowDelete = api_get_configuration_value('allow_delete_user_for_session_admin');
+ $deleteUserAvailable = api_get_configuration_value('deny_delete_users');
+
+ $message = '';
+
+ if (api_is_platform_admin() ||
+ ($allowDelete && api_is_session_admin())
+ ) {
+ $userToUpdateInfo = api_get_user_info($userId);
+ $currentUserId = api_get_user_id();
+
+ if ($userToUpdateInfo && $deleteUserAvailable &&
+ api_global_admin_can_edit_admin($userId, null, $allowDelete)
+ ) {
+ if ($userId != $currentUserId &&
+ UserManager::delete_user($userId)
+ ) {
+ $message = Display::return_message(
+ get_lang('UserDeleted').': '.$userToUpdateInfo['complete_name_with_username'],
+ 'confirmation'
+ );
+ } else {
+ $message = Display::return_message(
+ get_lang('CannotDeleteUserBecauseOwnsCourse'),
+ 'error'
+ );
+ }
+ } else {
+ $message = Display::return_message(
+ get_lang('CannotDeleteUser'),
+ 'error'
+ );
+ }
+ }
+
+ return $message;
+ }
+
/**
* @return EncoderFactory
*/
diff --git a/main/lp/lp_final_item.php b/main/lp/lp_final_item.php
index f4206864ba..44502bc63d 100644
--- a/main/lp/lp_final_item.php
+++ b/main/lp/lp_final_item.php
@@ -54,7 +54,7 @@ if ($checker) {
'normal',
false
),
- ''. $url .''
+ ''.$url.''
);
$tpl->assign('content', $content);
$tpl->display_blank_template();
diff --git a/main/lp/lp_view.php b/main/lp/lp_view.php
index 6c2c3a9068..95bb07e833 100755
--- a/main/lp/lp_view.php
+++ b/main/lp/lp_view.php
@@ -35,7 +35,7 @@ $show_learnpath = true;
api_protect_course_script();
-$lp_id = !empty($_GET['lp_id']) ? intval($_GET['lp_id']) : 0;
+$lp_id = !empty($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0;
$sessionId = api_get_session_id();
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
@@ -60,8 +60,8 @@ $visibility = api_get_item_visibility(
$sessionId
);
-if (!api_is_allowed_to_edit(false, true, false, false) &&
- intval($visibility) == 0
+if ($visibility === 0 &&
+ !api_is_allowed_to_edit(false, true, false, false)
) {
api_not_allowed(true);
}
@@ -113,7 +113,7 @@ if (!$is_allowed_to_edit) {
}
}
-$platform_theme = api_get_setting('stylesheets'); // Platform's css.
+$platform_theme = api_get_setting('stylesheets');
$my_style = $platform_theme;
$ajaxUrl = api_get_path(WEB_AJAX_PATH).'lp.ajax.php?a=get_item_prerequisites&'.api_get_cidreq();
$htmlHeadXtra[] = ' |