davidg          Mon Feb 19 07:50:20 2001 EDT

  Modified files:              
    /php4/ext/midgard   article.c page.c topic.c 
  Log:
  fixed bug #81, for more details, see:
  http://www.midgard-project.org/bugs/?id=81
  
  
  
Index: php4/ext/midgard/article.c
diff -u php4/ext/midgard/article.c:1.3 php4/ext/midgard/article.c:1.4
--- php4/ext/midgard/article.c:1.3      Sat Feb 17 15:21:49 2001
+++ php4/ext/midgard/article.c  Mon Feb 19 07:50:20 2001
@@ -1,4 +1,4 @@
-/* $Id: article.c,v 1.3 2001/02/17 23:21:49 emile Exp $
+/* $Id: article.c,v 1.4 2001/02/19 15:50:20 davidg Exp $
 Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]>
 Copyright (C) 2000 The Midgard Project ry
 Copyright (C) 2000 Emile Heyns, Aurora SA <[EMAIL PROTECTED]>
@@ -42,6 +42,16 @@
        convert_to_long_ex(root);
        convert_to_long_ex(article);
 
+       if((*article)->value.lval == 0 || /* useless to waste time if article=0 */
+                               !mgd_exists_id(mgd_handle(),
+                                               "article", "id=$d",
+                                               (*article)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+       if ((*root)->value.lval == 0)
+               RETURN_TRUE; /* always true if topic = 0 */
+       if(!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*root)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+
 #if 0
        if (!isarticlereader((*article)->value.lval))
                return;
@@ -534,6 +544,10 @@
        convert_to_string_ex(extra3);
        convert_to_long_ex(type);
 
+       /* author must NOT be 0 */
+       if (!(*author)->value.lval)
+      RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+
        if (!istopicowner((*topic)->value.lval)) {
                RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED);
    }
@@ -555,12 +569,11 @@
                                                                   ()))) {
       RETURN_FALSE_BECAUSE(MGD_ERR_SITEGROUP_VIOLATION);
    }
-       /* author must be in same SG or be 0 */
-       if ((*author)->value.lval != 0 && !mgd_exists_id(mgd_handle(), "person",
+       /* author must be in same SG */
+       if (!mgd_exists_id(mgd_handle(), "person",
                                                      "id=$d AND sitegroup IN (0,$d)",
                                                      (*author)->value.lval,
-                                                     mgd_sitegroup(mgd_handle
-                                                                   ()))) {
+                                                     mgd_sitegroup(mgd_handle()))) {
       RETURN_FALSE_BECAUSE(MGD_ERR_SITEGROUP_VIOLATION);
    }
 #endif
@@ -840,6 +853,10 @@
        convert_to_string_ex(extra2);
        convert_to_string_ex(extra3);
 
+       /* author must NOT be 0 */
+       if (!(*author)->value.lval)
+      RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+       
        /* EEH: conversion to string is intentional, see update code */
        if (type)
                convert_to_string_ex(type);
@@ -865,9 +882,8 @@
                RETURN_FALSE_BECAUSE(MGD_ERR_SITEGROUP_VIOLATION);
    }
 
-       /* author must be in same SG or be 0 */
-       if ((*author)->value.lval != 0
-           && !mgd_exists_bool(mgd_handle(), "article,person",
+       /* author must be in same SG */
+       if (!mgd_exists_bool(mgd_handle(), "article,person",
                           "article.id=$d AND person.id=$d"
                           " AND (article.sitegroup=person.sitegroup"
                           " OR article.sitegroup=0" " OR person.sitegroup=0)",
Index: php4/ext/midgard/page.c
diff -u php4/ext/midgard/page.c:1.3 php4/ext/midgard/page.c:1.4
--- php4/ext/midgard/page.c:1.3 Sat Feb 17 15:21:50 2001
+++ php4/ext/midgard/page.c     Mon Feb 19 07:50:20 2001
@@ -1,4 +1,4 @@
-/* $Id: page.c,v 1.3 2001/02/17 23:21:50 emile Exp $
+/* $Id: page.c,v 1.4 2001/02/19 15:50:20 davidg Exp $
 Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]>
 Copyright (C) 2000 The Midgard Project ry
 Copyright (C) 2000 Emile Heyns, Aurora SA <[EMAIL PROTECTED]>
@@ -79,6 +79,16 @@
        WRONG_PARAM_COUNT;
     convert_to_long_ex(root);
     convert_to_long_ex(page);
+
+       if((*page)->value.lval == 0 || /* useless to waste time if page=0 */
+                               !mgd_exists_id(mgd_handle(),
+                                               "page", "id=$d",
+                                               (*page)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+       if ((*root)->value.lval == 0)
+               RETURN_TRUE; /* always true if root=0 */
+       if(!mgd_exists_id(mgd_handle(), "page", "id=$d", (*root)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
 
     ids = mgd_tree(mgd_handle(), "page", (*root)->value.lval, 0, NULL);
        if (ids)
Index: php4/ext/midgard/topic.c
diff -u php4/ext/midgard/topic.c:1.3 php4/ext/midgard/topic.c:1.4
--- php4/ext/midgard/topic.c:1.3        Sat Feb 17 15:21:50 2001
+++ php4/ext/midgard/topic.c    Mon Feb 19 07:50:20 2001
@@ -1,4 +1,4 @@
-/* $Id: topic.c,v 1.3 2001/02/17 23:21:50 emile Exp $
+/* $Id: topic.c,v 1.4 2001/02/19 15:50:20 davidg Exp $
 Copyright (C) 1999 Jukka Zitting <[EMAIL PROTECTED]>
 Copyright (C) 2000 The Midgard Project ry
 Copyright (C) 2000 Emile Heyns, Aurora SA <[EMAIL PROTECTED]>
@@ -113,6 +113,15 @@
        convert_to_long_ex(root);
        convert_to_long_ex(topic);
 
+       if((*topic)->value.lval == 0 || /* useless to waste time if topic=0 */
+                               !mgd_exists_id(mgd_handle(),
+                                               "topic", "id=$d",
+                                               (*topic)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
+       if ((*root)->value.lval == 0)
+               RETURN_TRUE; /* always true if root=0 */
+       if(!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*root)->value.lval))
+               RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS);
 #if 0
        if (!istopicreader((*topic)->value.lval))
                return;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to