pluginspath . "koolielu/actions/delete_category.php", true); register_action("koolielu/manage_roles",false, $CONFIG->pluginspath . "koolielu/actions/manage_roles.php", true); register_action("koolielu/edit_poll", false, $CONFIG->pluginspath . "koolielu/actions/edit_poll.php", true); register_action("koolielu/upload_logo", false, $CONFIG->pluginspath . "koolielu/actions/upload_logo.php", true); // Register comments hook register_plugin_hook('comments', 'all', 'ke_comments_hook', 1000); // XXX Enable at the beginning and eneter any page once. Disable afterwards. // Create custom databases used by Koolielu plugin set //install_custom_databases(); // Create custom data storage //preset_koolielu_storage_folders(); // temporarly for setting archive to 0 //update_ads_and_news(); // Add widgets add_widget_type('ke_groups_activity_widget', /*translation:Groups' activity*/ elgg_echo('koolielu:river:widget:title:groups:activity'), /*translation:Shows latest activity in your groups.*/ elgg_echo('koolielu:river:widget:description:groups:activity') ); add_widget_type('ke_tools_widget', /*translation:Elgg tools*/ elgg_echo('koolielu:elgg_tools'), /*translation:Elgg tools*/ elgg_echo('koolielu:widget:description:elgg_tools') ); add_widget_type('ke_my_calendar_widget', /*translation:My calendar*/ elgg_echo('koolielu:widget:title:my:calendar'), /*translation:Shows configurable small calendar view.*/ elgg_echo('koolielu:widget:description:my:calendar') ); // TODO Enable this when SSO is done //add_widget_type('ke_sso_widget', /*translation:Single Sign-On*/ // elgg_echo('koolielu:widget:title:sso'), /*translation:Lets you configure SSO possibility with Havike and its services.*/ // elgg_echo('koolielu:widget:description:sso') //); add_widget_type('ke_my_subjects_widget', /*translation:My subjects*/ elgg_echo('koolielu:widget:title:my:subjects'), /*translation:Displays all your subjects that have been selected in profile. Every subject is a link to a subject page.*/ elgg_echo('koolielu:widget:description:my:subjects') ); // Only allow this widget if blog plugin is enabled if (is_plugin_enabled('blog')) { add_widget_type('ke_blog_widget', /*translation:My latest blog posts*/ elgg_echo('koolielu:widget:title:my:latest:blog:posts'), /*translation:Displays a number of your latest blog posts.*/ elgg_echo('koolielu:widget:description:my:latest:blog:posts') ); } // Crowdsound plugin, only works if ke_crowdsound setting is provided if (get_plugin_setting('ke_crowdsound', 'koolielu')) { add_widget_type('ke_crowdsound_widget', /*translation:Feedback widget*/ elgg_echo('koolielu:widget:title:crowdsound'), /*translation:This widget can be used for giving feedback to portal developers.*/ elgg_echo('koolielu:widget:description:crowdsound') ); } // Overrides for profile register_page_handler("defaultprofile", "ke_profileedit_page_handler"); // View location overrides set_view_location("widgets/tagcloud/view", $CONFIG->path . "mod/koolielu/views/"); set_view_location("input/longtext", $CONFIG->path . "mod/koolielu/views/"); set_view_location("annotation/annotate", $CONFIG->path . "mod/koolielu/views/"); // Override blog edit form set_view_location("blog/forms/edit", $CONFIG->path . "mod/koolielu/views/"); // reCaptcha usage part // Override registration form set_view_location('accounts/forms/register', $CONFIG->path . 'mod/koolielu/views/'); // Override registration action register_action('register', true, $CONFIG->pluginspath . 'koolielu/actions/recaptcha_register.php'); // Unregister captcha hook if (function_exists('koolielu_unregister_plugin_hook')) koolielu_unregister_plugin_hook('action', 'register', 'captcha_verify_action_hook'); } function koolielu_index() { if (!@include_once(dirname(dirname(__FILE__))) . "/koolielu/index.php") return false; return true; } function koolielu_pagesetup() { global $CONFIG; if (get_context() == 'admin' && isadminloggedin()) { /*translation:Koolielu management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_koolielu'), $CONFIG->wwwroot . 'pg/koolielu/mainmanage'); /*translation:Categories management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_categories'), $CONFIG->wwwroot . 'pg/koolielu/categories'); /*translation:Curriculum management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_curriculum'), $CONFIG->wwwroot . 'pg/koolielu/curriculum'); /*translation:Quality marks management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_quality_marks'), $CONFIG->wwwroot . 'pg/koolielu/quality_marks'); /*translation:Polls management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_polls'), $CONFIG->wwwroot . 'pg/koolielu/polls_management'); /*translation:Logos management*/ add_submenu_item(elgg_echo('koolielu:submenu_item_logos'), $CONFIG->wwwroot . 'pg/koolielu/logos'); /*translation:Koolielu statistics*/ add_submenu_item(elgg_echo('koolielu:submenu_item_statistics'), $CONFIG->wwwroot . 'pg/koolielu/statistics'); /*translation:Certificates*/ add_submenu_item(elgg_echo('koolielu:submenu_item_certificates'), $CONFIG->wwwroot . 'pg/koolielu/certificates'); } // Friends menu addition if ((get_context() == "friends" || get_context() == "friendsof" || get_context() == "collections") && isloggedin()) { /*translation:Find friends*/ add_submenu_item(elgg_echo('koolielu:submenu_item_find_friends'),$CONFIG->wwwroot."pg/koolielu/findfriends/" . get_loggedin_user()->username); } } function koolielu_page_handler($page) { global $CONFIG; if ($page[0]) { switch ($page[0]) { case "findfriends":// Additional friends handler if (isset($page[1]) && $user = get_user_by_username($page[1])) { set_page_owner($user->getGUID()); } if ($_SESSION['guid'] == page_owner()) { collections_submenu_items(); } include($CONFIG->pluginspath . "koolielu/find_friends.php"); break; case "curriculum": include($CONFIG->pluginspath . "koolielu/curriculum_index.php"); break; case "curriculumnumbers": include($CONFIG->pluginspath . "koolielu/curriculum_numbers.php"); break; case "curriculumtable": set_input("sub_id", $page[1]); include($CONFIG->pluginspath . "koolielu/curriculumtable.php"); break; case "categories": include($CONFIG->pluginspath . "koolielu/categories_index.php"); break; case "quality_marks": include($CONFIG->pluginspath . "koolielu/quality_marks_management.php"); break; case "polls_management": include($CONFIG->pluginspath . "koolielu/polls_management.php"); break; case "polls": set_input("poll_id", $page[1]); include($CONFIG->pluginspath . "koolielu/polls_index.php"); break; case "roles": set_input('user_to_show', $page[1]); include($CONFIG->pluginspath . "koolielu/roles.php"); break; case "logos": include($CONFIG->pluginspath . "koolielu/logos_management.php"); break; case "mainmanage": include($CONFIG->pluginspath . "koolielu/main_management.php"); break; case "login": include($CONFIG->pluginspath . "koolielu/login_page.php"); break; case "statistics": include($CONFIG->pluginspath . "koolielu/statistics_index.php"); break; case "certificates": include($CONFIG->pluginspath . "koolielu/certificates_index.php"); break; default: include($CONFIG->pluginspath . "koolielu/index.php"); break; } } else { include($CONFIG->pluginspath . "koolielu/index.php"); } } // Creates custom database tables used by the project function install_custom_databases() { global $CONFIG; // only creates table if that does not exist run_sql_script(dirname(dirname(dirname(__FILE__))) . "/mod/koolielu/koolielu.sql"); } function ke_profileedit_page_handler($page) { global $CONFIG; if (isset($page[0])) { switch ($page[0]) { case "edit" : default: include($CONFIG->pluginspath . "koolielu/ke_defaultprofile.php"); } } } // Our own profile fieldset function ke_profile_fields_setup() { global $CONFIG; $profile_defaults = array ( 'description' => 'longtext', 'briefdescription' => 'text', 'location' => 'tags', 'interests' => 'tags', 'skills' => 'tags', 'contactemail' => 'email', 'phone' => 'text', 'mobile' => 'text', 'website' => 'url', 'schools' => 'profile_schools', 'subjects' => 'profile_subjects', 'role' => 'profile_role', 'ke_openid' => 'url', ); // TODO: Have an admin interface for this $n = 0; $loaded_defaults = array(); while ($translation = get_plugin_setting("admin_defined_profile_$n", 'profile')) { // Add a translation add_translation(get_current_language(), array("profile:admin_defined_profile_$n" => $translation)); // Detect type $type = get_plugin_setting("admin_defined_profile_type_$n", 'profile'); if (!$type) $type = 'text'; // Set array $loaded_defaults["admin_defined_profile_$n"] = $type; $n++; } if (count($loaded_defaults)) { $CONFIG->profile_using_custom = true; $profile_defaults = $loaded_defaults; } $CONFIG->profile = trigger_plugin_hook('profile:fields', 'profile', NULL, $profile_defaults); } // Comemnts hook function ke_comments_hook($hook, $et, $rv, $params) { $entity = $params['entity']; if ($entity->getSubtype() != 'disctopic') { $comments = ""; $comments .= list_annotations($entity->getGUID(),'generic_comment'); $comments .= elgg_view('koolielu/forms/ke_comments',array('entity' => $entity)); return $comments; } } // Create needed storage folders function preset_koolielu_storage_folders() { global $CONFIG; $ke_datapath = getKeDataPath(); $subfolders = array("images", "rss_cache", "tempstore", "localstore"); // Create main folder if (is_dir($ke_datapath)) { foreach ($subfolders as $key => $subfolder) { if (!is_dir($ke_datapath . $subfolder . "/")) { mkdir($ke_datapath . $subfolder . "/"); } } } } // temporary method for setting ads and news metadata (archived = 0) function update_ads_and_news() { $courses = get_entities("object", "course", 0, "", 999); $job_offers = get_entities("object", "job_offering", 0, "", 999); $job_searches = get_entities("object", "job_wanted_ad", 0, "", 999); $news = get_entities("object", "news", 0, "", 999); $all_objs = array_merge($courses, $job_offers, $job_searches, $news); foreach ($all_objs as $obj) { $obj->archived = 0; $obj->save(); } } // Override for dashboard page handler function dashboard_page_handler_override($page_elements) { @require_once("ke_dashboard_index.php"); } // Custom override for initial profile fields register_elgg_event_handler('init','system','ke_profile_fields_setup', 10000); register_elgg_event_handler('init', 'system', 'koolielu_init'); register_elgg_event_handler('pagesetup','system','koolielu_pagesetup'); register_action("koolielu/filter_moderator_statistics", false, $CONFIG->pluginspath . "koolielu/actions/filter_moderator_statistics.php", true); register_action("koolielu/add_category",false, $CONFIG->pluginspath . "koolielu/actions/add_category.php", true); register_action("koolielu/edit_quality_mark", true, $CONFIG->pluginspath . "koolielu/actions/edit_quality_mark.php", false); register_action("koolielu/delete_quality_mark", true, $CONFIG->pluginspath . "koolielu/actions/delete_quality_mark.php", false); register_action("koolielu/vote_poll", true, $CONFIG->pluginspath . "koolielu/actions/vote_poll.php", false); register_action("koolielu/view_polls", true, $CONFIG->pluginspath . "koolielu/actions/view_polls.php", false); register_action("koolielu/populate_schools", false, $CONFIG->pluginspath . "koolielu/actions/populate_schools_table.php", false); // Override for default login action register_action("login", false, $CONFIG->pluginspath . "koolielu/actions/login.php"); // Override for default profile/edit action register_action("profile/edit", false, $CONFIG->pluginspath . "koolielu/actions/profile_edit.php"); ?>