From 4c87ae2ecab44d1c6e51c280a6bcf69759f369cb Mon Sep 17 00:00:00 2001 From: Neil Blakey-Milner Date: Wed, 25 May 2005 21:13:46 +0000 Subject: [PATCH] Make PEAR DB decide on whether the backend wants TRUE or 1 for booleans. --- lib/documentmanagement/Document.inc | 2 +- lib/documentmanagement/DocumentCollaboration.inc | 16 ++++++++-------- lib/foldermanagement/Folder.inc | 3 ++- lib/security/Permission.inc | 18 +++++++++--------- presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc | 2 +- presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc | 8 ++++---- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/documentmanagement/Document.inc b/lib/documentmanagement/Document.inc index 0fd48b8..13725dd 100644 --- a/lib/documentmanagement/Document.inc +++ b/lib/documentmanagement/Document.inc @@ -713,7 +713,7 @@ class Document extends KTEntity { $sQuery = array("SELECT field_id FROM $default->document_type_fields_table DTFL " . /*ok*/ "INNER JOIN $default->document_fields_table AS DF ON DF.id = DTFL.field_id " . "WHERE DTFL.document_type_id = ? " . - "AND DF.is_generic = 0", $this->iDocumentTypeID); + "AND DF.is_generic = ?", array($this->iDocumentTypeID, false)); $sql = $default->db; $sql->query($sQuery); $aFieldIDs = array(); diff --git a/lib/documentmanagement/DocumentCollaboration.inc b/lib/documentmanagement/DocumentCollaboration.inc index 6132036..edec697 100644 --- a/lib/documentmanagement/DocumentCollaboration.inc +++ b/lib/documentmanagement/DocumentCollaboration.inc @@ -34,8 +34,8 @@ class DocumentCollaboration { function documentCollaborationStarted($iDocumentID) { global $default; $sql = $default->db; - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND (active = 1 OR done = 1)";/*ok*/ - $aParams = array($iDocumentID); + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND (active = ? OR done = ?)";/*ok*/ + $aParams = array($iDocumentID, true, true); $sql->query(array($sQuery, $aParams)); if ($sql->next_record()) { return true; @@ -46,8 +46,8 @@ class DocumentCollaboration { function documentCollaborationDone($iDocumentID) { global $default; $sql = $default->db; - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND done = 0";/*ok*/ - $aParams = array($iDocumentID); + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND done = ?";/*ok*/ + $aParams = array($iDocumentID, false); $sql->query(array($sQuery, $aParams)); if ($sql->num_rows() > 0) { return false; @@ -64,8 +64,8 @@ class DocumentCollaboration { function userIsPerformingCurrentCollaborationStep($iDocumentID) { global $default; $sql = $default->db; - $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND active = 1 AND user_id = ?";/*ok*/ - $aParams = array($iDocumentID, $_SESSION["userID"]); + $sQuery = "SELECT id FROM $default->folders_user_roles_table WHERE document_id = ? AND active = ? AND user_id = ?";/*ok*/ + $aParams = array($iDocumentID, true, $_SESSION["userID"]); $sql->query(array($sQuery, $aParams)); if ($sql->next_record()) { return true; @@ -274,9 +274,9 @@ class DocumentCollaboration { "INNER JOIN $default->groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " . "WHERE FURL.document_id = ? " . "AND FURL.user_id = ? " . - "AND FURL.active = 1 " . + "AND FURL.active = ? " . "ORDER BY GFAT.precedence ASC"; - $aParams = array($iDocumentID, $_SESSION["userID"]); + $aParams = array($iDocumentID, $_SESSION["userID"], true); $sql = $default->db; $sql->query(array($sQuery, $aParams)); diff --git a/lib/foldermanagement/Folder.inc b/lib/foldermanagement/Folder.inc index 8b4ed26..59c32be 100644 --- a/lib/foldermanagement/Folder.inc +++ b/lib/foldermanagement/Folder.inc @@ -709,8 +709,9 @@ class Folder extends KTEntity { $aDocumentIDs = split(',', $sDocumentIDs); $sQms = DBUtil::paramArray($aDocumentIDs); - $sQuery = "SELECT * FROM folders_users_roles_link WHERE document_id in ($sQms) AND (active = 1)";/*ok*/ + $sQuery = "SELECT * FROM folders_users_roles_link WHERE document_id in ($sQms) AND (active = ?)";/*ok*/ $aParams = $aDocumentIDs; + $aParams[] = true; $sql = $default->db; $sql->query(array($sQuery, $aParams)); if ($sql->next_record()) { diff --git a/lib/security/Permission.inc b/lib/security/Permission.inc index 7d23ffa..d3cc007 100644 --- a/lib/security/Permission.inc +++ b/lib/security/Permission.inc @@ -168,8 +168,8 @@ class Permission { "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " . "WHERE UGL.user_id = ? " . "AND GFL.folder_id = ? " . - "AND GFL.can_write = 1 "; - $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID()); + "AND GFL.can_write = ? "; + $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID(), true); $res = DBUtil::runQuery(array($sQuery, $aParams)); @@ -230,8 +230,8 @@ class Permission { "FROM $default->groups_folders_table AS GFL INNER JOIN $default->users_groups_table AS UGL ON GFL.group_id = UGL.group_id " . "WHERE UGL.user_id = ? " . "AND GFL.folder_id = ? " . - "AND GFL.can_read = 1 "; - $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID()); + "AND GFL.can_read = ? "; + $aParams = array($_SESSION["userID"], $oFolder->getPermissionFolderID(), true); //$sql->query(array($sQuery, $aParams)); $res = DBUtil::runQuery(array($sQuery, $aParams)); @@ -306,9 +306,9 @@ class Permission { "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " . "WHERE FURL.user_id = ? " . "AND FURL.document_id = ? " . - "AND R.can_write = 1 " . - "AND R.active = 1"; - $aParams = array($_SESSION["userID"], $oDocument->getID()); + "AND R.can_write = ? " . + "AND R.active = ?"; + $aParams = array($_SESSION["userID"], $oDocument->getID(), true, true); $sql->query(array($sQuery, $aParams)); if ($sql->next_record()) { return true; @@ -331,8 +331,8 @@ class Permission { "INNER JOIN $default->roles_table AS R ON GFAL.role_id = R.id " . "WHERE FURL.user_id = ? " . "AND FURL.document_id = ? " . - "AND R.can_read = 1"; - $aParams = array($_SESSION["userID"], $oDocument->getID()); + "AND R.can_read = ?"; + $aParams = array($_SESSION["userID"], $oDocument->getID(), true); $sql->query(array($sQuery, $aParams)); if ($sql->next_record()) { return true; diff --git a/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc b/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc index 559386d..004b778 100644 --- a/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/administration/doctypemanagement/editDocTypeFieldsUI.inc @@ -125,7 +125,7 @@ function getFailurePage($sMessage, $iDocTypeID) { function getGenericFieldsList() { global $default; - $aGenericDocumentFields = DocumentField::getList("is_generic=1");/*ok*/ + $aGenericDocumentFields = DocumentField::getList(array("is_generic=?"), array(true)));/*ok*/ for($i = 0; $i < count($aGenericDocumentFields); $i++) { $sToRender .= "
  • " . $aGenericDocumentFields[$i]->getName() . "
  • \n"; } diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc index 52f7ed6..c90236c 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc @@ -73,9 +73,9 @@ function getUploadDocument() { */ function getGenericMetaDataForm() { global $default; - /*ok*/ $sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " . + /*ok*/ $sQuery = array("SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " . "FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " . - "WHERE DF.is_generic = 1 "; + "WHERE DF.is_generic = ? ", array(true)); $aStoreColumnNames = array("document_id", "document_field_id", "value"); $aDisplayColumnNames = array("document_id", "field_name", "value"); @@ -105,8 +105,8 @@ function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) { /*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 " . "FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " . "LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " . - "WHERE DF.is_generic = 0 " . - "AND DTFL.document_type_id = ?", $iDocumentTypeID); + "WHERE DF.is_generic = ? " . + "AND DTFL.document_type_id = ?", array(false, $iDocumentTypeID)); $aStoreColumnNames = array("document_id", "document_field_id", "value"); $aDisplayColumnNames = array("document_id", "field_name", "value"); -- libgit2 0.21.4