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 / groups [ view in CVS ]


Deprecated: Function gmstrftime() is deprecated in /home/mikespub/www/list.php on line 509
Date Directory [filter] File(s) [view] Author [filter]
07 Aug 2002 03:52:36postnuke_official/html/modules/groupspnuserapi.php,NONE,1.1st.ego
 userapi_getall extracted from adminapi_viewallgroups

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

Added Files:
	pnuserapi.php 
Log Message:
userapi_getall extracted from adminapi_viewallgroups
userapi_get extracted from adminapi_viewgroup
TODO - countitems = users in groups or ttl groups?


--- NEW FILE: pnuserapi.php ---
<?php // File: $Id: pnuserapi.php,v 1.1 2002/08/07 03:52:34 st.ego Exp $
// ----------------------------------------------------------------------
// PostNuke Content Management System
// Copyright (C) 2001 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jim McDonald
// Purpose of file: Group admin api
// ----------------------------------------------------------------------

/**
 * viewallgroups - generate all groups listing.
 * @param none
 * @return groups listing of available groups
 */
function groups_userapi_getall()
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();

    $groupstable = $pntable['groups'];

    if (!pnSecAuthAction(0, 'Groups::', "::", ACCESS_EDIT)) {
	pnSessionSetVar('errormsg', _GROUPSNOAUTH);
        return false;
    }

    $groups = array();

    // Get and display current groups
    $query = "SELECT pn_gid,
                     pn_name
              FROM $groupstable
              ORDER BY pn_name";
    $result = $dbconn->Execute($query);

    if($dbconn->ErrorNo() !=0) {
	pnSessionSetVar('errormsg', 'Error getting groups.');
	return false;
    }
    for(; !$result->EOF; $result->MoveNext()) {
		list($gid, $name) = $result->fields;
		    if (pnSecAuthAction(0, 'Groups::', "$name::$gid", ACCESS_OVERVIEW)) {
				$groups[] = array('gid'  => $gid,
								  'name' => $name);
		}
    }
    $result->Close();

    return $groups;
}

/*
 * viewgroup - view users in group
 * @param $args['gid'] group id
 * @return $users array containing uname, uid
 */
function groups_userapi_get($args)
{
    extract($args);

	if(!isset($gid)) {
		pnSessionSetVar('errormsg', _MODARGSERROR);
		return false;
    }

	// NEED TO PULL GROUP NAME FOR SECAUTH CALL
	if (!pnSecAuthAction(0, 'Groups::', "$name::$gid", ACCESS_READ)) {
    	pnSessionSetVar('errormsg', _GROUPSNOAUTH);
        return false;
    }

    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();

    $userstable = $pntable['users'];
    $groupmembership = $pntable['group_membership'];

    $users = array();
    // Get users in this group
    $query = "SELECT pn_uid
              FROM $groupmembership
              WHERE pn_gid=".pnVarPrepForStore($gid)."";
    $result = $dbconn->Execute($query);
    if (!$result->EOF) {
        for(;list($uid) = $result->fields;$result->MoveNext() ) {
            $uids[] = $uid;
        }
        $result->Close();
        $uidlist=implode(",", $uids);

        // Get names of users
        $query = "SELECT pn_uname,
                         pn_uid
                  FROM $userstable
                  WHERE pn_uid IN ($uidlist)
                  ORDER BY pn_uname";
        $result = $dbconn->Execute($query);

        while(list($uname, $uid) = $result->fields) {
            $result->MoveNext();
			$users[] = array('uname' => $uname,
					 'uid'   => $uid);
        }
        $result->Close();
    }
    return $users;
}

/**
 * utility function to count the number of items held by this module
 *
 * @author the Example module development team
 * @returns integer
 * @return number of items held by this module
 * @raise DATABASE_ERROR
 */
function groups_userapi_countitems()
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();

    $groupstable = $pntable['groups'];

    $sql = "SELECT COUNT(1)
            FROM $groupstable";
    $result = $dbconn->Execute($sql);

    if ($dbconn->ErrorNo() != 0) {
        $msg = pnML('Database error for #(1) function #(2)() in module #(3)',
                    'user', 'countitems', 'groups');
        pnExceptionSet(PN_SYSTEM_EXCEPTION, 'DATABASE_ERROR',
                       new SystemException($msg));
        return false;
    }

    list($numitems) = $result->fields;

    $result->Close();

    return $numitems;
}
?>

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