<?php /** * Elgg Market Plugin * @package market */ // Get input data $guid = (int) get_input('guid'); // Make sure we actually have permission to edit $post = get_entity($guid); if ($post->getSubtype() == "market" && $post->canEdit()) { elgg_load_library('market'); // Delete the market post $return = market_delete_post($post); if ($return) { // Success message system_message(elgg_echo("market:deleted")); } else { // Error message register_error(elgg_echo("market:notdeleted")); } // Forward to the main market page forward(elgg_get_site_url() . "market"); }
function market_expire_cron_hook($hook, $entity_type, $returnvalue, $params) { elgg_load_library('market'); $market_ttl = elgg_get_plugin_setting('market_expire', 'market'); if ($market_ttl == 0) { return true; } $time_limit = strtotime("-{$market_ttl} months"); $ret = elgg_set_ignore_access(TRUE); $entities = elgg_get_entities(array('type' => 'object', 'subtype' => 'market', 'created_time_upper' => $time_limit)); foreach ($entities as $entity) { $date = date('j/n-Y', $entity->time_created); $title = $entity->title; $owner = $entity->getOwnerEntity(); notify_user($owner->guid, elgg_get_site_entity()->guid, elgg_echo('market:expire:subject'), elgg_echo('market:expire:body', array($owner->name, $title, $date, $market_ttl)), NULL, 'site'); // Delete market post incl. pictures market_delete_post($entity); } $ret = elgg_set_ignore_access(FALSE); }