function site_extras_for_popup($id)
{
    global $SITE_EXTRAS_IN_POPUP;
    if ($SITE_EXTRAS_IN_POPUP != 'Y') {
        return '';
    }
    $extras = format_site_extras(get_site_extra_fields($id), EXTRA_DISPLAY_POPUP);
    if (empty($extras)) {
        return '';
    }
    $ret = '';
    foreach ($extras as $extra) {
        $ret .= '<dt>' . $extra['name'] . ":</dt>\n<dd>" . $extra['data'] . "</dd>\n";
    }
    return $ret;
}
Ejemplo n.º 2
0
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;
}