Xaraya / Postnuke CVS Notices - Message

Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites

View Statistics - Next Notice - Previous Notice

Directory filter : [ all ] / postnuke_modules / articles [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
13 Aug 2002 22:14:50postnuke_modules/articlespnuserapi.php,1.37,1.38Mike
 support AND-ing of categories for article selection/counting

Update of /home/cvsroot/postnuke_modules/articles
In directory ns7.hostnuke.net:/tmp/cvs-serv12830

Modified Files:
	pnuserapi.php 
Log Message:
support AND-ing of categories for article selection/counting


Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_modules/articles/pnuserapi.php,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** pnuserapi.php	11 Aug 2002 00:02:51 -0000	1.37
--- pnuserapi.php	13 Aug 2002 22:14:48 -0000	1.38
***************
*** 53,58 ****
   * @param $args['ptid'] publication type ID (for news, sections, reviews, ...)
   * @param $args['status'] array of requested status(es) for the articles
!  * @param $args['cids'] array of category IDs for which to get articles
   *                      (for all categories don�t set it)
   * @param $args['startdate'] articles published at startdate or later
   *                           (unix timestamp format)
--- 53,60 ----
   * @param $args['ptid'] publication type ID (for news, sections, reviews, ...)
   * @param $args['status'] array of requested status(es) for the articles
!  * @param $args['cids'] array of category IDs for which to get articles (OR)
   *                      (for all categories don�t set it)
+ // TODO : better name for params
+  * @param $args['andcids'] array of category IDs for which to get articles (AND)
   * @param $args['startdate'] articles published at startdate or later
   *                           (unix timestamp format)
***************
*** 77,80 ****
--- 79,85 ----
          $cids = array();
      }
+     if (empty($andcids)) {
+         $andcids = array();
+     }
  
      // Available fields in articles (for now)
***************
*** 108,112 ****
      $required['title'] = 1;
      // force cids as required when categories are given
!     if (count($cids) > 0) {
          $required['cids'] = 1;
      }
--- 113,117 ----
      $required['title'] = 1;
      // force cids as required when categories are given
!     if (count($cids) > 0 || count($andcids) > 0) {
          $required['cids'] = 1;
      }
***************
*** 145,148 ****
--- 150,154 ----
          $categoriesdef = pnModAPIFunc('categories','user','leftjoin',
                                        array('cids' => $cids,
+                                             'andcids' => $andcids,
                                              'modid' =>
                                                pnModGetIDFromName('articles')));
***************
*** 188,192 ****
  
          // add this for SQL compliance when there are multiple JOINs
!         if (!empty($required['counter']) || count($cids) > 0) {
              $from = '(' . $from . ')';
          }
--- 194,199 ----
  
          // add this for SQL compliance when there are multiple JOINs
!         if (!empty($required['counter']) || count($cids) > 0 ||
!                 count($andcids) > 0) {
              $from = '(' . $from . ')';
          }
***************
*** 198,202 ****
  
          // add this for SQL compliance when there are multiple JOINs
!         if (count($cids) > 0) {
              $from = '(' . $from . ')';
          }
--- 205,209 ----
  
          // add this for SQL compliance when there are multiple JOINs
!         if (count($cids) > 0 || count($andcids) > 0) {
              $from = '(' . $from . ')';
          }
***************
*** 206,209 ****
--- 213,220 ----
          $from .= ' LEFT JOIN ' . $categoriesdef['table'];
          $from .= ' ON ' . $categoriesdef['field'] . ' = ' . $articlesdef['aid'];
+         if (!empty($categoriesdef['more'])) {
+             $from = '(' . $from . ')';
+             $from .= $categoriesdef['more'];
+         }
      }
      $sql .= ' FROM ' . $from;
***************
*** 219,223 ****
          $where[] = $hitcountdef['where'];
      }
!     if (count($cids) > 0) {
          // we rely on leftjoin() to create the necessary categories clauses
          $where[] = $categoriesdef['where'];
--- 230,234 ----
          $where[] = $hitcountdef['where'];
      }
!     if (count($cids) > 0 || count($andcids) > 0) {
          // we rely on leftjoin() to create the necessary categories clauses
          $where[] = $categoriesdef['where'];
***************
*** 485,490 ****
   *
   * @param $args['status'] array of requested status(es) for the articles
-  * @param $args['cids'] array of category IDs
   * @param $args['ptid'] publication type ID
   * @param $args['reverse'] default is ptid => cid, reverse (1) is cid => ptid
   * @returns array
--- 496,503 ----
   *
   * @param $args['status'] array of requested status(es) for the articles
   * @param $args['ptid'] publication type ID
+  * @param $args['cids'] array of category IDs (OR)
+  * @param $args['andcids'] array of category IDs (AND), or
+  * @param $args['numcids'] number of categories to group by (AND)
   * @param $args['reverse'] default is ptid => cid, reverse (1) is cid => ptid
   * @returns array
***************
*** 527,531 ****
              FROM '. $articlesdef['table'] . '
              LEFT JOIN ' . $categoriesdef['table'] .'
!             ON '. $categoriesdef['field'] . ' = ' . $articlesdef['field'] .'
              WHERE '. $categoriesdef['where'] .' AND '. $articlesdef['where'] .'
              GROUP BY '. $articlesdef['pubtypeid'] .', '. $categoriesdef['cid'];
--- 540,545 ----
              FROM '. $articlesdef['table'] . '
              LEFT JOIN ' . $categoriesdef['table'] .'
!             ON '. $categoriesdef['field'] . ' = ' . $articlesdef['field'] .
!             $categoriesdef['more'] . '
              WHERE '. $categoriesdef['where'] .' AND '. $articlesdef['where'] .'
              GROUP BY '. $articlesdef['pubtypeid'] .', '. $categoriesdef['cid'];
***************
*** 545,549 ****
      }
      while (!$result->EOF) {
!         list($ptid, $cid, $count) = $result->fields;
          if (empty($args['reverse'])) {
              $pubcatcount[$ptid][$cid] = $count;
--- 559,569 ----
      }
      while (!$result->EOF) {
!         // we may have 1 or more cid fields here, depending on what we're
!         // counting (cfr. AND in categories)
!         $fields = $result->fields;
!         $ptid = array_shift($fields);
!         $count = array_pop($fields);
! // TODO: use multi-level array for multi-category grouping ?
!         $cid = join('+',$fields);
          if (empty($args['reverse'])) {
              $pubcatcount[$ptid][$cid] = $count;
***************
*** 644,648 ****
   * count number of items depending on additional module criteria
   *
!  * @param $args['cids'] array of cids that we are counting for
   *
   * @param $args['authorid'] the ID of the author
--- 664,669 ----
   * count number of items depending on additional module criteria
   *
!  * @param $args['cids'] array of cids that we are counting for (OR)
!  * @param $args['andcids'] array of cids that we are counting for (AND)
   *
   * @param $args['authorid'] the ID of the author
***************
*** 671,676 ****
      $sql .= ' FROM ' . $articlesdef['table'];
  
!     if (!empty($args['cids']) && is_array($args['cids'])
!         && count($args['cids']) > 0) {
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
--- 692,702 ----
      $sql .= ' FROM ' . $articlesdef['table'];
  
!     if (!isset($args['cids'])) {
!         $args['cids'] = array();
!     }
!     if (!isset($args['andcids'])) {
!         $args['andcids'] = array();
!     }
!     if (count($args['cids']) > 0 || count($args['andcids']) > 0) {
          // Load API
          if (!pnModAPILoad('categories', 'user')) {
***************
*** 682,693 ****
          }
          // Get the LEFT JOIN ... ON ...  and WHERE (!) parts from categories
!         $categoriesdef = pnModAPIFunc('categories','user','leftjoin',
!                                       array('cids' => $args['cids'],
!                                             'modid' =>
!                                                pnModGetIDFromName('articles')));
  
          $sql .= ' LEFT JOIN ' . $categoriesdef['table'];
          $sql .= ' ON ' . $categoriesdef['field'] . ' = '
                  . $articlesdef['aid'];
          $docid = 1;
      }
--- 708,718 ----
          }
          // Get the LEFT JOIN ... ON ...  and WHERE (!) parts from categories
!         $args['modid'] = pnModGetIDFromName('articles');
!         $categoriesdef = pnModAPIFunc('categories','user','leftjoin',$args);
  
          $sql .= ' LEFT JOIN ' . $categoriesdef['table'];
          $sql .= ' ON ' . $categoriesdef['field'] . ' = '
                  . $articlesdef['aid'];
+         $sql .= $categoriesdef['more'];
          $docid = 1;
      }


Directory filter : [ all ] / postnuke_modules / articles [ view in CVS ]

View Statistics - Next Notice - Previous Notice


Visit Developer Site - Browse CVS Repository Syndicate via backend.rss
(max. once per hour please)
Powered by CVSNotice 0.1.3