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 NoticeDirectory filter : [ all ] / postnuke_official / html / modules / users [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
30 Jul 2002 22:15:51 | postnuke_official/html/modules/users | pnuserapi.php,1.6,1.7 | Mike |
add leftjoin function to return LEFT JOIN ... ON ... [WHERE ...] parts of a query |
Update of /home/cvsroot/postnuke_official/html/modules/users In directory ns7.hostnuke.net:/tmp/cvs-serv6563 Modified Files: pnuserapi.php Log Message: add leftjoin function to return LEFT JOIN ... ON ... [WHERE ...] parts of a query Index: pnuserapi.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/modules/users/pnuserapi.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pnuserapi.php 30 Apr 2002 10:40:16 -0000 1.6 --- pnuserapi.php 30 Jul 2002 22:15:49 -0000 1.7 *************** *** 217,219 **** } ! ?> \ No newline at end of file --- 217,294 ---- } ! /** ! * return the field names and correct values for joining on users table ! * example : SELECT ..., $name, $email,... ! * FROM ... ! * LEFT JOIN $table ! * ON $field = <name of userid field> ! * WHERE ... ! * AND $email LIKE '%postnuke.com' ! * AND $where ! * ! * @param $args['uids'] optional array of uids that we are selecting on ! * @returns array ! * @return array('table' => 'nuke_users', ! * 'field' => 'nuke_users.pn_uid', ! * 'where' => 'nuke_users.pn_uid IN (...)', ! * 'name' => 'nuke_users.pn_name', ! * ... ! * 'email' => 'nuke_users.pn_email') ! */ ! function users_userapi_leftjoin($args) ! { ! // Get arguments from argument array ! extract($args); ! ! // Optional argument ! if (!isset($uids)) { ! $uids = array(); ! } ! ! // Security check ! if (!pnSecAuthAction(0, 'users::', '::', ACCESS_OVERVIEW)) { ! $msg = pnML('Not authorized to view #(1)', ! 'users'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION', ! new SystemException($msg)); ! return array(); ! } ! // TODO: check this ! ! foreach ($uids as $uid) { ! if (!pnSecAuthAction(0, 'users::', "::$uid", ACCESS_READ)) { ! $msg = pnML('Not authorized to view #(1) #(2)', ! 'user',pnVarPrepForStore($uid)); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'NO_PERMISSION', ! new SystemException($msg)); ! return array(); ! } ! } ! ! // Table definition ! $pntable = pnDBGetTables(); ! $userstable = $pntable['users']; ! ! $leftjoin = array(); ! ! // Specify LEFT JOIN ... ON ... [WHERE ...] parts ! $leftjoin['table'] = $userstable; ! $leftjoin['field'] = $userstable . '.pn_uid'; ! if (count($uids) > 0) { ! $alluids = join(', ', $uids); ! $leftjoin['where'] = $userstable . '.pn_uid IN (' . ! pnVarPrepForStore($alluids) . ')'; ! } else { ! $leftjoin['where'] = ''; ! } ! ! // Add available columns in the users table ! // note : we forget about pass and auth_module for now :-) ! $columns = array('uid','uname','name','email','url'); ! foreach ($columns as $column) { ! $leftjoin[$column] = $userstable . '.pn_' . $column; ! } ! ! return $leftjoin; ! } ! ! ?>
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 |