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_official / html / modules / categories [ view in CVS ]

Date Directory [filter] File(s) [view] Author [filter]
30 Jul 2002 18:24:05postnuke_official/html/modules/categoriespnuserapi.php,1.4,1.5Mike
 add a leftjoin function to return table, field and where clause

Update of /home/cvsroot/postnuke_official/html/modules/categories
In directory ns7.hostnuke.net:/tmp/cvs-serv5572

Modified Files:
	pnuserapi.php 
Log Message:
add a leftjoin function to return table, field and where clause


Index: pnuserapi.php
===================================================================
RCS file: /home/cvsroot/postnuke_official/html/modules/categories/pnuserapi.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pnuserapi.php	27 Jul 2002 23:48:59 -0000	1.4
--- pnuserapi.php	30 Jul 2002 18:24:02 -0000	1.5
***************
*** 591,593 ****
--- 591,655 ----
  }
  
+ /**
+  * return the correct values for joining on categories table
+  * example : SELECT ...
+  *           FROM ...
+  *           LEFT JOIN $table
+  *               ON $field = <name of itemid field>
+  *           WHERE ...
+  *               AND $where = <module ID>
+  *
+  * @param $args['cids'] array of cids that we are selecting on
+  * @returns array
+  * @return array('table' => 'categories_linkage',
+  *               'field' => 'categories_linkage.pn_iid',
+  *               'where' => 'categories_linkage.pn_cid IN (...)
+  *                           AND categories_linkage.pn_modid'
+  */
+ function categories_userapi_leftjoin($args)
+ {
+     // Get arguments from argument array
+     extract($args);
+ 
+     // Required argument (otherwise you don't need this stuff)
+     if (!isset($cids) || !is_array($cids) || count($cids) == 0) {
+         $msg = pnML('Required parameter #(1) missing','cids');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM',
+                        new SystemException($msg));
+         return array();
+     }
+ 
+     // Security check
+     if (!pnSecAuthAction(0, 'categories::category', '::', ACCESS_OVERVIEW)) {
+         $msg = pnML('Not authorized to view categories');
+         pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
+                        new SystemException($msg));
+         return array();
+     }
+ // TODO: check this !
+     foreach ($cids as $cid) {
+         if (!pnSecAuthAction(0, 'categories::category', 'ID::$cid', ACCESS_OVERVIEW)) {
+             $msg = pnML('Not authorized to view category #(1)',
+                         pnVarPrepForStore($cid));
+             pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION',
+                            new SystemException($msg));
+             return array();
+         }
+     }
+ 
+     // Table definition
+     $pntable = pnDBGetTables();
+     $categorieslinkagetable = $pntable['categories_linkage'];
+     $categorieslinkagecolumn = &$pntable['categories_linkage_column'];
+ 
+     $leftjoin = array();
+     $leftjoin['table'] = $categorieslinkagetable;
+     $leftjoin['field'] = $categorieslinkagecolumn['iid'];
+     $allcids = join(', ', $cids);
+     $leftjoin['where'] = "$categorieslinkagecolumn[cid] IN (" . pnVarPrepForStore($allcids) . ")";
+     $leftjoin['where'] .= " AND $categorieslinkagecolumn[modid] ";
+ 
+     return $leftjoin;
+ }
+ 
  ?>


Directory filter : [ all ] / postnuke_official / html / modules / categories [ 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