Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

pull/2487/head
Julio 8 years ago
commit 29f143edda
  1. 14
      main/calendar/agenda_list.php
  2. 11
      main/forum/editthread.php
  3. 2
      main/forum/forumfunction.inc.php
  4. 2
      main/inc/lib/agenda.lib.php
  5. 178
      main/inc/lib/sessionmanager.lib.php
  6. 6
      main/session/session_course_list.php
  7. 113
      main/template/default/agenda/event_list.tpl
  8. 22
      main/template/default/agenda/month.tpl

@ -13,6 +13,20 @@ $interbreadcrumb[] = array(
);
$currentCourseId = api_get_course_int_id();
$currentGroupdId = api_get_group_id();
if (!empty($currentGroupdId)) {
$groupProperties = GroupManager::get_group_properties($currentGroupdId);
$interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(),
"name" => get_lang('Groups')
);
$interbreadcrumb[] = array(
"url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(),
"name" => get_lang('GroupSpace').' '.$groupProperties['name']
);
}
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$agenda = new Agenda($type);
$events = $agenda->getEvents(

@ -228,7 +228,7 @@ if (!empty($threadData)) {
$defaults['weight_calification'] = 0;
$defaults['thread_peer_qualify'] = 0;
}
$form->setDefaults(isset($defaults) ? $defaults : null);
$form->addButtonUpdate(get_lang('ModifyThread'), 'SubmitPost');
if ($form->validate()) {
@ -242,12 +242,13 @@ if ($form->validate()) {
header('Location: '.$redirectUrl);
exit;
}
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
}
$form->setDefaults(isset($defaults) ? $defaults : null);
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$originIsLearnPath = $origin == 'learnpath';
$view = new Template(

@ -2454,7 +2454,7 @@ function updateThread($values)
// Simple update + set gradebook values to null
$params = [
'thread_title' => $values['thread_title'],
'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null
'thread_sticky' => isset($values['thread_sticky'])
];
$where = ['c_id = ? AND thread_id = ?' => [$courseId, $values['thread_id']]];
Database::update($threadTable, $params, $where);

@ -1282,7 +1282,7 @@ class Agenda
switch ($format) {
case 'json':
if (empty($this->events)) {
return '';
return '[]';
}
return json_encode($this->events);

@ -3096,127 +3096,107 @@ class SessionManager
/**
* Assign a coach to course in session with status = 2
* @param int $user_id
* @param int $session_id
* @param int $courseId
* @param bool $nocoach optional, if is true the user don't be a coach now,
* @param int $userId
* @param int $sessionId
* @param int $courseId
* @param bool $noCoach optional, if is true the user don't be a coach now,
* otherwise it'll assign a coach
* @return bool true if there are affected rows, otherwise false
*/
public static function set_coach_to_course_session(
$user_id,
$session_id = 0,
$userId,
$sessionId = 0,
$courseId = 0,
$nocoach = false
$noCoach = false
) {
// Definition of variables
$user_id = intval($user_id);
if (!empty($session_id)) {
$session_id = intval($session_id);
} else {
$session_id = api_get_session_id();
}
$userId = intval($userId);
if (!empty($courseId)) {
$courseId = intval($courseId);
} else {
$courseId = api_get_course_id();
}
$sessionId = !empty($sessionId) ? intval($sessionId) : api_get_session_id();
$courseId = !empty($courseId) ? intval($courseId) : api_get_course_id();
if (empty($session_id) || empty($courseId) || empty($user_id)) {
if (empty($sessionId) || empty($courseId) || empty($userId)) {
return false;
}
// Table definition
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tblSessionRelCourseRelUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tblSessionRelUser = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tblUser = Database::get_main_table(TABLE_MAIN_USER);
// check if user is a teacher
$sql = "SELECT * FROM $tbl_user
WHERE status = 1 AND user_id = $user_id";
$sql = "SELECT * FROM $tblUser
WHERE status = 1 AND user_id = $userId";
$rs_check_user = Database::query($sql);
$rsCheckUser = Database::query($sql);
if (Database::num_rows($rs_check_user) > 0) {
if ($nocoach) {
// check if user_id exists in session_rel_user (if the user is
// subscribed to the session in any manner)
$sql = "SELECT user_id FROM $tbl_session_rel_user
WHERE
session_id = $session_id AND
user_id = $user_id";
$res = Database::query($sql);
if (Database::num_rows($rsCheckUser) <= 0) {
return false;
}
if (Database::num_rows($res) > 0) {
// The user is already subscribed to the session. Change the
// record so the user is NOT a coach for this course anymore
// and then exit
$sql = "UPDATE $tbl_session_rel_course_rel_user
SET status = 0
WHERE
session_id = $session_id AND
c_id = $courseId AND
user_id = $user_id ";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0)
return true;
else
return false;
} else {
// The user is not subscribed to the session, so make sure
// he isn't subscribed to a course in this session either
// and then exit
$sql = "DELETE FROM $tbl_session_rel_course_rel_user
WHERE
session_id = $session_id AND
c_id = $courseId AND
user_id = $user_id ";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
return true;
} else {
return false;
}
}
} else {
// Assign user as a coach to course
// First check if the user is registered to the course
$sql = "SELECT user_id FROM $tbl_session_rel_course_rel_user
if ($noCoach) {
// check if user_id exists in session_rel_user (if the user is
// subscribed to the session in any manner)
$sql = "SELECT user_id FROM $tblSessionRelUser
WHERE
session_id = $sessionId AND
user_id = $userId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
// The user is already subscribed to the session. Change the
// record so the user is NOT a coach for this course anymore
// and then exit
$sql = "UPDATE $tblSessionRelCourseRelUser
SET status = 0
WHERE
session_id = $session_id AND
session_id = $sessionId AND
c_id = $courseId AND
user_id = $user_id";
$rs_check = Database::query($sql);
// Then update or insert.
if (Database::num_rows($rs_check) > 0) {
$sql = "UPDATE $tbl_session_rel_course_rel_user SET status = 2
WHERE
session_id = $session_id AND
c_id = $courseId AND
user_id = $user_id ";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
return true;
} else {
return false;
}
} else {
$sql = "INSERT INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id, status)
VALUES($session_id, $courseId, $user_id, 2)";
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
return true;
} else {
return false;
}
}
user_id = $userId ";
$result = Database::query($sql);
return Database::affected_rows($result) > 0;
}
} else {
return false;
// The user is not subscribed to the session, so make sure
// he isn't subscribed to a course in this session either
// and then exit
$sql = "DELETE FROM $tblSessionRelCourseRelUser
WHERE
session_id = $sessionId AND
c_id = $courseId AND
user_id = $userId ";
$result = Database::query($sql);
return Database::affected_rows($result) > 0;
}
// Assign user as a coach to course
// First check if the user is registered to the course
$sql = "SELECT user_id FROM $tblSessionRelCourseRelUser
WHERE
session_id = $sessionId AND
c_id = $courseId AND
user_id = $userId";
$rs_check = Database::query($sql);
// Then update or insert.
if (Database::num_rows($rs_check) > 0) {
$sql = "UPDATE $tblSessionRelCourseRelUser SET status = 2
WHERE
session_id = $sessionId AND
c_id = $courseId AND
user_id = $userId ";
$result = Database::query($sql);
return Database::affected_rows($result) > 0;
}
$sql = "INSERT INTO $tblSessionRelCourseRelUser(session_id, c_id, user_id, status)
VALUES($sessionId, $courseId, $userId, 2)";
$result = Database::query($sql);
return Database::affected_rows($result) > 0;
}
/**

@ -23,9 +23,9 @@ if (empty($id_session)) {
api_not_allowed();
}
$page = intval($_GET['page']);
$action = $_REQUEST['action'];
$sort = in_array($_GET['sort'], array('title', 'nbr_users')) ? $_GET['sort'] : 'title';
$page = isset($_GET['page']) ? intval($_GET['page']) : 0;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$sort = isset($_GET['sort']) && in_array($_GET['sort'], array('title', 'nbr_users')) ? $_GET['sort'] : 'title';
$result = Database::query("SELECT name FROM $tbl_session WHERE id='$id_session'");

@ -1,64 +1,65 @@
{{ agenda_actions }}
<table class="data_table">
<tr>
<th>
{{ 'StartDate'| get_lang }}
</th>
<th>
{{ 'EndDate'| get_lang }}
</th>
<th>
{{ 'Title' | get_lang }}
</th>
{% if is_allowed_to_edit and show_action %}
<th>
{{ 'Actions' | get_lang }}
</th>
{% endif %}
</tr>
{% for event in agenda_events %}
<tr>
<td style="width:20%">
{{ event.start_date_localtime }}
</td>
<td style="width:20%">
{% if event.allDay %}
{{ 'AllDay' | get_lang }}
{% else %}
{{ event.end_date_localtime }}
{% for event in agenda_events %}
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-{{ event.id }}">
{% if is_allowed_to_edit and show_action %}
<div class="pull-right">
{% if event.visibility == 1 %}
<a class="btn btn-default btn-xs"
href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&action=change_visibility&visibility=0&id={{ event.real_id }}&type={{ event.type }}">
<img title="{{ 'Invisible' }}" src="{{ 'visible.png'|icon(22) }}">
</a>
{% else %}
{% if event.type == 'course' or event.type == 'session' %}
<a class="btn btn-default btn-xs"
href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&action=change_visibility&visibility=1&id={{ event.real_id }}&type={{ event.type }}">
<img title="{{ 'Visible' }}" src="{{ 'invisible.png'|icon(22) }}">
</a>
{% endif %}
{% endif %}
</div>
{% endif %}
</td>
<td style="width:50%">
{{ event.title }}
{% if event.description %}
<p>{{ event.description}}</p>
{% endif %}
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion"
href="#collapse-{{ event.id }}" aria-expanded="false" aria-controls="collapse-{{ event.id }}">
{{ event.title }}
<br>
<small>
{{ event.start_date_localtime }}
{% if event.comment %}
<p>{{ event.comment}}</p>
{% endif %}
&dash;
{{ event.attachment }}
</td>
{% if event.allDay %}
{{ 'AllDay' | get_lang }}
{% else %}
{{ event.end_date_localtime }}
{% endif %}
</small>
</a>
</h4>
</div>
<div id="collapse-{{ event.id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-{{ event.id }}">
<ul class="list-group">
{% if event.description %}
<li class="list-group-item">
{{ event.description}}
</li>
{% endif %}
{% if is_allowed_to_edit and show_action %}
<td>
{% if event.visibility == 1 %}
<a class="btn btn-default" href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&action=change_visibility&visibility=0&id={{ event.real_id }}&type={{ event.type }}">
<img title="{{ 'Invisible' }}" src="{{'visible.png'|icon(32)}} " width="32" height="32">
</a>
{% else %}
{% if event.type == 'course' or event.type == 'session' %}
<a class="btn btn-default" href="{% if url %}{{ url }}{% else %}{{ event.url }}{% endif %}&action=change_visibility&visibility=1&id={{ event.real_id }}&type={{ event.type }}">
<img title="{{ 'Visible' }}" src="{{'invisible.png'|icon(32)}} " width="32" height="32">
</a>
{% endif %}
{% if event.comment %}
<li class="list-group-item">
{{ event.comment}}
</li>
{% endif %}
{% if event.attachment %}
<li class="list-group-item">{{ event.attachment }}</li>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</table>
</ul>
</div>
</div>
</div>
{% endfor %}

@ -213,6 +213,7 @@ $(document).ready(function() {
},
views: {
CustomView: { // name of view
type: 'list',
buttonText: '{{ 'AgendaList' | get_lang | escape('js') }}',
duration: { month: 1 },
defaults: {
@ -392,19 +393,14 @@ $(document).ready(function() {
}).removeData('qtip'); // this is an special hack to add multiple qtip in the same target
*/
}
if (event.description) {
var comment = '';
if (event.comment) {
comment = event.comment;
}
element.qtip({
hide: {
delay: 2000
},
content: event.description + ' ' + comment,
position: { at:'top left' , my:'bottom left'}
});
if (event.comment) {
element.qtip({
content: event.comment,
position: {
at: 'top center',
my: 'bottom center'
}
});
}
},
eventClick: function(calEvent, jsEvent, view) {

Loading…
Cancel
Save