Changeset 570
- Timestamp:
- 06/03/09 19:08:38 (3 years ago)
- Location:
- trunk/phpbms
- Files:
-
- 11 modified
-
include/search_class.php (modified) (1 diff)
-
include/tables.php (modified) (3 diffs)
-
install/files.sql (modified) (2 diffs)
-
install/generateuuids.php (modified) (2 diffs)
-
install/updatev0.98.sql (modified) (1 diff)
-
modules/base/files_addedit.php (modified) (1 diff)
-
modules/base/include/attachments.php (modified) (4 diffs)
-
modules/base/include/files.php (modified) (3 diffs)
-
modules/bms/clients_attachments.php (modified) (1 diff)
-
modules/bms/invoices_attachments.php (modified) (1 diff)
-
modules/bms/products_attachments.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/include/search_class.php
r563 r570 291 291 //Add limit (settings) 292 292 $_SESSION["thequerystatement"].=" limit ".$this->recordoffset.", ".RECORD_LIMIT.";"; 293 294 293 295 294 $this->db->logError=false; -
trunk/phpbms/include/tables.php
r565 r570 394 394 * @return array A list of uuids used in the table. 395 395 */ 396 396 397 397 function _loadUUIDList($tableName) { 398 398 … … 462 462 if(isset($variables["uuid"])) 463 463 if(!$variables["uuid"]) 464 $this->verifyErrors[] = "The `uuid` field annot be blank";464 $this->verifyErrors[] = "The `uuid` field cannot be blank"; 465 465 466 466 if(isset($variables["inactive"])) … … 705 705 706 706 $this->updateRecord($variables); 707 if(isset($variables["getid"])) 708 if(is_numeric($variables["getid"])) 709 $theid = (int) $variables["getid"];// special variable to override the 710 //id for get record 707 711 708 712 //get record -
trunk/phpbms/install/files.sql
r542 r570 1 INSERT INTO `files` (`id`, `uuid`, `name`, `description`, `file`, `type`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`, `roleid`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`) VALUES ('1', ' ', 'logo.png', 'Company Logo Used in PDF reports', 'PNG\r\n\Z\n\0\0\0\rIHDR\0\0\0\0\0]\0\0\0S°\0\0\0gAMA\0\0¯È7é\0\0\0tEXtSoftware\0Adobe ImageReadyqÉe<\0\0\0`PLTE666ÑÑѶ¶¶óó󪪪kkk rrrÅÅÅèèèÛÛÛ¿¿¿|||XXXÞÞÞðððÉÉÉâââKKK&&&QQQPPP%%%bbbcccÿÿÿV\"l\0\0\0ØIDATxÚb \0@£A\0\0D£påΡ\0D£p஡\04ÃA±I#<^inT)&1^v99YYv^.f°@\0a /¿¬1 INSERT INTO `files` (`id`, `uuid`, `name`, `description`, `file`, `type`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`, `roleid`, `custom1`, `custom2`, `custom3`, `custom4`, `custom5`, `custom6`, `custom7`, `custom8`) VALUES ('1', 'file:ad761197-e5a2-3fdf-f330-d1508f10813e', 'logo.png', 'Company Logo Used in PDF reports', 'PNG\r\n\Z\n\0\0\0\rIHDR\0\0\0\0\0]\0\0\0S°\0\0\0gAMA\0\0¯È7é\0\0\0tEXtSoftware\0Adobe ImageReadyqÉe<\0\0\0`PLTE666ÑÑѶ¶¶óó󪪪kkk rrrÅÅÅèèèÛÛÛ¿¿¿|||XXXÞÞÞðððÉÉÉâââKKK&&&QQQPPP%%%bbbcccÿÿÿV\"l\0\0\0ØIDATxÚb \0@£A\0\0D£påΡ\0D£p஡\04ÃA±I#<^inT)&1^v99YYv^.f°@\0a /¿¬ 2 2 X#%á I~8°\0] +t*#ËÏ&¬WVVN®ÝV~šŽ¬B 3 3 \"\n0àgj Žp\0« … … 122 122 Ü\0Â(Uº 123 123 HB=óÄ u¶±*\0\ZYóÜšå0\0 Ñy 124 \0 Ñp\0\0\Z\r\00\0tP|O;ë\0\0\0\0IEND®B`', 'image/png', 1, NOW(), 1, NOW(), ' 90', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);124 \0 Ñp\0\0\Z\r\00\0tP|O;ë\0\0\0\0IEND®B`', 'image/png', 1, NOW(), 1, NOW(), 'Admin', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); -
trunk/phpbms/install/generateuuids.php
r569 r570 110 110 $this->roleList[0] = ""; 111 111 112 $this->tabledefList = $this->generateUUIDList("tabledefs"); 113 // 114 //$this->moduleList= $this->generateUUIDList("modules"); 115 112 116 $menuList = $this->generateUUIDList("menu"); 113 117 $menuList[0] = ""; … … 128 132 //$this->updateFields("usersearches", array("tabledefid"=>$this->tabledefList, "userid"=>$this->userList, "roleid"=>$this->roleList)); 129 133 //$this->updateFields("relationships", array("fromtableid"=>$this->tabledefList, "totableid"=>$this->tabledefList)); 134 135 //$this->updateFields("files", array("roleid"=>$this->roleList)); 130 136 //$this->updateFields("menu", array("parentid"=>$menuList, "roleid"=>$this->roleList)); 131 137 //$this->updateFields("smartsearches", array("tabledefid"=>$this->tabledefList, "moduleid"=>$this->moduleList)); -
trunk/phpbms/install/updatev0.98.sql
r569 r570 232 232 --end usersearches ALTER-- 233 233 234 --files UPDATE-- 235 UPDATE `files` SET 236 `uuid`='file:ad761197-e5a2-3fdf-f330-d1508f10813e', 237 `roleid` = 'Admin' 238 WHERE 239 `id`='1'; 240 --end files UPDATE-- 234 241 --menu INSERT-- 235 242 DELETE FROM `menu`; -
trunk/phpbms/modules/base/files_addedit.php
r543 r570 67 67 function getAttachments($db,$id){ 68 68 $querystatement="SELECT tabledefs.displayname, attachments.recordid, attachments.creationdate, tabledefs.editfile 69 FROM attachments INNER JOIN tabledefs ON attachments.tabledefid=tabledefs. id69 FROM attachments INNER JOIN tabledefs ON attachments.tabledefid=tabledefs.uuid 70 70 WHERE fileid=".$id; 71 71 $queryresult=$db->query($querystatement); -
trunk/phpbms/modules/base/include/attachments.php
r427 r570 39 39 if(class_exists("files")){ 40 40 class attachments extends files{ 41 42 41 42 43 43 function getRecord($id){ 44 44 $id = (int) $id; 45 46 $querystatement = "SELECT 47 files.id,attachments.id as attachmentid,name,description,type,roleid,ISNULL(file) as nofile, 48 49 attachments.createdby, attachments.creationdate, 50 attachments.modifiedby, attachments.modifieddate 51 52 FROM attachments INNER JOIN files on attachments.fileid=files.id 53 WHERE attachments.id=".$id; 54 55 $queryresult = $this->db->query($querystatement); 56 45 46 $querystatement = " 47 SELECT 48 `files`.`id`, 49 `files`.`uuid`, 50 `attachments`.`id` AS `attachmentid`, 51 `name`, 52 `description`, 53 `type`, 54 `roleid`, 55 ISNULL(`file`) AS `nofile`, 56 `attachments`.`createdby`, 57 `attachments`.`creationdate`, 58 `attachments`.`modifiedby`, 59 `attachments`.`modifieddate` 60 FROM 61 `attachments`INNER JOIN `files` ON `attachments`.`fileid`=`files`.`uuid` 62 WHERE 63 `attachments`.`id`='".$id."' 64 "; 65 66 $queryresult = $this->db->query($querystatement); 67 57 68 if($this->db->numRows($queryresult)) 58 69 $therecord = $this->db->fetchArray($queryresult); 59 else 70 else 60 71 $therecord = $this-> getDefaults(); 61 62 72 73 63 74 return $therecord; 64 65 } 66 75 76 } 77 67 78 function getDefaults(){ 68 79 $therecord = parent::getDefaults(); 69 80 70 81 $therecord["attachmentid"] = NULL; 71 82 $therecord["nofile"] = 1; 72 73 return $therecord; 74 75 } 76 77 83 84 return $therecord; 85 86 } 87 88 89 function prepareVariables($variables){ 90 91 $variables["getid"] = $variables["attachmentid"]; //to fix the get record problem 92 93 return parent::prepareVariables($variables); 94 95 }//end method 96 97 78 98 function updateRecord($variables, $modifiedby = NULL){ 79 99 parent::updateRecord($variables, $modifiedby); 80 100 81 101 $_POST["id"] = $variables["attachmentid"]; 82 } 83 84 102 103 } 104 105 85 106 function insertRecord($variables, $createdby = NULL){ 86 107 87 108 if($createdby == NULL) 88 109 $createdby = $_SESSION["userinfo"]["id"]; 89 110 90 111 if($variables["newexisting"]=="new"){ 91 112 //we need to add a new file record before adding a new 92 113 //attachment record 93 94 $variables["fileid"] = parent::insertRecord($variables, $createdby); 114 115 $variables["fileid"] = parent::insertRecord($variables, $createdby); 95 116 } 96 117 97 118 //next we create the attachment record 98 $querystatement="INSERT INTO attachments "; 119 120 $querystatement = " 121 SELECT 122 `uuid`, 123 `maintable` 124 FROM 125 `tabledefs` 126 WHERE 127 `id` = '".(int)$variables["tabledefid"]."' 128 "; 129 130 $queryresult = $this->db->query($querystatement); 131 $therecord = $this->db->fetchArray($queryresult); 132 $tabldefid = $therecord["uuid"]; 133 $maintable = $therecord["maintable"]; 134 135 $querystatement = " 136 SELECT 137 `uuid` 138 FROM 139 `".$maintable."` 140 WHERE 141 `id` = '".$variables["recordid"]."' 142 "; 143 144 $queryresult = $this->db->query($querystatement); 145 $therecord = $this->db->fetchArray($queryresult); 146 $recordid = $therecord["uuid"]; 147 148 $querystatement = " 149 SELECT 150 `uuid` 151 FROM 152 `files` 153 WHERE 154 `id` = '".$variables["fileid"]."' 155 "; 156 157 $queryresult = $this->db->query($querystatement); 158 $therecord = $this->db->fetchArray($queryresult); 159 $fileid = $therecord["uuid"]; 160 161 $querystatement="INSERT INTO attachments "; 99 162 $querystatement.="(fileid,tabledefid,recordid, 100 163 createdby,creationdate,modifiedby) VALUES ("; 101 102 $querystatement.= $variables["fileid"].", ";103 $querystatement.= $variables["tabledefid"].", ";104 $querystatement.= $variables["recordid"].", ";105 106 $querystatement.=$createdby.", "; 164 165 $querystatement.="'".$fileid."', "; 166 $querystatement.="'".$tabldefid."', "; 167 $querystatement.="'".$recordid."', "; 168 169 $querystatement.=$createdby.", "; 107 170 $querystatement.="Now(), "; 108 $querystatement.=$createdby.")"; 109 110 $queryresult = $this->db->query($querystatement); 111 171 $querystatement.=$createdby.")"; 172 173 $queryresult = $this->db->query($querystatement); 174 112 175 if($queryresult) 113 176 return $this->db->insertId(); 114 177 else 115 178 return false; 116 179 117 180 }//end method 118 181 119 182 }//end class 120 183 }//end if … … 124 187 125 188 function delete_record(){ 126 189 127 190 $whereclause = $this->buildWhereClause(); 128 191 129 192 $rowsdeleted=0; 130 193 foreach($this->idsArray as $id){ … … 132 195 $queryresult = $this->db->query($querystatement); 133 196 $therecord=$this->db->fetchArray($queryresult); 134 197 135 198 $querystatement = "DELETE FROM attachments WHERE id=".$id.";"; 136 199 $queryresult = $this->db->query($querystatement); 137 200 $rowsdeleted++; 138 201 139 202 $querystatement = "SELECT id FROM attachments WHERE fileid=".$therecord["fileid"].";"; 140 203 $queryresult = $this->db->query($querystatement); … … 144 207 $queryresult = $this->db->query($querystatement); 145 208 } 146 209 147 210 } 148 211 149 212 $querystatement = "DELETE FROM attachments WHERE ".$whereclause.";"; 150 213 $queryresult = $this->db->query($querystatement); 151 214 152 215 $message = $this->buildStatusMessage($rowsdeleted); 153 216 $message.=" deleted."; -
trunk/phpbms/modules/base/include/files.php
r515 r570 41 41 class files extends phpbmsTable{ 42 42 43 var $ availableRoleIDs = array();43 var $_availableRoleUUIDs = NULL; 44 44 45 45 function getPicture($name){ … … 54 54 } 55 55 56 //populates the list of possible role ids57 //into $this->availableRoleIDs (an array)58 function populateRoleArray(){59 60 $this->availableRoleIDs = array();61 62 $querystatement = "63 SELECT64 `id`65 FROM66 `roles`;67 ";68 69 $queryresult = $this->db->query($querystatement);70 71 //next two should also be allowed, but aren't stored in the database72 $this->availableRoleIDs[] = 0;//for everyone73 $this->availableRoleIDs[] = -100;//for administrators74 75 while($therecord = $this->db->fetchArray($queryresult))76 $this->availableRoleIDs[] = $therecord["id"];77 78 }//end method --populateRoleArray--79 80 56 81 57 function verifyVariables($variables){ 82 58 83 //if it is set, we'll have to check, if not, it defaults to 0which is an acceptable59 //if it is set, we'll have to check, if not, it defaults to '' which is an acceptable 84 60 //value. 85 61 if(isset($variables["roleid"])){ 86 62 87 //either its numeric or == 0 88 if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 63 //check to see if the RoleIDs are populated 64 if($this->_availableRoleUUIDs === NULL){ 65 $this->_availableRoleUUIDs = $this->_loadUUIDList("roles"); 66 $this->_availableRoleUUIDs[] = ""; 67 $this->_availableRoleUUIDs[] = "Admin"; 68 }//end if 89 69 90 //check to see if the RoleIDs are populated 91 if(!count($this->availableRoleIDs)) 92 $this->populateRoleArray();//populate if not 70 if(!in_array(((string)$variables["roleid"]), $this->_availableRoleUUIDs)) 71 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 93 72 94 //check to see if the int typecast of the roleid (to allow for values95 //equivalent to 0) is an acceptable role id.96 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs))97 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number.";98 }else99 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0.";100 73 }//end if 101 74 … … 119 92 }//end if 120 93 121 return $variables;94 return parent::prepareVariables($variables); 122 95 123 96 }//end function -
trunk/phpbms/modules/bms/clients_attachments.php
r545 r570 50 50 $refid = (integer) $_GET["id"]; 51 51 52 $querystatement = " 53 SELECT 54 `uuid`, 55 `maintable` 56 FROM 57 `tabledefs` 58 WHERE 59 `id` = '".(int)$tabledefid."' 60 "; 61 62 $queryresult = $db->query($querystatement); 63 $therecord = $db->fetchArray($queryresult); 64 $tabledefuuid = $therecord["uuid"]; 65 $maintable = $therecord["maintable"]; 66 67 $querystatement = " 68 SELECT 69 `uuid` 70 FROM 71 `".$maintable."` 72 WHERE 73 `id` = '".$refid."' 74 "; 75 76 $queryresult = $db->query($querystatement); 77 $therecord = $db->fetchArray($queryresult); 78 $refuuid = $therecord["uuid"]; 79 52 80 $securitywhere=""; 53 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0) 54 $securitywhere=" AND files.roleid IN (".implode(",",$_SESSION["userinfo"]["roles"]).",0)"; 81 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0){ 82 $securitywhere = "''"; 83 foreach($_SESSION["userinfo"]["roles"] as $roleuuid) 84 $securitywhere .= ",'".$roleuuid."'"; 85 }//end if 55 86 56 $whereclause="attachments.tabledefid= ".$tabledefid." AND attachments.recordid=".$refid.$securitywhere;87 $whereclause="attachments.tabledefid='".$tabledefuuid."' AND attachments.recordid='".$refuuid."'".$securitywhere; 57 88 $backurl="../bms/clients_attachments.php"; 58 89 $base="../../"; -
trunk/phpbms/modules/bms/invoices_attachments.php
r546 r570 48 48 if(isset($_GET["refid"])) $_GET["id"]=$_GET["refid"]; 49 49 $refid=(integer) $_GET["id"]; 50 $securitywhere=""; 51 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0) 52 $securitywhere=" AND files.roleid IN (".implode(",",$_SESSION["userinfo"]["roles"]).",0)"; 53 $whereclause="attachments.tabledefid=".$tabledefid." AND attachments.recordid=".$refid.$securitywhere; 50 51 $querystatement = " 52 SELECT 53 `uuid`, 54 `maintable` 55 FROM 56 `tabledefs` 57 WHERE 58 `id` = '".(int)$tabledefid."' 59 "; 60 61 $queryresult = $db->query($querystatement); 62 $therecord = $db->fetchArray($queryresult); 63 $tabledefuuid = $therecord["uuid"]; 64 $maintable = $therecord["maintable"]; 65 66 $querystatement = " 67 SELECT 68 `uuid` 69 FROM 70 `".$maintable."` 71 WHERE 72 `id` = '".$refid."' 73 "; 74 75 $queryresult = $db->query($querystatement); 76 $therecord = $db->fetchArray($queryresult); 77 $refuuid = $therecord["uuid"]; 78 79 $securitywhere=""; 80 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0){ 81 $securitywhere = "''"; 82 foreach($_SESSION["userinfo"]["roles"] as $roleuuid) 83 $securitywhere .= ",'".$roleuuid."'"; 84 }//end if 85 86 $whereclause="attachments.tabledefid='".$tabledefuuid."' AND attachments.recordid='".$refuuid."'".$securitywhere; 54 87 $backurl="../bms/invoices_attachments.php"; 55 88 $base="../../"; -
trunk/phpbms/modules/bms/products_attachments.php
r546 r570 48 48 if(isset($_GET["refid"])) $_GET["id"]=$_GET["refid"]; 49 49 $refid=(integer) $_GET["id"]; 50 $securitywhere=""; 51 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0) 52 $securitywhere=" AND files.roleid IN (".implode(",",$_SESSION["userinfo"]["roles"]).",0)"; 53 $whereclause="attachments.tabledefid=".$tabledefid." AND attachments.recordid=".$refid.$securitywhere; 50 $querystatement = " 51 SELECT 52 `uuid`, 53 `maintable` 54 FROM 55 `tabledefs` 56 WHERE 57 `id` = '".(int)$tabledefid."' 58 "; 59 60 $queryresult = $db->query($querystatement); 61 $therecord = $db->fetchArray($queryresult); 62 $tabledefuuid = $therecord["uuid"]; 63 $maintable = $therecord["maintable"]; 64 65 $querystatement = " 66 SELECT 67 `uuid` 68 FROM 69 `".$maintable."` 70 WHERE 71 `id` = '".$refid."' 72 "; 73 74 $queryresult = $db->query($querystatement); 75 $therecord = $db->fetchArray($queryresult); 76 $refuuid = $therecord["uuid"]; 77 78 $securitywhere=""; 79 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0){ 80 $securitywhere = "''"; 81 foreach($_SESSION["userinfo"]["roles"] as $roleuuid) 82 $securitywhere .= ",'".$roleuuid."'"; 83 }//end if 84 85 $whereclause="attachments.tabledefid='".$tabledefuuid."' AND attachments.recordid='".$refuuid."'".$securitywhere; 54 86 $backurl="../bms/products_attachments.php"; 55 87 $base="../../";