Browse Source

update customs icons aparence template CT#7614

aragonc 9 years ago
parent
commit
72ce7b10d0

+ 30 - 2
app/Resources/public/css/base.css

@@ -43,8 +43,12 @@ select {
 .clear-header{
   height: 60px;
 }
-.title-header-tools{
-  text-align: center;
+.title-tools{
+  text-align: left;
+  font-size: 20px;
+  margin-bottom: 20px;
+  padding-top: 10px;
+  padding-left: 20px;
 }
 #formLogin .input-group{
   margin-top: 10px;
@@ -6115,6 +6119,30 @@ div#chat-remote-video video {
 #session-list .options p{
   margin: 0;
 }
+#custom-icons .items-tools{
+  padding: 10px;
+  border: 1px solid #CCCCCC;
+  border-radius: 5px;
+  -moz-border-radius: 5px;
+  -webkit-border-radius: 5px;
+  min-height: 185px;
+  margin-bottom: 20px;
+  text-align: center;
+}
+#custom-icons .name-tools{
+  font-size: 12px;
+  padding-top: 10px;
+  padding-bottom: 10px;
+}
+#custom-icons .btn{
+  font-size: 18px;
+  line-height: 0;
+  margin-right: 5px;
+}
+#custom-icons .page-header{
+  margin: 20px 0px 20px;
+  border-bottom: 1px solid #CCCCCC;
+}
 /* CSS NEW TOP ******************************************************************************/
 /* CSS Responsive */
 @media (min-width: 1025px) and (max-width: 1200px) {

+ 1 - 1
main/admin/skill_badge.php

@@ -16,7 +16,7 @@ if (!api_is_platform_admin() || api_get_setting('allow_skills_tool') !== 'true')
 }
 $backpack = 'https://backpack.openbadges.org/';
 
-$configBackpack = api_get_seeting('openbadges_backpack');
+$configBackpack = api_get_setting('openbadges_backpack');
 if (strcmp($backpack, $configBackpack) !== 0) {
     $backpack = $configBackpack;
 }

+ 2 - 2
main/calendar/agenda_js.php

@@ -5,7 +5,7 @@
  * @package chamilo.calendar
  */
 
-use \ChamiloSession as Session;
+use ChamiloSession as Session;
 
 // use anonymous mode when accessing this course tool
 $use_anonymous = true;
@@ -232,7 +232,7 @@ if ($agenda->type == 'course') {
     $form->addElement('textarea', 'comment', get_lang('Comment'), array('id' => 'comment'));
 }
 
-$tpl->assign('form_add', $form->return_form());
+$tpl->assign('form_add', $form->returnForm());
 
 // Loading Agenda template.
 $content = $tpl->fetch('default/agenda/month.tpl');

+ 3 - 6
main/course_home/activity.php

@@ -177,14 +177,11 @@ if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, tr
  */
 function return_block($title, $content, $class = null)
 {
-    $html = '<div class="row course-title-tools">
-                <div class="col-md-12">
-                    <div class="title-header-tools">
-                        <h4>'.$title.'</h4>
-                    </div>
+    $html = '<div class="row">
+                <div class="col-xs-12 col-md-12">
+                    <div class="title-tools">' . $title . '</div>
                 </div>
             </div>
             <div class="row '.$class.'">'.$content.'</div>';
-
     return $html;
 }

+ 0 - 1
main/course_home/course_home.php

@@ -287,7 +287,6 @@ if (api_get_setting('homepage_view') == 'activity' ||
 }
 
 
-
 $content = '<div id="course_tools">'.$content.'</div>';
 $tpl = new Template(null);
 $tpl->assign('message', $show_message);

+ 66 - 30
main/course_info/tools.php

@@ -35,7 +35,7 @@ switch ($action) {
             api_not_allowed(true);
         }
 
-        $interbreadcrumb[] = array('url' => api_get_self().'?'.api_get_cidreq(), 'name' => get_lang('Tools'));
+        $interbreadcrumb[] = array('url' => api_get_self().'?'.api_get_cidreq(), 'name' => get_lang('CustomizeIcons'));
 
         $toolName = $tool['name'];
 
@@ -43,9 +43,18 @@ switch ($action) {
 
         $form = new FormValidator('icon_edit', 'post', $currentUrl);
         $form->addElement('header', get_lang('EditIcon'));
+        $form->addHtml('<div class="col-md-7">');
         $form->addElement('text', 'name', get_lang('Name'));
         $form->addElement('text', 'link', get_lang('Links'));
-
+        $allowed_picture_types = array ('jpg', 'jpeg', 'png');
+        $form->addElement('file', 'icon', get_lang('CustomIcon'));
+        $form->addRule('icon', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
+        $form->addElement('select', 'target', get_lang('Target'), array('_self' => '_self', '_blank' => '_blank'));
+        $form->addElement('select', 'visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
+        $form->addElement('textarea', 'description', get_lang('Description'),array ('rows' => '3', 'cols' => '40'));
+        $form->addButtonUpdate(get_lang('Update'));
+        $form->addHtml('</div>');
+        $form->addHtml('<div class="col-md-5">');
         if (isset($tool['custom_icon']) && !empty($tool['custom_icon'])) {
             $form->addLabel(
                 get_lang('Icon'),
@@ -56,15 +65,8 @@ switch ($action) {
 
             $form->addCheckBox('delete_icon', null, get_lang('DeletePicture'));
         }
+        $form->addHtml('</div>');
 
-        $allowed_picture_types = array ('jpg', 'jpeg', 'png');
-        $form->addElement('file', 'icon', get_lang('CustomIcon'));
-        $form->addRule('icon', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
-
-        $form->addElement('select', 'target', get_lang('Target'), array('_self' => '_self', '_blank' => '_blank'));
-        $form->addElement('select', 'visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
-        $form->addElement('textarea', 'description', get_lang('Description'),array ('rows' => '3', 'cols' => '40'));
-        $form->addButtonUpdate(get_lang('Update'));
 
         $form->setDefaults($tool);
 
@@ -77,40 +79,74 @@ switch ($action) {
             if (isset($data['delete_icon'])) {
                 CourseHome::deleteIcon($id);
             }
-
-            header('Location: '.$currentUrl);
+            $currentUrlReturn = api_get_self().'?'.api_get_cidreq();
+            header('Location: '.$currentUrlReturn);
             exit;
         }
         break;
     case 'list':
     default:
-        $toolName = get_lang('Tools');
+
         $toolList = CourseHome::toolsIconsAction(
             api_get_course_int_id(),
             api_get_session_id()
         );
+        $iconsTools = '<div id="custom-icons">';
+        $iconsTools .= Display::page_header( get_lang('CustomizeIcons'),null,'h4');
+        $iconsTools .= '<div class="row">';
+        foreach($toolList as $tool){
+
+            if($tool['id']>20){
+                $toolName = $tool['name'];
+            }else{
+                $toolName = get_lang('Tool'.api_underscore_to_camel_case($tool['name']));
+            }
+
+            $iconsTools .= '<div class="col-md-2">';
+            $iconsTools .= '<div class="items-tools">';
+
+            if(!empty($tool['custom_icon'])){
+                $image = getCustomWebIconPath().$tool['custom_icon'];
+                $icon = Display::img($image,$toolName);
+            }else{
+                $image = (substr($tool['image'], 0, strpos($tool['image'], '.'))).'.png';
+                $icon = Display::return_icon(
+                    $image,
+                    $tool_name,
+                    array('id' => 'tool_'.$tool['id']),
+                    ICON_SIZE_BIG,
+                    false
+                );
+            }
 
-        $table = '<table class="data_table">';
-        foreach ($toolList as $tool) {
-            $table .= '<tr>';
-            $table .= '<td><a href="' . api_get_path(WEB_CODE_PATH) . $tool['link'] . '?' . api_get_cidreq() . '">
-                    <img src="' . api_get_path(WEB_IMG_PATH).$tool['image']. '"></a></td>';
-            $table .= '<td><a href="' . api_get_path(WEB_CODE_PATH) . $tool['link'] . '?' . api_get_cidreq() . '">' .
-                $tool['name']. '</a></td>';
-            $table .= '<td>
-                    <a class="btn btn-primary" href="' . api_get_self() . '?action=edit_icon&id=' . $tool['iid'] . '&'.api_get_cidreq().'">' .
-                    get_lang('Edit'). '</a></td>';
-            $delete = (!empty($tool['custom_icon'])) ? '<a class="btn btn-danger" href="' . api_get_self() . '?action=delete_icon&id=' . $tool['iid'] . '&'.api_get_cidreq().'">' .
-                get_lang('Delete'). '</a>' : '';
-            $table .= '<td>' . $delete . '</td>';
-            $table .= '</tr>';
+
+            $delete = (!empty($tool['custom_icon'])) ? '<a class="btn btn-default" href="' . api_get_self() . '?action=delete_icon&id=' . $tool['iid'] . '&'.api_get_cidreq().'">
+            <i class="fa fa-trash-o"></i></a>' : '';
+            $edit = '<a class="btn btn-default" href="' . api_get_self() . '?action=edit_icon&id=' . $tool['iid'] . '&'.api_get_cidreq().'"><i class="fa fa-pencil"></i></a>';
+
+
+            $iconsTools .= '<div class="icon-tools">'. $icon . '</div>';
+            $iconsTools .= '<div class="name-tools">' . $toolName . '</div>';
+            $iconsTools .= '<div class="toolbar">' . $edit . $delete . '</div>';
+            $iconsTools .= '</div>';
+            $iconsTools .= '</div>';
         }
-        $table .= '</table>';
-        $content = $table;
+        $iconsTools .= '</div>';
+        $iconsTools .= '</div>';
+
+        $content.=$iconsTools;
 
         break;
 }
-
+/**
+ * @return string
+ */
+function getCustomWebIconPath()
+{
+    // Check if directory exists or create it if it doesn't
+    $dir = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/course_home_icons/';
+    return $dir;
+}
 $tpl = new Template($toolName);
 
 $tpl->assign('content', $content);

+ 15 - 6
main/document/edit_document.php

@@ -25,7 +25,6 @@
  * not for validation at the moment)
  */
 
-/*	Included libraries */
 require_once '../inc/global.inc.php';
 
 // Template's javascript
@@ -140,7 +139,10 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
 $course_id = api_get_course_int_id();
 
 if (!empty($group_id)) {
-	$interbreadcrumb[] = array ('url' => '../group/group_space.php?'.api_get_cidreq(), 'name' => get_lang('GroupSpace'));
+    $interbreadcrumb[] = array(
+        'url' => '../group/group_space.php?'.api_get_cidreq(),
+        'name' => get_lang('GroupSpace'),
+    );
 	$group_document = true;
 	$noPHP_SELF = true;
 }
@@ -195,7 +197,8 @@ if (isset($_POST['comment'])) {
 	}
 
     if (!empty($document_id)) {
-        $query = "UPDATE $dbTable SET comment='".$comment."', title='".$title."' WHERE c_id = $course_id AND id = ".$document_id;
+        $query = "UPDATE $dbTable SET comment='".$comment."', title='".$title."'
+        		WHERE c_id = $course_id AND id = ".$document_id;
         Database::query($query);
         $info_message = get_lang('fileModified');
     }
@@ -495,7 +498,13 @@ if ($owner_id == api_get_user_id() ||
 
 	$form->setDefaults($defaults);
 
-	show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode);
+    show_return(
+        $parent_id,
+        $dir_original,
+        $call_from_tool,
+        $slide_id,
+        $is_certificate_mode
+    );
 
 	if ($is_certificate_mode) {
 		$all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(
@@ -537,8 +546,8 @@ Display::display_footer();
 	It returns nothing.
     @todo check if this function is used
 */
-function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) {
-
+function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc)
+{
 	$file_name_for_change = $base_work_dir.$dir.$source_file;
     $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file
 	$rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API

+ 130 - 0
main/gradebook/gradebook_display_summary.php

@@ -0,0 +1,130 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * Script
+ * @package chamilo.gradebook
+ */
+
+$language_file = 'gradebook';
+
+require_once '../inc/global.inc.php';
+$current_course_tool  = TOOL_GRADEBOOK;
+
+api_protect_course_script();
+
+set_time_limit(0);
+ini_set('max_execution_time', 0);
+api_block_anonymous_users();
+
+if (!api_is_allowed_to_edit()) {
+    api_not_allowed(true);
+}
+
+$cat_id = isset($_GET['selectcat']) ? (int)$_GET['selectcat'] : null;
+$action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
+
+$userList = CourseManager::get_user_list_from_course_code(
+    api_get_course_id(),
+    api_get_session_id()
+);
+
+switch ($action) {
+    case 'export_all':
+
+        $params = array();
+        $pdf = new PDF('A4', 'P', $params);
+
+        $pdfList = array();
+        foreach ($userList as $index => $value) {
+            $pdfList[] = GradebookUtils::generateTable(
+                $value['user_id'],
+                $cat_id,
+                false,
+                true
+            );
+        }
+
+        if (!empty($pdfList)) {
+            // Print certificates (without the common header/footer/watermark
+            //  stuff) and return as one multiple-pages PDF
+            $pdf->html_to_pdf(
+                $pdfList,
+                null,
+                null,
+                false,
+                false,
+                true
+            );
+        }
+
+        break;
+    case 'download':
+        $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
+        GradebookUtils::generateTable($userId, $cat_id);
+        break;
+    /*case 'generate_all_certificates':
+        $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
+        if (!empty($user_list)) {
+            foreach ($user_list as $user_info) {
+                if ($user_info['status'] == INVITEE) {
+                    continue;
+                }
+
+                Category::register_user_certificate($cat_id, $user_info['user_id']);
+            }
+        }
+        break;
+    case 'delete_all_certificates':
+        Category::deleteAllCertificates($cat_id);
+        break;*/
+}
+
+$course_code = api_get_course_id();
+
+$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?',	'name' => get_lang('Gradebook'));
+$interbreadcrumb[] = array('url' => '#','name' => get_lang('GradebookListOfStudentsReports'));
+
+$this_section = SECTION_COURSES;
+
+Display::display_header('');
+
+$token = Security::get_token();
+
+echo Display::page_header(get_lang('GradebookListOfStudentsReports'));
+
+echo '<div class="btn-group">';
+/*$url = api_get_self().'?action=generate_all_certificates'.'&'.api_get_cidReq().'&selectcat='.$cat_id;
+echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn'));
+*/
+/*$url = api_get_self().'?action=delete_all_certificates'.'&'.api_get_cidReq().'&selectcat='.$cat_id;
+echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn'));*/
+
+if (count($userList) > 0) {
+    $url = api_get_self().'?action=export_all&'.api_get_cidReq().'&selectcat='.$cat_id;
+    echo Display::url(get_lang('ExportAllToPDF'), $url, array('class' => 'btn btn-default'));
+}
+echo '</div>';
+
+if (count($userList) == 0 ) {
+    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
+} else {
+    echo '<br /><br /><table class="data_table">';
+    foreach ($userList as $index => $value) {
+        echo '<tr>
+                <td width="100%" >'.
+                get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') </td>';
+        echo '<td>';
+        $url = api_get_self().'?'.api_get_cidreq().'&action=download&user_id='.$value['user_id'].'&selectcat='.$cat_id;
+        $link = Display::url(
+            get_lang('ExportToPDF'),
+            $url,
+            array('target' => '_blank', 'class' => 'btn btn-default')
+        );
+        echo $link;
+        echo '</td></tr>';
+    }
+    echo '</table>';
+}
+
+Display::display_footer();

+ 89 - 0
main/gradebook/lib/GradebookUtils.php

@@ -1299,4 +1299,93 @@ class GradebookUtils
         return $sessionList;
     }
 
+    /**
+     * @param int $userId
+     * @param int $categoryId
+     * @param bool $saveToFile
+     * @param bool $saveToHtmlFile
+     *
+     * @return string
+     */
+    public static function generateTable($userId, $categoryId, $saveToFile = false, $saveToHtmlFile = false)
+    {
+        $courseInfo = api_get_course_info();
+        $userInfo = api_get_user_info($userId);
+
+        $cats = Category::load($categoryId, null, null, null, null, null, false);
+        $cat = $cats[0];
+
+        $allcat = $cats[0]->get_subcategories(
+            $userId,
+            api_get_course_id(),
+            api_get_session_id()
+        );
+        $alleval = $cats[0]->get_evaluations($userId);
+        $alllink = $cats[0]->get_links($userId);
+
+        $gradebooktable = new GradebookTable(
+            $cat,
+            $allcat,
+            $alleval,
+            $alllink,
+            null, // params
+            true, // $exportToPdf
+            false, // showteacher
+            $userId
+        );
+
+        if (api_is_allowed_to_edit()) {
+            $gradebooktable->td_attributes = [
+                4 => 'class=centered'
+            ];
+        } else {
+            $gradebooktable->td_attributes = [
+                3 => 'class=centered',
+                4 => 'class=centered',
+                5 => 'class=centered',
+                6 => 'class=centered',
+                7 => 'class=centered'
+            ];
+        }
+
+        $table = $gradebooktable->return_table();
+        $graph = $gradebooktable->getGraph();
+
+        $sessionName = api_get_session_name(api_get_session_id());
+        $sessionName = !empty($sessionName) ? " - $sessionName" : '';
+        $params = array(
+            //'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(),
+            'pdf_title' => $courseInfo['title'].$sessionName,
+            'course_code' => api_get_course_id(),
+            'session_info' => api_get_session_info(api_get_session_id()),
+            'add_signatures' => false,
+            'student_info' => $userInfo,
+            'show_grade_generated_date' => true,
+            'show_real_course_teachers' => true
+        );
+
+        $file = api_get_path(SYS_ARCHIVE_PATH).uniqid().'.html';
+
+        $content =
+            $table.
+            $graph.
+            '<br />'.get_lang('Feedback').'<br />
+            <textarea rows="5" cols="100" ></textarea>';
+
+        $pdf = new PDF('A4', $params['orientation'], $params);
+
+        $result = $pdf->html_to_pdf_with_template(
+            $content,
+            $saveToFile,
+            $saveToHtmlFile
+        );
+
+        if ($saveToHtmlFile) {
+            file_put_contents($file, $result);
+            return $file;
+        }
+
+        return $file;
+    }
+
 }

+ 13 - 0
main/gradebook/lib/fe/displaygradebook.php

@@ -584,6 +584,19 @@ class DisplayGradebook
                             . "</td>";
                     }
 
+                    $header .= "<td style=\"vertical-align: top;\">"
+                        . Display::url(
+                            Display::return_icon(
+                                'user.png',
+                                get_lang('GradebookListOfStudentsReports'),
+                                '',
+                                ICON_SIZE_MEDIUM
+                            ),
+                            "gradebook_display_summary.php?$my_api_cidreq&selectcat=" . intval($_GET['selectcat'])
+                        )
+                        . "</td>";
+
+
                     // Right icons
                     $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' .
                         Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';

+ 40 - 21
main/gradebook/lib/fe/gradebooktable.class.php

@@ -20,6 +20,8 @@ class GradebookTable extends SortableTable
     public $cats;
     private $dataForGraph;
     public $exportToPdf;
+    public $teacherView;
+    public $userId;
 
     /**
      * Constructor
@@ -29,8 +31,20 @@ class GradebookTable extends SortableTable
      * @param array $links
      * @param null $addparams
      */
-    public function __construct($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null, $exportToPdf = false)
-    {
+    public function __construct(
+        $currentcat,
+        $cats = array(),
+        $evals = array(),
+        $links = array(),
+        $addparams = null,
+        $exportToPdf = false,
+        $showTeacherView = null,
+        $userId = null
+    ) {
+        $this->teacherView = is_null($showTeacherView) ? api_is_allowed_to_edit(null, true) : $showTeacherView;
+        $this->userId = is_null($userId) ? api_get_user_id() : $userId;
+        $this->exportToPdf = $exportToPdf;
+
         parent::__construct('gradebooklist', null, null, api_is_allowed_to_edit() ? 1 : 0, 20, 'ASC', 'gradebook_list');
         $this->evals_links = array_merge($evals, $links);
         $this->currentcat = $currentcat;
@@ -42,7 +56,7 @@ class GradebookTable extends SortableTable
         }
 
         $column= 0;
-        if (api_is_allowed_to_edit(null, true)) {
+        if ($this->teacherView) {
             if ($this->exportToPdf == false) {
                 $this->set_header($column++, '', '', 'width="25px"');
             }
@@ -55,7 +69,7 @@ class GradebookTable extends SortableTable
             $this->set_header($column++, get_lang('Description'), false);
         }
 
-        if (api_is_allowed_to_edit(null, true)) {
+        if ($this->teacherView) {
             $this->set_header(
                 $column++,
                 get_lang('Weight'),
@@ -80,7 +94,7 @@ class GradebookTable extends SortableTable
         $this->odd_even_rows_enabled = false;
 
         // Admins get an edit column.
-        if (api_is_allowed_to_edit(null, true)) {
+        if ($this->teacherView) {
             $this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
             // Actions on multiple selected documents.
             $this->set_form_actions(array(
@@ -90,8 +104,14 @@ class GradebookTable extends SortableTable
                 )
             );
         } else {
-            if (empty($_GET['selectcat']) && !api_is_allowed_to_edit()) {
-                $this->set_header($column++, get_lang('Certificates'), false);
+            if (empty($_GET['selectcat']) && !$this->teacherView) {
+                if ($this->exportToPdf == false) {
+                    $this->set_header(
+                        $column++,
+                        get_lang('Certificates'),
+                        false
+                    );
+                }
             }
         }
     }
@@ -211,7 +231,7 @@ class GradebookTable extends SortableTable
             $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : '';
 
             // Id
-            if (api_is_allowed_to_edit(null, true)) {
+            if ($this->teacherView) {
                 if ($this->exportToPdf == false) {
                     $row[] = $this->build_id_column($item);
                 }
@@ -251,7 +271,7 @@ class GradebookTable extends SortableTable
                 true
             );
 
-            if (api_is_allowed_to_edit(null, true)) {
+            if ($this->teacherView) {
                 $row[] = $invisibility_span_open .Display::tag('h4', $weight).$invisibility_span_close;
             } else {
                 $row[] = $invisibility_span_open .$weight.$invisibility_span_close;
@@ -260,7 +280,7 @@ class GradebookTable extends SortableTable
             $category_weight = $item->get_weight();
             $mainCategoryWeight = $main_cat[0]->get_weight();
 
-            if (api_is_allowed_to_edit(null, true)) {
+            if ($this->teacherView) {
                 $weight_total_links += $data[3];
             } else {
                 $cattotal = Category::load($_GET['selectcat']);
@@ -269,7 +289,7 @@ class GradebookTable extends SortableTable
             }
 
             // Edit (for admins).
-            if (api_is_allowed_to_edit(null, true)) {
+            if ($this->teacherView) {
                 $cat = new Category();
                 $show_message = $cat->show_message_resource_delete($item->get_course_code());
                 if ($show_message === false) {
@@ -344,16 +364,15 @@ class GradebookTable extends SortableTable
 
             // Loading children
             if (get_class($item) == 'Category') {
-                $stud_id = api_get_user_id();
                 $course_code = api_get_course_id();
                 $session_id = api_get_session_id();
                 $parent_id = $item->get_id();
                 $cats = Category::load($parent_id, null, null, null, null, null);
 
                 if (isset($cats[0])) {
-                    $allcat  = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
-                    $alleval = $cats[0]->get_evaluations($stud_id);
-                    $alllink = $cats[0]->get_links($stud_id);
+                    $allcat  = $cats[0]->get_subcategories($this->userId, $course_code, $session_id);
+                    $alleval = $cats[0]->get_evaluations($this->userId);
+                    $alllink = $cats[0]->get_links($this->userId);
 
                     $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
                     $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
@@ -374,7 +393,7 @@ class GradebookTable extends SortableTable
                             $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
                         }
 
-                        if (api_is_allowed_to_edit(null, true)) {
+                        if ($this->teacherView) {
                             if ($this->exportToPdf == false) {
                                 $row[] = $this->build_id_column($item);
                             }
@@ -395,7 +414,7 @@ class GradebookTable extends SortableTable
                         // Weight
                         $row[] = $invisibility_span_open.$weight.$invisibility_span_close;
 
-                        if (api_is_allowed_to_edit(null, true)) {
+                        if ($this->teacherView) {
                             //$weight_total_links += intval($data[3]);
                         } else {
                             $cattotal = Category::load($_GET['selectcat']);
@@ -404,7 +423,7 @@ class GradebookTable extends SortableTable
                         }
 
                         // Admins get an edit column.
-                        if (api_is_allowed_to_edit(null, true)) {
+                        if ($this->teacherView) {
                             $cat = new Category();
                             $show_message = $cat->show_message_resource_delete($item->get_course_code());
                             if ($show_message === false) {
@@ -452,7 +471,7 @@ class GradebookTable extends SortableTable
 
                     // "Warning row"
                     if (!empty($data_array)) {
-                        if (api_is_allowed_to_edit()) {
+                        if ($this->teacherView) {
                             // Compare the category weight to the sum of all weights inside the category
                             if (intval($total_weight) == $category_weight) {
                                 $label = null;
@@ -484,7 +503,7 @@ class GradebookTable extends SortableTable
             }
         } //end looping categories
 
-        if (api_is_allowed_to_edit()) {
+        if ($this->teacherView) {
             // Total for teacher.
             if (count($main_cat) > 1) {
                 $main_weight = intval($main_cat[0]->get_weight());
@@ -573,7 +592,7 @@ class GradebookTable extends SortableTable
         // Warning messages
         $view = isset($_GET['view']) ? $_GET['view']: null;
 
-        if (api_is_allowed_to_edit()) {
+        if ($this->teacherView) {
             if (isset($_GET['selectcat']) &&
                 $_GET['selectcat'] > 0 &&
                 $view <> 'presence'

+ 47 - 16
main/inc/ajax/user_manager.ajax.php

@@ -9,25 +9,56 @@ $action = $_GET['a'];
 switch ($action) {
     case 'get_user_popup':
         $user_info = api_get_user_info($_REQUEST['user_id']);
+        $ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
 
         echo '<div class="well">';
-            echo '<div class="row">';
-            echo '<div class="span2">';
-            echo '<div class="thumbnail">';
-            echo '<img src="'.$user_info['avatar'].'" /> ';
-            echo '</div>';
-            echo '</div>';
-            echo '<div class="span3">';
-            if (api_get_setting('show_email_addresses') == 'false') {
-                $user_info['mail'] = ' ';
-            } else {
-                $user_info['mail'] = ' '.$user_info['mail'].' ';
-            }
-            echo '<h3>'.$user_info['complete_name'].'</h3>'.$user_info['mail'].$user_info['official_code'];
-            echo '<br/><br/><a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_info['user_id'].'">'.get_lang('ViewSharedProfile').'</a>';
-            echo '</div>';
-            echo '</div>';
+        echo '<div class="row">';
+        echo '<div class="span2">';
+        echo '<div class="thumbnail">';
+        echo '<img src="'.$user_info['avatar'].'" /> ';
+        echo '</div>';
+        echo '</div>';
+        echo '<div class="span3">';
+        if (api_get_setting('show_email_addresses') == 'false') {
+            $user_info['mail'] = ' ';
+        } else {
+            $user_info['mail'] = ' '.$user_info['mail'].' ';
+        }
+        echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_info['user_id'].'">';
+        echo '<h3>'.$user_info['complete_name'].'</h3>'.$user_info['mail'].$user_info['official_code'];
+        echo '</a>';
         echo '</div>';
+        echo '</div>';
+
+        if (api_get_setting('allow_message_tool') == 'true') {
+
+            echo '<script>';
+            echo '
+                $("#send_message_link").on("click", function() {
+                    var url = "'.$ajax_url.'?a=send_message&user_id='.$user_info['user_id'].'";
+                    var params = $("#send_message").serialize();
+                    $.ajax({
+                        url: url+"&"+params,
+                        success:function(data) {
+                            $("#subject_id").val("");
+                            $("#content_id").val("");
+                            $("#send_message").html(data);
+                            $("#send_message_link").hide();
+                        }
+                    });
+                });';
+
+            echo '</script>';
+            echo MessageManager::generate_message_form(
+                'send_message',
+                array(),
+                'block'
+            );
+
+            echo '<a class="btn btn-primary" id="send_message_link">'.
+                get_lang('Send').
+                '</a>';
+        }
         break;
     case 'user_id_exists':
         if (api_is_anonymous()) {

+ 1 - 1
main/inc/introductionSection.inc.php

@@ -292,7 +292,7 @@ if (api_is_allowed_to_edit()) {
 if ($intro_dispCommand) {
     if (empty($intro_content)) {
         // Displays "Add intro" commands
-        $toolbar =  '<div class="btn-group" rol="group">';
+        $toolbar =  '<div class="btn-group pull-right" rol="group">';
         if (!empty ($GLOBALS['_cid'])) {
             $toolbar .=  '<a class="btn btn-default" title="' . get_lang('AddIntro') . '" href="'.api_get_self().'?' . api_get_cidreq().'&amp;intro_cmdAdd=1">';
             $toolbar .=   '<i class="fa fa-file-text"></i> ';

+ 32 - 10
main/inc/lib/agenda.lib.php

@@ -135,8 +135,10 @@ class Agenda
         $start = api_get_utc_datetime($start);
         $end = api_get_utc_datetime($end);
         $allDay = isset($allDay) && $allDay == 'true' ? 1 : 0;
-
         $id = null;
+        $content = nl2br($content);
+        $eventComment = nl2br($eventComment);
+
         switch ($this->type) {
             case 'personal':
                 $attributes = array(
@@ -560,6 +562,8 @@ class Agenda
         $start = api_get_utc_datetime($start);
         $end = api_get_utc_datetime($end);
         $allDay = isset($allDay) && $allDay == 'true' ? 1 : 0;
+        $content = nl2br($content);
+        $comment = nl2br($comment);
 
         switch ($this->type) {
             case 'personal':
@@ -1247,8 +1251,8 @@ class Agenda
         if (empty($course_id)) {
             return array();
         }
-        $user_id = intval($user_id);
 
+        $user_id = intval($user_id);
         $groupList = GroupManager::get_group_list(null, $courseInfo['code']);
 
         $group_name_list = array();
@@ -1314,14 +1318,29 @@ class Agenda
                 if ($user_id == 0) {
                     $where_condition = "";
                 } else {
-                    $where_condition = " ( ip.to_user_id = ".$user_id. " OR ip.to_group_id='0' OR ip.to_group_id IS NULL ) AND ";
+                    $where_condition = " ( ip.to_user_id = ".$user_id. " OR (ip.to_group_id='0' OR ip.to_group_id IS NULL) ) AND ";
                 }
                 $visibilityCondition = " (ip.visibility IN ('1', '0')) AND ";
             } else {
-                $where_condition = " ( ip.to_user_id = $user_id OR ip.to_group_id='0' OR ip.to_group_id IS NULL) AND ";
+                $where_condition = " ( ip.to_user_id = $user_id OR (ip.to_group_id='0' OR ip.to_group_id IS NULL)) AND ";
             }
 
-            $sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref, to_user_id
+
+            $sessionCondition =  " agenda.session_id = $session_id AND
+                                   ip.session_id = $session_id ";
+            if (empty($session_id)) {
+                $sessionCondition =  "
+                (agenda.session_id = 0 OR agenda.session_id IS NULL) AND
+                (ip.session_id = 0 OR ip.session_id IS NULL) ";
+            }
+
+            $sql = "SELECT DISTINCT
+                        agenda.*,
+                        ip.visibility,
+                        ip.to_group_id,
+                        ip.insert_user_id,
+                        ip.ref,
+                        to_user_id
                     FROM $tlb_course_agenda agenda
                     INNER JOIN $tbl_property ip
                     ON (agenda.id = ip.ref AND agenda.c_id = ip.c_id)
@@ -1331,8 +1350,7 @@ class Agenda
                         $visibilityCondition
                         agenda.c_id = $course_id AND
                         ip.c_id = $course_id AND
-                        agenda.session_id = $session_id AND
-                        ip.session_id = $session_id
+                        $sessionCondition
                     ";
         }
 
@@ -1343,9 +1361,9 @@ class Agenda
                  agenda.start_date BETWEEN '".$start."' AND '".$end."' OR
                  agenda.end_date BETWEEN '".$start."' AND '".$end."' OR
                  (
-                 agenda.start_date <> '' AND agenda.end_date <> '' AND
-                 YEAR(agenda.start_date) = YEAR(agenda.end_date) AND
-                 MONTH('$start') BETWEEN MONTH(agenda.start_date) AND MONTH(agenda.end_date)
+                     agenda.start_date IS NOT NULL AND agenda.end_date IS NOT NULL AND
+                     YEAR(agenda.start_date) = YEAR(agenda.end_date) AND
+                     MONTH('$start') BETWEEN MONTH(agenda.start_date) AND MONTH(agenda.end_date)
                  )
             )";
         }
@@ -1743,6 +1761,10 @@ class Agenda
             $url = api_get_self().'?action='.$action.'&id='.$id.'&type='.$this->type;
         }
 
+        if (isset($params['content'])) {
+            $params['content'] = nl2br($params['content']);
+        }
+
         $form = new FormValidator(
             'add_event',
             'post',

+ 4 - 7
main/inc/lib/api.lib.php

@@ -1509,14 +1509,11 @@ function api_get_user_info(
         }
 
         if ($loadExtraData) {
-            $extraFieldValues = new ExtraFieldValue('user');
-            $values = $extraFieldValues->getAllValuesByItem($user_id);
+            $fieldValue = new ExtraFieldValue('user');
 
-            if (!empty($values)) {
-                foreach ($values as $value) {
-                    $result_array['extra'][$value['variable']] = $value['value'];
-                }
-            }
+            $result_array['extra'] = $fieldValue->getAllValuesForAnItem(
+                $user_id
+            );
         }
         $user = _api_format_user($result_array, $showPassword);
 

+ 1 - 1
main/inc/lib/course.lib.php

@@ -1829,7 +1829,7 @@ class CourseManager
                     $teacher['lastname']
                 );
                 if ($add_link_to_profile) {
-                    $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&resizable=0&height=300&user_id=' . $teacher['user_id'];
+                    $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&resizable=0&height=500&user_id=' . $teacher['user_id'];
                     $teacher_name = Display::url(
                         $teacher_name,
                         $url,

+ 6 - 0
main/inc/lib/message.lib.php

@@ -1425,6 +1425,12 @@ class MessageManager
         return $form->return_form();
     }
 
+    /**
+     * @param $id
+     * @param array $params
+     * @param string $display
+     * @return string
+     */
     public static function generate_invitation_form($id, $params = array())
     {
         $form = new FormValidator('send_invitation');

+ 57 - 7
main/inc/lib/pdf.lib.php

@@ -46,6 +46,7 @@ class PDF
         $this->params['add_signatures'] = isset($params['add_signatures']) ? $params['add_signatures'] : false;
         $this->params['show_real_course_teachers'] = isset($params['show_real_course_teachers']) ? $params['show_real_course_teachers'] : false;
         $this->params['student_info'] = isset($params['student_info']) ? $params['student_info'] : false;
+        $this->params['show_grade_generated_date'] = isset($params['show_grade_generated_date']) ? $params['show_grade_generated_date'] : false;
 
         $this->pdf = new mPDF(
             'UTF-8',
@@ -64,11 +65,16 @@ class PDF
 
     /**
      * Export the given HTML to PDF, using a global template
-     * @param string $content the HTML content
      *
      * @uses export/table_pdf.tpl
+
+     * @param $content
+     * @param bool|false $saveToFile
+     * @param bool|false $returnHtml
+     *
+     * @return string
      */
-    public function html_to_pdf_with_template($content)
+    public function html_to_pdf_with_template($content, $saveToFile = false, $returnHtml = false)
     {
         global $_configuration;
         Display :: display_no_header();
@@ -132,6 +138,8 @@ class PDF
         Display::$global_template->assign('pdf_date', api_format_date(api_get_local_time(), DATE_TIME_FORMAT_LONG));
         Display::$global_template->assign('pdf_teachers', $teacher_list);
         Display::$global_template->assign('pdf_title', $this->params['pdf_title']);
+        Display::$global_template->assign('pdf_student_info', $this->params['student_info']);
+        Display::$global_template->assign('show_grade_generated_date', $this->params['show_grade_generated_date']);
         Display::$global_template->assign('add_signatures', $this->params['add_signatures']);
 
         // Getting template
@@ -141,12 +149,21 @@ class PDF
 
         $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).'/print.css';
         $css = file_exists($css_file) ? @file_get_contents($css_file) : '';
-        self::content_to_pdf(
+
+        $html = self::content_to_pdf(
             $html,
             $css,
             $this->params['filename'],
-            $this->params['course_code']
+            $this->params['course_code'],
+            'D',
+            $saveToFile,
+            null,
+            $returnHtml
         );
+
+        if ($returnHtml) {
+            return $html;
+        }
     }
 
     /**
@@ -170,7 +187,8 @@ class PDF
         $pdf_name = '',
         $course_code = null,
         $print_title = false,
-        $complete_style = true
+        $complete_style = true,
+        $addStyle = true
     ) {
         if ($complete_style === false) {
             error_log(__FUNCTION__.' with no style');
@@ -242,6 +260,13 @@ class PDF
                 continue;
             }
 
+            if ($addStyle) {
+                $css_file = api_get_path(TO_SYS, WEB_CSS_PATH).'/print.css';
+                $css = file_exists($css_file) ? @file_get_contents($css_file) : '';
+
+                $this->pdf->WriteHTML($css, 1);
+            }
+
             //it's not a chapter but the file exists, print its title
             if ($print_title) {
                 $this->pdf->WriteHTML(
@@ -363,7 +388,10 @@ class PDF
         $css = '',
         $pdf_name = '',
         $course_code = null,
-        $outputMode = 'D'
+        $outputMode = 'D',
+        $saveInFile = false,
+        $fileToSave = null,
+        $returnHtml = false
     ) {
         global $_configuration;
 
@@ -434,6 +462,10 @@ class PDF
         // $_GET[] too, as it is done with file name.
         // At the moment the title is retrieved from the html document itself.
 
+        if ($returnHtml) {
+            return "<style>$css</style>".$document_html;
+        }
+
         if (!empty($css)) {
             $this->pdf->WriteHTML($css, 1);
         }
@@ -445,7 +477,25 @@ class PDF
             $pdf_name = api_replace_dangerous_char($pdf_name);
             $output_file = $pdf_name.'.pdf';
         }
-        $this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file
+        //$this->pdf->Output($output_file, $outputMode); // F to save the pdf in a file
+
+        if ($saveInFile) {
+            $fileToSave = !empty($fileToSave) ? $fileToSave : api_get_path(SYS_ARCHIVE_PATH).uniqid();
+
+            $this->pdf->Output(
+                $fileToSave,
+                $outputMode
+            ); // F to save the pdf in a file
+
+        } else {
+            $this->pdf->Output(
+                $output_file,
+                $outputMode
+            ); // F to save the pdf in a file
+            exit;
+        }
+
+
         if ($outputMode == 'F') {
             // Do NOT exit when export to file
         } else {

+ 60 - 18
main/inc/lib/social.lib.php

@@ -548,38 +548,50 @@ class SocialManager extends UserManager
             'browse_groups'
         );
 
-        $html = '<div class="avatar-profile">';
+        $template = new Template(null, false, false, false, false, false);
+
         if (in_array($show, $show_groups) && !empty($group_id)) {
             // Group image
             $userGroup = new UserGroup();
             $group_info = $userGroup->get($group_id);
 
-            $big = $userGroup->get_picture_group(
+            $userGroupImage = $userGroup->get_picture_group(
                 $group_id,
                 $group_info['picture'],
                 160,
                 GROUP_IMAGE_SIZE_BIG
             );
 
-            $html .= Display::url(
-                '<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />',
-                api_get_path(WEB_CODE_PATH).'social/group_view.php?id='.$group_id
+            $template->assign('show_group', true);
+            $template->assign('group_id', $group_id);
+            $template->assign('user_group_image', $userGroupImage);
+            $template->assign(
+                'user_is_group_admin',
+                $userGroup->is_group_admin(
+                    $group_id,
+                    api_get_user_id()
+                )
             );
-
-            if ($userGroup->is_group_admin($group_id, api_get_user_id())) {
-                $html .= '<div id="edit_image">
-                            <a href="'.api_get_path(WEB_CODE_PATH).'social/group_edit.php?id='.$group_id.'">'.
-                    get_lang('EditGroup').'</a></div>';
-            }
         } else {
-            $big_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_BIG);
-            $normal_image = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL);
-
-            $html .= '<a class="expand-image" href="'.$big_image.'"><img class="img-responsive" src='.$normal_image.' /> </a>';
+            $template->assign('show_user', true);
+            $template->assign(
+                'user_image',
+                [
+                    'big' => UserManager::getUserPicture(
+                        $user_id,
+                        USER_IMAGE_SIZE_BIG
+                    ),
+                    'normal' => UserManager::getUserPicture(
+                        $user_id,
+                        USER_IMAGE_SIZE_ORIGINAL
+                    )
+                ]
+            );
         }
-        $html .= '</div>';
 
-        return $html;
+        $skillBlock = $template->get_template('social/avatar_block.tpl');
+
+        return $template->fetch($skillBlock);
     }
 
     /**
@@ -1487,7 +1499,7 @@ class SocialManager extends UserManager
             $profileEditionLink = Display::getProfileEditionLink($userId);
         }
 
-        $userInfo = api_get_user_info($userId, true);
+        $userInfo = api_get_user_info($userId, true, false, true);
         $template->assign('user', $userInfo);
         $template->assign('socialAvatarBlock', $socialAvatarBlock);
         $template->assign('profileEditionLink', $profileEditionLink);
@@ -1603,4 +1615,34 @@ class SocialManager extends UserManager
 
         return $html;
     }
+
+    /**
+     * Get HTML code block for user skills
+     * @param int $userId The user ID
+     * @return string
+     */
+    public static function getSkillBlock($userId)
+    {
+        if (api_get_setting('allow_skills_tool') !== 'true') {
+            return null;
+        }
+
+        $skill = new Skill();
+
+        $ranking = $skill->get_user_skill_ranking($userId);
+        $skills = $skill->get_user_skills($userId, true);
+
+        $template = new Template(null, false, false, false, false, false);
+        $template->assign('ranking', $ranking);
+        $template->assign('skills', $skills);
+        $template->assign(
+            'show_skills_report_link',
+            api_is_student() || api_is_student_boss() || api_is_drh()
+        );
+
+        $skillBlock = $template->get_template('social/skills_block.tpl');
+
+        return $template->fetch($skillBlock);
+    }
+
 }

+ 6 - 4
main/inc/lib/usermanager.lib.php

@@ -2481,7 +2481,8 @@ class UserManager
 
         if (api_is_allowed_to_create_course()) {
             $sessionListFromCourseCoach = array();
-            $sql =" SELECT DISTINCT session_id FROM $tbl_session_course_user
+            $sql =" SELECT DISTINCT session_id
+                    FROM $tbl_session_course_user
                     WHERE user_id = $user_id AND status = 2 ";
 
             $result = Database::query($sql);
@@ -2493,7 +2494,7 @@ class UserManager
             }
             if (!empty($sessionListFromCourseCoach)) {
                 $condition = implode("','", $sessionListFromCourseCoach);
-                $coachCourseConditions = " OR ( id IN ('$condition'))";
+                $coachCourseConditions = " OR ( s.id IN ('$condition'))";
             }
         }
 
@@ -2517,8 +2518,9 @@ class UserManager
             }
         }
 
-        $sql = "SELECT DISTINCT id, name, access_start_date, access_end_date
-                FROM $tbl_session
+        $sql = "SELECT DISTINCT
+                id, name, access_start_date, access_end_date
+                FROM $tbl_session s
                 WHERE (
                     id_coach = $user_id
                 )

+ 6 - 1
main/session/about.php

@@ -6,8 +6,8 @@
  * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  * @package chamilo.session
  */
-use Chamilo\CourseBundle\Entity\CCourseDescription;
 use Chamilo\CoreBundle\Entity\ExtraField;
+use Chamilo\CourseBundle\Entity\CCourseDescription;
 
 $cidReset = true;
 
@@ -19,6 +19,10 @@ $entityManager = Database::getManager();
 
 $session = $entityManager->find('ChamiloCoreBundle:Session', $sessionId);
 
+if (!$session) {
+    api_not_allowed(true);
+}
+
 $sessionCourses = $entityManager->getRepository('ChamiloCoreBundle:Session')
     ->getCoursesOrderedByPosition($session);
 
@@ -119,6 +123,7 @@ $template->assign(
         api_get_user_id()
     )
 );
+
 $template->assign('courses', $courses);
 $template->assign('essence', \Essence\Essence::instance());
 $template->assign(

+ 1 - 82
main/social/home.php

@@ -80,87 +80,6 @@ if (api_get_setting('profile', 'picture') == 'true') {
 $social_menu_block = SocialManager::show_social_menu('home');
 $social_search_block = Display::panel(UserManager::get_search_form(''), get_lang("SearchUsers"));
 
-//BLock Social Skill
-$social_skill_block = '';
-
-if (api_get_setting('allow_skills_tool') == 'true') {
-    $skill = new Skill();
-
-    $ranking = $skill->get_user_skill_ranking(api_get_user_id());
-    $skills = $skill->get_user_skills(api_get_user_id(), true);
-
-    $extra = '<div class="btn-group pull-right">
-                <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
-                <span class="caret"></span></a>
-                 <ul class="dropdown-menu">';
-    if (api_is_student() || api_is_student_boss() || api_is_drh()) {
-        $extra .= '<li>' . Display::url(
-            get_lang('SkillsReport'),
-            api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
-            ) . '</li>';
-    }
-
-    $extra.= '<li>' . Display::url(
-        get_lang('SkillsWheel'),
-        api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
-        ) . '</li>';
-
-    $extra .= '<li>' . Display::url(
-        sprintf(get_lang('YourSkillRankingX'), $ranking),
-        api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
-    ) . '</li>';
-
-    $extra .= '</ul></div>';
-
-    $social_skill_block = Display::panel(
-        null,
-        get_lang('Skills'),
-        null,
-        null,
-        $extra
-    );
-
-    $lis = '';
-    if (!empty($skills)) {
-        foreach ($skills as $skill) {
-            $badgeImage = null;
-
-            if (!empty($skill['icon'])) {
-                $badgeImage = Display::img(
-                    $skill['web_icon_thumb_path'],
-                    $skill['name']
-                );
-            } else {
-                $badgeImage = Display::return_icon(
-                    'badges-default.png',
-                    $skill['name'],
-                    array('title' => $skill['name']), ICON_SIZE_BIG
-                );
-            }
-
-            $lis .= Display::tag(
-                'li',
-                $badgeImage .
-                '<div class="badges-name">' . $skill['name'] . '</div>'
-            );
-        }
-        $content = Display::tag('ul', $lis, array('class' => 'list-badges'));
-        $social_skill_block = Display::panel(
-            $content,
-            get_lang('Skills'),
-            null,
-            null,
-            $extra
-        );
-
-    } else {
-        $social_skill_block .= Display::panel(
-            Display::url(get_lang('SkillsWheel'), api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'),
-            get_lang('WithoutAchievedSkills')
-        );
-    }
-}
-
 $results = $userGroup->get_groups_by_age(1, false);
 
 $groups_newest = array();
@@ -277,7 +196,7 @@ SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
 
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_search_block', $social_search_block);
-$tpl->assign('social_skill_block', $social_skill_block);
+$tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id));
 $tpl->assign('social_group_block', $social_group_block);
 $social_layout = $tpl->get_template('social/home.tpl');
 $tpl->display($social_layout);

+ 1 - 70
main/social/profile.php

@@ -34,7 +34,6 @@ $social_extra_info_block = null;
 $social_course_block = null;
 $social_group_info_block = null;
 $social_rss_block = null;
-$social_skill_block = null;
 $social_session_block = null;
 
 if (!empty($_POST['social_wall_new_msg_main']) || !empty($_FILES['picture']['tmp_name'])) {
@@ -501,74 +500,6 @@ if ($show_full_profile) {
         $social_rss_block = Display::panel($user_feeds, get_lang('RSSFeeds'));
     }
 
-    //BLock Social Skill
-    if (api_get_setting('allow_skills_tool') == 'true') {
-        $skill = new Skill();
-
-        $ranking = $skill->get_user_skill_ranking($my_user_id);
-        $skills = $skill->get_user_skills($my_user_id, true);
-
-        $social_skill_block = '<div class="panel panel-default social-skill">';
-        $social_skill_block .= '<div class="panel-heading">' . get_lang('Skills');
-        $social_skill_block .= '<div class="btn-group pull-right"> <a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
-                            <span class="caret"></span></a>
-                             <ul class="dropdown-menu">';
-        if (api_is_student() || api_is_student_boss() || api_is_drh()) {
-            $social_skill_block .= '<li>' . Display::url(
-                    get_lang('SkillsReport'),
-                    api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php'
-                ) . '</li>';
-        }
-
-        $social_skill_block .= '<li>' . Display::url(
-                get_lang('SkillsWheel'),
-                api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php'
-            ) . '</li>';
-
-        $social_skill_block .= '<li>' . Display::url(
-                sprintf(get_lang('YourSkillRankingX'), $ranking),
-                api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php'
-            ) . '</li>';
-
-        $social_skill_block .= '</ul></div></div>';
-
-        $lis = '';
-        if (!empty($skills)) {
-            foreach ($skills as $skill) {
-                $badgeImage = null;
-
-                if (!empty($skill['icon'])) {
-                    $badgeImage = Display::img(
-                        api_get_path(WEB_DATA_PATH) . $skill['icon'],
-                        $skill['name']
-                    );
-                } else {
-                    $badgeImage = Display::return_icon(
-                        'badges-default.png',
-                        $skill['name'],
-                        array('title' => $skill['name']),ICON_SIZE_BIG
-                    );
-                }
-
-                $lis .= Display::tag(
-                    'li',
-                    $badgeImage .
-                    '<div class="badges-name">' . $skill['name'] . '</div>'
-                );
-            }
-            $social_skill_block .= '<div class="panel-body">';
-            $social_skill_block .= Display::tag('ul', $lis, array('class' => 'list-badges'));
-            $social_skill_block .= '</div>';
-        } else {
-
-            $social_skill_block .= '<div class="panel-body">';
-            $social_skill_block .= '<p>'. get_lang("WithoutAchievedSkills") . '</p>';
-            $social_skill_block .= '<p>' . Display::url(get_lang('SkillsWheel'),api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php').'</p>';
-            $social_skill_block .= '</div>';
-        }
-        $social_skill_block.='</div>';
-    }
-
     // Productions
     $production_list =  UserManager::build_production_list($user_id);
 
@@ -691,7 +622,7 @@ $tpl->assign('social_extra_info_block', $social_extra_info_block);
 $tpl->assign('social_course_block', $social_course_block);
 $tpl->assign('social_group_info_block', $social_group_info_block);
 $tpl->assign('social_rss_block', $social_rss_block);
-$tpl->assign('social_skill_block', $social_skill_block);
+$tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id));
 $tpl->assign('social_session_block', $social_session_block);
 $tpl->assign('social_right_information', $socialRightInformation);
 $tpl->assign('social_auto_extend_link', $socialAutoExtendLink);

+ 7 - 0
main/template/default/export/table_pdf.tpl

@@ -63,6 +63,13 @@
     </tr>
 </table>
 
+
+{% if show_grade_generated_date == true %}
+    <h5 align="right">
+        {{ "GradeGenerated" | get_lang }} {{ "now"|date("d/m/Y") }}
+    </h5>
+{% endif %}
+
 <br />
 
 {{ pdf_content }}

+ 19 - 0
main/template/default/social/avatar_block.tpl

@@ -0,0 +1,19 @@
+<div class="avatar-profile">
+    {% if show_group %}
+        <a href="{{ _p.web_main ~ 'social/group_view.php?id=' ~ group_id }}">
+            <img src="{{ user_group_image.file }}" class="social-groups-image">
+        </a>
+
+        {% if user_is_group_admin %}
+            <div id="edit_image">
+                <a href="{{ _p.web_main ~ 'social/group_edit.php?id=' ~ group_id }}">
+                    {{ 'EditGroup'|get_lang }}
+                </a>
+            </div>
+        {% endif %}
+    {% elseif show_user %}
+        <a href="{{ user_image.big }}" class="expand-image">
+            <img class="img-responsive" src="{{ user_image.normal }}">
+        </a>
+    {% endif %}
+</div>

+ 41 - 0
main/template/default/social/skills_block.tpl

@@ -0,0 +1,41 @@
+<div class="panel panel-default social-skill">
+    <div class="panel-heading">
+        {{ 'Skills'|get_lang }}
+        <div class="btn-group pull-right">
+            <a class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" href="#">
+                <span class="caret"></span>
+            </a>
+            <ul class="dropdown-menu">
+                {% if show_skills_report_link %}
+                    <li>
+                        <a href="{{ _p.web_main ~ 'social/my_skills_report.php' }}"> {{'SkillsReport'|get_lang }}</a>
+                    </li>
+                {% endif %}
+
+                <li>
+                    <a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}"> {{ 'SkillsWheel'|get_lang }}</a>
+                </li>
+                <li>
+                    <a href="{{ _p.web_main ~ 'social/skills_ranking.php' }}"> {{ 'YourSkillRankingX'|get_lang|format(ranking) }}</a>
+                </li>
+            </ul>
+        </div>
+    </div>
+    <div class="panel-body">
+        {% if skills %}
+            <ul class="list-badges">
+                {% for skill in skills %}
+                    <li>
+                        <img title="{{ skill.name }}" src="{{ skill.icon ? skill.web_icon_thumb_path : 'badges-default.png'|icon(64) }}" alt="{{ skill.name }}">
+                        <div class="badges-name">{{ skill.name }}</div>
+                    </li>
+                {% endfor %}
+            </ul>
+        {% else %}
+            <p>{{ 'WithoutAchievedSkills'|get_lang }}</p>
+            <p>
+                <a href="{{ _p.web_main ~ 'social/skills_wheel.php' }}">{{ 'SkillsWheel'|get_lang }}</a>
+            </p>
+        {% endif %}
+    </div>
+</div>

+ 6 - 0
main/work/work.lib.php

@@ -1345,6 +1345,9 @@ function getWorkListStudent(
     if (!in_array($direction, array('asc','desc'))) {
         $direction = 'desc';
     }
+    if (!empty($where_condition)) {
+        $where_condition = ' AND ' . $where_condition;
+    }
 
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
     $start = intval($start);
@@ -1483,6 +1486,9 @@ function getWorkListTeacher(
     if (!in_array($direction, array('asc', 'desc'))) {
         $direction = 'desc';
     }
+    if (!empty($where_condition)) {
+        $where_condition = ' AND ' . $where_condition;
+    }
 
     $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
     $start = intval($start);

+ 4 - 1
plugin/advanced_subscription/src/admin_view.php

@@ -68,7 +68,10 @@ if (!empty($sessionId)) {
         $studentId = intval($student['user_id']);
         $data['studentUserId'] = $studentId;
 
-        $student['area'] = api_get_user_info($studentId, false, false, true)['extra']['area'];
+        $fieldValue = new ExtraFieldValue('user');
+        $areaField = $foo->get_values_by_handler_and_field_variable($studentId, 'area', true);
+
+        $student['area'] = $areaField['value'];
         $student['userLink'] = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$studentId;
         $data['queueId'] = intval($student['queue_id']);
         $data['newStatus'] = ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED;