List Info

Thread: module users/groups api pws1.0




module users/groups api pws1.0
user name
2006-12-30 12:11:10
Fighting (with? against?) users/groups api of pws1.0, please
Matt would 
you kindly look to my code, because the doc about module
users is 
nothing until now. The function calls all defined groups and
wants to 
show the members usernames of each group.

*****

	function atMembers() {
	  // touching module users api, show the list of members
       PHPWS_Core::initModClass('users', 'Action.php');
	  // get an array of all groups
       $grplist=User_Action::getGroups('group',array());
	  $content='<pre>';
	  // working with the group object
	  $ug = & new PHPWS_Group('users');
	  // run thru the group list array
	  foreach ($grplist as $id=>$group) {
	    // show the group name
	    $content.=$group.' (id:'.$id.')<br />';
		// set the current group id to the group object
		$ug->setId($id);
		// get an array (in the object) of uids who are members of
the group
		$ug->loadMembers();
		// get the array here
		$m=$ug->getMembers();
		// run thru the array of member uids
		if (is_array($m)) {
		  foreach ($m as $k=>$uid) {
		    $us = & new PHPWS_User('users');
			$us->PHPWS_User($uid);
		    // get the username of the uid
		    $memname=$us->getUsername();
			// username null is group (recursion required to solve
...)
			if (is_null($memname)) {
			  $memname='n u l l';
			}
		    $content.='* '.$memname.' (id:'.$uid.')'.'<br
/>';
		  }
		} else {
		  $content.='* no members in group<br />';
		}
	  }
	 
$this->feedContent('MemberList',$content.'</pre>');
	}

*****

The result of the code is (as intended):

grpa (id:3)
* pre1 (id:2)
* n u l l (id:4)
grpb (id:4)
* n u l l (id:5)
grpc (id:5)
* pre (id:1)
grpd (id:6)
* no members in group

I think, the code looks a bit awkward, but works. Is there
are ways more 
simple?
regards, Hilmar

------------------------------------------------------------
-------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys -
and earn cash
http://www.techsay.com/default.
php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Phpwebsite-developers mailing list
Phpwebsite-developerslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/p
hpwebsite-developers
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )