Exemplo n.º 1
0
function load_user_preferences()
{
    global $login, $browser, $views, $prefarray, $is_assistant, $has_boss, $user;
    $lang_found = false;
    $browser = get_web_browser();
    $browser_lang = get_browser_language();
    $prefarray = array();
    // Note: default values are set in config.php
    $res = dbi_query("SELECT cal_setting, cal_value FROM webcal_user_pref " . "WHERE cal_login = '{$login}'");
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $setting = $row[0];
            $value = $row[1];
            $sys_setting = "sys_" . $setting;
            // save system defaults
            if (!empty($GLOBALS[$setting])) {
                $GLOBALS["sys_" . $setting] = $GLOBALS[$setting];
            }
            $GLOBALS[$setting] = $value;
            $prefarray[$setting] = $value;
            if ($setting == "LANGUAGE") {
                $lang_found = true;
            }
        }
        dbi_free_result($res);
    }
    // get views for this user
    $res = dbi_query("SELECT cal_view_id, cal_name, cal_view_type FROM webcal_view " . "WHERE cal_owner = '{$login}'");
    if ($res) {
        $views = array();
        while ($row = dbi_fetch_row($res)) {
            $v = array("cal_view_id" => $row[0], "cal_name" => $row[1], "cal_view_type" => $row[2]);
            $views[] = $v;
        }
        dbi_free_result($res);
    }
    // If user has not set a language preference, then use their browser
    // settings to figure it out, and save it in the database for future
    // use (email reminders).
    if (!$lang_found && strlen($login) && $login != "__public__") {
        $LANGUAGE = $browser_lang;
        dbi_query("INSERT INTO webcal_user_pref " . "( cal_login, cal_setting, cal_value ) VALUES " . "( '{$login}', 'LANGUAGE', '{$LANGUAGE}' )");
    }
    if (empty($GLOBALS["DATE_FORMAT_MY"])) {
        $GLOBALS["DATE_FORMAT_MY"] = "__month__ __yyyy__";
    }
    if (empty($GLOBALS["DATE_FORMAT_MD"])) {
        $GLOBALS["DATE_FORMAT_MD"] = "__month__ __dd__";
    }
    $is_assistant = user_is_assistant($login, $user);
    $has_boss = user_has_boss($login);
}
Exemplo n.º 2
0
        if ($owner == $login || user_is_assistant($login, $owner)) {
            $can_delete = true;
        }
    } else {
        // document not found
        $error = str_replace('XXX', $blid, translate('Invalid entry id XXX.'));
    }
    dbi_free_result($res);
}
if (empty($error) && !$can_delete && $event_id > 0) {
    // See if current user is creator of associated event
    $res = dbi_execute('SELECT cal_create_by FROM webcal_entry WHERE cal_id = ?', array($event_id));
    if ($res) {
        if ($row = dbi_fetch_row($res)) {
            $event_owner = $row[0];
            if ($event_owner == $login || user_is_assistant($login, $event_owner)) {
                $can_delete = true;
            }
        }
        dbi_free_result($res);
    }
}
if (empty($error) && !$can_delete) {
    $error = print_not_auth(6);
}
if (empty($error) && $can_delete) {
    if (!dbi_execute('DELETE FROM webcal_blob WHERE cal_blob_id = ?', array($blid))) {
        $error = db_error();
    } else {
        if ($event_id > 0) {
            $removeStr = translate('Removed');
function boss_must_be_notified($assistant, $boss)
{
    if (user_is_assistant($assistant, $boss)) {
        return get_pref_setting($boss, 'EMAIL_ASSISTANT_EVENTS') == 'Y' ? true : false;
    }
    return true;
}
Exemplo n.º 4
0
function boss_must_approve_event($assistant, $boss)
{
    if (user_is_assistant($assistant, $boss)) {
        return get_pref_setting($boss, "APPROVE_ASSISTANT_EVENT") == "Y" ? true : false;
    }
    return true;
}
Exemplo n.º 5
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.