Merge branch '1.9.x' of ssh://github.com/chamilo/chamilo-lms into chamilo19

1.9.x
Julio Montoya 11 years ago
commit 37a9cb959c
  1. 35
      main/admin/user_edit.php
  2. 24
      main/auth/profile.php
  3. 5
      main/exercice/exercise.class.php
  4. 8
      main/exercice/exercise_submit.php
  5. 2
      main/exercice/fill_blanks.class.php
  6. 4
      main/inc/ajax/model.ajax.php
  7. 2
      main/inc/lib/course.lib.php
  8. 12
      main/inc/lib/groupmanager.lib.php
  9. 14
      main/inc/lib/main_api.lib.php
  10. 121
      main/inc/lib/plugin.class.php
  11. 13
      main/inc/lib/sessionmanager.lib.php
  12. 175
      main/inc/lib/usermanager.lib.php
  13. 4
      main/install/configuration.dist.php
  14. 4
      main/survey/fillsurvey.php
  15. 27
      main/survey/preview.php
  16. 20
      main/survey/survey.lib.php
  17. 665
      main/user/add_users_to_session.php
  18. 355
      main/user/resume_session.php
  19. 158
      main/user/session_list.php
  20. 7
      main/user/user.php
  21. 7
      main/work/work.lib.php
  22. 67
      plugin/ticket/database.php
  23. 144
      plugin/ticket/lang/spanish.php
  24. 82
      plugin/ticket/src/myticket.php
  25. 10
      plugin/ticket/src/new_ticket.php
  26. 8
      plugin/ticket/src/report.php
  27. 24
      plugin/ticket/src/ticket.class.php
  28. 50
      plugin/ticket/src/ticket_details.php
  29. 15
      plugin/ticket/src/ticket_plugin.class.php
  30. 2
      plugin/ticket/src/tutor_report.lib.php

@ -64,6 +64,14 @@ function show_image(image,width,height) {
height = parseInt(height) + 20;
window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \' , resizable=0\');
}
function confirmation(name) {
if (confirm("'.get_lang('AreYouSureToDelete', '').' " + name + " ?")) {
document.forms["profile"].submit();
} else {
return false;
}
}
//-->
</script>';
@ -311,8 +319,7 @@ $form->setDefaults($user_data);
$error_drh = false;
// Validate form
if ($form->validate()) {
$user = $form->getSubmitValues();
$user = $form->getSubmitValues(1);
$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
if ($user['status'] == DRH && $is_user_subscribed_in_course) {
@ -387,8 +394,28 @@ if ($form->validate()) {
$value = date('Y-m-d',$time);
}
}
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
// For array $value -> if exists key 'tmp_name' then must not be empty
// This avoid delete from user field value table when doesn't upload a file
if (is_array($value)) {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) {
//Nothing to do
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
if (array_key_exists('name', $value)) {
$value['name'] = Security::filter_filename($value['name']);
}
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} else {
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} elseif (strpos($key,'remove_extra') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value($user_id, substr($key,13), $extra_value);
}
}
$tok = Security::get_token();
header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);

@ -416,7 +416,7 @@ if ($form->validate()) {
$wrong_current_password = false;
// $user_data = $form->exportValues();
$user_data = $form->getSubmitValues();
$user_data = $form->getSubmitValues(1);
// set password if a new one was provided
if (!empty($user_data['password0'])) {
@ -565,6 +565,10 @@ if ($form->validate()) {
} else {
$extras[$new_key] = $value;
}
} elseif (strpos($key, 'remove_extra_') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value($user_id, substr($key,13), $extra_value);
} else {
if (in_array($key, $available_values_to_modify)) {
$sql .= " $key = '".Database::escape_string($value)."',";
@ -623,7 +627,23 @@ if ($form->validate()) {
if (is_array($extras) && count($extras)> 0) {
foreach ($extras as $key => $value) {
//3. Tags are process in the UserManager::update_extra_field_value by the UserManager::process_tags function
UserManager::update_extra_field_value(api_get_user_id(), $key, $value);
// For array $value -> if exists key 'tmp_name' then must not be empty
// This avoid delete from user field value table when doesn't upload a file
if (is_array($value)) {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) {
//Nothing to do
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
if (array_key_exists('name', $value)) {
$value['name'] = Security::filter_filename($value['name']);
}
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} else {
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
}
}

@ -1733,6 +1733,7 @@ class Exercise
$label = get_lang('NextQuestion');
$class = 'btn btn-primary';
}
$class .= ' question-validate-btn'; // used to select it with jquery
if ($this->type == ONE_PER_PAGE) {
if ($questionNum != 1) {
$prev_question = $questionNum - 2;
@ -1757,6 +1758,7 @@ class Exercise
$all_label = get_lang('EndTest');
$class = 'btn btn-warning';
}
$class .= ' question-validate-btn'; // used to select it with jquery
$all_button = '&nbsp;<a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>';
$all_button .= '&nbsp;<span id="save_all_reponse"></span>';
$html .= $all_button;
@ -2407,7 +2409,8 @@ class Exercise
//Needed to let characters ' and " to work as part of an answer
$choice[$j] = stripslashes($choice[$j]);
} else {
$choice[$j] = trim($choice[$j]);
// This value is the user input, not escaped while correct answer is escaped by fckeditor
$choice[$j] = htmlentities(trim($choice[$j]));
}
//No idea why we api_strtolower user reponses

@ -775,6 +775,12 @@ if (!empty($error)) {
});
$(".no_remind_highlight").hide();
// if the users validates the form using return key, prevent form action and simulates click on validation button
$("#exercise_form").submit(function(){
$(".question-validate-btn").first().trigger("click");
return false;
});
});
function previous_question(question_num) {
@ -1011,7 +1017,7 @@ if (!empty($error)) {
//BUtton save and continue
switch ($objExercise->type) {
case ONE_PER_PAGE:
case ONE_PER_PAGE:
$exercise_actions .= $objExercise->show_button($questionId, $current_question);
break;
case ALL_ON_ONE_PAGE :

@ -162,8 +162,6 @@ class FillBlanks extends Question
{
global $charset;
$answer = $form->getSubmitValue('answer');
//Due the fckeditor transform the elements to their HTML value
$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
//remove the :: eventually written by the user
$answer = str_replace('::','',$answer);

@ -50,8 +50,10 @@ if (!in_array(
'get_user_course_report',
'get_sessions_tracking'
)
)) {
) && !$_REQUEST['from_course_session']) {
api_protect_admin_script(true);
} elseif ($_REQUEST['from_course_session'] == 1) {
api_protect_teacher_script(true);
}
// Search features

@ -4237,7 +4237,7 @@ class CourseManager
$my_course['extra_info']['register_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?action=subscribe&amp;sec_token='.$stok, array('class' => 'btn btn-primary'));
}
if ($access_link && in_array('enter', $access_link)) {
if ($access_link && in_array('enter', $access_link) || $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
}

@ -1472,11 +1472,13 @@ class GroupManager
$table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
if (!empty($user_ids)) {
foreach ($user_ids as $user_id) {
$user_id = Database::escape_string($user_id);
$group_id = Database::escape_string($group_id);
$sql = "INSERT INTO ".$table_group_user." (c_id, user_id, group_id)
VALUES ('$course_id', '".$user_id."', '".$group_id."')";
$result &= Database::query($sql);
if (self::can_user_subscribe($user_id, $group_id)) {
$user_id = Database::escape_string($user_id);
$group_id = Database::escape_string($group_id);
$sql = "INSERT INTO ".$table_group_user." (c_id, user_id, group_id)
VALUES ('$course_id', '".$user_id."', '".$group_id."')";
$result &= Database::query($sql);
}
}
}
return $result;

@ -976,6 +976,20 @@ function api_protect_admin_script($allow_sessions_admins = false, $allow_drh = f
return true;
}
/**
* Function used to protect a teacher script.
* The function blocks access when the user has no teacher rights.
*
* @author Yoselyn Castillo
*/
function api_protect_teacher_script($allow_sessions_admins = false) {
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
return false;
}
return true;
}
/**
* Function used to prevent anonymous users from accessing a script.
*

@ -468,12 +468,12 @@ class Plugin
{
}
/**
* Add a tab to chamilo's platform
* @param string $tabName
* @return int
*/
/**
* Add a tab to platform
* @param strings $tabName
* @param string $url
* @return boolean
*/
public function addTab($tabName, $url)
{
$sql = "SELECT *
@ -481,8 +481,9 @@ class Plugin
WHERE variable = 'show_tabs'
AND subkey like 'custom_tab_%'";
$result = Database::query($sql);
$customTabsNum = Database::count_rows($result);
$customTabsNum = Database::num_rows($result);
$tabNum = $customTabsNum + 1;
//Avoid Tab Name Spaces
@ -521,35 +522,33 @@ class Plugin
/**
* Delete a tab to chamilo's platform
* @param string $key
*
* @return int
*/
public function deleteTab($key)
{
$sql = "SELECT * FROM settings_current
WHERE
variable = 'show_tabs' AND
subkey <> '$key'";
$result = Database::query($sql);
$tabs = Database::store_result($result);
$customTabsNum = count($tabs);
//$customTabsNum = Database::count_rows($result);
$resp = false;
$sql = "SELECT *
FROM settings_current
WHERE variable = 'show_tabs'
AND subkey <> '$key'
AND subkey like 'custom_tab_%'
";
$resp = $result = Database::query($sql);
$customTabsNum = Database::num_rows($result);
if (!empty($key)) {
$whereCondition = array(
'variable = ? AND subkey = ?' => array('show_tabs', $key)
);
Database::delete('settings_current', $whereCondition);
$resp = Database::delete('settings_current', $whereCondition);
//if there is more than one tab
//re enumerate them
if ($customTabsNum > 0) {
//reenumerate them
if (!empty($customTabsNum) && $customTabsNum > 0) {
$i = 1;
foreach ($tabs as $row) {
$attributes = array(
'subkey' => 'custom_tab_' . $i
);
$resp = $this->updateTab($row['subkey'], $attributes);
$this->updateTab($row['subkey'], $attributes);
$i++;
}
}
@ -574,80 +573,4 @@ class Plugin
return $resp;
}
/**
* Add additional plugin Settings
* @param array $settings
*
* @return bool
*/
public function addExtraSettings($settings)
{
$pluginName = $this->get_name();
$resp = false;
foreach ($settings as $setting => $value) {
$attributes = array(
'variable' => 'plugin_settings_' . $pluginName,
'subkey' => $setting,
'selected_value' => $value,
'category' => 'PluginSettings'
);
$valueSetting = $this->getExtraSettingValue($setting);
if (empty($valueSetting)) {
$resp = Database::insert('settings_current', $attributes);
}
}
return $resp;
}
/**
* Edit additional Plugin Settings
* @param array $settings
* @return bool
*/
public function editExtraSetting($key, $attributes)
{
$pluginName = $this->get_name();
$whereCondition = array(
'variable = ? AND subkey = ?' => array('plugin_settings_' . $pluginName, $key)
);
$resp = Database::update('settings_current', $attributes, $whereCondition);
return $resp;
}
/**
* Delete all additional plugin settings
*/
public function deleteExtraSettings()
{
$pluginName = $this->get_name();
$whereCond = array(
'variable = ?' => 'plugin_settings_' . $pluginName
);
$resp = Database::delete('settings_current', $whereCond);
return $resp;
}
/**
* Give extra setting value
* @param string $settingName
* @return string
*/
public function getExtraSettingValue($settingName)
{
$pluginName = $this->get_name();
$fullSetting = api_get_full_setting('plugin_settings_' . $pluginName, $settingName);
if (empty($fullSetting)) {
return false;
} else {
$setting = current($fullSetting);
return $setting['selected_value'];
}
}
}

@ -351,7 +351,10 @@ class SessionManager
$extraJoin = " INNER JOIN $tbl_session_rel_user sru
ON sru.id_session = s.id ";
}
if (api_is_allowed_to_edit() && !api_is_platform_admin()) {
$where.=" AND s.id_coach = $user_id ";
}
$coach_name = " CONCAT(u.lastname , ' ', u.firstname) as coach_name ";
if (api_is_western_name_order()) {
@ -3032,6 +3035,14 @@ class SessionManager
}
}
}
static function protect_teacher_session_edit($id) {
if (!api_is_coach($id) && !api_is_platform_admin()) {
api_not_allowed(true);
} else {
return true;
}
}
/**
* @param string $course_code

@ -1271,6 +1271,51 @@ class UserManager
return $ok ? $filename : false;
}
/**
* Update User extra field file type into {user_folder}/{$extra_field}
* @param $user_id The user internal identification number
* @param string $extra_field The $extra_field The extra field name
* @param null $file The filename
* @param null $source_file The temporal filename
* @return bool|null return filename if success, but false
*/
public static function update_user_extra_file($user_id, $extra_field = '', $file = null, $source_file = null)
{
// Add Filter
$source_file = Security::filter_filename($source_file);
$file = Security::filter_filename($file);
if (empty($user_id)) {
return false;
}
if (empty($source_file)) {
$source_file = $file;
}
// User-reserved directory where extra file have to be placed.
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path = $path_info['dir'];
if (!empty($extra_field)) {
$path .= $extra_field . '/';
}
// If this directory does not exist - we create it.
if (!file_exists($path)) {
@mkdir($path, api_get_permissions_for_new_directories(), true);
}
if (filter_extension($file)) {
if (@move_uploaded_file($source_file,$path.$file)) {
if ($extra_field) {
return $extra_field.'/'.$file;
} else {
return $file;
}
}
}
return false; // this should be returned if anything went wrong with the upload
}
/**
* Deletes user photos.
* Note: This method relies on configuration setting from main/inc/conf/profile.conf.php
@ -1317,7 +1362,7 @@ class UserManager
foreach ($productions as $file) {
$production_list .= '<li><a href="'.$production_dir.urlencode($file).'" target="_blank">'.htmlentities($file).'</a>';
if ($showdelete) {
$production_list .= '<input type="image" name="remove_production['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($file).'" onclick="javascript: return confirmation(\''.htmlentities($file).'\');" /></li>';
$production_list .= '<input style="width:16px;" type="image" name="remove_production['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($file).'" onclick="javascript: return confirmation(\''.htmlentities($file).'\');" /></li>';
}
}
$production_list .= '</ul>';
@ -1447,6 +1492,7 @@ class UserManager
}
$sqluf = "SELECT * FROM $t_uf WHERE field_variable='$fname'";
$resuf = Database::query($sqluf);
$is_extra_file = false;
if (Database::num_rows($resuf) == 1) {
//ok, the field exists
// Check if enumerated field, if the option is available
@ -1482,6 +1528,19 @@ class UserManager
return false; //enumerated type but no option found
}
break;
case self::USER_FIELD_TYPE_FILE:
$is_extra_file = true;
if (isset($fvalue['tmp_name'])) {
// Filter against dangerous filenames
$fvalue['name'] = Security::filter_filename($fvalue['name']);
$fvalue['tmp_name'] = Security::filter_filename($fvalue['tmp_name']);
// Update and recover the filename
$fvalues = UserManager::update_user_extra_file($user_id, $rowuf['field_variable'], $fvalue['name'], $fvalue['tmp_name']);
} else {
// Set empty string to $fvalues to delete it
$fvalues = '';
}
break;
case 1:
case 2:
default:
@ -1511,6 +1570,10 @@ class UserManager
//we need to update the current record
$rowufv = Database::fetch_array($resufv);
if ($rowufv['field_value'] != $fvalues) {
if ($is_extra_file) {
// To remove from user folder
self::remove_user_extra_file($user_id, $fname, $rowufv['field_value']);
}
// If the new field is empty, delete it
if ($fvalues == '') {
$sql_query = "DELETE FROM $t_ufv WHERE id = ".$rowufv['id'].";";
@ -1606,6 +1669,105 @@ class UserManager
return $fields;
}
/**
* Build a list of extra file already uploaded in $user_folder/{$extra_field}/
* @param $user_id
* @param $extra_field
* @param bool $force
* @param bool $showdelete
* @return bool|string
*/
public static function build_user_extra_file_list($user_id, $extra_field, $force = false, $showdelete = false)
{
if (!$force && !empty($_POST['remove_'.$extra_field])) {
return true; // postpone reading from the filesystem
}
$extra_files = self::get_user_extra_files($user_id, $extra_field);
if (empty($extra_files)) {
return false;
}
$path_info = self::get_user_picture_path_by_id($user_id, 'web', true);
$path = $path_info['dir'];
$del_image = api_get_path(WEB_CODE_PATH).'img/delete.gif';
$del_text = get_lang('Delete');
$extra_file_list = '';
if (count($extra_files) > 0) {
$extra_file_list = '<ul id="productions">';
foreach ($extra_files as $file) {
$filename = substr($file,strlen($extra_field)+1);
$extra_file_list .= '<li><a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">'.htmlentities($filename).'</a>';
if ($showdelete) {
$extra_file_list .= '<input style="width:16px;" type="image" name="remove_extra_' . $extra_field . '['.urlencode($file).']" src="'.$del_image.'" alt="'.$del_text.'" title="'.$del_text.' '.htmlentities($filename).'" onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
}
}
$extra_file_list .= '</ul>';
}
return $extra_file_list;
}
/**
* Get valid filenames in $user_folder/{$extra_field}/
* @param $user_id
* @param $extra_field
* @param bool $full_path
* @return array
*/
public static function get_user_extra_files($user_id, $extra_field, $full_path = false)
{
if (!$full_path) {
// Nothing to do
} else {
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
$path = $path_info['dir'];
}
$extra_data = self::get_extra_user_data_by_field($user_id, $extra_field);
$extra_files = $extra_data[$extra_field];
if (is_array($extra_files)) {
var_dump($extra_files); exit;
foreach ($extra_files as $key => $value) {
if (!$full_path) {
// Relative path from user folder
$files[] = $value;
} else {
$files[] = $path.$value;
}
}
} elseif (!empty($extra_files)) {
if (!$full_path) {
// Relative path from user folder
$files[] = $extra_files;
} else {
$files[] = $path.$extra_files;
}
}
return $files; // can be an empty array
}
/**
* Remove an {$extra_file} from the user folder $user_folder/{$extra_field}/
* @param $user_id
* @param $extra_field
* @param $extra_file
* @return bool
*/
public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
{
$extra_file = Security::filter_filename($extra_file);
$path_info = self::get_user_picture_path_by_id($user_id, 'system', true);
if (strpos($extra_file, $extra_field) !== false) {
$path_extra_file = $path_info['dir'].$extra_file;
} else {
$path_extra_file = $path_info['dir'].$extra_field.'/'.$extra_file;
}
if (is_file($path_extra_file)) {
unlink($path_extra_file);
return true;
}
return false;
}
/**
* Get the list of options attached to an extra field
* @param string $fieldname the name of the field
@ -4342,14 +4504,13 @@ EOF;
$form->freeze('extra_'.$field_details[1]);
break;
case self::USER_FIELD_TYPE_FILE:
if (!empty($field_details[3])) {
$uPaths = UserManager::get_user_picture_path_by_id($user_id);
$path = '<a href="'.$uPaths['dir'].$field_details[3]."'>".$field_details[3].'</a>';
$form->addElement('html', 'extra_'.$field_details[1].'_link', $path, null, '');
$extra_field = 'extra_'.$field_details[1];
$form->addElement('file', $extra_field, $field_details[3], null, '');
if ($extra_file_list = UserManager::build_user_extra_file_list($user_id, $field_details[1], '', true)) {
$form->addElement('static', $extra_field . '_list', null, $extra_file_list);
}
$form->addElement('file', 'extra_'.$field_details[1], $field_details[3], null, '');
if ($field_details[7] == 0) {
$form->freeze('extra_'.$field_details[1]);
$form->freeze($extra_field);
}
break;
}

@ -189,4 +189,6 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
// Display group's forum in general forum tool
//$_configuration['display_groups_forum_in_general_tool'] = true;
// Boost query on last connection time
//$_configuration['save_user_last_login'] = true;
//$_configuration['save_user_last_login'] = true;
// Allow course tutors in sessions to add existing students to their session
//$_configuration['allow_tutors_to_assign_students_to_session'] = 'false';

@ -70,8 +70,8 @@ if ($surveyCode != "") {
$resultAnonymous = Database::query($sql);
$rowAnonymous = Database::fetch_array($resultAnonymous, 'ASSOC');
// If is anonymous and is not allowed to take the survey to anonymous users, forbid access:
if (!isset($rowAnonymous['anonymous']) || ($rowAnonymous['anonymous'] == 0 && api_is_anonymous($_user['user_id'], true)) || count($rowAnonymous) == 0) {
api_not_allowed();
if (!isset($rowAnonymous['anonymous']) || ($rowAnonymous['anonymous'] == 0 && api_is_anonymous()) || count($rowAnonymous) == 0) {
api_not_allowed(true);
}
// If is anonymous and it is allowed to take the survey as anonymous, mark survey as anonymous.
}

@ -32,6 +32,7 @@ $course_id = api_get_course_int_id();
$userId = api_get_user_id();
$surveyId = Database::escape_string($_GET['survey_id']);
$userInvited = 0;
$userAnonymous = 0;
//query to ask if logged user is allowed to see the preview (if he is invited of he is a teacher)
$sql = "SELECT survey_invitation.user
@ -46,11 +47,7 @@ $result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$userInvited = 1;
}
if ($userInvited == 0) {
if(!api_is_allowed_to_edit()) {
api_not_allowed();
}
}
// We exit here if ther is no valid $_GET parameter
if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])){
Display::display_header(get_lang('SurveyPreview'));
@ -71,11 +68,21 @@ if (empty($survey_data)) {
}
$urlname = strip_tags($survey_data['title']);
// Breadcrumbs
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname);
if (api_is_allowed_to_edit()) {
// Breadcrumbs
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id, 'name' => $urlname);
}
$courseCode = $_GET['cidReq'];
$surveyAnonymous = survey_manager::get_survey($survey_id, 0, $courseCode);
$surveyAnonymous = $surveyAnonymous['anonymous'];
if ($surveyAnonymous == 0 && api_is_anonymous()) {
api_not_allowed(true);
} elseif ($surveyAnonymous == 0 && $userInvited == 0) {
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
}
// Header
Display :: display_header(get_lang('SurveyPreview'));

@ -149,6 +149,7 @@ class survey_manager
$return['shuffle'] = $return['shuffle'];
$return['parent_id'] = $return['parent_id'];
$return['survey_version'] = $return['survey_version'];
$return['anonymous'] = $return['anonymous'];
}
return $return;
}
@ -2677,7 +2678,7 @@ class SurveyUtil
$name = $person['invited_user'];
}
} else {
$name = $key + 1;
$name = get_lang('Anonymous') . ' ' . ($key + 1);
$id = $person;
}
echo '<option value="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.Security::remove_XSS($id).'" ';
@ -3198,9 +3199,15 @@ class SurveyUtil
$answers_of_user = array();
$sql = "SELECT * FROM $table_survey_answer WHERE c_id = $course_id AND survey_id='".Database::escape_string($_GET['survey_id'])."' ORDER BY user ASC";
$result = Database::query($sql);
$i = 1;
while ($row = Database::fetch_array($result)) {
if ($old_user != $row['user'] && $old_user != '') {
SurveyUtil::display_complete_report_row($survey_data, $possible_answers, $answers_of_user, $old_user, $questions, $display_extra_user_fields);
$userParam = $old_user;
if ($survey_data['anonymous'] != 0) {
$userParam = $i;
$i++;
}
SurveyUtil::display_complete_report_row($survey_data, $possible_answers, $answers_of_user, $userParam, $questions, $display_extra_user_fields);
$answers_of_user=array();
}
if ($questions[$row['question_id']]['type'] != 'open') {
@ -3210,7 +3217,12 @@ class SurveyUtil
}
$old_user = $row['user'];
}
SurveyUtil::display_complete_report_row($survey_data, $possible_answers, $answers_of_user, $old_user, $questions, $display_extra_user_fields);
$userParam = $old_user;
if ($survey_data['anonymous'] != 0) {
$userParam = $i;
$i++;
}
SurveyUtil::display_complete_report_row($survey_data, $possible_answers, $answers_of_user, $userParam, $questions, $display_extra_user_fields);
// This is to display the last user
echo '</table>';
echo '</form>';
@ -3245,7 +3257,7 @@ class SurveyUtil
echo '<th>'.$user.'</th>'; // the user column
}
} else {
echo '<th>' . get_lang('Anonymous') . '</th>';
echo '<th>' . get_lang('Anonymous') . ' ' . $user . '</th>';
}
if ($display_extra_user_fields) {

@ -0,0 +1,665 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
// name of the language file that needs to be included
$language_file = array('admin','registration');
// resetting the course id
$cidReset = true;
// including some necessary files
require_once '../inc/global.inc.php';
require_once '../inc/lib/xajax/xajax.inc.php';
$xajax = new xajax();
$xajax -> registerFunction ('search_users');
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
$id_session = intval($_GET['id_session']);
SessionManager::protect_teacher_session_edit($id_session);
// setting breadcrumbs
if (api_is_platform_admin()) {
$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session,"name" => get_lang('SessionOverview'));
}
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
// setting the name of the tool
$tool_name = get_lang('SubscribeUsersToSession');
$add_type = 'unique';
if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
//checking for extra field with filter on
$extra_field_list= UserManager::get_extra_fields();
$new_field_list = array();
if (is_array($extra_field_list)) {
foreach ($extra_field_list as $extra_field) {
//if is enabled to filter and is a "<select>" field type
if ($extra_field[8]==1 && $extra_field[2]==4 ) {
$new_field_list[] = array('name'=> $extra_field[3], 'variable'=>$extra_field[1], 'data'=> $extra_field[9]);
}
}
}
function search_users($needle, $type)
{
global $tbl_user,$tbl_session_rel_user,$id_session;
$xajax_response = new XajaxResponse();
$return = '';
if (!empty($needle) && !empty($type)) {
//normal behaviour
if ($type == 'any_session' && $needle == 'false') {
$type = 'multiple';
$needle = '';
}
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = Database::escape_string($needle);
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$cond_user_id = '';
//Only for single & multiple
if (in_array($type, array('single','multiple'))) {
if (!empty($id_session)) {
$id_session = intval($id_session);
// check id_user from session_rel_user table
$sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
$res = Database::query($sql);
$user_ids = array();
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_row($res)) {
$user_ids[] = (int)$row[0];
}
}
if (count($user_ids) > 0) {
$cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
}
}
}
switch ($type) {
case 'single':
// search users where username or firstname or lastname begins likes $needle
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.''.
$order_clause.
' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
WHERE '.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id.
$order_clause;
break;
case 'any_session':
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
WHERE s.id_user IS null AND user.status<>'.DRH.' AND
user.status<>6 '.$cond_user_id.
$order_clause;
break;
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
switch ($type) {
case 'single':
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND (username LIKE "'.$needle.'%"
OR firstname LIKE "'.$needle.'%"
OR lastname LIKE "'.$needle.'%") AND user.status<>6 AND user.status<>'.DRH.' '.
$order_clause.
' LIMIT 11';
break;
case 'multiple':
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND
'.(api_sort_by_first_name() ? 'firstname' : 'lastname').' LIKE "'.$needle.'%" AND user.status<>'.DRH.' AND user.status<>6 '.$cond_user_id.
$order_clause;
break;
case 'any_session' :
$sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user LEFT OUTER JOIN '.$tbl_session_rel_user.' s ON (s.id_user = user.user_id)
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND
s.id_user IS null AND
user.status<>'.DRH.' AND
user.status<>6 '.$cond_user_id.
$order_clause;
break;
}
}
}
$rs = Database::query($sql);
$i=0;
if ($type == 'single') {
while ($user = Database :: fetch_array($rs)) {
$i++;
if ($i<=10) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\''.$user['user_id'].'\',\''.$person_name.' ('.$user['username'].')'.'\')">'.$person_name.' ('.$user['username'].')</a><br />';
} else {
$return .= '...<br />';
}
}
$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
} else {
global $nosessionUsersList;
$return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">';
while ($user = Database :: fetch_array($rs)) {
$person_name = api_get_person_name($user['firstname'], $user['lastname']);
$return .= '<option value="'.$user['user_id'].'">'.$person_name.' ('.$user['username'].')</option>';
}
$return .= '</select>';
$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
}
}
return $xajax_response;
}
$xajax -> processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '
<script type="text/javascript">
function add_user_to_session (code, content) {
document.getElementById("user_to_add").value = "";
document.getElementById("ajax_list_users_single").innerHTML = "";
destination = document.getElementById("destination_users");
for (i=0;i<destination.length;i++) {
if(destination.options[i].text == content) {
return false;
}
}
destination.options[destination.length] = new Option(content,code);
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function remove_item(origin) {
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
origin.options[i]=null;
i = i-1;
}
}
}
function validate_filter() {
document.formulaire.add_type.value = \''.$add_type.'\';
document.formulaire.form_sent.value=0;
document.formulaire.submit();
}
function checked_in_no_session(checked) {
$("#first_letter_user")
.find("option")
.attr("selected", false);
xajax_search_users(checked, "any_session");
}
function change_select(val) {
$("#user_with_any_session_id").attr("checked", false);
xajax_search_users(val,"multiple");
}
</script>';
$form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession='';
$UserList = $SessionList = array();
$sessions = array();
$noPHP_SELF = true;
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
$form_sent = $_POST['form_sent'];
$firstLetterUser = $_POST['firstLetterUser'];
$firstLetterSession = $_POST['firstLetterSession'];
$UserList = $_POST['sessionUsersList'];
if (!is_array($UserList)) {
$UserList=array();
}
if ($form_sent == 1) {
//added a parameter to send emails when registering a user
SessionManager::suscribe_users_to_session($id_session, $UserList, null, true);
header('Location: resume_session.php?id_session='.$id_session);
exit;
}
}
$session_info = SessionManager::fetch($id_session);
Display::display_header($tool_name);
$nosessionUsersList = $sessionUsersList = array();
$ajax_search = $add_type == 'unique' ? true : false;
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if ($ajax_search) {
$sql = "SELECT user_id, lastname, firstname, username, id_session
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND $tbl_session_rel_user.id_session = ".intval($id_session)."
WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql="SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND $tbl_session_rel_user.id_session = ".intval($id_session)."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
}
$result = Database::query($sql);
$users = Database::store_result($result);
foreach ($users as $user) {
$sessionUsersList[$user['user_id']] = $user ;
}
unset($users); //clean to free memory
} else {
//Filter by Extra Fields
$use_extra_fields = false;
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) {
$result_list=array();
foreach ($new_field_list as $new_field) {
$varname = 'field_'.$new_field['variable'];
if (UserManager::is_extra_field_available($new_field['variable'])) {
if (isset($_POST[$varname]) && $_POST[$varname]!='0') {
$use_extra_fields = true;
$extra_field_result[]= UserManager::get_extra_user_data_by_value($new_field['variable'], $_POST[$varname]);
}
}
}
}
}
if ($use_extra_fields) {
$final_result = array();
if (count($extra_field_result)>1) {
for($i=0;$i<count($extra_field_result)-1;$i++) {
if (is_array($extra_field_result[$i+1])) {
$final_result = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]);
}
}
} else {
$final_result = $extra_field_result[0];
}
$where_filter ='';
if (api_is_multiple_url_enabled()) {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " AND u.user_id IN ('".implode("','",$final_result)."') ";
} else {
//no results
$where_filter = " AND u.user_id = -1";
}
} else {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " WHERE u.user_id IN ('".implode("','",$final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.user_id = -1";
}
}
}
if ($use_extra_fields) {
$sql = "SELECT user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
$where_filter AND u.status<>".DRH." AND u.status<>6
$order_clause";
} else {
$sql = "SELECT user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
WHERE u.status<>".DRH." AND u.status<>6
$order_clause";
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id $where_filter AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
}
$result = Database::query($sql);
$users = Database::store_result($result,'ASSOC');
foreach ($users as $uid => $user) {
if ($user['id_session'] != $id_session) {
$nosessionUsersList[$user['user_id']] = array('fn'=>$user['firstname'],'ln'=>$user['lastname'],'un'=>$user['username']) ;
unset($users[$uid]);
}
}
unset($users); //clean to free memory
//filling the correct users in list
$sql="SELECT user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
WHERE u.status<>".DRH." AND u.status<>6 $order_clause";
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql="SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.id_session = '$id_session' AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH."
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6
$order_clause";
}
}
$result = Database::query($sql);
$users = Database::store_result($result,'ASSOC');
foreach ($users as $uid => $user) {
if ($user['id_session'] == $id_session) {
$sessionUsersList[$user['user_id']] = $user;
if (array_key_exists($user['user_id'],$nosessionUsersList)) {
unset($nosessionUsersList[$user['user_id']]);
}
}
unset($users[$uid]);
}
unset($users); //clean to free memory
}
if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id_session='.$id_session.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
} else {
$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
$link_add_type_multiple = '<a href="'.api_get_self().'?id_session='.$id_session.'&amp;add='.Security::remove_XSS($_GET['add']).'&amp;add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
}
$link_add_group = '<a href="usergroups.php">'.Display::return_icon('multiple.gif',get_lang('RegistrationByUsersGroups')).get_lang('RegistrationByUsersGroups').'</a>';
?>
<div class="actions">
<?php echo $link_add_type_unique ?>&nbsp;|&nbsp;<?php echo $link_add_type_multiple ?>&nbsp;|&nbsp;<?php echo $link_add_group; ?>
</div>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&id_session=<?php echo $id_session; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') </legend>'; ?>
<?php
if ($add_type == 'multiple') {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) {
echo '<h3>'.get_lang('FilterUsers').'</h3>';
foreach ($new_field_list as $new_field) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
echo '&nbsp;<select name="'.$varname.'">';
echo '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked='';
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option[1]) {
$checked = 'selected="true"';
}
}
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
}
echo '</select>';
echo '&nbsp;&nbsp;';
}
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
}
}
}
?>
<input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="add_type" />
<?php
if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API
}
?>
<div class="row">
<div class="span5">
<div class="multiple_select_header">
<b><?php echo get_lang('UserListInPlatform') ?> :</b>
<?php if ($add_type == 'multiple') { ?>
<?php echo get_lang('FirstLetterUser'); ?> :
<select id="first_letter_user" name="firstLetterUser" onchange = "change_select(this.value);" >
<option value = "%">--</option>
<?php
echo Display :: get_alphabet_options();
?>
</select>
<?php } ?>
</div>
<div id="content_source">
<?php
if (!($add_type == 'multiple')) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
<div id="ajax_list_users_single"></div>
<?php
} else {
?>
<div id="ajax_list_users_multiple">
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" class="span5">
<?php
foreach ($nosessionUsersList as $uid => $enreg) {
?>
<option value="<?php echo $uid; ?>" <?php if(in_array($uid,$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['fn'], $enreg['ln']).' ('.$enreg['un'].')'; ?></option>
<?php
}
?>
</select>
</div>
<input type="checkbox" onchange="checked_in_no_session(this.checked);" name="user_with_any_session" id="user_with_any_session_id">
<label for="user_with_any_session_id"><?php echo get_lang('UsersRegisteredInNoSession'); ?></label>
<?php
}
unset($nosessionUsersList);
?>
</div>
</div>
<div class="span2">
<div style="padding-top:54px;width:auto;text-align: center;">
<?php
if ($ajax_search) {
?>
<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button>
<?php
} else {
?>
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))"></button>
<br /><br />
<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))"></button>
<?php
}
?>
</div>
<br />
<br />
<?php
if (isset($_GET['add'])) {
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('FinishSessionCreation').'</button>';
} else {
//@todo see that the call to "valide()" doesn't duplicate the onsubmit of the form (necessary to avoid delete on "enter" key pressed)
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToSession').'</button>';
}
?>
</div>
<div class="span5">
<div class="multiple_select_header">
<b><?php echo get_lang('UserListInSession') ?> :</b>
</div>
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" class="span5">
<?php
foreach($sessionUsersList as $enreg) {
?>
<option value="<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
<?php
}
unset($sessionUsersList);
?>
</select>
</div>
</div>
</form>
<script>
<!--
function moveItem(origin , destination)
{
for (var i = 0 ; i<origin.options.length ; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options)
{
newOptions = new Array();
for (i = 0 ; i<options.length ; i++)
newOptions[i] = options[i];
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0 ; i < newOptions.length ; i++)
options[i] = newOptions[i];
}
function mysort(a, b)
{
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
}
function valide()
{
var options = document.getElementById('destination_users').options;
for (i = 0 ; i<options.length ; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
function loadUsersInSelect(select)
{
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('origin_users'));
sessionUsers = makepost(document.getElementById('destination_users'));
nosessionClasses = makepost(document.getElementById('origin_classes'));
sessionClasses = makepost(document.getElementById('destination_classes'));
xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
xhr_object.onreadystatechange = function() {
if (xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
//alert(xhr_object.responseText);
}
}
}
function makepost(select)
{
var options = select.options;
var ret = "";
for (i = 0 ; i<options.length ; i++)
ret = ret + options[i].value +'::'+options[i].text+";;";
return ret;
}
-->
</script>
<?php
} else {
api_not_allowed();
}
/* FOOTER */
Display::display_footer();

@ -0,0 +1,355 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Bart Mollet, Julio Montoya lot of fixes
* @package chamilo.admin
*/
/* INIT SECTION */
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
$id_session = (int)$_GET['id_session'];
SessionManager::protect_teacher_session_edit($id_session);
$tool_name = get_lang('SessionOverview');
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
FROM '.$tbl_session.' LEFT JOIN '.$tbl_user.' ON id_coach = user_id
WHERE '.$tbl_session.'.id='.$id_session;
$rs = Database::query($sql);
$session = Database::store_result($rs);
$session = $session[0];
$sql = 'SELECT name FROM '.$tbl_session_category.' WHERE id = "'.intval($session['session_category_id']).'"';
$rs = Database::query($sql);
$session_category = '';
if (Database::num_rows($rs)>0) {
$rows_session_category = Database::store_result($rs);
$rows_session_category = $rows_session_category[0];
$session_category = $rows_session_category['name'];
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
$url_id = api_get_current_access_url_id();
switch ($action) {
case 'add_user_to_url':
$user_id = $_REQUEST['user_id'];
$result = UrlManager::add_user_to_url($user_id, $url_id);
$user_info = api_get_user_info($user_id);
if ($result) {
$message = Display::return_message(get_lang('UserAdded').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']), 'confirm');
}
break;
case 'delete':
$idChecked = $_GET['idChecked'];
if(is_array($idChecked)) {
$my_temp = array();
foreach ($idChecked as $id){
$my_temp[]= Database::escape_string($id);// forcing the escape_string
}
$idChecked = $my_temp;
$idChecked="'".implode("','",$idChecked)."'";
Database::query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)");
$nbr_affected_rows=Database::affected_rows();
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)");
Database::query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'");
}
if (!empty($_GET['class'])){
Database::query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".Database::escape_string($_GET['class']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'");
}
if (!empty($_GET['user'])) {
Database::query("DELETE FROM $tbl_session_rel_user WHERE relation_type<>".SESSION_RELATION_TYPE_RRHH." AND id_session='$id_session' AND id_user=".intval($_GET['user']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'");
Database::query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".intval($_GET['user']));
$nbr_affected_rows=Database::affected_rows();
Database::query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'");
}
break;
}
Display::display_header($tool_name);
if (!empty($_GET['warn'])) {
Display::display_warning_message(urldecode($_GET['warn']));
}
if (!empty($message)) {
echo $message;
}
echo Display::page_header(Display::return_icon('session.png', get_lang('Session')).' '.$session['name']);
echo Display::page_subheader(get_lang('GeneralProperties').$url);
?>
<!-- General properties -->
<table class="data_table">
<tr>
<td><?php echo get_lang('GeneralCoach'); ?> :</td>
<td><?php echo api_get_person_name($session['firstname'], $session['lastname']).' ('.$session['username'].')' ?></td>
</tr>
<?php if(!empty($session_category)) { ?>
<tr>
<td><?php echo get_lang('SessionCategory') ?></td>
<td><?php echo $session_category; ?></td>
</tr>
<?php } ?>
<tr>
<td><?php echo get_lang('Date'); ?> :</td>
<td>
<?php
if ($session['date_start'] == '00-00-0000' && $session['date_end']== '00-00-0000' ) {
echo get_lang('NoTimeLimits');
}
else {
if ($session['date_start'] != '00-00-0000') {
//$session['date_start'] = Display::tag('i', get_lang('NoTimeLimits'));
$session['date_start'] = get_lang('From').' '.$session['date_start'];
} else {
$session['date_start'] = '';
}
if ($session['date_end'] == '00-00-0000') {
$session['date_end'] ='';
} else {
$session['date_end'] = get_lang('Until').' '.$session['date_end'];
}
echo $session['date_start'].' '.$session['date_end'];
}
?>
</td>
</tr>
<!-- show nb_days_before and nb_days_after only if they are different from 0 -->
<tr>
<td>
<?php echo api_ucfirst(get_lang('DaysBefore')) ?> :
</td>
<td>
<?php echo intval($session['nb_days_access_before_beginning']) ?>
</td>
</tr>
<tr>
<td>
<?php echo api_ucfirst(get_lang('DaysAfter')) ?> :
</td>
<td>
<?php echo intval($session['nb_days_access_after_end']) ?>
</td>
</tr>
<tr>
<td>
<?php echo api_ucfirst(get_lang('SessionVisibility')) ?> :
</td>
<td>
<?php if ($session['visibility']==1) echo get_lang('ReadOnly'); elseif($session['visibility']==2) echo get_lang('Visible');elseif($session['visibility']==3) echo api_ucfirst(get_lang('Invisible')) ?>
</td>
</tr>
<?php
$multiple_url_is_on = api_get_multiple_access_url();
if ($multiple_url_is_on) {
echo '<tr><td>';
echo 'URL';
echo '</td>';
echo '<td>';
$url_list = UrlManager::get_access_url_from_session($id_session);
foreach($url_list as $url_data) {
echo $url_data['url'].'<br />';
}
echo '</td></tr>';
}
?>
</table>
<br />
<?php
echo Display::page_subheader(get_lang('CourseList').$url);
?>
<!--List of courses -->
<table class="data_table">
<tr>
<th width="35%"><?php echo get_lang('CourseTitle'); ?></th>
<th width="30%"><?php echo get_lang('CourseCoach'); ?></th>
<th width="20%"><?php echo get_lang('UsersNumber'); ?></th>
</tr>
<?php
if ($session['nbr_courses'] == 0){
echo '<tr>
<td colspan="4">'.get_lang('NoCoursesForThisSession').'</td>
</tr>';
} else {
// select the courses
$sql = "SELECT code,title,visual_code, nbr_users
FROM $tbl_course,$tbl_session_rel_course
WHERE course_code = code
AND id_session='$id_session'
ORDER BY title";
$result=Database::query($sql);
$courses=Database::store_result($result);
foreach ($courses as $course) {
//select the number of users
$sql = " SELECT count(*) FROM $tbl_session_rel_user sru, $tbl_session_rel_course_rel_user srcru
WHERE srcru.id_user = sru.id_user AND srcru.id_session = sru.id_session AND srcru.course_code = '".Database::escape_string($course['code'])."'
AND sru.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND srcru.id_session = '".intval($id_session)."'";
$rs = Database::query($sql);
$course['nbr_users'] = Database::result($rs,0,0);
// Get coachs of the courses in session
$sql = "SELECT user.lastname,user.firstname,user.username FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user
WHERE session_rcru.id_user = user.user_id AND session_rcru.id_session = '".intval($id_session)."' AND session_rcru.course_code ='".Database::escape_string($course['code'])."' AND session_rcru.status=2";
$rs = Database::query($sql);
$coachs = array();
if (Database::num_rows($rs) > 0) {
while($info_coach = Database::fetch_array($rs)) {
$coachs[] = api_get_person_name($info_coach['firstname'], $info_coach['lastname']).' ('.$info_coach['username'].')';
}
} else {
$coach = get_lang('None');
}
if (count($coachs) > 0) {
$coach = implode('<br />',$coachs);
} else {
$coach = get_lang('None');
}
$orig_param = '&origin=resume_session';
//hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
echo '
<tr>
<td>'.Display::url($course['title'].' ('.$course['visual_code'].')', api_get_path(WEB_COURSE_PATH).$course['code'].'/?id_session='.$id_session),'</td>
<td>'.$coach.'</td>
<td>'.$course['nbr_users'].'</td>
</tr>';
}
}
?>
</table>
<br />
<?php
echo Display::page_subheader(get_lang('UserList').$url);
?>
<!--List of users -->
<table class="data_table">
<tr>
<th>
<?php echo get_lang('User'); ?>
</th>
<th>
<?php echo get_lang('Actions'); ?>
</th>
</tr>
<?php
if ($session['nbr_users']==0) {
echo '<tr>
<td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
</tr>';
} else {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
if ($multiple_url_is_on) {
$sql = "SELECT u.user_id, lastname, firstname, username, access_url_id
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON u.user_id = su.id_user AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH."
LEFT OUTER JOIN $table_access_url_user uu ON (uu.user_id = u.user_id)
WHERE su.id_session = $id_session AND (access_url_id = $url_id OR access_url_id is null )
$order_clause";
} else {
$sql = "SELECT u.user_id, lastname, firstname, username
FROM $tbl_user u
INNER JOIN $tbl_session_rel_user su
ON u.user_id = su.id_user AND su.relation_type<>".SESSION_RELATION_TYPE_RRHH."
AND su.id_session = ".$id_session.$order_clause;
}
$result = Database::query($sql);
$users = Database::store_result($result);
$orig_param = '&origin=resume_session&id_session='.$id_session; // change breadcrumb in destination page
foreach ($users as $user){
$user_link = '';
if (!empty($user['user_id'])) {
$user_link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.intval($user['user_id']).'">'.api_htmlentities(api_get_person_name($user['firstname'], $user['lastname']),ENT_QUOTES,$charset).' ('.$user['username'].')</a>';
}
$link_to_add_user_in_url = '';
if ($multiple_url_is_on) {
if ($user['access_url_id'] != $url_id) {
$user_link .= ' '.Display::return_icon('warning.png', get_lang('UserNotAddedInURL'), array(), ICON_SIZE_SMALL);
$add = Display::return_icon('add.png', get_lang('AddUsersToURL'), array(), ICON_SIZE_SMALL);
$link_to_add_user_in_url = '<a href="resume_session.php?action=add_user_to_url&id_session='.$id_session.'&user_id='.$user['user_id'].'">'.$add.'</a>';
}
}
echo '<tr>
<td width="90%">
'.$user_link.'
</td>
<td>
<a href="../mySpace/myStudents.php?student='.$user['user_id'].''.$orig_param.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>&nbsp;
<a href="session_course_user.php?id_user='.$user['user_id'].'&id_session='.$id_session.'">'.Display::return_icon('course.gif', get_lang('BlockCoursesForThisUser')).'</a>&nbsp;
<a href="'.api_get_self().'?id_session='.$id_session.'&action=delete&user='.$user['user_id'].'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>
'.$link_to_add_user_in_url.'
</td>
</tr>';
}
}
?>
</table>
<?php
} else {
api_not_allowed();
}
// footer
Display :: display_footer();

@ -0,0 +1,158 @@
<?php
/* For licensing terms, see /license.txt */
/**
* List sessions in an efficient and usable way
* @package chamilo.admin
*/
/**
* Code
*/
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_teacher_script(true);
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$action = $_REQUEST['action'];
$idChecked = $_REQUEST['idChecked'];
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
if($_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$error_message = ''; // Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
$error_message = Security::remove_XSS($_GET['message']);
}
if (!empty($error_message)) {
Display::display_normal_message($error_message, false);
}
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1';
if (isset($_REQUEST['keyword'])) {
//Begin with see the searchOper param
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&from_course_session=1&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw';
}
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('NumberOfUsers'), get_lang('SessionCategoryName'),
get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions'));
//$activeurl = '?sidx=session_active';
//Column config
$column_model = array(
array('name'=>'name', 'index'=>'name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'category_name', 'index'=>'category_name', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
array('name'=>'date_start', 'index'=>'date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
array('name'=>'date_end', 'index'=>'date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'),
array('name'=>'status', 'index'=>'session_active','width'=>'40', 'align'=>'left', 'search' => 'true', 'stype'=>'select',
//for the bottom bar
'searchoptions' => array(
'defaultValue' => '1',
'value' => '1:'.get_lang('Active').';0:'.get_lang('Inactive')),
//for the top bar
'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))),
array('name'=>'visibility', 'index'=>'visibility', 'width'=>'40', 'align'=>'left', 'search' => 'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false')
);
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//$extra_params['excel'] = 'excel';
//$extra_params['rowList'] = array(10, 20 ,30);
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'&nbsp;<a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',ICON_SIZE_SMALL).'</a>'.
'\';
}';
?>
<script>
function setSearchSelect(columnName) {
$("#sessions").jqGrid('setColProp', columnName,
{
searchoptions:{
dataInit:function(el){
$("option[value='2']",el).attr("selected", "selected");
setTimeout(function(){
$(el).trigger('change');
},1000);
}
}
});
}
$(function() {
<?php
echo Display::grid_js('sessions', $url,$columns,$column_model,$extra_params, array(), $action_links,true);
?>
setSearchSelect("status");
$("#sessions").jqGrid('navGrid','#sessions_pager', {edit:false,add:false,del:false},
{height:280,reloadAfterSubmit:false}, // edit options
{height:280,reloadAfterSubmit:false}, // add options
{reloadAfterSubmit:false}, // del options
{width:500} // search options
);
/*
// add custom button to export the data to excel
jQuery("#sessions").jqGrid('navButtonAdd','#sessions_pager',{
caption:"",
onClickButton : function () {
jQuery("#sessions").excelExport();
}
});
jQuery('#sessions').jqGrid('navButtonAdd','#sessions_pager',{id:'pager_csv',caption:'',title:'Export To CSV',onClickButton : function(e)
{
try {
jQuery("#sessions").jqGrid('excelExport',{tag:'csv', url:'grid.php'});
} catch (e) {
window.location= 'grid.php?oper=csv';
}
},buttonicon:'ui-icon-document'})
*/
//Adding search options
var options = {
'stringResult': true,
'autosearch' : true,
'searchOnEnter':false
}
jQuery("#sessions").jqGrid('filterToolbar',options);
var sgrid = $("#sessions")[0];
sgrid.triggerToolbar();
});
</script>
<?php if (api_is_platform_admin()) {?>
<div class="actions">
<?php
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('new_session.png',get_lang('AddSession'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_list.php">'.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
}
} else {
api_not_allowed();
}
echo Display::grid_html('sessions');
Display::display_footer();

@ -383,7 +383,12 @@ if ( api_is_allowed_to_edit(null, true)) {
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
$actions .= ' <a class="btn" href="class.php?'.api_get_cidreq().'">'.get_lang('Classes').'</a>';
}
if (api_is_allowed_to_edit() && $_configuration['allow_tutors_to_assign_students_to_session'] == 'true') {
$actions .= ' <a class="btn" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
}
//$actions .= ' <a class="btn" href="social_groups.php?'.api_get_cidreq().'">'.get_lang('SocialGroups').'</a>';
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, false);
$renderer = $form->defaultRenderer();

@ -4151,12 +4151,7 @@ function getFile($id, $course_info, $download = true)
{
$file = getFileContents($id, $course_info);
if (!empty($file) && is_array($file)) {
DocumentManager::file_send_for_download(
$file['path'],
$download,
$file['title']
);
return true;
return DocumentManager::file_send_for_download($file['path'], $download, $file['title']);
}
return false;
}

@ -8,19 +8,19 @@ $objPlugin = new TicketPlugin();
$table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
ticket_id int UNSIGNED DEFAULT NULL,
user_id int UNSIGNED DEFAULT NULL,
assigned_date datetime DEFAULT NULL,
sys_insert_user_id int UNSIGNED DEFAULT NULL,
PRIMARY KEY PK_ticket_assigned_log (iid),
PRIMARY KEY PK_ticket_assigned_log (id),
KEY FK_ticket_assigned_log (ticket_id))";
Database::query($sql);
//Category
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
category_id char(3) NOT NULL,
project_id char(3) NOT NULL,
name varchar(100) NOT NULL,
@ -31,14 +31,14 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
sys_insert_datetime datetime DEFAULT NULL,
sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
sys_lastedit_datetime datetime DEFAULT NULL,
PRIMARY KEY (iid))";
PRIMARY KEY (id))";
Database::query($sql);
//Default Categories
$categoRow = array(
$objPlugin->get_lang('Enrollment') => $objPlugin->get_lang('TicketsAboutEnrollment'),
$objPlugin->get_lang('GeneralInformation') => $objPlugin->get_lang('TicketsAboutGeneralInformation'),
$objPlugin->get_lang('RequestAndTramits') => $objPlugin->get_lang('TicketsAboutRequestAndTramits'),
$objPlugin->get_lang('RequestAndPapework') => $objPlugin->get_lang('TicketsAboutRequestAndPapework'),
$objPlugin->get_lang('AcademicIncidence') => $objPlugin->get_lang('TicketsAboutAcademicIncidence'),
$objPlugin->get_lang('VirtualCampus') => $objPlugin->get_lang('TicketsAboutVirtualCampus'),
$objPlugin->get_lang('OnlineEvaluation') => $objPlugin->get_lang('TicketsAboutOnlineEvaluation')
@ -48,7 +48,7 @@ foreach ($categoRow as $category => $description) {
//Online evaluation requires a course
if ($i == 6) {
$attributes = array(
'iid' => $i,
'id' => $i,
'category_id' => $i,
'name' => $category,
'description' => $description,
@ -57,7 +57,7 @@ foreach ($categoRow as $category => $description) {
);
} else {
$attributes = array(
'iid' => $i,
'id' => $i,
'category_id' => $i,
'project_id' => 1,
'description' => $description,
@ -71,7 +71,7 @@ foreach ($categoRow as $category => $description) {
//END default categories
$table = Database::get_main_table(TABLE_TICKET_MESSAGE);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int UNSIGNED NOT NULL AUTO_INCREMENT,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
message_id int UNSIGNED NOT NULL,
ticket_id int UNSIGNED NOT NULL,
subject varchar(150) DEFAULT NULL,
@ -82,13 +82,13 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
sys_insert_datetime datetime DEFAULT NULL,
sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
sys_lastedit_datetime datetime DEFAULT NULL,
PRIMARY KEY (iid),
PRIMARY KEY (id),
KEY FK_tick_message (ticket_id) )";
Database::query($sql);
$table = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int UNSIGNED NOT NULL AUTO_INCREMENT,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
message_attch_id char(2) NOT NULL,
message_id char(2) NOT NULL,
ticket_id int UNSIGNED NOT NULL,
@ -99,14 +99,14 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
sys_insert_datetime datetime DEFAULT NULL,
sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
sys_lastedit_datetime datetime DEFAULT NULL,
PRIMARY KEY (iid),
PRIMARY KEY (id),
KEY ticket_message_id_fk (message_id))";
Database::query($sql);
//Priority
$table = Database::get_main_table(TABLE_TICKET_PRIORITY);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int UNSIGNED NOT NULL AUTO_INCREMENT,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
priority_id char(3) NOT NULL,
priority varchar(20) DEFAULT NULL,
priority_desc varchar(250) DEFAULT NULL,
@ -116,18 +116,18 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
sys_insert_datetime datetime DEFAULT NULL,
sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
sys_lastedit_datetime datetime DEFAULT NULL,
PRIMARY KEY (iid))";
PRIMARY KEY (id))";
Database::query($sql);
//Default Priorities
$defaultPriorities = array(
'NRM' => get_lang('Normal'),
'HGH' => get_lang('High'),
'LOW' => get_lang('Low')
'NRM' => $objPlugin->get_lang('PriorityNormal'),
'HGH' => $objPlugin->get_lang('PriorityHigh'),
'LOW' => $objPlugin->get_lang('PriorityLow')
);
$i = 1;
foreach ($defaultPriorities as $pId => $priority) {
$attributes = array(
'iid' => $i,
'id' => $i,
'priority_id' => $pId,
'priority' => $priority,
'priority_desc' => $priority
@ -139,7 +139,7 @@ foreach ($defaultPriorities as $pId => $priority) {
$table = Database::get_main_table(TABLE_TICKET_PROJECT);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int UNSIGNED NOT NULL AUTO_INCREMENT,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
project_id char(3) NOT NULL,
name varchar(50) DEFAULT NULL,
description varchar(250) DEFAULT NULL,
@ -149,11 +149,11 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
sys_insert_datetime datetime DEFAULT NULL,
sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
sys_lastedit_datetime datetime DEFAULT NULL,
PRIMARY KEY (iid))";
PRIMARY KEY (id))";
Database::query($sql);
//Default Project Table Ticket
$attributes = array(
'iid' => 1,
'id' => 1,
'project_id' => 1,
'name' => 'Ticket System'
);
@ -163,25 +163,25 @@ Database::insert($table, $attributes);
//STATUS
$table = Database::get_main_table(TABLE_TICKET_STATUS);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int UNSIGNED NOT NULL AUTO_INCREMENT,
id int UNSIGNED NOT NULL AUTO_INCREMENT,
status_id char(3) NOT NULL,
name varchar(100) NOT NULL,
description varchar(255) DEFAULT NULL,
PRIMARY KEY (iid))";
PRIMARY KEY (id))";
Database::query($sql);
//Default status
$defaultStatus = array(
'NAT' => get_lang('New'),
'PND' => $objPlugin->get_lang('Pending'),
'XCF' => $objPlugin->get_lang('Unconfirmed'),
'CLS' => get_lang('Close'),
'REE' => get_lang('Forwarded')
'NAT' => $objPlugin->get_lang('StsNew'),
'PND' => $objPlugin->get_lang('StsPending'),
'XCF' => $objPlugin->get_lang('StsUnconfirmed'),
'CLS' => $objPlugin->get_lang('StsClose'),
'REE' => $objPlugin->get_lang('StsForwarded')
);
$i = 1;
foreach ($defaultStatus as $abr => $status) {
$attributes = array(
'iid' => $i,
'id' => $i,
'status_id' => $abr,
'name' => $status
);
@ -219,9 +219,8 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
Database::query($sql);
//Menu main tabs
$objPlugin->addTab('Ticket', '/plugin/ticket/src/myticket.php');
//Extra Settings
$extraSettings = array(
'allow_add' => 'true'
);
$objPlugin->addExtraSettings($extraSettings);
$rsTab = $objPlugin->addTab('Ticket', '/plugin/ticket/src/myticket.php');
if ($rsTab) {
echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>";
}

@ -1,76 +1,88 @@
<?php /* License: see /license.txt */
//Needed in order to show the plugin title
$strings['plugin_title'] = "Tickets de soporte";
$strings['plugin_comment'] = "Plugin para el soporte de tickets de atención dentro de Chamilo.";
$strings['tool_enable'] = "Activar plugin de tickets";
$strings['tool_enable_help'] = "Activar la herramienta de tickets hará disponible una nueva pestaña en la barra principal horizontal. Esta pestaña aparecerá para todos los usuarios y los guiará al sistema de gestión de tickets donde podrán verificar el estado de sus tickets.";
$strings['TabsTickets'] = "Pestaña de tickets";
$strings['TicketNum'] = "Ticket #";
$strings['Date'] = "Fecha";
$strings['Category'] = "Categoria";
$strings['User'] = "Usuario";
$strings['Program'] = "Programa";
$strings['Responsible'] = "Responsable";
$strings['Status'] = "Estado";
$strings['Message'] = "Mensajes";
$strings['Description'] = "Descripcion";
$strings['Tickets'] = "Tickets";
$strings['MyTickets'] = "Mis Tickets";
$strings['MsgWelcome'] = "Bienvenido a su secci&oacute;n MIS TICKETS. Esta secci&oacute;n le permite revisar sus Tickets de Soporte generados en SOPORTE TECNICO";
$strings['TckSuccessSave'] = "Se registró con exito su ticket";
$strings['TckClose'] = "Cerrar Tickets";
$strings['TckNew'] = "Nuevo Ticket";
$strings['TcksNew'] = "Tickets Nuevos";
$strings['Unassigned'] = "No asignados";
$strings['Unassign'] = "Desasignado";
$strings['Read'] = "Leidos";
$strings['Unread'] = "No Leidos";
$strings['RegisterDate'] = "Fecha de Registro";
$strings['Priority'] = "Prioridad";
$strings['AssignedTo'] = "Asignado a";
$strings['ValidUser'] = "Debe seleccionar a un usuario";
$strings['ValidType'] = "Debe seleccionar un tipo";
$strings['ValidSubject'] = "Debe escribir un asunto";
$strings['ValidCourse'] = "Debe elegir un curso";
$strings['ValidEmail'] = "Debe digitar un email valido";
$strings['ValidMessage'] = "Debe escribir un mensaje";
$strings['PersonalEmail'] = "Email Personal";
$strings['Optional'] = "Opcional";
$strings['plugin_title'] = "Tickets de soporte";
$strings['plugin_comment'] = "Plugin para el soporte de tickets de atención dentro de Chamilo.";
$strings['tool_enable'] = "Activar plugin de tickets";
$strings['tool_enable_help'] = "Activar la herramienta de tickets hará disponible una nueva pestaña en la barra principal horizontal. Esta pestaña aparecerá para todos los usuarios y los guiará al sistema de gestión de tickets donde podrán verificar el estado de sus tickets.";
$strings['TabsTickets'] = "Pestaña de tickets";
$strings['TicketNum'] = "Ticket #";
$strings['Date'] = "Fecha";
$strings['Category'] = "Categoría";
$strings['User'] = "Usuario";
$strings['Program'] = "Programa";
$strings['Responsible'] = "Responsable";
$strings['Status'] = "Estado";
$strings['Message'] = "Mensajes";
$strings['Description'] = "Descripcion";
$strings['Tickets'] = "Tickets";
$strings['MyTickets'] = "Mis Tickets";
$strings['MsgWelcome'] = "Bienvenido a su sección MIS TICKETS. Esta sección le permite revisar sus Tickets de Soporte generados en SOPORTE TECNICO";
$strings['TckSuccessSave'] = "Se registró con exito su ticket";
$strings['TckClose'] = "Cerrar Tickets";
$strings['TckNew'] = "Nuevo Ticket";
$strings['TcksNew'] = "Tickets Nuevos";
$strings['Unassigned'] = "No asignados";
$strings['Unassign'] = "Desasignado";
$strings['Read'] = "Leídos";
$strings['Unread'] = "No Leídos";
$strings['RegisterDate'] = "Fecha de Registro";
$strings['AssignedTo'] = "Asignado a";
$strings['ValidUser'] = "Debe seleccionar a un usuario";
$strings['ValidType'] = "Debe seleccionar un tipo";
$strings['ValidSubject'] = "Debe escribir un asunto";
$strings['ValidCourse'] = "Debe elegir un curso";
$strings['ValidEmail'] = "Debe digitar un email valido";
$strings['ValidMessage'] = "Debe escribir un mensaje";
$strings['PersonalEmail'] = "Email Personal";
$strings['Optional'] = "Opcional";
$strings['ErrorRegisterMessage'] = "No se pudo registrar su ticket";
$strings['Source'] = "Fuente";
$strings['DeniedAccess'] = "Acceso denegado.";
$strings['Source'] = "Fuente";
$strings['DeniedAccess'] = "Acceso denegado.";
// Status Tickets
$strings['StsNew'] = "Nuevo";
$strings['StsPending'] = "Pendiente";
$strings['StsNew'] = "Nuevo";
$strings['StsPending'] = "Pendiente";
$strings['StsUnconfirmed'] = "Por Confirmar";
$strings['StsClose'] = "Cerrado";
$strings['StsReenviado'] = "Reenviado";
$strings['StsClose'] = "Cerrado";
$strings['StsForwarded'] = "Reenviado";
// Priority
$strings['Priority'] = "Prioridad";
$strings['PriorityHigh'] = "Alta";
$strings['PriorityNormal'] = "Normal";
$strings['PriorityLow'] = "Baja";
$strings['Priority'] = "Prioridad";
$strings['PriorityHigh'] = "Alta";
$strings['PriorityNormal'] = "Normal";
$strings['PriorityLow'] = "Baja";
// Source
$strings['SrcEmail'] = "Email";
$strings['SrcPhone'] = "Telefono";
$strings['SrcPresential'] = "Presencial";
//
$strings['SrcEmail'] = "Email";
$strings['SrcPhone'] = "Teléfono";
$strings['SrcPresential'] = "Presencial";
$strings['TicketAssignedMsg'] = "<p>Estimado(a) %s </p><p>Se le ha sido asignado el <a href=\"%s\">ticket %s</a></p><p>Mensaje enviado desde el sistema de ticket.</p>";
$strings['TicketAssignX'] = "[TICKETS] Asignacion de Ticket #%s ";
$strings['AreYouSureYouWantToCloseTheTicket'] = "¿Esta seguro que quiere cerrar el ticket?";
$strings['AreYouSureYouWantToUnassignTheTicket'] = "¿Esta seguro que quiere desasignarse el ticket?";
$strings['TicketAssignX'] = "[TICKETS] Asignación de Ticket #%s ";
$strings['AreYouSureYouWantToCloseTheTicket'] = "¿Está seguro que quiere cerrar el ticket?";
$strings['AreYouSureYouWantToUnassignTheTicket'] = "¿Está seguro que quiere desasignarse el ticket?";
$strings['YouMustWriteAMessage'] = "Debe escribir un mensaje";
$strings['LastResponse'] = "Ultima Respuesta";
$strings['LastResponse'] = "Última Respuesta";
$strings['AssignTicket'] = "Asignar Ticket";
$strings['AttendedBy'] = "Atendido por";
$strings['AttendedBy'] = "Atendido por";
$strings['IfYouAreSureTheTicketWillBeClosed'] = "Si está seguro el Ticket será cerrado";
$strings['YourQuestionWasSentToTheResponableAreaX'] = "<p>Su consulta fue reenviada al área responsable: <a href='mailto: %s'>%s</a></p>";
$strings['YourAnswerToTheQuestionWillBeSentToX'] = "<p>La respuesta a su consulta será enviada al correo:<a href='#'>%s</a></p>";
$strings['VirtualSupport'] = "Soporte Virtual";
$strings['IncidentResentToVirtualSupport'] = "El incidente ha sido reenviado al Soporte Virtual";
$strings['DateLastEdition'] = "Fecha Última Edición";
$strings['GeneralInformation'] = "Información General";
$strings['TicketsAboutGeneralInformation'] = "Tickets acerca de Infomación General.";
$strings['Enrollment'] = "Matrícula";
$strings['TicketsAboutEnrollment'] = "Tickets relacionados con la Matrícula.";
$strings['RequestAndPapework'] = "Consultas y Trámites";
$strings['TicketsAboutRequestAndPapework'] = "Tickets relacionados a consultas anteriores y trámites.";
$strings['AcademicIncidence'] = "Incidencias Académicas";
$strings['TicketsAboutAcademicIncidence'] = "Tickets relacionados a incidencias académicas como examenes, prácticas, tareas, etc.";
$strings['VirtualCampus'] = "Campus Virtual";
$strings['TicketsAboutVirtualCampus'] = "Tickets relacionados al Campus Virtual";
$strings['OnlineEvaluation'] = "Evaluación en línea";
$strings['TicketsAboutOnlineEvaluation'] = "Tickets relacionados a las evaluaciones en línea";
$strings['ToBeAssigned'] = "Por Asignar";
$strings['Untill'] = "Hasta";
$strings['TicketWasThisAnswerSatisfying'] = "¿Fué la respuesta al Ticket satisfactoria?";
$strings['TicketDetail'] = "Detalle del Ticket";
$strings['AreYouSure'] = "¿Está seguro?";
$strings['allow_student_add'] = "Permitir al studiante generar Tickets";

@ -74,8 +74,15 @@ function display_advanced_search_form () {
margin-left: 20px;
float: left;
text-align: left;
margin-top: 5px;
width: 50px;
margin-top: 10px;
width: 95px;
}
.label4 {
float: left;
text-align: left;
margin-top: 10px;
width: 75px;
}
.formw2 {
@ -98,6 +105,26 @@ function display_advanced_search_form () {
.blackboard_hide {
display: none;
}
.advanced-parameters {
margin-top: 5px;
}
.remove-margin-top {
margin-top: 0px;
}
.select-margin-top {
margin-top: -5px;
}
.input-width {
width: 170px;
}
.fleft {
float: left;
}
</style>';
$this_section = 'tickets';
@ -207,16 +234,16 @@ if ($isAdmin) {
//select priority
$select_priority .= '<select name = "keyword_priority" id="keyword_priority" >';
$select_priority .= '<option value="">' . get_lang('All') . '</option>';
$select_priority .= '<option value="NRM">' . get_lang('PriorityNormal') . '</option>';
$select_priority .= '<option value="HGH">' . get_lang('PriorityHigh') . '</option>';
$select_priority .= '<option value="LOW">' . get_lang('PriorityLow') . '</option>';
$select_priority .= '<option value="NRM">' . $plugin->get_lang('PriorityNormal') . '</option>';
$select_priority .= '<option value="HGH">' . $plugin->get_lang('PriorityHigh') . '</option>';
$select_priority .= '<option value="LOW">' . $plugin->get_lang('PriorityLow') . '</option>';
$select_priority .= "</select>";
//select unread
$select_unread = '<select name = "keyword_unread" id="keyword_unread" >';
$select_unread .= '<option value="">' . get_lang('All') . '</option>';
$select_unread .= '<option value="yes">' . get_lang('Unread') . '</option>';
$select_unread .= '<option value="no">' . get_lang('Read') . '</option>';
$select_unread .= '<option value="yes">' . $plugin->get_lang('Unread') . '</option>';
$select_unread .= '<option value="no">' . $plugin->get_lang('Read') . '</option>';
$select_unread .= "</select>";
// Create a search-box
$form = new FormValidator('search_simple', 'get', '', '', null, false);
@ -225,24 +252,19 @@ if ($isAdmin) {
$form->addElement('text', 'keyword', get_lang('keyword'), 'size="25"');
$form->addElement('style_submit_button', 'submit_simple', get_lang('Search'), 'class="search"');
$form->addElement('static', 'search_advanced_link', null,
'<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();">'
'<a href="javascript://" class = "advanced-parameters" onclick="display_advanced_search_form();">'
. '<span id="img_plus_and_minus">&nbsp;'
. Display::return_icon('div_show.gif', get_lang('Show'),
array('style' => 'vertical-align:middle')) . ' '
. Display::return_icon('div_show.gif', get_lang('Show')) . ' '
. get_lang('AdvancedSearch') . '</span></a>');
echo '<div class="actions" >';
if (api_is_platform_admin()) {
echo '<span style="float:right;">' .
'<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' .
Display::return_icon('import_excel.png', get_lang('Export'), '', '32') . '</a>' .
'</span>';
echo '<span style="float:right;">' .
'<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . '</a>' .
'</span>';
echo '<span style="float:right;">' .
'</span>';
echo '<span class="fleft">' .
'<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>';
}
$form->display();
echo '</div>';
@ -263,19 +285,19 @@ if ($isAdmin) {
<td>
<div>
<div class="label3">' . get_lang('User') . ': </div>
<div class="formw2"><input id="keyword_request_user" name="keyword_request_user" type="text"></div>
<div class="formw2"><input class="input-width" id="keyword_request_user" name="keyword_request_user" type="text"></div>
</div>
</td>
<td>
<div>
<div class="label3">' . $plugin->get_lang('RegisterDate') . ': </div>
<div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
<div class="formw2"><input class="input-width" id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
</div>
</td>
<td>
<div>
<div class="label3"><input type="checkbox" name="keyword_dates" value="1">' . get_lang('Untill') . ':</div>
<div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
<div class="label3"><input type="checkbox" name="keyword_dates" value="1">' . $plugin->get_lang('Untill') . '</div>
<div class="formw2"><input class="input-width" id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
</div>
</td>
</tr>
@ -283,13 +305,13 @@ if ($isAdmin) {
<td>
<div>
<div class="label2">' . $plugin->get_lang('AssignedTo') . ': </div>
<div class="formw2" style="margin-top: -5px;">' . $select_admins . '</div>
<div class="formw2 select-margin-top">' . $select_admins . '</div>
</div>
</td>
<td>
<div>
<div class="label3">' . get_lang('Status') . ':</div>
<div class="formw2" style="margin-top: -5px;">' . $select_status . '</div>
<div class="label3 remove-margin-top">' . get_lang('Status') . ':</div>
<div class="formw2 select-margin-top">' . $select_status . '</div>
</div>
</td>
<td>
@ -302,7 +324,7 @@ if ($isAdmin) {
<td>
<div>
<div>
<div class="label3">' . $plugin->get_lang('MessageStatus') . ': </div>
<div class="label3">' . get_lang('Status') . ': </div>
<div class="formw2">' . $select_unread . '</div>
</div>
</td>
@ -310,7 +332,7 @@ if ($isAdmin) {
<tr>
<td>
<div >
<div class="label2">' . get_lang('Course') . ': </div>
<div class="label4">' . get_lang('Course') . ': </div>
<div class="formw2">
<input id="keyword_course" style="width: 170px;" name="keyword_course" type="text"></div>
</div>
@ -328,7 +350,7 @@ if ($isAdmin) {
<div class="clear">&nbsp;</div>
</form>';
} else {
if ($plugin->getExtraSettingValue('allow_add') == 'true') {
if ($plugin->get('allow_student_add') == 'true') {
echo '<div class="actions" >';
echo '<span style="float:right;">' .
'<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .

@ -12,7 +12,7 @@ $cidReset = true;
require_once '../config.php';
$plugin = TicketPlugin::create();
if (!api_is_platform_admin() && $plugin->getExtraSettingValue('allow_add') != 'true') {
if (!api_is_platform_admin() && $plugin->get('allow_student_add') != 'true') {
header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php');
exit;
}
@ -208,7 +208,7 @@ function show_form_send_ticket()
$status[PENDING] = $plugin->get_lang('StsPending');
$status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed');
$status[CLOSE] = $plugin->get_lang('StsClose');
$status[REENVIADO] = $plugin->get_lang('StsReenviado');
$status[REENVIADO] = $plugin->get_lang('StsForwarded');
}
$select_status = '
<div class="row" ' . $showStatus . ' >
@ -270,7 +270,7 @@ function show_form_send_ticket()
// Message
echo '<div class="row">
<div class="label2">' . get_lang('Message') . '</div>
<div class="label2">' . get_lang('Message') . ':</div>
<div class="formw2">
<input type="hidden" id="content" name="content" value="" style="display:none">
<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [ [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [ ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
@ -286,7 +286,7 @@ function show_form_send_ticket()
// Priority
$select_priority = '<div class="row" >
<div class="label2" >' . $plugin->get_lang('Priority') . ': </div>
<div class="label2" >' . $plugin->get_lang('Priority') . ':</div>
<div class="formw2">';
$priority = array();
@ -308,7 +308,7 @@ function show_form_send_ticket()
// Input file attach
echo '<div class="row">
<div class="label2">' . get_lang('FilesAttachment') . '</div>
<div class="label2">' . get_lang('FilesAttachment') . ':</div>
<div class="formw2">
<span id="filepaths">
<div id="filepath_1">

@ -228,18 +228,20 @@ function get_user_data($from, $number_of_items, $column, $direction)
$res = Database::query($sql);
$users = array();
$webPath = api_get_path(WEB_PATH);
$selfPath = api_get_self();
while ($user = Database::fetch_row($res)) {
$image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
$user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
if (!api_is_anonymous()) {
$photo = '<center><a href="' . api_get_path(WEB_PATH) . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
$photo = '<center><a href="' . $webPath . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
} else {
$photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
}
$user_id = $user[0];
$button = '<a href="' . api_get_self() . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
$button = '<a href="' . $selfPath . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
$button = '<a href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')">
<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" src="../../../main/img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')" src="' . $webPath . 'img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
</a>&nbsp;&nbsp;';
$users[] = array($photo, $user[1], $user[2], $user[3], $user[4], $user[5], $button);
}

@ -87,6 +87,7 @@ class TicketManager
$request_user = '', $assigned_user = 0
)
{
global $plugin;
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
@ -188,12 +189,12 @@ class TicketManager
</tr>
</table>';
api_mail_html(
'Soporte virtual', $email, "[SOPORTE] Incidente Reenviado de Soporte Virtual",
$plugin->get_lang('VirtualSupport'), $email, $plugin->get_lang('IncidentResentToVirtualSupport'),
$helpDeskMessage, $user['firstname'] . ' ' . $user['lastname'], $personalEmail,
array(), $data_files
);
$studentMessage = '<p>Su consulta fue reenviada al area responsable : <a href="mailto:' . $email . '">' . $email . '</a></p>';
$studentMessage .= '<p>La respuesta a su consulta ser&aacute; enviada al correo : <a href="#">' . $personalEmail . '</a></p>';
$studentMessage = sprintf($plugin->get_lang('YourQuestionWasSentToTheResponableAreaX'), $email, $email);
$studentMessage .= sprintf($plugin->get_lang('YourAnswerToTheQuestionWillBeSentToX'), $personalEmail);
self::insert_message(
$ticket_id, get_lang('MessageResent'), $studentMessage, null, 1
);
@ -211,6 +212,7 @@ class TicketManager
}
/**
* Assign ticket to admin
* @param $ticket_id
* @param $user_id
*/
@ -258,6 +260,7 @@ class TicketManager
}
/**
* Insert message between Users and Admins
* @param $ticket_id
* @param $subject
* @param $content
@ -272,7 +275,7 @@ class TicketManager
$user_id, $status = 'NOL', $sendConfirmation = false
)
{
global $data_files;
global $data_files, $plugin;
$ticket_id = intval($ticket_id);
$subject = Database::escape_string($subject);
$content = Database::escape_string($content);
@ -284,9 +287,9 @@ class TicketManager
$table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
if ($sendConfirmation) {
$form = '<form action="ticket_details.php?ticket_id=' . $ticket_id . '" id="confirmticket" method="POST" >
<p>' . get_lang('TicketWasThisAnswerSatisfying') . '</p>
<input id="responseyes" type="submit" value="' . get_lang('Yes') . '" name="response" />
<input id="responseno" type="submit" value="' . get_lang('No') . '" name="response" />
<p>' . $plugin->get_lang('TicketWasThisAnswerSatisfying') . '</p>
<button name="response" id="responseyes" value="1">' . get_lang('Yes') . '</button>
<button name="response" id="responseno" value="0">' . get_lang('No') . '</button>
</form>';
$content .= $form;
Database::query(
@ -361,6 +364,7 @@ class TicketManager
}
/**
* Attachment files when a message is sent
* @param $file_attach
* @param $ticket_id
* @param $message_id
@ -432,6 +436,7 @@ class TicketManager
}
/**
* Get tickets by userId
* @param $from
* @param $number_of_items
* @param $column
@ -443,6 +448,7 @@ class TicketManager
$from, $number_of_items, $column, $direction, $user_id = null
)
{
global $plugin;
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
);
@ -650,7 +656,7 @@ class TicketManager
$row['responsible'] = "<a href='$hrefResp'> {$row['responsible']['username']} </a>";
} else {
if ($row['status_id'] != 'REE') {
$row['responsible'] = '<span style="color:#ff0000;">' . get_lang('ToBeAssigned') . '</span>';
$row['responsible'] = '<span style="color:#ff0000;">' . $plugin->get_lang('ToBeAssigned') . '</span>';
} else {
$row['responsible'] = '<span style="color:#00ff00;">' . get_lang('MessageResent') . '</span>';
}
@ -1004,7 +1010,7 @@ class TicketManager
AND ticket_id= '$ticket_id' ";
$result_attach = Database::query($sql_atachment);
while ($row2 = Database::fetch_assoc($result_attach)) {
$archiveURL = $archiveURL = $webPath . PLUGIN_NAME . '/src/download.php?ticket_id=' . $ticket_id . '&file=';
$archiveURL = $archiveURL = $webPath . "plugin/" . PLUGIN_NAME . '/src/download.php?ticket_id=' . $ticket_id . '&file=';
$row2['attachment_link'] = $attach_icon . '&nbsp;<a href="' . $archiveURL . $row2['path'] . '&title=' . $row2['filename'] . '">' . $row2['filename'] . '</a>&nbsp;(' . $row2['size'] . ')';
$message['atachments'][] = $row2;
}

@ -14,10 +14,19 @@ require_once '../config.php';
$plugin = TicketPlugin::create();
api_block_anonymous_users();
$user_id = api_get_user_id();
$isAdmin = api_is_platform_admin();
$interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang('MyTickets'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('TicketDetail'));
$interbreadcrumb[] = array('url' => '#', 'name' => $plugin->get_lang('TicketDetail'));
$disableReponseButtons = "";
if ($isAdmin) {
$disableReponseButtons = "$('#responseyes').attr('disabled', 'disabled');
$('#responseno').attr('disabled', 'disabled');";
}
$htmlHeadXtra[] = '
<script src="/pie/PIE_IE678.js"></script>
<script language="javascript">
$(document).ready(function(){
$( "#dialog-form" ).dialog({
@ -40,12 +49,12 @@ $(document).ready(function(){
});
$("input#responseyes").click(function () {
if(!confirm("' . get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. Si est\u00e1 seguro el ticket ser\u00e1 cerrado")){
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. ' . $plugin->get_lang('IfYouAreSureTheTicketWillBeClosed') . '")){
return false;
}
});
$("input#responseno").click(function () {
if(!confirm("' . get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('No')) . '")){
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('No')) . '")){
return false;
}
});
@ -53,12 +62,15 @@ $(document).ready(function(){
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToUnassignTheTicket') . '")) {
return false
}
});
$("#close").click(function () {
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToCloseTheTicket') . '")) {
});
$("#close").click(function () {
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToCloseTheTicket') . '")) {
return false
}
});
' . $disableReponseButtons . '
});
function validate() {
fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML();
@ -140,8 +152,6 @@ div.row div.formw2 {
</style>';
$user_id = api_get_user_id();
$isAdmin = api_is_platform_admin();
$ticket_id = $_GET['ticket_id'];
$ticket = TicketManager::get_ticket_detail_by_id($ticket_id, $user_id);
if (!isset($ticket['ticket'])) {
@ -152,7 +162,7 @@ if (!isset($_GET['ticket_id'])) {
}
if (isset($_POST['response'])) {
if ($user_id == $ticket['ticket']['request_user']) {
$response = ($_POST['response'] == get_lang('Yes')) ? true : ($_POST['response'] == get_lang('No') ? false : null);
$response = ($_POST['response'] == "1") ? true : ($_POST['response'] == "0" ? false : null);
if ($response && $ticket['ticket']['status_id'] == 'XCF') {
TicketManager::close_ticket($_GET['ticket_id'], $user_id);
$ticket['ticket']['status_id'] = 'CLS';
@ -160,7 +170,7 @@ if (isset($_POST['response'])) {
} else if (!is_null($response) && $ticket['ticket']['status_id'] == 'XCF') {
TicketManager::update_ticket_status('PND', $_GET['ticket_id'], $user_id);
$ticket['ticket']['status_id'] = 'PND';
$ticket['ticket']['status'] = $plugin->get_lang('Pending');
$ticket['ticket']['status'] = $plugin->get_lang('StsPending');
}
}
}
@ -214,7 +224,17 @@ if (!isset($_POST['compose'])) {
$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>';
}
}
$bold = ($ticket['ticket']['status_id'] == 'CLS') ? 'style = "font-weight: bold;"' : '';
$bold = '';
if ($ticket['ticket']['status_id'] == 'CLS') {
$bold = 'style = "font-weight: bold;"';
echo "<style>
#confirmticket {
display: none;
}
</style>";
}
echo '<div style="margin-left:20%;margin-right:20%;">
<table width="100%" >
<tr>
@ -237,7 +257,7 @@ if (!isset($_POST['compose'])) {
<tr>
<td><p>' . get_lang('Category') . ': ' . $ticket['ticket']['name'] . '</p></td>
<td></td>
<td ><p>' . get_lang('Priority') . ':' . $ticket['ticket']['priority'] . '<p></td>
<td ><p>' . $plugin->get_lang('Priority') . ':' . $ticket['ticket']['priority'] . '<p></td>
<td colspan="2"></td>
</tr>';
if ($ticket['ticket']['course_url'] != null) {
@ -261,7 +281,7 @@ if (!isset($_POST['compose'])) {
$select_admins.= "<option value = '" . $admin['user_id'] . "' " . (($user_id == $admin['user_id']) ? ("selected='selected'") : "") . ">" . $admin['lastname'] . " ," . $admin['firstname'] . "</option>";
}
$select_admins .= "</select>";
echo '<div id="dialog-form" title="' . get_lang('AssignTicket') . '" >';
echo '<div id="dialog-form" title="' . $plugin->get_lang('AssignTicket') . '" >';
echo '<form id="genesis" method="POST" action="ticket_details.php?ticket_id=' . $ticket['ticket']['ticket_id'] . '">
<input type="hidden" name ="action" id="action" value="assign"/>
<div>
@ -277,7 +297,7 @@ if (!isset($_POST['compose'])) {
if ($message['admin']) {
$class = "messagesupport";
if ($isAdmin) {
$message['message'].='<br/><b>' . 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>";

@ -21,7 +21,11 @@ class TicketPlugin extends Plugin
}
protected function __construct()
{
parent::__construct('1.0', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier', array('tool_enable' => 'boolean'));
$settings = array(
'tool_enable' => 'boolean',
'allow_student_add' => 'boolean'
);
parent::__construct('1.0', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier', $settings);
}
/**
@ -31,7 +35,7 @@ class TicketPlugin extends Plugin
{
// Create database tables and insert a Tab
require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/database.php';
}
/**
* Uninstall the ticket plugin
@ -75,7 +79,10 @@ class TicketPlugin extends Plugin
$sql = "DROP TABLE IF EXISTS $tblTicketTicket";
Database::query($sql);
$this->deleteTab($plugSetting['comment']);
$this->deleteExtraSettings();
$rsTab = $this->deleteTab($plugSetting['comment']);
if ($rsTab) {
echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>";
}
}
}

@ -133,7 +133,7 @@ function showResults($courseInfo, $weeksCount, $page)
if ($weeksCount == 14) {
$html .= '<span style="float:right;"><a href="tutor.php?page=' . (($page == 1) ? 2 : 1) . '">' . (($page == 1) ? "Siguiente" : "Anterior") . '</a></span>';
}
$html .= '<span style="float:right;"><a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' . Display::return_icon('import_excel.png', get_lang('Export'), '', '32') . '</a></span>';
$html .= '<span style="float:right;"><a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a></span>';
$html .= '</form>';
$html .= '<table class="reports">';

Loading…
Cancel
Save