Actualización
This commit is contained in:
552
plugin/courselegal/CourseLegalPlugin.php
Normal file
552
plugin/courselegal/CourseLegalPlugin.php
Normal file
@@ -0,0 +1,552 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* Class CourseLegalPlugin.
|
||||
*/
|
||||
class CourseLegalPlugin extends Plugin
|
||||
{
|
||||
public $isCoursePlugin = true;
|
||||
|
||||
// When creating a new course this settings are added to the course
|
||||
public $course_settings = [
|
||||
[
|
||||
'name' => 'courselegal',
|
||||
'type' => 'text',
|
||||
],
|
||||
];
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'0.1',
|
||||
'Julio Montoya',
|
||||
[
|
||||
'tool_enable' => 'boolean',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CourseLegalPlugin
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
static $result = null;
|
||||
|
||||
return $result ? $result : $result = new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTeacherLink()
|
||||
{
|
||||
$link = null;
|
||||
if (api_is_allowed_to_edit()) {
|
||||
$url = api_get_path(WEB_PLUGIN_PATH).'courselegal/start.php?'.api_get_cidreq();
|
||||
$link = Display::url(
|
||||
$this->get_lang('CourseLegal'),
|
||||
$url,
|
||||
['class' => 'btn']
|
||||
);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserAcceptedLegal($userId, $courseId, $sessionId)
|
||||
{
|
||||
$userId = intval($userId);
|
||||
$courseId = intval($courseId);
|
||||
$sessionId = intval($sessionId);
|
||||
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
$sql = "SELECT *
|
||||
FROM $table
|
||||
WHERE user_id = $userId AND c_id = $courseId AND session_id = $sessionId";
|
||||
$result = Database::query($sql);
|
||||
$data = [];
|
||||
if (Database::num_rows($result) > 0) {
|
||||
$data = Database::fetch_array($result, 'ASSOC');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param string $courseCode
|
||||
* @param int $sessionId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUserAcceptedLegal($userId, $courseCode, $sessionId)
|
||||
{
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
$result = $this->getUserAcceptedLegal($userId, $courseId, $sessionId);
|
||||
|
||||
if (!empty($result)) {
|
||||
if ($result['mail_agreement'] == 1 &&
|
||||
$result['web_agreement'] == 1
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $courseCode
|
||||
* @param int $sessionId
|
||||
* @param bool $sendEmail Optional. Indicate whether the mail must be sent. Default is true
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function saveUserLegal($userId, $courseCode, $sessionId, $sendEmail = true)
|
||||
{
|
||||
$courseInfo = api_get_course_info($courseCode);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
$data = $this->getUserAcceptedLegal($userId, $courseId, $sessionId);
|
||||
|
||||
$id = false;
|
||||
if (empty($data)) {
|
||||
$table = Database::get_main_table(
|
||||
'session_rel_course_rel_user_legal'
|
||||
);
|
||||
$uniqueId = api_get_unique_id();
|
||||
$values = [
|
||||
'user_id' => $userId,
|
||||
'c_id' => $courseId,
|
||||
'session_id' => $sessionId,
|
||||
'web_agreement' => 1,
|
||||
'web_agreement_date' => api_get_utc_datetime(),
|
||||
'mail_agreement_link' => $uniqueId,
|
||||
];
|
||||
$id = Database::insert($table, $values);
|
||||
|
||||
if ($sendEmail) {
|
||||
$this->sendMailLink($uniqueId, $userId, $courseId, $sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*/
|
||||
public function updateMailAgreementLink($userId, $courseId, $sessionId)
|
||||
{
|
||||
$data = $this->getUserAcceptedLegal($userId, $courseId, $sessionId);
|
||||
if (!empty($data)) {
|
||||
$table = Database::get_main_table(
|
||||
'session_rel_course_rel_user_legal'
|
||||
);
|
||||
$uniqueId = api_get_unique_id();
|
||||
Database::update(
|
||||
$table,
|
||||
['mail_agreement_link' => $uniqueId],
|
||||
['id = ? ' => [$data['id']]]
|
||||
);
|
||||
$this->sendMailLink($uniqueId, $userId, $courseId, $sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*/
|
||||
public function deleteUserAgreement($userId, $courseId, $sessionId)
|
||||
{
|
||||
$data = $this->getUserAcceptedLegal($userId, $courseId, $sessionId);
|
||||
if (!empty($data)) {
|
||||
$table = Database::get_main_table(
|
||||
'session_rel_course_rel_user_legal'
|
||||
);
|
||||
Database::delete(
|
||||
$table,
|
||||
['id = ? ' => [$data['id']]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uniqueId
|
||||
* @param int $userId
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*/
|
||||
public function sendMailLink($uniqueId, $userId, $courseId, $sessionId)
|
||||
{
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
$courseCode = $courseInfo['code'];
|
||||
|
||||
$url = api_get_path(WEB_CODE_PATH).'course_info/legal.php?web_agreement_link='.$uniqueId.'&course_code='.Security::remove_XSS($courseCode).'&session_id='.$sessionId;
|
||||
$courseUrl = Display::url($url, $url);
|
||||
$sessionInfo = api_get_session_info($sessionId);
|
||||
$sesstionTitle = null;
|
||||
|
||||
if (!empty($sessionInfo)) {
|
||||
$sesstionTitle = ' ('.$sessionInfo['name'].')';
|
||||
}
|
||||
|
||||
$courseTitle = $courseInfo['title'].$sesstionTitle;
|
||||
|
||||
$subject = $this->get_lang("MailAgreement");
|
||||
$message = sprintf($this->get_lang("MailAgreementWasSentWithClickX"), $courseTitle, $courseUrl);
|
||||
MessageManager::send_message_simple($userId, $subject, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
* @param int $userId
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveUserMailLegal($link, $userId, $courseId, $sessionId)
|
||||
{
|
||||
$data = $this->getUserAcceptedLegal($userId, $courseId, $sessionId);
|
||||
|
||||
if (empty($data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($data['mail_agreement_link'] == $link) {
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
$id = $data['id'];
|
||||
$values = [
|
||||
'mail_agreement' => 1,
|
||||
'mail_agreement_date' => api_get_utc_datetime(),
|
||||
];
|
||||
Database::update($table, $values, ['id = ?' => [$id]]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
* @param string $filePath
|
||||
*/
|
||||
public function warnUsersByEmail($courseId, $sessionId, $filePath = null)
|
||||
{
|
||||
$courseInfo = api_get_course_info_by_id($courseId);
|
||||
$courseCode = $courseInfo['code'];
|
||||
|
||||
if (empty($sessionId)) {
|
||||
$students = CourseManager::get_student_list_from_course_code($courseCode, false);
|
||||
} else {
|
||||
$students = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId);
|
||||
}
|
||||
|
||||
$url = api_get_course_url($courseCode, $sessionId);
|
||||
$url = Display::url($url, $url);
|
||||
|
||||
$subject = $this->get_lang("AgreementUpdated");
|
||||
$message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url);
|
||||
|
||||
$dataFile = [];
|
||||
if (!empty($filePath)) {
|
||||
$dataFile = [
|
||||
'path' => $filePath,
|
||||
'filename' => basename($filePath),
|
||||
];
|
||||
$message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url)." \n";
|
||||
$message .= $this->get_lang("TheAgreementIsAttachedInThisEmail");
|
||||
}
|
||||
|
||||
if (!empty($students)) {
|
||||
foreach ($students as $student) {
|
||||
$userInfo = api_get_user_info($student['user_id']);
|
||||
api_mail_html(
|
||||
$userInfo['complete_name'],
|
||||
$userInfo['email'],
|
||||
$subject,
|
||||
$message,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$dataFile
|
||||
);
|
||||
//MessageManager::send_message_simple($student['user_id'], $subject, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
* @param string $order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getUserAgreementList($courseId, $sessionId, $order = null)
|
||||
{
|
||||
$courseId = intval($courseId);
|
||||
$sessionId = intval($sessionId);
|
||||
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
$userTable = Database::get_main_table(TABLE_MAIN_USER);
|
||||
$sql = "SELECT *
|
||||
FROM $table s INNER JOIN $userTable u
|
||||
ON u.user_id = s.user_id
|
||||
WHERE c_id = $courseId AND session_id = $sessionId ";
|
||||
|
||||
if (!empty($order)) {
|
||||
$sql .= $order;
|
||||
}
|
||||
$result = Database::query($sql);
|
||||
$data = [];
|
||||
if (Database::num_rows($result) > 0) {
|
||||
$data = Database::store_result($result, 'ASSOC');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*/
|
||||
public function removePreviousAgreements($courseId, $sessionId)
|
||||
{
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
$sessionId = intval($sessionId);
|
||||
$courseId = intval($courseId);
|
||||
$sql = "DELETE FROM $table
|
||||
WHERE c_id = '$courseId' AND session_id = $sessionId ";
|
||||
Database::query($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $values
|
||||
* @param array $file $_FILES['uploaded_file']
|
||||
* @param bool $deleteFile
|
||||
*/
|
||||
public function save($values, $file = [], $deleteFile = false)
|
||||
{
|
||||
$table = Database::get_main_table('session_rel_course_legal');
|
||||
|
||||
$courseId = $values['c_id'];
|
||||
$sessionId = $values['session_id'];
|
||||
|
||||
$conditions = [
|
||||
'c_id' => $courseId,
|
||||
'session_id' => $sessionId,
|
||||
];
|
||||
|
||||
$course = api_get_course_info_by_id($courseId);
|
||||
|
||||
$legalData = $this->getData($courseId, $sessionId);
|
||||
$coursePath = api_get_path(SYS_COURSE_PATH).$course['directory'].'/courselegal';
|
||||
$uploadResult = $coursePath.'/'.$legalData['filename'];
|
||||
|
||||
if (!is_dir($coursePath)) {
|
||||
mkdir($coursePath, api_get_permissions_for_new_directories());
|
||||
}
|
||||
$uploadOk = process_uploaded_file($file, false);
|
||||
$fileName = null;
|
||||
|
||||
if ($uploadOk) {
|
||||
$uploadResult = handle_uploaded_document(
|
||||
$course,
|
||||
$file,
|
||||
$coursePath,
|
||||
'/',
|
||||
api_get_user_id(),
|
||||
api_get_group_id(),
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
if ($uploadResult) {
|
||||
$fileName = basename($uploadResult);
|
||||
// Delete old one if exists.
|
||||
if ($legalData) {
|
||||
if (!empty($legalData['filename'])) {
|
||||
$fileToDelete = $coursePath.'/'.$legalData['filename'];
|
||||
if (file_exists($fileToDelete)) {
|
||||
unlink($fileToDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$conditions['content'] = $values['content'];
|
||||
$conditions['filename'] = $fileName;
|
||||
|
||||
if (empty($legalData)) {
|
||||
$id = Database::insert($table, $conditions);
|
||||
} else {
|
||||
$id = $legalData['id'];
|
||||
|
||||
$updateParams = [
|
||||
'content' => $values['content'],
|
||||
];
|
||||
|
||||
if (!empty($fileName)) {
|
||||
$updateParams['filename'] = $fileName;
|
||||
}
|
||||
|
||||
Database::update(
|
||||
$table,
|
||||
$updateParams,
|
||||
['id = ? ' => $id]
|
||||
);
|
||||
}
|
||||
|
||||
if ($deleteFile) {
|
||||
Database::update(
|
||||
$table,
|
||||
['filename' => ''],
|
||||
['id = ? ' => $id]
|
||||
);
|
||||
if (!empty($legalData['filename'])) {
|
||||
$fileToDelete = $coursePath.'/'.$legalData['filename'];
|
||||
if (file_exists($fileToDelete)) {
|
||||
unlink($fileToDelete);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($values['remove_previous_agreements']) &&
|
||||
!empty($values['remove_previous_agreements'])
|
||||
) {
|
||||
$this->removePreviousAgreements($courseId, $sessionId);
|
||||
}
|
||||
|
||||
$warnUsers = isset($values['warn_users_by_email']) ? $values['warn_users_by_email'] : null;
|
||||
|
||||
switch ($warnUsers) {
|
||||
case '1':
|
||||
// Nothing
|
||||
break;
|
||||
case '2':
|
||||
// Send mail
|
||||
$this->warnUsersByEmail($courseId, $sessionId);
|
||||
break;
|
||||
case '3':
|
||||
// Send mail + attachment if exists.
|
||||
if (!empty($legalData['filename'])) {
|
||||
$this->warnUsersByEmail(
|
||||
$courseId,
|
||||
$sessionId,
|
||||
$uploadResult
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getData($courseId, $sessionId)
|
||||
{
|
||||
$table = Database::get_main_table('session_rel_course_legal');
|
||||
$conditions = [
|
||||
'c_id = ? AND session_id = ? ' => [
|
||||
$courseId,
|
||||
$sessionId,
|
||||
],
|
||||
];
|
||||
|
||||
$result = Database::select('*', $table, ['where' => $conditions]);
|
||||
$legalData = isset($result) && !empty($result) ? current($result) : [];
|
||||
|
||||
return $legalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $courseId
|
||||
* @param int $sessionId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentFile($courseId, $sessionId)
|
||||
{
|
||||
$data = $this->getData($courseId, $sessionId);
|
||||
|
||||
if (isset($data['filename']) && !empty($data['filename'])) {
|
||||
$course = api_get_course_info_by_id($courseId);
|
||||
|
||||
$coursePath = api_get_path(SYS_COURSE_PATH).$course['directory'].'/courselegal';
|
||||
$file = $coursePath.'/'.$data['filename'];
|
||||
|
||||
if (file_exists($file)) {
|
||||
return Display::url(
|
||||
$data['filename'],
|
||||
api_get_path(WEB_COURSE_PATH).$course['directory'].'/courselegal/'.$data['filename'],
|
||||
['target' => '_blank']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
$table = Database::get_main_table('session_rel_course_legal');
|
||||
$sql = "CREATE TABLE IF NOT EXISTS $table (
|
||||
id int PRIMARY KEY AUTO_INCREMENT,
|
||||
c_id int,
|
||||
session_id int,
|
||||
content text,
|
||||
filename varchar(255)
|
||||
)";
|
||||
Database::query($sql);
|
||||
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS $table (
|
||||
id int PRIMARY KEY AUTO_INCREMENT,
|
||||
user_id int,
|
||||
c_id int,
|
||||
session_id int,
|
||||
web_agreement varchar(255),
|
||||
web_agreement_date datetime,
|
||||
mail_agreement varchar(255),
|
||||
mail_agreement_date datetime,
|
||||
mail_agreement_link varchar(255)
|
||||
)";
|
||||
Database::query($sql);
|
||||
|
||||
// Installing course settings
|
||||
$this->install_course_fields_in_all_courses(false);
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
$table = Database::get_main_table('session_rel_course_legal');
|
||||
$sql = "DROP TABLE $table ";
|
||||
Database::query($sql);
|
||||
|
||||
$table = Database::get_main_table('session_rel_course_rel_user_legal');
|
||||
$sql = "DROP TABLE $table ";
|
||||
Database::query($sql);
|
||||
|
||||
// Deleting course settings
|
||||
$this->uninstall_course_fields_in_all_courses($this->course_settings);
|
||||
}
|
||||
}
|
||||
25
plugin/courselegal/README.md
Normal file
25
plugin/courselegal/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
Installation
|
||||
============
|
||||
|
||||
1. Enabled the plugin from the list of plugins.
|
||||
2. Click "Configure" once the plugin was enabled.
|
||||
3. Select tool_enable = Yes and save.
|
||||
4. Go into a *course* (not course session) and enter the Settings tool.
|
||||
5. In the "Course access" section select "Enable legal terms" and
|
||||
change the course visibility to "Private" and save.
|
||||
6. Go to a course or a course in a session a new button "Legal" will appear
|
||||
in the course home.
|
||||
7. Click the button "Legal". Fill the form with the content and a file you want
|
||||
to be shown to the students. There are other options in the form, like:
|
||||
- Send an email to all users.
|
||||
- Delete all previous agreements
|
||||
- Delete the file.
|
||||
|
||||
The file are saved in courses/XX/courselegal/
|
||||
|
||||
8. Once the form was saved, a new form will appear for the registered users.
|
||||
The student has to accept the form.
|
||||
When the form is accepted an email will be sent to the user via email and
|
||||
then Chamilo message tool
|
||||
9. The user has to click in the URL. Once the user clicked to the URL the user
|
||||
will have access to the course.
|
||||
4
plugin/courselegal/config.php
Normal file
4
plugin/courselegal/config.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/../../main/inc/global.inc.php';
|
||||
1
plugin/courselegal/index.php
Normal file
1
plugin/courselegal/index.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php
|
||||
9
plugin/courselegal/install.php
Normal file
9
plugin/courselegal/install.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
|
||||
if (!api_is_platform_admin()) {
|
||||
exit('You must have admin permissions to install plugins');
|
||||
}
|
||||
CourseLegalPlugin::create()->install();
|
||||
23
plugin/courselegal/lang/english.php
Normal file
23
plugin/courselegal/lang/english.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$strings['plugin_title'] = "Course legal agreement";
|
||||
$strings['plugin_comment'] = "Add a legal agreement per course (also works with courses in sessions)";
|
||||
$strings['tool_enable'] = 'Enable plugin';
|
||||
$strings['tool_enable_help'] = 'Once enabled, you will have to configure the plugin inside the course configuration, then from the course homepage (a button will appear there only for the teacher)';
|
||||
|
||||
$strings['CourseLegal'] = 'Course legal agreement';
|
||||
$strings['WebAgreement'] = 'Web agreement';
|
||||
$strings['MailAgreement'] = 'Agreement by e-mail';
|
||||
$strings['MailAgreementWasSentWithClickX'] = 'Click on the link below to agree with the terms and conditions to access course %s: <br /> %s';
|
||||
$strings['AgreementUpdated'] = 'Agreement updated';
|
||||
$strings['AgreementWasUpdatedClickHere'] = 'The agreement was updated. Click here: %s';
|
||||
$strings['YouNeedToConfirmYourAgreementCheckYourEmail'] = 'You need to confirm that you agree. Please check your email.';
|
||||
$strings['DeleteFile'] = 'Delete the file attachment';
|
||||
$strings['RemoveAllUserAgreements'] = 'Remove all previous user agreements';
|
||||
$strings['WarnAllUsersByEmail'] = 'Notify all users by email';
|
||||
$strings['WarnAllUsersByEmailAndSendAttachment'] = 'Notify all users by email and send them the attachment.';
|
||||
$strings['ReSendMailAgreementLink'] = 'Send e-mail agreement link again';
|
||||
$strings['SendOnlyWarning'] = 'Send only notification';
|
||||
$strings['SendAgreementFile'] = 'Send notification and attach the agreement';
|
||||
$strings['NoSendWarning'] = 'Do not send notification';
|
||||
$strings['TheAgreementIsAttachedInThisEmail'] = 'A copy of the agreement document is attached to this email';
|
||||
23
plugin/courselegal/lang/french.php
Normal file
23
plugin/courselegal/lang/french.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$strings['plugin_title'] = "Termes légaux d'utilisation de cours";
|
||||
$strings['plugin_comment'] = "Ajouter des termes d'utilisation par cours (fonctionne également avec les cours dans des sessions), avec possibilité de demander confirmation par mail.";
|
||||
$strings['tool_enable'] = 'Activer le plugin';
|
||||
$strings['tool_enable_help'] = 'Une fois activé, il vous faudra configurer le plugin dans chaque cours (outil de configuration du cours), puis depuis la page d\'accueil du cours (un bouton apparaîtra au professeur uniquement)';
|
||||
|
||||
$strings['CourseLegal'] = 'Termes d\'utilisation du cours';
|
||||
$strings['WebAgreement'] = 'Accord web';
|
||||
$strings['MailAgreement'] = 'Accord par mail';
|
||||
$strings['MailAgreementWasSentWithClickX'] = 'Cliquez sur le lien suivant pour accepter les termes d\'accès au cours %s: <br /> %s';
|
||||
$strings['AgreementUpdated'] = 'Termes mis à jour';
|
||||
$strings['AgreementWasUpdatedClickHere'] = 'Les termes d\'utilisation ont été mis à jour. Cliquez ici: %s';
|
||||
$strings['YouNeedToConfirmYourAgreementCheckYourEmail'] = 'Veuillez confirmer votre accord. Vérifiez votre e-mail.';
|
||||
$strings['DeleteFile'] = 'Éliminez la pièce jointe';
|
||||
$strings['RemoveAllUserAgreements'] = 'Supprimer tous les accords utilisateurs antérieurs';
|
||||
$strings['WarnAllUsersByEmail'] = 'Avertir tous les utilisateurs par mail';
|
||||
$strings['WarnAllUsersByEmailAndSendAttachment'] = 'Avertir tous les utilisateurs par mail avec la pièce jointe.';
|
||||
$strings['ReSendMailAgreementLink'] = 'Envoyer le lien d\'accord par mail de nouveau';
|
||||
$strings['SendOnlyWarning'] = 'Envoyer seulement l\'avertissement';
|
||||
$strings['SendAgreementFile'] = 'Envoyer à nouveau l\'avertissement avec la pièce jointe';
|
||||
$strings['NoSendWarning'] = 'Ne pas envoyer l\'avertissement';
|
||||
$strings['TheAgreementIsAttachedInThisEmail'] = 'Une copie du document d\'accord est joint à cet e-mail';
|
||||
23
plugin/courselegal/lang/spanish.php
Normal file
23
plugin/courselegal/lang/spanish.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$strings['plugin_title'] = "Acuerdo de curso";
|
||||
$strings['plugin_comment'] = "Agrega un acuerdo a cada curso (funciona con cursos en sesiones de formación)";
|
||||
$strings['tool_enable'] = 'Activar la configuración del plugin en los cursos';
|
||||
$strings['tool_enable_help'] = 'Una vez activado, tendrá que configurar el plugin dentro de la página de configuración del curso, y luego desde la página principal del curso (un botón aparecerá solo al profesor)';
|
||||
|
||||
$strings['CourseLegal'] = 'Acuerdo legal de curso';
|
||||
$strings['WebAgreement'] = 'Acuerdo por Web';
|
||||
$strings['MailAgreement'] = 'Acuerdo por correo electrónico';
|
||||
$strings['MailAgreementWasSentWithClickX'] = 'Haga clic en el siguiente enlace para confirmar que está de acuerdo con los términos y condiciones para acceder al curso %s: <br /> %s';
|
||||
$strings['AgreementUpdated'] = 'Acuerdo actualizado';
|
||||
$strings['AgreementWasUpdatedClickHere'] = 'El acuerdo fue actualizado. Haga clic aquí: %s';
|
||||
$strings['YouNeedToConfirmYourAgreementCheckYourEmail'] = 'Usted necesita confirmar que está de acuerdo. Revise su correo electrónico, por favor';
|
||||
$strings['DeleteFile'] = 'Eliminar archivo adjuntado';
|
||||
$strings['RemoveAllUserAgreements'] = 'Eliminar todos los acuerdos de usuarios anteriores';
|
||||
$strings['WarnAllUsersByEmail'] = 'Notificar a todos los usuarios por corro electrónico';
|
||||
$strings['WarnAllUsersByEmailAndSendAttachment'] = 'Notificar a todos los usuarios por correo electrónico y enviarles el acuerdo adjuntado';
|
||||
$strings['ReSendMailAgreementLink'] = 'Enviar un correo electrónico con el enlace al acuerdo de nuevo.';
|
||||
$strings['SendOnlyWarning'] = 'Enviar solamente notificación';
|
||||
$strings['SendAgreementFile'] = 'Enviar notificación y adjuntar el acuerdo';
|
||||
$strings['NoSendWarning'] = 'No enviar notificación';
|
||||
$strings['TheAgreementIsAttachedInThisEmail'] = 'Una copia de este documento de acuerdo es adjuntado a este correo electrónico.';
|
||||
4
plugin/courselegal/plugin.php
Normal file
4
plugin/courselegal/plugin.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
$plugin_info = CourseLegalPlugin::create()->get_info();
|
||||
64
plugin/courselegal/start.php
Normal file
64
plugin/courselegal/start.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
|
||||
// Course legal
|
||||
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
|
||||
|
||||
if ($enabled != 'true') {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if (!api_is_allowed_to_edit()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$legal = CourseLegalPlugin::create();
|
||||
$url = api_get_self().'?'.api_get_cidreq();
|
||||
$courseId = api_get_course_int_id();
|
||||
$sessionId = api_get_session_id();
|
||||
|
||||
$form = new FormValidator('plugin', 'post', $url);
|
||||
$form->addElement('header', $legal->get_lang('CourseLegal'));
|
||||
$form->addElement('hidden', 'session_id', $sessionId);
|
||||
$form->addElement('hidden', 'c_id', $courseId);
|
||||
$form->addHtmlEditor(
|
||||
'content',
|
||||
get_lang('Text'),
|
||||
true,
|
||||
false,
|
||||
['ToolbarSet' => 'TermsAndConditions']
|
||||
);
|
||||
$form->addElement('file', 'uploaded_file', get_lang('File'));
|
||||
$file = $legal->getCurrentFile($courseId, $sessionId);
|
||||
|
||||
if (!empty($file)) {
|
||||
$form->addElement('label', get_lang('File'), $file);
|
||||
}
|
||||
|
||||
$form->addElement('checkbox', 'delete_file', null, $legal->get_lang('DeleteFile'));
|
||||
$form->addElement('checkbox', 'remove_previous_agreements', null, $legal->get_lang('RemoveAllUserAgreements'));
|
||||
$form->addElement('radio', 'warn_users_by_email', null, $legal->get_lang('NoSendWarning'), 1);
|
||||
$form->addElement('radio', 'warn_users_by_email', $legal->get_lang('WarnAllUsersByEmail'), $legal->get_lang('SendOnlyWarning'), 2);
|
||||
$form->addElement('radio', 'warn_users_by_email', null, $legal->get_lang('SendAgreementFile'), 3);
|
||||
$form->addButtonSave(get_lang('Save'));
|
||||
$defaults = $legal->getData($courseId, $sessionId);
|
||||
$defaults['warn_users_by_email'] = 1;
|
||||
$form->setDefaults($defaults);
|
||||
|
||||
if ($form->validate()) {
|
||||
$values = $form->getSubmitValues();
|
||||
$file = isset($_FILES['uploaded_file']) ? $_FILES['uploaded_file'] : [];
|
||||
$deleteFile = isset($values['delete_file']) ? $values['delete_file'] : false;
|
||||
$legal->save($values, $file, $deleteFile);
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
Display::display_header($legal->get_lang('CourseLegal'));
|
||||
$url = api_get_path(WEB_PLUGIN_PATH).'courselegal/user_list.php?'.api_get_cidreq();
|
||||
$link = Display::url(Display::return_icon('user.png', get_lang('UserList')), $url);
|
||||
echo '<div class="actions">'.$link.'</div>';
|
||||
$form->display();
|
||||
|
||||
Display::display_footer();
|
||||
81
plugin/courselegal/user_list.php
Normal file
81
plugin/courselegal/user_list.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/* For license terms, see /license.txt */
|
||||
|
||||
require_once __DIR__.'/config.php';
|
||||
|
||||
// Course legal
|
||||
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
|
||||
|
||||
if ($enabled != 'true') {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
if (!api_is_allowed_to_edit()) {
|
||||
api_not_allowed(true);
|
||||
}
|
||||
|
||||
$legal = CourseLegalPlugin::create();
|
||||
$courseId = api_get_course_int_id();
|
||||
$sessionId = api_get_session_id();
|
||||
$url = api_get_self().'?'.api_get_cidreq();
|
||||
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : null;
|
||||
switch ($action) {
|
||||
case 'resend':
|
||||
if (isset($_GET['user_id'])) {
|
||||
$legal->updateMailAgreementLink($_GET['user_id'], $courseId, $sessionId);
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (isset($_GET['user_id'])) {
|
||||
$legal->deleteUserAgreement($_GET['user_id'], $courseId, $sessionId);
|
||||
header('Location: '.$url);
|
||||
exit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$order = " ORDER BY firstname, lastname";
|
||||
$userList = $legal->getUserAgreementList($courseId, $sessionId, $order);
|
||||
$table = new HTML_Table(['class' => 'table table-hover table-striped data_table']);
|
||||
$table->setHeaderContents(0, 0, get_lang('User'));
|
||||
$table->setHeaderContents(0, 1, $legal->get_lang('WebAgreement'));
|
||||
$table->setHeaderContents(0, 2, $legal->get_lang('MailAgreement'));
|
||||
$table->setHeaderContents(0, 3, $legal->get_lang('Actions'));
|
||||
$row = 1;
|
||||
|
||||
$pluginPath = api_get_path(WEB_PLUGIN_PATH).'courselegal/';
|
||||
if (!empty($userList)) {
|
||||
foreach ($userList as $user) {
|
||||
$userName = api_get_person_name($user['firstname'], $user['lastname']);
|
||||
|
||||
$webDate = !empty($user['web_agreement_date']) ? api_get_local_time($user['web_agreement_date']) : '-';
|
||||
$mailDate = !empty($user['mail_agreement_date']) ? api_get_local_time($user['mail_agreement_date']) : '-';
|
||||
$url = $pluginPath.'user_list.php?action=resend&user_id='.$user['user_id'].'&'.api_get_cidreq();
|
||||
$link = Display::url(
|
||||
Display::return_icon('inbox.png', $legal->get_lang('ReSendMailAgreementLink')),
|
||||
$url
|
||||
);
|
||||
|
||||
$deleteLink = Display::url(
|
||||
Display::return_icon('delete.png', $legal->get_lang('Delete')),
|
||||
$pluginPath.'user_list.php?action=delete&user_id='.$user['user_id'].'&'.api_get_cidreq()
|
||||
);
|
||||
|
||||
$table->setCellContents($row, 0, $userName);
|
||||
$table->setCellContents($row, 1, $webDate);
|
||||
$table->setCellContents($row, 2, $mailDate);
|
||||
$table->setCellContents($row, 3, $link.' '.$deleteLink);
|
||||
$row++;
|
||||
}
|
||||
}
|
||||
$url = $pluginPath.'start.php?'.api_get_cidreq();
|
||||
|
||||
$interbreadcrumb[] = ["url" => $url, "name" => $legal->get_lang('CourseLegal')];
|
||||
Display::display_header($legal->get_lang('UserList'));
|
||||
|
||||
$table->display();
|
||||
|
||||
Display::display_footer();
|
||||
Reference in New Issue
Block a user