[PHP-CVS] cvs: php4 /ext/midgard article.c element.c page.c pageelement.c topic.c
emile Thu Mar 22 07:11:41 2001 EDT Modified files: /php4/ext/midgard article.c element.c page.c pageelement.c topic.c Log: Added update duplicate checks Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.18 php4/ext/midgard/article.c:1.19 --- php4/ext/midgard/article.c:1.18 Wed Mar 21 06:53:28 2001 +++ php4/ext/midgard/article.c Thu Mar 22 07:11:40 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.18 2001/03/21 14:53:28 emile Exp $ +/* $Id: article.c,v 1.19 2001/03/22 15:11:40 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -556,7 +556,8 @@ RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED); } - if (mgd_exists_id(mgd_handle(), "article", "topic=$d AND name=$q", + /* skip duplicate check for empty names because the name isn't mandatory */ + if ((*name)-value.str.len mgd_exists_id(mgd_handle(), "article", "topic=$d AND +name=$q", (*topic)-value.lval, (*name)-value.str.val)) { RETURN_FALSE_BECAUSE(MGD_ERR_DUPLICATE); } @@ -864,7 +865,8 @@ RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); } - if (mgd_exists_id(mgd_handle(), "article", "topic=$d AND name=$q AND id$d", + /* skip duplicate check for empty names because the name isn't mandatory */ + if ((*name)-value.str.len mgd_exists_id(mgd_handle(), "article", "topic=$d AND +name=$q AND id$d", (*topic)-value.lval, (*name)-value.str.val, (*id)-value.lval)) { RETURN_FALSE_BECAUSE(MGD_ERR_DUPLICATE); } Index: php4/ext/midgard/element.c diff -u php4/ext/midgard/element.c:1.7 php4/ext/midgard/element.c:1.8 --- php4/ext/midgard/element.c:1.7 Sat Mar 10 14:43:10 2001 +++ php4/ext/midgard/element.c Thu Mar 22 07:11:40 2001 @@ -1,4 +1,4 @@ -/* $Id: element.c,v 1.7 2001/03/10 22:43:10 emile Exp $ +/* $Id: element.c,v 1.8 2001/03/22 15:11:40 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -146,6 +146,11 @@ if (!isstyleowner(mgd_idfield(mgd_handle(), "style", "element", (*id)-value.lval))) RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED); + + if (mgd_exists_id(mgd_handle(), "element", "style=$d AND name=$q AND id$d", + mgd_idfield(mgd_handle(), "style", "element", (*id)-value.lval), + (*name)-value.str.val, (*id)-value.lval)) + RETURN_FALSE_BECAUSE(MGD_ERR_DUPLICATE); php_midgard_update(return_value, "element", "name=$q,value=$q", (*id)-value.lval, Index: php4/ext/midgard/page.c diff -u php4/ext/midgard/page.c:1.12 php4/ext/midgard/page.c:1.13 --- php4/ext/midgard/page.c:1.12Sat Mar 10 14:43:10 2001 +++ php4/ext/midgard/page.c Thu Mar 22 07:11:40 2001 @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.12 2001/03/10 22:43:10 emile Exp $ +/* $Id: page.c,v 1.13 2001/03/22 15:11:40 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -255,6 +255,11 @@ if (!mgd_exists_id(mgd_handle(), "person", "id=$d", (*author)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); + + if (mgd_exists_id(mgd_handle(), "page", "up=$d AND name=$q AND id$d", + mgd_idfield(mgd_handle(), "up", "page", (*id)-value.lval), + (*name)-value.str.val, (*id)-value.lval)) + RETURN_FALSE_BECAUSE(MGD_ERR_DUPLICATE); php_midgard_update(return_value, "page", "name=$q,style=$d,title=$q,changed=Curdate()," Index: php4/ext/midgard/pageelement.c diff -u php4/ext/midgard/pageelement.c:1.7 php4/ext/midgard/pageelement.c:1.8 --- php4/ext/midgard/pageelement.c:1.7 Sat Mar 10 14:43:10 2001 +++ php4/ext/midgard/pageelement.c Thu Mar 22 07:11:40 2001 @@ -1,4 +1,4 @@ -/* $Id: pageelement.c,v 1.7 2001/03/10 22:43:10 emile Exp $ +/* $Id: pageelement.c,v 1.8 2001/03/22 15:11:40 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -145,6 +145,11 @@ if (!ispageowner(mgd_idfield(mgd_handle(), "page", "pageelement", (*id)-value.lval))) RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED); + + if (mgd_exists_id(mgd_handle(), "pageelement", "page=$d AND name=$q AND id$d", + mgd_idfield(mgd_handle(), "page", "pageelement", (*id)-value.lval), + (*name)-value.str.val, (*id)-value.lval)) + RETURN_FALSE_BECAUSE(MGD_ERR_DUPLICATE); php_midgard_update(return_value, "pageelement", "name=$q,value=$q,info=$d", (*id)-value.lval, Index: php4/ext/midgard/topic.c diff -u php4/ext/midgard/topic.c:1.12
[PHP-CVS] cvs: php4 /ext/midgard article.c
emile Fri Mar 16 07:01:35 2001 EDT Modified files: /php4/ext/midgard article.c Log: String used as long. Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.16 php4/ext/midgard/article.c:1.17 --- php4/ext/midgard/article.c:1.16 Tue Mar 13 23:57:46 2001 +++ php4/ext/midgard/article.c Fri Mar 16 07:01:35 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.16 2001/03/14 07:57:46 emile Exp $ +/* $Id: article.c,v 1.17 2001/03/16 15:01:35 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -780,6 +780,7 @@ zval **url, **calstart, **caldays, **icon, **view, **print; zval **extra1, **extra2, **extra3; zval **type, **score, **up, *self; + long upval; RETVAL_FALSE; CHECK_MGD; @@ -852,8 +853,11 @@ if (!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*topic)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if (up (*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$d", (*up)-value.lval)) - RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); + if (up) { + upval = atol((*up)-value.str.val); + if (upval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$d", upval)) + RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); + } if (!istopicowner((*topic)-value.lval)) { RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED); -- 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]
[PHP-CVS] cvs: php4 /ext/midgard article.c
emile Tue Mar 13 23:57:46 2001 EDT Modified files: /php4/ext/midgard article.c Log: Test parameter for existance before use. Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.15 php4/ext/midgard/article.c:1.16 --- php4/ext/midgard/article.c:1.15 Mon Mar 12 02:19:37 2001 +++ php4/ext/midgard/article.c Tue Mar 13 23:57:46 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.15 2001/03/12 10:19:37 davidg Exp $ +/* $Id: article.c,v 1.16 2001/03/14 07:57:46 emile Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2000 Emile Heyns, Aurora SA [EMAIL PROTECTED] @@ -852,7 +852,7 @@ if (!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*topic)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if ((*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$d", (*up)-value.lval)) + if (up (*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", +"id=$d", (*up)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); if (!istopicowner((*topic)-value.lval)) { -- 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]
[PHP-CVS] cvs: php4 /ext/midgard article.c
davidg Mon Mar 12 02:19:37 2001 EDT Modified files: /php4/ext/midgard article.c Log: added NULL-check Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.14 php4/ext/midgard/article.c:1.15 --- php4/ext/midgard/article.c:1.14 Fri Mar 9 04:16:57 2001 +++ php4/ext/midgard/article.c Mon Mar 12 02:19:37 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.14 2001/03/09 12:16:57 davidg Exp $ +/* $Id: article.c,v 1.15 2001/03/12 10:19:37 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] @@ -645,7 +645,7 @@ convert_to_long_ex(id); convert_to_long_ex(up); - if ((*up)-value.lval != 0) { + if (up ((*up)-value.lval != 0)) { #if HAVE_MIDGARD_SITEGROUPS if (!mgd_exists_bool(mgd_handle(), "article src, article tgt", "src.id=$d AND tgt.id=$d" -- 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]
[PHP-CVS] cvs: php4 /ext/midgard article.c
davidg Fri Mar 9 04:06:27 2001 EDT Modified files: /php4/ext/midgard article.c Log: Fixed typo. Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.12 php4/ext/midgard/article.c:1.13 --- php4/ext/midgard/article.c:1.12 Thu Mar 8 02:25:15 2001 +++ php4/ext/midgard/article.c Fri Mar 9 04:06:26 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.12 2001/03/08 10:25:15 davidg Exp $ +/* $Id: article.c,v 1.13 2001/03/09 12:06:26 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] @@ -543,13 +543,13 @@ convert_to_string_ex(extra3); convert_to_long_ex(type); - if (!mgd_exists_id(mgd_handle(), "person", "id=$id", (*author)-value.lval)) + if (!mgd_exists_id(mgd_handle(), "person", "id=$d", (*author)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if (!mgd_exists_id(mgd_handle(), "topic", "id=$id", (*topic)-value.lval)) + if (!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*topic)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if ((*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$id", (*up)-value.lval)) + if ((*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$d", +(*up)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); if (!istopicowner((*topic)-value.lval)) { @@ -846,13 +846,13 @@ RETURN_FALSE_BECAUSE(MGD_ERR_ACCESS_DENIED); } - if (!mgd_exists_id(mgd_handle(), "person", "id=$id", (*author)-value.lval)) + if (!mgd_exists_id(mgd_handle(), "person", "id=$d", (*author)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if (!mgd_exists_id(mgd_handle(), "topic", "id=$id", (*topic)-value.lval)) + if (!mgd_exists_id(mgd_handle(), "topic", "id=$d", (*topic)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); - if ((*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$id", (*up)-value.lval)) + if ((*up)-value.lval != 0 !mgd_exists_id(mgd_handle(), "article", "id=$d", +(*up)-value.lval)) RETURN_FALSE_BECAUSE(MGD_ERR_NOT_EXISTS); if (!istopicowner((*topic)-value.lval)) { -- 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]
[PHP-CVS] cvs: php4 /ext/midgard article.c
davidg Fri Mar 9 04:16:58 2001 EDT Modified files: /php4/ext/midgard article.c Log: still a typo Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.13 php4/ext/midgard/article.c:1.14 --- php4/ext/midgard/article.c:1.13 Fri Mar 9 04:06:26 2001 +++ php4/ext/midgard/article.c Fri Mar 9 04:16:57 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.13 2001/03/09 12:06:26 davidg Exp $ +/* $Id: article.c,v 1.14 2001/03/09 12:16:57 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] @@ -480,7 +480,7 @@ MGD_FUNCTION(int, create_article, (int up, int topic, string name, string title, string abstract, - string content, string author, + string +content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, -- 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]
[PHP-CVS] cvs: php4 /ext/midgard article.c mgd_session.h session.c session.sql
davidg Thu Mar 8 02:25:15 2001 EDT Added files: /php4/ext/midgard session.c mgd_session.h session.sql Modified files: /php4/ext/midgard article.c Log: Session management (experimental code) Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.11 php4/ext/midgard/article.c:1.12 --- php4/ext/midgard/article.c:1.11 Tue Mar 6 02:35:02 2001 +++ php4/ext/midgard/article.c Thu Mar 8 02:25:15 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.11 2001/03/06 10:35:02 emile Exp $ +/* $Id: article.c,v 1.12 2001/03/08 10:25:15 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] @@ -770,7 +770,7 @@ MGD_FUNCTION(bool, update_article, (int id, int topic, string name, string title, string abstract, - string content, string author, + string +content, int author, string url, string calstart, int caldays, int icon, int view, int print, string extra1, string extra2, Index: php4/ext/midgard/session.c +++ php4/ext/midgard/session.c /* $Id: session.c,v 1.1 2001/03/08 10:25:15 davidg Exp $ Copyright (C) 1999 Jukka Zitting [EMAIL PROTECTED] Copyright (C) 2000 The Midgard Project ry Copyright (C) 2001 David Guerizec, Aurora SA [EMAIL PROTECTED] This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "php_midgard.h" #if HAVE_MIDGARD #if HAVE_MIDGARD_SESSION #include "php.h" #include "../session/php_session.h" #include "mgd_session.h" #define GET_MGD midgard * mgd = mgd_handle(); typedef struct { int id; int ready; } ps_midgard; ps_module ps_mod_midgard = { PS_MOD(midgard) }; static int ps_midgard_valid_key(const char *key) { size_t len; const char *p; char c; int ret = 1; for (p = key; (c = *p); p++) { /* valid characters are a..z,A..Z,0..9 */ if (!((c = 'a' c = 'z') || (c = 'A' c = 'Z') || (c = '0' c = '9'))) { ret = 0; break; } } len = p - key; if (len == 0) ret = 0; return ret; } static int ps_midgard_write(ps_midgard * data, const char * key, const char * val) { GET_MGD; if(!data-ready) return FAILURE; if(data-id) { if(mgd_update(mgd, "session", data-id, "sess_data='$s', " "expire=UNIX_TIMESTAMP() + 3600, " "changed=UNIX_TIMESTAMP()", val)) return SUCCESS; assert(0); } else { if((data-id = mgd_create(mgd, "session", "sess_key, sess_data, person, expire, changed", "$q, $q, $d, UNIX_TIMESTAMP() + 3600, UNIX_TIMESTAMP()", key, val, mgd_user(mgd return SUCCESS; assert(0); } return FAILURE; } static void ps_midgard_open(ps_midgard *data, const char *key) { GET_MGD; if(data-id) { php_error(E_WARNING, "Called twice ??"); } data-id = 0; if(!mgd) { php_error(E_WARNING, "Midgard is not ready yet for session management," " please come back later..."); return; } if(!ps_midgard_valid_key(key)) return; data-id = mgd_exists_id(mgd, "session", "sess_key=$q AND
[PHP-CVS] cvs: php4 /ext/midgard article.c attachment.c calendar.c element.c event.c eventmember.c file.c group.c host.c image.c mail.c member.c mgd_article.h mgd_attachment.h mgd_calendar.h mgd_element.h mgd_event.h mgd_eventmember.h mgd_file.h mgd_group.h mgd_host.h mgd_image.h mgd_internal.h mgd_mail.h mgd_member.h mgd_oop.h mgd_page.h mgd_pageelement.h mgd_pagelink.h mgd_person.h mgd_preferences.h mgd_preparser.h mgd_sitegroup.h mgd_snippet.h mgd_snippetdir.h mgd_style.h mgd_topic.h midgard.c oop.c page.c pageelement.c pagelink.c parameter.c person.c preferences.c preparser.c sitegroup.c snippet.c snippetdir.c style.c topic.c
davidg Tue Feb 27 17:00:40 2001 EDT Modified files: /php4/ext/midgard article.c attachment.c calendar.c element.c event.c eventmember.c file.c group.c host.c image.c mail.c member.c mgd_article.h mgd_attachment.h mgd_calendar.h mgd_element.h mgd_event.h mgd_eventmember.h mgd_file.h mgd_group.h mgd_host.h mgd_image.h mgd_internal.h mgd_mail.h mgd_member.h mgd_oop.h mgd_page.h mgd_pageelement.h mgd_pagelink.h mgd_person.h mgd_preferences.h mgd_preparser.h mgd_sitegroup.h mgd_snippet.h mgd_snippetdir.h mgd_style.h mgd_topic.h midgard.c oop.c page.c pageelement.c pagelink.c parameter.c person.c preferences.c preparser.c sitegroup.c snippet.c snippetdir.c style.c topic.c Log: First step towards automatic documentation Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.9 php4/ext/midgard/article.c:1.10 --- php4/ext/midgard/article.c:1.9 Sun Feb 25 11:31:17 2001 +++ php4/ext/midgard/article.c Tue Feb 27 17:00:31 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.9 2001/02/25 19:31:17 davidg Exp $ +/* $Id: article.c,v 1.10 2001/02/28 01:00:31 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] @@ -22,14 +22,14 @@ #include "mgd_oop.h" #include "mgd_article.h" -MGD_FUNCTION(is_article_owner) +MGD_FUNCTION(bool, is_article_owner, (int id)) { IDINIT; CHECK_MGD; RETVAL_LONG(isarticleowner(id)); } -MGD_FUNCTION(is_article_in_topic_tree) +MGD_FUNCTION(bool, is_article_in_topic_tree, (int topic_root, int id)) { zval **root, **article; @@ -103,7 +103,7 @@ return sort[i].sort; } -MGD_FUNCTION(list_topic_articles) +MGD_FUNCTION(mixed, list_topic_articles, (int id, [string sort, [int type, [int +up]]])) { const char *sortv = NULL; int typev = 0; @@ -177,7 +177,7 @@ up_wild); } -MGD_FUNCTION(list_reply_articles) +MGD_FUNCTION(mixed, list_reply_articles, (int id)) { IDINIT; CHECK_MGD; @@ -187,7 +187,7 @@ "article.created DESC", id); } -MGD_FUNCTION(list_topic_articles_all) +MGD_FUNCTION(mixed, list_topic_articles_all, (int id, [string sort, [int type, [int +up]]])) { int *topics; const char *sortv = NULL; @@ -268,7 +268,7 @@ } } -MGD_FUNCTION(list_topic_articles_all_fast) +MGD_FUNCTION(mixed, list_topic_articles_all_fast, (int id, [string sort, [int type, +[int up]]])) { int *topics; const char *sortv = NULL; @@ -347,7 +347,7 @@ } } -MGD_FUNCTION(list_topic_articles_all_of_person) +MGD_FUNCTION(mixed, list_topic_articles_all_of_person, (int topic, int person)) { int *topics; zval **topic, **person; @@ -373,7 +373,7 @@ } } -MGD_FUNCTION(get_article) +MGD_FUNCTION(mixed, get_article, ([int id])) { zval **id; CHECK_MGD; @@ -403,7 +403,7 @@ php_midgard_get_object(return_value, MIDGARD_OBJECT_ARTICLE, (*id)-value.lval); } -MGD_FUNCTION(get_article_by_name) +MGD_FUNCTION(mixed, get_article_by_name, ([int topic, string name])) { zval **id, **name; CHECK_MGD; @@ -446,7 +446,7 @@ (*id)-value.lval, (*name)-value.str.val); } -MGD_FUNCTION(get_reply_by_name) +MGD_FUNCTION(mixed, get_reply_by_name, ([int article, string name])) { zval **id, **name; CHECK_MGD; @@ -478,7 +478,13 @@ (*id)-value.lval, (*name)-value.str.val); } -MGD_FUNCTION(create_article) +MGD_FUNCTION(int, create_article, (int up, int topic, string name, + string title, +string abstract, + string +content, string author, + string url, +string calstart, + int caldays, +int icon, int view, + int print, +string extra1, string extra2, + string extra3, +int type)) { zval **up, **topic, **name, **title, **abstract, **content, **author; zval **url, **calstart, **caldays, **icon, **view, **print; @@ -592,7 +598,7 @@ PHP_CREATE_REPLIGARD("article", return_value-value.lval); } -MGD_FUNCTION(update_article_score) +MGD_FUNCTION(bool, update_article_score, (int id, int score)) {
[PHP-CVS] cvs: php4 /ext/midgard article.c calendar.c event.c person.c topic.c
davidg Sat Feb 24 05:39:30 2001 EDT Modified files: /php4/ext/midgard article.c calendar.c event.c person.c topic.c Log: fixed some possible memory leaks. Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.7 php4/ext/midgard/article.c:1.8 --- php4/ext/midgard/article.c:1.7 Thu Feb 22 09:39:37 2001 +++ php4/ext/midgard/article.c Sat Feb 24 05:39:30 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.7 2001/02/22 17:39:37 davidg Exp $ +/* $Id: article.c,v 1.8 2001/02/24 13:39:30 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] @@ -59,12 +59,14 @@ ids = mgd_tree(mgd_handle(), "topic", "up", (*root)-value.lval, 0, NULL); if (ids) { - id = - mgd_idfield(mgd_handle(), "topic", "article", + id = mgd_idfield(mgd_handle(), "topic", "article", (*article)-value.lval); for (i = 0; ids[i]; i++) - if (ids[i] == id) + if (ids[i] == id) { + free(ids); RETURN_TRUE; + } + free(ids); } } @@ -254,21 +256,24 @@ topics = mgd_tree(mgd_handle(), "topic", "up", (*id)-value.lval, 0, NULL); - if (typev == -1) - php_midgard_select(MidgardArticle, return_value, - ARTICLE_SELECT, - ARTICLE_FROM, - "article.topic IN $D AND author=person.id" - " AND (article.up=$d OR 1=$d)", - sortv, topics, up, up_wild); - else - php_midgard_select(MidgardArticle, return_value, - ARTICLE_SELECT, - ARTICLE_FROM, - "article.type=$d AND article.topic IN $D" - " AND (article.up=$d OR 1=$d)" - " AND author=person.id", - sortv, typev, topics, up, up_wild); + if(topics) { + if (typev == -1) + php_midgard_select(MidgardArticle, return_value, + ARTICLE_SELECT, + ARTICLE_FROM, + "article.topic IN $D AND author=person.id" + " AND (article.up=$d OR 1=$d)", + sortv, topics, up, up_wild); + else + php_midgard_select(MidgardArticle, return_value, + ARTICLE_SELECT, + ARTICLE_FROM, + "article.type=$d AND article.topic IN $D" + " AND (article.up=$d OR 1=$d)" + " AND author=person.id", + sortv, typev, topics, up, up_wild); + free(topics); + } } MGD_FUNCTION(list_topic_articles_all_fast) @@ -331,20 +336,23 @@ topics = mgd_tree(mgd_handle(), "topic", "up", (*id)-value.lval, 0, NULL); - if (typev == -1) - php_midgard_select(MidgardArticle, return_value, - ARTICLE_SELECT_FAST, - ARTICLE_FROM_FAST, - "article.topic IN $D" - " AND (article.up=$d OR 1=$d)", - sortv, topics, up, up_wild); - else - php_midgard_select(MidgardArticle, return_value, - ARTICLE_SELECT_FAST, - ARTICLE_FROM_FAST, - "article.type=$d AND article.topic IN $D" - " AND (article.up=$d OR 1=$d)", - sortv, typev, topics, up, up_wild); + if(topics) { + if (typev == -1) + php_midgard_select(MidgardArticle, return_value, + ARTICLE_SELECT_FAST, + ARTICLE_FROM_FAST, + "article.topic IN $D" + " AND (article.up=$d OR 1=$d)", + sortv, topics, up, up_wild); + else + php_midgard_select(MidgardArticle, return_value, + ARTICLE_SELECT_FAST, + ARTICLE_FROM_FAST, + "article.type=$d AND article.topic IN $D" +
[PHP-CVS] cvs: php4 /ext/midgard article.c mgd_article.h mgd_internal.h mgd_midgard.h mgd_page.h mgd_snippetdir.h mgd_style.h mgd_topic.h midgard.c page.c snippetdir.c style.c topic.c
davidg Tue Feb 20 16:24:56 2001 EDT Removed files: /php4/ext/midgard mgd_midgard.h Modified files: /php4/ext/midgard article.c mgd_article.h mgd_internal.h mgd_page.h mgd_snippetdir.h mgd_style.h mgd_topic.h midgard.c page.c snippetdir.c style.c topic.c Log: mgd_walk_xxx_tree() functions implemented. Index: php4/ext/midgard/article.c diff -u php4/ext/midgard/article.c:1.4 php4/ext/midgard/article.c:1.5 --- php4/ext/midgard/article.c:1.4 Mon Feb 19 07:50:20 2001 +++ php4/ext/midgard/article.c Tue Feb 20 16:24:56 2001 @@ -1,4 +1,4 @@ -/* $Id: article.c,v 1.4 2001/02/19 15:50:20 davidg Exp $ +/* $Id: article.c,v 1.5 2001/02/21 00:24:56 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] @@ -991,6 +991,8 @@ MGD_MOVE_FUNCTION(article, topic, article, topic) MGD_MOVE_FUNCTION(article, article, reply, up) + +MGD_WALK_FUNCTION(article) MidgardProperty MidgardArticleProperties [] = { { IS_LONG, "up"}, Index: php4/ext/midgard/mgd_article.h diff -u php4/ext/midgard/mgd_article.h:1.3 php4/ext/midgard/mgd_article.h:1.4 --- php4/ext/midgard/mgd_article.h:1.3 Sat Feb 17 15:21:50 2001 +++ php4/ext/midgard/mgd_article.h Tue Feb 20 16:24:56 2001 @@ -1,4 +1,4 @@ -/* $Id: mgd_article.h,v 1.3 2001/02/17 23:21:50 emile Exp $ +/* $Id: mgd_article.h,v 1.4 2001/02/21 00:24:56 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] @@ -45,5 +45,6 @@ extern MGD_FUNCTION(copy_reply); extern MGD_FUNCTION(move_reply); extern MGD_FUNCTION(delete_article_tree); +extern MGD_FUNCTION(walk_article_tree); #endif Index: php4/ext/midgard/mgd_internal.h diff -u php4/ext/midgard/mgd_internal.h:1.3 php4/ext/midgard/mgd_internal.h:1.4 --- php4/ext/midgard/mgd_internal.h:1.3 Sat Feb 17 15:21:50 2001 +++ php4/ext/midgard/mgd_internal.h Tue Feb 20 16:24:56 2001 @@ -1,4 +1,4 @@ -/* $Id: mgd_internal.h,v 1.3 2001/02/17 23:21:50 emile Exp $ +/* $Id: mgd_internal.h,v 1.4 2001/02/21 00:24:56 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] @@ -112,67 +112,49 @@ PHP_UPDATE_REPLIGARD(#roottable, (*root)-value.lval); \ } +void midgard_user_call_func(midgard *mgd, int id, int level, void * xparam); + #define MGD_WALK_FUNCTION(table) \ /* {{{ proto void walk_ ## table ## _tree(string func, id, level, xparam[, order]) \ */ \ MGD_FUNCTION(walk_ ## table ## _tree) \ { \ - zval **id, **level, **xparam, **order; \ - zval **old_user_func; \ - midgard_tree *tree; int mlevel, i; \ - TLS_VARS; \ + zval **id, **level, **xparam, *xp[2], **order; \ + zval **midgard_user_call_func_name; \ + CHECK_MGD; \ \ - old_user_func = midgard_user_call_func_name; \ switch (ZEND_NUM_ARGS()) { \ case 5: \ if (zend_get_parameters_ex(5, midgard_user_call_func_name, id, \ level, xparam, order) == FAILURE) { \ - midgard_user_call_func_name = old_user_func; \ WRONG_PARAM_COUNT; \ } \ break; \ case 4: \ if (zend_get_parameters_ex(4, midgard_user_call_func_name, id, \ level, xparam) == FAILURE) { \ - midgard_user_call_func_name = old_user_func; \ WRONG_PARAM_COUNT; \ } else { \ order = NULL; \ } \ break; \ default: \ - midgard_user_call_func_name = old_user_func; \ WRONG_PARAM_COUNT; \ break; \ }\ \ - convert_to_string_ex(midgard_user_call_func_name); \ + convert_to_string_ex(midgard_user_call_func_name); \ convert_to_long_ex(level); \ if (order) convert_to_long_ex(order); \ convert_to_long_ex(id); \ -\ - tree = mgd_tree_build(mgd_handle(), #table, mlevel, NULL); \ \ - if (!tree) { \ - RETURN_FALSE_BECAUSE(MGD_ERR_ERROR); \ - } \ - /* Be aware of top level trees */ \ - if ((*id)-value.lval == 0) { \ - i = 0; \ - while (tree[i].id) { \ - walktree(tree, order ? (*order)-value.lval : 1, i, 0, \ -(*level)-value.lval ? (*level)-value.lval : mlevel, xparam); \ - i += tree[i].cn; \ - } \ - } else { \ - /* Traverse regular sub tree */ \ - i = mgd_tree_find(tree, id-value.lval); \ - if (i != -1) \ - walktree(tree, order ? (*order)-value.lval : 1, i, tree[i].lv-1, \ - (*level)-value.lval ? (*level)-value.lval : mlevel, xparam); \ - } \ - free(tree); \ - midgard_user_call_func_name = old_user_func; \ + xp[0] = (*xparam); \ + xp[1] = (*midgard_user_call_func_name); \ +
[PHP-CVS] cvs: php4 /ext/midgard article.c page.c topic.c
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.3Sat Feb 17