phpBMS

Show
Ignore:
Timestamp:
04/07/09 11:44:18 (3 years ago)
Author:
nate
Message:
  • Merged Nathan branch back into trunk.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/base/include/reports.php

    r285 r485  
    3939if(class_exists("phpbmsTable")) { 
    4040        class reports extends phpbmsTable{ 
    41          
     41 
     42                var $availableTabledefIDs = array(); 
     43                var $availableRoleIDs = array(); 
     44 
    4245                function getDefaults(){ 
    4346                        $therecord = parent::getDefaults(); 
    44                          
     47 
    4548                        $therecord["type"]="report"; 
    46                          
     49 
    4750                        return $therecord; 
    48                          
     51 
    4952                } 
    50          
     53 
     54                //populates tabledef id array 
     55                function populateTabledefArray(){ 
     56 
     57                        $this->availableTabledefIDs = array(); 
     58 
     59                        $querystatement = " 
     60                                SELECT 
     61                                        `id` 
     62                                FROM 
     63                                        `tabledefs`; 
     64                                "; 
     65 
     66                        $queryresult = $this->db->query($querystatement); 
     67 
     68                        //This is for the "global" option 
     69                        $this->availableTabledefIDs[] = 0; 
     70 
     71                        while($therecord = $this->db->fetchArray($queryresult)) 
     72                                $this->availableTabledefIDs[] = $therecord["id"]; 
     73 
     74 
     75 
     76                }//end method --populateRoleArray-- 
     77 
     78                //populates role id array 
     79                function populateRoleArray(){ 
     80 
     81                        $this->availableRoleIDs = array(); 
     82 
     83                        $querystatement = " 
     84                                SELECT 
     85                                        `id` 
     86                                FROM 
     87                                        `roles`; 
     88                                "; 
     89 
     90                        $queryresult = $this->db->query($querystatement); 
     91 
     92                        //These two are added for no restriction on the role (0) and for 
     93                        //administrative restrictioin (-100) 
     94                        $this->availableRoleIDs[] = 0; 
     95                        $this->availableRoleIDs[] = -100; 
     96 
     97                        while($therecord = $this->db->fetchArray($queryresult)) 
     98                                $this->availableRoleIDs[] = $therecord["id"]; 
     99 
     100                }//end method --populateRoleArray-- 
     101 
     102 
     103                function verifyVariables($variables){ 
     104 
     105                        //cannot be table default ("") 
     106                        if(isset($variables["reportfile"])){ 
     107                                if($variables["reportfile"] === "" || $variables["reportfile"] === NULL) 
     108                                        $this->verifyErrors[] = "The `reportfile` field must not be blank."; 
     109                        }else 
     110                                $this->verifyErrors[] = "The `reportfile` field must be set."; 
     111 
     112                        //Table default (NULL) OK 
     113                        if(isset($variables["type"])) 
     114                                if($variables["type"])//don't care if it's "" 
     115                                        switch($variables["type"]){ 
     116                                                case "report": 
     117                                                case "PDF Report": 
     118                                                case "export": 
     119                                                        break; 
     120 
     121                                                default: 
     122                                                        $this->verifyErrors[] = "The `type` field is not an accepted value.  It must be 'report', 'PDF Report', or 'export."; 
     123                                                break; 
     124 
     125                                        }//end switch 
     126 
     127                        //Table Default (0) ok becuase it means report is globally available to any table 
     128                        if(isset($variables["tabledefid"])){ 
     129 
     130                                //must be a non-negative number or NULL/"" 
     131                                if( (!$variables["tabledefid"]) || ((int)$variables["tabledefid"]) > 0 ){ 
     132 
     133                                        if(!count($this->availableTabledefIDs)) 
     134                                                $this->populateTabledefArray(); 
     135 
     136                                        if( !in_array((int)$variables["tabledefid"], $this->availableTabledefIDs) ) 
     137                                                $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable to table definition id number."; 
     138 
     139                                }else 
     140                                        $this->verifyErrors[] = "The `tabledefid` field must be either a non-negative number or equivalent to 0."; 
     141 
     142                        }//end if 
     143 
     144                        //Table Default (0) ok becuase it means report is globally available to any user 
     145                        if(isset($variables["roleid"])){ 
     146 
     147                                //must be a number or NULL/"" 
     148                                if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 
     149 
     150                                        if(!count($this->availableRoleIDs)) 
     151                                                $this->populateRoleArray(); 
     152 
     153                                        if( !in_array((int)$variables["roleid"], $this->availableRoleIDs) ) 
     154                                                $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number."; 
     155 
     156                                }else 
     157                                        $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 
     158 
     159                        }//end if 
     160 
     161                        return parent::verifyVariables($variables); 
     162 
     163                }//end method 
     164 
     165 
    51166                function displayTables($fieldname,$selectedid){ 
    52                          
     167 
    53168                        $querystatement="SELECT id, displayname FROM tabledefs ORDER BY displayname"; 
    54                         $thequery=$this->db->query($querystatement);             
    55                                  
     169                        $thequery=$this->db->query($querystatement); 
     170 
    56171                        echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 
    57                  
     172 
    58173                        echo "<option value=\"0\" "; 
    59174                        if ($selectedid=="0") echo "selected=\"selected\""; 
    60175                        echo " style=\"font-weight:bold\">global</option>\n"; 
    61                  
     176 
    62177                        while($therecord=$this->db->fetchArray($thequery)){ 
    63178                                echo "  <option value=\"".$therecord["id"]."\""; 
     
    65180                                echo ">".$therecord["displayname"]."</option>\n"; 
    66181                        } 
    67                  
     182 
    68183                        echo "</select>\n"; 
    69184                }//end method 
    70          
     185 
    71186        }//end class 
    72187}//end if 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.