当前位置: 首页>>代码示例>>PHP>>正文


PHP blog_user_can_edit_entry函数代码示例

本文整理汇总了PHP中blog_user_can_edit_entry函数的典型用法代码示例。如果您正苦于以下问题:PHP blog_user_can_edit_entry函数的具体用法?PHP blog_user_can_edit_entry怎么用?PHP blog_user_can_edit_entry使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了blog_user_can_edit_entry函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_string

$strblogs = get_string('blogs', 'blog');
if ($action === 'delete') {
    if (empty($entry->id)) {
        print_error('wrongentryid', 'blog');
    }
    if (data_submitted() && $confirm && confirm_sesskey()) {
        // Make sure the current user is the author of the blog entry, or has some deleteanyentry capability
        if (!blog_user_can_edit_entry($entry)) {
            print_error('nopermissionstodeleteentry', 'blog');
        } else {
            $entry->delete();
            blog_rss_delete_file($userid);
            redirect($returnurl);
        }
    } else {
        if (blog_user_can_edit_entry($entry)) {
            $optionsyes = array('entryid' => $id, 'action' => 'delete', 'confirm' => 1, 'sesskey' => sesskey(), 'courseid' => $courseid);
            $optionsno = array('userid' => $entry->userid, 'courseid' => $courseid);
            $PAGE->set_title("{$SITE->shortname}: {$strblogs}");
            $PAGE->set_heading($SITE->fullname);
            echo $OUTPUT->header();
            // Output the entry.
            $entry->prepare_render();
            echo $output->render($entry);
            echo '<br />';
            echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog'), new moodle_url('edit.php', $optionsyes), new moodle_url('index.php', $optionsno));
            echo $OUTPUT->footer();
            die;
        }
    }
} else {
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:31,代码来源:edit.php

示例2: print_html


//.........这里部分代码省略.........
         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;
     }
     $contentcell->text .= $OUTPUT->container($blogtype, 'audience');
     $contentcell->text .= $template['body'];
     $contentcell->text .= $attachedimages;
     // Uniquehash is used as a link to an external blog
     if (!empty($this->uniquehash)) {
         $contentcell->text .= $OUTPUT->container_start('externalblog');
         $contentcell->text .= html_writer::link($this->uniquehash, get_string('linktooriginalentry', 'blog'));
         $contentcell->text .= $OUTPUT->container_end();
     }
     // Links to tags
     $officialtags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'official');
     $defaulttags = tag_get_tags_csv('post', $this->id, TAG_RETURN_HTML, 'default');
     if (!empty($CFG->usetags) && ($officialtags || $defaulttags)) {
         $contentcell->text .= $OUTPUT->container_start('tags');
         if ($officialtags) {
             $contentcell->text .= get_string('tags', 'tag') . ': ' . $OUTPUT->container($officialtags, 'officialblogtags');
             if ($defaulttags) {
                 $contentcell->text .= ', ';
             }
         }
         $contentcell->text .= $defaulttags;
         $contentcell->text .= $OUTPUT->container_end();
     }
     // Add associations
     if (!empty($CFG->useblogassociations) && $blogassociations) {
         $contentcell->text .= $OUTPUT->container_start('tags');
         $assocstr = '';
         $hascourseassocs = false;
         $assoctype = '';
         // First find and show the associated course
         foreach ($blogassociations as $assocrec) {
             $contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
             if ($contextrec->contextlevel == CONTEXT_COURSE) {
                 $assocurl = new moodle_url('/course/view.php', array('id' => $contextrec->instanceid));
                 $text = $DB->get_field('course', 'shortname', array('id' => $contextrec->instanceid));
                 //TODO: performance!!!!
                 $assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('i/course', $text), null, array(), true);
                 $hascourseassocs = true;
                 $assoctype = get_string('course');
             }
         }
         // Now show mod association
         foreach ($blogassociations as $assocrec) {
             $contextrec = $DB->get_record('context', array('id' => $assocrec->contextid));
             if ($contextrec->contextlevel == CONTEXT_MODULE) {
                 if ($hascourseassocs) {
                     $assocstr .= ', ';
                     $hascourseassocs = false;
                 }
                 $modinfo = $DB->get_record('course_modules', array('id' => $contextrec->instanceid));
                 $modname = $DB->get_field('modules', 'name', array('id' => $modinfo->module));
                 $assocurl = new moodle_url('/mod/' . $modname . '/view.php', array('id' => $modinfo->id));
                 $text = $DB->get_field($modname, 'name', array('id' => $modinfo->instance));
                 //TODO: performance!!!!
                 $assocstr .= $OUTPUT->action_icon($assocurl, new pix_icon('icon', $text, $modname), null, array(), true);
                 $assocstr .= ', ';
                 $assoctype = get_string('modulename', $modname);
             }
         }
         $assocstr = substr($assocstr, 0, -2);
         $contentcell->text .= get_string('associated', 'blog', $assoctype) . ': ' . $assocstr;
         $contentcell->text .= $OUTPUT->container_end();
     }
     if ($unassociatedentry) {
         $contentcell->text .= $OUTPUT->container(get_string('associationunviewable', 'blog'), 'noticebox');
     }
     /// Commands
     $contentcell->text .= $OUTPUT->container_start('commands');
     if (blog_user_can_edit_entry($this) && empty($this->uniquehash)) {
         $contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php', array('action' => 'edit', 'entryid' => $this->id)), $stredit) . ' | ';
         $contentcell->text .= html_writer::link(new moodle_url('/blog/edit.php', array('action' => 'delete', 'entryid' => $this->id)), $strdelete) . ' | ';
     }
     $contentcell->text .= html_writer::link(new moodle_url('/blog/index.php', array('entryid' => $this->id)), get_string('permalink', 'blog'));
     $contentcell->text .= $OUTPUT->container_end();
     if (isset($template['lastmod'])) {
         $contentcell->text .= '<div style="font-size: 55%;">';
         $contentcell->text .= ' [ ' . get_string('modified') . ': ' . $template['lastmod'] . ' ]';
         $contentcell->text .= '</div>';
     }
     $mainrow->cells[] = $contentcell;
     $table->data = array($mainrow);
     if ($return) {
         return html_writer::table($table);
     } else {
         echo html_writer::table($table);
     }
 }
开发者ID:nfreear,项目名称:moodle,代码行数:101,代码来源:locallib.php

示例3: prepare_render

 /**
  * Gets the required data to print the entry
  */
 public function prepare_render()
 {
     global $DB, $CFG, $PAGE;
     $this->renderable = new StdClass();
     $this->renderable->user = $DB->get_record('user', array('id' => $this->userid));
     // Entry comments.
     if (!empty($CFG->usecomments) and $CFG->blogusecomments) {
         require_once $CFG->dirroot . '/comment/lib.php';
         $cmt = new stdClass();
         $cmt->context = context_user::instance($this->userid);
         $cmt->courseid = $PAGE->course->id;
         $cmt->area = 'format_blog';
         $cmt->itemid = $this->id;
         $cmt->showcount = $CFG->blogshowcommentscount;
         $cmt->component = 'blog';
         $this->renderable->comment = new comment($cmt);
     }
     $this->summary = file_rewrite_pluginfile_urls($this->summary, 'pluginfile.php', SYSCONTEXTID, 'blog', 'post', $this->id);
     // External blog link.
     if ($this->uniquehash && $this->content) {
         if ($externalblog = $DB->get_record('blog_external', array('id' => $this->content))) {
             $urlparts = parse_url($externalblog->url);
             $this->renderable->externalblogtext = get_string('retrievedfrom', 'blog') . get_string('labelsep', 'langconfig');
             $this->renderable->externalblogtext .= html_writer::link($urlparts['scheme'] . '://' . $urlparts['host'], $externalblog->name);
         }
     }
     // Retrieve associations.
     $this->renderable->unassociatedentry = false;
     if (!empty($CFG->useblogassociations)) {
         // Adding the entry associations data.
         if ($associations = $associations = $DB->get_records('blog_association', array('blogid' => $this->id))) {
             // Check to see if the entry is unassociated with group/course level access.
             if ($this->publishstate == 'group' || $this->publishstate == 'course') {
                 $this->renderable->unassociatedentry = true;
             }
             foreach ($associations as $key => $assocrec) {
                 if (!($context = context::instance_by_id($assocrec->contextid, IGNORE_MISSING))) {
                     unset($associations[$key]);
                     continue;
                 }
                 // The renderer will need the contextlevel of the association.
                 $associations[$key]->contextlevel = $context->contextlevel;
                 // Course associations.
                 if ($context->contextlevel == CONTEXT_COURSE) {
                     // TODO: performance!!!!
                     $instancename = $DB->get_field('course', 'shortname', array('id' => $context->instanceid));
                     $associations[$key]->url = $assocurl = new moodle_url('/course/view.php', array('id' => $context->instanceid));
                     $associations[$key]->text = $instancename;
                     $associations[$key]->icon = new pix_icon('i/course', $associations[$key]->text);
                 }
                 // Mod associations.
                 if ($context->contextlevel == CONTEXT_MODULE) {
                     // Getting the activity type and the activity instance id.
                     $sql = 'SELECT cm.instance, m.name FROM {course_modules} cm
                               JOIN {modules} m ON m.id = cm.module
                              WHERE cm.id = :cmid';
                     $modinfo = $DB->get_record_sql($sql, array('cmid' => $context->instanceid));
                     // TODO: performance!!!!
                     $instancename = $DB->get_field($modinfo->name, 'name', array('id' => $modinfo->instance));
                     $associations[$key]->type = get_string('modulename', $modinfo->name);
                     $associations[$key]->url = new moodle_url('/mod/' . $modinfo->name . '/view.php', array('id' => $context->instanceid));
                     $associations[$key]->text = $instancename;
                     $associations[$key]->icon = new pix_icon('icon', $associations[$key]->text, $modinfo->name);
                 }
             }
         }
         $this->renderable->blogassociations = $associations;
     }
     // Entry attachments.
     $this->renderable->attachments = $this->get_attachments();
     $this->renderable->usercanedit = blog_user_can_edit_entry($this);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:75,代码来源:locallib.php


注:本文中的blog_user_can_edit_entry函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。