Code

Added periodical jobs
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 31 Aug 2009 12:56:17 +0000 (12:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 31 Aug 2009 12:56:17 +0000 (12:56 +0000)
- But something seems strange right now - The backend sends different info from time to time.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14171 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/events/class_DaemonEvent.inc
gosa-plugins/goto/addons/goto/events/timestamp_select.tpl

index bf9b968d75f452797a7693440c132cbde787e259..192b67af73924352fba859ec2bc0fad0e2c2fdb3 100644 (file)
@@ -69,6 +69,10 @@ class DaemonEvent
 
   protected $visible_for          = HIDDEN_EVENT;
 
+  protected $periodType           = "days";
+  protected $periodValue          = 7;
+  protected $activate_periodical_job = FALSE;
+
   protected $attributes           = array("timestamp");
  
   function set_type($type)
@@ -105,6 +109,15 @@ class DaemonEvent
         $this->timestamp = $this->_event_to_timestamp($data['TIMESTAMP']);
       }
     }
+
+    if(isset($data['PERIODIC'])){
+      $tmp = split("_",$data['PERIODIC']);
+      if(count($tmp)){
+        $this->activate_periodical_job = TRUE;
+        $this->periodValue = $tmp[0];
+        $this->periodType = $tmp[1];
+      }
+    }
   }
 
 
@@ -201,6 +214,19 @@ class DaemonEvent
       $seconds[$e] = $e;
     }
 
+    $periodTypes = array(
+        "minutes" => _("Minutes"),
+        "hours"   => _("Hours"),
+        "days"    => _("Days"),
+        "weeks"   => _("Weeks"),
+        "months"  => _("Months"));
+    
+
+    $smarty->assign("periodTypes", $periodTypes);
+    $smarty->assign("periodType", $this->periodType);
+    $smarty->assign("periodValue", $this->periodValue);
+    $smarty->assign("activate_periodical_job", $this-> activate_periodical_job);
+
     $smarty->assign("years", $years);
     $smarty->assign("months", $months);
     $smarty->assign("days", $days);
@@ -289,6 +315,15 @@ class DaemonEvent
             $_POST['time_month'],        
             $_POST['time_day'],        
             $_POST['time_year']);
+
+        if(isset($_POST['periodValue'])) $this->periodValue = get_post('periodValue');
+        if(isset($_POST['periodType'])) $this->periodType = get_post('periodType');
+
+        if(isset($_POST['activate_periodical_job'])){
+          $this->activate_periodical_job = TRUE;
+        }else{
+          $this->activate_periodical_job = FALSE;
+        }
       }
     }
 
@@ -456,6 +491,10 @@ class DaemonEvent
     }elseif(isset($ret['timestamp'])){
       unset($ret['timestamp']);
     }
+
+    if($this-> activate_periodical_job){
+      $ret['periodic'][$this->periodType] = $this->periodValue; 
+    }
     return($ret);
   }
 
index 9253774c982e451aef98f06b0f6f0ab6c4fb9032..593488abf3149b0fc026e2bf8a8900b6e881a24e 100644 (file)
                </td>
        </tr>
 </table>
+<br>
+<br>
+<table width="100%">
+  <tr>
+    <td colspan="2">
+      <h2>
+        <input type="checkbox" name='activate_periodical_job' value='1' {if $activate_periodical_job} checked {/if}
+          onClick="changeState('periodValue'); changeState('periodType');">
+        {t}Periodical job{/t}
+      </h2>
+    </td>
+       </tr>
+  <tr>
+    <td>{t}Repeat job every{/t}</td>
+    <td>
+      <input {if !$activate_periodical_job} disabled {/if}
+          size="4" type='text' id='periodValue' value='{$periodValue}' name='periodValue'>
+      <select name='periodType' id="periodType" {if !$activate_periodical_job} disabled {/if}>
+        {html_options options=$periodTypes selected=$periodType}
+      </select>
+    </td>
+       </tr>
+</table>