phpBMS

Changeset 621 for trunk/phpbms/include

Show
Ignore:
Timestamp:
06/25/09 17:55:57 (3 years ago)
Author:
nate
Message:
  • Initial changes to make the api use both uuids and ids, if possible.
  • An "options" object was added to the api's request array of objects. It currently has one option: useUuids. This toggles whether to use the id or the uuid in the update/get/delete commands.
  • Changes to delete, insertRecord, updateRecord commands in the main phpbms table / searchfunction classes and also the class extensions.
Location:
trunk/phpbms/include
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/include/search_class.php

    r599 r621  
    294294                        $this->db->logError=false; 
    295295                        $this->db->stopOnError=false; 
    296 //echo "<pre>"; 
    297 //var_dump($_SESSION["thequerystatement"]); 
    298 //exit; 
     296 
    299297                        $this->queryresult = $this->db->query($_SESSION["thequerystatement"]); 
    300298 
     
    12211219 
    12221220 
    1223                 function delete_record(){ 
    1224  
    1225                         $whereclause=$this->buildWhereClause(); 
     1221                function delete_record($useUUID = false){ 
     1222 
     1223                        if(!$useUUID) 
     1224                                $whereclause=$this->buildWhereClause(); 
     1225                        else 
     1226                                $whereclause = $this->buildWhereClause($this->maintable.".uuid"); 
    12261227 
    12271228                        $endmessage=""; 
     
    12361237                                        $endmessage=" deleted"; 
    12371238                        } 
     1239                         
    12381240                        $queryresult = $this->db->query($querystatement); 
    12391241                        $message = $this->buildStatusMessage().$endmessage; 
     
    12521254                        $whereclause=""; 
    12531255                        foreach($idsArray as $theid){ 
    1254                                 $whereclause.=" OR ".$fieldphrase."=".$theid; 
     1256                                $whereclause.=" OR ".$fieldphrase."='".$theid."'"; 
    12551257                        } 
    12561258                        $whereclause=substr($whereclause,3); 
  • trunk/phpbms/include/tables.php

    r609 r621  
    504504 
    505505        /** 
     506         * function updateRecord 
     507         * 
    506508         * updates a record 
    507509         * 
     
    510512         *                             If the modified is not passed or is NULL the function will use 
    511513         *                             the currently logged in user. 
    512          * @param bool $useUuid specifies whther the $id is a uuid (true) or not.  Default is false. 
     514         * @param bool $useUuid specifies whther to use the id or the uuid (true) in the whereclause.  Default is false. 
    513515         * 
    514516         * @return bool true or false depending upon update success 
     
    582584                $updatestatement .= " 
    583585                    WHERE 
    584                         `uuid` = '".mysql_real_escape_string($variables["id"])."'"; 
     586                        `uuid` = '".mysql_real_escape_string($variables["uuid"])."'"; 
    585587 
    586588            }//endif 
     
    600602         * @param bool $overrideID 
    601603         * @param bool $replace use the SQL replace statement (true) instead of insert (false, deault) 
    602          * @param bool $useUuid generates a uuid and specifies the function to retrn the an array with uuid and id instead of just the id 
     604         * @param bool $useUuid generates a uuid and specifies the function to retrn an array with uuid and id instead of just the id 
    603605         * 
    604606         * @return int|array|bool retruns the id of the newly created record of false on error.  If $useUuid is set to true, it will 
     
    624626                    switch($fieldname){ 
    625627                        case "id": 
    626                             if($overrideID && $variables["id"]){ 
    627  
    628                                 $fieldlist .= "id, "; 
    629                                 $insertvalues .= ((int) $variables["id"]).", "; 
     628                            if($overrideID && isset($variables["id"])){ 
     629 
     630                                if($variables["id"]){ 
     631                                    $fieldlist .= "id, "; 
     632                                    $insertvalues .= ((int) $variables["id"]).", "; 
     633                                }//end if 
    630634 
    631635                            }//endif 
     
    678682 
    679683                $fieldlist .= "`uuid`, "; 
    680                 $insertvalues .= "'".uuid($this->prefix.":")."', "; 
     684                $variables["uuid"] = uuid($this->prefix.":"); 
     685                $insertvalues .= "'".$variables["uuid"]."', "; 
    681686 
    682687            }//endif 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.