title); return $CONFIG->url . "pg/poster/read/" . $entity->getGUID() . "/" . $title; } function poster_page_handler($page) { global $CONFIG; switch ($page[0]) { case "job_offers": include($CONFIG->pluginspath . "poster/job_offers.php"); break; case "job_wanted_ads": include($CONFIG->pluginspath . "poster/job_wanted_ads.php"); break; case "courses": include($CONFIG->pluginspath . "poster/courses.php"); break; case "job_ads": include($CONFIG->pluginspath . "poster/job_ads.php"); break; case "unapproved": include($CONFIG->pluginspath . "poster/unapproved_ads.php"); break; case "archive": include($CONFIG->pluginspath . "poster/archive.php"); break; case "my_ads": include($CONFIG->pluginspath . "poster/my_ads.php"); break; case "add_job_advertisement": include($CONFIG->pluginspath . "poster/add_job_offering.php"); break; case "edit_job_advertisement": set_input('entity_guid', $page[1]); include($CONFIG->pluginspath . "poster/add_job_offering.php"); break; case "add_course": include($CONFIG->pluginspath . "poster/add_course.php"); break; case "read": set_input('entity_guid', $page[1]); include($CONFIG->pluginspath . "poster/read.php"); break; case "edit_course": set_input('course_guid', $page[1]); include($CONFIG->pluginspath . "poster/add_course.php"); break; default: include($CONFIG->pluginspath . "poster/index.php"); } return true; } function poster_pagesetup() { global $CONFIG; //add submenu options if (get_context() == "poster") { /*translation:Job offers*/ add_submenu_item(elgg_echo('koolielu:Job_offers'),$CONFIG->wwwroot."pg/poster/job_offers"); /*translation:Job search*/ add_submenu_item(elgg_echo('koolielu:Job_search'),$CONFIG->wwwroot."pg/poster/job_wanted_ads"); /*translation:Courses*/ add_submenu_item(elgg_echo('koolielu:Courses'),$CONFIG->wwwroot."pg/poster/courses"); if (isloggedin()) { /*translation:My ads*/ add_submenu_item(elgg_echo('koolielu:My_ads'),$CONFIG->wwwroot."pg/poster/my_ads"); /*translation:Add job advertisement*/ add_submenu_item(elgg_echo('koolielu:Add_job_advertisement'),$CONFIG->wwwroot."pg/poster/add_job_advertisement"); /*translation:Add course*/ add_submenu_item(elgg_echo('koolielu:Add_course'),$CONFIG->wwwroot."pg/poster/add_course"); } if (isEditor() || isadminloggedin()) { /*translation:Unapproved ads*/ add_submenu_item(elgg_echo('koolielu:Unapproved_ads'),$CONFIG->wwwroot."pg/poster/unapproved"); } if (isadminloggedin()) { /*translation:Archive*/ add_submenu_item(elgg_echo('koolielu:Archive'),$CONFIG->wwwroot."pg/poster/archive"); } } } function poster_can_edit($hook_name, $entity_type, $return_value, $parameters) { // Any Editor or above role should be able to edit if (isEditor()) { return true; } return null; } function poster_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" && in_array($subtype, array("course", "job_offering", "job_wanted_ad"))) { return $CONFIG->wwwroot . "/mod/koolielu/views/default/_graphics/subtype_icon_". $subtype .".png"; } } } function archive_old_ads($hook, $entity_type, $returnvalue, $params) { // log in as admin or else it's not possible to change entities login(get_entity(2)); $ads = get_entities_from_metadata_and_subtypes(array("approved" => 1, "archived" => 0), "object", array("course", "job_offering", "job_wanted_ad"), "", 99999); $current_time = time(); foreach ($ads as $ad) { //check is ending date passed $ad_end = $ad->ending_date; $ad_created = $ad->time_created; if ($ad_end && (($ad_end + 86400) <= $current_time)) { $ad->archived = 1; $ad->access_id = 0; $ad->frontpage = 0; $ad->save(); } // or older than two months if (!$ad_end && (strtotime("+2 month", $ad_created) < $current_time)) { $ad->archived = 1; $ad->access_id = 0; $ad->frontpage = 0; $ad->save(); } } logout(); } register_elgg_event_handler('init', 'system', 'poster_init'); register_elgg_event_handler('pagesetup','system','poster_pagesetup'); // register actions global $CONFIG; register_action("poster/add_job_offering",false,$CONFIG->pluginspath . "poster/actions/add_job_offering.php"); register_action("poster/edit_job_offering",false,$CONFIG->pluginspath . "poster/actions/edit_job_ad.php"); register_action("poster/delete_job_ad",false,$CONFIG->pluginspath . "poster/actions/delete_job_ad.php"); register_action("poster/review_object", false, $CONFIG->pluginspath . "poster/actions/review_object.php"); register_action("poster/add_course", false, $CONFIG->pluginspath . "poster/actions/add_course.php"); register_action("poster/edit_course", false, $CONFIG->pluginspath . "poster/actions/edit_course.php"); register_action("poster/delete_course", false, $CONFIG->pluginspath . "poster/actions/delete_course.php"); register_action("poster/goedit", false, $CONFIG->pluginspath . "poster/actions/goedit.php"); register_action("poster/forward", false, $CONFIG->pluginspath . "poster/actions/forward.php"); register_action("poster/show_in_frontpage", false, $CONFIG->pluginspath . "poster/actions/frontpage.php"); register_action("poster/filter", true, $CONFIG->pluginspath . "poster/actions/filter.php"); ?>