if ($login != '__public__') { if (!$is_nonuser && $readonly == 'N') { if (!access_is_enabled() || access_can_access_function(ACCESS_ADMIN_HOME) || access_can_access_function(ACCESS_PREFERENCES)) { $goto_link[] = '<a title="' . $adminStr . '" class="bold" href="adminhome.php' . ($is_nonuser_admin ? '?user='******'') . "\">{$adminStr}" . '</a>'; } if ($REQUIRE_APPROVALS == 'Y' || $PUBLIC_ACCESS == 'Y') { $goto_link[] = '<a title="' . $unapprovedStr . '" href="list_unapproved.php' . ($is_nonuser_admin ? '?user='******'user') : '') . "\">{$unapprovedStr}" . '</a>'; } } } if ($login == '__public__' && $PUBLIC_ACCESS_OTHERS != 'Y' || $is_nonuser && !access_is_enabled()) { // Don't allow them to see other people's calendar. } else { if (($ALLOW_VIEW_OTHER == 'Y' || $is_admin) && (!access_is_enabled() || access_can_access_function(ACCESS_ANOTHER_CALENDAR))) { // Get count of users this user can see. If > 1, then... $ulist = array_merge(get_my_users(), get_my_nonusers($login, true)); if (count($ulist) > 1) { $calStr = translate('Another Users Calendar'); $goto_link[] = '<a title="' . $calStr . '" href="select_user.php">' . $calStr . '</a>'; } } } } else { $goto_link[] = '<a title="' . $myCalStr . '" class="bold" href="' . "{$mycal}\">{$myCalStr}" . '</a>'; $goto_link[] = '<a title="' . $todayStr . '" class="bold" href="' . "{$todayURL}\">{$todayStr}" . '</a>'; if ($readonly == 'N') { $goto_link[] = '<a title="' . $adminStr . '" class="bold" href="adminhome.php">' . $adminStr . '</a>'; } } // Only display some links if we're viewing our own calendar. if (empty($user) || $user == $login) {
ob_start(); echo ' <script language="javascript" type="text/javascript">'; include 'includes/js/usersel.php'; echo ' </script> <center> <form action="#" name="userselform"> <table style="borderh: 0; width: 100%;"> <tr> <td class="aligntop"> <b>' . translate('Users') . ':</b><br /> <select name="users" size="15" multiple="multiple">'; $users = get_my_users(); if ($NONUSER_ENABLED == 'Y') { $nonusers = get_my_nonusers($login, true); $users = $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $users) : array_merge($users, $nonusers); } //modif lcs for ($i = 0; $i < count($users); $i++) { $u = $users[$i]['cal_login']; if ($users[$i]['cal_cat'] . "_" . $users[$i]['cal_group'] != $users[$i - 1]['cal_cat'] . "_" . $users[$i - 1]['cal_group']) { echo "<optgroup label='" . $users[$i]['cal_cat'] . "_" . $users[$i]['cal_group'] . "'>\n"; } echo "<option value=\"{$u}\""; if (!empty($selected[$u])) { echo " selected=\"selected\""; } echo ">" . $users[$i]['cal_fullname'] . "</option>\n"; if ($users[$i]['cal_cat'] . "_" . $users[$i]['cal_group'] != $users[$i + 1]['cal_cat'] . "_" . $users[$i + 1]['cal_group']) { echo "<\\optgroup>\n";
?> <input type="hidden" name="public" value="1" /> <?php } /*if ( $updating_public )*/ // If user is admin of a non-user cal, and non-user cal is "public" // (meaning it is a public calendar that requires no login), then allow // the current user to modify prefs for that nonuser cal if ($is_admin && !$updating_public) { if (empty($public) && !empty($PUBLIC_ACCESS) && $PUBLIC_ACCESS == 'Y') { $public_option = '<option value="pref.php?public=1">' . translate('Public Access calendar') . "</option>\n"; } } if ($NONUSER_ENABLED == 'Y' || $PUBLIC_ACCESS == 'Y') { if ((empty($user) || $user == $login) && !$updating_public) { $nulist = get_my_nonusers($login); echo '<select onchange="location=this.options[this.selectedIndex].value;">' . "\n"; echo "<option {$selected} disabled=\"disabled\" value=\"\">" . translate('Modify Non User Calendar Preferences') . "</option>\n"; if (!empty($public_option)) { echo $public_option . "\n"; } for ($i = 0, $cnt = count($nulist); $i < $cnt; $i++) { echo '<option value="pref.php?user='******'cal_login'] . '">' . $nulist[$i]['cal_fullname'] . "</option>\n"; } echo "</select>\n"; } else { $linktext = translate('Return to My Preferences'); echo "<a title=\"{$linktext}\" class=\"nav\" href=\"pref.php\">« {$linktext} </a>"; } } ?>
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; }
$updating_public = $is_admin && !empty($public) && $PUBLIC_ACCESS == 'Y'; $report_user = $updating_public ? '__public__' : ''; if (empty($report_id)) { $adding_report = true; $include_header = $report_allow_nav = 'Y'; $report_id = -1; $report_is_global = 'N'; } // Set date range options. $ranges = array('0' => translate('Tomorrow'), '1' => translate('Today'), '2' => translate('Yesterday'), '3' => translate('Day before yesterday'), '10' => translate('Next week'), '11' => translate('This week'), '12' => translate('Last week'), '13' => translate('Week before last'), '20' => translate('Next week and week after'), '21' => translate('This week and next week'), '22' => translate('Last week and this week'), '23' => translate('Last two weeks'), '30' => translate('Next month'), '31' => translate('This month'), '32' => translate('Last month'), '33' => translate('Month before last'), '40' => translate('Next year'), '41' => translate('This year'), '42' => translate('Last year'), '43' => translate('Year before last'), '50' => translate('Next 14 days'), '51' => translate('Next 30 days'), '52' => translate('Next 60 days'), '53' => translate('Next 90 days'), '54' => translate('Next 180 days'), '55' => translate('Next 365 days')); // Get list of users visible to the current user. if (empty($error) && $show_participants) { $userlist = get_my_users('', 'view'); if ($NONUSER_ENABLED == 'Y') { // Restrict NUC list if groups are enabled. $nonusers = get_my_nonusers($login, true, 'view'); $userlist = $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $userlist) : array_merge($userlist, $nonusers); } $userlistcnt = count($userlist); } // Default values. $day_template = '<dt><b>${date}</b></dt> <dd><dl>${events}</dl></dd>'; $event_template = '<dt>${name}</dt> <dd><b>' . translate('Date') . ':</b> ${date}<br /> <b>' . translate('Time') . ':</b> ${time}<br /> ${description}</dd> '; $page_template = '<dl>${days}</dl>'; // Setup option arrays. $day_options = array('events', 'date', 'fulldate', 'report_id');
} } // List Unapproved. if ($login != '__public__' && !$is_nonuser && $readonly == 'N' && ($REQUIRE_APPROVALS == 'Y' || $PUBLIC_ACCESS == 'Y')) { $unapproved_url = 'list_unapproved.php' . ($is_nonuser_admin ? '?user='******'user') : ''); } // Another User's Calendar. if ($login == '__public__' && $PUBLIC_ACCESS_OTHERS != 'Y' || $is_nonuser && !access_is_enabled()) { // Don't allow them to see other people's calendar. } else { if ($ALLOW_VIEW_OTHER == 'Y' || $is_admin) { // Also, make sure they able to access either day/week/month/year view. // If not, the only way to view another user's calendar is a custom view. if (!access_is_enabled() || access_can_access_function(ACCESS_ANOTHER_CALENDAR)) { // Get count of users this user can see. If > 1, then... $ulist = array_merge(get_my_users($login, 'view'), get_my_nonusers($login, true, 'view')); //remove duplicates if any if (function_exists('array_intersect_key')) { $ulist = array_intersect_key($ulist, array_unique(array_map('serialize', $ulist))); } if (count($ulist) > 1) { $select_user_url = 'select_user.php'; } } } } } // Only display some links if we're viewing our own calendar. if (empty($user) || $user == $login || !empty($user) && access_is_enabled() && access_user_calendar('view', $user)) { // Search if (access_can_access_function(ACCESS_SEARCH, $user)) {
$defIdx = !empty($viewisglobal) && $viewisglobal == 'Y' ? 'Y' : 'N'; echo '<tr><td><label>' . translate('Global') . ":</label></td>\n<td>" . print_radio('is_global', '', '', $defIdx, '</td><td>') . "</td></tr>\n"; } $defIdx = !empty($all_users) && $all_users == true ? 'Y' : 'N'; echo '<tr><td><label>' . translate('Users') . ":</label></td>\n<td>" . print_radio('viewuserall', array('N' => 'Selected', 'Y' => 'All'), 'usermode_handler', $defIdx, '</td><td>') . "</td></tr>\n"; ?> <tr><td colspan="4"> <div id="viewuserlist"> <select name="users[]" id="viewusers" size="10" multiple="multiple"> <?php // get list of all users $users = get_my_users('', 'view'); if ($NONUSER_ENABLED == 'Y') { $nonusers = get_my_nonusers($user, true, 'view'); $users = $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $users) : array_merge($users, $nonusers); } for ($i = 0, $cnt = count($users); $i < $cnt; $i++) { $u = $users[$i]['cal_login']; echo "<option value=\"{$u}\""; if (!empty($viewuser[$u])) { echo $selected; } echo '>' . $users[$i]['cal_fullname'] . "</option>\n"; } ?> </select> <?php if ($GROUPS_ENABLED == 'Y') { ?>
function get_list_of_users($user) { global $is_admin, $is_nonuser_admin; //Let Admins userlist be returnd if ($user == '__default__') { $user = ''; } $u = get_my_users($user, 'view'); if ($is_admin || $is_nonuser_admin) { // Get public NUCs also. $nonusers = get_my_nonusers($user, true); $u = array_merge($nonusers, $u); } return $u; }
<legend>' . translate('Participants') . '</legend>') . ' <table>'; // . // Only ask for participants if we are multi-user. $show_participants = $DISABLE_PARTICIPANTS_FIELD != 'Y'; if ($is_admin) { $show_participants = true; } if ($login == '__public__' && $PUBLIC_ACCESS_OTHERS != 'Y') { $show_participants = false; } if ($single_user == 'N' && $show_participants) { $userlist = get_my_users($create_by, 'invite'); if ($NONUSER_ENABLED == 'Y') { // Include public NUCs. $nonusers = get_my_nonusers($real_user, false); $userlist = $NONUSER_AT_TOP == 'Y' ? array_merge($nonusers, $userlist) : array_merge($userlist, $nonusers); } $num_users = $size = 0; $usercnt = count($userlist); $users = ''; for ($i = 0; $i < $usercnt; $i++) { $l = $userlist[$i]['cal_login']; $size++; $users .= ' <option value="' . $l . '"'; if ($id > 0) { if (!empty($participants[$l])) { $users .= $selected; } } else {
/** * Remove any users from the view list who this user is not * allowed to view. * @param int $view_id id of the view * @return the array of valid users */ function view_get_user_list($view_id) { global $error, $login, $is_admin, $NONUSER_ENABLED, $USER_SEES_ONLY_HIS_GROUPS; // get users in this view $res = dbi_execute('SELECT cal_login FROM webcal_view_user WHERE cal_view_id = ?', array($view_id)); $ret = array(); $all_users = false; if ($res) { while ($row = dbi_fetch_row($res)) { $ret[] = $row[0]; if ($row[0] == '__all__') { $all_users = true; } } dbi_free_result($res); } else { $error = db_error(); } if ($all_users) { $users = get_my_users('', 'view'); $ret = array(); $usercnt = count($users); for ($i = 0; $i < $usercnt; $i++) { $ret[] = $users[$i]['cal_login']; } } else { $myusers = get_my_users('', 'view'); if (!empty($NONUSER_ENABLED) && $NONUSER_ENABLED == 'Y') { $myusers = array_merge($myusers, get_my_nonusers($login, true, 'view')); } // Make sure this user is allowed to see all users in this view // If this is a global view, it may include users that this user // is not allowed to see. if (!empty($USER_SEES_ONLY_HIS_GROUPS) && $USER_SEES_ONLY_HIS_GROUPS == 'Y') { $userlookup = array(); $myusercnt = count($myusers); for ($i = 0; $i < $myusercnt; $i++) { $userlookup[$myusers[$i]['cal_login']] = 1; } $newlist = array(); $retcnt = count($ret); for ($i = 0; $i < $retcnt; $i++) { if (!empty($userlookup[$ret[$i]])) { $newlist[] = $ret[$i]; } } $ret = $newlist; } //Sort user list... $sortlist = array(); $myusercnt = count($myusers); $retcnt = count($ret); for ($i = 0; $i < $myusercnt; $i++) { for ($j = 0; $j < $retcnt; $j++) { if ($myusers[$i]['cal_login'] == $ret[$j]) { $sortlist[] = $ret[$j]; break; } } } $ret = $sortlist; } // If user access control enabled, check against that as well. if (access_is_enabled() && !$is_admin) { $newlist = array(); $retcnt = count($ret); for ($i = 0; $i < $retcnt; $i++) { if (access_user_calendar('view', $ret[$i])) { $newlist[] = $ret[$i]; } } $ret = $newlist; } //echo "<pre>"; print_r ( $ret ); echo "</pre>\n"; return $ret; }