Code

Added acls for phonereports
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Dec 2005 08:15:20 +0000 (08:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Dec 2005 08:15:20 +0000 (08:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2167 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/acl_definition.inc
plugins/gofon/fonreports/class_fonreport.inc
plugins/gofon/fonreports/contents.tpl
plugins/gofon/fonreports/main.inc

index 7336581d1b555aa7c03bb5c22c5c5a24e5f6e153..3c7323c8e78c6f4480f2c19305559193830e9dc6 100644 (file)
@@ -287,6 +287,6 @@ $ACLD['addressbook']=  array("addressbook","add", "delete",
       "homePhone", "mobile", "o", "postalAddress", "l",
       "postalCode", "st", "ou", "telephoneNumber",
       "facsimileTelephoneNumber", "pager");
-$ACLD['fonreport']     =  array("fonreport");
+$ACLD['fonreport']     =  array("fonreport", "src", "dst", "channel", "lastapp", "disposition", "duration");
 $ACLD['faxreport']     =  array("faxreport");
 ?>
index 893112c574b0cfd326d3ed06d16a7606552ae428..5b810f60b6be0d3d04e86f5e74f96cf9d27bfba9 100644 (file)
@@ -56,9 +56,17 @@ class fonreport extends plugin
        /* Call parent execute */
        plugin::execute();
 
-       /* Get template engine */
+       /* GVet template engine */
        $smarty= get_smarty();
 
+       foreach($this->fields as $field){
+               if(chkacl($this->acl,$field)==""){
+                       $smarty->assign($field."ACL","");       
+               }else{
+                       $smarty->assign($field."ACL"," disabled ");     
+               }
+       }
+
        $months= array();
        $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April");
        $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August");
@@ -171,9 +179,17 @@ class fonreport extends plugin
                  $this->userfilter= preg_replace("/OR $/", "", $this->userfilter);
          }
 
-         /* Perform SQL query */
-##### FIXME ACL, FILTER ######
-#        if ($this->userfilter){
+       $fields_str = "calldate, ";
+
+       foreach($this->fields as $field){
+               if($field == "calldate") continue;      
+               if(chkacl($this->acl,$field)==""){
+                       $fields_str .= $field.", ";
+               }
+       }
+
+       $fields_str = preg_replace("/, $/","",$fields_str);
+
        if ($this->sort_direction == "down"){
                $desc= "DESC";
        } else {
@@ -181,8 +197,7 @@ class fonreport extends plugin
        }
        $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year));
        $end=   date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year));
-       $query = "SELECT calldate, channel, src, clid, lastapp, lastdata, dst, ".
-               "disposition, duration FROM cdr ".
+       $query = "SELECT ".$fields_str." FROM cdr ".
                "WHERE calldate <= $end AND ".
                "calldate >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
 
@@ -199,20 +214,23 @@ class fonreport extends plugin
        }
        $report_list= array();
        while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+               $append_str = "";
                $hour=  substr($line["calldate"], 11, 2);
                $minute=substr($line["calldate"], 14, 2);
                $format= _("Y-M-D");
                $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format);
                $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date);
                $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date);
-
-               $report_list[]= "<td>$date $hour:$minute</td>".
-                       "<td>".$line["src"]."</td>".
-                       "<td>".$line["dst"]."</td>".
-                       "<td>".$line["channel"]."</td>".
-                       "<td>".$line["lastapp"]."</td>".
-                       "<td>".$line["disposition"]."</td>".
-                       "<td>".$this->gen_duration($line["duration"])."</td>";
+               $append_str .=  "<td>$date $hour:$minute</td>";
+               foreach(array("src","dst","channel","lastapp","disposition") as $atr){
+                       if(isset($line[$atr])){
+                               $append_str .=  "<td>".$line[$atr]."</td>";
+                       }
+               }
+               if(isset($line['duration'])){
+                       $append_str .=  "<td>".$this->gen_duration($line["duration"])."</td>";
+               }
+               $report_list[] = $append_str;
        }
 
        $this->report_list= $report_list;
index 3a780cac1e478c92a462b98b7f1c3105fd08839e..7a07cde8a882dae3fd47ef7d423cb297a5571122 100644 (file)
  <table style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 border=0 rules="cols" summary="">
   <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
    <td><a href="main.php{$plug}&amp;sort=0">{t}Date{/t} {$mode0}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=1">{t}Source{/t} {$mode1}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=2">{t}Destination{/t} {$mode2}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=3">{t}Channel{/t} {$mode3}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=4">{t}Application{/t} {$mode4}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=5">{t}Status{/t} {$mode5}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=6">{t}Duration{/t} {$mode6}</a></td>
+   {if $srcACL == ""}          <td><a href="main.php{$plug}&amp;sort=1">{t}Source{/t} {$mode1}</a></td>                        {/if}
+   {if $dstACL == ""}       <td><a href="main.php{$plug}&amp;sort=2">{t}Destination{/t} {$mode2}</a></td>              {/if}
+   {if $channelACL == ""}       <td><a href="main.php{$plug}&amp;sort=3">{t}Channel{/t} {$mode3}</a></td>                      {/if}
+   {if $lastappACL == ""}       <td><a href="main.php{$plug}&amp;sort=4">{t}Application{/t} {$mode4}</a></td>          {/if}
+   {if $dispositionACL == ""}       <td><a href="main.php{$plug}&amp;sort=5">{t}Status{/t} {$mode5}</a></td>                   {/if}
+   {if $durationACL == ""}       <td><a href="main.php{$plug}&amp;sort=6">{t}Duration{/t} {$mode6}</a></td>                    {/if}
   </tr>
   {$search_result}
  </table>
index f79641b3df9361d9f97428a264496907058d6b3a..329fc1526b9f8cc185815e720cb8f062b50eba45 100644 (file)
@@ -2,15 +2,20 @@
 
 if (!$remove_lock){
        /* Page header*/
-        $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports"));
+       $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports"));
 
-        /* Create fonreport object on demand */
-        if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
-                $_SESSION['fonreport']= new fonreport ($config, $ui);
-        }
-        $fonreport= $_SESSION['fonreport'];
+       /* Create fonreport object on demand */
+       if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+               $_SESSION['fonreport']= new fonreport ($config, $ui);
+       }
+       $fonreport= $_SESSION['fonreport'];
 
-        /* Execute formular */
+       /* set permissions */
+       $acl= get_permissions ($ui->dn, $ui->subtreeACL);
+       $fonreport->acl= get_module_permission($acl, "fonreport", $ui->dn);
+
+
+       /* Execute formular */
        $display.= $fonreport->execute ();
        $display.= "<input type=\"hidden\" name=\"ignore\">\n";