Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Lib.Usercard.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Function utilities to manipulate users
9  *
10  * @author Anakeen 2004
11  * @version $Id: Lib.Usercard.php,v 1.5 2007/02/16 07:35:54 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage USERCARD
15  */
16 /**
17  */
18 include_once ("Class.Group.php");
19 include_once ("FDL/Class.Dir.php");
20 /**
21  * refresh a set of group
22  * @param array $tg the groups which has been modify by insertion/deletion of user
23  * @return
24  */
25 
26 global $wg;
27 $wg = new group("", 2); // working group
28 
29 function refreshGroups($groupIdList, $refresh = false, &$currentPath = array() , &$groupDepth = array())
30 {
31  global $wg;
32  // Iterate over given groups list
33  foreach ($groupIdList as $groupId) {
34  // Detect loops in groups
35  if (array_search($groupId, $currentPath)) {
36  error_log(__CLASS__ . "::" . __FUNCTION__ . " " . sprintf("Loop detected in group with id '%s' (path=[%s])", $groupId, join('-', $currentPath)));
37  continue;
38  }
39  // Get direct parent groups list
40  $parentGroupIdList = $wg->getParentsGroupId($groupId);
41  // Compute depth of current group and recursively compute depth on parent groups
42  array_push($currentPath, $groupId);
43  $groupDepth[$groupId] = max($groupDepth[$groupId], count($currentPath));
44  refreshGroups($parentGroupIdList, $refresh, $currentPath, $groupDepth);
45  array_pop($currentPath);
46  }
47  // End of groups traversal
48  if (count($currentPath) <= 0) {
49  // We can now refresh the groups based on their ascending depth
50  uasort($groupDepth, create_function('$a,$b', 'return ($a-$b);'));
51  foreach ($groupDepth as $group => $depth) {
52  refreshOneGroup($group, $refresh);
53  }
54  }
55 
56  return $groupIdList;
57 }
58 
59 function array_unset(&$t, $vp)
60 {
61  foreach ($t as $k => $v) {
62  if ($v == $vp) unset($t[$k]);
63  }
64 }
65 
66 function refreshOneGroup($gid, $refresh)
67 {
68  global $_SERVER;
69  $g = new User("", $gid);
70  if ($g->fid > 0) {
71  $dbaccess = GetParam("FREEDOM_DB");
72  $doc = new_Doc($dbaccess, $g->fid);
73  if ($doc->isAlive()) {
74  if ($_SERVER['HTTP_HOST'] == "") print sprintf("\trefreshing %s\n", $doc->title);
75  wbartext(sprintf(_("refreshing %s") , $doc->title));
76  if ($refresh) $doc->refreshMembers();
77  $doc->SetGroupMail(($doc->GetValue("US_IDDOMAIN") > 1));
78  $doc->modify();
79  $doc->specPostInsert();
80  $doc->setValue("grp_isrefreshed", "1");
81  $doc->modify(true, array(
82  "grp_isrefreshed"
83  ) , true);
84  }
85  }
86 }
87 ?>
← centre documentaire © anakeen - published under CC License - Dynacase