Browse Source

Adding reestrinctions when viewing LPs (lp.publicated_on and expired_on)

Julio Montoya 14 years ago
parent
commit
135105d99c
3 changed files with 23 additions and 8 deletions
  1. 3 4
      main/newscorm/learnpath.class.php
  2. 2 2
      main/newscorm/lp_edit.php
  3. 18 2
      main/newscorm/lp_view.php

+ 3 - 4
main/newscorm/learnpath.class.php

@@ -144,13 +144,12 @@ class learnpath {
                 $this->modified_on      = $row['modified_on'];
 
                 if ($row['publicated_on'] != '0000-00-00 00:00:00') {
-                    $this->publicated_on    = api_get_local_time($row['publicated_on']);
+                    $this->publicated_on   = $row['publicated_on'];
                 }
 
                 if ($row['expired_on'] != '0000-00-00 00:00:00') {
-                    $this->expired_on     = api_get_local_time($row['expired_on']);
-                }
-
+                    $this->expired_on     = $row['expired_on'];
+                }                
                 if ($this->type == 2) {
                     if ($row['force_commit'] == 1) {
                         $this->force_commit = true;

+ 2 - 2
main/newscorm/lp_edit.php

@@ -219,8 +219,8 @@ $form->addElement('hidden', 'action', 'update_lp');
 $form->addElement('hidden', 'lp_id', $_SESSION['oLP']->get_id());
 
 
-$defaults['publicated_on']  = ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on))? $publicated_on : date('Y-m-d 12:00:00');
-$defaults['expired_on']     = ($expired_on   !='0000-00-00 00:00:00' && !empty($expired_on) )? $expired_on : date('Y-m-d 12:00:00',time()+84600);
+$defaults['publicated_on']  = ($publicated_on!='0000-00-00 00:00:00' && !empty($publicated_on))? api_get_local_time($publicated_on) : date('Y-m-d 12:00:00');
+$defaults['expired_on']     = ($expired_on   !='0000-00-00 00:00:00' && !empty($expired_on) )? api_get_local_time($expired_on): date('Y-m-d 12:00:00',time()+84600);
 
 $form->setDefaults($defaults);
 echo '<table><tr><td width="550px">';

+ 18 - 2
main/newscorm/lp_view.php

@@ -68,9 +68,25 @@ $htmlHeadXtra[] = '<script language="JavaScript" type="text/javascript">
 </script>';
 
 $_SESSION['oLP']->error = '';
-$lp_type    = $_SESSION['oLP']->get_type();
-$lp_item_id = $_SESSION['oLP']->get_current_item_id();
 
+$now = time();
+
+//Adding visibility reestrinctions
+if (!empty($_SESSION['oLP']->publicated_on) && $_SESSION['oLP']->publicated_on != '0000-00-00 00:00:00') {
+    if ($now < api_strtotime($_SESSION['oLP']->publicated_on)) {
+        api_not_allowed();
+    }    
+}
+
+if (!empty($_SESSION['oLP']->expired_on) && $_SESSION['oLP']->expired_on != '0000-00-00 00:00:00') {
+    if ($now > api_strtotime($_SESSION['oLP']->expired_on)) {
+        api_not_allowed();
+    }    
+}
+
+
+$lp_item_id = $_SESSION['oLP']->get_current_item_id();
+$lp_type    = $_SESSION['oLP']->get_type();
 
 //$lp_item_id = learnpath::escape_string($_GET['item_id']);
 //$_SESSION['oLP']->set_current_item($lp_item_id); // Already done by lp_controller.php.