コード例 #1
0
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
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: edit.php プロジェクト: BackupTheBerlios/samouk-svn
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');