prioval = '9'; $no->save(); } */ } function info_pages() { global $CONFIG; if (get_context() == "info") { /*translation:Pages*/ add_submenu_item(elgg_echo('koolielu:submenu_item_pages'), $CONFIG->wwwroot . "pg/info/pages"); /*translation:News*/ add_submenu_item(elgg_echo('koolielu:submenu_item_news'), $CONFIG->wwwroot . "pg/info/news"); /*translation:Calendar*/ add_submenu_item(elgg_echo('koolielu:submenu_item_calendar'), $CONFIG->wwwroot . "pg/info/calendar"); if (isloggedin()) { /*translation:My news*/ add_submenu_item(elgg_echo('koolielu:submenu_item_my_news'), $CONFIG->wwwroot . "pg/info/mynews"); /*translation:Add news*/ add_submenu_item(elgg_echo('koolielu:submenu_item_add_news'), $CONFIG->wwwroot . "pg/info/add_news"); } if (isEditor()) { /*translation:Add page*/ add_submenu_item(elgg_echo('koolielu:submenu_item_add_page'), $CONFIG->wwwroot . "pg/info/add_page"); /*translation:Unapproved*/ add_submenu_item(elgg_echo('koolielu:submenu_item_unapproved'), $CONFIG->wwwroot . "pg/info/unapproved"); } /*translation:Archive*/ add_submenu_item(elgg_echo('koolielu:Archive'), $CONFIG->wwwroot . "pg/info/archive"); } } function info_handler($page) { global $CONFIG; switch ($page[0]) { case "pages": include($CONFIG->pluginspath . "info/pages_index.php"); break; case "news": set_input('category', $page[1]); include($CONFIG->pluginspath . "info/news_index.php"); break; case "calendar": include($CONFIG->pluginspath . "info/calendar_index.php"); break; case "unapproved": include($CONFIG->pluginspath . "info/unapproved_index.php"); break; case "archive": include($CONFIG->pluginspath . "info/archive.php"); break; case "add_page": include($CONFIG->pluginspath . "info/add_page.php"); break; case "add_news": include($CONFIG->pluginspath . "info/add_news.php"); break; case "review_news": include($CONFIG->pluginspath . "info/review_news.php"); break; case "readpage": set_input('pageid', $page[1]); include($CONFIG->pluginspath . "info/read_page.php"); break; case "readnews": set_input('newsid', $page[1]); include($CONFIG->pluginspath . "info/read_news.php"); break; case "mynews": include($CONFIG->pluginspath . "info/mynews.php"); break; default: include($CONFIG->pluginspath . "koolielu/index.php"); break; } return true; } function page_url($obj) { global $CONFIG; return $CONFIG->url . "pg/info/readpage/" . $obj->getGUID(); } function news_url($obj) { global $CONFIG; return $CONFIG->url . "pg/info/readnews/" . $obj->getGUID(); } // Permissions hook // Also makes an override for canEdit call on object function info_can_edit($hook_name, $entity_type, $return_value, $parameters) { $entity = $parameters['entity']; $context = get_context(); // Any Editor or above role should be able to edit if ($entity->getSubtype()=="infopage" && isEditor()) { return true; } if ($entity->getSubtype()=="news" && isEditor()) { return true; } return null; } function newsViewable($news) { $state = $news->approved; if ($state == "1") { return true; } if (!isloggedin()) { return false; } $user_guid = get_loggedin_user()->getGUID(); // Looks like 0 gets to be known as false if ((!$state) && (isEditor() || ($news->getOwner() == $user_guid))) { return true; } return false; } function info_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 == "infopage") { return $CONFIG->wwwroot . "/mod/koolielu/views/default/_graphics/subtype_icon_page.png"; } } } function archive_old_news($hook, $entity_type, $returnvalue, $params) { // log in as admin or else it's not possible to change entities login(get_entity(2)); $all_news = get_entities_from_metadata_multi( array("approved" => "1", "archived" => "0", 'prioval' => '9'), "object", "news", "", 99999 ); $current_time = time(); foreach ($all_news as $news) { // check is ending date passed $news_end = $news->publishing_end; $news_created = $news->time_created; if ($news_end && (($news_end + 86400) <= $current_time)) { $news->archived = 1; $news->frontpage = 0; $news->save(); } else if (!$news_end && (strtotime("+2 month", $news_created) < $current_time)) { $news->archived = 1; $news->frontpage = 0; $news->save(); } } logout(); } global $CONFIG; register_elgg_event_handler('init', 'system', 'info_init'); register_elgg_event_handler('pagesetup', 'system', 'info_pages'); // Pages actions register_action("info/add_page", false, $CONFIG->pluginspath . "info/actions/add_page.php"); register_action("info/edit_page", false, $CONFIG->pluginspath . "info/actions/edit_page.php"); register_action("info/delete_page", false, $CONFIG->pluginspath . "info/actions/delete_page.php"); // News actions register_action("info/add_news", false, $CONFIG->pluginspath . "info/actions/add_news.php"); register_action("info/edit_news", false, $CONFIG->pluginspath . "info/actions/edit_news.php"); register_action("info/delete_news", false, $CONFIG->pluginspath . "info/actions/delete_news.php"); register_action("info/review_news", false, $CONFIG->pluginspath . "info/actions/review_news.php"); register_action("info/frontpage_news", false, $CONFIG->pluginspath . "info/actions/frontpage_news.php") ?>