Go to the documentation of this file.00001 <?php
00011 require_once "./classes/class.ilObjUser.php";
00012
00013 class ilCalGroupHandler
00014 {
00015 function getGroups($userId) {
00016 $actUser = new ilObjUser($userId);
00017 $role = $actUser->data["Role"];
00018 $groupArray = null;
00019 $arrayIndex = 0;
00020
00021 if($role == 2) {
00022 $dbtable = "dummy_groups";
00023 $where = "";
00024 $tempArray = array("ID" => 0,
00025 "term" => "Alle User");
00026 $groupArray[$arrayIndex] = $tempArray;
00027 $arrayIndex++;
00028 }
00029 else {
00030 $dbtable = "cal_user_group, dummy_groups";
00031 $where = "cal_user_group.userId=".$userId.
00032 " AND cal_user_group.groupId=dummy_groups.groupId";
00033 }
00034 $orderBy = "dummy_groups.term ASC";
00035
00036 $dbHandler = new ilCalDBHandler();
00037 $groupResultset = $dbHandler->select($dbtable, "dummy_groups.term as groupTerm, dummy_groups.groupId as groupId", $where, $orderBy);
00038 if ($groupResultset->numRows() > 0) {
00039 while($groupRecordSet = $groupResultset->fetchRow(DB_FETCHMODE_ASSOC)) {
00040 $tempArray = array("ID" => $groupRecordSet["groupId"],
00041 "term" => $groupRecordSet["groupTerm"]);
00042 $groupArray[$arrayIndex] = $tempArray;
00043 $arrayIndex++;
00044 }
00045 }
00046
00047 return $groupArray;
00048 }
00049
00050 function getAllUsers() {
00051 $userArray = null;
00052 $dbh = new ilCalDBHandler();
00053 $userResultset = $dbh->select("usr_data", "usr_id");
00054 if ($userResultset->numRows() > 0) {
00055 while($userRecordset = $userResultset->fetchRow(DB_FETCHMODE_ASSOC)) {
00056 $userArray[] = $userRecordset["usr_id"];
00057 }
00058 }
00059 return $userArray;
00060 }
00061
00062 function getUserIDs($groupId) {
00063 $userArray = null;
00064 $dbtable = "cal_user_group";
00065
00066 $where = "cal_user_group.groupId=".$groupId;
00067
00068 $dbHandler = new ilCalDBHandler();
00069 $userResultset = $dbHandler->select($dbtable, "cal_user_group.userId as userId", $where);
00070 if ($userResultset->numRows() > 0)
00071 {
00072
00073 while($userRecordSet = $userResultset->fetchRow(DB_FETCHMODE_ASSOC)) {
00074 $userArray[$userRecordSet["userId"]] = $userRecordSet["userId"];
00075
00076
00077 }
00078 }
00079
00080 return $userArray;
00081 }
00082 }
00083
00084 ?>