Browse Source

see #4554: move shibboleth classes to their namespace, remove redirect bug, remove conf

Laurent Opprecht 12 năm trước cách đây
mục cha
commit
c6fbaa3ad7
35 tập tin đã thay đổi với 479 bổ sung426 xóa
  1. 0 1
      main/auth/shibboleth/_readme.txt
  2. 6 1
      main/auth/shibboleth/app/controller/shibboleth_controller.class.php
  3. 2 0
      main/auth/shibboleth/app/model/admin.class.php
  4. 4 1
      main/auth/shibboleth/app/model/scaffold/admin.class.php
  5. 4 1
      main/auth/shibboleth/app/model/scaffold/user.class.php
  6. 2 0
      main/auth/shibboleth/app/model/shibboleth_store.class.php
  7. 2 0
      main/auth/shibboleth/app/model/shibboleth_user.class.php
  8. 2 0
      main/auth/shibboleth/app/model/user.class.php
  9. 39 55
      main/auth/shibboleth/app/shibboleth.class.php
  10. 2 0
      main/auth/shibboleth/app/view/admin_login.php
  11. 2 0
      main/auth/shibboleth/app/view/request.php
  12. 4 0
      main/auth/shibboleth/app/view/shibboleth_display.class.php
  13. 2 0
      main/auth/shibboleth/app/view/shibboleth_email_form.class.php
  14. 2 0
      main/auth/shibboleth/app/view/shibboleth_status_request_form.class.php
  15. 2 0
      main/auth/shibboleth/config-dist.php
  16. 0 11
      main/auth/shibboleth/config.php
  17. 4 2
      main/auth/shibboleth/config/aai.class.php
  18. 4 0
      main/auth/shibboleth/db/shibboleth_upgrade.class.php
  19. 14 12
      main/auth/shibboleth/init.php
  20. 2 0
      main/auth/shibboleth/lib/model.class.php
  21. 2 0
      main/auth/shibboleth/lib/scaffolder/scaffolder.class.php
  22. 2 0
      main/auth/shibboleth/lib/scaffolder/template/default.php
  23. 2 0
      main/auth/shibboleth/lib/scaffolder/template/model.php
  24. 2 0
      main/auth/shibboleth/lib/scaffolder/template/public.php
  25. 2 0
      main/auth/shibboleth/lib/shibboleth_config.class.php
  26. 5 0
      main/auth/shibboleth/lib/shibboleth_session.class.php
  27. 4 0
      main/auth/shibboleth/lib/store.class.php
  28. 3 1
      main/auth/shibboleth/login.php
  29. 0 0
      main/auth/shibboleth/script/output/user.class.php
  30. 2 0
      main/auth/shibboleth/script/scaffold.php
  31. 7 5
      main/auth/shibboleth/test/shibboleth_test.class.php
  32. 2 0
      main/auth/shibboleth/test/shibboleth_test_helper.class.php
  33. 2 0
      main/auth/shibboleth/test/test.php
  34. 2 0
      main/auth/shibboleth/test/test_no_email.php
  35. 343 336
      main/template/default/agenda/month.tpl

+ 0 - 1
main/auth/shibboleth/_readme.txt

@@ -8,4 +8,3 @@ with a web server security directive.
 
 Modify configuration to your federation's needs.
 
-Add a login url/redirection to chamilo/main/auth/login.php.

+ 6 - 1
main/auth/shibboleth/app/controller/shibboleth_controller.class.php

@@ -1,5 +1,10 @@
 <?php
 
+namespace Shibboleth;
+
+use \Redirect;
+use \Display;
+
 /**
  * Controller for the Shibboleth authentication system. 
  *
@@ -64,7 +69,7 @@ class ShibbolethController
 
         if ($is_new_user && $user->status_request)
         {
-            Shibboleth::redirect('main/auth/shibboleth/app/view/request.php');
+            Shibboleth::redirect('/main/auth/shibboleth/app/view/request.php');
         }
         else
         {

+ 2 - 0
main/auth/shibboleth/app/model/admin.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 require_once dirname(__FILE__) . '/scaffold/admin.class.php';
 
 /**

+ 4 - 1
main/auth/shibboleth/app/model/scaffold/admin.class.php

@@ -1,4 +1,7 @@
 <?php
+
+namespace Shibboleth;
+
 /**
  * This file is autogenerated. Do not modifiy it.
  */
@@ -77,7 +80,7 @@ class _AdminStore extends Store
     
     public function __construct()
     {
-        parent::__construct('admin', 'Admin', 'user_id');
+        parent::__construct('admin', '\Shibboleth\Admin', 'user_id');
     }
     
     /**

+ 4 - 1
main/auth/shibboleth/app/model/scaffold/user.class.php

@@ -1,4 +1,7 @@
 <?php
+
+namespace Shibboleth;
+
 /**
  * This file is autogenerated. Do not modifiy it.
  */
@@ -105,7 +108,7 @@ class _UserStore extends Store
     
     public function __construct()
     {
-        parent::__construct('user', 'User', 'user_id');
+        parent::__construct('user', '\Shibboleth\User', 'user_id');
     }
     
     /**

+ 2 - 0
main/auth/shibboleth/app/model/shibboleth_store.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Returns Shibboleth user's values based on Shibboleth's configuration.
  * Shibboleth returns not only whether a user is authenticated but returns as

+ 2 - 0
main/auth/shibboleth/app/model/shibboleth_user.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Represent a Shibboleth user. Not to be missunderstand with a Chamilo user
  * since they don't have the same attributes.

+ 2 - 0
main/auth/shibboleth/app/model/user.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 require_once dirname(__FILE__) . '/scaffold/user.class.php';
 
 /**

+ 39 - 55
main/auth/shibboleth/app/shibboleth.class.php

@@ -1,5 +1,9 @@
 <?php
 
+namespace Shibboleth;
+
+use \Redirect;
+
 /**
  * Shibboleth main class. Provides access to various Shibboleth sub components and
  * provides the high level functionalities.
@@ -19,20 +23,13 @@ class Shibboleth
 
     public static function format_status($status)
     {
-        if ($status == Shibboleth::TEACHER_STATUS)
-        {
+        if ($status == Shibboleth::TEACHER_STATUS) {
             return 'Teacher';
-        }
-        else if ($status == Shibboleth::STUDENT_STATUS)
-        {
+        } else if ($status == Shibboleth::STUDENT_STATUS) {
             return 'Student';
-        }
-        else if ($status == Shibboleth::UNKNOWN_STATUS)
-        {
+        } else if ($status == Shibboleth::UNKNOWN_STATUS) {
             return 'Unknown';
-        }
-        else
-        {
+        } else {
             return '???';
         }
     }
@@ -94,8 +91,7 @@ class Shibboleth
 
     public static function redirect($url = '')
     {
-        if (empty($url))
-        {
+        if (empty($url)) {
             $url = isset($_SESSION['shibb_direct_url']) ? $_SESSION['shibb_direct_url'] : '';
             unset($_SESSION['shibb_direct_url']);
 
@@ -111,25 +107,23 @@ class Shibboleth
              *       If any interest or question, please contact Nicolas.Rod_at_adm.unige.ch
              *
              */
-            if ($url)
-            {
-                //needed to log the user in his courses. Normally it is done by visiting /chamilo/index.php    
-                $include_path = api_get_path(INCLUDE_PATH);
-                require("$include_path/local.inc.php");
-
-                if (strpos($url, '?') === false)
-                {
-                    $url = "$url?";
-                }
-
-                $rootWeb = api_get_path('WEB_PATH');
-                $first_slash_pos = strpos($rootWeb, '/', 8);
-                $rootWeb_wo_uri = substr($rootWeb, 0, $first_slash_pos);
-                $url = $rootWeb_wo_uri . $course_url . '_stop';
-                Redirect::go($url);
-            }
         }
-        Redirect::go();
+        if ($url) {
+            //needed to log the user in his courses. Normally it is done by visiting /chamilo/index.php    
+//            $include_path = api_get_path(INCLUDE_PATH);
+//            require("$include_path/local.inc.php");
+//
+//            if (strpos($url, '?') === false) {
+//                $url = "$url?";
+//            }
+//
+//            $rootWeb = api_get_path('WEB_PATH');
+//            $first_slash_pos = strpos($rootWeb, '/', 8);
+//            $rootWeb_wo_uri = substr($rootWeb, 0, $first_slash_pos);
+//            $url = $rootWeb_wo_uri . $course_url . '_stop';
+            Redirect::go($url);
+        }
+        Redirect::home();
     }
 
     /**
@@ -144,22 +138,21 @@ class Shibboleth
         $shibb_user->shibb_persistent_id = $shibb_user->persistent_id;
 
         $user = User::store()->get_by_shibboleth_id($shibb_user->unique_id);
-        if (empty($user))
-        {
+        if (empty($user)) {
             $shibb_user->auth_source == self::NAME;
             return User::create($shibb_user)->save();
         }
 
         $shibb_user->status_request = false;
         $fields = self::config()->update_fields;
-        foreach ($fields as $key => $updatable)
-        {
-            if ($updatable)
-            {
+        foreach ($fields as $key => $updatable) {
+            if ($updatable) {
                 $user->{$key} = $shibb_user->{$key};
             }
             $user->auth_source == self::NAME;
         }
+        $user->shibb_unique_id = $user->unique_id;
+        $user->shibb_persistent_id = $user->persistent_id;
         $user->save();
         return $result;
     }
@@ -178,11 +171,9 @@ class Shibboleth
         $map = self::config()->affiliation_status;
 
         $rights = array();
-        foreach ($affiliations as $affiliation)
-        {
+        foreach ($affiliations as $affiliation) {
             $affiliation = strtolower($affiliation);
-            if (isset($map[$affiliation]))
-            {
+            if (isset($map[$affiliation])) {
                 $right = $map[$affiliation];
                 $rights[$right] = $right;
             }
@@ -192,13 +183,11 @@ class Shibboleth
         $student_status = isset($rights[self::STUDENT_STATUS]);
 
         //if the user has got teacher rights, we doesn't check anything else
-        if ($teacher_status)
-        {
+        if ($teacher_status) {
             return self::TEACHER_STATUS;
         }
 
-        if ($student_status)
-        {
+        if ($student_status) {
             return self::STUDENT_STATUS;
         }
 
@@ -217,23 +206,19 @@ class Shibboleth
      */
     public static function infer_status_request($user)
     {
-        if ($user->status == self::TEACHER_STATUS)
-        {
+        if ($user->status == self::TEACHER_STATUS) {
             return false;
         }
-        if ($user->status == self::UNKNOWN_STATUS)
-        {
+        if ($user->status == self::UNKNOWN_STATUS) {
             return true;
         }
 
         $config = Shibboleth::config();
         $affiliations = $user->affiliation;
         $affiliations = is_array($affiliations) ? $affiliations : array($affiliations);
-        foreach ($affiliations as $affiliation)
-        {
+        foreach ($affiliations as $affiliation) {
             $result = isset($config->affiliation_status_request[$affiliation]) ? $config->affiliation_status_request[$affiliation] : false;
-            if ($result)
-            {
+            if ($result) {
                 return true;
             }
         }
@@ -268,8 +253,7 @@ EOT;
         $header = "From: $email \n";
 
         $shibb_admin_email = Shibboleth::config()->admnistrator_email;
-        if ($shibb_admin_email)
-        {
+        if ($shibb_admin_email) {
             $header .= "Cc: $shibb_admin_email";
         }
 

+ 2 - 0
main/auth/shibboleth/app/view/admin_login.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Administratrive login. Useful when the standard login is not available anymore
  * which is usually the case. 

+ 2 - 0
main/auth/shibboleth/app/view/request.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Display the Request another status/additional rights. The request is emailed
  * to the shibboleth and platform administrators for processing.

+ 4 - 0
main/auth/shibboleth/app/view/shibboleth_display.class.php

@@ -1,5 +1,9 @@
 <?php
 
+namespace Shibboleth;
+
+use \Display;
+
 /**
  * Utility display functions tailored for the Shibboleth pluging.
  * 

+ 2 - 0
main/auth/shibboleth/app/view/shibboleth_email_form.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Enter email form. When the email is mandatory and the Shibboleth email user field
  * is empty the system display this form and ask the user to provide an email.

+ 2 - 0
main/auth/shibboleth/app/view/shibboleth_status_request_form.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Status request form. Display a form allowing the user to request additional
  * rights/ another status. 

+ 2 - 0
main/auth/shibboleth/config-dist.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Example of a config.php file. Not used. Configuration must appear in 
  * config.php.

+ 0 - 11
main/auth/shibboleth/config.php

@@ -1,11 +0,0 @@
-<?php
-
-/**
- * Shibboleth configuration. See /config/aai.php for an example.
- *
- * @license see /license.txt
- * @author Laurent Opprecht <laurent@opprecht.info>, Nicolas Rod for the University of Geneva
- */
-require_once dirname(__FILE__) . '/config/aai.class.php';
-
-Shibboleth::set_config(aai::config());

+ 4 - 2
main/auth/shibboleth/config/aai.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Shibboleth configuration for the AAI federation.
  *
@@ -39,8 +41,8 @@ class aai
         );
 
         $result->update_fields = array(
-            'firstname'     => false,
-            'lastname'      => false,
+            'firstname'     => true,
+            'lastname'      => true,
             'email'         => true,
             'status'        => false,
             'persistent_id' => true,

+ 4 - 0
main/auth/shibboleth/db/shibboleth_upgrade.class.php

@@ -1,5 +1,9 @@
 <?php
 
+namespace Shibboleth;
+
+use \Database;
+
 /**
  * Migrate the datatabase. Adds needed fields by Shibboleth to the User table.
  * Upgrade is checked at each user login so there is no need to manually run

+ 14 - 12
main/auth/shibboleth/init.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Initialize the Shibboleth authentication system. All scripts that can be directly
  * called must include this file
@@ -12,18 +14,18 @@ $__dir = dirname(__FILE__) . '/';
 $no_redirection = true;  //no redirection in global.
 include_once($__dir . '/../../inc/global.inc.php');
 
-require_once $__dir . 'lib/shibboleth_config.class.php';
-require_once $__dir . 'lib/shibboleth_session.class.php';
-require_once $__dir . 'lib/store.class.php';
-require_once $__dir . 'app/controller/shibboleth_controller.class.php';
-require_once $__dir . 'app/model/shibboleth_store.class.php';
-require_once $__dir . 'app/model/shibboleth_user.class.php';
-require_once $__dir . 'app/model/user.class.php';
-require_once $__dir . 'app/view/shibboleth_email_form.class.php';
-require_once $__dir . 'app/view/shibboleth_status_request_form.class.php';
-require_once $__dir . 'app/view/shibboleth_display.class.php';
-require_once $__dir . 'app/shibboleth.class.php';
-require_once $__dir . 'db/shibboleth_upgrade.class.php';
+//require_once $__dir . 'lib/shibboleth_config.class.php';
+//require_once $__dir . 'lib/shibboleth_session.class.php';
+//require_once $__dir . 'lib/store.class.php';
+//require_once $__dir . 'app/controller/shibboleth_controller.class.php';
+//require_once $__dir . 'app/model/shibboleth_store.class.php';
+//require_once $__dir . 'app/model/shibboleth_user.class.php';
+//require_once $__dir . 'app/model/user.class.php';
+//require_once $__dir . 'app/view/shibboleth_email_form.class.php';
+//require_once $__dir . 'app/view/shibboleth_status_request_form.class.php';
+//require_once $__dir . 'app/view/shibboleth_display.class.php';
+//require_once $__dir . 'app/shibboleth.class.php';
+//require_once $__dir . 'db/shibboleth_upgrade.class.php';
 
 require_once $__dir . 'config.php';
 

+ 2 - 0
main/auth/shibboleth/lib/model.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Description of model
  *

+ 2 - 0
main/auth/shibboleth/lib/scaffolder/scaffolder.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Scaffolder. Genereate code templates from the database layout.
  * See /template/ for the code being generated

+ 2 - 0
main/auth/shibboleth/lib/scaffolder/template/default.php

@@ -9,6 +9,8 @@
 echo '<?php';
 ?>
 
+namespace Shibboleth;
+
 /**
  * This file is autogenerated. Do not modifiy it.
  */

+ 2 - 0
main/auth/shibboleth/lib/scaffolder/template/model.php

@@ -9,6 +9,8 @@
 echo '<?php';
 ?>
 
+namespace Shibboleth;
+
 /**
  * This file is autogenerated. Do not modifiy it.
  */

+ 2 - 0
main/auth/shibboleth/lib/scaffolder/template/public.php

@@ -9,6 +9,8 @@
 echo '<?php';
 ?>
 
+namespace Shibboleth;
+
 /**
  *
  * Model for table <?php echo $table_name ?> 

+ 2 - 0
main/auth/shibboleth/lib/shibboleth_config.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Shibboleth configuration. All configuration for the Shibboleth authentication
  * plugin: field names mapping, etc.

+ 5 - 0
main/auth/shibboleth/lib/shibboleth_session.class.php

@@ -1,6 +1,11 @@
 <?php
 
+namespace Shibboleth;
+
 use \ChamiloSession as Session;
+use \Chamilo;
+use \Database;
+use \Redirect;
 
 
 /**

+ 4 - 0
main/auth/shibboleth/lib/store.class.php

@@ -1,5 +1,9 @@
 <?php
 
+namespace Shibboleth;
+
+use \Database;
+
 /**
  * A database store. Used interact with the database - save objects, run queries.
  * 

+ 3 - 1
main/auth/shibboleth/login.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Shibboleth login page. 
  * 
@@ -25,7 +27,7 @@ include_once(dirname(__FILE__) . '/init.php');
  */
 //Shibboleth::session()->logout();
 //ShibbolethTest::helper()->setup_new_student_no_email();
-//ShibbolethTest::helper()->setup_new_staff();
+ShibbolethTest::helper()->setup_new_staff();
 //ShibbolethTest::helper()->setup_new_teacher();
 //ShibbolethTest::helper()->setup_new_student();
 //ShibbolethTest::helper()->setup_new_minimal_data();

+ 0 - 0
main/auth/shibboleth/script/output/user.class.php


+ 2 - 0
main/auth/shibboleth/script/scaffold.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Scaffold script. Generates the required database models for the Shibboleth
  * plugin. 

+ 7 - 5
main/auth/shibboleth/test/shibboleth_test.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Various Unit Tests. Note that those tests create users in the database but
  * don't delete them.
@@ -122,8 +124,8 @@ class ShibbolethTest
         $fields = Shibboleth::config()->update_fields;
         self::assert($fields['email']);
         self::assert($fields['persistent_id']);
-        self::assert(!$fields['firstname']);
-        self::assert(!$fields['lastname']);
+        self::assert($fields['firstname']);
+        self::assert($fields['lastname']);
         self::assert(!$fields['status']);
 
         self::helper()->setup_teacher();
@@ -142,10 +144,10 @@ class ShibbolethTest
         $user = User::store()->get_by_shibboleth_id($shib_user->unique_id);
 
         self::assert($user->email == $new_shib_user->email);
-        self::assert($user->shibb_persistent_id == $new_shib_user->persistent_id);
+        self::assert($value = ($user->shibb_persistent_id == $new_shib_user->persistent_id));
 
-        self::assert($user->firstname == $shib_user->firstname);
-        self::assert($user->lastname == $shib_user->lastname);
+        self::assert($user->firstname == $new_shib_user->firstname);
+        self::assert($user->lastname == $new_shib_user->lastname);
         self::assert($user->status == $shib_user->status);
         self::assert(!empty($user->password));
         self::assert(!empty($user->username));

+ 2 - 0
main/auth/shibboleth/test/shibboleth_test_helper.class.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Helper functions for the tests. Set up various dummy user types: teacher, student, etc.
  *

+ 2 - 0
main/auth/shibboleth/test/test.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * Run unit tests. Server needs to be a test server to run those.
  * 

+ 2 - 0
main/auth/shibboleth/test/test_no_email.php

@@ -1,5 +1,7 @@
 <?php
 
+namespace Shibboleth;
+
 /**
  * @license see /license.txt
  * @author Laurent Opprecht <laurent@opprecht.info>, Nicolas Rod for the University of Geneva

+ 343 - 336
main/template/default/agenda/month.tpl

@@ -1,27 +1,33 @@
 <script>
+    
+    function date_to_timestamp(date){        
+        var date_utc = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(),  date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
+        var result =  Math.round(date_utc.getTime() / 1000);
+        return result;
+    }
 
-function checkLength( o, n, min, max ) {
-    if ( o.val().length > max || o.val().length < min ) {
-        o.addClass( "ui-state-error" );
-        updateTips( "Length of " + n + " must be between " +
-            min + " and " + max + "." );
-        return false;
-    } else {
-        return true;
+    function checkLength( o, n, min, max ) {
+        if ( o.val().length > max || o.val().length < min ) {
+            o.addClass( "ui-state-error" );
+            updateTips( "Length of " + n + " must be between " +
+                min + " and " + max + "." );
+            return false;
+        } else {
+            return true;
+        }
     }
-}
-function clean_user_select() {
-    //Cleans the selected attr     
-    $('#users_to_send_id')
+    function clean_user_select() {
+        //Cleans the selected attr     
+        $('#users_to_send_id')
         .find('option')
         .removeAttr('selected')
         .end();
-}
+    }
 
-var region_value = '{{region_value}}';
-$(document).ready(function() {
+    var region_value = '{{region_value}}';
+    $(document).ready(function() {
 
-    /*$("body").delegate(".datetime", "focusin", function(){
+        /*$("body").delegate(".datetime", "focusin", function(){
         $(this).datepicker({
             stepMinute: 10,            
             dateFormat: 'dd/mm/yy',
@@ -30,37 +36,37 @@ $(document).ready(function() {
     });*/
 
 	
-	var date = new Date();
-	var d = date.getDate();
-	var m = date.getMonth();
-	var y = date.getFullYear();
+        var date = new Date();
+        var d = date.getDate();
+        var m = date.getMonth();
+        var y = date.getFullYear();
 	
-	$("#dialog-form").dialog({
-		autoOpen: false,
-		modal	: false, 
-		width	: 580, 
-		height	: 480,
-        zIndex: 20000 // added because of qtip2
-   	});
+        $("#dialog-form").dialog({
+            autoOpen: false,
+            modal	: false, 
+            width	: 580, 
+            height	: 480,
+            zIndex: 20000 // added because of qtip2
+        });
     
-    $("#simple-dialog-form").dialog({
-		autoOpen: false,
-		modal	: false, 
-		width	: 580, 
-		height	: 480,
-        zIndex: 20000 // added because of qtip2
-   	});
+        $("#simple-dialog-form").dialog({
+            autoOpen: false,
+            modal	: false, 
+            width	: 580, 
+            height	: 480,
+            zIndex: 20000 // added because of qtip2
+        });
 
-	var title = $( "#title" ),
-	content = $( "#content" ),	
-	allFields = $( [] ).add( title ).add( content ), tips = $(".validateTips");	
+        var title = $( "#title" ),
+        content = $( "#content" ),	
+        allFields = $( [] ).add( title ).add( content ), tips = $(".validateTips");	
 
-	$('#users_to_send_id').bind('change', function() {
+        $('#users_to_send_id').bind('change', function() {
 	    
-	    var selected_counts = $("#users_to_send_id option:selected").size();
+            var selected_counts = $("#users_to_send_id option:selected").size();
 	    
-	    //alert(selected_counts);        
-       /* if (selected_counts >= 1 && $("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {        
+            //alert(selected_counts);        
+            /* if (selected_counts >= 1 && $("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {        
             clean_user_select();
             
             $('#users_to_send_id option').eq(0).attr('selected', 'selected');
@@ -69,320 +75,321 @@ $(document).ready(function() {
             deleted_items = true;
             
         }*/
-        $("#users_to_send_id").trigger("liszt:updated");    
-     /*
-	    if (selected_counts >= 1) {	        	                
-	        $('#users_to_send_id option').eq(0).removeAttr('selected');            
+            $("#users_to_send_id").trigger("liszt:updated");    
+            /*
+        if (selected_counts >= 1) {	        	                
+            $('#users_to_send_id option').eq(0).removeAttr('selected');            
             
             
-	    }
+        }
 	    
-	   */ 
-	    //clean_user_select();
-	    //$("#users_to_send_id").trigger("liszt:updated");
-	    //alert($("#users_to_send_id option[value='everyone']").attr('selected'));
-	    if ($("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {
+             */ 
             //clean_user_select();
-            //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
-            //$("#users_to_send_id").trigger("liszt:updated");            
-        }
-    });
+            //$("#users_to_send_id").trigger("liszt:updated");
+            //alert($("#users_to_send_id option[value='everyone']").attr('selected'));
+            if ($("#users_to_send_id option[value='everyone']").attr('selected') == 'selected') {
+                //clean_user_select();
+                //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
+                //$("#users_to_send_id").trigger("liszt:updated");            
+            }
+        });
     
-    $.datepicker.setDefaults( $.datepicker.regional[region_value] );
+        $.datepicker.setDefaults( $.datepicker.regional[region_value] );
 	
-	var calendar = $('#calendar').fullCalendar({
-		header: {
-			left: 'today prev,next',
-			center: 'title',
-			right: 'month,agendaWeek,agendaDay',	
-		},	        
-        {% if use_google_calendar == 1 %}
+        var calendar = $('#calendar').fullCalendar({
+            header: {
+                left: 'today prev,next',
+                center: 'title',
+                right: 'month,agendaWeek,agendaDay',	
+            },	        
+            {% if use_google_calendar == 1 %}
             eventSources: [
                 '{{google_calendar_url}}',  //if you want to add more just add URL in this array
                 {
                     className: 'gcal-event',           // an option!                    
                 }
             ],
-        {% endif %}
+            {% endif %}
         
-		buttonText: 	{{button_text}}, 
-		monthNames: 	{{month_names}},
-		monthNamesShort:{{month_names_short}},
-		dayNames: 		{{day_names}},
-		dayNamesShort: 	{{day_names_short}},		
-        firstHour: 8,
-        firstDay: 1, 
-		selectable	: true,
-		selectHelper: true,
+            buttonText: 	{{button_text}}, 
+            monthNames: 	{{month_names}},
+            monthNamesShort:{{month_names_short}},
+            dayNames: 		{{day_names}},
+            dayNamesShort: 	{{day_names_short}},		
+            firstHour: 8,
+            firstDay: 1, 
+            selectable	: true,
+            selectHelper: true,
         
-        viewDisplay: function(view) {
-            /* When changing the view update the qtips */            
-            var api = $('.qtip').qtip('api'); // Access the API of the first tooltip on the page
-            if (api) {
-                api.destroy();
-                //api.render();
-            }
-        },
-		//add event
-		select: function(start, end, allDay, jsEvent, view) {
-			/* When selecting one day or several days */			
-			var start_date 	= Math.round(start.getTime() / 1000);
-			var end_date 	= Math.round(end.getTime() / 1000);
+            viewDisplay: function(view) {
+                /* When changing the view update the qtips */            
+                var api = $('.qtip').qtip('api'); // Access the API of the first tooltip on the page
+                if (api) {
+                    api.destroy();
+                    //api.render();
+                }
+            },
+            //add event
+            select: function(start, end, allDay, jsEvent, view) {
+                /* When selecting one day or several days */			
+                var start_date 	= date_to_timestamp(start);
+                var end_date 	= date_to_timestamp(end);
 			
-			$('#visible_to_input').show();
-			$('#add_as_announcement_div').show();			
-			$('#visible_to_read_only').hide();
+                $('#visible_to_input').show();
+                $('#add_as_announcement_div').show();			
+                $('#visible_to_read_only').hide();
 			
-			//Cleans the selected attr 	
-		    clean_user_select();
+                //Cleans the selected attr 	
+                clean_user_select();
                 
-            //Sets the 1st item selected by default
-            //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
+                //Sets the 1st item selected by default
+                //$('#users_to_send_id option').eq(0).attr('selected', 'selected');
 			
-			//Update chz-select
-			$("#users_to_send_id").trigger("liszt:updated");
+                //Update chz-select
+                $("#users_to_send_id").trigger("liszt:updated");
 			
-			if ({{can_add_events}} == 1) {							
-				var url = '{{web_agenda_ajax_url}}&a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
+                if ({{can_add_events}} == 1) {							
+                    var url = '{{web_agenda_ajax_url}}&a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
                 
-                var start_date_value = $.datepicker.formatDate('{{js_format_date}}', start);
-                var end_date_value  = $.datepicker.formatDate('{{js_format_date}}', end);
+                    var start_date_value = $.datepicker.formatDate('{{js_format_date}}', start);
+                    var end_date_value  = $.datepicker.formatDate('{{js_format_date}}', end);
 				
-				$('#start_date').html(start_date_value + " " +  start.toTimeString().substr(0, 8));
+                    $('#start_date').html(start_date_value + " " +  start.toTimeString().substr(0, 8));
                 
-				if (view.name != 'month') {
-					$('#start_date').html(start_date_value + " " +  start.toTimeString().substr(0, 8));
-					if (start.toDateString() == end.toDateString()) {					
-						$('#end_date').html(' - '+end.toTimeString().substr(0, 8));
-					} else {
-						$('#end_date').html(' - '+start_date_value+" " + end.toTimeString().substr(0, 8));
-					}
-				} else {
-					$('#start_date').html(start_date_value);
-					$('#end_date').html(' ');					
-				}
-				$('#color_calendar').html('{{type_label}}');
-				$('#color_calendar').removeClass('group_event');
-				$('#color_calendar').addClass('label_tag');				
-				$('#color_calendar').addClass('{{ type_event_class }}');
+                    if (view.name != 'month') {
+                        $('#start_date').html(start_date_value + " " +  start.toTimeString().substr(0, 8));
+                        if (start.toDateString() == end.toDateString()) {					
+                            $('#end_date').html(' - '+end.toTimeString().substr(0, 8));
+                        } else {
+                            $('#end_date').html(' - '+start_date_value+" " + end.toTimeString().substr(0, 8));
+                        }
+                    } else {
+                        $('#start_date').html(start_date_value);
+                        $('#end_date').html(' ');					
+                    }
+                    $('#color_calendar').html('{{type_label}}');
+                    $('#color_calendar').removeClass('group_event');
+                    $('#color_calendar').addClass('label_tag');				
+                    $('#color_calendar').addClass('{{ type_event_class }}');
 				
-				allFields.removeClass( "ui-state-error" );		
-				$("#dialog-form").dialog("open");		
+                    allFields.removeClass( "ui-state-error" );		
+                    $("#dialog-form").dialog("open");		
 				
-				$("#dialog-form").dialog({				
-					buttons: {
-						{{"Add"|get_lang}}: function() {
-							var bValid = true;
-							bValid = bValid && checkLength( title, "title", 1, 255 );
-							//bValid = bValid && checkLength( content, "content", 1, 255 );
+                    $("#dialog-form").dialog({				
+                        buttons: {
+                            {{"Add"|get_lang}}: function() {
+                                var bValid = true;
+                                bValid = bValid && checkLength( title, "title", 1, 255 );
+                                //bValid = bValid && checkLength( content, "content", 1, 255 );
 							
-							var params = $("#add_event_form").serialize();						
-							$.ajax({
-								url: url+'&'+params,
-								success:function(data) {
-									calendar.fullCalendar("refetchEvents");
-									calendar.fullCalendar("rerenderEvents");
-									$("#dialog-form").dialog("close");										
-								}							
-							});
-						},
-					},				
-					close: function() {		
-						$("#title").attr('value', '');
-						$("#content").attr('value', '');					
-					}
-				});		
-	            //prevent the browser to follow the link
-	            return false;
-				calendar.fullCalendar('unselect');
-			}
-		},	
-		eventRender: function(event, element) {        
-            if (event.attachment) {
-                element.qtip({            
-                    hide: {
-                        delay: 2000
-                    },
-		            content: event.attachment,
-		            position: { at:'top right' , my:'bottom right'},	
-		        }).removeData('qtip'); // this is an special hack to add multipl qtip in the same target!
+                                var params = $("#add_event_form").serialize();						
+                                $.ajax({
+                                    url: url+'&'+params,
+                                    success:function(data) {
+                                        calendar.fullCalendar("refetchEvents");
+                                        calendar.fullCalendar("rerenderEvents");
+                                        $("#dialog-form").dialog("close");										
+                                    }							
+                                });
+                            },
+                        },				
+                        close: function() {		
+                            $("#title").attr('value', '');
+                            $("#content").attr('value', '');					
+                        }
+                    });		
+                    //prevent the browser to follow the link
+                    return false;
+                    calendar.fullCalendar('unselect');
+                }
+            },	
+            eventRender: function(event, element) {        
+                if (event.attachment) {
+                    element.qtip({            
+                        hide: {
+                            delay: 2000
+                        },
+                        content: event.attachment,
+                        position: { at:'top right' , my:'bottom right'},	
+                    }).removeData('qtip'); // this is an special hack to add multipl qtip in the same target!
                 
-            }
+                }
             
-			if (event.description) {
-				element.qtip({
-                    hide: {
-                        delay: 2000
-                    },
-		            content: event.description,
-		            position: { at:'top left' , my:'bottom left'},	
-		        });                
-			}
+                if (event.description) {
+                    element.qtip({
+                        hide: {
+                            delay: 2000
+                        },
+                        content: event.description,
+                        position: { at:'top left' , my:'bottom left'},	
+                    });                
+                }
 	        
-	    },
-		eventClick: function(calEvent, jsEvent, view) {
+            },
+            eventClick: function(calEvent, jsEvent, view) {
              
-            var start_date 	= Math.round(calEvent.start.getTime() / 1000);
-            if (calEvent.allDay == 1) {				
-                var end_date 	= '';				
-            } else {			
-                var end_date 	= '';	
-                if (calEvent.end && calEvent.end != '') {
-                    var end_date 	= Math.round(calEvent.end.getTime() / 1000);				
+                var start_date 	= date_to_timestamp(calEvent.start);
+            
+                if (calEvent.allDay == 1) {				
+                    var end_date 	= '';				
+                } else {			
+                    var end_date 	= '';	
+                    if (calEvent.end && calEvent.end != '') {
+                        var end_date 	= date_to_timestamp(calEvent.end);				
+                    }
                 }
-            }
 
-			//edit event
-			if (calEvent.editable) {	       
+                //edit event
+                if (calEvent.editable) {	       
 				
-				$('#visible_to_input').hide();                
-                $('#add_as_announcement_div').hide();
+                    $('#visible_to_input').hide();                
+                    $('#add_as_announcement_div').hide();
                 
-                {% if type != 'admin' %}
+                    {% if type != 'admin' %}
                     $('#visible_to_read_only').show();                    
                     $("#visible_to_read_only_users").html(calEvent.sent_to);
-				{% endif %}
+                    {% endif %}
                     
-                $('#color_calendar').html('{{type_label}}');            
-                $('#color_calendar').addClass('label_tag');								
-                $('#color_calendar').removeClass('course_event');
-                $('#color_calendar').removeClass('personal_event');
-                $('#color_calendar').removeClass('group_event');				
-                $('#color_calendar').addClass(calEvent.type+'_event');	
+                    $('#color_calendar').html('{{type_label}}');            
+                    $('#color_calendar').addClass('label_tag');								
+                    $('#color_calendar').removeClass('course_event');
+                    $('#color_calendar').removeClass('personal_event');
+                    $('#color_calendar').removeClass('group_event');				
+                    $('#color_calendar').addClass(calEvent.type+'_event');	
                 
-                $('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
+                    $('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
 
-                if (end_date != '') {
-                    $('#end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear());
-                }
+                    if (end_date != '') {
+                        $('#end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear());
+                    }
 
-                $("#title").attr('value', calEvent.title);
-                $("#content").attr('value', calEvent.description);			
+                    $("#title").attr('value', calEvent.title);
+                    $("#content").attr('value', calEvent.description);			
                 
-				allFields.removeClass( "ui-state-error" );
+                    allFields.removeClass( "ui-state-error" );
 				
-				$("#dialog-form").dialog("open");
+                    $("#dialog-form").dialog("open");
 	
-				var url = '{{web_agenda_ajax_url}}&a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
-				var delete_url = '{{web_agenda_ajax_url}}&a=delete_event&id='+calEvent.id;
+                    var url = '{{web_agenda_ajax_url}}&a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
+                    var delete_url = '{{web_agenda_ajax_url}}&a=delete_event&id='+calEvent.id;
 				
-				$("#dialog-form").dialog({
-					buttons: {
-                        '{{"ExportiCalConfidential"|get_lang}}' : function() {                                            
+                    $("#dialog-form").dialog({
+                        buttons: {
+                            '{{"ExportiCalConfidential"|get_lang}}' : function() {                                            
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";                                
                                 window.location.href = url;
                                 
-						},
-						'{{"ExportiCalPrivate"|get_lang}}': function() { 
+                            },
+                            '{{"ExportiCalPrivate"|get_lang}}': function() { 
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";			
                                 window.location.href = url;
-						},
-                        '{{"ExportiCalPublic"|get_lang}}': function() { 
+                            },
+                            '{{"ExportiCalPublic"|get_lang}}': function() { 
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";			
                                 window.location.href = url;
-						},                        
-						'{{"Edit"|get_lang}}' : function() {
+                            },                        
+                            '{{"Edit"|get_lang}}' : function() {
 							
-							var bValid = true;
-							bValid = bValid && checkLength( title, "title", 1, 255 );							
+                                var bValid = true;
+                                bValid = bValid && checkLength( title, "title", 1, 255 );							
 							
-							var params = $("#add_event_form").serialize();						
-							$.ajax({
-								url: url+'&'+params,
-								success:function() {
-									calEvent.title 			= $("#title").val();
-									calEvent.start 			= calEvent.start;
-									calEvent.end 			= calEvent.end;									
-									calEvent.allDay         = calEvent.allDay;
-									calEvent.description 	= $("#content").val();
+                                var params = $("#add_event_form").serialize();						
+                                $.ajax({
+                                    url: url+'&'+params,
+                                    success:function() {
+                                        calEvent.title 			= $("#title").val();
+                                        calEvent.start 			= calEvent.start;
+                                        calEvent.end 			= calEvent.end;									
+                                        calEvent.allDay         = calEvent.allDay;
+                                        calEvent.description 	= $("#content").val();
 																	
-									calendar.fullCalendar('updateEvent', 
-											calEvent,
-											true // make the event "stick"
-									);
+                                        calendar.fullCalendar('updateEvent', 
+                                        calEvent,
+                                        true // make the event "stick"
+                                    );
 									
-									$("#dialog-form").dialog("close");										
-								}							
-							});
-						},
-						'{{"Delete"|get_lang}}': function() { 
-							$.ajax({
-								url: delete_url,
-								success:function() {
-									calendar.fullCalendar('removeEvents',										
-										calEvent										
-									);								
-									calendar.fullCalendar("refetchEvents");
-									calendar.fullCalendar("rerenderEvents");
-									$("#dialog-form").dialog( "close" );		
-								}
-							});
-						}
-					},				
-					close: function() {		
-						$("#title").attr('value', '');
-						$("#content").attr('value', '');				
-					}
-				});
-			} else { //simple form    
+                                        $("#dialog-form").dialog("close");										
+                                    }							
+                                });
+                            },
+                            '{{"Delete"|get_lang}}': function() { 
+                                $.ajax({
+                                    url: delete_url,
+                                    success:function() {
+                                        calendar.fullCalendar('removeEvents',										
+                                        calEvent										
+                                    );								
+                                        calendar.fullCalendar("refetchEvents");
+                                        calendar.fullCalendar("rerenderEvents");
+                                        $("#dialog-form").dialog( "close" );		
+                                    }
+                                });
+                            }
+                        },				
+                        close: function() {		
+                            $("#title").attr('value', '');
+                            $("#content").attr('value', '');				
+                        }
+                    });
+                } else { //simple form    
             
-                $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
+                    $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
 
-                if (end_date != '') {
-                    $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear() +" - "+calEvent.start.toLocaleTimeString());
-                    $('#simple_end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear() +" - "+calEvent.end.toLocaleTimeString());
-                }
+                    if (end_date != '') {
+                        $('#simple_start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear() +" - "+calEvent.start.toLocaleTimeString());
+                        $('#simple_end_date').html(' '+calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear() +" - "+calEvent.end.toLocaleTimeString());
+                    }
                 
-                $("#simple_title").html(calEvent.title);
-                $("#simple_content").html(calEvent.description);	                
-                $("#simple-dialog-form").dialog("open");
+                    $("#simple_title").html(calEvent.title);
+                    $("#simple_content").html(calEvent.description);	                
+                    $("#simple-dialog-form").dialog("open");
                 
-                $("#simple-dialog-form").dialog({
-					buttons: {
-						'{{"ExportiCalConfidential"|get_lang}}' : function() {                                            
+                    $("#simple-dialog-form").dialog({
+                        buttons: {
+                            '{{"ExportiCalConfidential"|get_lang}}' : function() {                                            
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";			
                                 window.location.href = url;
                                 
-						},
-						'{{"ExportiCalPrivate"|get_lang}}': function() { 
+                            },
+                            '{{"ExportiCalPrivate"|get_lang}}': function() { 
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";			
                                 window.location.href = url;
-						},
-                        '{{"ExportiCalPublic"|get_lang}}': function() { 
+                            },
+                            '{{"ExportiCalPublic"|get_lang}}': function() { 
                                 url =  "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";			
                                 window.location.href = url;
-						}
-					}
-				});
+                            }
+                        }
+                    });
                 
-            }
-		},
-		editable: true,		
-		events: "{{web_agenda_ajax_url}}&a=get_events",
-		eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) {		
-			$.ajax({
-				url: '{{web_agenda_ajax_url}}',
-				data: {
-					a:'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
-				}
-			});
-		},
-        eventResize: function(event, day_delta, minute_delta, revert_func) {
-            $.ajax({
-				url: '{{web_agenda_ajax_url}}',
-				data: {
-					a:'resize_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
-				}
-			});        
-        },
-		axisFormat: 'HH(:mm)',
-		timeFormat: 'HH:mm{ - HH:mm}',		
-		loading: function(bool) {
-			if (bool) $('#loading').show();
-			else $('#loading').hide();
-		}		
-	});	
-});
+                }
+            },
+            editable: true,		
+            events: "{{web_agenda_ajax_url}}&a=get_events",
+            eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) {		
+                $.ajax({
+                    url: '{{web_agenda_ajax_url}}',
+                    data: {
+                        a:'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
+                    }
+                });
+            },
+            eventResize: function(event, day_delta, minute_delta, revert_func) {
+                $.ajax({
+                    url: '{{web_agenda_ajax_url}}',
+                    data: {
+                        a:'resize_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
+                    }
+                });        
+            },
+            axisFormat: 'HH(:mm)',
+            timeFormat: 'HH:mm{ - HH:mm}',		
+            loading: function(bool) {
+                if (bool) $('#loading').show();
+                else $('#loading').hide();
+            }		
+        });	
+    });
 </script>
 
 <div id="simple-dialog-form" style="display:none;">
@@ -412,64 +419,64 @@ $(document).ready(function() {
 </div>
 
 <div id="dialog-form" style="display:none;">
-	<div style="width:500px">
-	<form class="form-horizontal" id="add_event_form" name="form">
-	    
-        {% if visible_to is not null %}
-    	    <div id="visible_to_input" class="control-group">                      
+    <div style="width:500px">
+        <form class="form-horizontal" id="add_event_form" name="form">
+
+            {% if visible_to is not null %}
+            <div id="visible_to_input" class="control-group">                      
                 <label class="control-label" for="date">{{"To"|get_lang}}</label>                
                 <div class="controls">
                     {{visible_to}}                   
                 </div>                  
             </div>
-        {% endif %}        
-         <div id="visible_to_read_only" class="control-group" style="display:none">                      
+            {% endif %}        
+            <div id="visible_to_read_only" class="control-group" style="display:none">                      
                 <label class="control-label" for="date">{{"To"|get_lang}}</label>                
                 <div class="controls">
                     <div id="visible_to_read_only_users"></div>                  
                 </div>                  
-         </div>        	
-		<div class="control-group">					
-            <label class="control-label" for="date">{{"Agenda"|get_lang}}</label>			
-			<div class="controls">
-				<div id="color_calendar"></div>
-			</div>					
-		</div>
-		<div class="control-group">					
-			<label class="control-label" for="date">{{"Date"|get_lang}}</label>			
-			<div class="controls">
-				<span id="start_date"></span><span id="end_date"></span>                
-			</div>					
-		</div>
-		<div class="control-group">			
-			<label class="control-label" for="name">{{"Title"|get_lang}}</label>			
-			<div class="controls">
-				<input type="text" name="title" id="title" size="40" />				
-			</div>
-		</div>
-				
-		<div class="control-group">			
-			<label class="control-label" for="name">{{"Description"|get_lang}}</label>			
-			<div class="controls">
-				<textarea name="content" id="content" class="span3" rows="5"></textarea>
-			</div>
-		</div>	
-		
-        {% if type == 'course' %}
-		<div id="add_as_announcement_div">
-    		 <div class="control-group">                
-                <label></label>
-                <div class="controls">                    
-                    <label class="checkbox inline" for="add_as_annonuncement">
-                        {{ "AddAsAnnouncement"|get_lang }}
-                        <input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />                    
-                    </label>                    
+            </div>        	
+            <div class="control-group">					
+                <label class="control-label" for="date">{{"Agenda"|get_lang}}</label>			
+                <div class="controls">
+                    <div id="color_calendar"></div>
+                </div>					
+            </div>
+            <div class="control-group">					
+                <label class="control-label" for="date">{{"Date"|get_lang}}</label>			
+                <div class="controls">
+                    <span id="start_date"></span><span id="end_date"></span>                
+                </div>					
+            </div>
+            <div class="control-group">			
+                <label class="control-label" for="name">{{"Title"|get_lang}}</label>			
+                <div class="controls">
+                    <input type="text" name="title" id="title" size="40" />				
                 </div>
             </div>
-        </div>
-		{% endif %}
-	</form>
-	</div>
+
+            <div class="control-group">			
+                <label class="control-label" for="name">{{"Description"|get_lang}}</label>			
+                <div class="controls">
+                    <textarea name="content" id="content" class="span3" rows="5"></textarea>
+                </div>
+            </div>	
+
+            {% if type == 'course' %}
+            <div id="add_as_announcement_div">
+                <div class="control-group">                
+                    <label></label>
+                    <div class="controls">                    
+                        <label class="checkbox inline" for="add_as_annonuncement">
+                            {{ "AddAsAnnouncement"|get_lang }}
+                            <input type="checkbox" name="add_as_annonuncement" id="add_as_annonuncement" />                    
+                        </label>                    
+                    </div>
+                </div>
+            </div>
+            {% endif %}
+        </form>
+    </div>
 </div>
 <div id="loading" style="margin-left:150px;position:absolute;display:none">{{"Loading"|get_lang}}...</div>
 <div id="calendar"></div>