Esempio n. 1
0
        if (!$existing) {
            error('Incorrect blog post id');
        }
        $post->id = $existing->id;
        $post->subject = $existing->subject;
        $post->summary = $existing->summary;
        $post->publishstate = $existing->publishstate;
        $post->format = $existing->format;
        $post->action = $action;
        $strformheading = get_string('updateentrywithid', 'blog');
        if ($ptags = records_to_menu(get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'default'), 'id', 'rawname')) {
            $post->ptags = implode(', ', $ptags);
        } else {
            $post->ptags = '';
        }
        if ($otags = records_to_menu(get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'official'), 'id', 'rawname')) {
            $post->otags = array_keys($otags);
        }
        break;
    default:
        error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
    error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strblogs, 'link' => "{$CFG->wwwroot}/blog/index.php?userid={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strformheading, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
Esempio n. 2
0
}
/// Printing groups
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and !has_capability('moodle/site:accessallgroups', $coursecontext));
if (!$isseparategroups) {
    if ($usergroups = groups_get_all_groups($course->id, $user->id)) {
        $groupstr = '';
        foreach ($usergroups as $group) {
            $groupstr .= ' <a href="' . $CFG->wwwroot . '/user/index.php?id=' . $course->id . '&amp;group=' . $group->id . '">' . format_string($group->name) . '</a>,';
        }
        print_row(get_string("group") . ":", rtrim($groupstr, ', '));
    }
}
/// End of printing groups
/// Printing Interests
if (!empty($CFG->usetags)) {
    $interests = get_item_tags('user', $user->id);
    $instereststr = tag_links_csv($interests);
    if ($interests) {
        print_row(get_string('interests') . ": ", rtrim($instereststr));
    }
}
/// End of Printing Interests
echo "</table>";
echo "</td></tr></table>";
$userauth = get_auth_plugin($user->auth);
$passwordchangeurl = false;
if ($currentuser and $userauth->can_change_password() and !isguestuser() and has_capability('moodle/user:changeownpassword', $systemcontext)) {
    if (!($passwordchangeurl = $userauth->change_password_url())) {
        if (empty($CFG->loginhttps)) {
            $passwordchangeurl = "{$CFG->wwwroot}/login/change_password.php";
        } else {
 function get_content()
 {
     global $CFG, $USER, $PAGE;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $tagid = optional_param('id', 0, PARAM_INT);
     // tag id
     //include related tags in the photo query ?
     $tags_csv = tag_display_name(tag_by_id($tagid));
     if (!empty($this->config->includerelatedtags)) {
         $tags_csv .= ',' . tag_names_csv(get_item_tags('tag', $tagid));
     }
     $tags_csv = urlencode($tags_csv);
     //number of photos to display
     $numberofphotos = DEFAULT_NUMBER_OF_PHOTOS;
     if (!empty($this->config->numberofphotos)) {
         $numberofphotos = $this->config->numberofphotos;
     }
     //sort search results by
     $sortby = 'relevance';
     if (!empty($this->config->sortby)) {
         $sortby = $this->config->sortby;
     }
     //pull photos from a specific photoset
     if (!empty($this->config->photoset)) {
         $request = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos';
         $request .= '&api_key=' . FLICKR_DEV_KEY;
         $request .= '&photoset_id=' . $this->config->photoset;
         $request .= '&per_page=' . $numberofphotos;
         $request .= '&format=php_serial';
         $response = $this->fetch_request($request);
         $search = unserialize($response);
         foreach ($search['photoset']['photo'] as $p) {
             $p['owner'] = $search['photoset']['owner'];
         }
         $photos = array_values($search['photoset']['photo']);
     } else {
         $request = 'http://api.flickr.com/services/rest/?method=flickr.photos.search';
         $request .= '&api_key=' . FLICKR_DEV_KEY;
         $request .= '&tags=' . $tags_csv;
         $request .= '&per_page=' . $numberofphotos;
         $request .= '&sort=' . $sortby;
         $request .= '&format=php_serial';
         $response = $this->fetch_request($request);
         $search = unserialize($response);
         $photos = array_values($search['photos']['photo']);
     }
     if (strcmp($search['stat'], 'ok') != 0) {
         return;
     }
     //if no results were returned, exit...
     //render the list of photos
     $text = '';
     foreach ($photos as $photo) {
         $text .= '<a href="http://www.flickr.com/photos/' . $photo['owner'] . '/' . $photo['id'] . '/">';
         $text .= '<img title="' . s($photo['title']) . '" alt="' . s($photo['title']) . '" class="flickr-photos" src="' . $this->build_photo_url($photo, 'square') . '" /></a>';
     }
     $this->content = new stdClass();
     $this->content->text = $text;
     $this->content->footer = '';
     return $this->content;
 }
if ($user->id != $USER->id and $user->id == $mainadmin->id) {
    // Can't edit primary admin
    print_error('adminprimarynoedit');
}
if (isguestuser($user->id)) {
    // the real guest user can not be edited
    print_error('guestnoeditprofileother');
}
//load user preferences
useredit_load_preferences($user);
//Load custom profile fields data
profile_load_data($user);
//user interests separated by commas
if (!empty($CFG->usetags)) {
    require_once $CFG->dirroot . '/tag/lib.php';
    $user->interests = tag_names_csv(get_item_tags('user', $id));
}
//create form
$userform = new user_editadvanced_form();
$userform->set_data($user);
// kowy - temp
print "isAdvanced<br>";
print_r($user);
print "aa {$user->su_isadvanced} bb";
if ($usernew = $userform->get_data()) {
    add_to_log($course->id, 'user', 'update', "view.php?id={$user->id}&course={$course->id}", '');
    if (empty($usernew->auth)) {
        //user editing self
        $authplugin = get_auth_plugin($user->auth);
        unset($usernew->auth);
        //can not change/remove
Esempio n. 5
0
require_once 'lib.php';
require_once 'edit_form.php';
require_js(array('yui_dom-event', 'yui_connection', 'yui_animation', 'yui_autocomplete'));
require_login();
if (empty($CFG->usetags)) {
    error(get_string('tagsaredisabled', 'tag'));
}
$tagid = required_param('id', PARAM_INT);
// user id
$tag = tag_by_id($tagid);
$tagname = tag_display_name($tag);
//Editing a tag requires moodle/tag:edit capability
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/tag:edit', $systemcontext);
// set the relatedtags field of the $tag object that will be passed to the form
$tag->relatedtags = tag_names_csv(get_item_tags('tag', $tagid));
if (can_use_html_editor()) {
    $options = new object();
    $options->smiley = false;
    $options->filter = false;
    // convert and remove any XSS
    $tag->description = format_text($tag->description, $tag->descriptionformat, $options);
    $tag->descriptionformat = FORMAT_HTML;
}
$tagform = new tag_edit_form();
$tagform->set_data($tag);
// if new data has been sent, update the tag record
if ($tagnew = $tagform->get_data()) {
    $tagnew->timemodified = time();
    if (!update_record('tag', $tagnew)) {
        error('Error updating tag record');
Esempio n. 6
0
/**
 * This function is in lib and not in BlogInfo because entries being searched
 * might be found in any number of blogs rather than just one.
 *
 * This function builds an array which can be used by the included
 * template file, making predefined and nicely formatted variables available
 * to the template. Template creators will not need to become intimate
 * with the internal objects and vars of moodle blog nor will they need to worry
 * about properly formatting their data
 *
 *   @param BlogEntry blogEntry - a hopefully fully populated BlogEntry object
 *   @param string viewtype Default is 'full'. If 'full' then display this blog entry
 *     in its complete form (eg. archive page). If anything other than 'full'
 *     display the entry in its abbreviated format (eg. index page)
 */
function blog_print_entry($blogEntry, $viewtype = 'full', $filtertype = '', $filterselect = '', $mode = 'loud')
{
    global $USER, $CFG, $COURSE, $ME;
    $template['body'] = format_text($blogEntry->summary, $blogEntry->format);
    //$template['title'] = '<a name="'. $blogEntry->subject .'"></a>';
    //enclose the title in nolink tags so that moodle formatting doesn't autolink the text
    $template['title'] = '<span class="nolink">' . $blogEntry->subject . '</span>';
    $template['userid'] = $blogEntry->userid;
    $template['author'] = fullname(get_record('user', 'id', $blogEntry->userid));
    $template['lastmod'] = userdate($blogEntry->lastmodified);
    $template['created'] = userdate($blogEntry->created);
    $template['publishstate'] = $blogEntry->publishstate;
    /// preventing user to browse blogs that they aren't supposed to see
    /// This might not be too good since there are multiple calls per page
    /*
            if (!blog_user_can_view_user_post($template['userid'])) {
                error ('you can not view this post');
            }*/
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $user = get_record('user', 'id', $template['userid']);
    /// Start printing of the blog
    echo '<table cellspacing="0" class="forumpost blogpost blog' . $template['publishstate'] . '" width="100%">';
    echo '<tr class="header"><td class="picture left">';
    print_user_picture($template['userid'], SITEID, $user->picture);
    echo '</td>';
    echo '<td class="topic starter"><div class="subject">' . $template['title'] . '</div><div class="author">';
    $fullname = fullname($user, $template['userid']);
    $by = new object();
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $COURSE->id . '">' . $fullname . '</a>';
    $by->date = $template['lastmod'];
    print_string('bynameondate', 'forum', $by);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    /// Actual content
    echo '</td><td class="content">' . "\n";
    if ($blogEntry->attachment) {
        echo '<div class="attachments">';
        $attachedimages = blog_print_attachments($blogEntry);
        echo '</div>';
    } else {
        $attachedimages = '';
    }
    switch ($template['publishstate']) {
        case 'draft':
            $blogtype = get_string('publishtonoone', 'blog');
            break;
        case 'site':
            $blogtype = get_string('publishtosite', 'blog');
            break;
        case 'public':
            $blogtype = get_string('publishtoworld', 'blog');
            break;
        default:
            $blogtype = '';
            break;
    }
    echo '<div class="audience">' . $blogtype . '</div>';
    // Print whole message
    echo format_text($template['body']);
    /// Print attachments
    echo $attachedimages;
    /// Links to tags
    /*
    if ($blogtags = get_records_sql('SELECT t.* FROM '.$CFG->prefix.'tags t, '.$CFG->prefix.'blog_tag_instance ti
                                 WHERE t.id = ti.tagid
                                 AND ti.entryid = '.$blogEntry->id)) {
    */
    if (!empty($CFG->usetags) && ($blogtags = get_item_tags('blog', $blogEntry->id))) {
        echo '<div class="tags">';
        if ($blogtags) {
            print_string('tags');
            echo ': ';
            foreach ($blogtags as $key => $blogtag) {
                //$taglist[] = '<a href="index.php?filtertype='.$filtertype.'&amp;filterselect='.$filterselect.'&amp;tagid='.$blogtag->id.'">'.tag_display_name($blogtag).'</a>';  // Blog tag only
                $taglist[] = '<a href="' . $CFG->wwwroot . '/tag/index.php?id=' . $blogtag->id . '">' . tag_display_name($blogtag) . '</a>';
                // General tag link
            }
            echo implode(', ', $taglist);
        }
        echo '</div>';
    }
    /// Commands
    echo '<div class="commands">';
    if (blog_user_can_edit_post($blogEntry)) {
        echo '<a href="' . $CFG->wwwroot . '/blog/edit.php?action=edit&amp;id=' . $blogEntry->id . '">' . $stredit . '</a>';
        echo '| <a href="' . $CFG->wwwroot . '/blog/edit.php?action=delete&amp;id=' . $blogEntry->id . '">' . $strdelete . '</a>';
    }
    echo '</div>';
    echo '</td></tr></table>' . "\n\n";
}
Esempio n. 7
0
        }
        $post->id = $existing->id;
        $post->subject = $existing->subject;
        $post->summary = $existing->summary;
        $post->publishstate = $existing->publishstate;
        $post->format = $existing->format;
        $post->action = $action;
        $strformheading = get_string('updateentrywithid', 'blog');
        if ($itemptags = get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'default')) {
            if ($ptags = records_to_menu($itemptags, 'id', 'rawname')) {
                $post->ptags = implode(', ', $ptags);
            } else {
                $post->ptags = '';
            }
        }
        if ($itemotags = get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'official')) {
            if ($otags = records_to_menu($itemotags, 'id', 'rawname')) {
                $post->otags = array_keys($otags);
            }
        }
        break;
    default:
        error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
    error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strblogs, 'link' => "{$CFG->wwwroot}/blog/index.php?userid={$userid}", 'type' => 'misc');
Esempio n. 8
0
/**
 * Recalculates tag correlations of all the tags associated with an item
 * This function could be called whenever the tags associations with an item changes
 *  ( for example when tag_an_item() or untag_an_item() is called )
 *
 * @param string $item_type name of the table where the item is stored. Ex: 'user'
 * @param string $item_id id of the item
 */
function update_tag_correlations($item_type, $item_id)
{
    $item_tags = get_item_tags($item_type, $item_id);
    foreach ($item_tags as $tag) {
        cache_correlated_tags($tag->id);
    }
}