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


PHP events_trigger函数代码示例

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


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

示例1: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $user->password = hash_internal_user_password($user->password);
     $user->id = $DB->insert_record('user', $user);
     /// Save any custom profile field information
     profile_save_data($user);
     $user = $DB->get_record('user', array('id' => $user->id));
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth_email');
     }
     if ($notify) {
         global $CFG, $PAGE, $OUTPUT;
         $emailconfirm = get_string('emailconfirm');
         $PAGE->navbar->add($emailconfirm);
         $PAGE->set_title($emailconfirm);
         $PAGE->set_heading($PAGE->course->fullname);
         echo $OUTPUT->header();
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:32,代码来源:auth.php

示例2: user_signup

 /**
  * Sign up a new user ready for confirmation.
  * Password is passed in plaintext.
  *
  * @param object $user new user object (with system magic quotes)
  * @param boolean $notify print notice with link and terminate
  */
 function user_signup($user, $notify = true)
 {
     global $CFG;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     $user = get_record('user', 'id', $user->id);
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         $navlinks = array();
         $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($emailconfirm, $emailconfirm, $navigation);
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:34,代码来源:auth.php

示例3: cluster_groups_changed

function cluster_groups_changed($name)
{
    global $DB;
    $shortname = substr($name, strpos($name, 'local_elisprogram_') + strlen('local_elisprogram_'));
    // TBD: following didn't work?
    //$value = elis::$config->local_elisprogram->$shortname;
    $value = $DB->get_field('config_plugins', 'value', array('plugin' => 'local_elisprogram', 'name' => $shortname));
    //error_log("/local/elisprogram/lib/lib.php::cluster_groups_changed({$name}) {$shortname} = '{$value}'");
    if (!empty($value)) {
        $event = 'crlm_' . $shortname . '_enabled';
        error_log("Triggering event: {$event}");
        events_trigger($event, 0);
    }
}
开发者ID:jamesmcq,项目名称:elis,代码行数:14,代码来源:lib.php

示例4: user_update_user

/**
 * Update a user with a user object (will compare against the ID)
 *
 * @param object $user the user to update
 */
function user_update_user($user)
{
    global $DB;
    // set the timecreate field to the current time
    if (!is_object($user)) {
        $user = (object) $user;
    }
    // unset password here, for updating later
    if (isset($user->password)) {
        $passwd = $user->password;
        unset($user->password);
    }
    $user->timemodified = time();
    $DB->update_record('user', $user);
    // trigger user_updated event on the full database user row
    $updateduser = $DB->get_record('user', array('id' => $user->id));
    events_trigger('user_updated', $updateduser);
    // if password was set, then update its hash
    if (isset($passwd)) {
        update_internal_user_password($updateduser, $passwd);
    }
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:27,代码来源:lib.php

示例5: user_signup

 function user_signup($user, $notify = true)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     $password_clear = $user->password;
     $user->password = hash_internal_user_password($user->password);
     if (!($user->id = $DB->insert_record('user', $user))) {
         print_error('auth_emailnoinsert', 'auth');
     }
     /// Save any custom profile field information
     profile_save_data($user);
     $conditions = array('id' => $user->id);
     $user = $DB->get_record('user', $conditions);
     /* Create user in Joomla */
     $userinfo['username'] = $user->username;
     $userinfo['password'] = $password_clear;
     $userinfo['password2'] = $password_clear;
     $userinfo['name'] = $user->firstname . " " . $user->lastname;
     $userinfo['email'] = $user->email;
     $userinfo['block'] = 1;
     $this->call_method("createUser", $userinfo);
     events_trigger('user_created', $user);
     if (!send_confirmation_email($user)) {
         print_error('auth_emailnoemail', 'auth');
     }
     if ($notify) {
         global $CFG;
         $emailconfirm = get_string('emailconfirm');
         $navlinks = array();
         $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($emailconfirm, $emailconfirm, $navigation);
         notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php");
     } else {
         return true;
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:37,代码来源:auth.php

示例6: groups_add_member

/**
 * Adds a specified user to a group
 * @param int $userid   The user id
 * @param int $groupid  The group id
 * @return boolean True if user added successfully or the user is already a 
 * member of the group, false otherwise. 
 */
function groups_add_member($groupid, $userid)
{
    if (!groups_group_exists($groupid)) {
        return false;
    }
    if (groups_is_member($groupid, $userid)) {
        return true;
    }
    $member = new object();
    $member->groupid = $groupid;
    $member->userid = $userid;
    $member->timeadded = time();
    if (!insert_record('groups_members', $member)) {
        return false;
    }
    //update group info
    set_field('groups', 'timemodified', $member->timeadded, 'id', $groupid);
    // MDL-9983
    $eventdata = new object();
    $eventdata->groupid = $groupid;
    $eventdata->userid = $userid;
    events_trigger('group_user_added', $eventdata);
    return true;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:lib.php

示例7: implode

        } else {
            $newlayout[] = 0;
        }
    }
    $attempt->layout = implode(',', $newlayout);
}
// Save the attempt in the database.
$transaction = $DB->start_delegated_transaction();
question_engine::save_questions_usage_by_activity($quba);
$attempt->uniqueid = $quba->get_id();
$attempt->id = $DB->insert_record('quiz_attempts', $attempt);
// Log the new attempt.
if ($attempt->preview) {
    add_to_log($course->id, 'quiz', 'preview', 'view.php?id=' . $quizobj->get_cmid(), $quizobj->get_quizid(), $quizobj->get_cmid());
} else {
    add_to_log($course->id, 'quiz', 'attempt', 'review.php?attempt=' . $attempt->id, $quizobj->get_quizid(), $quizobj->get_cmid());
}
// Trigger event.
$eventdata = new stdClass();
$eventdata->component = 'mod_quiz';
$eventdata->attemptid = $attempt->id;
$eventdata->timestart = $attempt->timestart;
$eventdata->timestamp = $attempt->timestart;
$eventdata->userid = $attempt->userid;
$eventdata->quizid = $quizobj->get_quizid();
$eventdata->cmid = $quizobj->get_cmid();
$eventdata->courseid = $quizobj->get_courseid();
events_trigger('quiz_attempt_started', $eventdata);
$transaction->allow_commit();
// Redirect to the attempt page.
redirect($quizobj->attempt_url($attempt->id, $page));
开发者ID:vinoth4891,项目名称:clinique,代码行数:31,代码来源:startattempt.php

示例8: update_course

/**
 * Update a course.
 *
 * Please note this functions does not verify any access control,
 * the calling code is responsible for all validation (usually it is the form definition).
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 * @param array $editoroptions course description editor options
 * @return void
 */
function update_course($data, $editoroptions = NULL)
{
    global $CFG, $DB;
    $data->timemodified = time();
    $oldcourse = $DB->get_record('course', array('id' => $data->id), '*', MUST_EXIST);
    $context = get_context_instance(CONTEXT_COURSE, $oldcourse->id);
    if ($editoroptions) {
        $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
    }
    if (!isset($data->category) or empty($data->category)) {
        // prevent nulls and 0 in category field
        unset($data->category);
    }
    $movecat = (isset($data->category) and $oldcourse->category != $data->category);
    if (!isset($data->visible)) {
        // data not from form, add missing visibility info
        $data->visible = $oldcourse->visible;
    }
    if ($data->visible != $oldcourse->visible) {
        // reset the visibleold flag when manually hiding/unhiding course
        $data->visibleold = $data->visible;
    } else {
        if ($movecat) {
            $newcategory = $DB->get_record('course_categories', array('id' => $data->category));
            if (empty($newcategory->visible)) {
                // make sure when moving into hidden category the course is hidden automatically
                $data->visible = 0;
            }
        }
    }
    // Update with the new data
    $DB->update_record('course', $data);
    $course = $DB->get_record('course', array('id' => $data->id));
    if ($movecat) {
        $newparent = get_context_instance(CONTEXT_COURSECAT, $course->category);
        context_moved($context, $newparent);
    }
    fix_course_sortorder();
    // Test for and remove blocks which aren't appropriate anymore
    blocks_remove_inappropriate($course);
    // Save any custom role names.
    save_local_role_names($course->id, $data);
    // update enrol settings
    enrol_course_updated(false, $course, $data);
    add_to_log($course->id, "course", "update", "edit.php?id={$course->id}", $course->id);
    // Trigger events
    events_trigger('course_updated', $course);
}
开发者ID:numbas,项目名称:moodle,代码行数:58,代码来源:lib.php

示例9: associate

 /**
  * Associates a cluster with a track.
  */
 static function associate($cluster, $track, $autounenrol = true, $autoenrol = true)
 {
     global $CURMAN;
     $db = $CURMAN->db;
     // make sure we don't double-associate
     if ($db->record_exists(CLSTTRKTABLE, 'clusterid', $cluster, 'trackid', $track)) {
         return;
     }
     $record = new clustertrack();
     $record->clusterid = $cluster;
     $record->trackid = $track;
     $record->autoenrol = $autoenrol;
     $record->autounenrol = $autounenrol;
     $record->data_insert_record();
     // Enrol all users in the cluster into track.
     $sql = 'SELECT uc.*
             FROM ' . $CURMAN->db->prefix_table(CLSTASSTABLE) . ' as uc
             JOIN ' . $CURMAN->db->prefix_table(USRTABLE) . ' as u
             ON uc.userid = u.id
             WHERE uc.clusterid = ' . $cluster . ' AND uc.autoenrol = 1
             ORDER BY u.lastname';
     $users = $db->get_records_sql($sql);
     //        $users = $db->get_records(CLSTUSERTABLE, 'clusterid', $cluster);
     if ($users && !empty($autoenrol)) {
         foreach ($users as $user) {
             usertrack::enrol($user->userid, $track);
         }
     }
     events_trigger('crlm_cluster_track_associated', $record);
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:33,代码来源:clustercurriculum.class.php

示例10: finish_setup_course_module

 /**
  * Called after the mod has set itself up, to finish off any course module settings
  * (set instance id, add to correct section, set visibility, etc.) and send the response
  *
  * @param int $instanceid id returned by the mod when it was created
  */
 protected function finish_setup_course_module($instanceid)
 {
     global $DB, $USER;
     if (!$instanceid) {
         // Something has gone wrong - undo everything we can.
         delete_course_module($this->cm->id);
         throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
     }
     $DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
     // Rebuild the course cache after update action
     rebuild_course_cache($this->course->id, true);
     $this->course->modinfo = null;
     // Otherwise we will just get the old version back again.
     $sectionid = course_add_cm_to_section($this->course, $this->cm->id, $this->section);
     set_coursemodule_visible($this->cm->id, true);
     // retrieve the final info about this module.
     $info = get_fast_modinfo($this->course);
     if (!isset($info->cms[$this->cm->id])) {
         // The course module has not been properly created in the course - undo everything.
         delete_course_module($this->cm->id);
         throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
     }
     $mod = $info->cms[$this->cm->id];
     $mod->groupmodelink = $this->cm->groupmodelink;
     $mod->groupmode = $this->cm->groupmode;
     // Trigger mod_created event with information about this module.
     $eventdata = new stdClass();
     $eventdata->modulename = $mod->modname;
     $eventdata->name = $mod->name;
     $eventdata->cmid = $mod->id;
     $eventdata->courseid = $this->course->id;
     $eventdata->userid = $USER->id;
     events_trigger('mod_created', $eventdata);
     add_to_log($this->course->id, "course", "add mod", "../mod/{$mod->modname}/view.php?id={$mod->id}", "{$mod->modname} {$instanceid}");
     add_to_log($this->course->id, $mod->modname, "add", "view.php?id={$mod->id}", "{$instanceid}", $mod->id);
     $this->send_response($mod);
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:43,代码来源:dnduploadlib.php

示例11: forum_trigger_content_uploaded_event

/**
 * Sends post content to plagiarism plugin
 * @param object $post Forum post object
 * @param object $cm Course-module
 * @param string $name
 * @return bool
*/
function forum_trigger_content_uploaded_event($post, $cm, $name) {
    $context = context_module::instance($cm->id);
    $fs = get_file_storage();
    $files = $fs->get_area_files($context->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
    $eventdata = new stdClass();
    $eventdata->modulename   = 'forum';
    $eventdata->name         = $name;
    $eventdata->cmid         = $cm->id;
    $eventdata->itemid       = $post->id;
    $eventdata->courseid     = $post->course;
    $eventdata->userid       = $post->userid;
    $eventdata->content      = $post->message;
    if ($files) {
        $eventdata->pathnamehashes = array_keys($files);
    }
    events_trigger('assessable_content_uploaded', $eventdata);

    return true;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:26,代码来源:lib.php

示例12: delete_course

/**
 * Delete a course, including all related data from the database,
 * and any associated files from the moodledata folder.
 *
 * @param mixed $courseorid The id of the course or course object to delete.
 * @param bool $showfeedback Whether to display notifications of each action the function performs.
 * @return bool true if all the removals succeeded. false if there were any failures. If this
 *             method returns false, some of the removals will probably have succeeded, and others
 *             failed, but you have no way of knowing which.
 */
function delete_course($courseorid, $showfeedback = true)
{
    global $CFG;
    $result = true;
    if (is_object($courseorid)) {
        $courseid = $courseorid->id;
        $course = $courseorid;
    } else {
        $courseid = $courseorid;
        if (!($course = get_record('course', 'id', $courseid))) {
            return false;
        }
    }
    // frontpage course can not be deleted!!
    if ($courseid == SITEID) {
        return false;
    }
    if (!remove_course_contents($courseid, $showfeedback)) {
        if ($showfeedback) {
            notify("An error occurred while deleting some of the course contents.");
        }
        $result = false;
    }
    if (!delete_records("course", "id", $courseid)) {
        if ($showfeedback) {
            notify("An error occurred while deleting the main course record.");
        }
        $result = false;
    }
    /// Delete all roles and overiddes in the course context
    if (!delete_context(CONTEXT_COURSE, $courseid)) {
        if ($showfeedback) {
            notify("An error occurred while deleting the main course context.");
        }
        $result = false;
    }
    if (!fulldelete($CFG->dataroot . '/' . $courseid)) {
        if ($showfeedback) {
            notify("An error occurred while deleting the course files.");
        }
        $result = false;
    }
    if ($result) {
        //trigger events
        events_trigger('course_deleted', $course);
    }
    return $result;
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:58,代码来源:moodlelib.php

示例13: test__events_trigger__failed_instant

 /**
  * tests events_trigger funtion() when instant handler fails
  */
 function test__events_trigger__failed_instant()
 {
     $this->assertEqual(1, events_trigger('test_instant', 'fail'), 'fail first event: %s');
     $this->assertEqual(1, events_trigger('test_instant', 'ok'), 'this one should fail too: %s');
     $this->assertEqual(0, events_cron('test_instant'), 'all events should stay in queue: %s');
     $this->assertEqual(2, events_pending_count('test_instant'), 'two events should in queue: %s');
     $this->assertEqual(0, sample_function_handler('status'), 'verify no event dispatched yet: %s');
     sample_function_handler('ignorefail');
     //ignore "fail" eventdata from now on
     $this->assertEqual(1, events_trigger('test_instant', 'ok'), 'this one should go to queue directly: %s');
     $this->assertEqual(3, events_pending_count('test_instant'), 'three events should in queue: %s');
     $this->assertEqual(0, sample_function_handler('status'), 'verify previous event was not dispatched: %s');
     $this->assertEqual(3, events_cron('test_instant'), 'all events should be dispatched: %s');
     $this->assertEqual(3, sample_function_handler('status'), 'verify three events were dispatched: %s');
     $this->assertEqual(0, events_pending_count('test_instant'), 'no events should in queue: %s');
     $this->assertEqual(0, events_trigger('test_instant', 'ok'), 'this event should be dispatched immediately: %s');
     $this->assertEqual(4, sample_function_handler('status'), 'verify event was dispatched: %s');
     $this->assertEqual(0, events_pending_count('test_instant'), 'no events should in queue: %s');
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:22,代码来源:testeventslib.php

示例14: test_pmuser_moodle_fullname

 /**
  * Test PM user method moodle_fullname
  */
 public function test_pmuser_moodle_fullname()
 {
     global $DB;
     // Create a Moodle user
     $src = new stdClass();
     $src->username = '_____phpunit_test_';
     $src->password = 'pass';
     $src->idnumber = '_____phpunit_test_';
     $src->firstname = 'John';
     $src->lastname = 'Doe';
     $src->email = 'jdoe@phpunit.example.com';
     $src->country = 'CA';
     $src->confirmed = 1;
     $src->id = $DB->insert_record('user', $src);
     events_trigger('user_created', $src);
     // Get the PM user
     $retr = user::find(new field_filter('idnumber', $src->idnumber), array(), 0, 0);
     $this->assertTrue($retr->valid());
     $retr = $retr->current();
     $mdluser = $DB->get_record('user', array('id' => $src->id));
     $this->assertEquals(fullname($mdluser), $retr->moodle_fullname());
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:25,代码来源:user_test.php

示例15: user_update_user

/**
 * Update a user with a user object (will compare against the ID)
 *
 * @param object $user the user to update
 */
function user_update_user($user)
{
    global $DB;
    // set the timecreate field to the current time
    if (!is_object($user)) {
        $user = (object) $user;
    }
    //check username
    if (isset($user->username)) {
        if ($user->username !== textlib::strtolower($user->username)) {
            throw new moodle_exception('usernamelowercase');
        } else {
            if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {
                throw new moodle_exception('invalidusername');
            }
        }
    }
    // unset password here, for updating later
    if (isset($user->password)) {
        //check password toward the password policy
        if (!check_password_policy($user->password, $errmsg)) {
            throw new moodle_exception($errmsg);
        }
        $passwd = $user->password;
        unset($user->password);
    }
    $user->timemodified = time();
    $DB->update_record('user', $user);
    // trigger user_updated event on the full database user row
    $updateduser = $DB->get_record('user', array('id' => $user->id));
    // if password was set, then update its hash
    if (isset($passwd)) {
        $authplugin = get_auth_plugin($updateduser->auth);
        if ($authplugin->can_change_password()) {
            $authplugin->user_update_password($updateduser, $passwd);
        }
    }
    events_trigger('user_updated', $updateduser);
    add_to_log(SITEID, 'user', get_string('update'), '/view.php?id=' . $updateduser->id, fullname($updateduser));
}
开发者ID:nmicha,项目名称:moodle,代码行数:45,代码来源:lib.php


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