Пример #1
0
Файл: own.php Проект: rair/yacs
    // do the job
} elseif (!count($context['error'])) {
    // look for the user through his nick name
    if (isset($_REQUEST['assigned_name']) && ($user = Users::get($_REQUEST['assigned_name']))) {
        $_REQUEST['anchor'] = 'user:'******'id'];
    }
    // transfer ownership
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['anchor'])) {
        // assign a user, and also update his watch list
        $attributes = array('id' => $item['id'], 'owner_id' => $user['id']);
        Articles::put_attributes($attributes);
        Members::assign($_REQUEST['anchor'], 'article:' . $item['id']);
        Members::assign('article:' . $item['id'], $_REQUEST['anchor']);
        $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($user['full_name'], $user['email'], $user['id'])) . '</p>';
        // name current owner
    } elseif (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
        $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($owner['full_name'], $owner['email'], $owner['id'])) . '</p>';
    }
    // delegate to another person
    $context['text'] .= '<p style="margin-top: 2em;">' . i18n::s('To transfer ownership to another person, type some letters of the name you are looking for.') . '</p>';
    // the form to link additional users
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . '<input type="text" name="assigned_name" id="assigned_name" size="45" maxlength="255" />' . '<input type="hidden" name="id" value="' . encode_field($item['id']) . '" />' . '<input type="hidden" name="action" value="set" />' . ' <input type="submit" id="submit_button" value="' . i18n::s('Submit') . '" style="display: none;" />' . '</p></form>' . "\n";
    // enable autocompletion
    Page::insert_script('$(function() {' . "\n" . '	$("#name").focus();' . "\n" . '	Yacs.autocomplete_names("assigned_name",true, "", function(data) { $("#submit_button").show().click(); });' . "\n" . '});' . "\n");
    // back to the anchor page
    $links = array();
    $links[] = Skin::build_link(articles::get_permalink($item) . '#_users', i18n::s('Done'), 'button');
    $context['text'] .= Skin::finalize_list($links, 'assistant_bar');
}
// render the skin
render_skin();