Commit 4c87ae2ecab44d1c6e51c280a6bcf69759f369cb

Authored by Neil Blakey-Milner
1 parent 22b398be

Make PEAR DB decide on whether the backend wants TRUE or 1 for booleans.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3304 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
@@ -713,7 +713,7 @@ class Document extends KTEntity { @@ -713,7 +713,7 @@ class Document extends KTEntity {
713 $sQuery = array("SELECT field_id FROM $default->document_type_fields_table DTFL " . /*ok*/ 713 $sQuery = array("SELECT field_id FROM $default->document_type_fields_table DTFL " . /*ok*/
714 "INNER JOIN $default->document_fields_table AS DF ON DF.id = DTFL.field_id " . 714 "INNER JOIN $default->document_fields_table AS DF ON DF.id = DTFL.field_id " .
715 "WHERE DTFL.document_type_id = ? " . 715 "WHERE DTFL.document_type_id = ? " .
716 - "AND DF.is_generic = 0", $this->iDocumentTypeID); 716 + "AND DF.is_generic = ?", array($this->iDocumentTypeID, false));
717 $sql = $default->db; 717 $sql = $default->db;
718 $sql->query($sQuery); 718 $sql->query($sQuery);
719 $aFieldIDs = array(); 719 $aFieldIDs = array();
lib/documentmanagement/DocumentCollaboration.inc
@@ -34,8 +34,8 @@ class DocumentCollaboration { @@ -34,8 +34,8 @@ class DocumentCollaboration {
34 function documentCollaborationStarted($iDocumentID) { 34 function documentCollaborationStarted($iDocumentID) {
35 global $default; 35 global $default;
36 $sql = $default->db; 36 $sql = $default->db;
37 - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND (active = 1 OR done = 1)";/*ok*/  
38 - $aParams = array($iDocumentID); 37 + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND (active = ? OR done = ?)";/*ok*/
  38 + $aParams = array($iDocumentID, true, true);
39 $sql->query(array($sQuery, $aParams)); 39 $sql->query(array($sQuery, $aParams));
40 if ($sql->next_record()) { 40 if ($sql->next_record()) {
41 return true; 41 return true;
@@ -46,8 +46,8 @@ class DocumentCollaboration { @@ -46,8 +46,8 @@ class DocumentCollaboration {
46 function documentCollaborationDone($iDocumentID) { 46 function documentCollaborationDone($iDocumentID) {
47 global $default; 47 global $default;
48 $sql = $default->db; 48 $sql = $default->db;
49 - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND done = 0";/*ok*/  
50 - $aParams = array($iDocumentID); 49 + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND done = ?";/*ok*/
  50 + $aParams = array($iDocumentID, false);
51 $sql->query(array($sQuery, $aParams)); 51 $sql->query(array($sQuery, $aParams));
52 if ($sql->num_rows() > 0) { 52 if ($sql->num_rows() > 0) {
53 return false; 53 return false;
@@ -64,8 +64,8 @@ class DocumentCollaboration { @@ -64,8 +64,8 @@ class DocumentCollaboration {
64 function userIsPerformingCurrentCollaborationStep($iDocumentID) { 64 function userIsPerformingCurrentCollaborationStep($iDocumentID) {
65 global $default; 65 global $default;
66 $sql = $default->db; 66 $sql = $default->db;
67 - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND active = 1 AND user_id = ?";/*ok*/  
68 - $aParams = array($iDocumentID, $_SESSION["userID"]); 67 + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND active = ? AND user_id = ?";/*ok*/
  68 + $aParams = array($iDocumentID, true, $_SESSION["userID"]);
69 $sql->query(array($sQuery, $aParams)); 69 $sql->query(array($sQuery, $aParams));
70 if ($sql->next_record()) { 70 if ($sql->next_record()) {
71 return true; 71 return true;
@@ -274,9 +274,9 @@ class DocumentCollaboration { @@ -274,9 +274,9 @@ class DocumentCollaboration {
274 "INNER JOIN $default->groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " . 274 "INNER JOIN $default->groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " .
275 "WHERE FURL.document_id = ? " . 275 "WHERE FURL.document_id = ? " .
276 "AND FURL.user_id = ? " . 276 "AND FURL.user_id = ? " .
277 - "AND FURL.active = 1 " . 277 + "AND FURL.active = ? " .
278 "ORDER BY GFAT.precedence ASC"; 278 "ORDER BY GFAT.precedence ASC";
279 - $aParams = array($iDocumentID, $_SESSION["userID"]); 279 + $aParams = array($iDocumentID, $_SESSION["userID"], true);
280 280
281 $sql = $default->db; 281 $sql = $default->db;
282 $sql->query(array($sQuery, $aParams)); 282 $sql->query(array($sQuery, $aParams));
lib/foldermanagement/Folder.inc
@@ -709,8 +709,9 @@ class Folder extends KTEntity { @@ -709,8 +709,9 @@ class Folder extends KTEntity {
709 $aDocumentIDs = split(',', $sDocumentIDs); 709 $aDocumentIDs = split(',', $sDocumentIDs);
710 $sQms = DBUtil::paramArray($aDocumentIDs); 710 $sQms = DBUtil::paramArray($aDocumentIDs);
711 711
712 - $sQuery = "SELECT * FROM folders_users_roles_link WHERE document_id in ($sQms) AND (active = 1)";/*ok*/ 712 + $sQuery = "SELECT * FROM folders_users_roles_link WHERE document_id in ($sQms) AND (active = ?)";/*ok*/
713 $aParams = $aDocumentIDs; 713 $aParams = $aDocumentIDs;
  714 + $aParams[] = true;
714 $sql = $default->db; 715 $sql = $default->db;
715 $sql->query(array($sQuery, $aParams)); 716 $sql->query(array($sQuery, $aParams));
716 if ($sql->next_record()) { 717 if ($sql->next_record()) {
lib/security/Permission.inc
@@ -168,8 +168,8 @@ class Permission { @@ -168,8 +168,8 @@ class Permission {
168 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " . 168 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " .
169 "WHERE UGL.user_id = ? " . 169 "WHERE UGL.user_id = ? " .
170 "AND GFL.folder_id = ? " . 170 "AND GFL.folder_id = ? " .
171 - "AND GFL.can_write = 1 ";  
172 - $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID()); 171 + "AND GFL.can_write = ? ";
  172 + $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID(), true);
173 173
174 $res = DBUtil::runQuery(array($sQuery, $aParams)); 174 $res = DBUtil::runQuery(array($sQuery, $aParams));
175 175
@@ -230,8 +230,8 @@ class Permission { @@ -230,8 +230,8 @@ class Permission {
230 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " . 230 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " .
231 "WHERE UGL.user_id = ? " . 231 "WHERE UGL.user_id = ? " .
232 "AND GFL.folder_id = ? " . 232 "AND GFL.folder_id = ? " .
233 - "AND GFL.can_read = 1 ";  
234 - $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID()); 233 + "AND GFL.can_read = ? ";
  234 + $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID(), true);
235 235
236 //$sql->query(array($sQuery, $aParams)); 236 //$sql->query(array($sQuery, $aParams));
237 $res = DBUtil::runQuery(array($sQuery, $aParams)); 237 $res = DBUtil::runQuery(array($sQuery, $aParams));
@@ -306,9 +306,9 @@ class Permission { @@ -306,9 +306,9 @@ class Permission {
306 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " . 306 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " .
307 "WHERE FURL.user_id = ? " . 307 "WHERE FURL.user_id = ? " .
308 "AND FURL.document_id = ? " . 308 "AND FURL.document_id = ? " .
309 - "AND R.can_write = 1 " .  
310 - "AND R.active = 1";  
311 - $aParams = array($_SESSION["userID"], $oDocument->getID()); 309 + "AND R.can_write = ? " .
  310 + "AND R.active = ?";
  311 + $aParams = array($_SESSION["userID"], $oDocument->getID(), true, true);
312 $sql->query(array($sQuery, $aParams)); 312 $sql->query(array($sQuery, $aParams));
313 if ($sql->next_record()) { 313 if ($sql->next_record()) {
314 return true; 314 return true;
@@ -331,8 +331,8 @@ class Permission { @@ -331,8 +331,8 @@ class Permission {
331 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " . 331 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " .
332 "WHERE FURL.user_id = ? " . 332 "WHERE FURL.user_id = ? " .
333 "AND FURL.document_id = ? " . 333 "AND FURL.document_id = ? " .
334 - "AND R.can_read = 1";  
335 - $aParams = array($_SESSION["userID"], $oDocument->getID()); 334 + "AND R.can_read = ?";
  335 + $aParams = array($_SESSION["userID"], $oDocument->getID(), true);
336 $sql->query(array($sQuery, $aParams)); 336 $sql->query(array($sQuery, $aParams));
337 if ($sql->next_record()) { 337 if ($sql->next_record()) {
338 return true; 338 return true;
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc
@@ -125,7 +125,7 @@ function getFailurePage($sMessage, $iDocTypeID) { @@ -125,7 +125,7 @@ function getFailurePage($sMessage, $iDocTypeID) {
125 125
126 function getGenericFieldsList() { 126 function getGenericFieldsList() {
127 global $default; 127 global $default;
128 - $aGenericDocumentFields = DocumentField::getList("is_generic=1");/*ok*/ 128 + $aGenericDocumentFields = DocumentField::getList(array("is_generic=?"), array(true)));/*ok*/
129 for($i = 0; $i < count($aGenericDocumentFields); $i++) { 129 for($i = 0; $i < count($aGenericDocumentFields); $i++) {
130 $sToRender .= "<li>" . $aGenericDocumentFields[$i]->getName() . "</li>\n"; 130 $sToRender .= "<li>" . $aGenericDocumentFields[$i]->getName() . "</li>\n";
131 } 131 }
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
@@ -73,9 +73,9 @@ function getUploadDocument() { @@ -73,9 +73,9 @@ function getUploadDocument() {
73 */ 73 */
74 function getGenericMetaDataForm() { 74 function getGenericMetaDataForm() {
75 global $default; 75 global $default;
76 - /*ok*/ $sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " . 76 + /*ok*/ $sQuery = array("SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " .
77 "FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " . 77 "FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " .
78 - "WHERE DF.is_generic = 1 "; 78 + "WHERE DF.is_generic = ? ", array(true));
79 79
80 $aStoreColumnNames = array("document_id", "document_field_id", "value"); 80 $aStoreColumnNames = array("document_id", "document_field_id", "value");
81 $aDisplayColumnNames = array("document_id", "field_name", "value"); 81 $aDisplayColumnNames = array("document_id", "field_name", "value");
@@ -105,8 +105,8 @@ function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) { @@ -105,8 +105,8 @@ function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) {
105 /*ok*/ $sQuery = array("SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, DTFL.is_mandatory AS is_mandatory, -1 AS id " . 105 /*ok*/ $sQuery = array("SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, DTFL.is_mandatory AS is_mandatory, -1 AS id " .
106 "FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " . 106 "FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " .
107 "LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " . 107 "LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " .
108 - "WHERE DF.is_generic = 0 " .  
109 - "AND DTFL.document_type_id = ?", $iDocumentTypeID); 108 + "WHERE DF.is_generic = ? " .
  109 + "AND DTFL.document_type_id = ?", array(false, $iDocumentTypeID));
110 110
111 $aStoreColumnNames = array("document_id", "document_field_id", "value"); 111 $aStoreColumnNames = array("document_id", "document_field_id", "value");
112 $aDisplayColumnNames = array("document_id", "field_name", "value"); 112 $aDisplayColumnNames = array("document_id", "field_name", "value");