Applied fixed from FlintCI + Codacy

pull/2463/head
root 8 years ago
parent 954b23a95d
commit eff07a3b91
  1. 2
      main/mySpace/myStudents.php
  2. 6
      plugin/notebookteacher/config.php
  3. 2
      plugin/notebookteacher/database.php
  4. 4
      plugin/notebookteacher/install.php
  5. 3
      plugin/notebookteacher/lang/english.php
  6. 3
      plugin/notebookteacher/lang/spanish.php
  7. 4
      plugin/notebookteacher/plugin.php
  8. 42
      plugin/notebookteacher/src/index.php
  9. 134
      plugin/notebookteacher/src/notebookteacher.lib.php
  10. 11
      plugin/notebookteacher/src/notebookteacher_plugin.class.php
  11. 4
      plugin/notebookteacher/start.php
  12. 4
      plugin/notebookteacher/uninstall.php
  13. 2
      plugin/notebookteacher/update.php

@ -429,7 +429,7 @@ if ($notebookTeacherEnable && !empty($student_id) && !empty($course_code)) {
Display::return_icon('notebookteacher.png', get_lang('Notebook'), '', ICON_SIZE_MEDIUM). Display::return_icon('notebookteacher.png', get_lang('Notebook'), '', ICON_SIZE_MEDIUM).
'</a>'; '</a>';
} }
if (api_can_login_as($student_id)) { if (api_can_login_as($student_id)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$student_id.'&sec_token='.$token.'">'. echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$student_id.'&sec_token='.$token.'">'.
Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;'; Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';

@ -7,6 +7,6 @@
* *
* @author Jose Angel Ruiz <desarrollo@nosolored.com> * @author Jose Angel Ruiz <desarrollo@nosolored.com>
*/ */
require_once __DIR__ . '/../../main/inc/global.inc.php'; require_once __DIR__.'/../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php'; require_once api_get_path(LIBRARY_PATH).'plugin.class.php';
require_once api_get_path(SYS_PLUGIN_PATH) . 'notebookteacher/src/notebookteacher_plugin.class.php'; require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/src/notebookteacher_plugin.class.php';

@ -7,7 +7,7 @@
* @package chamilo.plugin.notebookteacher * @package chamilo.plugin.notebookteacher
*/ */
/** /**
* Check if script can be called * Check if script can be called.
*/ */
if (!function_exists('api_get_path')) { if (!function_exists('api_get_path')) {
die('This script must be loaded through the Chamilo plugin installer sequence'); die('This script must be loaded through the Chamilo plugin installer sequence');

@ -7,9 +7,9 @@
* @package chamilo.plugin.notebookteacher * @package chamilo.plugin.notebookteacher
*/ */
/** /**
* Initialization * Initialization.
*/ */
require_once __DIR__ . '/config.php'; require_once __DIR__.'/config.php';
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {
die('You must have admin permissions to install plugins'); die('You must have admin permissions to install plugins');
} }

@ -1,6 +1,7 @@
<?php <?php
$strings['plugin_title'] = "Teacher notes"; $strings['plugin_title'] = "Teacher notes";
$strings['plugin_comment'] = "This plugin allows the teachers of a course to have a shared notebook. Students do not have access."; $strings['plugin_comment'] = "This plugin allows the teachers of a course to have a shared notebook.
Students do not have access.";
$strings['NotebookTeacher'] = "Teacher notes"; $strings['NotebookTeacher'] = "Teacher notes";
$strings['enable_plugin_notebookteacher'] = "Enable plugin"; $strings['enable_plugin_notebookteacher'] = "Enable plugin";
$strings['ToolDisabled'] = "The tool is disabled from the administration"; $strings['ToolDisabled'] = "The tool is disabled from the administration";

@ -1,6 +1,7 @@
<?php <?php
$strings['plugin_title'] = "Notas profesores"; $strings['plugin_title'] = "Notas profesores";
$strings['plugin_comment'] = "Este plugin permite a los profesores de un curso tener un bloc de notas compartido. Alumnos no tienen acceso."; $strings['plugin_comment'] = "Este plugin permite a los profesores de un curso tener un bloc de notas compartido.
Alumnos no tienen acceso.";
$strings['NotebookTeacher'] = "Notas profesores"; $strings['NotebookTeacher'] = "Notas profesores";
$strings['enable_plugin_notebookteacher'] = "Activar plugin"; $strings['enable_plugin_notebookteacher'] = "Activar plugin";
$strings['ToolDisabled'] = "La herramienta está deshabilitada desde la administración"; $strings['ToolDisabled'] = "La herramienta está deshabilitada desde la administración";

@ -8,7 +8,7 @@
* @package chamilo.plugin.notebookteacher * @package chamilo.plugin.notebookteacher
*/ */
/** /**
* Plugin details (must be present) * Plugin details (must be present).
*/ */
require_once __DIR__ . '/config.php'; require_once __DIR__.'/config.php';
$plugin_info = NotebookTeacherPlugin::create()->get_info(); $plugin_info = NotebookTeacherPlugin::create()->get_info();

@ -21,7 +21,7 @@ if ($enable) {
$location = 'index.php?'.api_get_cidreq(); $location = 'index.php?'.api_get_cidreq();
// Additional javascript // Additional javascript
$htmlHeadXtra[] = NotebookTeacher::javascript_notebook(); $htmlHeadXtra[] = NotebookTeacher::javascriptNotebook();
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
function setFocus(){ function setFocus(){
$("#note_title").focus(); $("#note_title").focus();
@ -47,11 +47,17 @@ if ($enable) {
// Tool name // Tool name
if ($action === 'addnote') { if ($action === 'addnote') {
$tool = 'NoteAddNew'; $tool = 'NoteAddNew';
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => $plugin->get_lang('NotebookTeacher')]; $interbreadcrumb[] = [
'url' => 'index.php?'.api_get_cidreq(),
'name' => $plugin->get_lang('NotebookTeacher'),
];
} }
if ($action === 'editnote') { if ($action === 'editnote') {
$tool = 'ModifyNote'; $tool = 'ModifyNote';
$interbreadcrumb[] = ['url' => 'index.php?'.api_get_cidreq(), 'name' => $plugin->get_lang('NotebookTeacher')]; $interbreadcrumb[] = [
'url' => 'index.php?'.api_get_cidreq(),
'name' => $plugin->get_lang('NotebookTeacher')
];
} }
// Displaying the header // Displaying the header
@ -112,9 +118,9 @@ if ($enable) {
} else { } else {
$sql .= " AND session_course_user.status = 0 "; $sql .= " AND session_course_user.status = 0 ";
} }
$sql .= $sort_by_first_name ? $sql .= $sort_by_first_name
' ORDER BY user.firstname, user.lastname' : ? ' ORDER BY user.firstname, user.lastname'
' ORDER BY user.lastname, user.firstname'; : ' ORDER BY user.lastname, user.firstname';
$rs = Database::query($sql); $rs = Database::query($sql);
@ -174,13 +180,13 @@ if ($enable) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
$res = NotebookTeacher::save_note($values); $res = NotebookTeacher::saveNote($values);
if ($res) { if ($res) {
echo Display::return_message(get_lang('NoteAdded'), 'confirmation'); echo Display::return_message(get_lang('NoteAdded'), 'confirmation');
} }
} }
Security::clear_token(); Security::clear_token();
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="index.php">'. echo '<a href="index.php">'.
@ -195,7 +201,7 @@ if ($enable) {
} elseif ($action === 'editnote' && is_numeric($_GET['notebook_id'])) { } elseif ($action === 'editnote' && is_numeric($_GET['notebook_id'])) {
// Action handling: Editing a note // Action handling: Editing a note
if (!empty($_GET['isStudentView']) || api_is_drh()) { if (!empty($_GET['isStudentView']) || api_is_drh()) {
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
exit; exit;
} }
@ -246,7 +252,7 @@ if ($enable) {
} else { } else {
$sql .= " AND session_course_user.status = 0 "; $sql .= " AND session_course_user.status = 0 ";
} }
$sql .= $sort_by_first_name $sql .= $sort_by_first_name
? ' ORDER BY user.firstname, user.lastname' ? ' ORDER BY user.firstname, user.lastname'
: ' ORDER BY user.lastname, user.firstname'; : ' ORDER BY user.lastname, user.firstname';
@ -301,7 +307,7 @@ if ($enable) {
$form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote'); $form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote');
// Setting the defaults // Setting the defaults
$defaults = NotebookTeacher::get_note_information(Security::remove_XSS($_GET['notebook_id'])); $defaults = NotebookTeacher::getNoteInformation(Security::remove_XSS($_GET['notebook_id']));
$form->setDefaults($defaults); $form->setDefaults($defaults);
// Setting the rules // Setting the rules
@ -312,13 +318,13 @@ if ($enable) {
$check = Security::check_token('post'); $check = Security::check_token('post');
if ($check) { if ($check) {
$values = $form->exportValues(); $values = $form->exportValues();
$res = NotebookTeacher::update_note($values); $res = NotebookTeacher::updateNote($values);
if ($res) { if ($res) {
echo Display::return_message(get_lang('NoteUpdated'), 'confirmation'); echo Display::return_message(get_lang('NoteUpdated'), 'confirmation');
} }
} }
Security::clear_token(); Security::clear_token();
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="index.php">'. echo '<a href="index.php">'.
@ -331,12 +337,12 @@ if ($enable) {
} }
} elseif ($action === 'deletenote' && is_numeric($_GET['notebook_id'])) { } elseif ($action === 'deletenote' && is_numeric($_GET['notebook_id'])) {
// Action handling: deleting a note // Action handling: deleting a note
$res = NotebookTeacher::delete_note($_GET['notebook_id']); $res = NotebookTeacher::deleteNote($_GET['notebook_id']);
if ($res) { if ($res) {
echo Display::return_message(get_lang('NoteDeleted'), 'confirmation'); echo Display::return_message(get_lang('NoteDeleted'), 'confirmation');
} }
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
} elseif ( } elseif (
$action === 'changeview' && in_array($_GET['view'], ['creation_date', 'update_date', 'title'])) { $action === 'changeview' && in_array($_GET['view'], ['creation_date', 'update_date', 'title'])) {
@ -365,9 +371,9 @@ if ($enable) {
break; break;
} }
$_SESSION['notebook_view'] = $_GET['view']; $_SESSION['notebook_view'] = $_GET['view'];
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
} else { } else {
NotebookTeacher::display_notes(); NotebookTeacher::displayNotes();
} }
Display::display_footer(); Display::display_footer();
@ -383,7 +389,7 @@ if ($enable) {
Display::return_message($plugin->get_lang('ToolForTeacher')) Display::return_message($plugin->get_lang('ToolForTeacher'))
); );
header('Location: ' . $url); header('Location: '.$url);
} }
} else { } else {
echo $plugin->get_lang('ToolDisabled'); echo $plugin->get_lang('ToolDisabled');

@ -1,5 +1,7 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session;
require_once __DIR__.'/../config.php'; require_once __DIR__.'/../config.php';
/** /**
* This class provides methods for the notebook management. * This class provides methods for the notebook management.
@ -13,27 +15,27 @@ require_once __DIR__.'/../config.php';
class NotebookTeacher class NotebookTeacher
{ {
/** /**
* Constructor * Constructor.
*/ */
public function __construct() public function __construct()
{ {
} }
/** /**
* a little bit of javascript to display a prettier warning when deleting a note * a little bit of javascript to display a prettier warning when deleting a note.
* *
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* *
* @version januari 2009, dokeos 1.8.6 * @version januari 2009, dokeos 1.8.6
* *
* @return string * @return string
*/ */
public static function javascript_notebook() public static function javascriptNotebook()
{ {
return "<script> return "<script>
function confirmation (name) function confirmation (name)
{ {
if (confirm(\" " . get_lang("NoteConfirmDelete")." \"+ name + \" ?\")) if (confirm(\" ".get_lang("NoteConfirmDelete")." \"+ name + \" ?\"))
{return true;} {return true;}
else else
{return false;} {return false;}
@ -42,16 +44,16 @@ class NotebookTeacher
} }
/** /**
* This functions stores the note in the database * This functions stores the note in the database.
* *
* @param array $values * @param array $values
* @param int $userId Optional. The user ID * @param int $userId Optional. The user ID
* @param int $courseId Optional. The course ID + * @param int $courseId Optional. The course ID
* @param int $sessionId Optional. The session ID + * @param int $sessionId Optional. The session ID
* *
* @return bool * @return bool
*/ */
public static function save_note($values, $userId = 0, $courseId = 0, $sessionId = 0) public static function saveNote($values, $userId = 0, $courseId = 0, $sessionId = 0)
{ {
if (!is_array($values) || empty($values['note_title'])) { if (!is_array($values) || empty($values['note_title'])) {
return false; return false;
@ -85,13 +87,13 @@ class NotebookTeacher
} }
/** /**
* @param int $notebook_id * @param int $notebookId
* *
* @return array|mixed * @return array|mixed
*/ */
public static function get_note_information($notebook_id) public static function getNoteInformation($notebookId)
{ {
if (empty($notebook_id)) { if (empty($notebookId)) {
return []; return [];
} }
@ -106,7 +108,7 @@ class NotebookTeacher
session_id AS session_id, session_id AS session_id,
student_id AS student_id student_id AS student_id
FROM $tableNotebook FROM $tableNotebook
WHERE c_id = $courseId AND id = '".intval($notebook_id)."' "; WHERE c_id = $courseId AND id = '".intval($notebookId)."' ";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result) != 1) { if (Database::num_rows($result) != 1) {
return []; return [];
@ -121,7 +123,7 @@ class NotebookTeacher
* *
* @return bool * @return bool
*/ */
public static function update_note($values) public static function updateNote($values)
{ {
if (!is_array($values) or empty($values['note_title'])) { if (!is_array($values) or empty($values['note_title'])) {
return false; return false;
@ -139,7 +141,7 @@ class NotebookTeacher
'session_id' => $sessionId, 'session_id' => $sessionId,
'title' => $values['note_title'], 'title' => $values['note_title'],
'description' => $values['note_comment'], 'description' => $values['note_comment'],
'update_date' => api_get_utc_datetime() 'update_date' => api_get_utc_datetime(),
]; ];
Database::update( Database::update(
@ -148,7 +150,7 @@ class NotebookTeacher
[ [
'c_id = ? AND id = ?' => [ 'c_id = ? AND id = ?' => [
$courseId, $courseId,
$values['notebook_id'] $values['notebook_id'],
], ],
] ]
); );
@ -156,13 +158,13 @@ class NotebookTeacher
} }
/** /**
* @param int $notebook_id * @param int $notebookId
* *
* @return bool * @return bool
*/ */
public static function delete_note($notebook_id) public static function deleteNote($notebookId)
{ {
if (empty($notebook_id) || $notebook_id != strval(intval($notebook_id))) { if (empty($notebookId) || $notebookId != strval(intval($notebookId))) {
return false; return false;
} }
@ -174,8 +176,8 @@ class NotebookTeacher
$sql = "DELETE FROM $tableNotebook $sql = "DELETE FROM $tableNotebook
WHERE WHERE
c_id = $courseId AND c_id = $courseId AND
id = '".intval($notebook_id)."' AND id = '".intval($notebookId)."' AND
user_id = '" . api_get_user_id()."'"; user_id = '".api_get_user_id()."'";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::affected_rows($result) != 1) { if (Database::affected_rows($result) != 1) {
@ -187,14 +189,14 @@ class NotebookTeacher
/** /**
* Display notes. * Display notes.
*/ */
public static function display_notes() public static function displayNotes()
{ {
$plugin = NotebookTeacherPlugin::create(); $plugin = NotebookTeacherPlugin::create();
$_user = api_get_user_info(); $userInfo = api_get_user_info();
if (!isset($_GET['direction'])) { if (!isset($_GET['direction'])) {
$sortDirection = 'ASC'; $sortDirection = 'ASC';
$linkSortDirection = 'DESC'; $linkSortDirection = 'DESC';
} elseif ($_GET['direction'] == 'ASC') { } else if ($_GET['direction'] == 'ASC') {
$sortDirection = 'ASC'; $sortDirection = 'ASC';
$linkSortDirection = 'DESC'; $linkSortDirection = 'DESC';
} else { } else {
@ -212,12 +214,16 @@ class NotebookTeacher
$courseId = $courseInfo['real_id']; $courseId = $courseInfo['real_id'];
$currentAccessUrlId = api_get_current_access_url_id(); $currentAccessUrlId = api_get_current_access_url_id();
$sortByfirstName = api_sort_by_first_name(); $sortByfirstName = api_sort_by_first_name();
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
if (!empty($sessionId)) { if (!empty($sessionId)) {
$tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tableUsers = Database::get_main_table(TABLE_MAIN_USER); $tableUsers = Database::get_main_table(TABLE_MAIN_USER);
$isWesternNameOrder = api_is_western_name_order();
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
user.user_id, ".($is_western_name_order ? "user.firstname, user.lastname" : "user.lastname, user.firstname")." user.user_id, ".($isWesternNameOrder
? "user.firstname, user.lastname"
: "user.lastname, user.firstname")."
FROM $tableSessionCourseUser as session_course_user, FROM $tableSessionCourseUser as session_course_user,
$tableUsers as user "; $tableUsers as user ";
if (api_is_multiple_url_enabled()) { if (api_is_multiple_url_enabled()) {
@ -236,7 +242,9 @@ class NotebookTeacher
} else { } else {
$sql .= " AND session_course_user.status = 0 "; $sql .= " AND session_course_user.status = 0 ";
} }
$sql .= $sortByfirstName ? ' ORDER BY user.firstname, user.lastname' : ' ORDER BY user.lastname, user.firstname'; $sql .= $sortByfirstName
? ' ORDER BY user.firstname, user.lastname'
: ' ORDER BY user.lastname, user.firstname';
$rs = Database::query($sql); $rs = Database::query($sql);
@ -307,11 +315,17 @@ class NotebookTeacher
} }
} }
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=creation_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. echo '<a href="index.php?'.
api_get_cidreq().
'&action=changeview&view=creation_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'.
Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32').'</a>'; Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32').'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=update_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. echo '<a href="index.php?'.
api_get_cidreq().
'&action=changeview&view=update_date&direction='.$linkSortDirection.'&student_id='.$studentId.'">'.
Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32').'</a>'; Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32').'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=changeview&view=title&direction='.$linkSortDirection.'&student_id='.$studentId.'">'. echo '<a href="index.php?'.
api_get_cidreq().
'&action=changeview&view=title&direction='.$linkSortDirection.'&student_id='.$studentId.'">'.
Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>'; Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>';
echo '</div>'; echo '</div>';
@ -364,18 +378,24 @@ class NotebookTeacher
$first = false; $first = false;
} }
// Validation when belongs to a session // Validation when belongs to a session
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); $sessionImg = api_get_session_image($row['session_id'], $userInfo['status']);
$updateValue = ''; $updateValue = '';
if ($row['update_date'] <> $row['creation_date']) { if ($row['update_date'] != $row['creation_date']) {
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); $updateValue = ', '.get_lang('UpdateDate').': '.
Display::dateToStringAgoAndLongDate($row['update_date']);
} }
$userInfo = api_get_user_info($row['user_id']); $userInfo = api_get_user_info($row['user_id']);
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; $author = ', '.get_lang('Teacher').': '.$userInfo['complete_name'];
if (intval($row['user_id']) == api_get_user_id()) { if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.api_get_self().'?'.api_get_cidreq().'action=editnote&notebook_id='.$row['id'].'">'. $actions = '<a href="'.
api_get_self().'?'.
api_get_cidreq().'action=editnote&notebook_id='.$row['id'].'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="'.api_get_self().'?action=deletenote&notebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. $actions .= '<a href="'.
api_get_self().
'?action=deletenote&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
} else { } else {
$actions = ''; $actions = '';
@ -384,7 +404,8 @@ class NotebookTeacher
echo Display::panel( echo Display::panel(
$row['description'], $row['description'],
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', $row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author get_lang('CreationDate').': '.
Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author
); );
} }
} else { } else {
@ -412,21 +433,30 @@ class NotebookTeacher
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
// Validation when belongs to a session // Validation when belongs to a session
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); $sessionImg = api_get_session_image($row['session_id'], $userInfo['status']);
$updateValue = ''; $updateValue = '';
if ($row['update_date'] <> $row['creation_date']) { if ($row['update_date'] != $row['creation_date']) {
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); $updateValue = ', '.get_lang('UpdateDate').': '.
Display::dateToStringAgoAndLongDate($row['update_date']);
} }
$userInfo = api_get_user_info($row['user_id']); $userInfo = api_get_user_info($row['user_id']);
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; $author = ', '.get_lang('Teacher').': '.$userInfo['complete_name'];
if (intval($row['user_id']) == api_get_user_id()) { if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.api_get_self().'?action=editnote&notebook_id='.$row['id'].'&'.api_get_cidreq().'">'. $actions = '<a href="'.api_get_self().
'?action=editnote&notebook_id='.$row['id'].'&'.api_get_cidreq().'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="'.api_get_self().'?action=deletenote&notebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. $actions .= '<a href="'.api_get_self().
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; '?action=deletenote&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon(
'delete.png',
get_lang('Delete'),
'',
ICON_SIZE_SMALL
).'</a>';
} else { } else {
$actions = ''; $actions = '';
} }
@ -434,7 +464,8 @@ class NotebookTeacher
echo Display::panel( echo Display::panel(
$row['description'], $row['description'],
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', $row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author get_lang('CreationDate').': '.
Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author
); );
} }
} }
@ -456,20 +487,24 @@ class NotebookTeacher
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
// Validation when belongs to a session // Validation when belongs to a session
$sessionImg = api_get_session_image($row['session_id'], $_user['status']); $sessionImg = api_get_session_image($row['session_id'], $userInfo['status']);
$updateValue = ''; $updateValue = '';
if ($row['update_date'] <> $row['creation_date']) { if ($row['update_date'] != $row['creation_date']) {
$updateValue = ', '.get_lang('UpdateDate').': '.Display::dateToStringAgoAndLongDate($row['update_date']); $updateValue = ', '.get_lang('UpdateDate').': '.
Display::dateToStringAgoAndLongDate($row['update_date']);
} }
$userInfo = api_get_user_info($row['user_id']); $userInfo = api_get_user_info($row['user_id']);
$author = ', '.get_lang('Teacher').': '.$userInfo['complete_name']; $author = ', '.get_lang('Teacher').': '.$userInfo['complete_name'];
if (intval($row['user_id']) == api_get_user_id()) { if (intval($row['user_id']) == api_get_user_id()) {
$actions = '<a href="'.api_get_self().'?action=editnote&notebook_id='.$row['id'].'&'.api_get_cidreq().'">'. $actions = '<a href="'.api_get_self().
'?action=editnote&notebook_id='.$row['id'].'&'.api_get_cidreq().'">'.
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
$actions .= '<a href="'.api_get_self().'?action=deletenote&notebook_id='.$row['id'].'" onclick="return confirmation(\''.$row['title'].'\');">'. $actions .= '<a href="'.api_get_self().
'?action=deletenote&notebook_id='.$row['id'].
'" onclick="return confirmation(\''.$row['title'].'\');">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>'; Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
} else { } else {
$actions = ''; $actions = '';
@ -478,7 +513,8 @@ class NotebookTeacher
echo Display::panel( echo Display::panel(
$row['description'], $row['description'],
$row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>', $row['title'].$sessionImg.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate').': '.Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author get_lang('CreationDate').': '.
Display::dateToStringAgoAndLongDate($row['creation_date']).$updateValue.$author
); );
} }
} }

@ -29,7 +29,6 @@ class NotebookTeacherPlugin extends Plugin
} }
/** /**
*
* @return StaticPlugin * @return StaticPlugin
*/ */
public static function create() public static function create()
@ -48,7 +47,7 @@ class NotebookTeacherPlugin extends Plugin
$this->install_course_fields_in_all_courses(); $this->install_course_fields_in_all_courses();
$tablesToBeCompared = [ $tablesToBeCompared = [
self::TABLE_NOTEBOOKTEACHER self::TABLE_NOTEBOOKTEACHER,
]; ];
$em = Database::getManager(); $em = Database::getManager();
$cn = $em->getConnection(); $cn = $em->getConnection();
@ -72,7 +71,7 @@ class NotebookTeacherPlugin extends Plugin
copy($srcfile3, $dstfile3); copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4); copy($srcfile4, $dstfile4);
require_once api_get_path(SYS_PLUGIN_PATH) . 'notebookteacher/database.php'; require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/database.php';
} }
/** /**
@ -84,11 +83,11 @@ class NotebookTeacherPlugin extends Plugin
$this->uninstall_course_fields_in_all_courses($this->course_settings); $this->uninstall_course_fields_in_all_courses($this->course_settings);
$tablesToBeDeleted = [ $tablesToBeDeleted = [
TABLE_NOTEBOOKTEACHER TABLE_NOTEBOOKTEACHER,
]; ];
foreach ($tablesToBeDeleted as $tableToBeDeleted) { foreach ($tablesToBeDeleted as $tableToBeDeleted) {
$table = Database::get_main_table($tableToBeDeleted); $table = Database::get_main_table($tableToBeDeleted);
$sql = "DROP TABLE IF EXISTS $tableToBeDeleted"; $sql = "DROP TABLE IF EXISTS $table";
Database::query($sql); Database::query($sql);
} }
$this->manageTab(false); $this->manageTab(false);
@ -118,7 +117,7 @@ class NotebookTeacherPlugin extends Plugin
copy($srcfile3, $dstfile3); copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4); copy($srcfile4, $dstfile4);
Display::display_header(get_lang(ucfirst($tool))); Display::display_header(get_lang(ucfirst(self::TABLE_NOTEBOOKTEACHER)));
echo 'Plugin actualizado'; echo 'Plugin actualizado';
Display::display_footer(); Display::display_footer();
} }

@ -14,7 +14,7 @@ $enable = $plugin->get('enable_plugin_notebookteacher') == 'true';
if ($enable) { if ($enable) {
if (api_is_teacher() || api_is_drh()) { if (api_is_teacher() || api_is_drh()) {
$url = 'src/index.php?'.api_get_cidreq(); $url = 'src/index.php?'.api_get_cidreq();
header('Location: ' . $url); header('Location: '.$url);
exit; exit;
} else { } else {
/** @var \Chamilo\CoreBundle\Entity\Session $session */ /** @var \Chamilo\CoreBundle\Entity\Session $session */
@ -28,7 +28,7 @@ if ($enable) {
Display::return_message($plugin->get_lang('ToolForTeacher')) Display::return_message($plugin->get_lang('ToolForTeacher'))
); );
header('Location: ' . $url); header('Location: '.$url);
} }
} else { } else {
echo $plugin->get_lang('ToolDisabled'); echo $plugin->get_lang('ToolDisabled');

@ -8,7 +8,7 @@
* @package chamilo.plugin.notebookteacher * @package chamilo.plugin.notebookteacher
*/ */
/** /**
* Queries * Queries.
*/ */
require_once __DIR__ . '/config.php'; require_once __DIR__.'/config.php';
NotebookTeacherPlugin::create()->uninstall(); NotebookTeacherPlugin::create()->uninstall();

@ -7,7 +7,7 @@
* @package chamilo.plugin.notebookteacher * @package chamilo.plugin.notebookteacher
*/ */
/** /**
* Initialization * Initialization.
*/ */
require_once __DIR__ . '/config.php'; require_once __DIR__ . '/config.php';
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {

Loading…
Cancel
Save