/** * Check the current plugin release and load $plugin_id/lib/upgrade.php script if the release is newer * * @param str $plugin_id Plugin Name * @param str $release Release timestamp */ function hj_framework_check_release($plugin_id, $release) { if (!elgg_is_admin_logged_in()) { return false; } $old_release = elgg_get_plugin_setting('release', $plugin_id); if ($release > $old_release) { $shortcuts = hj_framework_path_shortcuts($plugin_id); $lib = "{$shortcuts['lib']}upgrade.php"; elgg_register_library("hj:{$plugin_id}:upgrade", $lib); elgg_load_library("hj:{$plugin_id}:upgrade"); elgg_set_plugin_setting('release', $release, $plugin_id); } return true; }
function hj_forum_init() { $plugin = 'hypeForum'; // Make sure hypeFramework is active and precedes hypeForum in the plugin list if (!is_callable('hj_framework_path_shortcuts')) { register_error(elgg_echo('framework:error:plugin_order', array($plugin))); disable_plugin($plugin); forward('admin/plugins'); } // Run upgrade scripts hj_framework_check_release($plugin, HYPEFORUM_RELEASE); $shortcuts = hj_framework_path_shortcuts($plugin); // Helper Classes elgg_register_classes($shortcuts['classes']); // Libraries $libraries = array('base', 'forms', 'page_handlers', 'actions', 'assets', 'views', 'menus', 'hooks'); foreach ($libraries as $lib) { $path = "{$shortcuts['lib']}{$lib}.php"; if (file_exists($path)) { elgg_register_library("forum:library:{$lib}", $path); elgg_load_library("forum:library:{$lib}"); } } // Search elgg_register_entity_type('object', 'hjforum'); elgg_register_entity_type('object', 'hjforumtopic'); elgg_register_entity_type('object', 'hjforumpost'); if (HYPEFORUM_GROUP_FORUMS) { // Add group option add_group_tool_option('forums', elgg_echo('hj:forum:groupoption:enableforum'), true); elgg_extend_view('groups/tool_latest', 'framework/forum/group_module'); } // Notification register_notification_object('object', 'hjforumtopic', elgg_echo('hj:forum:newforumtopic')); register_notification_object('object', 'hjforumpost', elgg_echo('hj:forum:newforumpost')); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'hj_forum_notify_message'); elgg_register_plugin_hook_handler("register", "menu:forums_sidebar_tree", "forums_sidebar_tree_hook"); }
/** * Forum page handler */ function hj_forum_page_handler($page, $handler) { $plugin = 'hypeForum'; $shortcuts = hj_framework_path_shortcuts($plugin); $pages = $shortcuts['pages'] . 'forum/'; elgg_load_css('forum.base.css'); elgg_load_js('forum.base.js'); elgg_push_breadcrumb(elgg_echo('forums'), 'forum/dashboard/site'); switch ($page[0]) { default: case 'dashboard': $dashboard = elgg_extract(1, $page, 'site'); set_input('dashboard', $dashboard); switch ($dashboard) { default: case 'site': include "{$pages}dashboard/site.php"; break; case 'groups': gatekeeper(); include "{$pages}dashboard/groups.php"; break; case 'bookmarks': gatekeeper(); include "{$pages}dashboard/bookmarks.php"; break; case 'subscriptions': gatekeeper(); include "{$pages}dashboard/subscriptions.php"; break; } break; case 'group': $group_guid = elgg_extract(1, $page, false); if (!$group_guid) { return false; } $group = get_entity($group_guid); if (!elgg_instanceof($group, 'group')) { return false; } elgg_set_page_owner_guid($group->guid); include "{$pages}dashboard/group.php"; break; case 'create': gatekeeper(); list($action, $subtype, $container_guid) = $page; if (!$subtype) { return false; } if (!$container_guid) { $site = elgg_get_site_entity(); $container_guid = $site->guid; } elgg_set_page_owner_guid($container_guid); set_input('container_guid', $container_guid); $include = "{$pages}create/{$subtype}.php"; if (!file_exists($include)) { return false; } include $include; break; case 'edit': gatekeeper(); list($action, $guid) = $page; set_input('guid', $guid); $include = "{$pages}edit/object.php"; if (!file_exists($include)) { return false; } include $include; break; case 'view': if (!isset($page[1])) { return false; } $entity = get_entity($page[1]); if (!$entity) { return false; } if (elgg_instanceof($entity, 'object', 'hjforum')) { $sidebar = elgg_view('framework/forum/dashboard/sidebar'); } echo elgg_view_page($entity->title, elgg_view_layout('framework/entity', array('entity' => $entity, 'sidebar' => $sidebar))); break; } return true; }
function hj_framework_legacy_page_handlers($page) { $plugin = 'hypeFrameworkLegacy'; $shortcuts = hj_framework_path_shortcuts($plugin); $pages = dirname(dirname(dirname(__FILE__))) . '/pages/'; if (!isset($page[0])) { forward(); } switch ($page[0]) { case 'file': if (!isset($page[1])) { forward(); } switch ($page[1]) { case 'download': set_input('e', $page[2]); include $pages . 'file/download.php'; break; default: forward(); break; } case 'print': include $pages . 'print/print.php'; break; case 'pdf': include $pages . 'print/pdf.php'; break; case 'icon': set_input('guid', $page[1]); set_input('size', $page[2]); include "{$pages}icon/icon.php"; break; case 'sync': switch ($page[1]) { default: include "{$pages}sync/sync.php"; break; case 'priority': include "{$pages}sync/sync_priority.php"; break; case 'metadata': include "{$pages}sync/sync_metadata.php"; break; case 'relationship': include "{$pages}sync/sync_relationship.php"; break; } break; case 'multifile': session_id(get_input('Elgg')); global $_SESSION; $_SESSION = json_decode(get_input('SESSION'), true); hj_framework_handle_multifile_upload(get_input('userid')); break; default: return false; break; } return true; }
<?php $shortcuts = hj_framework_path_shortcuts('hypeForum'); // Actions elgg_register_action('edit/object/hjforum', $shortcuts['actions'] . 'edit/object/hjforum.php'); elgg_register_action('edit/object/hjforumtopic', $shortcuts['actions'] . 'edit/object/hjforumtopic.php'); elgg_register_action('edit/object/hjforumpost', $shortcuts['actions'] . 'edit/object/hjforumpost.php'); elgg_register_action('edit/object/hjforumcategory', $shortcuts['actions'] . 'edit/object/hjforumcategory.php'); elgg_register_action('forum/order/categories', $shortcuts['actions'] . 'order/categories.php'); elgg_register_action('forum/bookmark', $shortcuts['actions'] . 'forum/bookmark/default.php'); elgg_register_action('forum/bookmark/create', $shortcuts['actions'] . 'forum/bookmark/create.php'); elgg_register_action('forum/bookmark/remove', $shortcuts['actions'] . 'forum/bookmark/remove.php'); elgg_register_action('forum/subscription', $shortcuts['actions'] . 'forum/subscription/default.php'); elgg_register_action('forum/subscription/create', $shortcuts['actions'] . 'forum/subscription/create.php'); elgg_register_action('forum/subscription/remove', $shortcuts['actions'] . 'forum/subscription/remove.php');
<?php $shortcuts = hj_framework_path_shortcuts('hypeFramework'); $path_actions = $shortcuts['actions']; elgg_register_action('framework/edit/object', $path_actions . 'framework/edit/object.php'); elgg_register_action('framework/delete/object', $path_actions . 'framework/delete/object.php'); elgg_register_action('framework/access/set', $path_actions . 'framework/access/set.php'); elgg_register_action('framework/bookmark', $path_actions . 'framework/bookmark/default.php'); elgg_register_action('framework/bookmark/create', $path_actions . 'framework/bookmark/create.php'); elgg_register_action('framework/bookmark/remove', $path_actions . 'framework/bookmark/remove.php'); elgg_register_action('framework/subscription', $path_actions . 'framework/subscription/default.php'); elgg_register_action('framework/subscription/create', $path_actions . 'framework/subscription/create.php'); elgg_register_action('framework/subscription/remove', $path_actions . 'framework/subscription/remove.php'); elgg_register_action('framework/file/temp', $path_actions . 'framework/file/temp.php'); elgg_register_action('edit/object/hjfile', $path_actions . 'framework/edit/object/hjfile.php'); function hj_framework_edit_object_action() { $form_name = get_input('form_name', false); elgg_make_sticky_form($form_name); if (!hj_framework_validate_form($form_name)) { return false; } $guid = get_input('guid', ELGG_ENTITIES_ANY_VALUE); $event = $guid ? 'edit' : 'create'; $type = get_input('type'); $subtype = get_input('subtype'); $class = get_subtype_class($type, $subtype); //get the attachments $attachments = $_FILES['attachments']; if ($class) { $entity = new $class($guid);