path . 'mod/community/views/'); // Override for file view set_view_location('object/file', $CONFIG->path . 'mod/community/views/'); // Override forum topic create view set_view_location('forms/forums/addtopic', $CONFIG->path . 'mod/community/views/'); // Override forum topic addpost view set_view_location('forms/forums/addpost', $CONFIG->path . 'mod/community/views/'); // Override file css set_view_location('file/css', $CONFIG->path . 'mod/community/views/'); // Override messageboard content view set_view_location('messageboard/messageboard_content', $CONFIG->path . 'mod/community/views/'); // Override groups members portlet set_view_location('groups/members', $CONFIG->path . 'mod/community/views/'); // Override file upload view set_view_location('file/upload', $CONFIG->path . 'mod/community/views/'); // Override page edit view set_view_location('forms/pages/edit', $CONFIG->path . 'mod/community/views/'); // Override groups world tabs set_view_location('groups/group_sort_menu', $CONFIG->path . 'mod/community/views/'); // extend css extend_view('css', 'community/css'); extend_view('metatags', 'community/metatags'); register_elgg_event_handler('delete', 'all', 'community_clean_up_subcomments'); // Cron register_plugin_hook('cron', 'hourly', 'community_publish_files_cron'); } function community_pagesetup() { global $CONFIG; $page_owner = page_owner_entity(); if (get_context() == 'groups' && !($page_owner instanceof ElggGroup)) { add_submenu_item(elgg_echo('groups:all'), $CONFIG->wwwroot . "pg/groups/world/", '1groupslinks'); } // Link to group page from files or pages (also added search to get link to pages main page) if (($page_owner instanceof ElggGroup) && (get_context() != 'groups')) { /*translation:Back to %s*/ add_submenu_item(sprintf(elgg_echo('koolielu:back_to_group_main'),$page_owner->name), $page_owner->getURL()); } if (($page_owner instanceof ElggGroup) && (get_context() == 'groups')) { /*translation:Back to %s*/ add_submenu_item(sprintf(elgg_echo('koolielu:back_to_group_main'),$page_owner->name), $page_owner->getURL(), '1groupsactions'); } if (get_context() == 'groups' && !($page_owner instanceof ElggGroup)) { /*translation:All external groups*/ add_submenu_item(elgg_echo('koolielu:submenu_item_external_groups'), $CONFIG->wwwroot . 'pg/groups/allexternal', '1groupslinks'); if (isloggedin()) { add_submenu_item(elgg_echo('groups:yours'), $CONFIG->wwwroot . "pg/groups/member/" . $_SESSION['user']->username, '1groupslinks'); add_submenu_item(elgg_echo('groups:owned'), $CONFIG->wwwroot . "pg/groups/owned/" . $_SESSION['user']->username, '1groupslinks'); add_submenu_item(elgg_echo('groups:new'), $CONFIG->wwwroot."pg/groups/new/", '1groupslinks'); } } if (get_context() == 'groups' && !($page_owner instanceof ElggGroup) && (isEditor() || isExternalGroupModerator())) { /*translation:Add external group*/ add_submenu_item(elgg_echo('koolielu:submenu_item_add_external_group'), $CONFIG->wwwroot . 'pg/groups/newexternal', '1groupslinks'); } if (get_context() == 'groups' && !($page_owner instanceof ElggGroup)) { /*translation:Online users*/ add_submenu_item(elgg_echo('koolielu:submenu_online_uers'), $CONFIG->wwwroot . 'pg/groups/onlineusers', '1groupslinks'); } // Additional point for group menu if ($page_owner instanceof ElggGroup && get_context() == 'groups') { if ($page_owner->canEdit()) { if ($page_owner->getOwner() == get_loggedin_user()->getGUID()) { /*translation:Invite members*/ add_submenu_item(elgg_echo('koolielu:groups_invite_all'),$CONFIG->wwwroot . "mod/community/invite_all.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); } /*translation:Manage members*/ add_submenu_item(elgg_echo('koolielu:groups_manage_members'),$CONFIG->wwwroot . "mod/community/manage_members.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); } if (isEditor()) { if ($page_owner->study != 1) { /*translation:Set study group*/ //add_submenu_item(elgg_echo('koolielu:submenu_item_set_studygroup'), $CONFIG->wwwroot . "action/groups/set_unset_study?entity_guid=" . $page_owner->getGUID() . "&setstudy=true", '1groupsactions'); } else { /*translation:Unset study group*/ add_submenu_item(elgg_echo('koolielu:submenu_item_unset_studygroup'), $CONFIG->wwwroot . "action/groups/set_unset_study?entity_guid=" . $page_owner->getGUID() . "&unsetstudy=true", '1groupsactions'); } if ($page_owner->featured != 1) { /*translation:Set featured group*/ add_submenu_item(elgg_echo('koolielu:submenu_item_set_featuredgroup'), $CONFIG->wwwroot . "action/groups/set_featured?entity_guid=" . $page_owner->getGUID() . "&featured=true", '1groupsactions'); } } /*translation:Group materials*/ add_submenu_item(elgg_echo('koolielu:submenu_item_group_materials'),$CONFIG->wwwroot . "pg/groups/materials/{$page_owner->getGUID()}/", '1groupslinks'); } } function externalgroup_url($object) { global $CONFIG; return $CONFIG->url . "pg/groups/viewexternal/" . $object->getGUID(); } function community_page_handler($page) { global $CONFIG; //Redirecting to Groups section index forward("pg/groups/index"); } function groups_page_handler_override($page) { global $CONFIG; if (isset($page[0])) { // See what context we're using switch($page[0]) { case "new" : include($CONFIG->pluginspath . "groups/new.php"); break; case "newexternal" : include($CONFIG->pluginspath . "community/add_external_group.php"); break; case "viewexternal" : set_input('objectid', $page[1]); include($CONFIG->pluginspath . "community/view.php"); break; case "editexternal" : set_input('externalgroup', $page[1]); include($CONFIG->pluginspath . "community/edit_external_group.php"); break; case "allexternal" : include($CONFIG->pluginspath . "community/allexternal.php"); break; case "onlineusers": include($CONFIG->pluginspath . "community/onlineusers.php"); break; case "index" : include($CONFIG->pluginspath . "community/index.php"); break; case "world": set_context('groups'); set_page_owner(0); include($CONFIG->pluginspath . "community/all.php"); break; case "materials": set_input('group_guid', $page[1]); include($CONFIG->pluginspath . "community/materials.php"); break; case "browsetags": set_input('group_guid', $page[1]); include($CONFIG->pluginspath . "community/browsetags.php"); break; case "forum": set_input('group_guid', $page[1]); include($CONFIG->pluginspath . "groups/forum.php"); break; case "owned" : // Owned by a user if (isset($page[1])) set_input('username',$page[1]); include($CONFIG->pluginspath . "groups/index.php"); break; case "member" : // User is a member of if (isset($page[1])) set_input('username',$page[1]); include($CONFIG->pluginspath . "groups/membership.php"); break; case "show_all_group_members" : if (isset($page[1])) set_input('group_guid', $page[1]); include($CONFIG->pluginspath . "community/show_all_group_members.php"); break; default: // Override for group view, using our own now set_input('group_guid', $page[0]); include($CONFIG->pluginspath . "community/groupprofile.php"); break; } } } // Permissions hook function externalgroup_edit_hook($hook_name, $entity_type, $return_value, $parameters) { $entity = $parameters['entity']; if ($entity->getSubtype() == 'externalgroup' && (isEditor() || isExternalGroupModerator())) { return true; } return null; } // Permission hook for groups function groups_permission_hook($hook_name, $entity_type, $return_value, $parameters) { $page_owner = page_owner_entity(); if ($page_owner instanceof ElggGroup && isEditor()) { return true; } $entity = $parameters['entity']; if ($entity instanceof ElggGroup && isEditor()) { return true; } return null; } // TODO - hook it up later, no need for it atm function groups_write_acl_plugin_hook_community($hook, $entity_type, $returnvalue, $params) { $page_owner = page_owner_entity(); if ($page_owner instanceof ElggGroup) { if (can_write_to_container() || isEditor()) { $returnvalue[$page_owner->group_acl] = elgg_echo('groups:group') . ": " . $page_owner->name; return $returnvalue; } } } // Override for groups_fields_setup fnction in grops/start.php function groups_fields_setup_override() { global $CONFIG; $profile_defaults = array( 'name' => 'text', 'description' => 'longtext', 'briefdescription' => 'text', 'interests' => 'tags', 'website' => 'url', 'subjects' => 'profile_subjects', 'externalrss' => 'url', 'gtype' => 'group_type' ); $CONFIG->group = trigger_plugin_hook('profile:fields', 'group', NULL, $profile_defaults); } // Get all users that are not already members of some group function ke_group_get_users_to_invite($group_guid) { global $CONFIG; $group = get_entity($group_guid); $members = $group->getMembers(9999); $portal_users = get_entities("user", "", 0, "", 9999); $members_guids = array(); foreach ($members as $key => $mem) { $members_guids[] = $mem->guid; } if (count($members_guids) > 0) { $members_guids_str = "(" . implode(",", $members_guids) . ")"; $returned_arr = get_data("SELECT e.* FROM {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where u.guid not in $members_guids_str and e.enabled='yes'", "entity_row_to_elggstar"); return $returned_arr; } return false; } function community_usericon_hook($hook, $entity_type, $returnvalue, $params) { global $CONFIG; if ((!$returnvalue) && ($hook == 'entity:icon:url')) { $entity = $params['entity']; $type = $entity->type; $subtype = get_subtype_from_id($entity->subtype); if ($type == "object" && $subtype == "externalgroup") { if(getImageFileExists("listing_" . $entity->getGUID() . ".jpg", $entity->getOwner())) { return getImageFileURL("listing_" . $entity->getGUID() . ".jpg", $entity->getOwner()); } else { return $CONFIG->wwwroot . "/mod/koolielu/views/default/_graphics/subtype_icon_externalgroup.png"; } } } } // File plugin submenu obverride function koolielu_file_submenus() { global $CONFIG; $page_owner = page_owner_entity(); // Group submenu option if ($page_owner instanceof ElggGroup && get_context() == "groups") { if($page_owner->files_enable != "no"){ add_submenu_item(sprintf(elgg_echo("file:group"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); } } // General submenu options if (get_context() == "file") { if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) { add_submenu_item(sprintf(elgg_echo("file:yours"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); add_submenu_item(sprintf(elgg_echo('file:yours:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/friends/"); } else if (page_owner()) { add_submenu_item(sprintf(elgg_echo("file:user"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); if ($page_owner instanceof ElggUser) // This one's for users, not groups add_submenu_item(sprintf(elgg_echo('file:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/friends/"); } // Override. We do not show this one for groups files if (!($page_owner instanceof ElggGroup)) { add_submenu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "mod/file/world.php"); } if (can_write_to_container($_SESSION['guid'], page_owner())) add_submenu_item(elgg_echo('file:upload'), $CONFIG->wwwroot . "pg/file/". $page_owner->username . "/new/"); } } // Pages plugin page handler override function pages_page_handler_override($page) { global $CONFIG; if (isset($page[0])) { // See what context we're using switch($page[0]) { case "new" : include($CONFIG->pluginspath . "pages/new.php"); break; case "welcome" : include($CONFIG->pluginspath . "pages/welcome.php"); break; case "world": include($CONFIG->pluginspath . "pages/world.php"); break; case "owned" : // Owned by a user if (isset($page[1])) set_input('username',$page[1]); include($CONFIG->pluginspath . "community/pages_index.php"); break; case "edit" : if (isset($page[1])) set_input('page_guid', $page[1]); $entity = get_entity($page[1]); add_submenu_item(elgg_echo('pages:label:view'), $CONFIG->url . "pg/pages/view/{$page[1]}", 'pageslinks'); // add_submenu_item(elgg_echo('pages:user'), $CONFIG->wwwroot . "pg/pages/owned/" . $_SESSION['user']->username, 'pageslinksgeneral'); //if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}", 'pagesactions'); add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}", 'pageslinks'); include($CONFIG->pluginspath . "pages/edit.php"); break; case "view" : if (isset($page[1])) set_input('page_guid', $page[1]); extend_view('metatags','pages/metatags'); $entity = get_entity($page[1]); //add_submenu_item(elgg_echo('pages:label:view'), $CONFIG->url . "pg/pages/view/{$page[1]}", 'pageslinks'); //if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}", 'pagesactions'); add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}", 'pageslinks'); include($CONFIG->pluginspath . "community/view_page.php"); break; case "history" : if (isset($page[1])) set_input('page_guid', $page[1]); extend_view('metatags','pages/metatags'); $entity = get_entity($page[1]); add_submenu_item(elgg_echo('pages:label:view'), $CONFIG->url . "pg/pages/view/{$page[1]}", 'pageslinks'); //if (($entity) && ($entity->canEdit())) add_submenu_item(elgg_echo('pages:label:edit'), $CONFIG->url . "pg/pages/edit/{$page[1]}", 'pagesactions'); add_submenu_item(elgg_echo('pages:label:history'), $CONFIG->url . "pg/pages/history/{$page[1]}", 'pageslinks'); include($CONFIG->pluginspath . "pages/history.php"); break; default: include($CONFIG->pluginspath . "pages/new.php"); break; } } } function file_page_handler_override($page) { global $CONFIG; // The username should be the file we're getting if (isset($page[0])) { set_input('username',$page[0]); } if (isset($page[1])) { switch($page[1]) { case "read": set_input('guid',$page[2]); @include(dirname(dirname(dirname(__FILE__))) . "/entities/index.php"); break; case "friends": include($CONFIG->pluginspath . "file/friends.php"); break; case "world": include($CONFIG->pluginspath . "file/world.php"); break; case "new": include($CONFIG->pluginspath . "file/upload.php"); break; } } else { // Include the standard profile index include($CONFIG->pluginspath . "community/file_index.php"); } } // Koolielu groups submenus override function groups_submenus_override() { global $CONFIG; // Get the page owner entity $page_owner = page_owner_entity(); // Submenu items for all group pages // Koolielu addition if (get_context() == 'groups' && !($page_owner instanceof ElggGroup)) { /*translation:Index*/ //add_submenu_item(elgg_echo('koolielu:submenu_item_index'), $CONFIG->wwwroot . 'pg/groups/index', '1groupslinks'); } if ($page_owner instanceof ElggGroup && get_context() == 'groups') { if (isloggedin()) { if ($page_owner->canEdit()) { add_submenu_item(elgg_echo('groups:edit'),$CONFIG->wwwroot . "mod/groups/edit.php?group_guid=" . $page_owner->getGUID(), '1groupsactions'); if ($page_owner->getOwner() == get_loggedin_user()->getGUID()) { add_submenu_item(elgg_echo('groups:invite'),$CONFIG->wwwroot . "mod/groups/invite.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); } if (!$page_owner->isPublicMembership()) add_submenu_item(elgg_echo('groups:membershiprequests'),$CONFIG->wwwroot . "mod/groups/membershipreq.php?group_guid={$page_owner->getGUID()}", '1groupsactions'); } if ($page_owner->isMember($_SESSION['user'])) { if ($page_owner->getOwner() != $_SESSION['guid']) add_submenu_item(elgg_echo('groups:leave'), $CONFIG->wwwroot . "action/groups/leave?group_guid=" . $page_owner->getGUID(), '1groupsactions'); } else { if ($page_owner->isPublicMembership()) { add_submenu_item(elgg_echo('groups:join'),$CONFIG->wwwroot . "action/groups/join?group_guid={$page_owner->getGUID()}", '1groupsactions'); } else { add_submenu_item(elgg_echo('groups:joinrequest'),$CONFIG->wwwroot . "action/groups/joinrequest?group_guid={$page_owner->getGUID()}", '1groupsactions'); } } } if($page_owner->forum_enable != "no"){ add_submenu_item(elgg_echo('groups:forum'),$CONFIG->wwwroot . "pg/groups/forum/{$page_owner->getGUID()}/", '1groupslinks'); } } } function get_community_types() { return array( /*translation:Subject group*/ 'sg' => elgg_echo('koolielu:community:type:subject_group'), /*translation:Interest group*/ 'ig' => elgg_echo('koolielu:community:type:interest_group'), /*translation:Project group*/ 'pg' => elgg_echo('koolielu:community:type:project_group'), /*translation:Study group*/ 'stg' => elgg_echo('koolielu:community:type:study_group') ); } function community_clean_up_subcomments($event, $object_type, $object) { global $CONFIG; // Entity if ($object_type == 'object') { // Only works with files if ($object->getSubtype() == 'file') { delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_subcomments WHERE entity_guid = {$object->guid}"); } } // Owner if ($object_type == 'user') { if ($object instanceof ElggUser) { delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_subcomments WHERE owner_guid = {$object->guid}"); } } // Comment if ($object_type == 'annotation') { if ($object->getSubtype() == 'generic_comment') { delete_data("DELETE FROM {$CONFIG->dbprefix}koolielu_subcomments WHERE comment_id = {$object->id}"); } } } function community_publish_files_cron() { global $CONFIG; login(get_entity(2)); // Activate files from today and yesterday (just in case) $pubtimes = array(date("d.m.Y"), date("d.m.Y", strtotime("yesterday"))); foreach ($pubtimes as $pubtime) { $files_count = get_entities_from_metadata("pubtime", $pubtime, "object", "file", 0, 0, 0, "", 0, true); if ($files_count > 0) { $files = get_entities_from_metadata("pubtime", $pubtime, "object", "file", 0, $files_count); foreach ($files as $file) { $file->access_id = $file->future_acl; $file->clearMetadata("pubtime"); $file->clearMetadata("future_acl"); if ($file->save()) { $t_updated = time(); update_data("UPDATE {$CONFIG->dbprefix}entities set time_created = {$t_updated} WHERE guid = {$file->guid}"); } } } } logout(); } global $CONFIG; register_elgg_event_handler('init', 'system', 'community_init'); // Override for groups/start.php register_elgg_event_handler('init','system','groups_fields_setup_override', 10000); // Ensure this runs after other plugins // Override file and groups menu // XXX We need to delete the original first, this is not really good foreach ($CONFIG->events['pagesetup']['system'] as $key => $value) { if ($value == 'file_submenus') { unset($CONFIG->events['pagesetup']['system'][$key]); } if ($value == 'groups_submenus') { unset($CONFIG->events['pagesetup']['system'][$key]); } } register_elgg_event_handler('pagesetup', 'system', 'community_pagesetup'); register_elgg_event_handler('pagesetup','system','koolielu_file_submenus'); register_elgg_event_handler('pagesetup','system','groups_submenus_override'); // Additional group actions register_action("groups/set_featured", false, $CONFIG->pluginspath . "community/actions/set_featured.php"); register_action("groups/set_unset_study", false, $CONFIG->pluginspath . "community/actions/set_unset_study.php"); // External groups actions // Overrides into groups plugin register_action("groups/addexternal", false, $CONFIG->pluginspath . "community/actions/add_external_group.php"); register_action("groups/editexternal", false, $CONFIG->pluginspath . "community/actions/edit_external_group.php"); register_action("groups/deleteexternal", false, $CONFIG->pluginspath . "community/actions/delete_external_group.php"); //register_action("community/add_external_group", false, $CONFIG->pluginspath . "community/actions/add_external_group.php"); //register_action("community/edit_external_group", false, $CONFIG->pluginspath . "community/actions/edit_external_group.php"); //register_action("community/delete_external_group", false, $CONFIG->pluginspath . "community/actions/delete_external_group.php"); register_action("groups/inviteall",false, $CONFIG->pluginspath . "community/actions/invite_all.php"); register_action("file/delete_file", false, $CONFIG->pluginspath. "community/actions/delete_file.php"); register_action("file/upload", false, $CONFIG->pluginspath . "community/actions/upload_file.php"); register_action("file/save", false, $CONFIG->pluginspath . "community/actions/save_file.php"); // Small change to default leave action of groups plugin register_action("community/leave",false, $CONFIG->pluginspath . "community/actions/leave.php"); // Messageboard update action register_action("messageboard/update", false, $CONFIG->pluginspath . "community/actions/ajax/update_message.php"); // Subcomment register_action("community/add_subcomment", false, $CONFIG->pluginspath . "community/actions/add_subcomment.php"); register_action("community/delete_subcomment", false, $CONFIG->pluginspath . "community/actions/delete_subcomment.php"); ?>