Alex Aragon 10 years ago
commit 492e4192be
  1. 5
      app/Migrations/Schema/V110/Version20150603181728.php
  2. 34
      app/Migrations/Schema/V111/Version20160418093800.php
  3. 3
      composer.json
  4. 24
      main/course_info/infocours.php
  5. 2
      main/document/document.php
  6. 4
      main/document/edit_document.php
  7. 5
      main/dropbox/index.php
  8. 21
      main/exercice/answer.class.php
  9. 65
      main/exercice/exercise.class.php
  10. 20
      main/exercice/exercise_result.php
  11. 12
      main/exercice/exercise_submit.php
  12. 2
      main/gradebook/certificate_report.php
  13. 18
      main/inc/ajax/user_manager.ajax.php
  14. 1
      main/inc/global.inc.php
  15. 3
      main/inc/lib/add_course.lib.inc.php
  16. 13
      main/inc/lib/api.lib.php
  17. 24
      main/inc/lib/course.lib.php
  18. 2
      main/inc/lib/formvalidator/Element/SelectAjax.php
  19. 120
      main/inc/lib/internationalization.lib.php
  20. 3
      main/inc/lib/message.lib.php
  21. 4
      main/inc/lib/notebook.lib.php
  22. 2
      main/inc/lib/plugin.class.php
  23. 327
      main/inc/lib/ppt2png/DocumentConverter.java.orig
  24. 13
      main/inc/lib/sortable_table.class.php
  25. 8
      main/inc/lib/usermanager.lib.php
  26. 8
      main/inc/lib/userportal.lib.php
  27. 2
      main/inc/local.inc.php
  28. 4608
      main/install/database.sql
  29. 4
      main/install/index.php
  30. 3
      main/lang/brazilian/trad4all.inc.php
  31. 15148
      main/lang/english/trad4all.inc.php
  32. 6
      main/lang/french/trad4all.inc.php
  33. 15150
      main/lang/spanish/trad4all.inc.php
  34. 2
      main/mySpace/company_reports.php
  35. 2
      main/mySpace/company_reports_resumed.php
  36. 4
      main/mySpace/myStudents.php
  37. 2
      main/mySpace/student.php
  38. 2
      main/newscorm/learnpath.class.php
  39. 3
      main/template/default/user_portal/index.tpl
  40. 5
      main/template/default/user_portal/index_grid.tpl
  41. 130
      main/template/default/user_portal/session.tpl
  42. 1
      main/user/user.php
  43. 2
      main/work/work.lib.php
  44. 1
      plugin/ticket/config.php
  45. 7
      plugin/ticket/database.php
  46. 13
      plugin/ticket/lang/english.php
  47. 152
      plugin/ticket/src/categories.php
  48. 52
      plugin/ticket/src/categories_add_user.php
  49. 1
      plugin/ticket/src/course_user_list.php
  50. 20
      plugin/ticket/src/myticket.php
  51. 146
      plugin/ticket/src/new_ticket.php
  52. 413
      plugin/ticket/src/ticket.class.php
  53. 141
      plugin/ticket/src/ticket_details.php
  54. 22
      plugin/ticket/src/ticket_plugin.class.php
  55. 34
      src/Chamilo/CoreBundle/EventListener/LegacyLoginListener.php
  56. 89
      src/Chamilo/CoreBundle/EventListener/LocaleListener.php
  57. 14
      src/Chamilo/CoreBundle/EventListener/UserLocaleListener.php
  58. 12
      src/Chamilo/CoreBundle/Resources/config/services.yml
  59. 25
      src/Chamilo/CourseBundle/Entity/CQuiz.php
  60. 9
      user_portal.php
  61. 22
      web/.htaccess

@ -73,7 +73,10 @@ class Version20150603181728 extends AbstractMigrationChamilo
$this->addSql("DELETE FROM c_item_property WHERE c_id = 0");
// Remove inconsistencies about non-existing users
$this->addSql("DELETE FROM course_rel_user WHERE user_id = 0");
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)');
$this->addSql("DELETE FROM c_item_property WHERE c_id NOT IN (SELECT id FROM course)");
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course(id)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181330D47E9 FOREIGN KEY (to_group_id) REFERENCES c_group_info (iid)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C1819C859CC3 FOREIGN KEY (insert_user_id) REFERENCES user (id)');

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160418093800
* Add save_correct_answers column to c_quiz table
* @package Application\Migrations\Schema\V111
*/
class Version20160418093800 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$cQuizTable = $schema->getTable('c_quiz');
$cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

@ -142,7 +142,8 @@
"a2lix/translation-form-bundle": "~2.0",
"knplabs/doctrine-behaviors": "~1.1",
"lunetics/locale-bundle": "^2.4",
"theodo-evolution/session-bundle": "1.0.*"
"theodo-evolution/session-bundle": "1.0.*",
"jimmiw/php-time-ago": "^0.4.11"
},
"require-dev": {
"behat/behat": "@stable",

@ -178,6 +178,13 @@ $form->addElement(
);
$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
$group = array(
$form->createElement('radio', 'show_course_in_user_language', null, get_lang('Yes'), 1),
$form->createElement('radio', 'show_course_in_user_language', null, get_lang('No'), 2),
);
$form->addGroup($group, '', array(get_lang("ShowCourseInUserLanguage")), '');
$form->addText('department_name', get_lang('Department'), false);
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');
@ -204,8 +211,12 @@ $form->addHtml('
');
$form->addHidden('cropResult', '');
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
//$form->addElement('html', '<div class="form-group "><div class="col-md-2"></div> <div class="col-md-8 help-image">'.get_lang('UniqueAnswerImagePreferredSize200x150').'</div></div>');
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
'filetype',
$allowed_picture_types
);
$form->addElement('checkbox', 'delete_picture', null, get_lang('DeletePicture'));
if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
@ -213,8 +224,7 @@ if (api_get_setting('pdf_export_watermark_by_course') == 'true') {
$form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, array('size' => '60'));
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.
Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<div class="row"><div class="formw"><a href="'.$url.'">'.$url.' '.$delete_url.'</a></div></div>');
}
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
@ -453,12 +463,14 @@ $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
$form->addElement('html', '</div></div>');
// Document settings
$form->addElement('html', '<div><h3>'.Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Documents')).'</h3><div>');
$form->addElement(
'html',
'<div><h3>'.Display::return_icon('folder.png', Security::remove_XSS(get_lang('Documents')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('Documents')).'</h3><div>'
);
$group = array(
$form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1),
$form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2),
);
$form->addGroup($group, '', array(get_lang("ShowSystemFolders")), '');
$form->addButtonSave(get_lang('SaveSettings'), 'submit_save');

@ -1784,7 +1784,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) {
// Last edit date
$last_edit_date = api_get_local_time($document_data['lastedit_date']);
$display_date = date_to_str_ago($last_edit_date).
$display_date = date_to_str_ago($document_data['lastedit_date']).
' <div class="muted"><small>'.$last_edit_date."</small></div>";
$row[] = $invisibility_span_open.$display_date.$invisibility_span_close;

@ -475,8 +475,8 @@ if ($owner_id == api_get_user_id() ||
if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) {
// Updated on field
$last_edit_date = api_get_local_time($last_edit_date);
$display_date = date_to_str_ago($last_edit_date).' <span class="dropbox_date">'.api_format_date($last_edit_date).'</span>';
$display_date = date_to_str_ago($last_edit_date).
' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>';
$form->addElement('static', null, get_lang('UpdatedOn'), $display_date);
}

@ -382,7 +382,7 @@ if ($action != 'add') {
$dropbox_file_data[] = $dropbox_file->author;
$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
$dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.
$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
api_format_date($last_upload_date).'</span>';
$action_icons = check_number_feedback($dropbox_file->id, $number_feedback).' '.get_lang('Feedback').'
@ -554,7 +554,8 @@ if ($action != 'add') {
$receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma.
$dropbox_file_data[] = $receivers_celldata;
$last_upload_date = api_get_local_time($dropbox_file->last_upload_date);
$dropbox_file_data[] = date_to_str_ago($last_upload_date).'<br /><span class="dropbox_date">'.api_format_date($last_upload_date).'</span>';
$dropbox_file_data[] = date_to_str_ago($dropbox_file->last_upload_date).'<br /><span class="dropbox_date">'.
api_format_date($last_upload_date).'</span>';
//$dropbox_file_data[] = $dropbox_file->author;
$receivers_celldata = '';

@ -832,4 +832,25 @@ class Answer
</script>";
}
/**
* Check if a answer is correct by an answer auto id
* @param $needle int The answer auto id
* @return bool
*/
public function isCorrectByAutoId($needle)
{
$key = 0;
foreach ($this->autoId as $autoIdKey => $autoId) {
if ($autoId == $needle) {
$key = $autoIdKey;
}
}
if (!$key) {
return false;
}
return $this->isCorrect($key) ? true : false;
}
}

@ -35,6 +35,7 @@ class Exercise
public $course;
public $course_id;
public $propagate_neg;
public $saveCorrectAnswers;
public $review_answers;
public $randomByCat;
public $text_when_finished;
@ -91,6 +92,7 @@ class Exercise
$this->results_disabled = 1;
$this->expired_time = '0000-00-00 00:00:00';
$this->propagate_neg = 0;
$this->saveCorrectAnswers = 0;
$this->review_answers = false;
$this->randomByCat = 0;
$this->text_when_finished = '';
@ -152,6 +154,7 @@ class Exercise
$this->attempts = $object->max_attempt;
$this->feedback_type = $object->feedback_type;
$this->propagate_neg = $object->propagate_neg;
$this->saveCorrectAnswers = $object->save_correct_answers;
$this->randomByCat = $object->random_by_category;
$this->text_when_finished = $object->text_when_finished;
$this->display_category_name = $object->display_category_name;
@ -1133,6 +1136,14 @@ class Exercise
return $this->propagate_neg;
}
/**
* @return int
*/
public function selectSaveCorrectAnswers()
{
return $this->saveCorrectAnswers;
}
/**
* Selects questions randomly in the question list
*
@ -1275,6 +1286,14 @@ class Exercise
$this->propagate_neg = $value;
}
/**
* @param $value int
*/
public function updateSaveCorrectAnswers($value)
{
$this->saveCorrectAnswers = $value;
}
/**
* @param $value
*/
@ -1523,6 +1542,7 @@ class Exercise
$random_answers = $this->random_answers;
$active = $this->active;
$propagate_neg = $this->propagate_neg;
$saveCorrectAnswers = isset($this->saveCorrectAnswers) && $this->saveCorrectAnswers ? true : false;
$review_answers = isset($this->review_answers) && $this->review_answers ? 1 : 0;
$randomByCat = intval($this->randomByCat);
$text_when_finished = $this->text_when_finished;
@ -1573,6 +1593,7 @@ class Exercise
'max_attempt' => $attempts,
'expired_time' => $expired_time,
'propagate_neg' => $propagate_neg,
'save_correct_answers' => $saveCorrectAnswers,
'review_answers' => $review_answers,
'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished,
@ -1643,7 +1664,8 @@ class Exercise
'random_by_category' => $randomByCat,
'text_when_finished' => $text_when_finished,
'display_category_name' => $display_category_name,
'pass_percentage' => $pass_percentage
'pass_percentage' => $pass_percentage,
'save_correct_answers' => $saveCorrectAnswers
];
$this->id = Database::insert($TBL_EXERCISES, $params);
@ -2154,6 +2176,11 @@ class Exercise
//$check_option=$this->selectType();
$diplay = 'block';
$form->addElement('checkbox', 'propagate_neg', null, get_lang('PropagateNegativeResults'));
$form->addCheckBox(
'save_correct_answers',
null,
get_lang('Save the correct answers for the next attempt')
);
$form->addElement('html','<div class="clear">&nbsp;</div>');
$form->addElement('checkbox', 'review_answers', null, get_lang('ReviewAnswers'));
@ -2275,6 +2302,7 @@ class Exercise
$defaults['exerciseFeedbackType'] = $this->selectFeedbackType();
$defaults['results_disabled'] = $this->selectResultsDisabled();
$defaults['propagate_neg'] = $this->selectPropagateNeg();
$defaults['save_correct_answers'] = $this->selectSaveCorrectAnswers();
$defaults['review_answers'] = $this->review_answers;
$defaults['randomByCat'] = $this->selectRandomByCat();
$defaults['text_when_finished'] = $this->selectTextWhenFinished();
@ -2366,6 +2394,7 @@ class Exercise
$this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
$this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
$this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
$this->updateSaveCorrectAnswers($form->getSubmitValue('save_correct_answers'));
$this->updateRandomByCat($form->getSubmitValue('randomByCat'));
$this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
$this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
@ -8238,4 +8267,38 @@ class Exercise
}
return 1;
}
/**
* Get the correct answers in all attempts
* @param int $learnPathId
* @param int $learnPathItemId
* @return array
*/
public function getCorrectAnswersInAllAttempts($learnPathId = 0, $learnPathItemId = 0)
{
$attempts = Event::getExerciseResultsByUser(
api_get_user_id(),
$this->id,
api_get_course_int_id(),
api_get_session_id(),
$learnPathId,
$learnPathItemId,
'asc'
);
$corrects = [];
foreach ($attempts as $attempt) {
foreach ($attempt['question_list'] as $answer) {
$objAnswer = new Answer($answer['question_id']);
$isCorrect = $objAnswer->isCorrectByAutoId($answer['answer']);
if ($isCorrect) {
$corrects[$answer['question_id']][] = $answer;
}
}
}
return $corrects;
}
}

@ -144,6 +144,26 @@ if ($objExercise->selectAttempts() > 0) {
Display::display_footer();
}
exit;
} else {
$attempt_count++;
$remainingAttempts = $objExercise->selectAttempts() - $attempt_count;
if ($remainingAttempts) {
$attemptButton = Display::toolbarButton(
get_lang('AnotherAttempt'),
api_get_patth(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&' . http_build_query([
'exerciseId' => $objExercise->id
]),
'pencil-square-o',
'info'
);
$attemptMessage = sprintf(get_lang('RemainingXAttempts'), $remainingAttempts);
Display::display_normal_message(
sprintf("<p>%s</p> %s", $attemptMessage, $attemptButton),
false
);
}
}
}

@ -1116,7 +1116,17 @@ if (!empty($error)) {
}
}
$user_choice = isset($attempt_list[$questionId]) ? $attempt_list[$questionId] : null;
$user_choice = null;
if (isset($attempt_list[$questionId])) {
$user_choice = $attempt_list[$questionId];
} elseif ($objExercise->saveCorrectAnswers) {
$correctAnswers = $objExercise->getCorrectAnswersInAllAttempts($learnpath_id, $learnpath_item_id);
if (isset($correctAnswers[$questionId])) {
$user_choice = $correctAnswers[$questionId];
}
}
$remind_highlight = '';

@ -17,7 +17,7 @@ $this_section = SECTION_TRACKING;
api_block_anonymous_users();
$interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH) . "mySpace/index.php?".api_get_cidreq(),
"url" => api_is_student_boss()?"#":api_get_path(WEB_CODE_PATH) . "mySpace/index.php?".api_get_cidreq(),
"name" => get_lang("MySpace")
);

@ -7,6 +7,24 @@ require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'get_user_like':
$query = $_REQUEST['q'];
$conditions = [
'username' => $query,
'firstname' => $query,
'lastname' => $query,
];
$users = UserManager::get_user_list_like($conditions, [], false, 'OR');
$result = [];
if (!empty($users)) {
foreach ($users as $user) {
$result[] = ['id' => $user['id'], 'text' => $user['complete_name'].' ('.$user['username'].')'];
}
$result['items'] = $result;
}
echo json_encode($result);
break;
case 'get_user_popup':
$user_info = api_get_user_info($_REQUEST['user_id']);
$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';

@ -437,6 +437,7 @@ if (!empty($valid_languages)) {
} else {
$language_interface = api_get_setting('platformLanguage');
}
if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
$language_interface = api_get_language_from_type($language_priority3);

@ -689,7 +689,8 @@ class AddCourse
'default' => api_get_setting('allow_public_certificates') === 'true' ? 1 : '',
'category' =>'certificates'
],
'documents_default_visibility' => ['default' =>'visible', 'category' =>'document']
'documents_default_visibility' => ['default' =>'visible', 'category' =>'document'],
'show_course_in_user_language' => ['default' => 2],
];
$counter = 1;

@ -1392,7 +1392,7 @@ function api_get_user_info(
) {
if (empty($user_id)) {
$userFromSession = Session::read('_user');
$userFromSession = Session::read('_user');
if (isset($userFromSession)) {
return _api_format_user($userFromSession);
}
@ -4245,6 +4245,7 @@ function api_get_language_from_type($lang_type)
global $_course;
$cidReq = null;
if (empty($_course)) {
// Code modified because the local.inc.php file it's declarated after this work
// causing the function api_get_course_info() returns a null value
$cidReq = isset($_GET["cidReq"]) ? Database::escape_string($_GET["cidReq"]) : null;
@ -4257,8 +4258,16 @@ function api_get_language_from_type($lang_type)
}
}
$_course = api_get_course_info($cidReq);
if (isset($_course['language']) && !empty($_course['language']))
if (isset($_course['language']) && !empty($_course['language'])) {
$return = $_course['language'];
$showCourseInUserLanguage = api_get_course_setting('show_course_in_user_language');
if ($showCourseInUserLanguage == 1) {
$userInfo = api_get_user_info();
if (isset($userInfo['language'])) {
$return = $userInfo['language'];
}
}
}
break;
default:
$return = false;

@ -3540,6 +3540,7 @@ class CourseManager
$result = Database::query($sql);
$html = null;
$courseCount = 0;
$items = [];
while ($row = Database::fetch_array($result)) {
// We simply display the title of the category.
$params = array(
@ -3556,10 +3557,14 @@ class CourseManager
$load_dirs
);
$html .= self::course_item_parent(
$item = self::course_item_parent(
self::course_item_html($params, true),
$courseInCategory['html']
);
$html .= $item;
$items[] = $item;
$courseCount += $courseInCategory['course_count'];
}
@ -3567,10 +3572,16 @@ class CourseManager
$courseInCategory = self::displayCoursesInCategory(0, $load_dirs);
$html .= $courseInCategory['html'];
if (!empty($courseInCategory['items'])) {
$items = array_merge($items, $courseInCategory['items']);
}
$courseCount += $courseInCategory['course_count'];
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
@ -3949,6 +3960,7 @@ class CourseManager
$result = Database::query($sql);
$html = '';
$items = [];
$course_list = array();
$showCustomIcon = api_get_setting('course_images_in_courses_list');
@ -4067,11 +4079,14 @@ class CourseManager
if (empty($user_category_id)) {
$isSubContent = false;
}
$html .= self::course_item_html($params, $isSubContent);
$item = self::course_item_html($params, $isSubContent);
$html .= $item;
$items[] = $item;
}
return [
'html' => $html,
'items' => $items,
'course_count' => $courseCount
];
}
@ -5356,7 +5371,8 @@ class CourseManager
'pdf_export_watermark_text',
'show_system_folders',
'exercise_invisible_in_session',
'enable_forum_auto_launch'
'enable_forum_auto_launch',
'show_course_in_user_language'
);
$allowLPReturnLink = api_get_setting('allow_lp_return_link');
@ -5766,7 +5782,7 @@ class CourseManager
$result[$content['value']] = $content['content'];
}
$form->addElement('advmultiselect', 'users', get_lang('Users'), $result);
return $form->addElement('advmultiselect', 'users', get_lang('Users'), $result);
}
/**

@ -65,7 +65,7 @@ class SelectAjax extends HTML_QuickForm_select
$id = $this->getAttribute('name');
$this->setAttribute('id', $id);
}
// URL must return ajax json_encode arrady [items => [['id'=>1, 'text'='content']]
$url = $this->getAttribute('url');
if (!$url) {

@ -658,125 +658,11 @@ function api_format_date($time, $format = null, $language = null)
* @author Julio Montoya
*/
function date_to_str_ago($date)
function date_to_str_ago($date, $timeZone = 'UTC')
{
static $initialized = false;
static $today, $yesterday;
static $min_decade, $min_year, $min_month, $min_week, $min_day, $min_hour, $min_minute;
static $min_decades, $min_years, $min_months, $min_weeks, $min_days, $min_hours, $min_minutes;
static $sec_time_time, $sec_time_sing, $sec_time_plu;
$timeAgo = new TimeAgo($timeZone, api_get_language_isocode());
$system_timezone = date_default_timezone_get();
date_default_timezone_set(_api_get_timezone());
if (!$initialized) {
$today = get_lang('Today');
$yesterday = get_lang('Yesterday');
$min_decade = get_lang('MinDecade');
$min_year = get_lang('MinYear');
$min_month = get_lang('MinMonth');
$min_week = get_lang('MinWeek');
$min_day = get_lang('MinDay');
$min_hour = get_lang('MinHour');
$min_minute = get_lang('MinMinute');
$min_decades = get_lang('MinDecades');
$min_years = get_lang('MinYears');
$min_months = get_lang('MinMonths');
$min_weeks = get_lang('MinWeeks');
$min_days = get_lang('MinDays');
$min_hours = get_lang('MinHours');
$min_minutes = get_lang('MinMinutes');
// original 1
//$sec_time=array('century'=>3.1556926*pow(10,9),'decade'=>315569260,'year'=>31556926,'month'=>2629743.83,'week'=>604800,'day'=>86400,'hour'=>3600,'minute'=>60,'second'=>1);
//$sec_time=array(get_lang('MinDecade')=>315569260,get_lang('MinYear')=>31556926,get_lang('MinMonth')=>2629743.83,get_lang('MinWeek')=>604800,get_lang('MinDay')=>86400,get_lang('MinHour')=>3600,get_lang('MinMinute')=>60);
$sec_time_time = array(315569260, 31556926, 2629743.83, 604800, 86400, 3600, 60);
$sec_time_sing = array($min_decade, $min_year, $min_month, $min_week, $min_day, $min_hour, $min_minute);
$sec_time_plu = array($min_decades, $min_years, $min_months, $min_weeks, $min_days, $min_hours, $min_minutes);
$initialized = true;
}
$dst_date = is_string($date) ? strtotime($date) : $date;
// For avoiding calling date() several times
$date_array = date('s/i/G/j/n/Y', $dst_date);
$date_split = explode('/', $date_array);
$dst_s = $date_split[0];
$dst_m = $date_split[1];
$dst_h = $date_split[2];
$dst_day = $date_split[3];
$dst_mth = $date_split[4];
$dst_yr = $date_split[5];
$dst_date = mktime($dst_h, $dst_m, $dst_s, $dst_mth, $dst_day, $dst_yr);
$time = $offset = time() - $dst_date; // Seconds between current days and today.
// Here start the functions sec_to_str()
$act_day = date('d');
$act_mth = date('n');
$act_yr = date('Y');
if ($dst_day == $act_day && $dst_mth == $act_mth && $dst_yr == $act_yr) {
return $today;
}
if ($dst_day == $act_day - 1 && $dst_mth == $act_mth && $dst_yr == $act_yr) {
return $yesterday;
}
$str_result = array();
$time_result = array();
$key_result = array();
$str = '';
$i = 0;
for ($i = 0; $i < count($sec_time_time); $i++) {
$seconds = $sec_time_time[$i];
if ($seconds > $time) {
continue;
}
$current_value = intval($time/$seconds);
if ($current_value != 1) {
$date_str = $sec_time_plu[$i];
} else {
$date_str = $sec_time_sing[$i];
}
$key_result[] = $sec_time_sing[$i];
$str_result[] = $current_value.' '.$date_str;
$time_result[] = $current_value;
$str .= $current_value.$date_str;
$time %= $seconds;
}
if (!empty($key_result)) {
if ($key_result[0] == $min_day && $key_result[1]== $min_minute) {
$key_result[1] = ' 0 '.$min_hours;
$str_result[0] = $time_result[0].' '.$key_result[0];
$str_result[1] = $key_result[1];
}
if ($key_result[0] == $min_year && ($key_result[1] == $min_day || $key_result[1] == $min_week)) {
$key_result[1] = ' 0 '.$min_months;
$str_result[0] = $time_result[0].' '.$key_result[0];
$str_result[1] = $key_result[1];
}
}
if (!empty($str_result)) {
if (!empty($str_result[1])) {
$str = $str_result[0].', '.$str_result[1];
} else {
$str = $str_result[0];
}
}
date_default_timezone_set($system_timezone);
return $str;
return $timeAgo->inWords($date);
}
/**

@ -1193,7 +1193,8 @@ class MessageManager
if (!empty($topic['update_date']) &&
$topic['update_date'] != '0000-00-00 00:00:00'
) {
$date .= '<div class="message-group-date" > <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
$date .= '<div class="message-group-date" >
<i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
}
} else {
$date .= '<div class="message-group-date"> <i>'.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</i></div>';

@ -274,7 +274,7 @@ class NotebookManager
$updateValue = '';
if ($row['update_date'] <> $row['creation_date']) {
$updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
$updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($row['update_date']) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
}
$actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' .
@ -285,7 +285,7 @@ class NotebookManager
echo Display::panel(
$row['description'],
$row['title'] . $session_img.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue."</span>"
get_lang('CreationDate') . ': ' . date_to_str_ago($row['creation_date']) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue."</span>"
);
}
}

@ -325,6 +325,7 @@ class Plugin
//1. Loading english if exists
$english_path = $root.$plugin_name."/lang/english.php";
if (is_readable($english_path)) {
$strings = array();
include $english_path;
@ -332,6 +333,7 @@ class Plugin
}
$path = $root.$plugin_name."/lang/$language_interface.php";
//2. Loading the system language
if (is_readable($path)) {
include $path;

@ -1,327 +0,0 @@
import java.awt.Event;
//import sun.text.Normalizer;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
import com.sun.star.bridge.XBridge;
import com.sun.star.bridge.XBridgeFactory;
import com.sun.star.connection.NoConnectException;
import com.sun.star.connection.XConnection;
import com.sun.star.connection.XConnector;
import com.sun.star.container.XNamed;
import com.sun.star.document.XExporter;
import com.sun.star.document.XFilter;
import com.sun.star.drawing.XDrawPage;
import com.sun.star.drawing.XDrawPages;
import com.sun.star.drawing.XDrawPagesSupplier;
import com.sun.star.frame.XComponentLoader;
import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
/**
* The class <CODE>DocumentConverter</CODE> allows you to convert all
* documents in a given directory and in its subdirectories to a given type. A
* converted document will be created in the same directory as the origin
* document.
*
*/
public class DocumentConverter {
/**
* Containing the loaded documents
*/
static XComponentLoader xcomponentloader = null;
/**
* Connecting to the office with the component UnoUrlResolver and calling
* the static method traverse
*
* @param args
* The array of the type String contains the directory, in which
* all files should be converted, the favoured converting type
* and the wanted extension
*/
public static void main(String args[]) {
String cnx, ftpuser, host, port, url, ftpPasswd, destinationFolder, remoteFolderFullPath, remoteFolder;
int width, height;
try {
host = args[0];
port = args[1];
url = args[2];
destinationFolder = args[3];
width = Integer.parseInt(args[4]);
height = Integer.parseInt(args[5]);
if(args.length == 8){
ftpuser = args[6];
ftpPasswd = args[7];
}
else{
ftpuser = "";
ftpPasswd = "";
}
if(host.equals("localhost")){
String prefix = "file://";
if(url.charAt(0)!='/')
prefix += '/';
url = prefix+url;
remoteFolder = destinationFolder;
remoteFolderFullPath = prefix;
}
else {
remoteFolderFullPath = "file:///home/"+ftpuser+"/";
remoteFolder = url.replace('/','_');
remoteFolder = removeAccents(remoteFolder);
}
cnx = "socket,host="+host+",port="+port;
XComponentContext xComponentContext = com.sun.star.comp.helper.Bootstrap
.createInitialComponentContext(null);
XComponentContext xRemoteContext = xComponentContext;
Object x = xRemoteContext
.getServiceManager()
.createInstanceWithContext(
"com.sun.star.connection.Connector", xRemoteContext);
XConnector xConnector = (XConnector) UnoRuntime.queryInterface(
XConnector.class, x);
XConnection connection = xConnector.connect(cnx);
//if (connection == null)
//System.out.println("Connection is null");
x = xRemoteContext.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", xRemoteContext);
XBridgeFactory xBridgeFactory = (XBridgeFactory) UnoRuntime
.queryInterface(XBridgeFactory.class, x);
// this is the bridge that you will dispose
XBridge bridge = xBridgeFactory.createBridge("", "urp", connection,null);
/*XComponent xComponent = (XComponent) UnoRuntime.queryInterface(
XComponent.class, bridge);*/
// get the remote instance
x = bridge.getInstance("StarOffice.ServiceManager");
// Query the initial object for its main factory interface
XMultiComponentFactory xMultiComponentFactory = (XMultiComponentFactory) UnoRuntime
.queryInterface(XMultiComponentFactory.class, x);
XPropertySet xProperySet = (XPropertySet) UnoRuntime
.queryInterface(XPropertySet.class, xMultiComponentFactory);
// Get the default context from the office server.
Object oDefaultContext = xProperySet
.getPropertyValue("DefaultContext");
// Query for the interface XComponentContext.
xComponentContext = (XComponentContext) UnoRuntime.queryInterface(
XComponentContext.class, oDefaultContext);
while (xcomponentloader == null) {
try {
xcomponentloader = (XComponentLoader) UnoRuntime
.queryInterface(
XComponentLoader.class,
xMultiComponentFactory
.createInstanceWithContext(
"com.sun.star.frame.Desktop",
xComponentContext));
//System.out.println("Loading document "+url);
FTPClient ftp = new FTPClient();
if(!host.equals("localhost")){
//ftp connexion
ftp.setRemoteHost(host);
ftp.connect();
ftp.login(ftpuser, ftpPasswd);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.setType(FTPTransferType.BINARY);
try{
ftp.mkdir(remoteFolder);
}catch(Exception e){}
ftp.chdir(remoteFolder);
ftp.put(url,"presentation.ppt");
url = remoteFolderFullPath+"/"+remoteFolder+"/presentation.ppt";
}
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = new PropertyValue();
loadProps[0].Name = "Hidden";
loadProps[0].Value = new Boolean(true);
// open the document
XComponent component = xcomponentloader
.loadComponentFromURL(url,
"_blank", 0, loadProps);
//System.out.println("Document Opened");
// filter
loadProps = new PropertyValue[4];
// type of image
loadProps[0] = new PropertyValue();
loadProps[0].Name = "MediaType";
loadProps[0].Value = "image/png";
// Height and width
PropertyValue[] filterDatas = new PropertyValue[4];
for(int i = 0; i<4 ; i++){
filterDatas[i] = new PropertyValue();
}
filterDatas[0].Name = "PixelWidth";
filterDatas[0].Value = new Integer(width);
filterDatas[1].Name = "PixelHeight";
filterDatas[1].Value = new Integer(height);
filterDatas[2].Name = "LogicalWidth";
filterDatas[2].Value = new Integer(2000);
filterDatas[3].Name = "LogicalHeight";
filterDatas[3].Value = new Integer(2000);
XDrawPagesSupplier pagesSupplier = (XDrawPagesSupplier) UnoRuntime
.queryInterface(XDrawPagesSupplier.class, component);
//System.out.println(pagesSupplier.toString());
XDrawPages pages = pagesSupplier.getDrawPages();
int nbPages = pages.getCount();
for (int i = 0; i < nbPages; i++) {
XDrawPage page = (XDrawPage) UnoRuntime.queryInterface(
com.sun.star.drawing.XDrawPage.class, pages
.getByIndex(i));
XNamed xPageName = (XNamed)UnoRuntime.queryInterface(XNamed.class,page);
xPageName.setName("slide"+(i+1));
//if(!xPageName.getName().equals("slide"+(i+1)) && !xPageName.getName().equals("page"+(i+1)))
//xPageName.setName((i+1)+"-"+xPageName.getName());
Object GraphicExportFilter = xMultiComponentFactory
.createInstanceWithContext(
"com.sun.star.drawing.GraphicExportFilter",
xComponentContext);
XExporter xExporter = (XExporter) UnoRuntime
.queryInterface(XExporter.class,
GraphicExportFilter);
XComponent xComp = (XComponent) UnoRuntime
.queryInterface(XComponent.class, page);
xExporter.setSourceDocument(xComp);
loadProps[1] = new PropertyValue();
loadProps[1].Name = "URL";
loadProps[1].Value = remoteFolderFullPath+remoteFolder+"/"+xPageName.getName()+".png";
loadProps[2] = new PropertyValue();
loadProps[2].Name = "FilterData";
loadProps[2].Value = filterDatas;
loadProps[3] = new PropertyValue();
loadProps[3].Name = "Quality";
loadProps[3].Value = new Integer(100);
XFilter xFilter = (XFilter) UnoRuntime.queryInterface(XFilter.class, GraphicExportFilter);
xFilter.filter(loadProps);
System.out.println(xPageName.getName()+".png");
//System.out.println("Page saved to url "+loadProps[1].Value);
}
if(!host.equals("localhost")){
String[] files = ftp.dir();
for (int i = 0; i < files.length; i++){
//System.out.println("Transfer of "+files[i]+ "to "+destinationFolder+"/"+files[i]);
if(!files[i].equals("presentation.ppt"))
ftp.get(destinationFolder+"/"+files[i],files[i]);
ftp.delete(files[i]);
}
ftp.chdir("..");
ftp.rmdir(remoteFolder);
ftp.quit();
}
//System.out.println("Closing Document");
component.dispose();
//System.out.println("Document close");
System.exit(0);
}
catch (NoConnectException e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
}
}
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
System.exit(255);
}
}
public static String removeAccents(String text) {
/*
String newText = Normalizer.decompose(text, false, 0)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");*/
/*
newText = newText.replace('\u00B4','_');
newText = newText.replace('\u02CA','_');
newText = newText.replace('\u02B9','_');
newText = newText.replace('\u02BC','_');
newText = newText.replace('\u02B9','_');
newText = newText.replace('\u03D8','_');
newText = newText.replace('\u0374','_');
newText = newText.replace('\u0384','_');
newText = newText.replace('\u055A','_');
*/
/*
newText = newText.replace('\u2019','_');
newText = newText.replace('\u00B4','_');
newText = newText.replace('\u055A','_');
newText = newText.replace('?','_');
newText = newText.replace('\'','_');
newText = newText.replace(' ','_');
return newText;*/
return java.text.Normalizer.normalize(text, java.text.Normalizer.Form.NFD).replaceAll("[\u0300-\u036F]", "");
}
public boolean handleEvent(Event evt) {
// Traitement de l'evenement de fin de programme
if ( evt.id == evt.WINDOW_DESTROY ) {
System.exit(0) ;
return true ;
}
return false ;
}
}

@ -245,7 +245,6 @@ class SortableTable extends HTML_Table
$empty_table = false;
$content = $this->get_table_html();
if ($this->get_total_number_of_items() == 0) {
$cols = $this->getColCount();
$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);
@ -954,10 +953,18 @@ class SortableTable extends HTML_Table
*/
public function get_table_data($from = null, $per_page = null, $column = null, $direction = null, $sort = null)
{
$data = [];
if (!is_null($this->get_data_function)) {
return call_user_func($this->get_data_function, $from, $this->per_page, $this->column, $this->direction);
$data = call_user_func(
$this->get_data_function,
$from,
$this->per_page,
$this->column,
$this->direction
);
}
return array();
return $data;
}

@ -1282,7 +1282,7 @@ class UserManager
/**
* Get a list of users of which the given conditions match with an = 'cond'
* @param array $conditions a list of condition (exemple : status=>STUDENT)
* @param array $conditions a list of condition (example : status=>STUDENT)
* @param array $order_by a list of fields on which sort
* @return array An array with all users of the platform.
* @todo optional course code parameter, optional sorting parameters...
@ -1312,6 +1312,7 @@ class UserManager
}
$sql_result = Database::query($sql_query);
while ($result = Database::fetch_array($sql_result)) {
$result['complete_name'] = api_get_person_name($result['firstname'], $result['lastname']);
$return_array[] = $result;
}
return $return_array;
@ -1351,6 +1352,11 @@ class UserManager
}
$sql_result = Database::query($sql_query);
while ($result = Database::fetch_array($sql_result)) {
$result['complete_name'] = api_get_person_name(
$result['firstname'],
$result['lastname']
);
$return_array[] = $result;
}
return $return_array;

@ -1043,6 +1043,7 @@ class IndexManager
$sessionCount = 0;
$courseCount = 0;
$items = [];
// If we're not in the history view...
if (!isset($_GET['history'])) {
// Display special courses.
@ -1050,6 +1051,7 @@ class IndexManager
$user_id,
$this->load_directories_preview
);
// Display courses.
$courses = CourseManager::returnCourses(
$user_id,
@ -1296,9 +1298,7 @@ class IndexManager
$sessionParams['id'] = $session_id;
$sessionParams['show_link_to_session'] = !api_is_drh() && $sessionTitleLink;
$sessionParams['title'] = $session_box['title'];
$sessionParams['subtitle'] = (!empty($session_box['coach'])
? $session_box['coach'] . ' | '
: '') . $session_box['dates'];
$sessionParams['subtitle'] = (!empty($session_box['coach']) ? $session_box['coach'] . ' | ': '') . $session_box['dates'];
$sessionParams['show_actions'] = api_is_platform_admin();
$sessionParams['courses'] = $html_courses_session;
$sessionParams['show_simple_session_info'] = false;
@ -1429,7 +1429,7 @@ class IndexManager
if ($load_history) {
$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
if (empty($session_categories)) {
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
$html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
}
}

@ -1251,7 +1251,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) {
$courseCode,
$session_id
);
if (isset($user_id) && $isUserSubscribedInCourse === true && !api_is_anonymous($user_id)) {
if (isset($user_id) && ($is_platformAdmin || $isUserSubscribedInCourse === true) && !api_is_anonymous($user_id)) {
$is_allowed_in_course = true;
}
break;

File diff suppressed because it is too large Load Diff

@ -215,6 +215,9 @@ if ($installType == 'update' && in_array($my_old_version, $update_from_version_8
}
}
$session_lifetime = 360000;
if (!isset($_GET['running'])) {
$dbHostForm = 'localhost';
$dbUsernameForm = 'root';
@ -252,7 +255,6 @@ if (!isset($_GET['running'])) {
$allowSelfReg = 1;
$allowSelfRegProf = 1;
$encryptPassForm = 'sha1';
$session_lifetime = 360000;
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}

@ -7418,7 +7418,7 @@ $FieldTypeLettersSpaces = "letras e espaços de texto";
$CronRemindCourseFinishedActivateTitle = "Enviar curso terminou notificação";
$FieldTypeAlphanumericSpaces = "caracteres alfanuméricos texto e espaços";
$CronRemindCourseFinishedActivateComment = "Se enviar um e-mail para os alunos quando seu curso (sessão) é acabados. Isto requer tarefas cron para ser configurado (ver/cron/diretório principal).";
$ThanksForRegisteringToSite = "Obrigado por registrar em %s.";
$ThanksForRegisteringToSite = "Obrigado por registrar-se em %s.";
$AllowCoachFeedbackExercisesTitle = "Permitir que os treinadores para comentar na avaliação de exercícios";
$AllowCoachFeedbackExercisesComment = "Permitir que os treinadores para editar o feedback durante a revisão de exercícios";
$PreventMultipleSimultaneousLoginTitle = "Impedir o login simultânea";
@ -7558,4 +7558,5 @@ $NewLogoUpdated = "Novo logotipo carregado";
$CurrentLogo = "Logo atual";
$UpdateLogo = "Logotipo atualização";
$FollowedStudentBosses = "chefes de estudantes seguiram";
$AccessData = "Dados de acesso";
?>

File diff suppressed because one or more lines are too long

@ -7625,4 +7625,10 @@ $EnableForumAutoLaunch = "Activar l'auto-démarrage des forums";
$NowDownloadYourCertificateClickHere = "Télécharge ton certificat en cliquant ici";
$AdditionallyYouHaveObtainedTheFollowingSkills = "En plus, tu as acquis les compétences suivantes";
$IHaveObtainedSkillXOnY = "J'ai acquis la compétence %s sur %s";
$AnotherAttempt = "Nouvelle tentative";
$RemainingXAttempts = "%s tentatives restantes";
$Map = "Carte";
$MyLocation = "Ma position";
$ShowCourseInUserLanguage = "Afficher les cours dans la langue de l'utilisateur";
$AccessData = "Données d'accès";
?>

File diff suppressed because one or more lines are too long

@ -16,7 +16,7 @@ if ($userNotAllowed) {
api_not_allowed(true);
}
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('MySpace'));
$interbreadcrumb[] = array ('url' => api_is_student_boss()?'#':'index.php', 'name' => get_lang('MySpace'));
$tool_name = get_lang('Report');
$this_section = SECTION_TRACKING;

@ -15,7 +15,7 @@ if ($userNotAllowed) {
api_not_allowed(true);
}
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('MySpace'));
$interbreadcrumb[] = array('url' => api_is_student_boss()?'#':'index.php', 'name' => get_lang('MySpace'));
$tool_name = get_lang('Report');
$this_section = SECTION_TRACKING;

@ -90,7 +90,7 @@ if (isset($_GET['details'])) {
);
} else {
$interbreadcrumb[] = array (
"url" => "index.php",
"url" => api_is_student_boss()?"#":"index.php",
"name" => get_lang('MySpace')
);
if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
@ -128,7 +128,7 @@ if (isset($_GET['details'])) {
}
} else {
$interbreadcrumb[] = array (
"url" => "index.php",
"url" => api_is_student_boss()?"#":"index.php",
"name" => get_lang('MySpace')
);
if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {

@ -19,7 +19,7 @@ api_block_anonymous_users();
$this_section = SECTION_TRACKING;
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
$interbreadcrumb[] = array ("url" => api_is_student_boss()?"#":"index.php", "name" => get_lang('MySpace'));
if (isset($_GET["user_id"]) && $_GET["user_id"] != "" && !isset($_GET["type"])) {
$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));

@ -6266,7 +6266,7 @@ class learnpath
$_SESSION['parent_item_id'] = ($row['item_type'] == 'dokeos_chapter' || $row['item_type'] == 'dokeos_module' || $row['item_type'] == 'dir') ? $item_id : 0;
// Prevents wrong parent selection for document, see Bug#1251.
if ($row['item_type'] != 'dokeos_chapter' || $row['item_type'] != 'dokeos_module') {
if ($row['item_type'] != 'dokeos_chapter' && $row['item_type'] != 'dokeos_module') {
$_SESSION['parent_item_id'] = $row['parent_item_id'];
}

@ -0,0 +1,3 @@
{% for item in items %}
{{ item }}
{% endfor %}

@ -0,0 +1,5 @@
{% for item in items %}
<div class="well">
{{ item }}
</div>
{% endfor %}

@ -21,83 +21,83 @@
{% endif %}
<div class="sessions panel-body">
{% if session.show_simple_session_info %}
<div class="row">
<div class="col-md-7">
<h3>
{{ session.title ~ session.notifications }}
</h3>
{% if session.show_simple_session_info %}
<div class="row">
<div class="col-md-7">
<h3>
{{ session.title ~ session.notifications }}
</h3>
{% if session.show_description %}
<div>
{{ session.description }}
</div>
{% endif %}
{% if session.show_description %}
<div>
{{ session.description }}
</div>
{% endif %}
{% if session.subtitle %}
<small>{{ session.subtitle }}</small>
{% endif %}
{% if session.subtitle %}
<small>{{ session.subtitle }}</small>
{% endif %}
{% if session.teachers %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.teachers }}</h5>
{% endif %}
{% if session.teachers %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.teachers }}</h5>
{% endif %}
{% if session.coaches %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.coaches }}</h5>
{% endif %}
</div>
{% if session.coaches %}
<h5 class="teacher-name">{{ "teacher.png"|icon(16) ~ session.coaches }}</h5>
{% endif %}
</div>
{% if session.show_actions %}
<div class="col-md-5 text-right">
<a href="{{ _p.web_main ~ "session/resume_session.php?id_session=" ~ session.id }}">
<img src="{{ "edit.png"|icon(22) }}" width="22" height="22" alt="{{ "Edit"|get_lang }}" title="{{ "Edit"|get_lang }}">
</a>
{% if session.show_actions %}
<div class="col-md-5 text-right">
<a href="{{ _p.web_main ~ "session/resume_session.php?id_session=" ~ session.id }}">
<img src="{{ "edit.png"|icon(22) }}" width="22" height="22" alt="{{ "Edit"|get_lang }}" title="{{ "Edit"|get_lang }}">
</a>
</div>
{% endif %}
</div>
{% else %}
<div class="row">
<div class="col-md-12">
{% if session.subtitle %}
<div class="subtitle-session">
<em class="fa fa-clock-o"></em> {{ session.subtitle }}
</div>
{% endif %}
</div>
{% else %}
<div class="row">
<div class="col-md-12">
{% if session.subtitle %}
<div class="subtitle-session">
<em class="fa fa-clock-o"></em> {{ session.subtitle }}
</div>
{% endif %}
{% if session.show_description %}
<div class="description-session">
{{ session.description }}
</div>
{% endif %}
<div class="sessions-items">
{% for item in session.courses %}
<div class="row">
<div class="col-md-2">
{% if item.link %}
<a href="{{ item.link }}" class="thumbnail">{{ item.icon }}</a>
{% else %}
{{ item.icon }}
{% endif %}
</div>
<div class="col-md-10">
{{ item.title }}
{% if session.show_description %}
<div class="description-session">
{{ session.description }}
</div>
{% endif %}
<div class="sessions-items">
{% for item in session.courses %}
<div class="row">
<div class="col-md-2">
{% if item.link %}
<a href="{{ item.link }}" class="thumbnail">{{ item.icon }}</a>
{% else %}
{{ item.icon }}
{% endif %}
</div>
<div class="col-md-10">
{{ item.title }}
{% if item.coaches|length > 0 %}
<img src="{{ 'teacher.png'|icon(16) }}" width="16" height="16">
{% if item.coaches|length > 0 %}
<img src="{{ 'teacher.png'|icon(16) }}" width="16" height="16">
{% for coach in item.coaches %}
{{ loop.index > 1 ? ' | ' }}
{% for coach in item.coaches %}
{{ loop.index > 1 ? ' | ' }}
<a href="{{ _p.web_ajax ~ 'user_manager.ajax.php?' ~ {'a': 'get_user_popup', 'user_id': coach.user_id}|url_encode() }}" data-title="{{ coach.full_name }}" class="ajax">
{{ coach.full_name }}
</a>
{% endfor %}
{% endif %}
</div>
<a href="{{ _p.web_ajax ~ 'user_manager.ajax.php?' ~ {'a': 'get_user_popup', 'user_id': coach.user_id}|url_encode() }}" data-title="{{ coach.full_name }}" class="ajax">
{{ coach.full_name }}
</a>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
</div>

@ -445,6 +445,7 @@ if (api_is_allowed_to_edit(null, true)) {
}
}
// $is_allowed_in_course is first defined in local.inc.php
if (!$is_allowed_in_course) {
api_not_allowed(true);
}

@ -2059,7 +2059,7 @@ function get_work_user_list(
$work_date = api_convert_and_format_date($work['sent_date']);
$work['sent_date_from_db'] = $work['sent_date'];
$work['sent_date'] = '<div class="date-time">' . date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . ' ' . $work_date . '</div>';
$work['sent_date'] = '<div class="date-time">' . date_to_str_ago($work['sent_date']). ' ' . $add_string . ' ' . $work_date . '</div>';
// Actions.
$correction = '';

@ -14,6 +14,7 @@ define('TABLE_TICKET_PRIORITY', 'plugin_ticket_priority');
define('TABLE_TICKET_PROJECT', 'plugin_ticket_project');
define('TABLE_TICKET_STATUS', 'plugin_ticket_status');
define('TABLE_TICKET_TICKET', 'plugin_ticket_ticket');
define('TABLE_TICKET_CATEGORY_REL_USER', 'plugin_ticket_category_rel_user');
define('TABLE_TICKET_MESSAGE_ATTACHMENTS', 'plugin_ticket_message_attachments');
/* Ticket status constants */

@ -220,6 +220,13 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
KEY FK_ticket_category (project_id,category_id))";
Database::query($sql);
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
id int UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
category_id INT NOT NULL,
user_id INT NOT NULL
)";
//Menu main tabs
$rsTab = $objPlugin->addTab('Ticket', 'plugin/ticket/src/myticket.php');

@ -83,5 +83,18 @@ $strings['AreYouSure'] = "Are you sure?";
$strings['allow_student_add'] = "Allow students to generate tickets";
$strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Please select a user before you register a ticket.";
$strings['RequestConfirmation'] = "Request confirmation";
$strings['TicketUpdated'] = "Ticket updated";
$strings['TicketClosed'] = "Ticket closed";
$strings['TicketXCreated'] = "Ticket <b>%s</b>created";
$strings['allow_category_edition'] = "Allow category edition";
$strings['warn_admin_no_user_in_category'] = "Warn admin if category doesn't have users related";
$strings['send_warning_to_all_admins'] = "Send warning to all admins, if category doesn't have users related";
$strings['WarningCategoryXDoesntHaveUsers'] = "Warning: The category '%s' doesn't have users assigned";
$strings['TicketInformation'] = 'Ticket information';
$strings['CategoryWithNoUserNotificationSentToAdmins'] = 'Category <b>%s</b> with no user sent to all administrators.';
$strings['TicketXAssignedToUserX'] = 'Ticket <b>#%s</b> assigned to user <b>%s</b>';
$strings['TicketXCreatedWithNoCategory'] = 'Ticket <b>#%s</b> created with no category';

@ -0,0 +1,152 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script is the Tickets plugin main entry point
* @package chamilo.plugin.ticket
*/
$cidReset = true;
// needed in order to load the plugin lang variables
$course_plugin = 'ticket';
require_once '../config.php';
$plugin = TicketPlugin::create();
api_protect_admin_script(true);
$tool_name = $plugin->get_lang('LastEdit');
$libPath = api_get_path(LIBRARY_PATH);
$webLibPath = api_get_path(WEB_LIBRARY_PATH);
$this_section = 'tickets';
unset($_SESSION['this_section']);
$table = new SortableTable(
'TicketCategories',
array('TicketManager', 'getCategoriesCount'),
array('TicketManager', 'getCategories'),
1
);
if ($table->per_page == 0) {
$table->per_page = 20;
}
$formToString = '';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if (isset($_GET['action'])) {
global $table;
$action = $_GET['action'];
switch ($action) {
case 'delete':
TicketManager::deleteCategory($id);
Display::addFlash(Display::return_message(get_lang('Deleted')));
header("Location: ".api_get_self());
break;
case 'add':
$url = api_get_self().'?action=add';
$form = TicketManager::getCategoryForm($url);
$formToString = $form->returnForm();
if ($form->validate()) {
$values =$form->getSubmitValues();
$params = [
'name' => $values['name'],
'description' => $values['description'],
'total_tickets' => 0,
'sys_insert_user_id' => api_get_user_id(),
'sys_insert_datetime' => api_get_utc_datetime()
];
TicketManager::addCategory($params);
Display::addFlash(Display::return_message(get_lang('Added')));
header("Location: ".api_get_self());
exit;
}
break;
case 'edit':
$url = api_get_self().'?action=edit&id='.$id;
$form = TicketManager::getCategoryForm($url);
$cat = TicketManager::getCategory($_GET['id']);
$form->setDefaults($cat);
$formToString = $form->returnForm();
if ($form->validate()) {
$values =$form->getSubmitValues();
$params = [
'name' => $values['name'],
'description' => $values['description'],
'sys_lastedit_datetime' => api_get_utc_datetime(),
'sys_lastedit_user_id' => api_get_user_id()
];
$cat = TicketManager::updateCategory($_GET['id'], $params);
Display::addFlash(Display::return_message(get_lang('Updated')));
header("Location: ".api_get_self());
exit;
}
break;
default:
break;
}
}
$user_id = api_get_user_id();
$isAdmin = api_is_platform_admin();
/**
* Build the modify-column of the table
* @param int The user id
* @param string URL params to add to table links
* @param array Row of elements to alter
* @return string Some HTML-code with modify-buttons
*/
function modify_filter($id, $params, $row)
{
$result = Display::url(
Display::return_icon('edit.png', get_lang('Edit')),
"categories.php?action=edit&id={$row['id']}"
);
$result .= Display::url(
Display::return_icon('user.png', get_lang('AssignUser')),
"categories_add_user.php?id={$row['id']}"
);
$result .= Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
"categories.php?action=delete&id={$row['id']}"
);
return $result;
}
$table->set_header(0, '', false);
$table->set_header(1, $plugin->get_lang('Title'), false);
$table->set_header(2, get_lang('Description'), true, array("style" => "width:200px"));
$table->set_header(3, $plugin->get_lang('TotalTickets'), false);
$table->set_header(4, get_lang('Actions'), true);
$table->set_column_filter(4, 'modify_filter');
$interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang('MyTickets'));
Display::display_header($plugin->get_lang('Categories'));
$items = [
[
'url' => 'categories.php?action=add',
'content' => Display::return_icon('new_folder.png', null, null, ICON_SIZE_MEDIUM),
]
];
echo Display::actions($items);
echo $formToString;
echo $table->return_table();
Display::display_footer();

@ -0,0 +1,52 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once '../config.php';
$plugin = TicketPlugin::create();
api_protect_admin_script(true);
$categoryId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if (empty($categoryId)) {
api_not_allowed(true);
}
$form = new FormValidator('edit', 'post', api_get_self().'?id='.$categoryId);
$users = UserManager::get_user_list([], ['firstname']);
$users = array_column($users, 'complete_name', 'user_id');
$form->addElement(
'advmultiselect',
'users',
get_lang('Users'),
$users,
'style="width: 280px;"'
);
$usersAdded = TicketManager::getUsersInCategory($categoryId);
if (!empty($usersAdded)) {
$usersAdded = array_column($usersAdded, 'user_id');
}
$form->setDefaults(['users' => $usersAdded]);
// submit button
$form->addButtonSave(get_lang('Save'));
if ($form->validate()) {
$values = $form->exportValues();
TicketManager::deleteAllUserInCategory($categoryId);
TicketManager::addUsersToCategory($categoryId, $values['users']);
Display::addFlash(Display::return_message(get_lang('Updated')));
header("Location: ".api_get_self()."?id=".$categoryId);
exit;
}
$interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang('MyTickets'));
$interbreadcrumb[] = array('url' => 'categories.php', 'name' => get_lang('Categories'));
Display::display_header();
$form->display();

@ -31,7 +31,6 @@ $userInput = Display::tag(
)
);
$userControl = Display::div($userInput, array('class' => 'controls'));
$courseLabel = Display::tag('label', get_lang('Course'), array('class' => 'control-label'));
$courseSelect = Display::select('course_id', $arrCourseList, 0, array(), false);
$courseControl = Display::div($courseSelect, array('class' => 'controls'));

@ -12,8 +12,8 @@ $course_plugin = 'ticket';
require_once '../config.php';
$plugin = TicketPlugin::create();
$tool_name = $plugin->get_lang('LastEdit');
$tool_name = $plugin->get_lang('LastEdit');
api_block_anonymous_users();
$libPath = api_get_path(LIBRARY_PATH);
@ -289,12 +289,22 @@ if ($isAdmin) {
echo '<div class="actions" >';
if (api_is_platform_admin()) {
echo '<span class="fleft">' .
echo '<span class="left">' .
'<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . '</a>' .
'<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' .
Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a>' .
'</span>';
Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a>';
if ($plugin->get('allow_category_edition')) {
echo Display::url(
Display::return_icon('folder_document.gif'),
api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/categories.php'
);
}
echo '</span>';
}
$form->display();
echo '</div>';
@ -417,7 +427,7 @@ if ($isAdmin) {
$table->set_header(3, $plugin->get_lang('Category'));
$table->set_header(4, $plugin->get_lang('Status'), false);
$table->set_header(5, get_lang('Actions'), false);
}
}
$table->display();
Display::display_footer();

@ -18,13 +18,6 @@ if (!api_is_platform_admin() &&
api_block_anonymous_users();
$scrollTop = '';
if (api_is_platform_admin()) {
$scrollTol = '$("html, body").animate({
scrollTop: $(".divTicket").offset().top - 20
}, "slow");';
}
$htmlHeadXtra[] = '
<script>
function load_course_list (div_course, my_user_id, user_email) {
@ -38,7 +31,6 @@ function load_course_list (div_course, my_user_id, user_email) {
$("#user_id_request").val(my_user_id);
$("#personal_email").val(user_email);
$("#btnsubmit").attr("disabled", false);
' . $scrollTol . '
}
});
}
@ -73,10 +65,7 @@ function validate() {
document.getElementById("content").value= fckEditor1val;
var selected = document.getElementById("category_id").selectedIndex;
var id = document.getElementById("category_id").options[selected].value;
if (document.getElementById("user_id_request").value == "") {
alert("' . $plugin->get_lang("ValidUser") . '");
return false;
} else if(id == 0) {
if (id == 0) {
alert("' . $plugin->get_lang("ValidType") . '");
return false;
} else if(document.getElementById("subject").value == "") {
@ -86,8 +75,10 @@ function validate() {
alert("' . $plugin->get_lang("ValidCourse") . '");
return false;
} else if(id != "CUR" && parseInt(course_required[id]) != 1 && !re.test(document.getElementById("personal_email").value)) {
alert("' . $plugin->get_lang("ValidEmail") . '");
return false;
if (document.getElementById("personal_email").value != "") {
alert("' . $plugin->get_lang("ValidEmail") . '");
return false;
}
} else if(fckEditor1val == "") {
alert("' . $plugin->get_lang("ValidMessage") . '");
return false;
@ -132,7 +123,7 @@ function add_image_form() {
});
img_remove = $("<img/>", {
src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif"
src: "' . Display::returnIconPath('delete.png') . '"
});
new_filepath_id = $("#filepath_" + counter_image);
@ -200,7 +191,6 @@ function js_array($array, $name, $key)
function show_form_send_ticket()
{
global $types, $plugin;
echo '<div class="divTicket">';
// Category List
$categoryList = array();
@ -263,8 +253,7 @@ function show_form_send_ticket()
"",
array(
'enctype' => 'multipart/form-data',
'onsubmit' => 'return validate()',
'class' => 'span8 offset1 form-horizontal'
'onsubmit' => 'return validate()'
)
);
@ -317,49 +306,12 @@ function show_form_send_ticket()
)
);
$form->addElement(
'html',
Display::div(
'',
array(
'id' => 'user_request'
)
)
);
$form->addElement(
'select',
'status_id',
get_lang('Status'),
$statusList,
$statusAttributes
);
$form->addElement(
'select',
'source_id',
$plugin->get_lang('Source'),
$sourceList,
$sourceAttributes
);
$form->addElement(
'text',
'subject',
get_lang('Subject'),
array(
'id' => 'subject',
'style' => 'width: 550px;'
)
);
$form->addElement(
'text',
'personal_email',
$plugin->get_lang('PersonalEmail'),
array(
'id' => 'personal_email',
'style' => 'width: 550px;'
'id' => 'subject'
)
);
@ -370,20 +322,49 @@ function show_form_send_ticket()
false,
array(
'ToolbarSet' => 'Profile',
'Width' => '600',
'Height' => '250'
)
);
//if (api_is_platform_admin()) {
$form->addElement(
'SelectAjax',
'user_id',
get_lang('Assign'),
null,
['url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_like']
);
//}
$form->addElement(
'text',
'phone',
get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')',
'personal_email',
$plugin->get_lang('PersonalEmail'),
array(
'id' => 'phone'
'id' => 'personal_email'
)
);
$form->addLabel('',
Display::div(
'',
array(
'id' => 'user_request'
)
)
);
$form->addElement(
'select',
'status_id',
get_lang('Status'),
$statusList,
$statusAttributes
);
$form->addElement(
'select',
'priority_id',
@ -395,17 +376,33 @@ function show_form_send_ticket()
)
);
$form->addElement('html', '<span id="filepaths">');
$form->addElement('html', '<div id="filepath_1">');
$form->addElement(
'select',
'source_id',
$plugin->get_lang('Source'),
$sourceList,
$sourceAttributes
);
$form->addElement(
'text',
'phone',
get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')',
array(
'id' => 'phone'
)
);
$form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
$form->addElement('html', '</div>');
$form->addElement('html', '</span>');
$form->addLabel('', '<span id="filepaths"><div id="filepath_1"></div></span>');
$form->addElement('html', '<div class="controls">');
$form->addElement('html', '<span id="link-more-attach" >');
$form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
$form->addElement('html', '</span>');
$form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
$form->addLabel('',
'<span id="link-more-attach">
<span class="btn btn-success" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>
</span>
('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')
');
$form->addElement('html', '<br/>');
$form->addElement(
@ -415,7 +412,7 @@ function show_form_send_ticket()
null,
null,
null,
'save',
'btn btn-primary',
array(
'id' => 'btnsubmit'
)
@ -435,18 +432,19 @@ function save_ticket()
if ($_POST['phone'] != "") {
$content .= '<p style="color:red">&nbsp;' . get_lang('Phone') . ': ' . Security::remove_XSS($_POST['phone']). '</p>';
}
$course_id = $_POST['course_id'];
$course_id = isset($_POST['course_id']) ? $_POST['course_id'] : 0;
$project_id = $_POST['project_id'];
$subject = $_POST['subject'];
$other_area = (int) $_POST['other_area'];
$email = $_POST['email'];
$personal_email = $_POST['personal_email'];
$source = $_POST['source_id'];
$user_id = $_POST['user_id_request'];
$user_id = isset($_POST['user_id']) ? $_POST['user_id'] : 0;
$priority = $_POST['priority_id'];
$status = $_POST['status_id'];
$file_attachments = $_FILES;
$responsible = (api_is_platform_admin() ? api_get_user_id() : 0);
if (TicketManager::insert_new_ticket(
$category_id,
$course_id,
@ -581,6 +579,8 @@ function get_user_data($from, $number_of_items, $column, $direction)
if (!isset($_POST['compose'])) {
if (api_is_platform_admin()) {
Display::display_header(get_lang('ComposeMessage'));
/*
$message = $plugin->get_lang('PleaseBeforeRegisterATicketSelectOneUser');
Display::display_warning_message($message);
echo '
@ -617,7 +617,7 @@ if (!isset($_POST['compose'])) {
$table->set_header(5, get_lang('Email'));
$table->set_header(6, get_lang('Action'));
$table->display();
echo '</div>';
echo '</div>';*/
} else {
$userInfo = api_get_user_info();
$htmlHeadXtra[] = "

@ -35,6 +35,173 @@ class TicketManager
return $types;
}
/**
* @param $from
* @param $numberItems
* @param $column
* @param $direction
* @return array
*/
public static function getCategories($from, $numberItems, $column, $direction)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$sql = "SELECT id, name, description, total_tickets
FROM $table";
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';
}
$column = intval($column);
$from = intval($from);
$numberItems = intval($numberItems);
//$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$numberItems";
$result = Database::query($sql);
$types = array();
while ($row = Database::fetch_array($result)) {
$types[] = $row;
}
return $types;
}
/**
* @param int $id
* @return array|mixed
*/
public static function getCategory($id)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$id = intval($id);
$sql = "SELECT id, name, description, total_tickets
FROM $table WHERE id = $id";
$result = Database::query($sql);
$category = Database::fetch_array($result);
return $category;
}
/**
* @return int
*/
public static function getCategoriesCount()
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$sql = "SELECT count(id) count
FROM $table ";
$result = Database::query($sql);
$category = Database::fetch_array($result);
return $category['count'];
}
/**
* @param int $id
* @param array $params
*/
public static function updateCategory($id, $params)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$id = intval($id);
Database::update($table, $params, ['id = ?' => $id]);
}
/**
* @param int $id
* @param array $params
*/
public static function addCategory($params)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
Database::insert($table, $params);
}
/**
* @param int $id
*/
public static function deleteCategory($id)
{
$id = intval($id);
$table = Database::get_main_table(TABLE_TICKET_TICKET);
$sql = "UPDATE $table SET category_id = NULL WHERE category_id = $id";
Database::query($sql);
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$sql = "DELETE FROM $table WHERE id = $id";
Database::query($sql);
}
/**
* @param int $categoryId
* @param array $users
*/
public static function addUsersToCategory($categoryId, $users)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
if (empty($users) || empty($categoryId)) {
return false;
}
foreach ($users as $userId) {
if (self::userIsAssignedToCategory($userId, $categoryId) == false) {
$params = [
'category_id' => $categoryId,
'user_id' => $userId
];
Database::insert($table, $params);
}
}
}
/**
* @param int $userId
* @param int $categoryId
*
* @return bool
*/
public static function userIsAssignedToCategory($userId, $categoryId)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
$userId = intval($userId);
$categoryId = intval($categoryId);
$sql = "SELECT * FROM $table WHERE category_id = $categoryId AND user_id = $userId";
$result = Database::query($sql);
return Database::num_rows($result) > 0;
}
/**
* @param int $categoryId
*
* @return array
*/
public static function getUsersInCategory($categoryId)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
$categoryId = intval($categoryId);
$sql = "SELECT * FROM $table WHERE category_id = $categoryId";
$result = Database::query($sql);
return Database::store_result($result);
}
/**
* @param int $categoryId
*/
public static function deleteAllUserInCategory($categoryId)
{
$table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
$categoryId = intval($categoryId);
$sql = "DELETE FROM $table WHERE category_id = $categoryId";
Database::query($sql);
}
/**
* Get all possible tickets statuses
* @return array
@ -78,7 +245,7 @@ class TicketManager
$email,
$subject,
$content,
$personalEmail = "",
$personalEmail = '',
$file_attachments,
$source = 'VRT',
$priority = 'NRM',
@ -91,6 +258,9 @@ class TicketManager
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
);
$now = api_get_utc_datetime();
$user_id = api_get_user_id();
$course_id = intval($course_id);
$category_id = intval($category_id);
$project_id = intval($project_id);
@ -107,8 +277,6 @@ class TicketManager
$personalEmail = Database::escape_string($personalEmail);
$status = Database::escape_string($status);
$now = api_get_utc_datetime();
$user_id = api_get_user_id();
if ($status == '') {
$status = NEWTCK;
if ($other_area > 0) {
@ -116,10 +284,31 @@ class TicketManager
}
}
if ($request_user == '' && $source == 'VRT') {
if (!empty($category_id)) {
if (empty($request_user)) {
$usersInCategory = TicketManager::getUsersInCategory($category_id);
if (!empty($usersInCategory) && count($usersInCategory) > 0) {
$userCategoryInfo = $usersInCategory[0];
if (isset($userCategoryInfo['user_id'])) {
$assigned_user = $userCategoryInfo['user_id'];
}
}
}
}
if (empty($request_user)) {
$request_user = $user_id;
}
$assignedUserInfo = api_get_user_info($assigned_user);
if (empty($assignedUserInfo)) {
return false;
}
$sql_insert_ticket = "INSERT INTO $table_support_tickets
// insert_ticket
$sql = "INSERT INTO $table_support_tickets
(
project_id,
category_id,
@ -143,58 +332,173 @@ class TicketManager
'$personalEmail',
'$status',
'$now',
$user_id,
$request_user,
'$now',
'$user_id',
'$request_user',
'$now',
'$source'
)";
Database::query($sql_insert_ticket);
Database::query($sql);
$ticket_id = Database::insert_id();
if ($assigned_user != 0) {
self::assign_ticket_user($ticket_id, $assigned_user);
}
if ($ticket_id != 0) {
$ticket_code = "A" . str_pad(
(int) $ticket_id, 11, "0", STR_PAD_LEFT
);
$sql_update_code = "UPDATE $table_support_tickets
SET ticket_code = '$ticket_code'
WHERE ticket_id = '$ticket_id'";
Database::query($sql_update_code);
if ($assigned_user != 0) {
self::assign_ticket_user($ticket_id, $assigned_user);
Display::addFlash(Display::return_message(
sprintf(
$plugin->get_lang('TicketXAssignedToUserX'),
$ticket_code,
$assignedUserInfo['complete_name']
),
'normal',
false
));
} else {
Display::addFlash(Display::return_message(
sprintf(
$plugin->get_lang('TicketXCreated'),
$ticket_code
),
'normal',
false
));
}
// Update code
$sql = "UPDATE $table_support_tickets
SET ticket_code = '$ticket_code'
WHERE ticket_id = '$ticket_id'";
Database::query($sql);
$data_files = array();
$sql_update_total = "UPDATE $table_support_category
SET total_tickets = total_tickets +1
WHERE category_id = '$category_id';";
Database::query($sql_update_total);
if (self::insert_message($ticket_id, $subject, $content, $file_attachments, $request_user)) {
// Update total
$sql = "UPDATE $table_support_category
SET total_tickets = total_tickets +1
WHERE category_id = '$category_id'";
Database::query($sql);
if (self::insert_message(
$ticket_id,
$subject,
$content,
$file_attachments,
$request_user)
) {
$user = api_get_user_info($request_user);
$helpDeskMessage =
'<table>
<tr>
<td width="100px"><b>' . get_lang('User') . '</b></td>
<td width="400px">' . $user['firstname']. ' ' . $user['lastname'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Username') . '</b></td>
<td width="400px">' . $user['username'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Email') . '</b></td>
<td width="400px">' . $user['email'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Phone') . '</b></td>
<td width="400px">' . $user['phone'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Date') . '</b></td>
<td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Title') . '</b></td>
<td width="400px">' . $subject . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Description') . '</b></td>
<td width="400px">' . $content . '</td>
</tr>
</table>';
if (empty($category_id)) {
if ($plugin->get('send_warning_to_all_admins')) {
$warningSubject = sprintf(
$plugin->get_lang('TicketXCreatedWithNoCategory'),
$ticket_code
);
Display::addFlash(Display::return_message($warningSubject));
$admins = UserManager::get_all_administrators();
foreach ($admins as $userId => $data) {
if ($data['active']) {
MessageManager::send_message_simple(
$userId,
$warningSubject,
$message
);
}
}
}
} else {
$categoryInfo = TicketManager::getCategory($category_id);
$usersInCategory = TicketManager::getUsersInCategory($category_id);
$message = '<h2>'.$plugin->get_lang('TicketInformation').'</h2><br />'.$helpDeskMessage;
if ($plugin->get('warn_admin_no_user_in_category')) {
$usersInCategory = TicketManager::getUsersInCategory($category_id);
if (empty($usersInCategory)) {
$subject = sprintf(
$plugin->get_lang('WarningCategoryXDoesntHaveUsers'),
$categoryInfo['name']
);
if ($plugin->get('send_warning_to_all_admins')) {
Display::addFlash(Display::return_message(
sprintf(
$plugin->get_lang('CategoryWithNoUserNotificationSentToAdmins'),
$categoryInfo['name']
),
null,
false
));
$admins = UserManager::get_all_administrators();
foreach ($admins as $userId => $data) {
if ($data['active']) {
MessageManager::send_message_simple(
$userId,
$subject,
$message
);
}
}
} else {
Display::addFlash(Display::return_message($subject));
}
}
}
// Send notification to all users
if (!empty($usersInCategory)) {
foreach ($usersInCategory as $data) {
if ($data['user_id']) {
MessageManager::send_message_simple(
$data['user_id'],
$subject,
$message
);
}
}
}
}
global $data_files;
if ($other_area) {
$user = api_get_user_info($request_user);
$helpDeskMessage = '<table>
<tr>
<td width="100px"><b>' . get_lang('User') . '</b></td>
<td width="400px">' . $user['firstname']. ' ' . $user['lastname'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Username') . '</b></td>
<td width="400px">' . $user['username'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Date') . '</b></td>
<td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Topic') . '</b></td>
<td width="400px">' . $subject . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Description') . '</b></td>
<td width="400px">' . $content . '</td>
</tr>
</table>';
// Send email to "other area" email
api_mail_html(
@ -227,6 +531,9 @@ class TicketManager
);
}
return true;
} else {
@ -637,6 +944,7 @@ class TicketManager
)";
}
}
if ($keyword_unread == 'yes') {
$sql .= " AND ticket.ticket_id IN (SELECT ticket.ticket_id
FROM $table_support_tickets ticket,
@ -1012,12 +1320,15 @@ class TicketManager
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_assoc($result)) {
$row['course'] = null;
$row['start_date_from_db'] = $row['start_date'];
$row['start_date'] = api_convert_and_format_date(
api_get_local_time($row['start_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
$row['end_date_from_db'] = $row['end_date'];
$row['end_date'] = api_convert_and_format_date(
api_get_local_time($row['end_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
$row['sys_lastedit_datetime_from_db'] = $row['sys_lastedit_datetime'];
$row['sys_lastedit_datetime'] = api_convert_and_format_date(
api_get_local_time($row['sys_lastedit_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
@ -1551,4 +1862,18 @@ class TicketManager
return $tickets;
}
/**
* @param string $url
* @return FormValidator
*/
public static function getCategoryForm($url)
{
$form = new FormValidator('category', 'post', $url);
$form->addText('name', get_lang('Name'));
$form->addHtmlEditor('description', get_lang('Description'));
$form->addButtonUpdate(get_lang('Save'));
return $form;
}
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
@ -30,13 +31,13 @@ $(document).ready(function(){
width: 600,
modal: true,
buttons: {
' . get_lang('Accept') . ': function(){
$("#frmResponsable").submit()
},
' . ucfirst(get_lang('Close')) . ': function() {
$(this).dialog("close");
}
}
' . get_lang('Accept') . ': function(){
$("#frmResponsable").submit()
},
' . ucfirst(get_lang('Close')) . ': function() {
$(this).dialog("close");
}
}
});
$("a#assign").click(function () {
@ -117,7 +118,7 @@ function add_image_form() {
});
img_remove = $("<img/>", {
src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif"
src: "' . Display::returnIconPath('delete.png').'"
});
new_filepath_id = $("#filepath_" + counter_image);
@ -223,10 +224,16 @@ if (isset($_REQUEST['action'])) {
}
}
$titulo = 'Ticket #' . $ticket['ticket']['ticket_code'];
$firstMessage = is_array($ticket['messages']) ? $ticket['messages'][0] : '';
$subTitle = '';
if (!empty($firstMessage) && isset($firstMessage['subject'])) {
$subTitle = $firstMessage['subject'];
}
if (!isset($_POST['compose'])) {
if (isset($_POST['close'])) {
$_GET['ticket_id'] = $_POST['ticket_id'];
TicketManager::close_ticket($_GET['ticket_id'], $user_id);
if (isset($_REQUEST['close'])) {
TicketManager::close_ticket($_REQUEST['ticket_id'], $user_id);
$ticket['ticket']['status_id'] = 'CLS';
$ticket['ticket']['status'] = $plugin->get_lang('Closed');
}
@ -239,22 +246,21 @@ if (!isset($_POST['compose'])) {
if ($ticket['ticket']['status_id'] != 'REE' && $ticket['ticket']['status_id'] != 'CLS' && $isAdmin) {
if (intval($ticket['ticket']['assigned_last_user']) == $user_id) {
if ($ticket['ticket']['status_id'] != 'CLS') {
$form_close_ticket.= '<form enctype="multipart/form-data" action="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '" method="post" name="close_ticket" id="close_ticket" >';
$form_close_ticket.= '<input type="hidden" name="ticket_id" value="' . $ticket['ticket']['ticket_id'] . '"/>
<button class="minus" name="close" type="submit" id="close" >' . get_lang('Close') . '</button>';
$form_close_ticket.= '</form>';
$form_close_ticket.= '<a href="' . api_get_self() . '?close=1&ticket_id=' . $ticket['ticket']['ticket_id'] . '" id="close" class="btn btn-danger" >';
$form_close_ticket.= get_lang('Close') . '</a>';
}
}
}
$titulo = '<center><h1>Ticket #' . $ticket['ticket']['ticket_code'] . '</h1></center>';
$img_assing = '';
if ($isAdmin && $ticket['ticket']['status_id'] != 'CLS' && $ticket['ticket']['status_id'] != 'REE') {
if ($ticket['ticket']['assigned_last_user'] != 0 && $ticket['ticket']['assigned_last_user'] == $user_id) {
$img_assing = '<a href="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '&amp;action=unassign" id="unassign">
<img src="' . api_get_path(WEB_CODE_PATH) . 'img/admin_star.png" style="height: 32px; width: 32px;" border="0" title="Unassign" align="center"/>
$img_assing = '<a class="btn btn-warning" href="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '&amp;action=unassign" id="unassign">
'.get_lang('Unassign').'
</a>';
} else {
$img_assing = '<a href="#" id="assign"><img src="' . api_get_path(WEB_CODE_PATH) . 'img/admin_star_na.png" style="height: 32px; width: 32px;" title="Assign" align="center"/></a>';
$img_assing = '<a href="#" id="assign" class="btn btn-success">'.get_lang('Assign').'</a>';
}
}
$bold = '';
@ -267,31 +273,43 @@ if (!isset($_POST['compose'])) {
}
</style>";
}
if ($isAdmin) {
$senderData = get_lang('AddedBy') . ' ' . $ticket['ticket']['user_url'] . ' (' . $ticket['usuario']['username'] . ').';
} else {
$senderData = get_lang('AddedBy') . ' ' . $ticket['usuario']['complete_name'] . ' (' . $ticket['usuario']['username'] . ').';
}
echo '<div style="margin-left:20%;margin-right:20%;">
echo '
<table width="100%" >
<tr>
<td colspan="3" style="width:65%">' . $titulo . '</td>
<td style="width: 15%">' . $img_assing . '</td>
<td style="width: 15%">' . $form_close_ticket . '</td>
<td colspan="3" style="width:65%">
<h1>' . $titulo . ' '.$form_close_ticket.' '.$img_assing.' </h1>
<h2>'.$subTitle.'</h2>
<p>
'.$senderData.' ' .
get_lang('Created') . ' '.
Display::url(
date_to_str_ago($ticket['ticket']['start_date_from_db']),
'#',
['title' => $ticket['ticket']['start_date'], 'class' => 'boot-tooltip']
).'. '.
$plugin->get_lang('TicketUpdated').' '.
Display::url(
date_to_str_ago($ticket['ticket']['sys_lastedit_datetime_from_db']),
'#',
['title' => $ticket['ticket']['sys_lastedit_datetime'], 'class' => 'boot-tooltip']
).'
</p>
</td>
</tr>
<tr>
<td style="width:45%;" ><p>' . get_lang('Sent') . ': ' . $ticket['ticket']['start_date'] . '</p></td>
<td style="width:50px;"></td>
<td style="width:45%;" ><p>' . $plugin->get_lang('LastResponse') . ': ' . $ticket['ticket']['sys_lastedit_datetime'] . '</p></td>
<td colspan="2"></td>
<tr>
<td><p><b>' . get_lang('Category') . ': </b>' . $ticket['ticket']['name'] . '</p></td>
</tr>
<tr>
<td><p>' . get_lang('Subject') . ': ' . $ticket['messages'][0]['subject'] . '</p></td>
<td></td>
<td><p ' . $bold . '>' . get_lang('Status') . ': ' . $ticket['ticket']['status'] . '</p></td>
<td colspan="2"></td>
<td><p ' . $bold . '><b>' . get_lang('Status') . ':</b> ' . $ticket['ticket']['status'] . '</p></td>
</tr>
<tr>
<td><p>' . get_lang('Category') . ': ' . $ticket['ticket']['name'] . '</p></td>
<td></td>
<td ><p>' . $plugin->get_lang('Priority') . ':' . $ticket['ticket']['priority'] . '<p></td>
<td colspan="2"></td>
<td><p><b>' . $plugin->get_lang('Priority') . ': </b>' . $ticket['ticket']['priority'] . '<p></td>
</tr>';
if ($ticket['ticket']['course_url'] != null) {
echo '<tr>
@ -301,12 +319,13 @@ if (!isset($_POST['compose'])) {
<td colspan="2"></td>
</tr>';
}
if ($isAdmin) {
echo '<tr>
<td><p>' . get_lang('User') . ': &nbsp;' . $user_info = $ticket['ticket']['user_url'] . ' (' . $ticket['usuario']['username'] . ')</p></td>
</tr>';
}
//select admins
echo '<tr>
<td><b>' . get_lang('Description') . ':</b> <br />
'.$firstMessage['message'].'</td>
</tr>
';
// select admins
$select_admins = '<select class ="chzn-select" style="width: 350px; " name = "admins" id="admins" ">';
$admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true);
@ -323,23 +342,24 @@ if (!isset($_POST['compose'])) {
</div>
</form>';
echo '</div>';
echo '</table></div>';
echo '</table>';
$messages = $ticket['messages'];
echo "<div class='row'>";
echo "<div class='span8 offset2'>";
unset($messages[0]);
foreach ($messages as $message) {
$type = "success";
if ($message['admin']) {
$type = "normal";
if ($isAdmin) {
$message['message'].='<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
$message['message'] .= '<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
}
}else {
$message['message'].='<b>' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
$message['message'] .= '<br /><b>' . get_lang('Sent') . ':</b> ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone());
}
$receivedMessage = '<b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/> <b>' . get_lang('Message') . ':</b>' . $message['message'] . '<br/>';
$receivedMessage = '<b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/>
<b>' . get_lang('Message') . ':</b><br/>' . $message['message'] . '<br/>';
$attachementLinks = "";
if (isset($message['atachments'])) {
@ -354,9 +374,8 @@ if (!isset($_POST['compose'])) {
$entireMessage = $receivedMessage . $attachementLinks;
echo Display::return_message($entireMessage, $type, false);
}
echo "</div>";
echo "</div>";
$subject = get_lang('ReplyShort') .": " . $message['subject'];
$subject = get_lang('ReplyShort') .": " . $firstMessage['subject'];
$user_admin = api_is_platform_admin();
if ($ticket['ticket']['status_id'] != 'REE' AND $ticket['ticket']['status_id'] != 'CLS') {
if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') {
@ -438,17 +457,17 @@ function show_form_send_message()
);
}
$form->addElement('html', '<span id="filepaths">');
$form->addElement('html', '<div id="filepath_1">');
$form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
$form->addElement('html', '</div>');
$form->addElement('html', '</span>');
$form->addLabel('', '<span id="filepaths"><div id="filepath_1"></div></span>');
$form->addLabel('',
'<span id="link-more-attach">
<span class="btn btn-success" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>
</span>
('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')
');
$form->addElement('html', '<div class="controls">');
$form->addElement('html', '<span id="link-more-attach" >');
$form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
$form->addElement('html', '</span>');
$form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
$form->addElement('html', '<br/>');
$form->addElement(
@ -458,7 +477,7 @@ function show_form_send_message()
null,
null,
null,
'save'
'btn btn-primary'
);
$form->display();

@ -12,21 +12,32 @@ class TicketPlugin extends Plugin
/**
* Set the result
* @staticvar null $result
* @return type
* @return TicketPlugin
*/
static function create()
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* TicketPlugin constructor.
*/
protected function __construct()
{
$settings = array(
'tool_enable' => 'boolean',
'allow_student_add' => 'boolean'
'allow_student_add' => 'boolean',
'allow_category_edition' => 'boolean',
'warn_admin_no_user_in_category' => 'boolean',
'send_warning_to_all_admins' => 'boolean'
);
parent::__construct(
'2.0',
'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier, Julio Montoya',
$settings
);
parent::__construct('1.0', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier', $settings);
}
/**
@ -36,7 +47,6 @@ class TicketPlugin extends Plugin
{
// Create database tables and insert a Tab
require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/database.php';
}
/**
@ -87,4 +97,6 @@ class TicketPlugin extends Plugin
echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>";
}
}
}

@ -3,6 +3,8 @@
namespace Chamilo\CoreBundle\EventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@ -45,6 +47,7 @@ class LegacyLoginListener implements EventSubscriberInterface
return;
}
$token = $this->tokenStorage->getToken();
if ($token) {
$isGranted = $this->container->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY');
@ -67,23 +70,33 @@ class LegacyLoginListener implements EventSubscriberInterface
}
$languages = ['german' => 'de', 'english' => 'en', 'spanish' => 'es', 'french' => 'fr'];
if ($user && isset($languages[$user->getLanguage()])) {
$locale = $languages[$user->getLanguage()];
$locale = isset($languages[$user->getLanguage()]) ? $languages[$user->getLanguage()] : '';
if ($user && !empty($locale)) {
error_log('legacyloginlistener');
error_log($locale);
$user->setLocale($locale);
$request->getSession()->set('_locale_user', $locale);
//$request->getSession()->set('_locale_user', $locale);
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($locale);
$request->getSession()->set('_locale', $locale);
$request->setLocale($locale);
}
$token = new UsernamePasswordToken($user, null, "main", $user->getRoles());
$this->tokenStorage->setToken($token); //now the user is logged in
//now dispatch the login event
$event = new InteractiveLoginEvent($request, $token);
$this->container->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$this->container->get("event_dispatcher")->addListener(
KernelEvents::RESPONSE, array($this, 'redirectUser')
);
}
}
}
@ -98,7 +111,18 @@ class LegacyLoginListener implements EventSubscriberInterface
{
return array(
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 17)),
KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
);
}
/**
* @param FilterResponseEvent $event
*/
public function redirectUser(FilterResponseEvent $event)
{
$uri = $event->getRequest()->getUri();
// on effectue la redirection
$response = new RedirectResponse($uri);
$event->setResponse($response);
}
}

@ -0,0 +1,89 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Chamilo\CoreBundle\Controller\LegacyController;
use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter;
use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter;
use Chamilo\CoreBundle\Framework\Container;
use Doctrine\ORM\EntityManager;
use Chamilo\UserBundle\Entity\User;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Chamilo\CourseBundle\Controller\ToolInterface;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Chamilo\CourseBundle\Event\CourseAccess;
use Chamilo\CourseBundle\Event\SessionAccess;
/**
* Class LocaleListener
* @package Chamilo\CoreBundle\EventListener
*/
class LocaleListener implements EventSubscriberInterface
{
private $defaultLocale;
/** @var ContainerInterface */
protected $container;
/**
* @param string $defaultLocale
*/
public function __construct($defaultLocale = 'en', $container)
{
$this->defaultLocale = $defaultLocale;
$this->container = $container;
}
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->hasPreviousSession()) {
return;
}
// try to see if the locale has been set as a _locale routing parameter
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $locale);
} else {
$locale = $this->defaultLocale;
// 2. Check user locale
// _locale_user is set when user logins the system check UserLocaleListener
$userLocale = $request->getSession()->get('_locale');
if (!empty($userLocale)) {
$locale = $userLocale;
}
// if no explicit locale has been set on this request, use one from the session
$request->setLocale($locale);
$request->getSession()->set('_locale', $locale);
}
}
/**
* @return array
*/
public static function getSubscribedEvents()
{
return array(
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 15)),
);
}
}

@ -51,18 +51,10 @@ class UserLocaleListener
if ($token) {
$user = $token->getUser();
if ($user && isset($languages[$user->getLanguage()])) {
$user->setLocale($languages[$user->getLanguage()]);
$event->getRequest()->setLocale($user->getLocale());
$this->session->set('_locale', $user->getLocale());
$this->session->set('_locale_user', $user->getLocale());
$locale = isset($languages[$user->getLanguage()]) ? $languages[$user->getLanguage()] : '';
if ($user && !empty($locale)) {
$this->session->set('_locale', $locale);
}
}
/*if (null !== $user->getLocale()) {
$this->session->set('_locale', $user->getLocale());
$this->session->set('_locale_user', $user->getLocale());
}*/
}
}

@ -145,7 +145,15 @@ services:
arguments: ["@session"]
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
# - { name: kernel.event_listener, event: kernel.request, method: setLocaleForUnauthenticatedUser}
chamilo_core.listener.locale:
class: Chamilo\CoreBundle\EventListener\LocaleListener
arguments: ["%kernel.default_locale%", "@service_container"]
tags:
- { name: kernel.event_subscriber }
#
# # Settings listener
# chamilo_core.listener.settings:
@ -177,7 +185,7 @@ services:
# tags:
# - { name: kernel.event_listener, event: theme.messages, method: onListMessages }
#
# # Login listener - When user logs in
# Login listener - When user logs in
# chamilo_core.listener.login_success_handler:
# class: Chamilo\CoreBundle\EventListener\LoginSuccessHandler
# arguments: [@router, @security.authorization_checker]

@ -154,6 +154,12 @@ class CQuiz
*/
private $propagateNeg;
/**
* @var boolean
* @ORm\Column(name="save_correct_answers", type="boolean", nullable=false)
*/
private $saveCorrectAnswers;
/**
* @var integer
*
@ -564,6 +570,25 @@ class CQuiz
return $this->propagateNeg;
}
/**
* @param $saveCorrectAnswers boolean
* @return CQuiz
*/
public function setSaveCorrectAnswers($saveCorrectAnswers)
{
$this->saveCorrectAnswers = $saveCorrectAnswers;
return $this;
}
/**
* @return boolean
*/
public function getSaveCorrectAnswers()
{
return $this->saveCorrectAnswers;
}
/**
* Set reviewAnswers
*

@ -185,17 +185,12 @@ if (api_get_setting('go_to_course_after_login') == 'true') {
}
}
//Show the chamilo mascot
// Show the chamilo mascot
if (empty($courseAndSessions['html']) && !isset($_GET['history'])) {
$controller->tpl->assign('welcome_to_course_block', $controller->return_welcome_to_course_block());
}
if($_configuration['course_grid']){
$controller->tpl->assign('content', $courseAndSessions['html']);
}else{
$controller->tpl->assign('content', $courseAndSessions['html']);
}
$controller->tpl->assign('content', $courseAndSessions['html']);
if (api_get_setting('allow_browser_sniffer') == 'true') {
if (isset($_SESSION['sniff_navigator']) && $_SESSION['sniff_navigator'] != "checked") {

@ -5,18 +5,6 @@
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks
# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@ -30,10 +18,6 @@ DirectoryIndex app.php
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/app.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
@ -46,15 +30,15 @@ DirectoryIndex app.php
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule .? - [L]
# Rewrite all other queries to the front controller.
RewriteRule ^ %{ENV:BASE}/app.php [L]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
<IfModule !mod_rewrite.c>

Loading…
Cancel
Save