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


PHP note_load函数代码示例

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


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

示例1: test_remove_course_contents

 /**
  * Test remove_course_content deletes course contents
  * TODO Add asserts to verify other data related to course is deleted as well.
  */
 public function test_remove_course_contents()
 {
     $this->resetAfterTest();
     $course = $this->getDataGenerator()->create_course();
     $user = $this->getDataGenerator()->create_user();
     $gen = $this->getDataGenerator()->get_plugin_generator('core_notes');
     $note = $gen->create_instance(array('courseid' => $course->id, 'userid' => $user->id));
     $this->assertNotEquals(false, note_load($note->id));
     remove_course_contents($course->id, false);
     $this->assertFalse(note_load($note->id));
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:15,代码来源:moodlelib_test.php

示例2: required_param

<?php

// $Id$
require_once '../config.php';
require_once 'lib.php';
// retrieve parameters
$noteid = required_param('id', PARAM_INT);
// locate note information
if (!($note = note_load($noteid))) {
    error('Incorrect note id specified');
}
// locate course information
if (!($course = get_record('course', 'id', $note->courseid))) {
    error('Incorrect course id found');
}
// locate user information
if (!($user = get_record('user', 'id', $note->userid))) {
    error('Incorrect user id found');
}
// require login to access notes
require_login($course);
// locate context information
$context = get_context_instance(CONTEXT_COURSE, $course->id);
// check capability
if (!has_capability('moodle/notes:manage', $context)) {
    print_error('nopermissiontodelete', 'notes');
}
if (empty($CFG->enablenotes)) {
    print_error('notesdisabled', 'notes');
}
if (data_submitted() && confirm_sesskey()) {
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:delete.php

示例3: note_save

/**
 * Saves a note object. The note object is passed by reference and its fields (i.e. id)
 * might change during the save.
 *
 * @param stdClass   $note object to save
 * @return boolean true if the object was saved; false otherwise
 */
function note_save(&$note)
{
    global $USER, $DB;
    // Setup & clean fields.
    $note->module = 'notes';
    $note->lastmodified = time();
    $note->usermodified = $USER->id;
    if (empty($note->format)) {
        $note->format = FORMAT_PLAIN;
    }
    if (empty($note->publishstate)) {
        $note->publishstate = NOTES_STATE_PUBLIC;
    }
    // Save data.
    if (empty($note->id)) {
        // Insert new note.
        $note->created = $note->lastmodified;
        $id = $DB->insert_record('post', $note);
        $note = note_load($id);
        // Trigger event.
        $event = \core\event\note_created::create(array('objectid' => $note->id, 'courseid' => $note->courseid, 'relateduserid' => $note->userid, 'userid' => $note->usermodified, 'context' => context_course::instance($note->courseid), 'other' => array('publishstate' => $note->publishstate)));
        $event->trigger();
    } else {
        // Update old note.
        $DB->update_record('post', $note);
        $note = note_load($note->id);
        // Trigger event.
        $event = \core\event\note_updated::create(array('objectid' => $note->id, 'courseid' => $note->courseid, 'relateduserid' => $note->userid, 'userid' => $note->usermodified, 'context' => context_course::instance($note->courseid), 'other' => array('publishstate' => $note->publishstate)));
        $event->trigger();
    }
    unset($note->module);
    return true;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:40,代码来源:lib.php

示例4: update_notes

 /**
  * Update notes about users.
  *
  * @param array $notes An array of ids for the notes to update.
  * @return array fail infos.
  * @since Moodle 2.2
  */
 public static function update_notes($notes = array())
 {
     global $CFG, $DB;
     $params = self::validate_parameters(self::update_notes_parameters(), array('notes' => $notes));
     // Check if note system is enabled.
     if (!$CFG->enablenotes) {
         throw new moodle_exception('notesdisabled', 'notes');
     }
     $warnings = array();
     foreach ($params['notes'] as $note) {
         $notedetails = note_load($note['id']);
         if (isset($notedetails->id)) {
             // Ensure the current user is allowed to run this function.
             $context = context_course::instance($notedetails->courseid);
             self::validate_context($context);
             require_capability('moodle/notes:manage', $context);
             $dbnote = new stdClass();
             $dbnote->id = $note['id'];
             $dbnote->content = $note['text'];
             $dbnote->format = external_validate_format($note['format']);
             // Get the state ('personal', 'course', 'site').
             switch ($note['publishstate']) {
                 case 'personal':
                     $dbnote->publishstate = NOTES_STATE_DRAFT;
                     break;
                 case 'course':
                     $dbnote->publishstate = NOTES_STATE_PUBLIC;
                     break;
                 case 'site':
                     $dbnote->publishstate = NOTES_STATE_SITE;
                     $dbnote->courseid = SITEID;
                     break;
                 default:
                     $warnings[] = array('item' => 'note', 'itemid' => $note["id"], 'warningcode' => 'badparam', 'message' => 'Provided publishstate incorrect');
                     break;
             }
             if (!note_save($dbnote)) {
                 $warnings[] = array('item' => 'note', 'itemid' => $note["id"], 'warningcode' => 'savedfailed', 'message' => 'Note could not be modified');
             }
         } else {
             $warnings[] = array('item' => 'note', 'itemid' => $note["id"], 'warningcode' => 'badid', 'message' => 'Note does not exist');
         }
     }
     return $warnings;
 }
开发者ID:mongo0se,项目名称:moodle,代码行数:52,代码来源:externallib.php

示例5: note_delete

/**
 * Deletes a note object based on its id.
 *
 * @param int|object    $note id of the note to delete, or a note object which is to be deleted.
 * @return boolean true if the object was deleted; false otherwise
 */
function note_delete($note) {
    global $DB;
    if (is_int($note)) {
        $note = note_load($note);
        debugging('Warning: providing note_delete with a note object would improve performance.',DEBUG_DEVELOPER);
    }
    $logurl = new moodle_url('index.php', array('course'=> $note->courseid, 'user'=>$note->userid));
    $logurl->set_anchor('note-' . $note->id);
    add_to_log($note->courseid, 'notes', 'delete', $logurl, 'delete note');
    return $DB->delete_records('post', array('id'=>$note->id, 'module'=>'notes'));
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:17,代码来源:lib.php

示例6: note_save

/**
 * Saves a note object. The note object is passed by reference and its fields (i.e. id)
 * might change during the save.
 *
 * @param note   $note object to save
 * @return boolean true if the object was saved; false otherwise
 */
function note_save(&$note) {
    global $USER, $DB;

    // setup & clean fields
    $note->module       = 'notes';
    $note->lastmodified = time();
    $note->usermodified = $USER->id;
    if (empty($note->format)) {
        $note->format = FORMAT_PLAIN;
    }
    if (empty($note->publishstate)) {
        $note->publishstate = NOTES_STATE_PUBLIC;
    }
    // save data
    if (empty($note->id)) {
        // insert new note
        $note->created = $note->lastmodified;
        $id = $DB->insert_record('post', $note);
        $note = note_load($id);
    } else {
        // update old note
        $DB->update_record('post', $note);
        $note = note_load($note->id);
    }
    unset($note->module);
    return true;
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:34,代码来源:lib.php


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