Fix empty sessions description - refs BT#9049

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent 4b0edaa6de
commit 9b72f20bbd
  1. 12
      main/admin/resume_session.php
  2. 17
      main/auth/courses_controller.php
  3. 6
      main/session/index.php
  4. 2
      main/template/default/auth/sessions_catalog.tpl
  5. 4
      plugin/advancedsessions/src/AdvancedSessionsPlugin.class.php

@ -249,12 +249,20 @@ if (SessionManager::durationPerUserIsEnabled()) {
}
?>
<?php if (class_exists('AdvancedSessionsPlugin') && AdvancedSessionsPlugin::hasDescriptionField()) { ?>
<?php
if (class_exists('AdvancedSessionsPlugin') && AdvancedSessionsPlugin::hasDescriptionField()) {
$sessionDescription = AdvancedSessionsPlugin::getSessionDescription($sessionId);
if (!empty($sessionDescription)) {
?>
<tr>
<td><?php echo get_lang('Description'); ?></td>
<td><?php echo AdvancedSessionsPlugin::getSessionDescription($sessionId) ?></td>
</tr>
<?php } ?>
<?php
}
}
?>
</table>
<br />

@ -553,7 +553,7 @@ class CoursesController
}
foreach ($sessions as $session) {
$sessionsBlocks[] = array(
$sessionsBlock = array(
'id' => $session['id'],
'name' => $session['name'],
'nbr_courses' => $session['nbr_courses'],
@ -562,8 +562,19 @@ class CoursesController
'is_subscribed' => $session['is_subscribed'],
'icon' => $this->getSessionIcon($session['name']),
'date' => SessionManager::getSessionFormattedDate($session),
'subscribe_button' => $this->getRegisterInSessionButton($session['name'])
'subscribe_button' => $this->getRegisterInSessionButton($session['name']),
'hasDescription' => false
);
if ($showDescription) {
$sessionDescription = AdvancedSessionsPlugin::getSessionDescription($session['id']);
if (!empty($sessionDescription)) {
$sessionsBlock['hasDescription'] = true;
}
}
$sessionsBlocks[] = $sessionsBlock;
}
$tpl = new Template();
@ -586,8 +597,6 @@ class CoursesController
$tpl->assign('sessions_blocks', $sessionsBlocks);
$tpl->assign('already_subscribed_label', $this->getAlreadyRegisterInSessionLabel());
$tpl->assign('showDescription', $showDescription);
$contentTemplate = $tpl->get_template('auth/sessions_catalog.tpl');
$tpl->display($contentTemplate);

@ -361,15 +361,19 @@ echo Display::tag('h1', $session_info['name']);
echo $dates.'<br />';
if (class_exists('AdvancedSessionsPlugin') && AdvancedSessionsPlugin::hasDescriptionField()) {
$sessionDescription = AdvancedSessionsPlugin::getSessionDescription($session_id);
if (!empty($sessionDescription)) {
?>
<div class="home-course-intro">
<div class="page-course">
<div class="page-course-intro">
<p><?php echo AdvancedSessionsPlugin::getSessionDescription($session_id) ?></p>
<p><?php echo $sessionDescription; ?></p>
</div>
</div>
</div>
<?php
}
}
// All Learnpaths grid settings (First tab, first subtab)

@ -134,7 +134,7 @@
</div>
</div>
<div class="span3">
{% if showDescription %}
{% if session.hasDescription %}
<div class="buttom-subscribed">
<a class="ajax btn btn-large btn-info" href="{{ _p.web_ajax }}session.ajax.php?a=get_description&session={{ session.id }}">{{ 'Description' | get_lang }}</a>
</div>

@ -138,7 +138,7 @@ class AdvancedSessionsPlugin extends Plugin
/**
* Get the session description
* @param int $sessionId The session id
* @return string
* @return string The session description. Otherwise return null
*/
public static function getSessionDescription($sessionId) {
$sessionId = intval($sessionId);
@ -146,6 +146,6 @@ class AdvancedSessionsPlugin extends Plugin
$fieldValue = new ExtraFieldValue('session');
$description = $fieldValue->get_values_by_handler_and_field_variable($sessionId, self::FIELD_NAME, false);
return $description !== false ? $description['field_value'] : get_lang('None');
return $description !== false ? trim($description['field_value']) : '';
}
}

Loading…
Cancel
Save