示例#1
0
        </td>
      </tr>';
}
if (Doc::commentsEnabled()) {
    echo '
      <tr>
        <td class="aligntop bold">' . translate('Comments') . ':</td>
        <td>';
    $comList = new CommentList($id);
    $num_comment = $comList->getSize();
    $comment_text = '';
    for ($i = 0; $i < $num_comment; $i++) {
        $cmt = $comList->getDoc($i);
        user_load_variables($cmt->getLogin(), 'cmt_');
        $comment_text .= '
          <strong>' . htmlspecialchars($cmt->getDescription()) . '</strong> - ' . $cmt_fullname . ' ' . translate('at') . ' ' . date_to_str($cmt->getModDate(), '', false, true) . ' ' . display_time($cmt->getModTime(), 2) . ($is_admin || $login == $cmt->getLogin() || user_is_assistant($login, $cmt->getLogin()) || $login == $create_by || user_is_assistant($login, $create_by) ? ' [<a href="docdel.php?blid=' . $cmt->getId() . '" onclick="return confirm( \'' . $areYouSureStr . '\' );">' . translate('Delete') . '</a>]' : '') . '<br />
          <blockquote id="eventcomment">' . nl2br(activate_urls(htmlspecialchars($cmt->getData()))) . '
        </blockquote><div style="clear:both"></div>';
    }
    if ($num_comment == 0) {
        echo translate('None') . '<br />';
    } else {
        echo '
          ' . $num_comment . ' ' . translate('comments') . '
          <input id="showbutton" type="button" value="' . translate('Show') . '" onclick="showComments();" />
          <input id="hidebutton" type="button" value="' . translate('Hide') . '" onclick="hideComments();" /><br />
          <div id="comtext">' . $comment_text . '</div>';
        // We could put the following JS in includes/js/view_entry.php,
        // but we won't need it in many cases and we don't know whether
        // we need it until after would need to include it.
        // So, we will include it here instead.
示例#2
0
文件: view_v.php 项目: rhertzog/lcs
set_today($date);
$nextdate = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday + 7, $thisyear));
$prevdate = date('Ymd', mktime(0, 0, 0, $thismonth, $thisday - 7, $thisyear));
$wkstart = get_weekday_before($thisyear, $thismonth, $thisday + 1);
$wkend = $wkstart + 86400 * ($DISPLAY_WEEKENDS == 'N' ? 5 : 7);
$thisdate = date('Ymd', $wkstart);
$nextStr = translate('Next');
$prevStr = translate('Previous');
print_header(array('js/popups.php/true'));
ob_start();
echo '
    <div style="width:99%;">
      <a title="' . $prevStr . '" class="prev" href="view_v.php?id=' . $id . '&amp;date=' . $prevdate . '"><img src="images/leftarrow.gif" alt="' . $prevStr . '" /></a>
      <a title="' . $nextStr . '" class="next" href="view_v.php?id=' . $id . '&amp;date=' . $nextdate . '"><img src="images/rightarrow.gif" alt="' . $nextStr . '" /></a>
      <div class="title">
        <span class="date">' . date_to_str($thisdate, '', false) . '&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;' . date_to_str(date('Ymd', $wkend), '', false) . '</span><br />
        <span class="viewname">' . htmlspecialchars($view_name) . '</span>
      </div>
    </div><br />';
// .
// The table has names across the top and dates for rows. Since we need to spit
// out an entire row before we can move to the next date, we'll save up all the
// HTML for each cell and then print it out when we're done..
// Additionally, we only want to put at most 6 users in one table since
// any more than that doesn't really fit in the page.
// .
// Get users in this view.
$viewusers = view_get_user_list($id);
$viewusercnt = count($viewusers);
if ($viewusercnt == 0) {
    // This could happen if user_sees_only_his_groups = Y and
function list_unapproved($user)
{
    global $temp_fullname, $key, $login;
    //echo "Listing events for $user <BR>";
    echo "<UL>\n";
    $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date";
    $res = dbi_query($sql);
    $count = 0;
    $eventinfo = "";
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $key++;
            $id = $row[0];
            $name = $row[1];
            $description = $row[2];
            $pri = $row[3];
            $date = $row[4];
            $time = $row[5];
            $duration = $row[6];
            $status = $row[7];
            $divname = "eventinfo-{$id}-{$key}";
            echo "<LI><A CLASS=\"entry\" HREF=\"view_entry.php?id={$id}";
            echo "\" onMouseOver=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onMouseOut=\"hide('{$divname}'); return true;\">";
            $timestr = "";
            if ($time > 0) {
                $timestr = display_time($time);
                if ($duration > 0) {
                    // calc end time
                    $h = (int) ($time / 10000);
                    $m = $time / 100 % 100;
                    $m += $duration;
                    $d = $duration;
                    while ($m >= 60) {
                        $h++;
                        $m -= 60;
                    }
                    $end_time = sprintf("%02d%02d00", $h, $m);
                    $timestr .= " - " . display_time($end_time);
                }
            }
            echo htmlspecialchars($name);
            echo "</A>";
            echo " (" . date_to_str($date) . ")\n";
            echo ": <A HREF=\"approve_entry.php?id={$id}&ret=list";
            if ($user == "__public__") {
                echo "&public=1";
            }
            echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</A>, ";
            echo "<A HREF=\"reject_entry.php?id={$id}&ret=list";
            if ($user == "__public__") {
                echo "&public=1";
            }
            echo "\" CLASS=\"navlinks\" onClick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</A>";
            $eventinfo .= build_event_popup($divname, $user, $description, $timestr, $time);
            $count++;
        }
        dbi_free_result($res);
    }
    echo "</UL><P>\n";
    if ($count == 0) {
        user_load_variables($user, "temp_");
        echo translate("No unapproved events for") . " " . $temp_fullname . ".";
    } else {
        echo $eventinfo;
    }
}
  </td></tr>
</table>

</td><td class="aligncenter aligntop">
<br />
<!-- BEGIN EXAMPLE MONTH -->
<table style="width:90%; background-color:<?php 
    echo $BGCOLOR;
    ?>
"><tr>
<td width="1%" rowspan="3">&nbsp;</td>
<td style="text-align:center; color:<?php 
    echo $H2COLOR;
    ?>
; font-weight:bold;"><?php 
    echo date_to_str($dateYmd, $DATE_FORMAT_MY, false);
    ?>
</td>
<td width="1%" rowspan="3">&nbsp;</td></tr>
<tr><td bgcolor="<?php 
    echo $BGCOLOR;
    ?>
">
<?php 
    set_today($dateYmd);
    echo display_month(date('m'), date('Y'), true);
    ?>
</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
<!-- END EXAMPLE MONTH -->
function check_for_conflicts($dates, $duration, $hour, $minute, $participants, $login, $id)
{
    global $single_user_login, $single_user;
    global $repeated_events, $limit_appts, $limit_appts_number;
    if (!count($dates)) {
        return false;
    }
    $evtcnt = array();
    $sql = "SELECT distinct webcal_entry_user.cal_login, webcal_entry.cal_time," . "webcal_entry.cal_duration, webcal_entry.cal_name, " . "webcal_entry.cal_id, webcal_entry.cal_ext_for_id, " . "webcal_entry.cal_access, " . "webcal_entry_user.cal_status, webcal_entry.cal_date " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND (";
    for ($x = 0; $x < count($dates); $x++) {
        if ($x != 0) {
            $sql .= " OR ";
        }
        $sql .= "webcal_entry.cal_date = " . date("Ymd", $dates[$x]);
    }
    $sql .= ") AND webcal_entry.cal_time >= 0 " . "AND webcal_entry_user.cal_status IN ('A','W') AND ( ";
    if ($single_user == "Y") {
        $participants[0] = $single_user_login;
    } else {
        if (strlen($participants[0]) == 0) {
            // likely called from a form with 1 user
            $participants[0] = $login;
        }
    }
    for ($i = 0; $i < count($participants); $i++) {
        if ($i > 0) {
            $sql .= " OR ";
        }
        $sql .= " webcal_entry_user.cal_login = '******'";
    }
    $sql .= " )";
    // make sure we don't get something past the end date of the
    // event we are saving.
    //echo "SQL: $sql<P>";
    $conflicts = "";
    $res = dbi_query($sql);
    $found = array();
    $count = 0;
    if ($res) {
        $time1 = sprintf("%d%02d00", $hour, $minute);
        $duration1 = sprintf("%d", $duration);
        while ($row = dbi_fetch_row($res)) {
            //Add to an array to see if it has been found already for the next part.
            $found[$count++] = $row[4];
            // see if either event overlaps one another
            if ($row[4] != $id && (empty($row[5]) || $row[5] != $id)) {
                $time2 = $row[1];
                $duration2 = $row[2];
                $cntkey = $user . "-" . $row[8];
                $evtcnt[$cntkey]++;
                $over_limit = 0;
                if ($limit_appts == "Y" && $limit_appts_number > 0 && $evtcnt[$cntkey] >= $limit_appts_number) {
                    $over_limit = 1;
                }
                if ($over_limit || times_overlap($time1, $duration1, $time2, $duration2)) {
                    $conflicts .= "<LI>";
                    if ($single_user == "Y") {
                        $conflicts .= "{$row['0']}: ";
                    }
                    if ($row[6] == 'R' && $row[0] != $login) {
                        $conflicts .= "(" . translate("Private") . ")";
                    } else {
                        $conflicts .= "<A HREF=\"view_entry.php?id={$row['4']}";
                        if ($user != $login) {
                            $conflicts .= "&user={$user}";
                        }
                        $conflicts .= "\">{$row['3']}</A>";
                    }
                    if ($duration2 == 24 * 60) {
                        $conflicts .= " (" . translate("All day event") . ")";
                    } else {
                        $conflicts .= " (" . display_time($time2);
                        if ($duration2 > 0) {
                            $conflicts .= "-" . display_time(add_duration($time2, $duration2));
                        }
                        $conflicts .= ")";
                    }
                    $conflicts .= " on " . date_to_str($row[8]);
                    if ($over_limit) {
                        $tmp = translate("exceeds limit of XXX events per day");
                        $tmp = str_replace("XXX", $limit_appts_number, $tmp);
                        $conflicts .= " (" . $tmp . ")";
                    }
                }
            }
        }
        dbi_free_result($res);
    } else {
        echo translate("Database error") . ": " . dbi_error();
        exit;
    }
    //echo "<br>hello";
    for ($q = 0; $q < count($participants); $q++) {
        $time1 = sprintf("%d%02d00", $hour, $minute);
        $duration1 = sprintf("%d", $duration);
        //This date filter is not necessary for functional reasons, but it eliminates some of the
        //events that couldn't possibly match.  This could be made much more complex to put more
        //of the searching work onto the database server, or it could be dropped all together to put
        //the searching work onto the client.
        $date_filter = "AND (webcal_entry.cal_date <= " . date("Ymd", $dates[count($dates) - 1]);
        $date_filter .= " AND (webcal_entry_repeats.cal_end IS NULL OR webcal_entry_repeats.cal_end >= " . date("Ymd", $dates[0]) . "))";
        //Read repeated events for the participants only once for a participant for
        //for performance reasons.
        $repeated_events = query_events($participants[$q], true, $date_filter);
        //for ($dd=0; $dd<count($repeated_events); $dd++) {
        //  echo $repeated_events[$dd]['cal_id'] . "<BR>";
        //}
        for ($i = 0; $i < count($dates); $i++) {
            $dateYmd = date("Ymd", $dates[$i]);
            $list = get_repeating_entries($participants[$q], $dateYmd);
            $thisyear = substr($dateYmd, 0, 4);
            $thismonth = substr($dateYmd, 4, 2);
            for ($j = 0; $j < count($list); $j++) {
                //okay we've narrowed it down to a day, now I just gotta check the time...
                //I hope this is right...
                $row = $list[$j];
                if ($row['cal_id'] != $id && $row['cal_ext_for_id'] != $id) {
                    $time2 = $row['cal_time'];
                    $duration2 = $row['cal_duration'];
                    if (times_overlap($time1, $duration1, $time2, $duration2)) {
                        $conflicts .= "<LI>";
                        if ($single_user != "Y") {
                            $conflicts .= $row['cal_login'] . ": ";
                        }
                        if ($row['cal_access'] == 'R' && $row['cal_login'] != $login) {
                            $conflicts .= "(" . translate("Private") . ")";
                        } else {
                            $conflicts .= "<A HREF=\"view_entry.php?id=" . $row['cal_id'];
                            if ($user != $login) {
                                $conflicts .= "&user={$user}";
                            }
                            $conflicts .= "\">" . $row['cal_name'] . "</A>";
                        }
                        $conflicts .= " (" . display_time($time2);
                        if ($duration2 > 0) {
                            $conflicts .= "-" . display_time(add_duration($time2, $duration2));
                        }
                        $conflicts .= ")";
                        $conflicts .= " on " . date("l, F j, Y", $dates[$i]);
                    }
                }
            }
        }
    }
    return $conflicts;
}
$sql .= "ORDER BY webcal_entry_log.cal_log_id DESC";
$res = dbi_query($sql);
$nextpage = "";
if ($res) {
    $num = 0;
    while ($row = dbi_fetch_row($res)) {
        $num++;
        if ($num > $PAGE_SIZE) {
            $nextpage = $row[7];
            break;
        } else {
            echo "<tr";
            if ($num % 2) {
                echo " class=\"odd\"";
            }
            echo "><td>\n" . $row[0] . "</td><td>\n" . $row[1] . "</td><td>\n" . date_to_str($row[3]) . "&nbsp;" . display_time($row[4]) . "</td><td>\n" . "<a title=\"" . htmlspecialchars($row[6]) . "\" href=\"view_entry.php?id={$row['5']}\">" . htmlspecialchars($row[6]) . "</a></td><td>\n";
            if ($row[2] == $LOG_CREATE) {
                etranslate("Event created");
            } else {
                if ($row[2] == $LOG_APPROVE) {
                    etranslate("Event approved");
                } else {
                    if ($row[2] == $LOG_REJECT) {
                        etranslate("Event rejected");
                    } else {
                        if ($row[2] == $LOG_UPDATE) {
                            etranslate("Event updated");
                        } else {
                            if ($row[2] == $LOG_DELETE) {
                                etranslate("Event deleted");
                            } else {
示例#7
0
for ($i = 0, $cnt = count($views); $i < $cnt; $i++) {
    if ($views[$i]['cal_is_global'] != 'Y' && ($prad || $views[$i]['cal_owner'] != $user)) {
        continue;
    }
    $xurl = $views[$i]['url'];
    $xurl_strip = str_replace('&amp;', '&', $xurl);
    $user_vu .= $option . $xurl . '"' . ($tmp == $xurl_strip ? $selected : '') . '>' . htmlspecialchars($views[$i]['cal_name']) . '</option>';
}
foreach (array('BGCOLOR' => translate('Document background'), 'H2COLOR' => translate('Document title'), 'TEXTCOLOR' => translate('Document text'), 'MYEVENTS' => translate('My event text'), 'TABLEBG' => translate('Table grid color'), 'THBG' => translate('Table header background'), 'THFG' => translate('Table header text'), 'CELLBG' => translate('Table cell background'), 'TODAYCELLBG' => translate('Table cell background for current day'), 'HASEVENTSBG' => translate('Table cell background for days with events'), 'WEEKENDBG' => translate('Table cell background for weekends'), 'OTHERMONTHBG' => translate('Table cell background for other month'), 'WEEKNUMBER' => translate('Week number color'), 'POPUP_BG' => translate('Event popup background'), 'POPUP_FG' => translate('Event popup text')) as $k => $v) {
    $color_sets .= print_color_input_html($k, $v);
}
$example_month = '

<!-- BEGIN EXAMPLE MONTH -->
          <div id="example_month">
            <p>' . date_to_str(date('Ymd'), $DATE_FORMAT_MY, false) . '</p>' . display_month(date('m'), date('Y'), true) . '
          </div>
<!-- END EXAMPLE MONTH -->
';
/* Save either system or user preferences.
 *
 * @param string  $prefs
 * @param string  $src
 * @param bool    _SYSTEM_ = true
 *                user     = false
 */
function save_pref($prefs, $src)
{
    global $error, $my_theme, $prad;
    if (!$prad) {
        global $prefuser;
     if (!dbi_query($sql)) {
         $error = translate("Database error") . ": " . dbi_error();
     }
     // send mail notification if enabled
     // TODO: move this code into a function...
     if ($external_notifications == "Y" && $send_email != "N" && strlen($ext_emails[$i]) > 0) {
         $fmtdate = sprintf("%04d%02d%02d", $year, $month, $day);
         // Strip [\d] from duplicate Names before emailing
         $ext_names[$i] = trim(preg_replace('/\\[[\\d]]/', "", $ext_names[$i]));
         $msg = translate("Hello") . ", " . $ext_names[$i] . ".\n\n";
         if ($newevent) {
             $msg .= translate("A new appointment has been made for you by");
         } else {
             $msg .= translate("An appointment has been updated by");
         }
         $msg .= " " . $login_fullname . ". " . translate("The subject is") . " \"" . $name . "\"\n\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100) . "\n") . translate("Please look on") . " " . translate($application_name) . ".";
         // add URL to event, if we can figure it out
         /*
         if ( ! empty ( $server_url ) ) {
           $url = $server_url .  "view_entry.php?id=" .  $id;
           $msg .= "\n\n" . $url;
         }
         */
         if (strlen($from)) {
             $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate($application_name);
         } else {
             $extra_hdrs = "X-Mailer: " . translate($application_name);
         }
         mail($ext_emails[$i], translate($application_name) . " " . translate("Notification") . ": " . $name, utf8_decode(html_to_8bits($msg)), $extra_hdrs);
     }
 }
示例#9
0
function event_to_text($id, $date, $time, $duration, $name, $description, $status, $pri, $access, $event_owner)
{
    global $login, $user, $event_template, $report_id, $allow_html_description;
    $time_str = $start_time_str = $end_time_str = '';
    if ($duration == 24 * 60) {
        $time_str = translate("All day event");
    } else {
        if ($time == -1) {
            $time_str = translate("Untimed event");
        } else {
            $time_str = display_time($time);
            $start_time_str = $time_str;
            $time_short = preg_replace("/(:00)/", '', $time_str);
            if ($duration > 0) {
                if ($duration == 24 * 60) {
                    $time_str = translate("All day event");
                } else {
                    // calc end time
                    $h = (int) ($time / 10000);
                    $m = $time / 100 % 100;
                    $m += $duration;
                    $d = $duration;
                    while ($m >= 60) {
                        $h++;
                        $m -= 60;
                    }
                    $end_time = sprintf("%02d%02d00", $h, $m);
                    $time_str .= " - " . display_time($end_time);
                    $end_time_str = display_time($end_time);
                }
            }
        }
    }
    if ($login != $user && $access == 'R' && strlen($user)) {
        $name_str = "(" . translate("Private") . ")";
        $description_str = translate("This event is confidential");
    } else {
        if ($login != $event_owner && $access == 'R' && strlen($event_owner)) {
            $name_str = "(" . translate("Private") . ")";
            $description_str = translate("This event is confidential");
        } else {
            $name_str = htmlspecialchars($name);
            if (!empty($allow_html_description) && $allow_html_description == 'Y') {
                $str = str_replace('&', '&amp;', $description);
                $description_str = str_replace('&amp;amp;', '&amp;', $str);
                if (strstr($description_str, "<") && strstr($description_str, ">")) {
                    // found some HTML
                } else {
                    // No HTML found.  Add line breaks.
                    $description_str = nl2br($description_str);
                }
            } else {
                $description_str = nl2br(activate_urls(htmlspecialchars($description)));
            }
        }
    }
    $date_str = date_to_str($date, "", false);
    $date_full_str = date_to_str($date, "", true, false);
    if ($duration > 0) {
        $duration_str = $duration . ' ' . translate("minutes");
    } else {
        $duration_str = '';
    }
    if ($pri == 1) {
        $pri_str = translate("Low");
    } else {
        if ($pri == 2) {
            $pri_str = translate("Medium");
        } else {
            if ($pri == 3) {
                $pri_str = translate("High");
            }
        }
    }
    if ($status == 'W') {
        $status_str = translate("Waiting for approval");
    } else {
        if ($status == 'D') {
            $status_str = translate("Deleted");
        } else {
            if ($status == 'R') {
                $status_str = translate("Rejected");
            } else {
                if ($status == 'A') {
                    $status_str = translate("Approved");
                } else {
                    $status_str = translate("Unknown");
                }
            }
        }
    }
    $href_str = "view_entry.php?id={$id}";
    // Replace all variables in the event template.
    $text = $event_template;
    $text = str_replace('${name}', $name_str, $text);
    $text = str_replace('${description}', $description_str, $text);
    $text = str_replace('${date}', $date_str, $text);
    $text = str_replace('${dateYmd}', $date, $text);
    $text = str_replace('${fulldate}', $date_full_str, $text);
    $text = str_replace('${time}', $time_str, $text);
    $text = str_replace('${starttime}', $start_time_str, $text);
    $text = str_replace('${endtime}', $end_time_str, $text);
    $text = str_replace('${duration}', $duration_str, $text);
    $text = str_replace('${priority}', $pri_str, $text);
    $text = str_replace('${href}', $href_str, $text);
    $text = str_replace('${id}', $id, $text);
    $text = str_replace('${user}', $event_owner, $text);
    $text = str_replace('${report_id}', $report_id, $text);
    return $text;
}
$sql .= "ORDER BY webcal_entry_log.cal_log_id DESC";
$res = dbi_query($sql);
$nextpage = "";
if ($res) {
    $font = "<FONT SIZE=\"-1\">";
    $num = 0;
    while ($row = dbi_fetch_row($res)) {
        $num++;
        if ($num > $PAGE_SIZE) {
            $nextpage = $row[7];
            break;
        } else {
            echo "<TR>";
            echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . $row[0] . "</FONT></TD>";
            echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . $row[1] . "</FONT></TD>";
            echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . date_to_str($row[3]) . " " . display_time($row[4]) . "</FONT></TD>";
            echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font . "<A HREF=\"view_entry.php?id={$row['5']}\" CLASS=\"navlinks\">" . htmlspecialchars($row[6]) . "</A></FONT></TD>";
            echo "<TD VALIGN=\"top\" BGCOLOR=\"{$CELLBG}\">" . $font;
            if ($row[2] == $LOG_CREATE) {
                etranslate("Event created");
            } else {
                if ($row[2] == $LOG_APPROVE) {
                    etranslate("Event approved");
                } else {
                    if ($row[2] == $LOG_REJECT) {
                        etranslate("Event rejected");
                    } else {
                        if ($row[2] == $LOG_UPDATE) {
                            etranslate("Event updated");
                        } else {
                            if ($row[2] == $LOG_DELETE) {
function format_site_extras($extras, $filter = '')
{
    global $site_extras;
    if (empty($site_extras) || empty($extras)) {
        return;
    }
    $ret = array();
    $extra_view = 1;
    foreach ($site_extras as $site_extra) {
        $data = '';
        $extra_name = $site_extra[0];
        $extra_desc = $site_extra[1];
        $extra_type = $site_extra[2];
        $extra_arg1 = $site_extra[3];
        $extra_arg2 = $site_extra[4];
        if (!empty($site_extra[5]) && !empty($filter)) {
            $extra_view = $site_extra[5] & $filter;
        }
        if (!empty($extras[$extra_name]) && !empty($extras[$extra_name]['cal_name']) && !empty($extra_view)) {
            $name = translate($extra_desc);
            if ($extra_type == EXTRA_DATE) {
                if ($extras[$extra_name]['cal_date'] > 0) {
                    $data = date_to_str($extras[$extra_name]['cal_date']);
                }
            } elseif ($extra_type == EXTRA_TEXT || $extra_type == EXTRA_MULTILINETEXT) {
                $data = nl2br($extras[$extra_name]['cal_data']);
            } elseif ($extra_type == EXTRA_RADIO && !empty($extra_arg1[$extras[$extra_name]['cal_data']])) {
                $data .= $extra_arg1[$extras[$extra_name]['cal_data']];
            } else {
                $data .= $extras[$extra_name]['cal_data'];
            }
            $ret[$extra_name] = array('name' => $name, 'data' => $data);
        }
    }
    return $ret;
}
示例#12
0
    if (is_array($ext_names) && is_array($ext_emails)) {
        $ext_namescnt = count($ext_names);
        for ($i = 0; $i < $ext_namescnt; $i++) {
            if (strlen($ext_names[$i])) {
                if (!dbi_execute('INSERT INTO webcal_entry_ext_user
          ( cal_id, cal_fullname, cal_email ) VALUES ( ?, ?, ? )', array($id, $ext_names[$i], strlen($ext_emails[$i]) ? $ext_emails[$i] : null))) {
                    $error = $dberror . dbi_error();
                }
                // Send mail notification if enabled.
                // TODO:  Move this code into a function...
                if ($EXTERNAL_NOTIFICATIONS == 'Y' && $SEND_EMAIL != 'N' && strlen($ext_emails[$i]) > 0) {
                    if (!$newevent && isset($EXTERNAL_UPDATES) && $EXTERNAL_UPDATES == 'Y' || $newevent) {
                        $fmtdate = $timetype == 'T' ? date('Ymd', $eventstart) : gmdate('Ymd', $eventstart);
                        // Strip [\d] from duplicate Names before emailing.
                        $ext_names[$i] = trim(preg_replace('/\\[[\\d]]/', '', $ext_names[$i]));
                        $msg = str_replace('XXX', $ext_names[$i], $helloStr) . "\n\n" . str_replace('XXX', $login_fullname, $newevent ? $newAppStr : $updAppStr) . "\n" . str_replace('XXX', $name, $subjStr) . "\n\n" . str_replace('XXX', $description, $descStr) . "\n\n" . str_replace('XXX', date_to_str($fmtdate), $dateStr) . "\n" . ($timetype == 'T' ? str_replace('XXX', display_time('', !empty($GENERAL_USE_GMT) && $GENERAL_USE_GMT == 'Y' ? 3 : 6, $eventstart), $timeStr) : '') . $extra_email_data;
                        // Don't send HTML to external adresses.
                        // Always attach iCalendar file to external users
                        $mail->WC_Send($login_fullname, $ext_emails[$i], $ext_names[$i], $name, $msg, 'N', $from, $id);
                    }
                }
            }
        }
    }
    //end external mail
}
//end empty error
// If we were editing this event, then go back to the last view (day, month, week).
// If this is a new event,
// then go to the preferred view for the date range where this event was added.
if (empty($error) && empty($mailerError)) {
示例#13
0
function dbtable_html_list($tablear, $tablename, $href, $fields, $keys, $order)
{
    global $THBG, $THFG, $CELLBG;
    if (!is_array($tablear)) {
        return "Error: dbtable_to_html_list parameter 1 is not an array!\n<br />\n";
    }
    if (!is_array($fields)) {
        return "Error: dbtable_to_html_list parameter 2 is not an array!\n<br />\n";
    }
    if (!is_array($keys)) {
        return "Error: dbtable_to_html_list parameter 3 is not an array!\n<br />\n";
    }
    $ret = "<table style=\"border-width:0px;\" cellspacing=\"0\" cellpadding=\"0\">" . "<tr><td style=\"background-color:#000000;\">" . "<table style=\"border-width:0px; width:100%;\" cellspacing=\"1\" cellpadding=\"2\">" . "<tr><td style=\"width:100%; background-color:{$CELLBG};\">" . "<table style=\"border-width:0px; width:100%;\">\n";
    // header
    $ret .= "<tr>";
    for ($i = 0; $i < count($fields); $i++) {
        $ind = dbtable_get_field_index($tablear, $fields[$i]);
        /*
            if ( $ind < 0 )
              echo "Error: dbtable_html_list invalid fieldname \"$fields[$i]\" $i\n"; exit;
        */
        if (empty($tablear[$ind]["hide"])) {
            $ret .= "<th style=\"background-color:{$THBG}; color:{$THFG};\">" . $tablear[$ind]["prompt"] . "</th>";
        }
    }
    $ret .= "</tr>\n";
    $sql = "SELECT " . $fields[0];
    for ($i = 1; $i < count($fields); $i++) {
        $sql .= ", " . $fields[$i];
    }
    $sql .= " FROM " . $tablename . " ";
    if (is_array($keys) && count($keys) > 0) {
        $sql .= "WHERE ";
        $first = 1;
        for ($i = 0; $i < count($tablear); $i++) {
            if (!empty($tablear[$i]["iskey"])) {
                if (empty($keys[$tablear[$i]["name"]])) {
                    //echo "Error: key value for " . $tablear[$i]["name"] . " not set.\n";
                    //exit;
                } else {
                    if ($first) {
                        $first = 0;
                    } else {
                        $sql .= " AND ";
                    }
                    $sql .= $tablear[$i]["name"] . " = ";
                    if ($tablear[$i]["type"] == "int" || $tablear[$i]["type"] == "float" || $tablear[$i]["type"] == "date") {
                        $sql .= $keys[$tablear[$i]["name"]];
                    } else {
                        $sql .= "'" . $keys[$tablear[$i]["name"]] . "'";
                    }
                }
            }
        }
    }
    if (!empty($order)) {
        $sql .= " ORDER BY " . $order;
    }
    //echo "SQL: $sql<br />\n";
    $res = dbi_query($sql);
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $ret .= "<tr>";
            $first_href = 1;
            $first = 1;
            for ($i = 0; $i < count($fields); $i++) {
                // check data type (date)
                $ind = dbtable_get_field_index($tablear, $fields[$i]);
                if (empty($tablear[$ind]["hide"])) {
                    $ret .= "<td style=\"background-color:{$CELLBG}; vertical-align:top;\">";
                    if ($tablear[$ind]["type"] == "date") {
                        $val = date_to_str($row[$i], "", 1, 1);
                    } else {
                        if ($tablear[$ind]["type"] == "dbdate") {
                            $y = substr($row[$i], 0, 4);
                            $m = substr($row[$i], 5, 2);
                            $d = substr($row[$i], 8, 2);
                            $date = sprintf("%04d%02d%02d", $y, $m, $d);
                            $val = date_to_str($date, "", 1, 1);
                        } else {
                            $val = htmlentities($row[$i]);
                        }
                    }
                    if ($first_href && !empty($href)) {
                        $first_href = 0;
                        $url = $href;
                        for ($j = count($fields) - 1; $j >= 0; $j--) {
                            $url = str_replace("%{$j}", $row[$j], $url);
                        }
                        $ret .= "<a href=\"{$url}\">" . $val . "</a>";
                    } else {
                        $ret .= $val;
                    }
                    $ret .= "</td>";
                }
            }
            $ret .= "</tr>\n";
        }
    } else {
        echo translate("Database error") . ": " . dbi_error();
        exit;
    }
    $ret .= "</table>\n</td></tr></table>\n</td></tr></table>\n";
    return $ret;
}
示例#14
0
文件: week.php 项目: rhertzog/lcs
/* Pre-Load the repeated events for quickier access. */
$repeated_events = read_repeated_events(strlen($user) ? $user : $login, $evStart, $evEnd, $cat_id);
/* Pre-load the non-repeating events for quicker access. */
// Start the search ONE_WEEK early to account for cross-day events.
$events = read_events(strlen($user) ? $user : $login, $evStart - 604800, $evEnd, $cat_id);
if (empty($DISPLAY_TASKS_IN_GRID) || $DISPLAY_TASKS_IN_GRID == 'Y') {
    /* Pre-load tasks for quicker access. */
    $tasks = read_tasks(!empty($user) && strlen($user) && $is_assistant ? $user : $login, $wkend, $cat_id);
}
$eventsStr = $filler = $headerStr = $minical_tasks = $untimedStr = '';
$navStr = display_navigation('week');
for ($i = $start_ind; $i <= $end_ind; $i++) {
    $days[$i] = $wkstart + 86400 * $i + 43200;
    $weekdays[$i] = weekday_name(($i + $WEEK_START) % 7, $DISPLAY_LONG_DAYS);
    $dateYmd = date('Ymd', $days[$i]);
    $header[$i] = $weekdays[$i] . '<br />' . date_to_str($dateYmd, $DATE_FORMAT_MD, false, true);
    // .
    // Generate header row.
    $class = $dateYmd == date('Ymd', $today) ? ' class="today"' : (is_weekend($days[$i]) ? ' class="weekend"' : '');
    $headerStr .= '
              <th ' . $class . '>' . ($can_add ? html_for_add_icon($dateYmd, '', '', $user) : '') . '<p style="margin:.75em 0 0 0"><a href="day.php?' . $u_url . 'date=' . $dateYmd . $caturl . '">' . $header[$i] . '</a></p></th>';
    $date = date('Ymd', $days[$i]);
    $hour_arr = $rowspan_arr = $tk = array();
    // .
    // Get, combine and sort, static and repeating events for this date.
    $ev = combine_and_sort_events(get_entries($date, $get_unapproved), get_repeating_entries($user, $date));
    // .
    // Then sort in any tasks due for this day and before.
    $ev = combine_and_sort_events($ev, $date >= date('Ymd') ? get_tasks($date, $get_unapproved) : $tk);
    for ($j = 0, $cnt = count($ev); $j < $cnt; $j++) {
        if ($get_unapproved || $ev[$j]->getStatus() == 'A') {
示例#15
0
        dbi_free_result($res);
    }
    if ($time != '-1') {
        $hour = substr($time, 0, 2);
        $minute = substr($time, 2, 2);
    }
    for ($i = 0; $i < count($partlogin); $i++) {
        // does this user want email for this?
        $send_user_mail = get_pref_setting($partlogin[$i], "EMAIL_EVENT_REJECTED");
        user_load_variables($partlogin[$i], "temp");
        $user_language = get_pref_setting($partlogin[$i], "LANGUAGE");
        if ($send_user_mail == "Y" && strlen($tempemail) && $send_email != "N") {
            if ($GLOBALS['LANGUAGE'] != $user_language && !empty($user_language) && $user_language != 'none') {
                reset_language($user_language);
            }
            $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been rejected by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . " \"\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100)) . "\n\n\n";
            if (!empty($server_url)) {
                $url = $server_url . "view_entry.php?id=" . $id;
                $msg .= "\n\n" . $url;
            }
            $from = $email_fallback_from;
            if (strlen($login_email)) {
                $from = $login_email;
            }
            $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate("Title");
            mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs);
            activity_log($id, $login, $partlogin[$i], $LOG_NOTIFICATION, "Event rejected by {$app_user}");
        }
    }
}
if (empty($error)) {
示例#16
0
<head>
<title>Upcoming Events</title>
</head>
<body>
<?php 
print "<dl>\n";
print "<!-- \nstartTime: {$startTime}\nendTime: {$endTime}\nstartDate: {$date}\nnumDays: {$numDays}\nuser: {$username}\nevents: " . count($events) . "\nrevents: " . count($revents) . " -->\n";
$numEvents = 0;
for ($i = $startTime; date("Ymd", $i) <= date("Ymd", $endTime) && $numEvents < $maxEvents; $i += 24 * 3600) {
    $d = date("Ymd", $i);
    $entries = get_entries($username, $d);
    $rentries = get_repeating_entries($username, $d);
    print "<!-- {$d} " . count($entries) . "/" . count($rentries) . " -->\n";
    if (count($entries) > 0 || count($rentries) > 0) {
        print "<!-- XXX -->\n";
        print "<dt>" . date_to_str($d) . "</dt>\n<dd>";
        for ($j = 0; $j < count($entries) && $numEvents < $maxEvents; $j++) {
            print_upcoming_event($entries[$j]);
            $numEvents++;
        }
        for ($j = 0; $j < count($rentries) && $numEvents < $maxEvents; $j++) {
            print_upcoming_event($rentries[$j]);
            $numEvents++;
        }
        print "</dd>\n";
    }
}
print "</dl>\n";
print "</body>\n</html>";
// Print the details of an upcoming event
function print_upcoming_event($e)
示例#17
0
function list_unapproved($user)
{
    global $login, $SERVER_URL;
    $count = 0;
    $ret = '';
    $sql = 'SELECT we.cal_id, we.cal_name, we.cal_description, weu.cal_login,
    we.cal_priority, we.cal_date, we.cal_time, we.cal_duration,
    weu.cal_status, we.cal_type
    FROM webcal_entry we, webcal_entry_user weu
    WHERE we.cal_id = weu.cal_id AND weu.cal_login = ? AND weu.cal_status = \'W\'
    ORDER BY weu.cal_login, we.cal_date';
    $rows = dbi_get_cached_rows($sql, array($user));
    if ($rows) {
        $allDayStr = translate('All day event');
        $appConStr = translate('Approve/Confirm');
        $appSelStr = translate('Approve Selected');
        $checkAllStr = translate('Check All');
        $deleteStr = translate('Delete');
        $emailStr = translate('Emails Will Not Be Sent');
        $rejectSelStr = translate('Reject Selected');
        $rejectStr = translate('Reject');
        $uncheckAllStr = translate('Uncheck All');
        $viewStr = translate('View this entry');
        for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) {
            $row = $rows[$i];
            $id = $row[0];
            $name = $row[1];
            $description = $row[2];
            $cal_user = $row[3];
            $pri = $row[4];
            $date = $row[5];
            $time = sprintf("%06d", $row[6]);
            $duration = $row[7];
            $status = $row[8];
            $type = $row[9];
            $view_link = 'view_entry';
            $entryID = 'entry' . $type . $id;
            $unixtime = date_to_epoch($date . $time);
            $timestr = '';
            if ($time > 0 || $time == 0 && $duration != 1440) {
                $eventstart = date_to_epoch($date . $time);
                $eventstop = $eventstart + $duration;
                $eventdate = date_to_str(date('Ymd', $eventstart));
                $timestr = display_time('', 0, $eventstart) . ($duration > 0 ? ' - ' . display_time('', 0, $eventstop) : '');
            } else {
                // Don't shift date if All Day or Untimed.
                $eventdate = date_to_str($date);
                // If All Day display in popup.
                if ($time == 0 && $duration == 1440) {
                    $timestr = $allDayStr;
                }
            }
            $ret .= "<item>\n" . '  <title><![CDATA[' . htmlspecialchars($name) . ']]></title>' . "\n  <link>" . $SERVER_URL . $view_link . '.php?id=' . $id . '&amp;user='******'  <description><![CDATA[' . $description . ']]></description>' . "\n";
            $ret .= '  <category><![CDATA[' . $category . ']]></category>' . "\n";
            /* RSS 2.0 date format Wed, 02 Oct 2002 13:00:00 GMT */
            $ret .= '<pubDate>' . gmdate('D, d M Y H:i:s', $unixtime) . ' GMT</pubDate>' . "\n" . '  <guid>' . $SERVER_URL . 'view_entry.php?id=' . $id . '&amp;friendly=1&amp;rssuser='******'&amp;date=' . $d . "</guid>\n";
            $ret .= "</item>\n\n";
        }
    }
    return $ret;
}
示例#18
0
        $show_log = true;
    }
}
if ($show_log) {
    echo "<h3>" . translate("Activity Log") . "</h3>\n";
    echo "<table class=\"embactlog\">\n";
    echo "<tr><th class=\"usr\">\n" . translate("User") . "</th><th class=\"cal\">\n";
    echo translate("Calendar") . "</th><th class=\"date\">\n";
    echo translate("Date") . "/" . translate("Time") . "</th><th class=\"action\">\n";
    echo translate("Action") . "\n</th></tr>\n";
    $res = dbi_query("SELECT cal_login, cal_user_cal, cal_type, " . "cal_date, cal_time " . "FROM webcal_entry_log WHERE cal_entry_id = {$id} " . "ORDER BY cal_log_id DESC");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            echo "<tr><td>\n";
            echo $row[0] . "</td><td>\n";
            echo $row[1] . "</td><td>\n" . date_to_str($row[3]) . "&nbsp;" . display_time($row[4]) . "</td><td>\n";
            if ($row[2] == $LOG_CREATE) {
                etranslate("Event created");
            } else {
                if ($row[2] == $LOG_APPROVE) {
                    etranslate("Event approved");
                } else {
                    if ($row[2] == $LOG_REJECT) {
                        etranslate("Event rejected");
                    } else {
                        if ($row[2] == $LOG_UPDATE) {
                            etranslate("Event updated");
                        } else {
                            if ($row[2] == $LOG_DELETE) {
                                etranslate("Event deleted");
                            } else {
示例#19
0
$thisdate = date("Ymd", $d_time);
$wday = date("w", $d_time);
// $WEEK_START equals 1 or 0
$wkstart = mktime(3, 0, 0, $m, $d - ($wday - $WEEK_START), $y);
for ($i = -7; $i <= 7; $i++) {
    $twkstart = $wkstart + 3600 * 24 * 7 * $i;
    $twkend = $twkstart + 3600 * 24 * 6;
    echo "<option value=\"" . date("Ymd", $twkstart) . "\"";
    if (date("Ymd", $twkstart) <= $thisdate && date("Ymd", $twkend) >= $thisdate) {
        echo " selected=\"selected\"";
    }
    echo ">";
    if (!empty($GLOBALS['PULLDOWN_WEEKNUMBER']) && ($GLOBALS['PULLDOWN_WEEKNUMBER'] = "Y")) {
        echo "(" . week_number($twkstart) . ")&nbsp;&nbsp;";
    }
    printf("%s - %s", date_to_str(date("Ymd", $twkstart), $DATE_FORMAT_MD, false, true), date_to_str(date("Ymd", $twkend), $DATE_FORMAT_MD, false, true));
    echo "</option>\n";
}
?>
</select>
<input type="submit" value="<?php 
etranslate("Go");
?>
" />
</form>

<form action="year.php" method="get" name="SelectYear" id="yearform">
<?php 
if (!empty($user) && $user != $login) {
    echo "<input type=\"hidden\" name=\"user\" value=\"{$user}\" />\n";
}
示例#20
0
function list_unapproved($user)
{
    global $temp_fullname, $key, $login;
    //echo "Listing events for $user <br>";
    $sql = "SELECT webcal_entry.cal_id, webcal_entry.cal_name, " . "webcal_entry.cal_description, " . "webcal_entry.cal_priority, webcal_entry.cal_date, " . "webcal_entry.cal_time, webcal_entry.cal_duration, " . "webcal_entry_user.cal_status " . "FROM webcal_entry, webcal_entry_user " . "WHERE webcal_entry.cal_id = webcal_entry_user.cal_id " . "AND ( webcal_entry.cal_ext_for_id IS NULL " . "OR webcal_entry.cal_ext_for_id = 0 ) AND " . "webcal_entry_user.cal_login = '******' AND " . "webcal_entry_user.cal_status = 'W' " . "ORDER BY webcal_entry.cal_date";
    $res = dbi_query($sql);
    $count = 0;
    $eventinfo = "";
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            if ($count == 0) {
                echo "<ul>\n";
            }
            $key++;
            $id = $row[0];
            $name = $row[1];
            $description = $row[2];
            $pri = $row[3];
            $date = $row[4];
            $time = $row[5];
            $duration = $row[6];
            $status = $row[7];
            $divname = "eventinfo-{$id}-{$key}";
            echo "<li><a title=\"" . translate("View this entry") . "\" class=\"entry\" href=\"view_entry.php?id={$id}&amp;user={$user}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; show(event, '{$divname}'); return true;\" onmouseout=\"hide('{$divname}'); return true;\">";
            $timestr = "";
            if ($time > 0) {
                $timestr = display_time($time);
                if ($duration > 0) {
                    // calc end time
                    $h = (int) ($time / 10000);
                    $m = $time / 100 % 100;
                    $m += $duration;
                    $d = $duration;
                    while ($m >= 60) {
                        $h++;
                        $m -= 60;
                    }
                    $end_time = sprintf("%02d%02d00", $h, $m);
                    $timestr .= " - " . display_time($end_time);
                }
            }
            echo htmlspecialchars($name);
            echo "</a>";
            echo " (" . date_to_str($date) . ")\n";
            //approve
            echo ": <a title=\"" . translate("Approve/Confirm") . "\"  href=\"approve_entry.php?id={$id}&amp;ret=list&amp;user={$user}";
            if ($user == "__public__") {
                echo "&amp;public=1";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Approve this entry?") . "');\">" . translate("Approve/Confirm") . "</a>, ";
            //reject
            echo "<a title=\"" . translate("Reject") . "\" href=\"reject_entry.php?id={$id}&amp;ret=list&amp;user={$user}";
            if ($user == "__public__") {
                echo "&amp;public=1";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Reject this entry?") . "');\">" . translate("Reject") . "</a>";
            //delete
            echo ", <a title=\"" . translate("Delete") . "\" href=\"del_entry.php?id={$id}&amp;ret=list";
            if ($user != $login) {
                echo "&amp;user={$user}";
            }
            echo "\" class=\"nav\" onclick=\"return confirm('" . translate("Are you sure you want to delete this entry?") . "');\">" . translate("Delete") . "</a>";
            echo "\n</li>\n";
            $eventinfo .= build_event_popup($divname, $user, $description, $timestr, site_extras_for_popup($id));
            $count++;
        }
        dbi_free_result($res);
        if ($count > 0) {
            echo "</ul>\n";
        }
    }
    if ($count == 0) {
        user_load_variables($user, "temp_");
        echo "<span class=\"nounapproved\">" . translate("No unapproved events for") . "&nbsp;" . $temp_fullname . ".</span>\n";
    } else {
        if (!empty($eventinfo)) {
            echo $eventinfo;
        }
    }
}
示例#21
0
function send_reminder($id, $event_date)
{
    global $names, $emails, $site_extras, $debug, $only_testing, $server_url, $languages, $tzoffset, $application_name;
    global $EXTRA_TEXT, $EXTRA_MULTILINETEXT, $EXTRA_URL, $EXTRA_DATE, $EXTRA_EMAIL, $EXTRA_USER, $EXTRA_REMINDER, $LANGUAGE, $LOG_REMINDER;
    global $allow_external_users, $external_reminders;
    $pri[1] = translate("Low");
    $pri[2] = translate("Medium");
    $pri[3] = translate("High");
    // get participants first...
    $sql = "SELECT cal_login FROM webcal_entry_user " . "WHERE cal_id = {$id} AND cal_status IN ('A','W') " . "ORDER BY cal_login";
    $res = dbi_query($sql);
    $participants = array();
    $num_participants = 0;
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $participants[$num_participants++] = $row[0];
        }
    }
    // get external participants
    $ext_participants = array();
    $num_ext_participants = 0;
    if (!empty($allow_external_users) && $allow_external_users == "Y" && !empty($external_reminders) && $external_reminders == "Y") {
        $sql = "SELECT cal_fullname, cal_email FROM webcal_entry_ext_user " . "WHERE cal_id = {$id} AND cal_email IS NOT NULL " . "ORDER BY cal_fullname";
        $res = dbi_query($sql);
        if ($res) {
            while ($row = dbi_fetch_row($res)) {
                $ext_participants[$num_ext_participants] = $row[0];
                $ext_participants_email[$num_ext_participants++] = $row[1];
            }
        }
    }
    if (!$num_participants && !$num_ext_participants) {
        if ($debug) {
            echo "No participants found for event id: {$id} <br />\n";
        }
        return;
    }
    // get event details
    $res = dbi_query("SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " . "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " . "cal_name, cal_description FROM webcal_entry WHERE cal_id = {$id}");
    if (!$res) {
        echo "Db error: could not find event id {$id}.\n";
        return;
    }
    if (!($row = dbi_fetch_row($res))) {
        echo "Error: could not find event id {$id} in database.\n";
        return;
    }
    // send mail.  we send one user at a time so that we can switch
    // languages between users if needed.
    $mailusers = array();
    $recipients = array();
    if (isset($single_user) && $single_user == "Y") {
        $mailusers[] = $emails[$single_user_login];
        $recipients[] = $single_user_login;
    } else {
        for ($i = 0; $i < count($participants); $i++) {
            if (strlen($emails[$participants[$i]])) {
                $mailusers[] = $emails[$participants[$i]];
                $recipients[] = $participants[$i];
            } else {
                if ($debug) {
                    echo "No email for user {$participants[$i]} <br />\n";
                }
            }
        }
        for ($i = 0; $i < count($ext_participants); $i++) {
            $mailusers[] = $ext_participants_email[$i];
            $recipients[] = $ext_participants[$i];
        }
    }
    if ($debug) {
        echo "Found " . count($mailusers) . " with email addresses <br />\n";
    }
    for ($j = 0; $j < count($mailusers); $j++) {
        $recip = $mailusers[$j];
        $user = $participants[$j];
        if (!empty($languages[$user])) {
            $userlang = $languages[$user];
        } else {
            $userlang = $LANGUAGE;
        }
        // system default
        if ($userlang == "none") {
            $userlang = "English-US";
        }
        // gotta pick something
        if ($debug) {
            echo "Setting language to \"{$userlang}\" <br />\n";
        }
        reset_language($userlang);
        // reset timezone setting for current user
        if (empty($tzoffset[$user])) {
            $GLOBALS["TZ_OFFSET"] = 0;
        } else {
            $GLOBALS["TZ_OFFSET"] = $tzoffset[$user];
        }
        $body = translate("This is a reminder for the event detailed below.") . "\n\n";
        $create_by = $row[0];
        $name = $row[9];
        $description = $row[10];
        // add trailing '/' if not found in server_url
        if (!empty($server_url)) {
            if (substr($server_url, -1, 1) == "/") {
                $body .= $server_url . "view_entry.php?id=" . $id . "\n\n";
            } else {
                $body .= $server_url . "/view_entry.php?id=" . $id . "\n\n";
            }
        }
        $body .= strtoupper($name) . "\n\n";
        $body .= translate("Description") . ":\n";
        $body .= indent($description) . "\n";
        $body .= translate("Date") . ": " . date_to_str($event_date) . "\n";
        if ($row[2] >= 0) {
            $body .= translate("Time") . ": " . display_time($row[2]) . "\n";
        }
        if ($row[5] > 0) {
            $body .= translate("Duration") . ": " . $row[5] . " " . translate("minutes") . "\n";
        }
        if (!empty($disable_priority_field) && !$disable_priority_field) {
            $body .= translate("Priority") . ": " . $pri[$row[6]] . "\n";
        }
        if (!empty($disable_access_field) && !$disable_access_field) {
            $body .= translate("Access") . ": " . ($row[8] == "P" ? translate("Public") : translate("Confidential")) . "\n";
        }
        if (!empty($single_user_login) && $single_user_login == false) {
            $body .= translate("Created by") . ": " . $row[0] . "\n";
        }
        $body .= translate("Updated") . ": " . date_to_str($row[3]) . " " . display_time($row[4]) . "\n";
        // site extra fields
        $extras = get_site_extra_fields($id);
        for ($i = 0; $i < count($site_extras); $i++) {
            $extra_name = $site_extras[$i][0];
            $extra_descr = $site_extras[$i][1];
            $extra_type = $site_extras[$i][2];
            if ($extras[$extra_name]['cal_name'] != "") {
                $body .= translate($extra_descr) . ": ";
                if ($extra_type == $EXTRA_DATE) {
                    $body .= date_to_str($extras[$extra_name]['cal_date']) . "\n";
                } else {
                    if ($extra_type == $EXTRA_MULTILINETEXT) {
                        $body .= "\n" . indent($extras[$extra_name]['cal_data']) . "\n";
                    } else {
                        if ($extra_type == $EXTRA_REMINDER) {
                            $body .= ($extras[$extra_name]['cal_remind'] > 0 ? translate("Yes") : translate("No")) . "\n";
                        } else {
                            // default method for $EXTRA_URL, $EXTRA_TEXT, etc...
                            $body .= $extras[$extra_name]['cal_data'] . "\n";
                        }
                    }
                }
            }
        }
        if (!empty($single_user) && $single_user != "Y" && !empty($disable_participants_field) && !$disable_participants_field) {
            $body .= translate("Participants") . ":\n";
            for ($i = 0; $i < count($participants); $i++) {
                $body .= "  " . $names[$participants[$i]] . "\n";
            }
            for ($i = 0; $i < count($ext_participants); $i++) {
                $body .= "  " . $ext_participants[$i] . " (" . translate("External User") . ")\n";
            }
        }
        $subject = translate("Reminder") . ": " . $name;
        if (strlen($GLOBALS["email_fallback_from"])) {
            $extra_hdrs = "From: " . $GLOBALS["email_fallback_from"] . "\r\n" . "X-Mailer: " . translate($application_name);
        } else {
            $extra_hdrs = "X-Mailer: " . translate($application_name);
        }
        if ($debug) {
            echo "Sending mail to {$recip} (in {$userlang})\n";
        }
        if ($only_testing) {
            if ($debug) {
                echo "<hr /><pre>To: {$recip}\nSubject: {$subject}\n{$extra_hdrs}\n\n{$body}\n\n</pre>\n";
            }
        } else {
            mail($recip, $subject, $body, $extra_hdrs);
            activity_log($id, "system", $user, $LOG_REMINDER, "");
        }
    }
}
示例#22
0
文件: pref.php 项目: rohcehlam/rflow
;">
<br />

<!-- BEGIN EXAMPLE MONTH -->
<table style="border:0px; width:100%;"><tr>
<td style="text-align:center; color:<?php 
    echo $H2COLOR;
    ?>
; font-weight:bold;"><?php 
    $today = mktime(3, 0, 0, 12, 13, 2000);
    if ($prefarray["WEEK_START"] == 1) {
        $wkstart = get_monday_before(2000, 12, 1);
    } else {
        $wkstart = get_sunday_before(2000, 12, 1);
    }
    echo date_to_str("20001201", $DATE_FORMAT_MY, false, false);
    ?>
</td></tr>
</table>

<table style="border-width:0px; width:90%;" cellspacing="0" cellpadding="0">
<tr><td style="background-color:<?php 
    echo $TABLEBG;
    ?>
;">
<table style="border-width:0px; width:100%;" cellspacing="1" cellpadding="2">
<tr>
<?php 
    if ($prefarray["WEEK_START"] == 0) {
        ?>
<th style="width:14%;" class="tableheader"><?php 
示例#23
0
    $v = array();
    echo translate('Add Group') . '</h2>
      <input type="hidden" name="add" value="1';
} else {
    echo translate('Edit Group') . '</h2>
      <input type="hidden" name="id" value="' . $id;
}
echo '" />
      <table>
        <tr>
          <td class="bold"><label for="groupname">' . translate('Group name') . ':</label></td>
          <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);
}
            // Don't search confidential entries of other users.
            $sql .= "AND ( webcal_entry_user.cal_login = '******' OR " . "( webcal_entry_user.cal_login != '{$login}' AND " . "webcal_entry.cal_access = 'P' ) ) ";
        }
        $sql .= "AND ( UPPER(webcal_entry.cal_name) " . "LIKE UPPER('%" . $words[$i] . "%') " . "OR UPPER(webcal_entry.cal_description) " . "LIKE UPPER('%" . $words[$i] . "%') ) " . "ORDER BY cal_date";
        //echo "SQL: $sql<br />";
        $res = dbi_query($sql);
        if ($res) {
            while ($row = dbi_fetch_row($res)) {
                $matches++;
                $idstr = strval($row[0]);
                if (empty($ids[$idstr])) {
                    $ids[$idstr] = 1;
                } else {
                    $ids[$idstr]++;
                }
                $info[$idstr] = "{$row['1']} (" . date_to_str($row[2]) . ")";
            }
        }
        dbi_free_result($res);
    }
}
if ($matches > 0) {
    $matches = count($ids);
}
if ($matches == 1) {
    echo "<span style=\"font-weight:bold;\">{$matches} " . translate("match found") . ".</span><br /><br />";
} else {
    if ($matches > 0) {
        echo "<span style=\"font-weight:bold;\">{$matches} " . translate("matches found") . ".</span><br /><br />";
    } else {
        echo translate("No matches found") . ".";
示例#25
0
文件: day.php 项目: noikiy/owaspbwa
<a title="<?php 
etranslate("Previous");
?>
" class="prev" href="day.php?<?php 
echo $u_url;
?>
date=<?php 
echo $prevYmd . $caturl;
?>
"><img src="leftarrow.gif" alt="<?php 
etranslate("Previous");
?>
" /></a>
<div class="title">
<span class="date"><?php 
echo date_to_str($nowYmd);
?>
</span>
<span class="user"><?php 
// display current calendar's user (if not in single user)
if ($single_user == "N") {
    echo "<br />";
    echo $user_fullname;
}
if ($is_nonuser_admin) {
    echo "<br />-- " . translate("Admin mode") . " --";
}
if ($is_assistant) {
    echo "<br />-- " . translate("Assistant mode") . " --";
}
?>
function import_data($data, $overwrite, $type)
{
    global $login, $count_con, $count_suc, $error_num, $ImportType, $LOG_CREATE;
    global $single_user, $single_user_login, $allow_conflicts;
    global $numDeleted, $errormsg;
    global $calUser, $H2COLOR, $sqlLog;
    $oldUIDs = array();
    $oldIds = array();
    $firstEventId = 0;
    $importId = 1;
    // Generate a unique import id
    $res = dbi_query("SELECT MAX(cal_import_id) FROM webcal_import");
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            $importId = $row[0] + 1;
        }
        dbi_free_result($res);
    }
    $sql = "INSERT INTO webcal_import ( cal_import_id, cal_name, " . "cal_date, cal_type, cal_login ) VALUES ( {$importId}, NULL, " . date("Ymd") . ", '{$type}', '{$login}' )";
    if (!dbi_query($sql)) {
        $errormsg = translate("Database error") . ": " . dbi_error();
        return;
    }
    foreach ($data as $Entry) {
        $priority = 2;
        $participants[0] = $calUser;
        // Some additional date/time info
        $START = $Entry['StartTime'] > 0 ? localtime($Entry['StartTime']) : 0;
        $END = $Entry['EndTime'] > 0 ? localtime($Entry['EndTime']) : 0;
        $Entry['StartMinute'] = sprintf("%02d", $START[1]);
        $Entry['StartHour'] = sprintf("%02d", $START[2]);
        $Entry['StartDay'] = sprintf("%02d", $START[3]);
        $Entry['StartMonth'] = sprintf("%02d", $START[4] + 1);
        $Entry['StartYear'] = sprintf("%04d", $START[5] + 1900);
        $Entry['EndMinute'] = sprintf("%02d", $END[1]);
        $Entry['EndHour'] = sprintf("%02d", $END[2]);
        $Entry['EndDay'] = sprintf("%02d", $END[3]);
        $Entry['EndMonth'] = sprintf("%02d", $END[4] + 1);
        $Entry['EndYear'] = sprintf("%04d", $END[5] + 1900);
        if ($overwrite && !empty($Entry['UID'])) {
            $oldUIDs[$Entry['UID']]++;
        }
        // Check for untimed
        if ($Entry['Untimed'] == 1) {
            $Entry['StartMinute'] = '';
            $Entry['StartHour'] = '';
            $Entry['EndMinute'] = '';
            $Entry['EndHour'] = '';
        }
        // first check for any schedule conflicts
        if (empty($allow_conflicts) && $Entry['Duration'] != 0) {
            $date = mktime(0, 0, 0, $Entry['StartMonth'], $Entry['StartDay'], $Entry['StartYear']);
            $endt = !empty($Entry['Repeat']['EndTime']) ? $Entry['Repeat']['EndTime'] : 'NULL';
            $dayst = !empty($Entry['Repeat']['RepeatDays']) ? $Entry['Repeat']['RepeatDays'] : "nnnnnnn";
            $ex_days = array();
            if (!empty($Entry['Repeat']['Exceptions'])) {
                foreach ($Entry['Repeat']['Exceptions'] as $ex_date) {
                    $ex_days[] = date("Ymd", $ex_date);
                }
            }
            $dates = get_all_dates($date, RepeatType($Entry['Repeat']['Interval']), $endt, $dayst, $ex_days, $Entry['Repeat']['Frequency']);
            $overlap = overlap($dates, $Entry['Duration'], $Entry['StartHour'], $Entry['StartMinute'], $participants, $login, 0);
        }
        if (empty($error) && !empty($overlap)) {
            $error = translate("The following conflicts with the suggested time") . ":<ul>{$overlap}</ul>\n";
        }
        if (empty($error)) {
            $updateMode = false;
            // See if event already is there from prior import.
            // The same UID is used for all events imported at once with iCal.
            // So, we still don't have enough info to find the exact
            // event we want to replace.  We could just delete all
            // existing events that correspond to the UID.
            /************************************************************************
              Not sure what to do with this code since I don't know how Palm and vCal
              use the UID stuff yet...
              
                  if ( ! empty ( $Entry['UID'] ) ) {
                    $res = dbi_query ( "SELECT webcal_import_data.cal_id " .
                      "FROM webcal_import_data, webcal_entry_user " .
                      "WHERE cal_import_type = 'ical' AND " .
                      "webcal_import_data.cal_id = webcal_entry_user.cal_id AND " .
                      "webcal_entry_user.cal_login = '******' AND " .
                      "cal_external_id = '$Entry[UID]'" );
                    if ( $res ) {
                      if ( $row = dbi_fetch_row ( $res ) ) {
                        if ( ! empty ( $row[0] ) ) {
                          $id = $row[0];
                          $updateMode = true;
                          // update rather than add a new event
                        }
                      }
                    }
                  }
            ************************************************************************/
            // Add the Event
            $res = dbi_query("SELECT MAX(cal_id) FROM webcal_entry");
            if ($res) {
                $row = dbi_fetch_row($res);
                $id = $row[0] + 1;
                dbi_free_result($res);
            } else {
                $id = 1;
                //$error = "Unable to select MAX cal_id: " . dbi_error () . "<br /><br />\n<b>SQL:</b> $sql";
                //break;
            }
            if ($firstEventId == 0) {
                $firstEventId = $id;
            }
            $names = array();
            $values = array();
            $names[] = 'cal_id';
            $values[] = "{$id}";
            if (!$updateMode) {
                $names[] = 'cal_create_by';
                $values[] = "'{$login}'";
            }
            $names[] = 'cal_date';
            $values[] = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']);
            $names[] = 'cal_time';
            $values[] = $Entry['Untimed'] == 1 ? "-1" : sprintf("%02d%02d00", $Entry['StartHour'], $Entry['StartMinute']);
            $names[] = 'cal_mod_date';
            $values[] = date("Ymd");
            $names[] = 'cal_mod_time';
            $values[] = date("Gis");
            $names[] = 'cal_duration';
            $values[] = sprintf("%d", $Entry['Duration']);
            $names[] = 'cal_priority';
            $values[] = $priority;
            $names[] = 'cal_access';
            $values[] = $Entry['Private'] == 1 ? "'R'" : "'P'";
            $names[] = 'cal_type';
            $values[] = $Entry['Repeat'] ? "'M'" : "'E'";
            if (strlen($Entry['Summary']) == 0) {
                $Entry['Summary'] = translate("Unnamed Event");
            }
            if (strlen($Entry['Description']) == 0) {
                $Entry['Description'] = $Entry['Summary'];
            }
            $Entry['Summary'] = str_replace("\\n", "\n", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\'", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\\"", "\"", $Entry['Summary']);
            $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']);
            $names[] = 'cal_name';
            $values[] = "'" . $Entry['Summary'] . "'";
            $Entry['Description'] = str_replace("\\n", "\n", $Entry['Description']);
            $Entry['Description'] = str_replace("\\'", "'", $Entry['Description']);
            $Entry['Description'] = str_replace("\\\"", "\"", $Entry['Description']);
            $Entry['Description'] = str_replace("'", "\\'", $Entry['Description']);
            // limit length to 1024 chars since we setup tables that way
            if (strlen($Entry['Description']) >= 1024) {
                $Entry['Description'] = substr($Entry['Description'], 0, 1019) . "...";
            }
            $names[] = 'cal_description';
            $values[] = "'" . $Entry['Description'] . "'";
            //echo "Summary:<p>" . nl2br ( htmlspecialchars ( $Entry['Summary'] ) ) . "</p>";
            //echo "Description:<p>" . nl2br ( htmlspecialchars ( $Entry['Description'] ) ) . "</p>"; exit;
            if ($updateMode) {
                $sql = "UPDATE webcal_entry SET ";
                for ($f = 0; $f < count($names); $f++) {
                    if ($f > 0) {
                        $sql .= ", ";
                    }
                    $sql .= $names[$f] . " = " . $values[$f];
                }
                $sql .= " WHERE cal_id = {$id}";
            } else {
                $sql = "INSERT INTO webcal_entry ( " . implode(", ", $names) . " ) VALUES ( " . implode(", ", $values) . " )";
            }
            if (empty($error)) {
                $sqlLog .= $sql . "<br />\n";
                //echo "SQL: $sql <br />\n";
                if (!dbi_query($sql)) {
                    $error .= "<p>" . translate("Database error") . ": " . dbi_error() . "</p>\n";
                    break;
                }
            }
            // log add/update
            activity_log($id, $login, $login, $updateMode ? $LOG_UPDATE : $LOG_CREATE, "Import from {$ImportType}");
            if ($single_user == "Y") {
                $participants[0] = $single_user_login;
            }
            // Now add to webcal_import_data
            if (!$updateMode) {
                if ($ImportType == "PALMDESKTOP") {
                    $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'palm', '{$Entry['RecordID']}' )";
                    $sqlLog .= $sql . "<br />\n";
                    if (!dbi_query($sql)) {
                        $error = translate("Database error") . ": " . dbi_error();
                        break;
                    }
                } else {
                    if ($ImportType == "VCAL") {
                        $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'";
                        if (strlen($uid) > 200) {
                            $uid = "NULL";
                        }
                        $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'vcal', {$uid} )";
                        $sqlLog .= $sql . "<br />\n";
                        if (!dbi_query($sql)) {
                            $error = translate("Database error") . ": " . dbi_error();
                            break;
                        }
                    } else {
                        if ($ImportType == "ICAL") {
                            $uid = empty($Entry['UID']) ? "null" : "'{$Entry['UID']}'";
                            if (strlen($uid) > 200) {
                                $uid = "NULL";
                            }
                            $sql = "INSERT INTO webcal_import_data ( cal_import_id, cal_id, " . "cal_login, cal_import_type, cal_external_id ) VALUES ( " . "{$importId}, {$id}, '{$calUser}', 'ical', {$uid} )";
                            $sqlLog .= $sql . "<br />\n";
                            if (!dbi_query($sql)) {
                                $error = translate("Database error") . ": " . dbi_error();
                                break;
                            }
                        }
                    }
                }
            }
            // Now add participants
            if (!$updateMode) {
                $status = $login == "__public__" ? 'W' : 'A';
                if (empty($cat_id)) {
                    $cat_id = 'NULL';
                }
                $sql = "INSERT INTO webcal_entry_user " . "( cal_id, cal_login, cal_status, cal_category ) VALUES ( {$id}, '" . $participants[0] . "', '{$status}', {$cat_id} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = translate("Database error") . ": " . dbi_error();
                    break;
                }
            }
            // Add repeating info
            if ($updateMode) {
                // remove old repeating info
                dbi_query("DELETE FROM webcal_entry_repeats WHERE cal_id = {$id}");
                dbi_query("DELETE FROM webcal_entry_repeats_not WHERE cal_id = {$id}");
            }
            if (!empty($Entry['Repeat']['Interval'])) {
                //while ( list($k,$v) = each ( $Entry['Repeat'] ) ) {
                //  echo "$k: $v <br />\n";
                //}
                $rpt_type = RepeatType($Entry['Repeat']['Interval']);
                $freq = $Entry['Repeat']['Frequency'] ? $Entry['Repeat']['Frequency'] : 1;
                if (strlen($Entry['Repeat']['EndTime'])) {
                    $REND = localtime($Entry['Repeat']['EndTime']);
                    $end = sprintf("%04d%02d%02d", $REND[5] + 1900, $REND[4] + 1, $REND[3]);
                } else {
                    $end = 'NULL';
                }
                $days = !empty($Entry['Repeat']['RepeatDays']) ? "'" . $Entry['Repeat']['RepeatDays'] . "'" : 'NULL';
                $sql = "INSERT INTO webcal_entry_repeats ( cal_id, " . "cal_type, cal_end, cal_days, cal_frequency ) VALUES " . "( {$id}, '{$rpt_type}', {$end}, {$days}, {$freq} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = "Unable to add to webcal_entry_repeats: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}";
                    break;
                }
                // Repeating Exceptions...
                if (!empty($Entry['Repeat']['Exceptions'])) {
                    foreach ($Entry['Repeat']['Exceptions'] as $ex_date) {
                        $ex_date = date("Ymd", $ex_date);
                        $sql = "INSERT INTO webcal_entry_repeats_not ( cal_id, cal_date ) VALUES ( {$id}, {$ex_date} )";
                        $sqlLog .= $sql . "<br />\n";
                        if (!dbi_query($sql)) {
                            $error = "Unable to add to webcal_entry_repeats_not: " . dbi_error() . "<br /><br />\n<b>SQL:</b> {$sql}";
                            break;
                        }
                    }
                }
            }
            // End Repeat
            // Add Alarm info -> site_extras
            if ($updateMode) {
                dbi_query("DELETE FROM webcal_site_extras WHERE cal_id = {$id}");
            }
            if ($Entry['AlarmSet'] == 1) {
                $RM = $Entry['AlarmAdvanceAmount'];
                if ($Entry['AlarmAdvanceType'] == 1) {
                    $RM = $RM * 60;
                }
                if ($Entry['AlarmAdvanceType'] == 2) {
                    $RM = $RM * 60 * 24;
                }
                $sql = "INSERT INTO webcal_site_extras ( cal_id, " . "cal_name, cal_type, cal_remind, cal_data ) VALUES " . "( {$id}, 'Reminder', 7, 1, {$RM} )";
                $sqlLog .= $sql . "<br />\n";
                if (!dbi_query($sql)) {
                    $error = translate("Database error") . ": " . dbi_error();
                }
            }
        }
        if (!empty($error) && empty($overlap)) {
            $error_num++;
            echo "<h2>" . translate("Error") . "</h2>\n<blockquote>\n";
            echo $error . "</blockquote>\n<br />\n";
        }
        // Conflicting
        if (!empty($overlap)) {
            echo "<b><h2>" . translate("Scheduling Conflict") . ": ";
            $count_con++;
            echo "</h2></b>";
            if ($Entry['Duration'] > 0) {
                $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00");
            }
            $dd = $Entry['StartMonth'] . "-" . $Entry['StartDay'] . "-" . $Entry['StartYear'];
            echo "<a class=\"entry\" href=\"view_entry.php?id={$id}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">";
            $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("'", "\\'", $Entry['Summary']);
            echo htmlspecialchars($Entry['Summary']);
            echo "</a> (" . $dd;
            $time = trim($time);
            if (!empty($time)) {
                echo "&nbsp; " . $time;
            }
            echo ")<br />\n";
            etranslate("conflicts with the following existing calendar entries");
            echo ":<ul>\n" . $overlap . "</ul>\n";
        } else {
            // No Conflict
            echo "<b><h2>" . translate("Event Imported") . ":</h2></b>\n";
            $count_suc++;
            if ($Entry['Duration'] > 0) {
                $time = display_time($Entry['StartHour'] . $Entry['StartMinute'] . "00") . " - " . display_time($Entry['EndHour'] . $Entry['EndMinute'] . "00");
            }
            $dateYmd = sprintf("%04d%02d%02d", $Entry['StartYear'], $Entry['StartMonth'], $Entry['StartDay']);
            $dd = date_to_str($dateYmd);
            echo "<a class=\"entry\" href=\"view_entry.php?id={$id}";
            echo "\" onmouseover=\"window.status='" . translate("View this entry") . "'; return true;\" onmouseout=\"window.status=''; return true;\">";
            $Entry['Summary'] = str_replace("''", "'", $Entry['Summary']);
            $Entry['Summary'] = str_replace("\\", "", $Entry['Summary']);
            echo htmlspecialchars($Entry['Summary']);
            echo "</a> (" . $dd;
            if (!empty($time)) {
                echo "&nbsp; " . $time;
            }
            echo ")<br />\n";
        }
        // Reset Variables
        $overlap = $error = $dd = $time = '';
    }
    // Mark old events from prior import as deleted.
    if ($overwrite && count($oldUIDs) > 0) {
        // We could do this with a single SQL using sub-select, but
        // I'm pretty sure MySQL does not support it.
        $old = array_keys($oldUIDs);
        for ($i = 0; $i < count($old); $i++) {
            $sql = "SELECT cal_id FROM webcal_import_data WHERE " . "cal_import_type = '{$type}' AND " . "cal_external_id = '{$old[$i]}' AND " . "cal_login = '******' AND " . "cal_id < {$firstEventId}";
            $res = dbi_query($sql);
            if ($res) {
                while ($row = dbi_fetch_row($res)) {
                    $oldIds[] = $row[0];
                }
                dbi_free_result($res);
            } else {
                echo translate("Database error") . ": " . dbi_error() . "<br />\n";
            }
        }
        for ($i = 0; $i < count($oldIds); $i++) {
            $sql = "UPDATE webcal_entry_user SET cal_status = 'D' " . "WHERE cal_id = {$oldIds[$i]}";
            $sqlLog .= $sql . "<br />\n";
            dbi_query($sql);
            $numDeleted++;
        }
    }
    //echo "<b>SQL:</b><br />\n$sqlLog\n";
}
示例#27
0
    for ($j = 0; $j < count($repeated_events) && $should_add; $j++) {
        if ($re_save[$i]['cal_id'] == $repeated_events[$j]['cal_id']) {
            $should_add = 0;
        }
    }
    if ($should_add) {
        array_push($repeated_events, $re_save[$i]);
    }
}
display_small_month($prevmonth, $prevyear, true, true, "prevmonth", "view_l.php?id={$id}&amp;");
display_small_month($nextmonth, $nextyear, true, true, "nextmonth", "view_l.php?id={$id}&amp;");
?>

<div class="title">
<span class="date"><br /><?php 
echo date_to_str(sprintf("%04d%02d01", $thisyear, $thismonth), $DATE_FORMAT_MY, false, false);
?>
</span>
<span class="viewname"><br /><?php 
echo $view_name;
?>
</span></div>
<br /><br /><br /><br />

<table class="main" style="clear:both;" cellspacing="0" cellpadding="0">
<tr>
<?php 
if ($WEEK_START == 0) {
    ?>
<th class="weekend"><?php 
    etranslate("Sun");
示例#28
0
 if ($res) {
     $row = dbi_fetch_row($res);
     $name = $row[0];
     $eventdate = $row[1];
     $eventtime = $row[2];
     dbi_free_result($res);
 }
 // TODO: switch transation language based on user so each user
 // gets message in their selected language.
 for ($i = 0; $i < count($partlogin); $i++) {
     // Log the deletion
     activity_log($id, $login, $partlogin[$i], $LOG_DELETE, "");
     $do_send = get_pref_setting($partlogin[$i], "EMAIL_EVENT_DELETED");
     user_load_variables($partlogin[$i], "temp");
     if ($partlogin[$i] != $login && $do_send == "Y" && boss_must_be_notified($login, $partlogin[$i]) && strlen($tempemail) && $send_email != "N") {
         $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been canceled for you by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . "\"\n" . translate("Date") . ": " . date_to_str($thisdate) . "\n";
         if ($eventtime != '-1') {
             $msg .= translate("Time") . ": " . display_time($eventtime);
         }
         $msg .= "\n\n";
         if (strlen($login_email)) {
             $extra_hdrs = "From: {$login_email}\r\nX-Mailer: " . translate($application_name);
         } else {
             $extra_hdrs = "From: {$email_fallback_from}\r\nX-Mailer: " . translate($application_name);
         }
         mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs);
     }
 }
 // Instead of deleting from the database... mark it as deleted
 // by setting the status for each participant to "D" (instead
 // of "A"/Accepted, "W"/Waiting-on-approval or "R"/Rejected)
示例#29
0
?>
" class="next" 
  href="view_v.php?id=<?php 
echo $id;
?>
&amp;date=<?php 
echo $nextdate;
?>
">
  <img src="rightarrow.gif" class="prevnext" alt="<?php 
etranslate("Next");
?>
" /></a>
<div class="title">
<span class="date"><?php 
echo date_to_str(date("Ymd", $wkstart), false) . "&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;" . date_to_str(date("Ymd", $wkend), false);
?>
</span><br />
<span class="viewname"><?php 
echo $view_name;
?>
</span>
</div></div><br />

<?php 
// The table has names across the top and dates for rows.  Since we need
// to spit out an entire row before we can move to the next date, we'll
// save up all the HTML for each cell and then print it out when we're
// done..
// Additionally, we only want to put at most 6 users in one table since
// any more than that doesn't really fit in the page.
示例#30
0
文件: report.php 项目: rhertzog/lcs
function event_to_text($event, $date)
{
    global $ALLOW_HTML_DESCRIPTION, $event_template, $login, $report_id, $user;
    $allDayStr = translate('All day event');
    $confStr = translate('This event is confidential.');
    // translate ( 'Private' )
    $privStr = translate('(Private)');
    $end_time_str = $start_time_str = $time_str = '';
    $tempAllDay = $event->isAllDay();
    $tempDurStr = $event->getDuration();
    if ($tempAllDay) {
        $time_str = $allDayStr;
    } else {
        if ($event->isUntimed()) {
            $time_str = translate('Untimed event');
        } else {
            $start_time_str = $time_str = display_time($event->getDateTime());
            $time_short = getShortTime($time_str);
            if ($tempDurStr > 0) {
                if ($tempAllDay) {
                    $time_str = $allDayStr;
                } else {
                    $tempEDT = $event->getEndDateTime();
                    $end_time_str = display_time($tempEDT);
                    $time_str .= ' - ' . display_time($tempEDT);
                }
            }
        }
    }
    $name = $event->getName();
    $tempAcc = $event->getAccess();
    $tempDesc = $event->getDescription();
    $tempExtForID = $event->getExtForID();
    $tempLog = $event->getLogin();
    if ($tempExtForID != '') {
        $id = $tempExtForID;
        // translate ( 'cont.' )
        $name .= ' ' . translate('(cont.)');
    } else {
        $id = $event->getID();
    }
    if ($tempAcc == 'R') {
        if ($login != $user && strlen($user) || $login != $tempLog && strlen($tempLog)) {
            $description_str = $confStr;
            $name_str = $privStr;
        }
    } else {
        $name_str = htmlspecialchars($name);
        if (!empty($ALLOW_HTML_DESCRIPTION) && $ALLOW_HTML_DESCRIPTION == 'Y') {
            $str = str_replace('&', '&amp;', $tempDesc);
            //fix any broken special characters
            $str = preg_replace("/&amp;(#[0-9]+|[a-z]+);/i", "&\$1;", $str);
            $description_str = str_replace('&amp;amp;', '&amp;', $str);
            if (strstr($description_str, '<') && strstr($description_str, '>')) {
                // Found some HTML.
            } else {
                // No HTML found. Add line breaks.
                $description_str = nl2br($description_str);
            }
        } else {
            $description_str = nl2br(activate_urls(htmlspecialchars($tempDesc)));
        }
    }
    $date_full_str = date_to_str($date);
    $date_str = date_to_str($date, '', false);
    $duration_str = $tempDurStr > 0 ? $tempDurStr . ' ' . translate('minutes') : '';
    $temp = $event->getPriority();
    $pri_str = $temp > 6 ? translate('Low') : ($temp < 4 ? translate('High') : translate('Medium'));
    $temp = $event->getStatus();
    if ($temp == 'A') {
        $status_str = translate('Approved');
    } elseif ($temp == 'D') {
        $status_str = translate('Deleted');
    } elseif ($temp == 'R') {
        $status_str = translate('Rejected');
    } elseif ($temp == 'W') {
        $status_str = translate('Waiting for approval');
    } else {
        $status_str = translate('Unknown');
    }
    $location = $event->getLocation();
    $url = $event->getUrl();
    $href_str = 'view_entry.php?id=' . $id;
    // Get user's fullname.
    user_load_variables($tempLog, 'report_');
    $fullname = $GLOBALS['report_fullname'];
    // Replace all variables in the event template.
    $text = str_replace(array('${date}', '${dateYmd}', '${description}', '${duration}', '${endtime}', '${fulldate}', '${fullname}', '${href}', '${id}', '${location}', '${name}', '${priority}', '${report_id}', '${starttime}', '${time}', '${url}', '${user}'), array($date_str, $date, $description_str, $duration_str, $end_time_str, $date_full_str, $fullname, $href_str, $id, $location, $name_str, $pri_str, $report_id, $start_time_str, $time_str, $url, $tempLog), $event_template);
    $text = replace_site_extras_in_template($text, format_site_extras(get_site_extra_fields($id), EXTRA_DISPLAY_REPORT));
    return $text;
}