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 713 $sQuery = array("SELECT field_id FROM $default->document_type_fields_table DTFL " . /*ok*/
714 714 "INNER JOIN $default->document_fields_table AS DF ON DF.id = DTFL.field_id " .
715 715 "WHERE DTFL.document_type_id = ? " .
716   - "AND DF.is_generic = 0", $this->iDocumentTypeID);
  716 + "AND DF.is_generic = ?", array($this->iDocumentTypeID, false));
717 717 $sql = $default->db;
718 718 $sql->query($sQuery);
719 719 $aFieldIDs = array();
... ...
lib/documentmanagement/DocumentCollaboration.inc
... ... @@ -34,8 +34,8 @@ class DocumentCollaboration {
34 34 function documentCollaborationStarted($iDocumentID) {
35 35 global $default;
36 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 39 $sql->query(array($sQuery, $aParams));
40 40 if ($sql->next_record()) {
41 41 return true;
... ... @@ -46,8 +46,8 @@ class DocumentCollaboration {
46 46 function documentCollaborationDone($iDocumentID) {
47 47 global $default;
48 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 51 $sql->query(array($sQuery, $aParams));
52 52 if ($sql->num_rows() > 0) {
53 53 return false;
... ... @@ -64,8 +64,8 @@ class DocumentCollaboration {
64 64 function userIsPerformingCurrentCollaborationStep($iDocumentID) {
65 65 global $default;
66 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 69 $sql->query(array($sQuery, $aParams));
70 70 if ($sql->next_record()) {
71 71 return true;
... ... @@ -274,9 +274,9 @@ class DocumentCollaboration {
274 274 "INNER JOIN $default->groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " .
275 275 "WHERE FURL.document_id = ? " .
276 276 "AND FURL.user_id = ? " .
277   - "AND FURL.active = 1 " .
  277 + "AND FURL.active = ? " .
278 278 "ORDER BY GFAT.precedence ASC";
279   - $aParams = array($iDocumentID, $_SESSION["userID"]);
  279 + $aParams = array($iDocumentID, $_SESSION["userID"], true);
280 280  
281 281 $sql = $default->db;
282 282 $sql->query(array($sQuery, $aParams));
... ...
lib/foldermanagement/Folder.inc
... ... @@ -709,8 +709,9 @@ class Folder extends KTEntity {
709 709 $aDocumentIDs = split(',', $sDocumentIDs);
710 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 713 $aParams = $aDocumentIDs;
  714 + $aParams[] = true;
714 715 $sql = $default->db;
715 716 $sql->query(array($sQuery, $aParams));
716 717 if ($sql->next_record()) {
... ...
lib/security/Permission.inc
... ... @@ -168,8 +168,8 @@ class Permission {
168 168 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " .
169 169 "WHERE UGL.user_id = ? " .
170 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 174 $res = DBUtil::runQuery(array($sQuery, $aParams));
175 175  
... ... @@ -230,8 +230,8 @@ class Permission {
230 230 "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " .
231 231 "WHERE UGL.user_id = ? " .
232 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 236 //$sql->query(array($sQuery, $aParams));
237 237 $res = DBUtil::runQuery(array($sQuery, $aParams));
... ... @@ -306,9 +306,9 @@ class Permission {
306 306 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " .
307 307 "WHERE FURL.user_id = ? " .
308 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 312 $sql->query(array($sQuery, $aParams));
313 313 if ($sql->next_record()) {
314 314 return true;
... ... @@ -331,8 +331,8 @@ class Permission {
331 331 "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " .
332 332 "WHERE FURL.user_id = ? " .
333 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 336 $sql->query(array($sQuery, $aParams));
337 337 if ($sql->next_record()) {
338 338 return true;
... ...
presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc
... ... @@ -125,7 +125,7 @@ function getFailurePage($sMessage, $iDocTypeID) {
125 125  
126 126 function getGenericFieldsList() {
127 127 global $default;
128   - $aGenericDocumentFields = DocumentField::getList("is_generic=1");/*ok*/
  128 + $aGenericDocumentFields = DocumentField::getList(array("is_generic=?"), array(true)));/*ok*/
129 129 for($i = 0; $i < count($aGenericDocumentFields); $i++) {
130 130 $sToRender .= "<li>" . $aGenericDocumentFields[$i]->getName() . "</li>\n";
131 131 }
... ...
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
... ... @@ -73,9 +73,9 @@ function getUploadDocument() {
73 73 */
74 74 function getGenericMetaDataForm() {
75 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 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 80 $aStoreColumnNames = array("document_id", "document_field_id", "value");
81 81 $aDisplayColumnNames = array("document_id", "field_name", "value");
... ... @@ -105,8 +105,8 @@ function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) {
105 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 106 "FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " .
107 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 111 $aStoreColumnNames = array("document_id", "document_field_id", "value");
112 112 $aDisplayColumnNames = array("document_id", "field_name", "value");
... ...