wwwroot . "pg/tools"); // Registering custom tool_url to override getURL register_entity_url_handler('tool_url', 'object', 'tool'); // Registering tool type register_entity_type('object', 'tool'); // Registering handler to make redirections register_page_handler('tools', 'tools_handler'); // Registering css extension extend_view('css','tools/css'); // register custom permissions hook register_plugin_hook('permissions_check','object','tools_can_edit'); /*translation:Latest tools*/ add_widget_type('latest_tools', elgg_echo("koolielu:heading_latest_tools"), /*translation:Displays portal latest tools*/ elgg_echo("koolielu:widget:latest_tools:expl")); } function tools_pages() { global $CONFIG; if (get_context() == "tools") { if (isEditor() || isToolsModerator()) { /*translation:Add new tool*/ add_submenu_item(elgg_echo('koolielu:submenu_item_addtool'), $CONFIG->wwwroot . "pg/tools/add.php"); } /*translation:All tools*/ add_submenu_item(elgg_echo('koolielu:submenu_item_alltools'), $CONFIG->wwwroot . "pg/tools/all"); } } function tool_url($tool) { global $CONFIG; return $CONFIG->url . "pg/tools/read/" . $tool->getGUID(); } function tools_handler($page) { global $CONFIG; switch ($page[0]) { case "add.php": include($CONFIG->pluginspath . "tools/add.php"); break; case "read": set_input('toolid', $page[1]); include($CONFIG->pluginspath . "tools/read.php"); break; case "all": set_input('show_all', true); include($CONFIG->pluginspath . "tools/index.php"); break; default: include($CONFIG->pluginspath . "tools/index.php"); break; } return true; } // Permissions hook function tools_can_edit($hook_name, $entity_type, $return_value, $parameters) { $entity = $parameters['entity']; if ($entity->getSubtype() == 'tool' && (isEditor() || isToolsModerator())) { return true; } return null;//TODO Look through all the methods, this does not look like it's needed. Do a clean-up. } global $CONFIG; register_elgg_event_handler('init', 'system', 'tools_init'); register_elgg_event_handler('pagesetup', 'system', 'tools_pages'); register_action("tools/add", false, $CONFIG->pluginspath . "tools/actions/add.php"); register_action("tools/edit", false, $CONFIG->pluginspath . "tools/actions/edit.php"); register_action("tools/delete", false, $CONFIG->pluginspath . "tools/actions/delete.php"); register_action("tools/make_revert_featured", false, $CONFIG->pluginspath . "tools/actions/make_revert_featured.php"); ?>