I know some of this might get refactored, but these need to be class constants so
they can be autoloaded now.
@define('JONAH_BASE', dirname(__FILE__) . '/..');
require_once dirname(__FILE__) . '/../lib/Application.php';
$jonah = Horde_Registry::appInit('jonah');
-require_once JONAH_BASE . '/lib/News.php';
-require_once 'Horde/Form.php';
-require_once 'Horde/Form/Renderer.php';
function _getLinks($id, $subid, $name, $title)
{
/* Get the vars for channel type. */
$channel_type = $channel['channel_type'];
-if ($channel_type != JONAH_AGGREGATED_CHANNEL) {
+if ($channel_type != Jonah::AGGREGATED_CHANNEL) {
$notification->push(_("This is no aggregated channel."), 'horde.error');
header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('channels/edit.php', true), 'channel_id', $channel_id));
exit;
'channel_name' => $vars->get('channel_name'),
'channel_link' => $vars->get('channel_link'),
'channel_img' => $vars->get('channel_img'),
- 'channel_type' => JONAH_EXTERNAL_CHANNEL);
+ 'channel_type' => Jonah::EXTERNAL_CHANNEL);
if ($vars->get('subchannel_id')) {
$subchannel['channel_id'] = $vars->get('subchannel_id');
}
$form->addHidden('', 'channel_id', 'int', true, true);
$msg = _("Really delete this News Channel?");
-if ($vars->get('channel_type') == JONAH_INTERNAL_CHANNEL) {
+if ($vars->get('channel_type') == Jonah::INTERNAL_CHANNEL) {
$msg .= ' ' . _("All stories created in this channel will be lost!");
} else {
$msg .= ' ' . _("Any cached stories for this channel will be lost!");
$notification->push(sprintf(_("There was an error saving the feed: %s"), $save->getMessage()), 'horde.error');
} else {
$notification->push(sprintf(_("The feed \"%s\" has been saved."), $info['channel_name']), 'horde.success');
- if ($channel_type == JONAH_AGGREGATED_CHANNEL) {
+ if ($channel_type == Jonah::AGGREGATED_CHANNEL) {
$notification->push(_("You can now edit the sub-feeds."), 'horde.message');
} else {
header('Location: ' . Horde::applicationUrl('channels/index.php', true));
/* Edit channel link. */
$url = Horde::applicationUrl('channels/edit.php');
$url = Horde_Util::addParameter($url, 'channel_id', $channel['channel_id']);
- $channels[$key]['edit_link'] = Horde::link($url, _("Edit channel"), '', '', '', _("Edit channel")) . Horde_Themes::img('edit.png') . '</a>';
+ $channels[$key]['edit_link'] = Horde::link($url, _("Edit channel"), '', '', '', _("Edit channel")) . Horde::img('edit.png') . '</a>';
/* Delete channel link. */
$url = Horde::applicationUrl('channels/delete.php');
$channels[$key]['refresh_link'] = '';
switch ($channel['channel_type']) {
- case JONAH_INTERNAL_CHANNEL:
+ case Jonah::INTERNAL_CHANNEL:
/* Add story link. */
$url = Horde::applicationUrl('stories/edit.php');
$url = Horde_Util::addParameter($url, 'channel_id', $channel['channel_id']);
$channels[$key]['addstory_link'] = Horde::link($url, _("Add story"), '', '', '', _("Add story")) . Horde_Themes::img('new.png') . '</a>';
break;
- case JONAH_EXTERNAL_CHANNEL:
- case JONAH_AGGREGATED_CHANNEL:
+ case Jonah::EXTERNAL_CHANNEL:
+ case Jonah::AGGREGATED_CHANNEL:
/* Refresh cache link. */
$url = Horde::applicationUrl('stories/index.php');
$url = Horde_Util::addParameter($url, array('channel_id' => $channel['channel_id'], 'refresh' => '1', 'url' => Horde::selfUrl()));
* Get a list of stored channels.
*
* @param integer $type The type of channel to filter for. Possible
- * values are either JONAH_INTERNAL_CHANNEL
+ * values are either Jonah::INTERNAL_CHANNEL
* to fetch only a list of internal channels,
- * or JONAH_EXTERNAL_CHANNEL for only external.
+ * or Jonah::EXTERNAL_CHANNEL for only external.
* If null both channel types are returned.
*
* @return mixed An array of channels or PEAR_Error on error.
* @param integer $max The maximum number of stories to return.
* @param integer $from The number of the story to start with.
* @param array $channel_id An array of channel_ids to limit the search to.
- * @param integer $order How to order the results (a JONAH_ORDER_* constant)
+ * @param integer $order How to order the results (a Jonah::ORDER_* constant)
* @param boolean $raw Return the raw story data?
*
* @return mixed An array of results | PEAR_Error
public function perms()
{
$news = Jonah_News::factory();
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
/* Loop through internal channels and add their ids to the
* perms. */
$perms['tree']['jonah']['news']['internal_channels'][$channel['channel_id']] = false;
}
- $channels = $news->getChannels(JONAH_EXTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::EXTERNAL_CHANNEL);
/* Loop through external channels and add their ids to the
* perms. */
$news = Jonah_News::factory();
$channels = array();
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
if (is_a($channels, 'PEAR_Error')) {
$channels = array();
}
'values' => array());
$news = Jonah_News::factory();
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
foreach ($channels as $channel) {
$params['source']['values'][$channel['channel_id']] = $channel['channel_name'];
}
$news = Jonah_News::factory();
$channels = $news->getChannels();
foreach ($channels as $channel) {
- if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL) {
+ if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL) {
$params['source']['values'][$channel['channel_id']] = $channel['channel_name'];
}
}
}
- return $news->renderChannel($this->_params['source'], $view, $this->_params['max'], 0, JONAH_ORDER_READ);
+ return $news->renderChannel($this->_params['source'], $view, $this->_params['max'], 0, Jonah::ORDER_READ);
}
}
function _params()
{
$news = Jonah_News::factory();
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
$channel_choices = array();
foreach ($channels as $channel) {
$channel_choices[$channel['channel_id']] = $channel['channel_name'];
*
* @param integer $order How to order the results for internal
* channels. Possible values are the
- * JONAH_ORDER_* constants.
+ * Jonah::ORDER_* constants.
*
* @return array The specified number (or less, if there are fewer) of
* stories from the given channel.
* Defaults to false - only published stories.
* @param integer $order How to order the results for internal
* channels. Possible values are the
- * JONAH_ORDER_* constants.
+ * Jonah::ORDER_* constants.
*
* @return array The specified number (or less, if there are fewer) of
* stories from the given channel.
*/
function legacyGetStories($channel, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
global $conf, $registry;
if (is_a($channel, 'PEAR_Error')) {
return $channel;
}
- if ($channel['channel_type'] == JONAH_EXTERNAL_CHANNEL) {
+ if ($channel['channel_type'] == Jonah::EXTERNAL_CHANNEL) {
return $this->_getExternalStory($channel, $story_id);
}
}
* null, all stories will be returned.
* @param integer $from The number of the story to start with.
* @param integer $order How to sort the results for internal channels
- * Possible values are the JONAH_ORDER_*
+ * Possible values are the Jonah::ORDER_*
* constants.
*
* @return string The rendered story listing.
*/
- function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = JONAH_ORDER_PUBLISHED)
+ function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = Jonah::ORDER_PUBLISHED)
{
$channel = $this->getChannel($channel_id);
if (is_a($channel, 'PEAR_Error')) {
}
function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
return PEAR::raiseError(_("Tag support not enabled in backend."));
}
}
$result['channel_name'] = Horde_String::convertCharset($result['channel_name'], $this->_params['charset']);
- if ($result['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($result['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$channels = explode(':', $result['channel_url']);
if (count($channels)) {
$sql = 'SELECT MAX(channel_updated) FROM jonah_channels WHERE channel_id IN (' . implode(',', $channels) . ')';
* stories from the given channel.
*/
function _legacyGetStories($channel_id, $max, $from = 0, $date = null,
- $unreleased = false, $order = JONAH_ORDER_PUBLISHED)
+ $unreleased = false, $order = Jonah::ORDER_PUBLISHED)
{
if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
return $result;
}
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sql .= ' ORDER BY story_published DESC';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sql .= ' ORDER BY story_read DESC';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
$channels = array();
foreach ($channel_id as $cid) {
$c = $this->_getChannel($cid);
- if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$channels = array_merge($channels, explode(':', $c['channel_url']));
}
}
* @return mixed Array of stories| PEAR_Error
*/
function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
return $result;
$channels = array();
foreach ($channel_id as $cid) {
$c = $this->_getChannel($cid);
- if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$temp = explode(':', $c['channel_url']);
// Save a map of channels that are from composites.
foreach ($temp as $t) {
}
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sql .= ' ORDER BY story_published DESC';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sql .= ' ORDER BY story_read DESC';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
* @see Jonah_Driver_sql::searchTagsById()
*/
function searchTags($names, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
$ids = $this->getTagIds($names);
if (is_a($ids, 'PEAR_Error')) {
function getInfo(&$vars, &$info)
{
parent::getInfo($vars, $info);
- if ($vars->get('channel_type') == JONAH_COMPOSITE_CHANNEL &&
+ if ($vars->get('channel_type') == Jonah::COMPOSITE_CHANNEL &&
is_array($vars->get('subchannels'))) {
$info['channel_url'] = implode(':', $vars->get('subchannels'));
}
}
switch ($type) {
- case JONAH_INTERNAL_CHANNEL:
+ case Jonah::INTERNAL_CHANNEL:
$this->addVariable(_("Description"), 'channel_desc', 'text', false);
$this->addVariable(
_("Channel Slug"), 'channel_slug', 'text', true, false,
$this->addVariable(_("Story URL if not the default one. %c gets replaced by the feed ID, %s by the story ID."), 'channel_story_url', 'text', false);
break;
- case JONAH_EXTERNAL_CHANNEL:
+ case Jonah::EXTERNAL_CHANNEL:
$interval = Jonah_News::getIntervalLabel();
$v = &$this->addVariable(_("Caching"), 'channel_interval', 'enum', false, false, _("The interval before stories in this feed are rechecked for updates. If none, then stories will always be refetched from the source."), array($interval));
$v->setDefault('86400');
$this->addVariable(_("Image"), 'channel_img', 'text', false);
break;
- case JONAH_AGGREGATED_CHANNEL:
+ case Jonah::AGGREGATED_CHANNEL:
$this->addHidden('', 'channel_url', 'text', false);
$interval = Jonah_News::getIntervalLabel();
$this->addVariable(_("Description"), 'channel_desc', 'text', false);
}
break;
- case JONAH_COMPOSITE_CHANNEL:
+ case Jonah::COMPOSITE_CHANNEL:
global $news;
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
$enum = array();
foreach ($channels as $channel) {
$enum[$channel['channel_id']] = $channel['channel_name'];
*/
/**
- * Internal Jonah channel.
- */
-define('JONAH_INTERNAL_CHANNEL', 0);
-
-/**
- * External channel.
- */
-define('JONAH_EXTERNAL_CHANNEL', 1);
-
-/**
- * Aggregated channel.
- */
-define('JONAH_AGGREGATED_CHANNEL', 2);
-
-/**
- * Composite channel.
- */
-define('JONAH_COMPOSITE_CHANNEL', 3);
-
-/**
- */
-define('JONAH_ORDER_PUBLISHED', 0);
-define('JONAH_ORDER_READ', 1);
-define('JONAH_ORDER_COMMENTS', 2);
-
-
-/**
* Jonah Base Class.
*
* $Horde: jonah/lib/Jonah.php,v 1.141 2009/11/24 04:15:37 chuck Exp $
*/
class Jonah {
+
+ /**
+ * Internal Jonah channel.
+ */
+ const INTERNAL_CHANNEL = 0;
+
+ /**
+ * External channel.
+ */
+ const EXTERNAL_CHANNEL = 1;
+
+ /**
+ * Aggregated channel.
+ */
+ const AGGREGATED_CHANNEL = 2;
+
+ /**
+ * Composite channel.
+ */
+ const COMPOSITE_CHANNEL = 3;
+
+ /**
+ */
+ const ORDER_PUBLISHED = 0;
+ const ORDER_READ = 1;
+ const ORDER_COMMENTS = 2;
+
/**
*/
function _readURL($url)
function getChannelTypeLabel($type)
{
switch ($type) {
- case JONAH_INTERNAL_CHANNEL:
+ case Jonah::INTERNAL_CHANNEL:
return _("Local Feed");
- case JONAH_EXTERNAL_CHANNEL:
+ case Jonah::EXTERNAL_CHANNEL:
return _("External Feed");
- case JONAH_AGGREGATED_CHANNEL:
+ case Jonah::AGGREGATED_CHANNEL:
return _("Aggregated Feed");
- case JONAH_COMPOSITE_CHANNEL:
+ case Jonah::COMPOSITE_CHANNEL:
return _("Composite Feed");
}
}
*/
function typeToPermName($type)
{
- if ($type == JONAH_INTERNAL_CHANNEL) {
+ if ($type == Jonah::INTERNAL_CHANNEL) {
return 'internal_channels';
- } elseif ($type == JONAH_EXTERNAL_CHANNEL) {
+ } elseif ($type == Jonah::EXTERNAL_CHANNEL) {
return 'external_channels';
}
}
if ($channel_id = Horde_Util::getFormData('channel_id')) {
$news = Jonah_News::factory();
$channel = $news->getChannel($channel_id);
- if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL &&
+ if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL &&
Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::EDIT, $channel_id)) {
$menu->addArray(array('url' => Horde::applicationUrl('stories/edit.php?channel_id=' . (int)$channel_id), 'text' => _("_New Story"), 'icon' => 'new.png'));
}
/**
* Checks if the channel is editable by first checking if the $channel_id
* returns a valid channel array and then whether the channel type is
- * JONAH_INTERNAL_CHANNEL, which is the only one to allow stories to be
+ * Jonah::INTERNAL_CHANNEL, which is the only one to allow stories to be
* added.
*
* @param integer $channel_id The channel id to check.
}
/* Check if the channel type allows adding of stories. */
- if ($channel['channel_type'] != JONAH_INTERNAL_CHANNEL) {
+ if ($channel['channel_type'] != Jonah::INTERNAL_CHANNEL) {
return PEAR::raiseError(sprintf(_("Feed \"%s\" is not authored on this system."), $channel['channel_name']));
}
* Defaults to false - only published stories.
* @param integer $order How to order the results for internal
* channels. Possible values are the
- * JONAH_ORDER_* constants.
+ * Jonah::ORDER_* constants.
*
* @return array The specified number (or less, if there are fewer) of
* stories from the given channel.
*/
function getStories($channel_id, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
$channel = $this->getChannel($channel_id);
if (is_a($channel, 'PEAR_Error')) {
/* Fetch the stories according to channel type, using a
* template method pattern for each type. */
$funcs = array(
- JONAH_INTERNAL_CHANNEL => '_getInternalStories',
- JONAH_EXTERNAL_CHANNEL => '_getExternalStories',
- JONAH_AGGREGATED_CHANNEL => '_getAggregatedStories',
- JONAH_COMPOSITE_CHANNEL => '_getCompositeStories',
+ Jonah::INTERNAL_CHANNEL => '_getInternalStories',
+ Jonah::EXTERNAL_CHANNEL => '_getExternalStories',
+ Jonah::AGGREGATED_CHANNEL => '_getAggregatedStories',
+ Jonah::COMPOSITE_CHANNEL => '_getCompositeStories',
);
$func = $funcs[$channel['channel_type']];
*/
function _getInternalStories($channel, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
return $GLOBALS['jonah_driver']->legacyGetStories($channel, $max, $from, $refresh, $date, $unreleased, $order);
}
*/
function _getExternalStories($channel, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
if ($refresh) {
$channel['channel_interval'] = -1;
*/
function _getAggregatedStories($channel, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sort = 'story_published';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sort = 'story_read';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
*/
function _getCompositeStories($channel, $max = 10, $from = 0, $refresh = false,
$date = null, $unreleased = false,
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sort = 'story_published';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sort = 'story_read';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
if (is_a($channel, 'PEAR_Error')) {
return $channel;
}
- if ($channel['channel_type'] == JONAH_EXTERNAL_CHANNEL) {
+ if ($channel['channel_type'] == Jonah::EXTERNAL_CHANNEL) {
return $this->_getExternalStory($channel, $story_id);
}
}
return $types;
}
if (in_array('external', $GLOBALS['conf']['news']['enable'])) {
- $types[JONAH_EXTERNAL_CHANNEL] = _("External Feed");
+ $types[Jonah::EXTERNAL_CHANNEL] = _("External Feed");
}
if (in_array('internal', $GLOBALS['conf']['news']['enable'])) {
- $types[JONAH_INTERNAL_CHANNEL] = _("Local Feed");
+ $types[Jonah::INTERNAL_CHANNEL] = _("Local Feed");
}
if (in_array('aggregated', $GLOBALS['conf']['news']['enable'])) {
- $types[JONAH_AGGREGATED_CHANNEL] = _("Aggregated Feed");
+ $types[Jonah::AGGREGATED_CHANNEL] = _("Aggregated Feed");
}
if (in_array('composite', $GLOBALS['conf']['news']['enable'])) {
- $types[JONAH_COMPOSITE_CHANNEL] = _("Composite Feed");
+ $types[Jonah::COMPOSITE_CHANNEL] = _("Composite Feed");
}
return $types;
function getDefaultType()
{
if (in_array('external', $GLOBALS['conf']['news']['enable'])) {
- return JONAH_EXTERNAL_CHANNEL;
+ return Jonah::EXTERNAL_CHANNEL;
} else {
- return JONAH_INTERNAL_CHANNEL;
+ return Jonah::INTERNAL_CHANNEL;
}
}
* null, all stories will be returned.
* @param integer $from The number of the story to start with.
* @param integer $order How to sort the results for internal channels
- * Possible values are the JONAH_ORDER_*
+ * Possible values are the Jonah::ORDER_*
* constants.
*
* @return string The rendered story listing.
*/
- function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = JONAH_ORDER_PUBLISHED)
+ function renderChannel($channel_id, $tpl, $max = 10, $from = 0, $order = Jonah::ORDER_PUBLISHED)
{
$channel = $this->getChannel($channel_id);
if (is_a($channel, 'PEAR_Error')) {
}
/* Parse the feed. */
- require_once JONAH_BASE . '/lib/FeedParser.php';
$charset = empty($xml['charset']) ? 'utf-8' : $xml['charset'];
$parser = new Jonah_FeedParser($charset);
if (!$parser->parse($xml['body'])) {
}
function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
return PEAR::raiseError(_("Tag support not enabled in backend."));
}
* Get a list of stored channels.
*
* @param integer $type The type of channel to filter for. Possible
- * values are either JONAH_INTERNAL_CHANNEL
+ * values are either Jonah::INTERNAL_CHANNEL
* to fetch only a list of internal channels,
- * or JONAH_EXTERNAL_CHANNEL for only external.
+ * or Jonah::EXTERNAL_CHANNEL for only external.
* If null both channel types are returned.
*
* @return mixed An array of channels or PEAR_Error on error.
}
$result['channel_name'] = Horde_String::convertCharset($result['channel_name'], $this->_params['charset']);
- if ($result['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($result['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$channels = explode(':', $result['channel_url']);
if (count($channels)) {
$sql = 'SELECT MAX(channel_updated) FROM jonah_channels WHERE channel_id IN (' . implode(',', $channels) . ')';
* @param boolean $unreleased Whether to return not yet released stories.
* @param integer $order How to order the results for internal
* channels. Possible values are the
- * JONAH_ORDER_* constants.
+ * Jonah::ORDER_* constants.
*
* @return array The specified number (or less, if there are fewer) of
* stories from the given channel.
*/
function _getStories($channel_id, $max, $from = 0, $date = null,
- $unreleased = false, $order = JONAH_ORDER_PUBLISHED)
+ $unreleased = false, $order = Jonah::ORDER_PUBLISHED)
{
if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
return $result;
}
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sql .= ' ORDER BY story_published DESC';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sql .= ' ORDER BY story_read DESC';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
$channels = array();
foreach ($channel_id as $cid) {
$c = $this->_getChannel($cid);
- if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$channels = array_merge($channels, explode(':', $c['channel_url']));
}
}
* present in these channels
* @param integer $order How to order the results for internal
* channels. Possible values are the
- * JONAH_ORDER_* constants.
+ * Jonah::ORDER_* constants.
*
* @return mixed Array of stories| PEAR_Error
*/
function searchTagsById($ids, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
return $result;
$channels = array();
foreach ($channel_id as $cid) {
$c = $this->_getChannel($cid);
- if ($c['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($c['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$temp = explode(':', $c['channel_url']);
// Save a map of channels that are from composites.
foreach ($temp as $t) {
}
switch ($order) {
- case JONAH_ORDER_PUBLISHED:
+ case Jonah::ORDER_PUBLISHED:
$sql .= ' ORDER BY story_published DESC';
break;
- case JONAH_ORDER_READ:
+ case Jonah::ORDER_READ:
$sql .= ' ORDER BY story_read DESC';
break;
- case JONAH_ORDER_COMMENTS:
+ case Jonah::ORDER_COMMENTS:
//@TODO
break;
}
* @see Jonah_News_sql::searchTagsById()
*/
function searchTags($names, $max = 10, $from = 0, $channel_id = array(),
- $order = JONAH_ORDER_PUBLISHED)
+ $order = Jonah::ORDER_PUBLISHED)
{
$ids = $this->getTagIds($names);
if (is_a($ids, 'PEAR_Error')) {
$stories[$key]['delete_link'] = '';
/* These links only if internal channel. */
- if ($channel['channel_type'] == JONAH_INTERNAL_CHANNEL ||
- $channel['channel_type'] == JONAH_COMPOSITE_CHANNEL) {
+ if ($channel['channel_type'] == Jonah::INTERNAL_CHANNEL ||
+ $channel['channel_type'] == Jonah::COMPOSITE_CHANNEL) {
$stories[$key]['view_link'] = Horde::link(Horde::url($story['story_link']), $story['story_desc']) . htmlspecialchars($story['story_title']) . '</a>';
/* PDF link. */
$template->set('refresh', Horde::link(Horde_Util::addParameter(Horde::selfUrl(true), array('refresh' => 1)), _("Refresh Channel")) . Horde_Themes::img('reload.png') . '</a>');
$template->set('listheaders', array(_("Story"), _("Date")));
$template->set('stories', $stories, true);
-$template->set('read', $channel['channel_type'] == JONAH_INTERNAL_CHANNEL || $channel['channel_type'] == JONAH_COMPOSITE_CHANNEL, true);
-$template->set('comments', $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages') && $channel['channel_type'] == JONAH_INTERNAL_CHANNEL, true);
+$template->set('read', $channel['channel_type'] == Jonah::INTERNAL_CHANNEL || $channel['channel_type'] == Jonah::COMPOSITE_CHANNEL, true);
+$template->set('comments', $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages') && $channel['channel_type'] == Jonah::INTERNAL_CHANNEL, true);
$template->set('menu', Jonah::getMenu('string'));
// Buffer the notifications and send to the template
$channel_ids = array($channel_id);
} else {
$channel_ids = array();
- $channels = $news->getChannels(JONAH_INTERNAL_CHANNEL);
+ $channels = $news->getChannels(Jonah::INTERNAL_CHANNEL);
foreach ($channels as $ch) {
if (Jonah::checkPermissions(Jonah::typeToPermName($ch['channel_type']), Horde_Perms::SHOW, $ch['channel_id'])) {
$channel_ids[] = $ch['channel_id'];
$stories[$key]['pdf_link'] = Horde::link($url, _("PDF version")) . Horde_Themes::img('mime/pdf.png') . '</a>';
/* Edit story link. */
- if (Jonah::checkPermissions(Jonah::typeToPermName(JONAH_INTERNAL_CHANNEL), Horde_Perms::EDIT, $channel_id)) {
+ if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::EDIT, $channel_id)) {
$url = Horde::applicationUrl('stories/edit.php');
$url = Horde_Util::addParameter($url, array('story_id' => $story['story_id'], 'channel_id' => $channel_id));
$stories[$key]['edit_link'] = Horde::link($url, _("Edit story")) . Horde_Themes::img('edit.png') . '</a>';
}
/* Delete story link. */
- if (Jonah::checkPermissions(Jonah::typeToPermName(JONAH_INTERNAL_CHANNEL), Horde_Perms::DELETE, $channel_id)) {
+ if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::DELETE, $channel_id)) {
$url = Horde::applicationUrl('stories/delete.php');
$url = Horde_Util::addParameter($url, array('story_id' => $story['story_id'], 'channel_id' => $channel_id));
$stories[$key]['delete_link'] = Horde::link($url, _("Delete story")) . Horde_Themes::img('delete.png') . '</a>';