Ensure the 'Create Rule' context menu option is always offered when appropriate.
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Wed, 19 Dec 2007 22:22:08 +0000 (22:22 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Wed, 19 Dec 2007 22:22:08 +0000 (22:22 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@6919 a7884b65-44f6-0310-8a51-81a127f17b15

CHANGELOG
pgadmin/schema/pgSchema.cpp

index 55dd6f77b9a9976ab7780a37d4c612f6e8cca0cb..e00377820ea1084947f7bdc9cb7fd71009048c8f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,8 @@ Changes
 \r
 Date       Dev Ver    Change details\r
 ---------- --- -----  --------------\r
+2007-12-19 DP  1.8.1  Ensure the 'Create Rule' context menu option is always\r
+                      offered when appropriate.\r
 2007-12-19 DP  1.8.1  Prevent the user from trying to debug catalog objects.\r
 2007-12-17 DP  1.8.1  Refresh the tree without erroring after creating a new\r
                       package on EnterpriseDB.\r
index 6cb167662d6bb4f7bcf96b67a6b988de415e53c5..14485c6e5f1150d423fc9a793192f8dd80a59ead 100644 (file)
@@ -406,7 +406,17 @@ bool pgSchemaObjCollection::CanCreate()
        if(IsCollectionForType(PGM_OPCLASS) || IsCollectionForType(PGM_OPFAMILY))
                return false;
 
-    return GetSchema()->GetCreatePrivilege();
+    // TODO
+    // OK, this is a hack. Rules and Views are both derived from pgRuleObject, which
+    // is derived from pgSchemaObject. In order that they attached to the treeview 
+    // under the relevant node however, the Schema object is actually the table or
+    // View (yeah, I know - I didn't write it :-p ). This works fine *except* for
+    // Get CreatePrivilege() which doesn't exist in these classes so must be fixed
+    // up at this level. This needs a major rethink in the longer term
+    if (GetSchema()->GetMetaType() == PGM_TABLE || GetSchema()->GetMetaType() == PGM_VIEW)
+        return GetSchema()->GetSchema()->GetCreatePrivilege();
+    else
+        return GetSchema()->GetCreatePrivilege();
 }