Code

Backport from trunk
[gosa.git] / gosa-plugins / gofax / gofax / faxreports / class_faxreport.inc
index ee78cb718edd212c6d38b86ec3548dd085e75115..1990dd30d9a69ab5c45d5c570a2fbc42391aaffa 100644 (file)
@@ -4,7 +4,7 @@ class faxreport extends plugin
 {
     /* Definitions */
     var $plHeadline     = "FAX Reports";
-    var $plDescription  = "View the FAX report or single documents that have been recieved";
+    var $plDescription  = "View the FAX report or single documents that have been received";
     var $plIcon         = "plugins/gofax/images/reports.png";
 
     /* For internal use */
@@ -43,6 +43,8 @@ class faxreport extends plugin
     /* Create class */
     function faxreport (&$config, &$ui)
     {
+        $this->initTime = microtime(TRUE);
+
         /* Include config object */
         $this->config       = $config;
         $this->ui           = &$ui;
@@ -73,6 +75,11 @@ class faxreport extends plugin
         foreach($tmp as $attrs){
             $this->uidToDN[$attrs['uid'][0]] = $attrs['dn'];
         }
+
+        // Create statistic table entry
+        stats::log('plugin', $class = get_class($this), $category = array($this->acl_category),  $action = 'open',
+                $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
+
     }
 
 
@@ -106,7 +113,7 @@ class faxreport extends plugin
 
         // Set smarty defaults  
         $smarty= get_smarty();
-        $smarty->assign("search_for"           , $this->search_for);
+        $smarty->assign("search_for"           , set_post($this->search_for));
         $smarty->assign("months"                         , $months);
         $smarty->assign("month_select" , $this->month);
         $smarty->assign("years"                                  , $years);
@@ -116,7 +123,7 @@ class faxreport extends plugin
 
         // Check database accessibility 
         if(!isset($this->config->data['SERVERS']['FAX'])){
-            msg_dialog::display(_("Error"), _("No fax server found!"), ERROR_DIALOG);
+            msg_dialog::display(_("Error"), _("No FAX server found!"), ERROR_DIALOG);
             return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
         }elseif(!is_callable("mysql_connect")){
             msg_dialog::display(_("Configuration error"), sprintf(
@@ -128,7 +135,7 @@ class faxreport extends plugin
             $link      = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
             if ($link === FALSE){
                 msg_dialog::display(_("Error"), sprintf(
-                    _("Cannot connect to %s database!"), "GOfax"), ERROR_DIALOG);
+                    _("Cannot connect to %s database!"), "<b>".$cfg['SERVER'].":"."GOfax"."</b>"), ERROR_DIALOG);
                 return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
             }
             if (! @mysql_select_db("gofax")){
@@ -158,7 +165,7 @@ class faxreport extends plugin
             // Query for the requested fay entry 
             $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') ".
                 "as queuing_time,status,sender_id,sender_msn,receiver_id,".
-                "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id=".$detail.";";
+                "receiver_msn,pages,status_message,transfer_time FROM faxlog WHERE id='".$detail."';";
 
             $cfg= $this->config->data['SERVERS']['FAX'];
             $result = @mysql_query($query);
@@ -183,7 +190,7 @@ class faxreport extends plugin
             $acls = $this->ui->get_permissions($dn,"users/viewFaxEntries","");
             if(!preg_match("/r/",$acls)){
                 msg_dialog::display(_("Permission error"), 
-                _("You have no permission to view this fax id!"), ERROR_DIALOG);
+                _("You have no permission to view this FAX id!"), ERROR_DIALOG);
                 return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
             }
 
@@ -194,15 +201,17 @@ class faxreport extends plugin
                 $final="fax_$vname";
                 $v_acl = $this->ui->get_permissions($dn,"users/viewFaxEntries",preg_replace("/_/","",$vname));
                 if($line[$vname] != "" && preg_match("/r/i", $v_acl)){
-                    $smarty->assign("$final", $line[$vname]);
+                    $smarty->assign("$final", set_post($line[$vname]));
                 } else {
                     $smarty->assign("$final", "-");
                 }
             }
             $format= _("Y-M-D");
             $queuing_time= $line['queuing_time'];
-            $smarty->assign("plug", "?plug=".validate($_GET['plug']));
-            $smarty->assign("detail", validate($detail));
+
+            $plug = (isset($_GET['plug'])) ? '?plug='.$_GET['plug'] : '';
+            $smarty->assign("plug", $plug);
+            $smarty->assign("detail", set_post($detail));
             $date= preg_replace("/Y/", substr($queuing_time,0,4), $format);
             $date= preg_replace("/M/", substr($queuing_time,4,2), $date);
             $date= preg_replace("/D/", substr($queuing_time,6,2), $date);
@@ -384,7 +393,7 @@ class faxreport extends plugin
     {
         $faxreportfilter = session::get("faxreportfilter");
         if(isset($_POST['EntriesPerPage'])){
-            $this->range = $_POST['EntriesPerPage'];
+            $this->range = get_post('EntriesPerPage');
         }
 
         if (isset($_GET['start'])){
@@ -407,7 +416,7 @@ class faxreport extends plugin
         }
         foreach( array("year", "month", "search_for") as $type){
             if (isset($_POST[$type])){
-                $faxreportfilter[$type]= $_POST[$type];
+                $faxreportfilter[$type]= get_post($type);
 
                 /* reset start page, if filter has changed */ 
                 if(!isset($_GET['start'])){
@@ -431,8 +440,8 @@ class viewFaxEntries extends plugin {
     {
 
         return (array(
-            "plShortName"     => _("View fax reports"),
-            "plDescription"   => _("View fax reports")."&nbsp;<i>"._("All entries are readonly")."</i>",
+            "plShortName"     => _("View FAX reports"),
+            "plDescription"   => _("View FAX reports")."&nbsp;<i>"._("All entries are read-only")."</i>",
             "plRequirements"=> array(
                 'activePlugin' => 'faxreport', 
                 'ldapSchema' => array('goFaxAccount' => '>=1.0.4'),
@@ -448,6 +457,7 @@ class viewFaxEntries extends plugin {
             "plProvidedAcls" => array(
                 "detailedView"   => _("Detailed view and download"),
                 "id"             => _("Fax ID"),
+                "uid"            => _("The username"),
                 "queuingtime"    => _("Date")."&nbsp;/&nbsp;"._("Time"),
                 "status"         => _("Status"),
                 "senderid"       => _("Sender ID"),