Skip to content

Commit

Permalink
Use a constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 10, 2013
1 parent fc88aa9 commit ad8d9fa
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion kronolith/calendars/edit.php
Expand Up @@ -59,7 +59,7 @@
$vars->set('system', is_null($calendar->get('owner')));
$vars->set('description', $calendar->get('desc'));
$tagger = Kronolith::getTagger();
$vars->set('tags', implode(',', array_values($tagger->getTags($calendar->getName(), 'calendar'))));
$vars->set('tags', implode(',', array_values($tagger->getTags($calendar->getName(), Kronolith_Tagger::TYPE_CALENDAR))));

$page_output->header(array(
'title' => $form->getTitle()
Expand Down
2 changes: 1 addition & 1 deletion kronolith/lib/Api.php
Expand Up @@ -1584,7 +1584,7 @@ public function updateCalendar($id, array $info)

// Prevent wiping tags if they were not passed.
if (!array_key_exists('tags', $info)) {
$info['tags'] = Kronolith::getTagger()->getTags($id, 'calendar');
$info['tags'] = Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR);
}
Kronolith::updateShare($calendar->share(), $info);
}
Expand Down
2 changes: 1 addition & 1 deletion kronolith/lib/Calendar/Internal.php
Expand Up @@ -149,7 +149,7 @@ public function toHash()
. $id . '.ics';
$hash['feed'] = (string)Kronolith::feedUrl($id);
$hash['embed'] = Kronolith::embedCode($id);
$hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, 'calendar'));
$hash['tg'] = array_values(Kronolith::getTagger()->getTags($id, Kronolith_Tagger::TYPE_CALENDAR));
if ($owner) {
$hash['perms'] = Kronolith::permissionToJson($this->_share->getPermission());
}
Expand Down
8 changes: 4 additions & 4 deletions kronolith/lib/Driver.php
Expand Up @@ -478,7 +478,7 @@ public function deleteEvent($eventId, $silent = false)

/* Remove any tags */
$tagger = Kronolith::getTagger();
$tagger->replaceTags($event->uid, array(), $event->creator, 'event');
$tagger->replaceTags($event->uid, array(), $event->creator, Kronolith_Tagger::TYPE_EVENT);

/* Remove any geolocation data. */
try {
Expand Down Expand Up @@ -567,7 +567,7 @@ public function removeUserData($user)
*/
protected function _updateTags(Kronolith_Event $event)
{
Kronolith::getTagger()->replaceTags($event->uid, $event->tags, $event->creator, 'event');
Kronolith::getTagger()->replaceTags($event->uid, $event->tags, $event->creator, Kronolith_Tagger::TYPE_EVENT);

// Resources don't currently have owners, so can't tag as owner.
if ($event->calendarType == 'resource') {
Expand All @@ -580,7 +580,7 @@ protected function _updateTags(Kronolith_Event $event)
} catch (Horde_Share_Exception $e) {
throw new Kronolith_Exception($e);
}
Kronolith::getTagger()->tag($event->uid, $event->tags, $cal->get('owner'), 'event');
Kronolith::getTagger()->tag($event->uid, $event->tags, $cal->get('owner'), Kronolith_Tagger::TYPE_EVENT);
}

/**
Expand All @@ -591,7 +591,7 @@ protected function _updateTags(Kronolith_Event $event)
protected function _addTags(Kronolith_Event $event)
{
$tagger = Kronolith::getTagger();
$tagger->tag($event->uid, $event->tags, $event->creator, 'event');
$tagger->tag($event->uid, $event->tags, $event->creator, Kronolith_Tagger::TYPE_EVENT);

// Resources don't currently have owners, so can't tag as owner.
if ($event->calendarType == 'resource') {
Expand Down
4 changes: 2 additions & 2 deletions kronolith/lib/Event.php
Expand Up @@ -493,7 +493,7 @@ public function __get($name)
break;
case 'tags':
if (!isset($this->_tags)) {
$this->synchronizeTags(Kronolith::getTagger()->getTags($this->uid, 'event'));
$this->synchronizeTags(Kronolith::getTagger()->getTags($this->uid, Kronolith_Tagger::TYPE_EVENT));
}
return $this->_tags;
case 'geoLocation':
Expand Down Expand Up @@ -2562,7 +2562,7 @@ public function synchronizeTags($tags)
$this->uid,
$this->_internaltags,
$this->_creator,
'event'
Kronolith_Tagger::TYPE_EVENT
);
}
$this->_tags = $this->_internaltags;
Expand Down
4 changes: 2 additions & 2 deletions kronolith/lib/Kronolith.php
Expand Up @@ -1252,7 +1252,7 @@ static public function addShare($info)
$calendar->set('owner', null);
}
$tagger = self::getTagger();
$tagger->tag($calendar->getName(), $info['tags'], $calendar->get('owner'), 'calendar');
$tagger->tag($calendar->getName(), $info['tags'], $calendar->get('owner'), Kronolith_Tagger::TYPE_CALENDAR);

try {
$kronolith_shares->addShare($calendar);
Expand Down Expand Up @@ -1296,7 +1296,7 @@ static public function updateShare(&$calendar, $info)
}

$tagger = self::getTagger();
$tagger->replaceTags($calendar->getName(), $info['tags'], $calendar->get('owner'), 'calendar');
$tagger->replaceTags($calendar->getName(), $info['tags'], $calendar->get('owner'), Kronolith_Tagger::TYPE_CALENDAR);
}

/**
Expand Down
17 changes: 10 additions & 7 deletions kronolith/lib/Tagger.php
Expand Up @@ -10,8 +10,11 @@
*/
class Kronolith_Tagger extends Horde_Core_Tagger
{
const TYPE_CALENDAR = 'calendar';
const TYPE_EVENT = 'event';

protected $_app = 'kronolith';
protected $_types = array('event', 'calendar');
protected $_types = array(self::TYPE_EVENT, self::TYPE_CALENDAR);

/**
* Searches for resources that are tagged with all of the requested tags.
Expand Down Expand Up @@ -51,21 +54,21 @@ public function search($tags, $filter = array())
// Items owned by specific user(s)
$args['userId'] = $filter['user'];
}
} elseif (!empty($filter['calendar'])) {
} elseif (!empty($filter[self::TYPE_CALENDAR])) {
// Only events located in specific calendar(s)
if (!is_array($filter['calendar'])) {
$filter['calendar'] = array($filter['calendar']);
if (!is_array($filter[self::TYPE_CALENDAR])) {
$filter[self::TYPE_CALENDAR] = array($filter[self::TYPE_CALENDAR]);
}
$args['calendarId'] = $filter['calendar'];
$args['calendarId'] = $filter[self::TYPE_CALENDAR];
}

/* Add the tags to the search */
$args['tagId'] = $GLOBALS['injector']->getInstance('Content_Tagger')->getTagIds($tags);

/* Restrict to events or calendars? */
$cal_results = $event_results = array();
if (empty($filter['type']) || $filter['type'] == 'calendar') {
$args['typeId'] = $this->_type_ids['calendar'];
if (empty($filter['type']) || $filter['type'] == self::TYPE_CALENDAR) {
$args['typeId'] = $this->_type_ids[self::TYPE_CALENDAR];
$cal_results = $GLOBALS['injector']->getInstance('Content_Tagger')->getObjects($args);
}

Expand Down

0 comments on commit ad8d9fa

Please sign in to comment.