Add option to restrict course chat only for coaches - refs BT#13885

pull/2458/head
Angel Fernando Quiroz Campos 8 years ago
parent 476a5dd38c
commit 29465ed4b1
  1. 1
      main/chat/chat.php
  2. 23
      main/inc/lib/CourseChatUtils.php
  3. 2
      main/install/configuration.dist.php
  4. 16
      main/template/default/chat/chat.tpl

@ -50,6 +50,7 @@ $view = new Template(get_lang('Chat'), false, false, false, true, false);
$view->assign('icons', $iconList); $view->assign('icons', $iconList);
$view->assign('emoji_strategy', CourseChatUtils::getEmojiStrategy()); $view->assign('emoji_strategy', CourseChatUtils::getEmojiStrategy());
$view->assign('emoji_smile', \Emojione\Emojione::toImage(':smile:')); $view->assign('emoji_smile', \Emojione\Emojione::toImage(':smile:'));
$view->assign('restrict_to_coach', api_get_configuration_value('course_chat_restrict_to_coach'));
$template = $view->get_template('chat/chat.tpl'); $template = $view->get_template('chat/chat.tpl');
$content = $view->fetch($template); $content = $view->fetch($template);

@ -4,6 +4,8 @@
use Michelf\MarkdownExtra; use Michelf\MarkdownExtra;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Chamilo\CourseBundle\Entity\CChatConnected; use Chamilo\CourseBundle\Entity\CChatConnected;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
/** /**
* Class CourseChat * Class CourseChat
@ -41,20 +43,31 @@ class CourseChatUtils
private function getUsersSubscriptions() private function getUsersSubscriptions()
{ {
$em = Database::getManager(); $em = Database::getManager();
/** @var Course $course */
$course = $em->find('ChamiloCoreBundle:Course', $this->courseId); $course = $em->find('ChamiloCoreBundle:Course', $this->courseId);
if ($this->sessionId) { if ($this->sessionId) {
/** @var Session $session */
$session = $em->find('ChamiloCoreBundle:Session', $this->sessionId);
$criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course)); $criteria = Criteria::create()->where(Criteria::expr()->eq('course', $course));
$userIsCoach = api_is_course_session_coach($this->userId, $course->getId(), $session->getId());
return $em if (api_get_configuration_value('course_chat_restrict_to_coach')) {
->find('ChamiloCoreBundle:Session', $this->sessionId) if (!$userIsCoach) {
$criteria->andWhere(
Criteria::expr()->eq('status', Session::COACH)
);
}
}
$criteria->orderBy(['status' => Criteria::DESC]);
return $session
->getUserCourseSubscriptions() ->getUserCourseSubscriptions()
->matching($criteria); ->matching($criteria);
} }
return $em return $course->getUsers();
->find('ChamiloCoreBundle:Course', $course)
->getUsers();
} }
/** /**

@ -731,3 +731,5 @@ $_configuration['gradebook_badge_sidebar'] = [
// You need add a new option called "confirmation" to the registration settings // You need add a new option called "confirmation" to the registration settings
//INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_registration', 'confirmation', 'MailConfirmation'); //INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_registration', 'confirmation', 'MailConfirmation');
// ------ (End) Custom DB changes // ------ (End) Custom DB changes
// Restrict course chat only for course coach in sessions
//$_configuration['course_chat_restrict_to_coach'] = false;

@ -6,13 +6,15 @@
<div class="col-sm-8 col-md-7 col-lg-8"> <div class="col-sm-8 col-md-7 col-lg-8">
<div id="chat-tabs"> <div id="chat-tabs">
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"> {% if not restrict_to_coach %}
<a href="#all" aria-controls="all" role="tab" data-toggle="tab">{{ 'All'|get_lang }}</a> <li role="presentation" class="active">
</li> <a href="#all" aria-controls="all" role="tab" data-toggle="tab">{{ 'All'|get_lang }}</a>
</li>
{% endif %}
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="all"> <div role="tabpanel" class="tab-pane active" id="{{ restrict_to_coach ? '' : 'all' }}">
<div class="course-chat chat-history" id="chat-history"></div> <div class="course-chat chat-history" id="{{ restrict_to_coach ? '' : 'chat-history' }}"></div>
</div> </div>
</div> </div>
</div> </div>
@ -41,7 +43,7 @@
<textarea id="chat-writer" name="message"></textarea> <textarea id="chat-writer" name="message"></textarea>
</div> </div>
<div class="col-sm-3"> <div class="col-sm-3">
<button id="chat-send-message" type="button" class="btn btn-primary">{{ 'Send'|get_lang }}</button> <button id="chat-send-message" type="button" disabled class="btn btn-primary">{{ 'Send'|get_lang }}</button>
</div> </div>
</div> </div>
</div> </div>
@ -271,6 +273,8 @@ $(document).on('ready', function () {
} }
}); });
$('button#chat-send-message').prop('disabled', false);
if (exists) { if (exists) {
$('#chat-tab-' + userId).tab('show'); $('#chat-tab-' + userId).tab('show');

Loading…
Cancel
Save