function developers_process_settings() { if (elgg_get_plugin_setting('display_errors', 'developers') == 1) { ini_set('display_errors', 1); } else { ini_set('display_errors', 0); } if (elgg_get_plugin_setting('screen_log', 'developers') == 1) { $cache = new ElggLogCache(); elgg_set_config('log_cache', $cache); elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); elgg_extend_view('page/elements/foot', 'developers/log'); } if (elgg_get_plugin_setting('show_strings', 'developers') == 1) { // first and last in case a plugin registers a translation in an init method elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1000); elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1); } if (elgg_get_plugin_setting('wrap_views', 'developers') == 1) { elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views'); } if (elgg_get_plugin_setting('log_events', 'developers') == 1) { elgg_register_event_handler('all', 'all', 'developers_log_events', 1); elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } }
/** * Initialize the pages plugin. * */ function publications_init() { // register a library of helper functions elgg_register_library('elgg:publications', elgg_get_plugins_path() . 'publications/lib/publications.php'); $item = new ElggMenuItem('pages', elgg_echo('publications'), 'publications/all'); elgg_register_menu_item('site', $item); // Register a page handler, so we can have nice URLs elgg_register_page_handler('publications', 'publications_page_handler'); // Register an icon handler for blog elgg_register_page_handler("publicationsicon", "publications_icon_handler"); // Register a url handler elgg_register_entity_url_handler('object', 'publication', 'publication_url_handler'); // Register some actions $action_base = elgg_get_plugins_path() . 'publications/actions'; elgg_register_action("publications/edit", "{$action_base}/publications/edit.php"); elgg_register_action("publications/delete", "{$action_base}/publications/delete.php"); // Register entity type for search elgg_register_entity_type('object', 'publication'); //icon url overide elgg_register_plugin_hook_handler("entity:icon:url", "object", "publications_icon_hook"); //add a widget elgg_register_widget_type('publications', elgg_echo('publications'), elgg_echo('publications:widget:description'), "index"); // Language short codes must be of the form "pages:key" // where key is the array key below elgg_set_config('publications', array('title' => 'text', 'description' => 'longtext', 'pubDate' => 'text', 'tags' => 'tags', 'access_id' => 'access')); }
/** * hook called on route, all * check if $returnvalue['handler'] to see if we need to replace it * if the handler is an original handler, we want to foward it to the new url * * @param type $hook * @param type $type * @param type $returnvalue * @param type $params * @return array */ function router($hook, $type, $returnvalue, $params) { if (elgg_get_config('pagehandler_hijack')) { return $returnvalue; } $handlers = get_replacement_handlers(); if (in_array($returnvalue['handler'], array_keys($handlers))) { // we have been given an old handler -> we should forward to the replacement // probably from an old link or something $currenturl = current_page_url(); //get everything after the pagehandler $afterhandler = str_replace(elgg_get_site_url() . $returnvalue['handler'], "", $currenturl); $newurl = elgg_get_site_url() . $handlers[$returnvalue['handler']] . $afterhandler; // forward to the new url forward($newurl); } if (in_array($returnvalue['handler'], $handlers)) { // we need to do something about it // get the original handler $original = array_search($returnvalue['handler'], $handlers); if (!empty($original)) { // reset the context for non-hijack aware code elgg_set_context($original); // let the system load content for the original handler $returnvalue['handler'] = $original; $returnvalue['identifier'] = $original; // set a flag so we don't infinite loop ourselves in route hooks elgg_set_config('pagehandler_hijack', true); return elgg_trigger_plugin_hook('route', $original, null, $returnvalue); } } }
/** * Cron initialization * * @return void * @access private */ function _elgg_cron_init() { elgg_register_page_handler('cron', '_elgg_cron_page_handler'); elgg_register_plugin_hook_handler('cron', 'all', '_elgg_cron_monitor', 1000); elgg_set_config('elgg_cron_periods', array('minute', 'fiveminute', 'fifteenmin', 'halfhour', 'hourly', 'daily', 'weekly', 'monthly', 'yearly')); elgg_register_admin_menu_item('administer', 'cron', 'statistics'); }
/** * Initialize the projects plugin. * */ function surveys_init() { // register a library of helper functions elgg_register_library('surveys', elgg_get_plugins_path() . 'surveys/lib/surveys.php'); elgg_load_library('surveys'); //register css $css_url = 'mod/surveys/css/styles.css'; elgg_register_css('surveysCss', $css_url); elgg_load_css('surveysCss'); // register a project handler, so we can have nice URLs elgg_register_page_handler('surveys', 'surveys_page_handler'); // register a url handler elgg_register_entity_url_handler('object', 'survey', 'surveys_url'); // register entity type for search elgg_register_entity_type('object', 'survey'); // register some actions $action_base = elgg_get_plugins_path() . 'surveys/actions'; elgg_register_action("surveys/submit", "{$action_base}/submit.php"); elgg_register_action("surveys/delete", "{$action_base}/delete.php"); elgg_register_action("surveys/edit", "{$action_base}/edit.php"); // Language short codes must be of the form "projects:key" // where key is the array key below elgg_set_config('surveys', array('hear[]' => 'custom_checkbox', 'reason[]' => 'custom_checkbox', 'overall' => 'dropdown', 'speakers' => 'dropdown', 'facilitators' => 'dropdown', 'topics' => 'dropdown', 'structure' => 'dropdown', 'relevance' => 'dropdown', 'venue' => 'dropdown', 'overall_length' => 'dropdown', 'presentations' => 'dropdown', 'breaks' => 'dropdown', 'networking' => 'dropdown', 'groups' => 'dropdown', 'plenaries' => 'dropdown', 'worked' => 'plaintext', 'not_useful' => 'plaintext', 'useful' => 'plaintext', 'willAttend' => 'radio', 'attendExplain' => 'plaintext', 'help' => 'radio', 'helpExplain' => 'plaintext', 'recommend' => 'radio', 'otherDeparts' => 'radio', 'otherDepartsExplain' => 'plaintext', 'usefulDev' => 'radio', 'usefulDevExplain' => 'plaintext', 'suggestion' => 'plaintext', 'final1' => 'radio', 'final2' => 'radio', 'final3' => 'radio', 'final4' => 'radio', 'final5' => 'radio', 'final6' => 'radio', 'final7' => 'radio', 'final8[]' => 'custom_checkbox', 'final9' => 'plaintext', 'final10' => 'text')); // register the hook handler //elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'projects_owner_block_menu'); // Access permissions //elgg_register_plugin_hook_handler('access:collections:write', 'all', 'projects_write_acl_plugin_hook'); //elgg_register_plugin_hook_handler('access:collections:read', 'all', 'projects_read_acl_plugin_hook'); }
/** * Initializes config values on system init * @return void */ public function setLegacyConfig() { // legacy definitions define('HYPECATEGORIES_RELATIONSHIP', $this->get('relationship')); define('HYPECATEGORIES_SUBTYPE', $this->get('subtype')); define('HYPECATEGORIES_ENTITY_MENU', $this->get('entity_menu')); define('HYPECATEGORIES_GROUP_CATEGORIES', $this->get('group_categories')); define('HYPECATEGORIES_GROUP_TREE_SITE', $this->get('group_tree_site')); define('HYPECATEGORIES_INPUT_MULTIPLE', $this->get('input_multiple')); // legacy config values $pairs = $this->getEntityTypeSubtypePairs() ?: array(); $subtypes = array(); array_walk_recursive($pairs, function ($current) use(&$subtypes) { $subtypes[] = $current; }); elgg_set_config('taxonomy_types', array_keys($pairs)); elgg_set_config('taxonomy_subtypes', $subtypes); $tsp = array(); foreach ($pairs as $type => $subtypes) { if (empty($subtypes)) { $subtypes = array('default'); } foreach ($subtypes as $subtype) { $tsp[] = "{$type}:{$subtype}"; } } elgg_set_config('taxonomy_type_subtype_pairs', $tsp); elgg_set_config('taxonomy_tree_subtypes', array(Category::SUBTYPE)); }
function au_landing_page_update($event, $type, $object) { if (!elgg_instanceof($object, 'page') && elgg_instanceof($object, 'page_top')) { return true; } // only process this event once if (elgg_get_config('page_update_notify_sent_' . $object->guid)) { return true; } elgg_set_config('page_update_notify_sent_' . $object->guid, true); // get revision history for the page $revisions = $object->getAnnotations(array('annotation_name' => 'page', 'limit' => false)); // create an array of unique users to notify, excluding the current user // and the object owner (as core notifies them) $users = array(); foreach ($revisions as $revision) { if ($revision->owner_guid != $object->owner_guid && $revision->owner_guid != elgg_get_logged_in_user_guid()) { $users[] = $revision->owner_guid; } } $users = array_unique($users); // notify the users if (count($users)) { notify_user($users, elgg_get_logged_in_user_guid(), elgg_echo('au_landing:page:update:subject', array($object->title)), elgg_echo('au_landing:page:update:message', array($object->title, elgg_get_logged_in_user_entity()->name, $object->getURL()))); } }
function subsite_manager_plugins_boot() { // handle run once functions run_function_once("subsite_manager_runonce"); run_function_once("subsite_manager_runonce_elgg18"); // Check if current user should be a admin of this site if ($user = elgg_get_logged_in_user_entity()) { // don't check for super admins if (!subsite_manager_is_superadmin($user->getGUID())) { // where are we if (subsite_manager_on_subsite()) { // is the user suppose to be an admin if (elgg_get_site_entity()->isAdmin($user->getGUID())) { // is the user currently an admin if (!$user->isAdmin()) { $user->makeAdmin(); } } elseif ($user->isAdmin()) { // user is an admin, but shouldn't be $user->removeAdmin(); } } elseif ($user->isAdmin()) { // user is an admin, but shouldn't be $user->removeAdmin(); } } } // check the site email address $config_email = elgg_get_config("siteemail"); $site = elgg_get_site_entity(); if (empty($config_email) || $site->email != $config_email) { elgg_set_config("siteemail", $site->email); } }
/** * Initialize the plugin * @return void */ function ui_icons_init() { elgg_extend_view('elements/icons.css', 'elements/avatar.css'); elgg_register_simplecache_view('elements/avatar.sizes.css.php'); elgg_extend_view('elements/icons.css', 'elements/avatar.sizes.css'); elgg_set_config('icon_sizes', ui_icons_get_sizes()); elgg_register_plugin_hook_handler('entity:icon:url', 'all', 'ui_icons_default_icon', 900); }
function generateMultiSizesForType($type) { $config = 'myicon_' . $type; $icons = elgg_get_config($config); foreach ($icons as $icon) { generateMultiSizesForFile($type, $icon); } elgg_set_config('myicon_' . $type . '_processed', true); }
/** * Initialize the pages plugin. * */ function pages_init() { // register a library of helper functions elgg_register_library('elgg:pages', elgg_get_plugins_path() . 'pages/lib/pages.php'); $item = new ElggMenuItem('pages', elgg_echo('pages'), 'pages/all'); elgg_register_menu_item('site', $item); // Register a page handler, so we can have nice URLs elgg_register_page_handler('pages', 'pages_page_handler'); // Register a url handler elgg_register_entity_url_handler('object', 'page_top', 'pages_url'); elgg_register_entity_url_handler('object', 'page', 'pages_url'); elgg_register_annotation_url_handler('page', 'pages_revision_url'); // Register some actions $action_base = elgg_get_plugins_path() . 'pages/actions'; elgg_register_action("pages/edit", "{$action_base}/pages/edit.php"); elgg_register_action("pages/delete", "{$action_base}/pages/delete.php"); elgg_register_action("pages/checkout", "{$action_base}/pages/checkout.php"); elgg_register_action("pages/checkin", "{$action_base}/pages/checkin.php"); elgg_register_action("annotations/page/delete", "{$action_base}/annotations/page/delete.php"); // Extend the main css view elgg_extend_view('css/elgg', 'pages/css'); // Register javascript needed for sidebar menu $js_url = 'mod/pages/vendors/jquery-treeview/jquery.treeview.min.js'; elgg_register_js('jquery-treeview', $js_url); $css_url = 'mod/pages/vendors/jquery-treeview/jquery.treeview.css'; elgg_register_css('jquery-treeview', $css_url); // Register entity type for search elgg_register_entity_type('object', 'page'); elgg_register_entity_type('object', 'page_top'); // Register granular notification for this type //register_notification_object('object', 'page', elgg_echo('pages:new')); //register_notification_object('object', 'page_top', elgg_echo('pages:new')); //elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'page_notify_message'); // add to groups add_group_tool_option('pages', elgg_echo('groups:enablepages'), true); elgg_extend_view('groups/tool_latest', 'pages/group_module'); //add a widget elgg_register_widget_type('pages', elgg_echo('pages'), elgg_echo('pages:widget:description')); // Language short codes must be of the form "pages:key" // where key is the array key below elgg_set_config('pages', array('title' => 'text', 'description' => 'longtext', 'tags' => 'tags', 'parent_guid' => 'parent', 'access_id' => 'access', 'write_access_id' => 'write_access')); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'pages_owner_block_menu'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'pages_write_permission_check'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'pages_container_permission_check'); // icon url override elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'pages_icon_url_override'); // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'pages_entity_menu_setup'); // hook into annotation menu //elgg_register_plugin_hook_handler('register', 'menu:annotation', 'pages_annotation_menu_setup'); // register ecml views to parse elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook'); elgg_register_event_handler('upgrade', 'system', 'pages_run_upgrades'); }
/** * Initialize the pages plugin. * */ function pages_init() { // register a library of helper functions elgg_register_library('elgg:pages', __DIR__ . '/lib/pages.php'); $item = new ElggMenuItem('pages', elgg_echo('pages'), 'pages/all'); elgg_register_menu_item('site', $item); // Register a page handler, so we can have nice URLs elgg_register_page_handler('pages', 'pages_page_handler'); // Register a url handler elgg_register_plugin_hook_handler('entity:url', 'object', 'pages_set_url'); elgg_register_plugin_hook_handler('entity:url', 'object', 'pages_set_url'); elgg_register_plugin_hook_handler('extender:url', 'annotation', 'pages_set_revision_url'); // Register some actions $action_base = __DIR__ . '/actions'; elgg_register_action("pages/edit", "{$action_base}/pages/edit.php"); elgg_register_action("pages/delete", "{$action_base}/pages/delete.php"); elgg_register_action("annotations/page/delete", "{$action_base}/annotations/page/delete.php"); // Extend the main css view elgg_extend_view('elgg.css', 'pages/css'); elgg_define_js('jquery.treeview', array('src' => '/mod/pages/vendors/jquery-treeview/jquery.treeview.min.js', 'exports' => 'jQuery.fn.treeview', 'deps' => array('jquery'))); $css_url = 'mod/pages/vendors/jquery-treeview/jquery.treeview.css'; elgg_register_css('jquery.treeview', $css_url); // Register entity type for search elgg_register_entity_type('object', 'page'); elgg_register_entity_type('object', 'page_top'); // Register for notifications elgg_register_notification_event('object', 'page'); elgg_register_notification_event('object', 'page_top'); elgg_register_plugin_hook_handler('prepare', 'notification:create:object:page', 'pages_prepare_notification'); elgg_register_plugin_hook_handler('prepare', 'notification:create:object:page_top', 'pages_prepare_notification'); // add to groups add_group_tool_option('pages', elgg_echo('groups:enablepages'), true); elgg_extend_view('groups/tool_latest', 'pages/group_module'); //add a widget elgg_register_widget_type('pages', elgg_echo('pages'), elgg_echo('pages:widget:description')); // Language short codes must be of the form "pages:key" // where key is the array key below elgg_set_config('pages', array('title' => 'text', 'description' => 'longtext', 'tags' => 'tags', 'parent_guid' => 'parent', 'access_id' => 'access', 'write_access_id' => 'write_access')); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'pages_owner_block_menu'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'pages_write_permission_check'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'pages_container_permission_check'); elgg_register_plugin_hook_handler('access:collections:write', 'user', 'pages_write_access_options_hook'); // icon url override elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'pages_icon_url_override'); // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'pages_entity_menu_setup'); // register ecml views to parse elgg_register_plugin_hook_handler('get_views', 'ecml', 'pages_ecml_views_hook'); // allow to be liked elgg_register_plugin_hook_handler('likes:is_likable', 'object:page', 'Elgg\\Values::getTrue'); elgg_register_plugin_hook_handler('likes:is_likable', 'object:page_top', 'Elgg\\Values::getTrue'); // prevent public write access elgg_register_plugin_hook_handler('view_vars', 'input/access', 'pages_write_access_vars'); }
/** * Initialize the projects plugin. * */ function projects_init() { // register a library of helper functions elgg_register_library('elgg:projects', elgg_get_plugins_path() . 'projects/lib/projects.php'); elgg_load_library('elgg:projects'); //register css $css_url = 'mod/projects/css/styles.css'; elgg_register_css('projectsCss', $css_url); elgg_load_css('projectsCss'); // register an elgg menu item $item = new ElggMenuItem('projects', elgg_echo('projects'), 'projects/all'); //elgg_register_menu_item('site', $item); // register a project handler, so we can have nice URLs elgg_register_page_handler('projects', 'projects_page_handler'); // register a url handler elgg_register_entity_url_handler('object', 'project_top', 'projects_url'); elgg_register_entity_url_handler('object', 'project', 'projects_url'); elgg_register_annotation_url_handler('project', 'projects_revision_url'); // register entity type for search elgg_register_entity_type('object', 'project'); elgg_register_entity_type('object', 'project_top'); // register some actions $action_base = elgg_get_plugins_path() . 'projects/actions/projects'; $requests_action_base = elgg_get_plugins_path() . 'projects/actions/requests'; elgg_register_action("projects/edit", "{$action_base}/edit.php"); elgg_register_action("projects/editwelcome", "{$action_base}/editwelcome.php"); elgg_register_action("projects/delete", "{$action_base}/delete.php"); elgg_register_action("requests/add", "{$requests_action_base}/add.php"); elgg_register_action("requests/edit", "{$requests_action_base}/edit.php"); elgg_register_action("projects/helperFuncs", elgg_get_plugins_path() . 'lib/projects.php'); //elgg_register_action("projects/search", elgg_get_plugins_path() ."projects/pages/projects/search.php"); // register granular notification for this type register_notification_object('object', 'project', elgg_echo('projects:new')); register_notification_object('object', 'project_top', elgg_echo('projects:new')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'project_notify_message'); // add to groups add_group_tool_option('projects', elgg_echo('groups:enableprojects'), true); elgg_extend_view('groups/tool_latest', 'projects/group_module'); // Language short codes must be of the form "projects:key" // where key is the array key below elgg_set_config('projects', array('title' => 'text', 'description' => 'longtext', 'project_type' => 'dr_down', 'cost' => 'text', 'organization' => 'text', 'funding' => 'text', 'status' => 'dr_down', 'start_date' => 'date', 'end_date' => 'date', 'assigned_to[]' => 'assign_to', 'tags' => 'tags', 'access_id' => 'access', 'write_access_id' => 'write_access', 'upload' => 'file')); // register the hook handler elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'projects_owner_block_menu'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'projects_write_permission_check'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'projects_container_permission_check'); // icon url override elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'projects_icon_url_override'); // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'projects_entity_menu_setup'); // Access permissions //elgg_register_plugin_hook_handler('access:collections:write', 'all', 'projects_write_acl_plugin_hook'); //elgg_register_plugin_hook_handler('access:collections:read', 'all', 'projects_read_acl_plugin_hook'); }
/** * Add an annotation name to a list of valid rating names * * @param string $annotation_name */ function elgg_stars_register_rating_annotation_name($annotation_name) { $rating_annotation_names = elgg_get_config('elgg_stars_annotation_names'); if (!is_array($rating_annotation_names)) { $rating_annotation_names = array(); } if (!in_array($annotation_name, $rating_annotation_names)) { $rating_annotation_names[] = $annotation_name; } elgg_set_config('elgg_stars_annotation_names', $rating_annotation_names); }
function videolist_init() { elgg_register_library('elgg:videolist', elgg_get_plugins_path() . 'videolist/lib/videolist.php'); if (!class_exists('Videolist_PlatformInterface')) { // ./classes autoloading failed (pre 1.9) spl_autoload_register('videolist_load_class'); } // add a site navigation item $item = new ElggMenuItem('videolist', elgg_echo('videolist'), 'videolist/all'); elgg_register_menu_item('site', $item); // Extend system CSS with our own styles elgg_extend_view('css/elgg', 'videolist/css'); // register the js $js = elgg_get_simplecache_url('js', 'videolist/videolist'); elgg_register_simplecache_view('js/videolist/videolist'); elgg_register_js('elgg.videolist', $js); $js = elgg_get_simplecache_url('js', 'videolist/json2'); elgg_register_simplecache_view('js/videolist/json2'); elgg_register_js('elgg.videolist.json2', $js); // Register a page handler, so we can have nice URLs elgg_register_page_handler('videolist', 'videolist_page_handler'); // Language short codes must be of the form "videolist:key" // where key is the array key below elgg_set_config('videolist', array('video_url' => 'url', 'title' => 'text', 'description' => 'longtext', 'tags' => 'tags', 'access_id' => 'access')); elgg_set_config('videolist_dimensions', array('width' => 600, 'height' => 400)); // add to groups add_group_tool_option('videolist', elgg_echo('groups:enablevideolist'), true); elgg_extend_view('groups/tool_latest', 'videolist/group_module'); //add a widget elgg_register_widget_type('videolist', elgg_echo('videolist'), elgg_echo('videolist:widget:description')); // Register granular notification for this type register_notification_object('object', 'videolist_item', elgg_echo('videolist:notification:subject')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'videolist_notify_message'); // Register entity type for search elgg_register_entity_type('object', 'videolist_item'); // add a file link to owner blocks elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'videolist_owner_block_menu'); //register entity url handler elgg_register_entity_url_handler('object', 'videolist_item', 'videolist_url'); elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'videolist_icon_url_override'); // register for embed elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'videolist_embed_get_sections'); elgg_register_plugin_hook_handler('embed_get_items', 'videolist', 'videolist_embed_get_items'); // handle URLs without scheme elgg_register_plugin_hook_handler('videolist:preprocess', 'url', 'videolist_preprocess_url'); // Register actions $actions_path = elgg_get_plugins_path() . "videolist/actions/videolist"; elgg_register_action("videolist/add", "{$actions_path}/add.php"); elgg_register_action("videolist/edit", "{$actions_path}/edit.php"); elgg_register_action("videolist/delete", "{$actions_path}/delete.php"); elgg_register_action("videolist/get_metadata_from_url", "{$actions_path}/get_metadata_from_url.php"); elgg_register_event_handler('upgrade', 'system', 'videolist_run_upgrades'); }
/** * Init */ function registration_randomizer_init() { // Override registration page elgg_unregister_page_handler('register'); // serve registration pages elgg_register_page_handler('register', 'registration_randomizer_page_handler'); // check referrers elgg_register_plugin_hook_handler('action', 'register', 'registration_randomizer_referrer_check'); // replace view vars elgg_register_plugin_hook_handler('view', 'output/url', 'registration_randomizer_output_url'); elgg_set_config('rr_debug', false); }
/** * Initialize the tasks management plugin. * */ function tasks_init() { // register a library of helper functions elgg_register_library('elgg:tasks', elgg_get_plugins_path() . 'tasks/lib/tasks.php'); $item = new ElggMenuItem('tasks', elgg_echo('tasks'), 'tasks/all'); elgg_register_menu_item('site', $item); // Register a page handler, so we can have nice URLs elgg_register_page_handler('tasks', 'tasks_page_handler'); // Register a url handler elgg_register_entity_url_handler('object', 'task', 'tasks_url'); // Register some actions $action_base = elgg_get_plugins_path() . 'tasks/actions/tasks'; elgg_register_action("tasks/edit", "{$action_base}/edit.php"); elgg_register_action("tasks/delete", "{$action_base}/delete.php"); elgg_register_action("tasks/comments/add", "{$action_base}/comments/add.php"); elgg_register_action("tasks/comments/delete", "{$action_base}/comments/delete.php"); // Extend the main css and js views elgg_extend_view('css/elgg', 'tasks/css'); elgg_extend_view('js/elgg', 'tasks/js'); // register the blog's JavaScript elgg_register_simplecache_view('js/tasks/tasklists'); elgg_register_js('elgg.tasks', elgg_get_simplecache_url('js', 'tasks/tasklists')); elgg_register_ajax_view('object/task'); elgg_register_ajax_view('tasks/tasklist_graph'); // Register entity type for search elgg_register_entity_type('object', 'task'); // Register a different form for annotations elgg_register_plugin_hook_handler('comments', 'object', 'tasks_comments_hook'); // Register granular notification for this type register_notification_object('object', 'task', elgg_echo('tasks:new')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'tasks_notify_message'); // add to groups add_group_tool_option('tasks', elgg_echo('groups:enabletasks'), true); elgg_extend_view('groups/tool_latest', 'tasks/group_module'); //add a widget elgg_register_widget_type('tasks', elgg_echo('tasks:active'), elgg_echo('tasks:widget:description')); // Language short codes must be of the form "tasks:key" // where key is the array key below elgg_set_config('tasks', array('title' => 'text', 'description' => 'longtext', 'list_guid' => 'tasks/list', 'enddate' => 'date', 'priority' => 'tasks/priority', 'tags' => 'tags', 'access_id' => 'access')); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tasks_owner_block_menu'); elgg_register_event_handler('pagesetup', 'system', 'tasks_pagesetup'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'tasks_write_permission_check'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'tasks_container_permission_check'); // icon url override elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'tasks_icon_url_override'); // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'tasks_entity_menu_setup'); // register ecml views to parse elgg_register_plugin_hook_handler('get_views', 'ecml', 'tasks_ecml_views_hook'); elgg_register_plugin_hook_handler('format', 'friendly:time', 'tasks_get_friendly_time'); elgg_register_event_handler('upgrade', 'system', 'tasks_run_upgrades'); }
/** * Called during system init * * @return void */ function user_default_limit_init() { if (!elgg_is_logged_in()) { return; } elgg_extend_view('forms/account/settings', 'user_default_limit/settings'); elgg_register_plugin_hook_handler('usersettings:save', 'user', 'user_default_limit_settings_save'); $setting = sanitize_int(elgg_get_logged_in_user_entity()->getPrivateSetting('user_default_limit'), false); if (empty($setting)) { return; } elgg_set_config('default_limit', $setting); }
/** * Select the correct embed tab for display * * @param string $hook * @param string $type * @param array $items * @param array $vars */ function embed_select_tab($hook, $type, $items, $vars) { $tab_name = array_pop(explode('/', full_url())); foreach ($items as $item) { if ($item->getName() == $tab_name) { $item->setSelected(); elgg_set_config('embed_tab', $item); } } if (!elgg_get_config('embed_tab') && count($items) > 0) { $items[0]->setSelected(); elgg_set_config('embed_tab', $items[0]); } }
/** * Called on shutdown event after vroom has flushed to browser * used for background processes * @return void */ function vroom_functions() { elgg_set_config('shutdown_initiated', 1); $vroom_functions = elgg_get_config('event_vroom_functions'); if ($vroom_functions && is_array($vroom_functions)) { foreach ($vroom_functions as $params) { foreach ($params as $function => $args) { if (is_callable($function)) { call_user_func_array($function, $args); } } } } }
/** * Initialize elgg-markdown_wiki plugin. */ function markdown_wiki_init() { // register libraries of helper functions $root = dirname(__FILE__); elgg_register_library('markdown_wiki:utilities', "{$root}/lib/utilities.php"); elgg_register_library('markdown_wiki:fineDiff', "{$root}/vendors/PHP-FineDiff/finediff.php"); // js and css elgg_register_js('showdown', "/mod/elgg-markdown_wiki/vendors/showdown/compressed/showdown.js"); elgg_register_js('showdownggouv', "/mod/elgg-markdown_wiki/vendors/showdown/compressed/extensions/showdownggouv.js"); elgg_load_js('showdown'); elgg_load_js('showdownggouv'); elgg_register_js('highlight', "/mod/elgg-markdown_wiki/vendors/highlight/highlight.pack.js", 'footer', 100); elgg_load_js('highlight'); elgg_extend_view('js/elgg', 'markdown_wiki/js'); elgg_extend_view('js/elgg', 'markdown_wiki/editor_js'); elgg_extend_view('css/elgg', 'markdown_wiki/css'); elgg_extend_view('css/elgg', 'markdown_wiki/markdown_css'); elgg_extend_view('css/elgg', 'markdown_wiki/highlight_css'); elgg_extend_view('page/elements/foot', 'markdown_wiki/syntax/language_selector'); // Add a menu item to the main site menu $item = new ElggMenuItem('markdown_wiki_all', elgg_echo('markdown_wiki'), 'wiki/all'); elgg_register_menu_item('site', $item); // entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'markdown_wiki_object_menu'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'markdown_wiki_write_permission_check'); // Register a page handler, so we can have nice URLs elgg_register_page_handler('wiki', 'markdown_wiki_page_handler'); // Register entity type for search elgg_register_entity_type('object', 'markdown_wiki'); // Register a url handler elgg_register_entity_url_handler('object', 'markdown_wiki', 'markdown_wiki_url'); // Register a script to handle (usually) a POST request (an action) $base_dir = "{$root}/actions/markdown_wiki"; elgg_register_action('markdown_wiki/edit', "{$base_dir}/edit.php"); elgg_register_action('markdown_wiki/compare', "{$root}/pages/markdown_wiki/compare.php"); elgg_register_action('markdown_wiki/settings', "{$base_dir}/settings.php"); // add to groups add_group_tool_option('markdown_wiki', elgg_echo('groups:enable_markdown_wiki'), true); elgg_extend_view('groups/tool_latest', 'markdown_wiki/group_module'); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'markdown_wiki_owner_block_menu'); //add a widget elgg_register_widget_type('markdown_wiki', elgg_echo('markdown_wiki'), elgg_echo('markdown_wiki:widget:description')); // Language short codes must be of the form "markdown_wiki:key" // where key is the array key below elgg_set_config('markdown_wiki', array('description' => 'markdown', 'summary' => 'text', 'tags' => 'tags', 'write_access_id' => 'access', 'title' => 'hidden', 'guid' => 'hidden', 'container_guid' => 'hidden')); // Parse link elgg_register_plugin_hook_handler('format_markdown', 'format', 'markdown_wiki_parse_link_plugin_hook', 600); }
/** * This function loads a set of default fields into the profile, then triggers * a hook letting other plugins to edit add and delete fields. * * Note: This is a system:init event triggered function and is run at a super * low priority to guarantee that it is called after all other plugins have * initialized. */ function groups_fields_setup() { $profile_defaults = array('description' => 'longtext', 'briefdescription' => 'text', 'interests' => 'tags'); $profile_defaults = elgg_trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults); elgg_set_config('group', $profile_defaults); // register any tag metadata names foreach ($profile_defaults as $name => $type) { if ($type == 'tags') { elgg_register_tag_metadata_name($name); // only shows up in search but why not just set this in en.php as doing it here // means you cannot override it in a plugin add_translation(get_current_language(), array("tag_names:{$name}" => elgg_echo("groups:{$name}"))); } } }
/** * Select the correct embed tab for display * * @param string $hook * @param string $type * @param array $items * @param array $vars */ function embed_select_tab($hook, $type, $items, $vars) { // can this ba called from page handler instead? $page = get_input('page'); $tab_name = array_pop(explode('/', $page)); foreach ($items as $item) { if ($item->getName() == $tab_name) { $item->setSelected(); elgg_set_config('embed_tab', $item); } } if (!elgg_get_config('embed_tab') && count($items) > 0) { $items[0]->setSelected(); elgg_set_config('embed_tab', $items[0]); } }
function developers_process_settings() { $settings = elgg_get_plugin_from_id('developers')->getAllSettings(); ini_set('display_errors', (int) (!empty($settings['display_errors']))); if (!empty($settings['screen_log'])) { // don't show in action/simplecache $path = substr(current_page_url(), strlen(elgg_get_site_url())); if (!preg_match('~^(cache|action)/~', $path)) { $cache = new ElggLogCache(); elgg_set_config('log_cache', $cache); elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) { $vars['body'] .= elgg_view('developers/log'); return $vars; }); } } if (!empty($settings['show_strings'])) { // Beginning and end to make sure both early-rendered and late-loaded translations get included elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1); elgg_register_event_handler('init', 'system', 'developers_decorate_all_translations', 1000); } if (!empty($settings['show_modules'])) { elgg_require_js('elgg/dev/amd_monitor'); } if (!empty($settings['wrap_views'])) { elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600); } if (!empty($settings['log_events'])) { elgg_register_event_handler('all', 'all', 'developers_log_events', 1); elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) { elgg_require_js('elgg/dev/gear'); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_register_ajax_view('developers/gear_popup'); elgg_register_simplecache_view('elgg/dev/gear.html'); // TODO use ::class in 2.0 $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars']; elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler); $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections']; elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler); } }
/** * amapnews plugin initialization functions. */ function amapnews_init() { // register a library of helper functions elgg_register_library('elgg:amapnews', elgg_get_plugins_path() . 'amapnews/lib/amapnews.php'); // register extra css elgg_extend_view('elgg.css', 'amapnews/amapnews.css'); // Register entity_type for search elgg_register_entity_type('object', Amapnews::SUBTYPE); // Site navigation $item = new ElggMenuItem('amapnews', elgg_echo('amapnews:menu'), 'news'); elgg_register_menu_item('site', $item); // add option to all site entities for adding to news elgg_register_plugin_hook_handler('register', 'menu:entity', 'amapnews_entity_menu_setup', 400); // add option for admin to add/remove user from news-staff elgg_register_plugin_hook_handler("register", "menu:user_hover", "news_staff_user_hover_menu_hook"); // Register menu item to an ownerblock. It is used to register news menu item to groups elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'amapnews_owner_block_menu'); // allow to be liked elgg_register_plugin_hook_handler('likes:is_likable', 'object:amapnews', 'Elgg\\Values::getTrue'); // Register a URL handler for news elgg_register_plugin_hook_handler('entity:url', 'object', 'amapnews_set_url'); // We don't want people commenting on news posts in the river elgg_register_plugin_hook_handler('permissions_check:comment', 'object', 'amapnews_comment_override'); // Register a page handler, so we can have nice URLs elgg_register_page_handler('news', 'amapnews_page_handler'); elgg_register_page_handler('amapnews', 'amapnews_page_handler'); // extend group main page elgg_extend_view('groups/tool_latest', 'amapnews/group_module'); // add the group news tool option add_group_tool_option('amapnews', elgg_echo('amapnews:group:enable'), true); // loads the widgets amapnews_widgets_init(); // set photo sizes for news posts elgg_set_config('amapnews_photo_sizes', array('tiny' => array('w' => 25, 'h' => 25, 'square' => TRUE, 'upscale' => FALSE), 'small' => array('w' => 40, 'h' => 40, 'square' => TRUE, 'upscale' => FALSE), 'medium' => array('w' => 100, 'h' => 100, 'square' => TRUE, 'upscale' => FALSE), 'large' => array('w' => 150, 'h' => 150, 'square' => TRUE, 'upscale' => FALSE), 'master' => array('w' => 215, 'h' => 215, 'square' => TRUE, 'upscale' => FALSE), 'default' => array('w' => 1200, 'h' => 1200, 'square' => FALSE, 'upscale' => FALSE))); // Register actions $action_path = elgg_get_plugins_path() . 'amapnews/actions/amapnews'; elgg_register_action('amapnews/add', "{$action_path}/add.php"); elgg_register_action('amapnews/delete', "{$action_path}/delete.php"); elgg_register_action('amapnews/staff', "{$action_path}/staff.php", "admin"); elgg_register_action('amapnews/set_featured', "{$action_path}/set_featured.php", "admin"); }
function videolist_init() { elgg_register_library('elgg:videolist', elgg_get_plugins_path() . 'videolist/lib/videolist.php'); // add a site navigation item $item = new ElggMenuItem('videolist', elgg_echo('videolist'), 'videolist/all'); elgg_register_menu_item('site', $item); // Extend system CSS with our own styles elgg_extend_view('css/elgg', 'videolist/css'); // Register a page handler, so we can have nice URLs elgg_register_page_handler('videolist', 'videolist_page_handler'); // Language short codes must be of the form "videolist:key" // where key is the array key below elgg_set_config('videolist', array('video_url' => 'url', 'title' => 'text', 'description' => 'longtext', 'tags' => 'tags', 'access_id' => 'access')); // add to groups add_group_tool_option('videolist', elgg_echo('groups:enablevideolist'), true); elgg_extend_view('groups/tool_latest', 'videolist/group_module'); //add a widget elgg_register_widget_type('videolist', elgg_echo('videolist'), elgg_echo('videolist:widget:description')); // Register granular notification for this type register_notification_object('object', 'videolist_item', elgg_echo('videolist:new')); // Register entity type for search elgg_register_entity_type('object', 'videolist_item'); // add a file link to owner blocks elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'videolist_owner_block_menu'); elgg_register_event_handler('annotate', 'all', 'videolist_object_notifications'); elgg_register_plugin_hook_handler('object:notifications', 'object', 'videolist_object_notifications_intercept'); //register entity url handler elgg_register_entity_url_handler('object', 'videolist_item', 'videolist_url'); elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'videolist_icon_url_override'); // register for embed elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'videolist_embed_get_sections'); elgg_register_plugin_hook_handler('embed_get_items', 'videolist', 'videolist_embed_get_items'); // handle URLs without scheme elgg_register_plugin_hook_handler('videolist:preprocess', 'url', 'videolist_preprocess_url'); // Register actions $actions_path = elgg_get_plugins_path() . "videolist/actions/videolist"; elgg_register_action("videolist/add", "{$actions_path}/add.php"); elgg_register_action("videolist/edit", "{$actions_path}/edit.php"); elgg_register_action("videolist/delete", "{$actions_path}/delete.php"); elgg_register_event_handler('upgrade', 'system', 'videolist_run_upgrades'); }
function developers_process_settings() { $settings = elgg_get_plugin_from_id('developers')->getAllSettings(); ini_set('display_errors', (int) (!empty($settings['display_errors']))); if (!empty($settings['screen_log'])) { $cache = new ElggLogCache(); elgg_set_config('log_cache', $cache); elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump')); elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function ($hook, $type, $vars, $params) { $vars['body'] .= elgg_view('developers/log'); return $vars; }); } if (!empty($settings['show_strings'])) { // first and last in case a plugin registers a translation in an init method elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1000); elgg_register_event_handler('init', 'system', 'developers_clear_strings', 1); } if (!empty($settings['show_modules'])) { elgg_require_js('elgg/dev/amd_monitor'); } if (!empty($settings['wrap_views'])) { elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views', 600); } if (!empty($settings['log_events'])) { elgg_register_event_handler('all', 'all', 'developers_log_events', 1); elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } if (!empty($settings['show_gear']) && elgg_is_admin_logged_in() && !elgg_in_context('admin')) { elgg_require_js('elgg/dev/gear'); elgg_load_js('lightbox'); elgg_load_css('lightbox'); elgg_register_ajax_view('developers/gear_popup'); elgg_register_simplecache_view('elgg/dev/gear.html'); // TODO use ::class in 2.0 $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSectionVars']; elgg_register_plugin_hook_handler('view_vars', 'navigation/menu/elements/section', $handler); $handler = ['Elgg\\DevelopersPlugin\\Hooks', 'alterMenuSections']; elgg_register_plugin_hook_handler('view', 'navigation/menu/elements/section', $handler); } }
/** * Embed filter tabs * * @param string $hook Equals 'register' * @param string $type Equals 'menu:embed' * @param array $menu Current menu * @param array $params Additional params * @return array Updated menu */ function embed_filter_menu_setup($hook, $type, $menu, $params) { $selected_tab = elgg_get_config('embed_tab_context'); if (elgg_is_active_plugin('file')) { $menu[] = \ElggMenuItem::factory(array('name' => 'file', 'text' => elgg_echo('embed:file'), 'href' => 'embed/tab/file', 'class' => 'embed-section embed-section-file', 'priority' => 1)); $menu[] = \ElggMenuItem::factory(array('name' => 'file_upload', 'text' => elgg_echo('embed:file:upload'), 'href' => 'embed/tab/file_upload', 'class' => 'embed-section embed-section-file-upload', 'priority' => 200)); } $menu[] = \ElggMenuItem::factory(array('name' => 'content_items', 'text' => elgg_echo('embed:content_items'), 'href' => 'embed/tab/content_items', 'class' => 'embed-section embed-section-content-items', 'priority' => 300)); $menu[] = \ElggMenuItem::factory(array('name' => 'embed_src', 'text' => elgg_echo('embed:embed_src'), 'href' => 'embed/tab/embed_src', 'class' => 'embed-section embed-section-embed-src', 'priority' => 400)); foreach ($menu as $key => $item) { if ($item instanceof \ElggMenuItem) { if ($item->getName() == $selected_tab) { elgg_set_config('embed_tab', $item); $item->setSelected(true); } } else { unset($menu[$key]); } } return $menu; }
/** * Initialize the plugin. * */ function changeRequestsInit() { // register a library of helper functions elgg_register_library('elgg:changeReqs', elgg_get_plugins_path() . 'projects/lib/changeReqs.php'); elgg_load_library('elgg:changeReqs'); // register a project handler, so we can have nice URLs elgg_register_page_handler('changeReqs', 'changeReqs_page_handler'); // register some actions $requests_action_base = elgg_get_plugins_path() . 'projects/actions/requests'; elgg_register_action("requests/add", "{$requests_action_base}/add.php"); elgg_register_action("requests/edit", "{$requests_action_base}/edit.php"); // add to groups add_group_tool_option('projects', elgg_echo('changeReqs:enableGroupTool'), true); //elgg_extend_view('groups/tool_latest', 'projects/group_module'); // Language short codes must be of the form "projects:key" // where key is the array key below elgg_set_config('changeReqs', array('title' => 'text', 'description' => 'longtext', 'project_type' => 'dr_down', 'cost' => 'text', 'organization' => 'text', 'funding' => 'text', 'status' => 'dr_down', 'start_date' => 'date', 'end_date' => 'date', 'assigned_to[]' => 'assign_to', 'tags' => 'tags', 'access_id' => 'access', 'write_access_id' => 'write_access', 'upload' => 'file')); // write permission plugin hooks // Access permissions //elgg_register_plugin_hook_handler('access:collections:write', 'all', 'projects_write_acl_plugin_hook'); //elgg_register_plugin_hook_handler('access:collections:read', 'all', 'projects_read_acl_plugin_hook'); }
function etherpad_init() { // override pages library // elgg_register_library('elgg:pages', elgg_get_plugins_path() . 'etherpad/lib/pages.php'); $actions_base = elgg_get_plugins_path() . 'etherpad/actions/etherpad'; elgg_register_action("etherpad/save", "{$actions_base}/save.php"); elgg_register_action("etherpad/delete", "{$actions_base}/delete.php"); // elgg_register_page_handler('pages', 'etherpad_page_handler'); elgg_register_page_handler('etherpad', 'etherpad_page_handler'); // Language short codes must be of the form "etherpad:key" // where key is the array key below elgg_set_config('etherpad', array('title' => 'text', 'tags' => 'tags', 'access_id' => 'access', 'write_access_id' => 'write_access')); elgg_register_plugin_hook_handler('register', 'menu:entity', 'etherpad_entity_menu'); elgg_register_entity_type('object', 'etherpad', 'ElggPad'); // elgg_register_entity_type('object', 'subpad', 'ElggPad'); // write permission plugin hooks elgg_register_plugin_hook_handler('permissions_check', 'object', 'etherpad_write_permission_check'); elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'etherpad_container_permission_check'); //Widget elgg_register_widget_type('etherpad', elgg_echo('etherpad'), elgg_echo('etherpad:profile:widgetdesc'), "profile,dashboard,groups,index"); elgg_register_plugin_hook_handler('widget_url', 'widget_manager', 'etherpad_widget_url_hook'); // icon url override elgg_register_plugin_hook_handler('entity:icon:url', 'object', 'etherpad_icon_url_override'); if (elgg_get_plugin_setting('integrate_in_pages', 'etherpad') != 'yes') { $item = new ElggMenuItem('etherpad', elgg_echo('etherpad'), 'etherpad/all'); elgg_register_menu_item('site', $item); elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'etherpad_owner_block_menu'); // add to groups add_group_tool_option('etherpad', elgg_echo('groups:enablepads'), true); elgg_extend_view('groups/tool_latest', 'etherpad/group_module'); // Register a URL handler for bookmarks elgg_register_entity_url_handler('object', 'etherpad', 'etherpad_url'); elgg_register_entity_url_handler('object', 'subpad', 'etherpad_url'); } else { // Register a URL handler for bookmarks elgg_register_entity_url_handler('object', 'etherpad', 'pages_url'); elgg_register_entity_url_handler('object', 'subpad', 'pages_url'); } }