Example #1
0
/**
 * Удаление заметки пользователя
 *
 * @param integer $uid      ИД пользователя владельца заметки
 * @param inetger $to_uid   ИД пользователя на кого написана заметка
 * @return object xajaxResponse; @see xajax
 */
function delNote($uid, $to_uid, $type)
{
    session_start();
    if ($_SESSION['uid'] != $uid) {
        return false;
    }
    include_once $_SERVER['DOCUMENT_ROOT'] . '/classes/notes.php';
    $objResponse = new xajaxResponse();
    notes::DeleteNote($uid, $to_uid);
    if ($type == 100) {
        $objResponse->script("\$\$('.userFav_{$to_uid}').destroy();");
    } else {
        $html = '<div class="sent-mark"><a href="javascript:void(0)" onclick="xajax_getNotesForm(' . $to_uid . ', false, ' . $type . ')">Оставить заметку</a>&nbsp;<span></span></div>';
        // $objResponse->script("$$('.userFav_{$to_uid}').getParent('div').removeClass('fs-g').removeClass('fs-p').addClass('add-z');");
        // $objResponse->script("$$('.userFav_{$to_uid}').getParent('div').removeClass('fs-o').addClass('add-z');");
        $objResponse->script("\$\$('.userFav_{$to_uid}').set('html', '{$html}');");
    }
    //$objResponse->script("$('ov-izbr-2').destroy();"); // Если удаляем с формы
    return $objResponse;
}
Example #2
0
function FormSave($login, $text, $action, $rl, $num)
{
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php";
    session_start();
    $objResponse = new xajaxResponse();
    $action = trim($action);
    // Режем тег <script>
    $text = strip_only(trim($text), '<script>');
    //$text = stripslashes($text);
    $text = change_q_x($text, FALSE, TRUE, "", false, false);
    if ($rl == '1') {
        $s_role = "_emp";
    } else {
        $s_role = "_frl";
    }
    if ($text == '') {
        $s_role = "";
    }
    $noassign = 0;
    $nuid = get_uid(false);
    $user = new users();
    $nTargetId = $user->GetUid($sError, $login);
    switch ($action) {
        case "add":
            if ($text) {
                $error = notes::Add($nuid, (int) $nTargetId, $text);
            }
            break;
        case "update":
            if ($text) {
                $error = notes::Update($nuid, (int) $nTargetId, $text);
            } else {
                $error = notes::DeleteNote($nuid, (int) $nTargetId);
            }
            break;
        default:
            $noassign = 1;
    }
    $text = stripslashes($text);
    $text = reformat($text, 24, 0, 0, 1, 24);
    if ($s_role == "") {
        $text = "Вы можете оставить заметку о&nbsp;пользователе. Видеть написанное будете только вы и никто другой.";
    }
    if (!$noassign) {
        $GLOBALS['xajax']->setCharEncoding("windows-1251");
        $objResponse->assign("notetext" . $num, "innerHTML", $text);
        $objResponse->assign("notetd" . $num, "className", "note" . $s_role);
        if (!$s_role == "") {
            $objResponse->script("txt[" . $num . "] = '" . $text . "';");
        }
        $objResponse->script("act[" . $num . "] = '" . ($s_role ? "update" : "add") . "';");
    }
    return $objResponse;
}