* update phpdoc for users.php
This commit is contained in:
Jan Dittberner 2007-11-26 09:44:23 +00:00
parent 581b0dc90f
commit 8567a8aaac
2 changed files with 34 additions and 4 deletions

View file

@ -31,7 +31,7 @@ SRCFILES=admin/common.inc.php,admin/directories.php,admin/getgroups.php,admin/in
apidoc: apidoc:
if [ -d apidoc ]; then rm -r apidoc; fi if [ -d apidoc ]; then rm -r apidoc; fi
phpdoc -f $(SRCFILES) -t apidoc -s phpdoc -f $(SRCFILES) -t apidoc --undocumentedelements on -s
clean: clean:
find -name '*~' -type f -exec rm {} \; find -name '*~' -type f -exec rm {} \;

View file

@ -30,7 +30,14 @@
/** Include common code. */ /** Include common code. */
include_once('common.inc.php'); include_once('common.inc.php');
function getGroups($username) { /**
* Gets the names of the given users's groups from the group file.
*
* @param string $username user name
* @return array of group names
* @access private
*/
function _getGroupNames($username) {
$groupdata = file($GLOBALS['davconfig']['group.file']); $groupdata = file($GLOBALS['davconfig']['group.file']);
$retval = array(); $retval = array();
foreach ($groupdata as $line) { foreach ($groupdata as $line) {
@ -58,7 +65,7 @@ function getUserData($uid) {
} }
$row = $GLOBALS['namemap'][$uid]; $row = $GLOBALS['namemap'][$uid];
$groups = getGroups($row['username']); $groups = _getGroupNames($row['username']);
$retval = sprintf('<?xml version="1.0" encoding="utf8"?><userdata><uid>%d</uid><username>%s</username><firstname>%s</firstname><lastname>%s</lastname><groups>%s</groups><loggedin>0</loggedin></userdata>', $retval = sprintf('<?xml version="1.0" encoding="utf8"?><userdata><uid>%d</uid><username>%s</username><firstname>%s</firstname><lastname>%s</lastname><groups>%s</groups><loggedin>0</loggedin></userdata>',
$uid, $row['username'], $row['firstname'], $uid, $row['username'], $row['firstname'],
$row['lastname'], implode(", ", $groups)); $row['lastname'], implode(", ", $groups));
@ -121,7 +128,7 @@ function validateUserData(&$userdata, $forinsert) {
} }
/** /**
* Creates an entry for a digest authentication file. * Create an entry for a digest authentication file.
* *
* @param string $username user name * @param string $username user name
* @param string $realm realm name * @param string $realm realm name
@ -133,12 +140,20 @@ function createDigest($username, $realm, $password) {
md5(sprintf("%s:%s:%s", $username, $realm, $password))); md5(sprintf("%s:%s:%s", $username, $realm, $password)));
} }
/**
* Update the user to name mapping file.
*/
function updateNameMap() { function updateNameMap() {
$fh = fopen($GLOBALS['davconfig']['namemap.file'], 'w'); $fh = fopen($GLOBALS['davconfig']['namemap.file'], 'w');
fwrite($fh, json_encode($GLOBALS['namemap'])); fwrite($fh, json_encode($GLOBALS['namemap']));
fclose($fh); fclose($fh);
} }
/**
* Update the digest file with the user information.
*
* @param &array reference to an associative array of user data
*/
function updateDigest(&$userdata) { function updateDigest(&$userdata) {
if ($userdata['password']) { if ($userdata['password']) {
$digests = file($GLOBALS['davconfig']['digest.file']); $digests = file($GLOBALS['davconfig']['digest.file']);
@ -165,6 +180,11 @@ function updateDigest(&$userdata) {
} }
} }
/**
* Update the group file with the group assignments of the user.
*
* @param &array reference to an associative array of user data
*/
function updateGroups(&$userdata) { function updateGroups(&$userdata) {
if ($userdata['groups']) { if ($userdata['groups']) {
$written = array(); $written = array();
@ -255,6 +275,11 @@ function insertUser(&$userdata) {
return $uid; return $uid;
} }
/**
* Remove the digest entries of the given user from the digest file.
*
* @param string $username
*/
function removeDigest($username) { function removeDigest($username) {
$digests = file($GLOBALS['davconfig']['digest.file']); $digests = file($GLOBALS['davconfig']['digest.file']);
$fh = fopen($GLOBALS['davconfig']['digest.file'], 'w'); $fh = fopen($GLOBALS['davconfig']['digest.file'], 'w');
@ -268,6 +293,11 @@ function removeDigest($username) {
fclose($fh); fclose($fh);
} }
/**
* Remove the given user from all groups in the group file.
*
* @param string $username
*/
function removeFromGroups($username) { function removeFromGroups($username) {
$groupdata = file($GLOBALS['davconfig']['group.file']); $groupdata = file($GLOBALS['davconfig']['group.file']);
$fh = fopen($GLOBALS['davconfig']['group.file'], 'w'); $fh = fopen($GLOBALS['davconfig']['group.file'], 'w');