本文整理汇总了PHP中trigger_elgg_event函数的典型用法代码示例。如果您正苦于以下问题:PHP trigger_elgg_event函数的具体用法?PHP trigger_elgg_event怎么用?PHP trigger_elgg_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trigger_elgg_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform_redirect
function perform_redirect()
{
global $CONFIG;
$username = get_loggedin_user()->username;
$custom = get_plugin_setting("custom_redirect", "new_profile_redirector");
if (!get_loggedin_user()->profile_updated && !empty($custom)) {
$custom = str_replace("[wwwroot]", $CONFIG->wwwroot, $custom);
$custom = str_replace("[username]", $username, $custom);
get_loggedin_user()->profile_updated = 1;
trigger_elgg_event('firstprofileupdate', 'user', $user);
forward($custom);
}
}
示例2: update_annotation
/**
* Update an annotation.
*
* @param int $annotation_id
* @param string $name
* @param string $value
* @param string $value_type
* @param int $owner_guid
* @param int $access_id
*/
function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id)
{
global $CONFIG;
$annotation_id = (int) $annotation_id;
$name = trim($name);
$value = trim($value);
$value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
$owner_guid = (int) $owner_guid;
if ($owner_guid == 0) {
$owner_guid = get_loggedin_userid();
}
$access_id = (int) $access_id;
$access = get_access_sql_suffix();
// Add the metastring
$value = add_metastring($value);
if (!$value) {
return false;
}
$name = add_metastring($name);
if (!$name) {
return false;
}
// If ok then add it
$result = update_data("UPDATE {$CONFIG->dbprefix}annotations set value_id='{$value}', value_type='{$value_type}', access_id={$access_id}, owner_guid={$owner_guid} where id={$annotation_id} and name_id='{$name}' and {$access}");
if ($result !== false) {
$obj = get_annotation($annotation_id);
if (trigger_elgg_event('update', 'annotation', $obj)) {
return true;
} else {
delete_annotation($annotation_id);
}
}
return $result;
}
示例3: version_upgrade
/**
* Upgrades Elgg
*
*/
function version_upgrade()
{
$dbversion = (int) datalist_get('version');
// Upgrade database
db_upgrade($dbversion);
system_message(elgg_echo('upgrade:db'));
// Upgrade core
if (upgrade_code($dbversion)) {
system_message(elgg_echo('upgrade:core'));
}
// Now we trigger an event to give the option for plugins to do something
$upgrade_details = stdClass;
$upgrade_details->from = $dbversion;
$upgrade_details->to = get_version();
trigger_elgg_event('upgrade', 'upgrade', $upgrade_details);
// Update the version
datalist_set('version', get_version());
}
示例4: request_user_validation
/**
* Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
*
* This function invalidates any existing validation value.
*
* @param int $user_guid User's GUID
* @deprecated 1.8 Hook into the register, user plugin hook and request validation.
*/
function request_user_validation($user_guid)
{
elgg_deprecated_notice("request_user_validation() is deprecated.\n\t\tPlugins should register for the 'register, user' plugin hook", 1.8);
$user = get_entity($user_guid);
if ($user && $user instanceof ElggUser) {
// invalidate any existing validations
set_user_validation_status($user_guid, false);
// request validation
trigger_elgg_event('validate', 'user', $user);
}
}
示例5: delete_annotation
/**
* Delete a given annotation.
*
* @param $id int The id
*/
function delete_annotation($id)
{
global $CONFIG;
$id = (int) $id;
$access = get_access_sql_suffix();
$annotation = get_annotation($id);
if (trigger_elgg_event('delete', 'annotation', $annotation)) {
return delete_data("DELETE from {$CONFIG->dbprefix}annotations where id={$id} and {$access}");
}
return false;
}
示例6: request_user_validation
/**
* Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
*
* This event invalidates any existing values and returns
*
* @param unknown_type $user_guid
*/
function request_user_validation($user_guid)
{
$user = get_entity($user_guid);
if ($user && $user instanceof ElggUser) {
// invalidate any existing validations
set_user_validation_status($user_guid, false);
// request validation
trigger_elgg_event('validate', 'user', $user);
}
}
示例7: load_plugins
$lightmode = true;
}
// Load plugins, if we're not in light mode
if ($installed && $db_installed && $sanitised && !$lightmode) {
load_plugins();
trigger_elgg_event('plugins_boot', 'system');
}
// Forward if we haven't been installed
if ((!$installed || !$db_installed) && !substr_count($_SERVER["PHP_SELF"], "install.php") && !substr_count($_SERVER["PHP_SELF"], "css.php") && !substr_count($_SERVER["PHP_SELF"], "action_handler.php")) {
header("Location: install.php");
exit;
}
// Trigger events
if (!substr_count($_SERVER["PHP_SELF"], "install.php") && !substr_count($_SERVER["PHP_SELF"], "setup.php") && !$lightmode && !(defined('upgrading') && upgrading == 'upgrading')) {
// If default settings haven't been installed, forward to the default settings page
trigger_elgg_event('init', 'system');
//if (!datalist_get('default_settings')) {
//forward("setup.php");
//}
}
// System booted, return to normal view
set_input('view', $oldview);
if (empty($oldview)) {
if (empty($CONFIG->view)) {
$oldview = 'default';
} else {
$oldview = $CONFIG->view;
}
}
if ($installed && $db_installed) {
$lastupdate = datalist_get('simplecache_lastupdate');
示例8: logout
/**
* Log the current user out
*
* @return true|false
*/
function logout()
{
global $CONFIG;
if (isset($_SESSION['user'])) {
if (!trigger_elgg_event('logout', 'user', $_SESSION['user'])) {
return false;
}
$_SESSION['user']->code = "";
$_SESSION['user']->save();
}
unset($_SESSION['username']);
unset($_SESSION['name']);
unset($_SESSION['code']);
unset($_SESSION['guid']);
unset($_SESSION['id']);
unset($_SESSION['user']);
setcookie("elggperm", "", time() - 86400 * 30, "/");
// pass along any messages
$old_msg = $_SESSION['msg'];
session_destroy();
// starting a default session to store any post-logout messages.
session_init(NULL, NULL, NULL);
$_SESSION['msg'] = $old_msg;
return TRUE;
}
示例9: __elgg_shutdown_hook
/**
* This function is a shutdown hook registered on startup which does nothing more than trigger a
* shutdown event when the script is shutting down, but before database connections have been dropped etc.
*
*/
function __elgg_shutdown_hook()
{
global $START_MICROTIME;
trigger_elgg_event('shutdown', 'system');
$time = (double) (microtime(TRUE) - $START_MICROTIME);
elgg_log("Page {$_SERVER['REQUEST_URI']} generated in {$time} seconds", 'DEBUG');
}
示例10: delete_metadata
/**
* Delete an item of metadata, where the current user has access.
*
* @param $id int The item of metadata to delete.
*/
function delete_metadata($id)
{
global $CONFIG;
$id = (int) $id;
$metadata = get_metadata($id);
if ($metadata) {
// Tidy up if memcache is enabled.
static $metabyname_memcache;
if (!$metabyname_memcache && is_memcache_available()) {
$metabyname_memcache = new ElggMemcache('metabyname_memcache');
}
if ($metabyname_memcache) {
$metabyname_memcache->delete("{$metadata->entity_guid}:{$metadata->name_id}");
}
if ($metadata->canEdit() && trigger_elgg_event('delete', 'metadata', $metadata)) {
return delete_data("DELETE from {$CONFIG->dbprefix}metadata where id={$id}");
}
}
return false;
}
示例11: sprintf
if (count($not_uploaded) > 0) {
if (count($uploaded_images) > 0) {
$error = sprintf(elgg_echo("tidypics:partialuploadfailure"), count($not_uploaded), count($not_uploaded) + count($uploaded_images)) . '<br />';
} else {
$error = elgg_echo("tidypics:completeuploadfailure") . '<br />';
}
$num_failures = count($not_uploaded);
for ($i = 0; $i < $num_failures; $i++) {
$error .= "{$not_uploaded[$i]}: {$error_msgs[$i]} <br />";
}
register_error($error);
if (count($uploaded_images) == 0) {
forward(get_input('forward_url', $_SERVER['HTTP_REFERER']));
} else {
// some images did upload so we fall through
}
} else {
system_message(elgg_echo('tidypics:upl_success'));
}
if (count($uploaded_images) && $img_river_view == "1") {
if (function_exists('add_to_river')) {
add_to_river('river/object/image/create', 'create', $file_for_river->getObjectOwnerGUID(), $file_for_river->getGUID());
}
}
// update image repo size
create_metadata($album->container_guid, "image_repo_size", $image_repo_size, 'integer', $album->container_guid);
// plugins can register to be told when a Tidypics album has had images added
trigger_elgg_event('upload', 'tp_album', $album);
//forward to multi-image edit page
$url = $CONFIG->wwwroot . 'mod/tidypics/pages/edit_multiple.php?files=' . implode('-', $uploaded_images);
forward($url);
示例12: array
// get the images and save their file handlers into an array
// so we can do clean up if one fails.
$files = array();
foreach ($icon_sizes as $name => $size_info) {
$resized = get_resized_image_from_uploaded_file('profileicon', $size_info['w'], $size_info['h'], $size_info['square']);
if ($resized) {
//@todo Make these actual entities. See exts #348.
$file = new ElggFile();
$file->owner_guid = $profile_owner_guid;
$file->setFilename("profile/{$profile_username}{$name}.jpg");
$file->open('write');
$file->write($resized);
$file->close();
$files[] = $file;
} else {
// cleanup on fail
foreach ($files as $file) {
$file->delete();
}
system_message(elgg_echo('profile:icon:notfound'));
forward($_SERVER['HTTP_REFERER']);
}
}
$profile_owner->icontime = time();
if (trigger_elgg_event('profileiconupdate', $profile_owner->type, $profile_owner)) {
// pull this out into the river plugin.
//add_to_river('river/user/default/profileiconupdate','update',$user->guid,$user->guid);
system_message(elgg_echo("profile:icon:uploaded"));
}
//forward the user back to the upload page to crop
forward($_SERVER['HTTP_REFERER']);
示例13: system_log_listener
/**
* System log listener.
* This function listens to all events in the system and logs anything appropriate.
*
* @param String $event
* @param String $object_type
* @param Loggable $object
*/
function system_log_listener($event, $object_type, $object)
{
if ($object_type != 'systemlog' && $event != 'log') {
trigger_elgg_event('log', 'systemlog', array('object' => $object, 'event' => $event));
}
return true;
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:15,代码来源:system_log.php
示例14: delete_entity
/**
* Delete a given entity.
*
* @param int $guid
* @param bool $recursive If true (default) then all entities which are owned or contained by $guid will also be deleted.
* Note: this bypasses ownership of sub items.
*/
function delete_entity($guid, $recursive = true)
{
global $CONFIG;
$guid = (int) $guid;
if ($entity = get_entity($guid)) {
if (trigger_elgg_event('delete', $entity->type, $entity)) {
if ($entity->canEdit()) {
// Delete contained owned and otherwise releated objects (depth first)
if ($recursive) {
// Temporary token overriding access controls TODO: Do this better.
static $__RECURSIVE_DELETE_TOKEN;
$__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid());
// Make it slightly harder to guess
$sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid={$guid} or owner_guid={$guid} or site_guid={$guid}", 'entity_row_to_elggstar');
if ($sub_entities) {
foreach ($sub_entities as $e) {
$e->delete();
}
}
$__RECURSIVE_DELETE_TOKEN = null;
}
// Now delete the entity itself
$entity->clearMetadata();
$entity->clearAnnotations();
$entity->clearRelationships();
remove_from_river_by_subject($guid);
remove_from_river_by_object($guid);
remove_all_private_settings($guid);
$res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
if ($res) {
$sub_table = "";
// Where appropriate delete the sub table
switch ($entity->type) {
case 'object':
$sub_table = $CONFIG->dbprefix . 'objects_entity';
break;
case 'user':
$sub_table = $CONFIG->dbprefix . 'users_entity';
break;
case 'group':
$sub_table = $CONFIG->dbprefix . 'groups_entity';
break;
case 'site':
$sub_table = $CONFIG->dbprefix . 'sites_entity';
break;
}
if ($sub_table) {
delete_data("DELETE from {$sub_table} where guid={$guid}");
}
}
return $res;
}
}
}
return false;
}
示例15: leave_group
/**
* Remove a user from a group.
*
* @param int $group_guid The group.
* @param int $user_guid The user.
*/
function leave_group($group_guid, $user_guid)
{
// event needs to be triggered while user is still member of group to have access to group acl
trigger_elgg_event('leave', 'group', array('group' => get_entity($group_guid), 'user' => get_entity($user_guid)));
$result = remove_entity_relationship($user_guid, 'member', $group_guid);
return $result;
}