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


PHP note_save函数代码示例

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


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

示例1: require_login

require_login($course->id);
// to create notes the current user needs a capability
require_capability('moodle/notes:manage', $context);
if (!empty($users) && !empty($content) && confirm_sesskey()) {
    $note = new object();
    $note->courseid = $id;
    $note->format = FORMAT_PLAIN;
    $note->content = $content;
    $note->publishstate = $state;
    foreach ($users as $k => $v) {
        if (!($user = get_record('user', 'id', $v))) {
            continue;
        }
        $note->id = 0;
        $note->userid = $v;
        if (note_save($note)) {
            add_to_log($note->courseid, 'notes', 'add', 'index.php?course=' . $note->courseid . '&user=' . $note->userid . '#note-' . $note->id, 'add note');
        }
    }
    redirect("{$CFG->wwwroot}/user/index.php?id={$id}");
}
/// Print headers
$straddnote = get_string('groupaddnewnote', 'notes');
$navlinks = array();
$navlinks[] = array('name' => $straddnote, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header("{$course->shortname}: " . get_string('extendenrol'), $course->fullname, $navigation, "", "", true, " ", navmenu($course));
// this will contain all available the based On select options, but we'll disable some on them on a per user basis
print_heading($straddnote);
echo '<form method="post" action="groupaddnote.php" >';
echo '<div style="width:100%;text-align:center;">';
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:groupaddnote.php

示例2: test_note_updated_event

 /**
  * Tests for event note_updated.
  */
 public function test_note_updated_event()
 {
     // Delete a note.
     $sink = $this->redirectEvents();
     $note = clone $this->eventnote;
     $note->publishstate = NOTES_STATE_DRAFT;
     note_save($note);
     $events = $sink->get_events();
     $event = array_pop($events);
     // Delete note event.
     $sink->close();
     // Validate event data.
     $this->assertInstanceOf('\\core\\event\\note_updated', $event);
     $this->assertEquals($note->id, $event->objectid);
     $this->assertEquals($note->usermodified, $event->userid);
     $this->assertEquals($note->userid, $event->relateduserid);
     $this->assertEquals('post', $event->objecttable);
     $this->assertEquals(NOTES_STATE_DRAFT, $event->other['publishstate']);
     // Test legacy data.
     $logurl = new \moodle_url('index.php', array('course' => $note->courseid, 'user' => $note->userid));
     $logurl->set_anchor('note-' . $note->id);
     $arr = array($note->courseid, 'notes', 'update', $logurl, 'update note');
     $this->assertEventLegacyLogData($arr, $event);
     $this->assertEventContextNotUsed($event);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:events_test.php

示例3: print_error

        print_error('invalidformdata', '', $CFG->wwwroot . '/user/index.php?id=' . $id);
    }
    $note = new stdClass();
    $note->courseid = $id;
    $note->format = FORMAT_PLAIN;
    foreach ($users as $k => $v) {
        $user = $DB->get_record('user', array('id' => $v));
        $content = trim($contents[$k]);
        if (!$user || empty($content)) {
            continue;
        }
        $note->id = 0;
        $note->content = $content;
        $note->publishstate = $states[$k];
        $note->userid = $v;
        note_save($note);
    }
    redirect("{$CFG->wwwroot}/user/index.php?id={$id}");
}
// Print headers.
$straddnote = get_string('addnewnote', 'notes');
$PAGE->navbar->add($straddnote);
$PAGE->set_title("{$course->shortname}: " . get_string('extendenrol'));
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
// This will contain all available the based On select options, but we'll disable some on them on a per user basis.
echo $OUTPUT->heading($straddnote);
echo '<form method="post" action="addnote.php">';
echo '<fieldset class="invisiblefieldset">';
echo '<input type="hidden" name="id" value="' . $course->id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:addnote.php

示例4: create_notes

    /**
     * Create notes about some users
     * Note: code should be matching the /notes/edit.php checks
     * and the /user/addnote.php checks. (they are similar cheks)
     *
     * @param array $notes  An array of notes to create.
     * @return array (success infos and fail infos)
     * @since Moodle 2.2
     */
    public static function create_notes($notes = array()) {
        global $CFG, $DB;
        require_once($CFG->dirroot . "/notes/lib.php");

        $params = self::validate_parameters(self::create_notes_parameters(), array('notes' => $notes));

        //check if note system is enabled
        if (!$CFG->enablenotes) {
            throw new moodle_exception('notesdisabled', 'notes');
        }

        //retrieve all courses
        $courseids = array();
        foreach($params['notes'] as $note) {
            $courseids[] = $note['courseid'];
        }
        $courses = $DB->get_records_list("course", "id", $courseids);

        //retrieve all users of the notes
        $userids = array();
        foreach($params['notes'] as $note) {
            $userids[] = $note['userid'];
        }
        list($sqluserids, $sqlparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'userid_');
        $users = $DB->get_records_select("user", "id " . $sqluserids . " AND deleted = 0", $sqlparams);

        $resultnotes = array();
        foreach ($params['notes'] as $note) {

            $success = true;
            $resultnote = array(); //the infos about the success of the operation

            //check the course exists
            if (empty($courses[$note['courseid']])) {
                $success = false;
                $errormessage = get_string('invalidcourseid', 'notes', $note['courseid']);
            } else {
                // Ensure the current user is allowed to run this function
                $context = get_context_instance(CONTEXT_COURSE, $note['courseid']);
                self::validate_context($context);
                require_capability('moodle/notes:manage', $context);
            }

            //check the user exists
            if (empty($users[$note['userid']])) {
                $success = false;
                $errormessage = get_string('invaliduserid', 'notes', $note['userid']);
            }

            //build the resultnote
            if (isset($note['clientnoteid'])) {
                $resultnote['clientnoteid'] = $note['clientnoteid'];
            }

            if ($success) {
                //now we can create the note
                $dbnote = new stdClass;
                $dbnote->courseid = $note['courseid'];
                $dbnote->userid = $note['userid'];
                //clean param text and set format accordingly
                switch (strtolower($note['format'])) {
                    case 'html':
                        $dbnote->content = clean_param($note['text'], PARAM_CLEANHTML);
                        $dbnote->format = FORMAT_HTML;
                        break;
                    case 'text':
                    default:
                        $dbnote->content = clean_param($note['text'], PARAM_TEXT);
                        $dbnote->format = FORMAT_PLAIN;
                        break;
                }

                //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:
                        break;
                }

                //TODO MDL-31119 performance improvement - if possible create a bulk functions for saving multiple notes at once
                if (note_save($dbnote)) { //note_save attribut an id in case of success
                    add_to_log($dbnote->courseid, 'notes', 'add',
//.........这里部分代码省略.........
开发者ID:nicusX,项目名称:moodle,代码行数:101,代码来源:externallib.php

示例5: update

            $OUTPUT = update($_POST);
            break;
        case "display":
            $OUTPUT = financialStatements::trialbal($_POST);
            $ql = true;
            break;
        case ct("Print"):
        case ct("Save"):
        case ct("Export to Spreadsheet"):
            $OUTPUT = print_report();
            break;
        case "note_view":
            $OUTPUT = note_view($_POST);
            break;
        case "note_save":
            $OUTPUT = note_save($_POST);
            break;
    }
} else {
    $OUTPUT = customize($_POST);
    //$OUTPUT = financialStatements::trialbal($_GET);
    $ql = true;
}
require "../template.php";
function customize($_POST)
{
    extract($_POST);
    $fields["naccount"] = "";
    $fields["last_year"] = "checked";
    $fields["budget"] = "checked";
    $fields["month_from"] = (int) date("m");
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:trial_bal.php

示例6: 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

示例7: create_notes

 /**
  * Create notes about some users
  * Note: code should be matching the /notes/edit.php checks
  * and the /user/addnote.php checks. (they are similar cheks)
  *
  * @param array $notes  An array of notes to create.
  * @return array (success infos and fail infos)
  * @since Moodle 2.2
  */
 public static function create_notes($notes = array())
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . "/notes/lib.php";
     $params = self::validate_parameters(self::create_notes_parameters(), array('notes' => $notes));
     //check if note system is enabled
     if (!$CFG->enablenotes) {
         throw new moodle_exception('notesdisabled', 'notes');
     }
     //retrieve all courses
     $courseids = array();
     foreach ($params['notes'] as $note) {
         $courseids[] = $note['courseid'];
     }
     $courses = $DB->get_records_list("course", "id", $courseids);
     //retrieve all users of the notes
     $userids = array();
     foreach ($params['notes'] as $note) {
         $userids[] = $note['userid'];
     }
     list($sqluserids, $sqlparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'userid_');
     $users = $DB->get_records_select("user", "id " . $sqluserids . " AND deleted = 0", $sqlparams);
     $resultnotes = array();
     foreach ($params['notes'] as $note) {
         $success = true;
         $resultnote = array();
         //the infos about the success of the operation
         //check the course exists
         if (empty($courses[$note['courseid']])) {
             $success = false;
             $errormessage = get_string('invalidcourseid', 'error');
         } else {
             // Ensure the current user is allowed to run this function
             $context = get_context_instance(CONTEXT_COURSE, $note['courseid']);
             self::validate_context($context);
             require_capability('moodle/notes:manage', $context);
         }
         //check the user exists
         if (empty($users[$note['userid']])) {
             $success = false;
             $errormessage = get_string('invaliduserid', 'notes', $note['userid']);
         }
         //build the resultnote
         if (isset($note['clientnoteid'])) {
             $resultnote['clientnoteid'] = $note['clientnoteid'];
         }
         if ($success) {
             //now we can create the note
             $dbnote = new stdClass();
             $dbnote->courseid = $note['courseid'];
             $dbnote->userid = $note['userid'];
             // Need to support 'html' and 'text' format values for backward compatibility.
             switch (strtolower($note['format'])) {
                 case 'html':
                     $textformat = FORMAT_HTML;
                     break;
                 case 'text':
                     $textformat = FORMAT_PLAIN;
                 default:
                     $textformat = external_validate_format($note['format']);
                     break;
             }
             $dbnote->content = $note['text'];
             $dbnote->format = $textformat;
             //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:
                     break;
             }
             //TODO MDL-31119 performance improvement - if possible create a bulk functions for saving multiple notes at once
             if (note_save($dbnote)) {
                 //note_save attribut an id in case of success
                 add_to_log($dbnote->courseid, 'notes', 'add', 'index.php?course=' . $dbnote->courseid . '&amp;user=' . $dbnote->userid . '#note-' . $dbnote->id, 'add note');
                 $success = $dbnote->id;
             }
             $resultnote['noteid'] = $success;
         } else {
             // WARNINGS: for backward compatibility we return this errormessage.
             //          We should have thrown exceptions as these errors prevent results to be returned.
             // See http://docs.moodle.org/dev/Errors_handling_in_web_services#When_to_send_a_warning_on_the_server_side .
             $resultnote['noteid'] = -1;
//.........这里部分代码省略.........
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:externallib.php

示例8: create_instance

 /**
  * Create a new note.
  *
  * @param array|stdClass $record
  * @throws coding_exception
  * @return stdClass activity record with extra cmid field
  */
 public function create_instance($record = null)
 {
     global $CFG, $USER;
     require_once "{$CFG->dirroot}/notes/lib.php";
     $this->instancecount++;
     $i = $this->instancecount;
     $record = (object) (array) $record;
     if (empty($record->courseid)) {
         throw new coding_exception('Module generator requires $record->courseid.');
     }
     if (empty($record->userid)) {
         throw new coding_exception('Module generator requires $record->userid.');
     }
     if (!isset($record->module)) {
         $record->module = 'notes';
     }
     if (!isset($record->groupid)) {
         $record->groupid = 0;
     }
     if (!isset($record->moduleid)) {
         $record->moduleid = 0;
     }
     if (!isset($record->coursemoduleid)) {
         $record->coursemoduleid = 0;
     }
     if (!isset($record->subject)) {
         $record->subject = '';
     }
     if (!isset($record->summary)) {
         $record->summary = null;
     }
     if (!isset($record->content)) {
         $record->content = "This is test generated note - {$i} .";
     }
     if (!isset($record->uniquehash)) {
         $record->uniquehash = '';
     }
     if (!isset($record->rating)) {
         $record->rating = 0;
     }
     if (!isset($record->format)) {
         $record->format = FORMAT_PLAIN;
     }
     if (!isset($record->summaryformat)) {
         $record->summaryformat = FORMAT_MOODLE;
     }
     if (!isset($record->attachment)) {
         $record->attachment = null;
     }
     if (!isset($record->publishstate)) {
         $record->publishstate = NOTES_STATE_SITE;
     }
     if (!isset($record->lastmodified)) {
         $record->lastmodified = time();
     }
     if (!isset($record->created)) {
         $record->created = time();
     }
     if (!isset($record->usermodified)) {
         $record->usermodified = $USER->id;
     }
     note_save($record);
     return $record;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:71,代码来源:lib.php


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