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/relationships.php

    r285 r485  
    3939if(class_exists("phpbmsTable")){ 
    4040        class relationships extends phpbmsTable{ 
    41                  
     41 
     42                var $availableTabledefIDs = array(); 
     43                var $availableTabledefNames = array(); 
     44 
     45                //function populateds the tabledef ids 
     46                //and the tabledef names corresponding to those ids 
     47                function populateTabledefArrays(){ 
     48 
     49                        $this->availableTabledefIDs = array(); 
     50                        $this->availableTabledefNames = array(); 
     51 
     52                        $querystatement = " 
     53                                SELECT 
     54                                        `id`, 
     55                                        `displayname` 
     56                                FROM 
     57                                        `tabledefs` 
     58                                WHERE 
     59                                        `type` != 'view' 
     60                                ORDER BY 
     61                                        `displayname`; 
     62                                "; 
     63 
     64                        $queryresult = $this->db->query($querystatement); 
     65 
     66                        if($this->db->numRows($queryresult)){ 
     67                                while($therecord = $this->db->fetchArray($queryresult)){ 
     68 
     69                                        $this->availableTabledefIDs[] = $therecord["id"]; 
     70                                        $this->availableTabledefNames[] = $therecord["displayname"]; 
     71 
     72                                }//end while 
     73                        }else{ 
     74                                //if no valid id/names, I put in a value that will 
     75                                //give the arrays a count but not actually match any integers 
     76                                $this->availableTabledefIDs[] = "none"; 
     77                                $this->availableTabledefNames[] = "none"; 
     78                        }//end if 
     79 
     80                }//end method --populateArrays-- 
     81 
     82 
     83                function verifyVariables($variables){ 
     84 
     85                        //cannot be table default ("") 
     86                        if(isset($variables["tofield"])){ 
     87                                if($variables["tofield"] === "" || $variables["tofield"] === NULL) 
     88                                        $this->verifyErrors[] = "The `tofield` field cannot be blank."; 
     89                        }else 
     90                                $this->verifyErrors[] = "The `tofield` field must be set."; 
     91 
     92                        //cannot be table default ("") 
     93                        if(isset($variables["fromfield"])){ 
     94                                if($variables["fromfield"] === "" || $variables["fromfield"] === NULL) 
     95                                        $this->verifyErrors[] = "The `from` field cannot be blank."; 
     96                        }else 
     97                                $this->verifyErrors[] = "The `fromfield` field must be set."; 
     98 
     99                        //cannot be table default (0) 
     100                        if(isset($variables["fromtableid"])){ 
     101 
     102                                //must be a positive number 
     103                                if(((int) $variables["fromtableid"]) > 0 ){ 
     104 
     105                                        if(!count($this->availableTabledefIDs)) 
     106                                                $this->populateTableDefArrays(); 
     107 
     108                                        if(!in_array(((int)$variables["fromtableid"]), $this->availableTabledefIDs)) 
     109                                                $this->verifyErrors[] = "The `fromtableid` field does not give an existing/acceptable parent id number."; 
     110                                }else 
     111                                        $this->verifyErrors[] = "The `fromtableid` field must be a positive number."; 
     112 
     113                        }else 
     114                                $this->verifyErrors[] = "The `fromtableid` field must be set."; 
     115 
     116                        //cannot be table default (0) 
     117                        if(isset($variables["totableid"])){ 
     118 
     119                                //must be a positive number 
     120                                if(((int) $variables["totableid"]) > 0 ){ 
     121 
     122                                        if(!count($this->availableTabledefIDs)) 
     123                                                $this->populateTableDefArrays(); 
     124 
     125                                        if(!in_array(((int)$variables["totableid"]), $this->availableTabledefIDs)) 
     126                                                $this->verifyErrors[] = "The `totableid` field does not give an existing/acceptable to table id number."; 
     127                                }else 
     128                                        $this->verifyErrors[] = "The `totableid` field must be a positive number."; 
     129                        }else 
     130                                $this->verifyErrors[] = "The `totableid` field must be set."; 
     131 
     132                        //check boolean 
     133                        if(isset($variables["inherit"])) 
     134                                if($variables["inherit"] && $variables["inherit"] != 1) 
     135                                        $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1)."; 
     136 
     137                        return parent::verifyVariables($variables); 
     138 
     139                }//end method --verifyVariables-- 
     140 
     141 
    42142                function displayTables($fieldname,$selectedid){ 
    43                          
    44                         $querystatement="SELECT id, displayname FROM tabledefs WHERE type!=\"view\" ORDER BY displayname"; 
    45                         $thequery=$this->db->query($querystatement); 
    46                          
     143 
     144                        if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 
     145                                $this->populateTabledefArrays(); 
     146 
    47147                        echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 
    48                         while($therecord=$this->db->fetchArray($thequery)){ 
    49                                 echo "  <option value=\"".$therecord["id"]."\""; 
    50                                         if($selectedid==$therecord["id"]) echo " selected=\"selected\""; 
    51                                 echo ">".$therecord["displayname"]."</option>\n"; 
     148 
     149                        for($i = 0; $i < count($this->availableTabledefIDs); $i++){ 
     150                                echo "  <option value=\"".$this->availableTabledefIDs[$i]."\""; 
     151                                        if($selectedid==$this->availableTabledefIDs[$i]) echo " selected=\"selected\""; 
     152                                echo ">".$this->availableTabledefNames[$i]."</option>\n"; 
    52153                        } 
    53                  
     154 
    54155                        echo "</select>\n"; 
    55156                } 
    56          
     157 
    57158        }//end class 
    58159}//end if 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.