function print_user_list() { global $is_admin, $is_assistant, $is_nonuser_admin, $login, $NONUSER_AT_TOP, $NONUSER_ENABLED, $single_user; if ($single_user == 'N' && $is_admin) { $userlist = user_get_users(); if ($NONUSER_ENABLED == 'Y') { $nonusers = get_nonuser_cals(); $userlist = !empty($NONUSER_AT_TOP) && $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $userlist) : array_merge($userlist, $nonusers); } $num_users = $size = 0; $users = ''; for ($i = 0, $cnt = count($userlist); $i < $cnt; $i++) { $l = $userlist[$i]['cal_login']; $size++; $users .= ' <option value="' . $l . '"' . ($l == $login && !$is_assistant && !$is_nonuser_admin ? ' selected="selected"' : '') . '>' . $userlist[$i]['cal_fullname'] . '</option>'; } if ($size > 50) { $size = 15; } elseif ($size > 5) { $size = 5; } echo ' <tr> <td class="aligntop"><label for="caluser">' . translate('Calendar') . ':</label></td> <td> <select name="calUser" id="caluser" size="' . $size . '">' . $users . ' </select> </td> </tr>'; } }
function get_my_users() { global $login, $is_admin, $groups_enabled, $user_sees_only_his_groups; if ($groups_enabled == "Y" && $user_sees_only_his_groups == "Y" && !$is_admin) { // get groups that current user is in $res = dbi_query("SELECT cal_group_id FROM webcal_group_user " . "WHERE cal_login = '******'"); $groups = array(); if ($res) { while ($row = dbi_fetch_row($res)) { $groups[] = $row[0]; } dbi_fetch_row($res); } $u = user_get_users(); $u_byname = array(); for ($i = 0; $i < count($u); $i++) { $name = $u[$i]['cal_login']; $u_byname[$name] = $u[$i]; } $ret = array(); if (count($groups) == 0) { // Eek. User is in no groups... Return only themselves $ret[] = $u_byname[$login]; return $ret; } // get list of users in the same groups as current user $sql = "SELECT DISTINCT(cal_login) from webcal_group_user " . "WHERE cal_group_id "; if (count($groups) == 1) { $sql .= "= " . $groups[0]; } else { $sql .= "IN ( " . implode(", ", $groups) . " )"; } //echo "SQL: $sql <P>\n"; $res = dbi_query($sql); if ($res) { while ($row = dbi_fetch_row($res)) { $ret[] = $u_byname[$row[0]]; } dbi_free_result($res); } return $ret; } else { // groups not enabled... return all users //echo "No groups. "; return user_get_users(); } }
<td><input type="text" name="groupname" id="groupname" size="20" ' . 'value="' . htmlspecialchars($groupname) . '" /></td> </tr>' . (!$newgroup ? ' <tr> <td class="aligntop bold">' . translate('Updated') . ':</td> <td>' . date_to_str($groupupdated) . '</td> </tr> <tr> <td class="aligntop bold">' . translate('Created by') . ':</td> <td>' . $groupowner . '</td> </tr>' : '') . ' <tr> <td class="aligntop bold"><label for="users">' . translate('Users') . ':</label></td> <td> <select name="users[]" id="users" size="10" multiple="multiple">'; // Get list of all users. $users = user_get_users(); if ($NONUSER_ENABLED == 'Y') { $nonusers = get_nonuser_cals(); $users = $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $users) : array_merge($users, $nonusers); } // Get list of users for this group. if (!$newgroup) { $res = dbi_execute('SELECT cal_login FROM webcal_group_user WHERE cal_group_id = ?', array($id)); if ($res) { while ($row = dbi_fetch_row($res)) { $groupuser[$row[0]] = 1; } dbi_free_result($res); } }
$res = dbi_query("SELECT cal_login FROM webcal_user_pref " . "WHERE cal_setting = 'EMAIL_REMINDER' " . "AND cal_value = 'N'"); $noemail = array(); if ($res) { while ($row = dbi_fetch_row($res)) { $user = $row[0]; $noemail[$user] = 1; if ($debug) { echo "User {$user} does not want email. <br />\n"; } } dbi_free_result($res); } // Get a list of the email users in the system. // They must also have an email address. Otherwise, we can't // send them mail, so what's the point? $allusers = user_get_users(); for ($i = 0; $i < count($allusers); $i++) { $names[$allusers[$i]['cal_login']] = $allusers[$i]['cal_fullname']; $emails[$allusers[$i]['cal_login']] = $allusers[$i]['cal_email']; } // Get all users language settings. $res = dbi_query("SELECT cal_login, cal_value FROM webcal_user_pref " . "WHERE cal_setting = 'LANGUAGE'"); $languages = array(); if ($res) { while ($row = dbi_fetch_row($res)) { $user = $row[0]; $user_lang = $row[1]; $languages[$user] = $user_lang; if ($debug) { echo "Language for {$user} is \"{$user_lang}\" <br />\n"; }
<!-- TABS BODY --> <div id="tabscontent"> <!-- USERS --> <a name="tabusers"></a> <div id="tabscontent_users"> <?php if ($is_admin) { ?> <?php if ($admin_can_add_user) { echo "<a title=\"" . translate("Add New User") . "\" href=\"edit_user.php\" target=\"useriframe\" onclick=\"javascript:show('useriframe');\">" . translate("Add New User") . "</a><br />\n"; } ?> <ul> <?php $userlist = user_get_users(); for ($i = 0; $i < count($userlist); $i++) { if ($userlist[$i]['cal_login'] != '__public__') { echo "<li><a title=\"" . $userlist[$i]['cal_fullname'] . "\" href=\"edit_user.php?user="******"cal_login"] . "\" target=\"useriframe\" onclick=\"javascript:show('useriframe');\">"; echo $userlist[$i]['cal_fullname']; echo "</a>"; if ($userlist[$i]["cal_is_admin"] == 'Y') { echo " <abbr title=\"" . translate("denotes administrative user") . "\">*</abbr>"; } echo "</li>\n"; } } ?> </ul> * <?php etranslate("denotes administrative user");
function get_my_users($user = '', $reason = 'invite') { global $GROUPS_ENABLED, $is_admin, $is_nonuser, $is_nonuser_admin, $login, $my_user_array, $USER_SEES_ONLY_HIS_GROUPS, $USER_SORT_ORDER; $this_user = empty($user) ? $login : $user; // Return the global variable (cached). if (!empty($my_user_array[$this_user][$reason]) && is_array($my_user_array)) { return $my_user_array[$this_user][$reason]; } if ($GROUPS_ENABLED == 'Y' && $USER_SEES_ONLY_HIS_GROUPS == 'Y' && !$is_admin) { // Get groups with current user as member. $rows = dbi_get_cached_rows('SELECT cal_group_id FROM webcal_group_user WHERE cal_login = ?', array($this_user)); $groups = $ret = $u_byname = array(); if ($rows) { for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; $groups[] = $row[0]; } } $groupcnt = count($groups); // Nonuser (public) can only see themself (unless access control is on). if ($is_nonuser && !access_is_enabled()) { return array($this_user); } $u = user_get_users(); if ($is_nonuser_admin) { $u = array_merge(get_my_nonusers(), $u); } for ($i = 0, $cnt = count($u); $i < $cnt; $i++) { $u_byname[$u[$i]['cal_login']] = $u[$i]; } if ($groupcnt == 0) { // Eek. User is in no groups... Return only themselves. if (isset($u_byname[$this_user])) { $ret[] = $u_byname[$this_user]; } $my_user_array[$this_user][$reason] = $ret; return $ret; } // Get other members of users' groups. $sql = 'SELECT DISTINCT(webcal_group_user.cal_login), cal_lastname, cal_firstname FROM webcal_group_user LEFT JOIN webcal_user ON webcal_group_user.cal_login = webcal_user.cal_login WHERE cal_group_id '; if ($groupcnt == 1) { $sql .= '= ?'; } else { // Build count ( $groups ) placeholders separated with commas. $placeholders = ''; for ($p_i = 0; $p_i < $groupcnt; $p_i++) { $placeholders .= $p_i == 0 ? '?' : ', ?'; } $sql .= "IN ( {$placeholders} )"; } $rows = dbi_get_cached_rows($sql . ' ORDER BY ' . (empty($USER_SORT_ORDER) ? '' : "{$USER_SORT_ORDER}, ") . 'webcal_group_user.cal_login', $groups); if ($rows) { for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) { $row = $rows[$i]; if (isset($u_byname[$row[0]])) { $ret[] = $u_byname[$row[0]]; } } } } else { // Groups not enabled... return all users. $ret = user_get_users(); } // If user access control enabled, // remove any users that this user does not have required access. if (access_is_enabled()) { $newlist = array(); for ($i = 0, $cnt = count($ret); $i < $cnt; $i++) { $can_list = access_user_calendar($reason, $ret[$i]['cal_login'], $this_user); if ($can_list == 'Y' || $can_list > 0) { $newlist[] = $ret[$i]; } } $ret = $newlist; } $my_user_array[$this_user][$reason] = $ret; return $ret; }
function export_get_attendee($id, $export) { global $login, $EMAIL_FALLBACK_FROM; $request = 'SELECT weu.cal_login, weu.cal_status, we.cal_create_by FROM webcal_entry_user weu LEFT JOIN webcal_entry we ON weu.cal_id = we.cal_id WHERE weu.cal_id = ? AND weu.cal_status <> \'D\''; $att_res = dbi_execute($request, array($id)); $count = 0; $attendee = array(); $entry_array = array(); while ($entry = dbi_fetch_row($att_res)) { $entry_array[$count++] = $entry; } dbi_free_result($att_res); $count = 0; $userlist = user_get_users(); while (list($key, $row) = each($entry_array)) { // $user[0] = cal_firstname, cal_lastname, cal_email, cal_login $userPos = search_users($userlist, $row[0]); if ($userPos == -1) { continue; } else { $user = $userlist[$userPos]; $attendee[$count] = 'ATTENDEE;ROLE='; if (strcmp($export, 'vcal') == 0) { $attendee[$count] .= $row[0] == $row[2] ? 'OWNER;' : 'ATTENDEE;'; } else { $attendee[$count] .= $row[0] == $row[2] ? 'CHAIR;' : 'REQ-PARTICIPANT;'; } if (strcmp($export, 'vcal') == 0) { $attendee[$count] .= 'STATUS='; } else { $attendee[$count] .= 'PARTSTAT='; } switch ($row[1]) { case 'A': $attendee[$count] .= 'ACCEPTED'; break; case 'R': $attendee[$count] .= 'DECLINED'; break; case 'W': $attendee[$count] .= 'NEEDS-ACTION'; break; default: continue; } //end switch if (strcmp($export, 'vcal') == 0) { $attendee[$count] .= ';ENCODING=QUOTED-PRINTABLE:'; if (empty($user['cal_firstname']) && empty($user['cal_lastname'])) { $attendee[$count] .= $user['cal_login'] . '"'; } else { $attendee[$count] .= $user['cal_firstname'] . ' ' . $user['cal_lastname']; } if (!empty($user['cal_email'])) { $attendee[$count] .= '<' . $user['cal_email'] . '>'; } else { $attendee[$count] .= '<' . $EMAIL_FALLBACK_FROM . '>'; } } else { // Use "Full Name <email>" if we have it, just "login" if that's all // we have. if (empty($user['cal_firstname']) && empty($user['cal_lastname'])) { $attendee[$count] .= ';CN="' . $user['cal_login'] . '"'; } else { $attendee[$count] .= ';CN="' . utf8_encode($user['cal_firstname']) . ' ' . utf8_encode($user['cal_lastname']) . '"'; } if (!empty($user['cal_email'])) { $attendee[$count] .= ':MAILTO:' . $user['cal_email']; } else { $attendee[$count] .= ':MAILTO:' . $EMAIL_FALLBACK_FROM; } } $count++; } //end if ( count ( $user ) > 0 ) } //end while return $attendee; }