getURL() method for market objects function market_set_url($hook, $type, $url, $params) { $entity = $params['entity']; if (elgg_instanceof($entity, 'object', 'market')) { $friendly_title = elgg_get_friendly_title($entity->title); return "market/view/{$entity->guid}/{$friendly_title}"; } } // Add to the user block menu function market_owner_block_menu($hook, $type, $return, $params) { if (elgg_instanceof($params['entity'], 'user')) { $url = "market/owned/{$params['entity']->username}"; $item = new ElggMenuItem('market', elgg_echo('market'), $url); $return[] = $item; } return $return; } /** * Add a page menu menu. * * @param string $hook * @param string $type * @param array $return * @param array $params */ function market_page_menu($hook, $type, $return, $params) { if (elgg_is_logged_in()) { // only show buttons in market pages if (elgg_in_context('market')) { $user = elgg_get_logged_in_user_entity(); $page_owner = elgg_get_page_owner_entity(); if (!$page_owner) { $page_owner = elgg_get_logged_in_user_entity(); } if ($page_owner != $user) { $usertitle = elgg_echo('market:user', array($page_owner->name)); $return[] = new ElggMenuItem('market_owner', $usertitle, 'market/owned/' . $page_owner->username); //$friendstitle = elgg_echo('market:user:friends', array($page_owner->name)); //$return[] = new ElggMenuItem('2userfriends', $friendstitle, 'market/friends/' . $page_owner->username); } else { $return[] = new ElggMenuItem('market_owner', elgg_echo('market:mine'), 'market/owned/' . $user->username); } } } return $return; } // Cron function to delete old market posts 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); } /** * Returns the body of a notification message * * @param string $hook * @param string $entity_type * @param string $returnvalue * @param array $params */ function market_notify_message($hook, $entity_type, $returnvalue, $params) { $entity = $params['entity']; $to_entity = $params['to_entity']; $method = $params['method']; if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'market')) { $descr = elgg_get_excerpt($entity->description); $title = $entity->title; $owner = $entity->getOwnerEntity(); $market_type = elgg_echo("market:type:{$entity->market_type}"); return elgg_echo('market:notification', array( $owner->name, $market_type, $title, $descr, $entity->getURL() )); } return null; }