Files
Xes 73154ae174
Behat tests 1.11.x 🐞 / PHP 7.4 Test on ubuntu-latest (push) Canceled after 0s
PHP-CS-Fixer / composer_install (7.4) (push) Canceled after 0s
Chamilo 1.11.40 (ZIP oficial v1.11.40)
Fuente: https://github.com/chamilo/chamilo-lms/releases/download/v1.11.40/chamilo-1.11.40.zip
sha256: 1cf4bf2cc7bae1ef1a1eff643235db1d552f78ddf4b6dd1e2d2dac9868679439
Snapshot independiente (rama huerfana); diffable vs 1.11.38. vendor incluido.
2026-08-06 17:59:45 +02:00

102 lines
2.6 KiB
PHP

<?php
/* For license terms, see /license.txt */
class Justification extends Plugin
{
protected function __construct()
{
parent::__construct(
'1.2',
'Julio Montoya, Nicolas Ducoulombier',
[
'tool_enable' => 'boolean',
'notification_to_creator_only' => 'boolean',
'access_for_session_admin' => 'boolean',
'default_course_id' => 'text',
]
);
}
/**
* @return $this
*/
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
public function getJustification($id)
{
$id = (int) $id;
$sql = 'SELECT * FROM justification_document WHERE id = '.$id;
$query = Database::query($sql);
return Database::fetch_array($query, 'ASSOC');
}
public function getUserJustificationList($userId)
{
$userId = (int) $userId;
$sql = "SELECT * FROM justification_document_rel_users WHERE user_id = $userId ";
$query = Database::query($sql);
return Database::store_result($query, 'ASSOC');
}
public function getUserJustification($id)
{
$id = (int) $id;
$sql = "SELECT * FROM justification_document_rel_users WHERE id = $id ";
$query = Database::query($sql);
return Database::fetch_array($query, 'ASSOC');
}
public function getList()
{
$sql = 'SELECT * FROM justification_document ORDER BY name ';
$query = Database::query($sql);
return Database::store_result($query, 'ASSOC');
}
/**
* Install.
*/
public function install()
{
$sql = "CREATE TABLE IF NOT EXISTS justification_document (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
code TEXT NULL,
name TEXT NULL,
validity_duration INT,
comment TEXT NULL,
date_manual_on INT
)";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS justification_document_rel_users (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
justification_document_id INT NOT NULL,
file_path VARCHAR(255),
user_id INT,
date_validity DATE
)";
Database::query($sql);
}
public function uninstall()
{
$sql = 'DROP TABLE IF EXISTS justification_document';
Database::query($sql);
$sql = 'DROP TABLE IF EXISTS justification_document_rel_users';
Database::query($sql);
}
}