Code

Moved getfax.php
[gosa.git] / gosa-plugins / gofax / gofax / faxreports / class_faxreport.inc
index 41e0fc47160179a046cf8865be4222448fb46e5b..f02aef2adf8d17becd895a68d7e8d4da4fa5eccb 100644 (file)
@@ -44,14 +44,14 @@ class faxreport extends plugin
 
     /* Get global filter config and set class vars , 
        or create a filter */
-    if (!is_global("faxreportfilter")){
+    if (!session::is_set("faxreportfilter")){
       $faxreportfilter = array();
       foreach($this->attributes_SO as $name){
         $faxreportfilter[$name] = $this->$name;
       } 
-      register_global("faxreportfilter",$faxreportfilter);
+      session::set("faxreportfilter",$faxreportfilter);
     }else{
-      $faxreportfilter = get_global("faxreportfilter");
+      $faxreportfilter = session::get("faxreportfilter");
       foreach($this->attributes_SO as $name){
         $this->$name = $faxreportfilter[$name];
       }
@@ -112,26 +112,26 @@ class faxreport extends plugin
 
     /* Some checks */
     if(!isset($this->config->data['SERVERS']['FAX'])){
-      print_red(_("No fax extension defined in your server configuration, no reports can be shown!"));
+      msg_dialog::display(_("Error"), _("No fax server found!"), ERROR_DIALOG);
       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
     }elseif(!is_callable("mysql_connect")){
-      print_red(_("There is no mysql extension available, please check your php setup."));
+      msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
     }else{
       /* Connecting, selecting database */
       $cfg     = $this->config->data['SERVERS']['FAX'];
       $link    = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
       if ($link === FALSE){
-        print_red(_("Can't connect to fax database, no reports can be shown!"));
+        msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "GOfax"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
       if (! @mysql_select_db("gofax")){
-        print_red(_("Can't select fax database for report generation!"));
+        msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOfax"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
 
       if (! mysql_query("SELECT * FROM faxlog;")){
-        print_red(_("Can't query fax table 'faxlog' for report generation!"));
+        msg_dialog::display(_("Error"), sprintf(_("Cannot query %s database!"), "GOfax"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
     }          
@@ -154,7 +154,7 @@ class faxreport extends plugin
       /* Check if everything went ok*/
       $result = @mysql_query($query);
       if ($result === false){
-        print_red(_("Query for fax database failed!"));
+        msg_dialog::display(_("Error"), sprintf(_("Cannot query %s database!"), "GOfax"), ERROR_DIALOG);
         @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query failed");
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
@@ -163,7 +163,7 @@ class faxreport extends plugin
       mysql_close($link);
 
       if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){
-        print_red (_("You have no permission to retrieve informations about this fax id!"));
+        msg_dialog::display(_("Permission error"), _("You have no permission to view this fax id!"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
 
@@ -173,7 +173,7 @@ class faxreport extends plugin
       $dn = $fax_uids[$uid];
       $acls = $this->ui->get_permissions($dn,"faxreport/faxreport");
       if(!preg_match("/r/",$acls)){
-        print_red (_("You have no permission to retrieve informations about this fax id!"));
+        msg_dialog::display(_("Permission error"), _("You have no permission to view this fax id!"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
 
@@ -198,9 +198,9 @@ class faxreport extends plugin
       $queuing_time= $line['queuing_time'];
 
       /* The user is allowed to download all fax images from those users 
-          that are listed in $_SESSION['fuserfilter'] 
+          that are listed in session::get('fuserfilter') 
          Don't forget to check getfax.php if you change somthing here */
-      $_SESSION['fuserfilter']= $this->userfilter;
+      session::set('fuserfilter',$this->userfilter);
       $smarty->assign("plug", "?plug=".validate($_GET['plug']));
       $smarty->assign("detail", validate($_GET['detail']));
 
@@ -278,7 +278,7 @@ class faxreport extends plugin
         "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
 
       if(!is_callable("mysql_connect")){
-        print_red("There is no mysql extension configured in your php setup.");
+        msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
 
@@ -294,7 +294,7 @@ class faxreport extends plugin
       @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
       $result = @mysql_query($query);
       if ($result === false){
-        print_red(_("Query for fax database failed!"));
+        msg_dialog::display(_("Error"), sprintf(_("Cannot query %s database!"), "GOfax"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
       }
 
@@ -425,11 +425,11 @@ class faxreport extends plugin
   }
 
 
-  /* Save ui input, and store it in $_SESSION 
+  /* Save ui input, and store it in session::get() 
      to remember last search next time*/
   function save_object()
   {
-    $faxreportfilter = get_global("faxreportfilter");
+    $faxreportfilter = session::get("faxreportfilter");
     if(isset($_POST['EntriesPerPage'])){
       $this->range = $_POST['EntriesPerPage'];
     }
@@ -467,7 +467,7 @@ class faxreport extends plugin
     foreach($this->attributes_SO as $name){
       $faxreportfilter[$name] = $this->$name;
     }  
-    register_global("faxreportfilter",$faxreportfilter);
+    session::set("faxreportfilter",$faxreportfilter);
   }