Browse Source

Add "mail_header_style" setting, avoid doubled return_logo function call

jmontoyaa 8 years ago
parent
commit
989a7cfe05

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

@@ -2992,15 +2992,16 @@ function api_is_allowed_to_session_edit($tutor = false, $coach = false)
         // If I'm a teacher, I will return true in order to not affect the normal behaviour of Chamilo tools.
         return true;
     } else {
-        if (api_get_session_id() == 0) {
+        $sessionId = api_get_session_id();
+
+        if ($sessionId == 0) {
             // I'm not in a session so i will return true to not affect the normal behaviour of Chamilo tools.
             return true;
         } else {
             // I'm in a session and I'm a student
-            $session_id = api_get_session_id();
 
             // Get the session visibility
-            $session_visibility = api_get_session_visibility($session_id);
+            $session_visibility = api_get_session_visibility($sessionId);
             // if 5 the session is still available
 
             //@todo We could load the session_rel_course_rel_user permission to increase the level of detail.
@@ -7770,7 +7771,10 @@ function api_mail_html(
     if (isset($additionalParameters['link'])) {
         $mailView->assign('link', $additionalParameters['link']);
     }
-
+    $mailView->assign(
+        'mail_header_style',
+        api_get_configuration_value('mail_header_style')
+    );
     $layout = $mailView->get_template('mail/mail.tpl');
     $mail->Body = $mailView->fetch($layout);
 
@@ -7996,3 +8000,54 @@ function api_remove_uploaded_file($type, $file)
         unlink($path);
     }
 }
+
+/**
+ * Converts values to float value
+ *
+ * 3.141516 => 3.141516
+ * 3,141516 => 3.141516
+ * @todo WIP
+ *
+ * @param $number
+ * @return false|float|int|mixed
+ */
+function api_parse_float_val($number)
+{
+    if (INTL_INSTALLED) {
+        $iso = api_get_language_isocode();
+        $iso = 'fr';
+        $formatter = new NumberFormatter($iso, NumberFormatter::DECIMAL);
+
+        return $formatter->parse($number);
+    } else {
+        return floatval($number);
+    }
+}
+
+/**
+ * Converts float values
+ * Example if $decimals = 2
+ *
+ * 3.141516 => 3.14
+ * 3,141516 => 3,14
+ *
+ * @todo WIP
+ *
+ * @param string $number number in iso code
+ * @param int $decimals
+ * @return bool|string
+ */
+function api_number_format($number, $decimals = 0)
+{
+    if (INTL_INSTALLED) {
+        $iso = api_get_language_isocode();
+        $iso = 'fr';
+        $formatter = new NumberFormatter($iso, NumberFormatter::DECIMAL);
+        $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
+        $formatter->setAttribute(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
+
+        return $formatter->format($number);
+    } else {
+        return number_format($number, $decimals);
+    }
+}

+ 1 - 2
main/inc/lib/banner.lib.php

@@ -172,9 +172,8 @@ function getCustomTabs()
  * Return the active logo of the portal, based on a series of settings
  * @param string $theme The name of the theme folder from web/css/themes/
  * @return string HTML string with logo as an HTML element
- * @param string $theme
  */
-function return_logo($theme)
+function return_logo()
 {
     $siteName = api_get_setting('siteName');
 

+ 1 - 6
main/inc/lib/template.lib.php

@@ -126,7 +126,6 @@ class Template
         $this->twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
         $this->twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
         $this->twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
-        $this->twig->addFilter('return_logo', new Twig_Filter_Function('return_logo'));
         $this->twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
         $this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
         $this->twig->addFilter(
@@ -176,8 +175,6 @@ class Template
 
         $this->assign('template', $this->templateFolder);
         $this->assign('locale', api_get_language_isocode());
-
-        $this->assign('css_styles', $this->theme);
         $this->assign('login_class', null);
 
         $this->setLoginForm();
@@ -185,7 +182,6 @@ class Template
         // Chamilo plugins
         if ($this->show_header) {
             if ($this->load_plugins) {
-
                 $this->plugin = new AppPlugin();
 
                 //1. Showing installed plugins in regions
@@ -649,9 +645,8 @@ class Template
         }
 
         // Logo
-        $logo = return_logo($this->theme);
+        $logo = return_logo();
         $this->assign('logo', $logo);
-
         $this->assign('show_media_element', 1);
     }
 

+ 2 - 0
main/install/configuration.dist.php

@@ -265,6 +265,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 //$_configuration['send_score_in_exam_notification_mail_to_manager'] = false;
 // Show blocked LPs by prerequisite to students
 //$_configuration['show_prerequisite_as_blocked'] = false;
+// Mail header extra HTML attributes
+//$_configuration['mail_header_style'] = '';
 
 
 

+ 3 - 4
main/template/default/mail/header.tpl

@@ -1,10 +1,9 @@
 <table border="0" cellpadding="10" cellspacing="0" width="100%">
     <tr>
-        <td width="245" class="mail_header_container">
-            {{ css_styles | return_logo }}
+        <td width="245" {{ mail_header_style }}>
+            {{ logo }}
         </td>
-        <td width="100%">
-            &nbsp;
+        <td width="100%">            &nbsp;
         </td>
     </tr>
 </table>

+ 1 - 1
main/template/default/mail/mail.tpl

@@ -11,7 +11,7 @@
           "description":    "Chamilo Mail Notification",
           "potentialAction": {
             "@type": "ViewAction",
-            "target":   "{{ link }}"
+            "target": "{{ link }}"
           }
         }
     </script>