/**
 *
 *
 *
 */
function bookmarks_print_item($item, $cmid, $userids = '', $commands = false, $options = '')
{
    $link = bookmarks_get_link($item->linkid);
    echo '<div class="bookmark">
		<h3 class="name"><a class="previewlink" title="' . $link->url . '" href="link.php?id=' . $cmid . '&url=' . urlencode($link->url) . '">' . $item->name . '</a></h3>';
    if ($commands) {
        echo '<div class="commands">
				<a class="edit" href="edit.php?id=' . $cmid . '&item=' . $item->id . '">[' . get_string('edit', 'forum') . ']</a> /
				<a class="rm" href="del.php?id=' . $cmid . '&item=' . $item->id . '">[' . get_string('delete') . ']</a>
			</div>';
    }
    echo '<p class="notes">' . $item->description . '</p>';
    $tags = bookmarks_get_item_tags($item->id);
    if (!empty($tags)) {
        echo '<div class="meta">';
        echo get_string('tags') . ':';
        foreach ($tags as $tag) {
            echo '<a class="tag" href="view.php?id=' . $cmid . '&action=search&query=' . urlencode('tag:' . $tag->name) . '">' . $tag->name . '</a>';
        }
        echo '</div>';
    }
    echo '<div class="meta">';
    if ($options == 'detailed') {
        $usr = get_user_info_from_db('id', $item->userid);
        echo get_string('savedby', 'bookmarks') . $usr->lastname . ', ' . $usr->firstname;
    } else {
        $cm = get_coursemodule_from_id('bookmarks', $cmid);
        $countall = bookmarks_count_all_bookmarks($link->url);
        $countpart = bookmarks_count_all_accessible_bookmarks($link->url, $cm->instance, $userids);
        if ($countall > 1) {
            echo get_string('savedby', 'bookmarks') . $countall . ' (<a href="view.php?id=' . $cmid . '&action=search&query=' . urlencode('url:' . $link->url) . '&options=detailed">' . $countpart . ' ' . get_string('people', 'bookmarks') . '</a>)';
        } else {
            echo get_string('savedby', 'bookmarks') . $countall . ' (<a href="view.php?id=' . $cmid . '&action=search&query=' . urlencode('url:' . $link->url) . '&options=detailed">' . $countpart . ' ' . get_string('person', 'bookmarks') . '</a>)';
        }
        echo ' \\ ' . get_string('seen', 'bookmarks') . ' ' . $link->hits . ' ' . get_string('times', 'bookmarks');
    }
    echo '</div>';
    echo '</div>';
}
Esempio n. 2
0
/// Print the main part of the page
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/bookmarks:additem', $context);
echo '<div class="middle">';
require_js($CFG->wwwroot . '/mod/bookmarks/tags.js');
if (isset($itemid)) {
    require_once "update_form.php";
    $form =& new mod_bookmarks_update_form("save.php?id={$id}");
    $item = bookmarks_get_item($itemid);
    if ($USER->id == $item->userid) {
        $data = new stdClass();
        $data->cmid = $cm->id;
        $data->itemid = $item->id;
        $data->name = $item->name;
        $data->description = $item->description;
        $link = bookmarks_get_link($item->linkid);
        $data->url = $link->url;
        $tags = bookmarks_get_item_tags($item->id);
        if (!empty($tags)) {
            foreach ($tags as $tag) {
                $data->tags .= $tag->name . ',';
            }
        }
        $form->set_data($data);
        $form->display();
    } else {
        notice(get_string('notyours', 'bookmarks'));
    }
} else {
    require_once "edit_form.php";
    $form =& new mod_bookmarks_edit_form("save.php?id={$id}");