Fade out PEAR_Error.
}
if ($search || $prefs->getValue('display_contact')) {
- $results = $registry->call('contacts/search', $apiargs);
+ try {
+ $results = $registry->call('contacts/search', $apiargs);
+ } catch (Exception $e) {
+ $results = array();
+ }
} else {
$results = array();
}
/* The results list returns an array for each source searched - at least
that's how it looks to me. Make it all one array instead. */
$addresses = array();
-if (!is_a($results, 'PEAR_Error')) {
- foreach ($results as $r) {
- $addresses = array_merge($addresses, $r);
- }
+foreach ($results as $r) {
+ $addresses = array_merge($addresses, $r);
}
/* If self-submitted, preserve the currently selected users encoded by
foreach ($calevents as $dayevents) {
foreach ($dayevents as $event) {
$calIds[$event->calendar] = true;
- if (is_a($event, 'PEAR_Error')) {
- continue;
- }
$iCal->addComponent($event->toiCalendar($iCal));
}
}
if (!$error) {
$data = &Horde_Data::singleton($import_format);
- if (is_a($data, 'PEAR_Error')) {
+ if ($data instanceof PEAR_Error) {
$notification->push(_("This file format is not supported."), 'horde.error');
$next_step = Horde_Data::IMPORT_FILE;
} else {
$next_step = $data->cleanup();
} else {
$next_step = $data->nextStep($actionID, $param);
- if (is_a($next_step, 'PEAR_Error')) {
+ if ($next_step instanceof PEAR_Error) {
$notification->push($next_step->getMessage(), 'horde.error');
$next_step = $data->cleanup();
}
}
} else {
$next_step = $data->nextStep($actionID, $param);
- if (is_a($next_step, 'PEAR_Error')) {
+ if ($next_step instanceof PEAR_Error) {
$notification->push($next_step->getMessage(), 'horde.error');
$next_step = $data->cleanup();
}
$error = true;
break;
}
- if (is_a($row, 'Horde_iCalendar_vevent')) {
+ if ($row instanceof Horde_iCalendar_vevent) {
$event->fromiCalendar($row);
- } elseif (is_a($row, 'Horde_iCalendar')) {
+ } elseif ($row instanceof Horde_iCalendar) {
// Skip other iCalendar components for now.
continue;
} else {
$kronolith_driver->open($calendar);
$event = $kronolith_driver->getEvent(Horde_Util::getFormData('eventID'));
$result = sscanf($exception, '%04d%02d%02d', $year, $month, $day);
- if ($result == 3 && !is_a($event, 'PEAR_Error') && $event->recurs()) {
+ if ($result == 3 && $event->recurs()) {
$event->recurrence->deleteException($year, $month, $day);
_save($event);
}
// has permissions to do so.
try {
$sourceShare = Kronolith::getInternalCalendar($source);
- if (!is_a($share, 'PEAR_Error') &&
+ if (!($share instanceof PEAR_Error) &&
$sourceShare->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE) &&
(($user == Horde_Auth::getAuth() &&
$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) ||
}
if ($event) {
- if (isset($sourceShare) && !is_a($sourceShare, 'PEAR_Error')
+ if (isset($sourceShare) && !($sourceShare instanceof PEAR_Error)
&& !$sourceShare->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
$notification->push(_("You do not have permission to move this event."), 'horde.warning');
} elseif ($user != Horde_Auth::getAuth() &&
$viewName = Horde_Util::getFormData('view', 'Event');
$view = Kronolith::getView($viewName);
-if (is_a($view->event, 'PEAR_Error')) {
+if (is_string($view->event)) {
$notification->push($view->event, 'horde.error');
header('Location: ' . Horde::applicationUrl($prefs->getValue('defaultview') . '.php', true));
exit;
if (!$event) {
$GLOBALS['notification']->push(_("The requested event was not found."), 'horde.error');
return false;
- } elseif ($event instanceof PEAR_Error) {
- $GLOBALS['notification']->push($event, 'horde.error');
- return false;
} elseif (!$event->hasPermission(Horde_Perms::DELETE)) {
$GLOBALS['notification']->push(_("You do not have permission to delete this event."), 'horde.warning');
return false;
return false;
}
- $tasks = $GLOBALS['registry']->call('tasks/listTasks', array(null, null, null, $vars->list, $vars->type == 'incomplete' ? 'future_incomplete' : $vars->type, true));
- if ($tasks instanceof PEAR_Error) {
- $GLOBALS['notification']->push($tasks, 'horde.error');
+ try {
+ $tasks = $GLOBALS['registry']->tasks->listTasks(null, null, null, $vars->list, $vars->type == 'incomplete' ? 'future_incomplete' : $vars->type, true);
+ } catch (Exception $e)
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
return false;
}
- $task = $GLOBALS['registry']->tasks->getTask($vars->list, $vars->id);
- if (!$task) {
- $GLOBALS['notification']->push(_("The requested task was not found."), 'horde.error');
- return false;
- } elseif ($task instanceof PEAR_Error) {
- $GLOBALS['notification']->push($task, 'horde.error');
+ try {
+ $task = $GLOBALS['registry']->tasks->getTask($vars->list, $vars->id);
+ if (!$task) {
+ $GLOBALS['notification']->push(_("The requested task was not found."), 'horde.error');
+ return false;
+ }
+ } catch (Exception $e)
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
? $task['alarm']['value'] * $task['alarm']['unit']
: 0;
- $result = ($id && $list)
- ? $GLOBALS['registry']->tasks->updateTask($list, $id, $task)
- : $GLOBALS['registry']->tasks->addTask($task);
- if ($result instanceof PEAR_Error) {
- $GLOBALS['notification']->push($result, 'horde.error');
+ try {
+ $result = ($id && $list)
+ ? $GLOBALS['registry']->tasks->updateTask($list, $id, $task)
+ : $GLOBALS['registry']->tasks->addTask($task);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
if (!$id) {
$id = $result[0];
}
- $task = $GLOBALS['registry']->tasks->getTask($task['tasklist'], $id);
- if ($task instanceof PEAR_Error) {
- $GLOBALS['notification']->push($task, 'horde.error');
+ try {
+ $task = $GLOBALS['registry']->tasks->getTask($task['tasklist'], $id);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
return false;
}
- $result = $GLOBALS['registry']->tasks->deleteTask($vars->list, $vars->id);
- if ($result instanceof PEAR_Error) {
- $GLOBALS['notification']->push($result, 'horde.error');
+ try {
+ $GLOBALS['registry']->tasks->deleteTask($vars->list, $vars->id);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
return false;
}
- $saved = $GLOBALS['registry']->call('tasks/toggleCompletion', array($vars->id, $vars->list));
- if ($saved instanceof PEAR_Error) {
- $GLOBALS['notification']->push($saved, 'horde.error');
+ try {
+ $GLOBALS['registry']->tasks->toggleCompletion($vars->id, $vars->list);
+ } catch (Exception $e)
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
$GLOBALS['prefs']->isLocked('default_share')) {
return false;
}
- $tasklist = $GLOBALS['registry']->tasks->addTasklist($calendar['name'], $calendar['description'], $calendar['color']);
- if ($tasklist instanceof PEAR_Error) {
- $GLOBALS['notification']->push($tasklist, 'horde.error');
+ try {
+ $tasklist = $GLOBALS['registry']->tasks->addTasklist($calendar['name'], $calendar['description'], $calendar['color']);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
$GLOBALS['notification']->push(sprintf(_("The task list \"%s\" has been created."), $calendar['name']), 'horde.success');
$GLOBALS['notification']->push(_("You are not allowed to change this task list."), 'horde.error');
return false;
}
- $updated = $GLOBALS['registry']->tasks->updateTasklist($calendar_id, $calendar);
- if ($updated instanceof PEAR_Error) {
- $GLOBALS['notification']->push($updated, 'horde.error');
+ try {
+ $GLOBALS['registry']->tasks->updateTasklist($calendar_id, $calendar);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
if ($tasklists[$calendar_id]->get('name') != $calendar['name']) {
$GLOBALS['notification']->push(_("You are not allowed to delete this task list."), 'horde.error');
return false;
}
- $deleted = $GLOBALS['registry']->tasks->deleteTasklist($calendar_id);
- if ($deleted instanceof PEAR_Error) {
- $GLOBALS['notification']->push(sprintf(_("Unable to delete \"%s\": %s"), $tasklists[$calendar_id]->get('name'), $deleted->getMessage()), 'horde.error');
+ try {
+ $GLOBALS['registry']->tasks->deleteTasklist($calendar_id);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push(sprintf(_("Unable to delete \"%s\": %s"), $tasklists[$calendar_id]->get('name'), $e->getMessage()), 'horde.error');
return false;
}
$GLOBALS['notification']->push(sprintf(_("The task list \"%s\" has been deleted."), $tasklists[$calendar_id]->get('name')), 'horde.success');
$GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
return false;
}
- $kronolith_driver = Kronolith::getDriver($driver, $calendar);
- if ($kronolith_driver instanceof PEAR_Error) {
- $GLOBALS['notification']->push($kronolith_driver, 'horde.error');
+ try {
+ $kronolith_driver = Kronolith::getDriver($driver, $calendar);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e, 'horde.error');
return false;
}
if ($driver == 'remote') {
case 'text/calendar':
case 'text/x-vcalendar':
$iCal = new Horde_iCalendar();
- if (!is_a($content, 'Horde_iCalendar_vevent')) {
+ if (!($content instanceof Horde_iCalendar_vevent)) {
if (!$iCal->parsevCalendar($content)) {
throw new Kronolith_Exception(_("There was an error importing the iCalendar data."));
}
$kronolith_driver = Kronolith::getDriver();
foreach ($iCal->getComponents() as $content) {
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
$event = $kronolith_driver->getEvent();
$event->fromiCalendar($content);
$uid = $event->uid;
// the event's history.
$history = Horde_History::singleton();
$created = $modified = null;
- $log = $history->getHistory('kronolith:' . $calendar . ':'
- . $uid);
- if ($log && !is_a($log, 'PEAR_Error')) {
- foreach ($log->getData() as $entry) {
- switch ($entry['action']) {
- case 'add':
- $created = $entry['ts'];
- break;
-
- case 'modify':
- $modified = $entry['ts'];
- break;
+ $log = $history->getHistory('kronolith:' . $calendar . ':' . $uid);
+ try {
+ if ($log) {
+ foreach ($log->getData() as $entry) {
+ switch ($entry['action']) {
+ case 'add':
+ $created = $entry['ts'];
+ break;
+
+ case 'modify':
+ $modified = $entry['ts'];
+ break;
+ }
}
}
+ } catch (Exception $e) {
}
if (empty($modified) && !empty($created)) {
$modified = $created;
// Remove share and all groups/permissions.
$share = $GLOBALS['kronolith_shares']->getShare($calendarId);
$result = $GLOBALS['kronolith_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
+ if ($result instanceof PEAR_Error) {
+ throw new Kronolith_Exception($result);
}
} catch (Exception $e) {
throw new Kronolith_Exception(sprintf(_("Unable to delete calendar \"%s\": %s"), $calendarId, $e->getMessage()));
throw new Horde_Exception_PermissionDenied();
}
- $driver = Kronolith::getDriver(null, $calendar);
- if (is_a($driver, 'PEAR_Error')) {
- return $driver;
- }
-
- $events = $driver->listEvents(new Horde_Date($startstamp),
- new Horde_Date($endstamp));
+ $events = Kronolith::getDriver(null, $calendar)
+ ->listEvents(new Horde_Date($startstamp), new Horde_Date($endstamp));
$uids = array();
foreach ($events as $dayevents) {
foreach ($dayevents as $event) {
$history = Horde_History::singleton();
$histories = $history->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'kronolith:' . $calendar);
- if (is_a($histories, 'PEAR_Error')) {
- return $histories;
- }
// Strip leading kronolith:username:.
return preg_replace('/^([^:]*:){2}/', '', array_keys($histories));
case 'text/calendar':
case 'text/x-vcalendar':
$iCal = new Horde_iCalendar();
- if (!is_a($content, 'Horde_iCalendar_vevent')) {
+ if (!($content instanceof Horde_iCalendar_vevent)) {
if (!$iCal->parsevCalendar($content)) {
throw new Kronolith_Exception(_("There was an error importing the iCalendar data."));
}
$kronolith_driver = Kronolith::getDriver(null, $calendar);
$ids = array();
foreach ($components as $content) {
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
$event = $kronolith_driver->getEvent();
$event->fromiCalendar($content);
// Check if the entry already exists in the data source,
if (is_array($uid)) {
foreach ($uid as $g) {
$result = $this->delete($g);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
}
return;
}
throw new Horde_Exception_PermissionDenied();
}
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
$component = $content;
} else {
switch ($contentType) {
case 'text/calendar':
case 'text/x-vcalendar':
- if (!is_a($content, 'Horde_iCalendar_vevent')) {
+ if (!($content instanceof Horde_iCalendar_vevent)) {
$iCal = new Horde_iCalendar();
if (!$iCal->parsevCalendar($content)) {
throw new Kronolith_Exception(_("There was an error importing the iCalendar data."));
$components = $iCal->getComponents();
$component = null;
foreach ($components as $content) {
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
if ($component !== null) {
throw new Kronolith_Exception(_("Multiple iCalendar components found; only one vEvent is supported."));
}
public function updateAttendee($response, $sender = null)
{
$uid = $response->getAttribute('UID');
- if (is_a($uid, 'PEAR_Error')) {
- return $uid;
+ if ($uid instanceof PEAR_Error) {
+ throw new Kronolith_Exception($uid);
}
$events = Kronolith::getDriver()->getByUID($uid, null, true);
$groups = $share->listGroups(Horde_Perms::READ);
foreach ($groups as $gid) {
$group_users = $group->listUsers($gid);
- if (!is_a($group_users, 'PEAR_Error')) {
+ if (!($group_users instanceof PEAR_Error)) {
$users = array_merge($users, $group_users);
}
}
$history = Horde_History::singleton();
$histories = $history->removeByParent('kronolith:' . $user);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
-
/* Get the user's default share */
try {
$share = $GLOBALS['kronolith_shares']->getShare($user);
$result = $GLOBALS['kronolith_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$hasError = true;
Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
}
/* Get a list of all shares this user has perms to and remove the
* perms */
$shares = $GLOBALS['kronolith_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
+ if ($shares instanceof PEAR_Error) {
Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
}
foreach ($shares as $share) {
* connection parameters a subclass might need.
*
* @return Kronolith_Driver The newly created concrete Kronolith_Driver
- * instance, or a PEAR_Error on error.
+ * instance.
*/
public function factory($driver = null, $params = null)
{
$dh->addTranslation($this->_params['language']);
$event = $dh->getHoliday($id);
- if (is_a($event, 'PEAR_Error')) {
+ if ($event instanceof PEAR_Error) {
throw new Horde_Exception_NotFound($event);
}
$data = $response->getBody();
$_SESSION['kronolith']['remote'][$signature] = new Horde_iCalendar();
$result = $_SESSION['kronolith']['remote'][$signature]->parsevCalendar($data);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
throw new Kronolith_Exception($result);
}
// Connect to the Kolab backend
$result = $this->_kolab->open($this->calendar, 1);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
+ if ($result instanceof PEAR_Error) {
+ throw new Kronolith_Exception($result);
}
$this->_store = $this->_kolab->_storage;
}
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
if ($this->_store->objectUidExists($uid)) {
return $uid;
$json = false, $coverDates = true)
{
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
if (is_null($startDate)) {
$startDate = new Horde_Date(array('mday' => 1,
}
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
if (array_key_exists($eventId, $this->_events_cache)) {
return $this->_events_cache[$eventId];
public function saveEvent($event)
{
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
$uid = $event->uid;
if ($uid == null) {
}
$result = $this->_store->save($attributes, $stored_uid);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
/* Deal with tags */
$tagger = Kronolith::getTagger();
{
$event = $this->getEvent($eventId);
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
global $kronolith_shares;
$target = $kronolith_shares->getShare($newCalendar);
{
$this->open($calendar);
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
$result = $this->_store->deleteAll($calendar);
if (is_callable('Kolab', 'triggerFreeBusyUpdate')) {
public function deleteEvent($eventId, $silent = false)
{
$result = $this->synchronize();
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- }
if (!$this->_store->objectUidExists($eventId)) {
throw new Kronolith_Exception(sprintf(_("Event not found: %s"), $eventId));
$query = 'UPDATE kronolith_resources SET resource_name = ?, resource_calendar = ? , resource_description = ?, resource_response_type = ?, resource_type = ?, resource_members = ? WHERE resource_id = ?';
$values = array($this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members')), $resource->getId());
$result = $this->_write_db->query($query, $values);
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
} else {
$query = 'INSERT INTO kronolith_resources (resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members)';
$cols_values = ' VALUES (?, ?, ?, ?, ?, ?, ?)';
$id = $this->_db->nextId('kronolith_resources');
$values = array($id, $this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members')));
$result = $this->_write_db->query($query . $cols_values, $values);
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
-
+ $this->handleError($result);
$resource->setId($id);
}
$query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE calendar_id = ?';
$result = $this->_write_db->query($query, array($resource->get('calendar')));
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
$query = 'DELETE FROM kronolith_resources WHERE resource_id = ?';
$result = $this->_write_db->query($query, array($resource->getId()));
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
}
/**
{
$query = 'SELECT resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members FROM kronolith_resources WHERE resource_id = ?';
$results = $this->_db->getRow($query, array($id), DB_FETCHMODE_ASSOC);
- if ($results instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($results);
- }
+ $this->handleError($results);
if (empty($results)) {
throw new Kronolith_Exception('Resource not found');
}
{
$query = 'SELECT resource_id FROM kronolith_resources WHERE resource_calendar = ?';
$result = $this->_db->getOne($query, array($calendar));
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
if (empty($result)) {
throw new Kronolith_Exception('Resource not found');
}
}
$results = $this->_db->getAssoc($query, true, $filter, DB_FETCHMODE_ASSOC, false);
- if ($results instanceof PEAR_Error) {
- Horde::logMessage($results, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($results);
- }
+ $this->handleError($results);
$return = array();
foreach ($results as $key => $result) {
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$event = $this->_db->getRow($query, $values, DB_FETCHMODE_ASSOC);
- if (is_a($event, 'PEAR_Error')) {
- Horde::logMessage($event, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($event);
- }
+ $this->handleError($event);
if ($event) {
return $event['event_id'];
- } else {
- return false;
}
+
+ return false;
}
/**
/* Run the query. */
$qr = $this->_db->query($q, $values);
- if ($qr instanceof PEAR_Error) {
- Horde::logMessage($qr, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($qr);
- }
+ $this->handleError($qr);
$events = array();
$row = $qr->fetchRow(DB_FETCHMODE_ASSOC);
- while ($row && !is_a($row, 'PEAR_Error')) {
+ while ($row && !($row instanceof PEAR_Error)) {
/* If the event did not have a UID before, we need to give
* it one. */
if (empty($row['event_uid'])) {
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_write_db->query($query, $values);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
}
}
/* Run the query. */
$result = $this->_db->getOne($query, array($this->calendar));
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
return $result;
}
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$event = $this->_db->getRow($query, $values, DB_FETCHMODE_ASSOC);
- if (is_a($event, 'PEAR_Error')) {
- Horde::logMessage($event, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($event);
- }
+ $this->handleError($event);
if ($event) {
$this->_cache[$this->calendar][$eventId] = new $this->_eventClass($this, $event);
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$events = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
- if (is_a($events, 'PEAR_Error')) {
- Horde::logMessage($events, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($events);
- }
+ $this->handleError($events);
if (!count($events)) {
throw new Horde_Exception_NotFound($uid . ' not found');
}
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_write_db->query($query, $values);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
/* Log the modification of this item in the history log. */
if ($event->uid) {
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_write_db->query($query, $values);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
/* Log the creation of this item in the history log. */
$history = Horde_History::singleton();
/* Attempt the move query. */
$result = $this->_write_db->query($query, $values);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
return $event;
}
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_write_db->query($query, $values);
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
}
/**
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_write_db->query($query, $values);
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
/* Log the deletion of this item in the history log. */
if ($event->uid) {
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_db->getCol($sql, 0, array_merge($calendar, $uids));
- if ($result instanceof PEAR_Error) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- throw new Kronolith_Exception($result);
- }
+ $this->handleError($result);
+
+ return $result;
}
/**
$this->_write_db = DB::connect($this->_params,
array('persistent' => !empty($this->_params['persistent']),
'ssl' => !empty($this->_params['ssl'])));
- if ($this->_write_db instanceof PEAR_Error) {
- throw new Kronolith_Exception($this->_write_db);
- }
+ $this->handleError($this->_write_db);
$this->_initConn($this->_write_db);
/* Check if we need to set up the read DB connection
$this->_db = DB::connect($params,
array('persistent' => !empty($params['persistent']),
'ssl' => !empty($params['ssl'])));
- if ($this->_db instanceof PEAR_Error) {
- throw new Kronolith_Exception($this->_db);
- }
+ $this->handleError($this->_db);
$this->_initConn($this->_db);
} else {
/* Default to the same DB handle for the writer too. */
}
$shares = $GLOBALS['kronolith_shares']->listShares($user, Horde_Perms::EDIT);
- if (is_a($shares, 'PEAR_Error')) {
- return $shares;
- }
+ $this->handleError($shares);
foreach (array_keys($shares) as $calendar) {
$ids = Kronolith::listEventIds(null, null, $calendar);
- if (is_a($ids, 'PEAR_Error')) {
- return $ids;
- }
+ $this->handleError($ids);
$uids = array();
foreach ($ids as $cal) {
$uids = array_merge($uids, array_keys($cal));
return true;
}
+ /**
+ * Determines if the given result is a PEAR error. If it is, logs the event
+ * and throws an exception.
+ *
+ * @param mixed $result The result to check.
+ *
+ * @throws Horde_Exception
+ */
+ protected function handleError($result)
+ {
+ if ($result instanceof PEAR_Error) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+ throw new Kronolith_Exception($result);
+ }
+ }
+
}
/* Get the event's history. */
$history = &Horde_History::singleton();
$created = $modified = null;
- $log = $history->getHistory('kronolith:' . $this->calendar . ':' . $this->uid);
- if ($log && !is_a($log, 'PEAR_Error')) {
- foreach ($log->getData() as $entry) {
- switch ($entry['action']) {
- case 'add':
- $created = $entry['ts'];
- break;
+ try {
+ $log = $history->getHistory('kronolith:' . $this->calendar . ':' . $this->uid);
+ if ($log) {
+ foreach ($log->getData() as $entry) {
+ switch ($entry['action']) {
+ case 'add':
+ $created = $entry['ts'];
+ break;
- case 'modify':
- $modified = $entry['ts'];
- break;
+ case 'modify':
+ $modified = $entry['ts'];
+ break;
+ }
}
}
+ } catch (Exception $e) {
}
if (!empty($created)) {
$vEvent->setAttribute($v1 ? 'DCREATED' : 'CREATED', $created);
{
// Unique ID.
$uid = $vEvent->getAttribute('UID');
- if (!empty($uid) && !is_a($uid, 'PEAR_Error')) {
+ if (!empty($uid) && !($uid instanceof PEAR_Error)) {
$this->uid = $uid;
}
// Title, tags and description.
$title = $vEvent->getAttribute('SUMMARY');
- if (!is_array($title) && !is_a($title, 'PEAR_Error')) {
+ if (!is_array($title) && !($title instanceof PEAR_Error)) {
$this->title = $title;
}
// Tags
$categories = $vEvent->getAttributeValues('CATEGORIES');
- if (!is_a($categories, 'PEAR_Error')) {
+ if (!($categories instanceof PEAR_Error)) {
$this->tags = $categories;
}
// Description
$desc = $vEvent->getAttribute('DESCRIPTION');
- if (!is_array($desc) && !is_a($desc, 'PEAR_Error')) {
+ if (!is_array($desc) && !($desc instanceof PEAR_Error)) {
$this->description = $desc;
}
// Remote Url
$url = $vEvent->getAttribute('URL');
- if (!is_array($url) && !is_a($url, 'PEAR_Error')) {
+ if (!is_array($url) && !($url instanceof PEAR_Error)) {
$this->url = $url;
}
// Location
$location = $vEvent->getAttribute('LOCATION');
- if (!is_array($location) && !is_a($location, 'PEAR_Error')) {
+ if (!is_array($location) && !($location instanceof PEAR_Error)) {
$this->location = $location;
}
// Class
$class = $vEvent->getAttribute('CLASS');
- if (!is_array($class) && !is_a($class, 'PEAR_Error')) {
+ if (!is_array($class) && !($class instanceof PEAR_Error)) {
$class = Horde_String::upper($class);
$this->private = $class == 'PRIVATE' || $class == 'CONFIDENTIAL';
}
// Status.
$status = $vEvent->getAttribute('STATUS');
- if (!is_array($status) && !is_a($status, 'PEAR_Error')) {
+ if (!is_array($status) && !($status instanceof PEAR_Error)) {
$status = Horde_String::upper($status);
if ($status == 'DECLINED') {
$status = 'CANCELLED';
// Start and end date.
$start = $vEvent->getAttribute('DTSTART');
- if (!is_a($start, 'PEAR_Error')) {
+ if (!($start instanceof PEAR_Error)) {
if (!is_array($start)) {
// Date-Time field
$this->start = new Horde_Date($start);
}
}
$end = $vEvent->getAttribute('DTEND');
- if (!is_a($end, 'PEAR_Error')) {
+ if (!($end instanceof PEAR_Error)) {
if (!is_array($end)) {
// Date-Time field
$this->end = new Horde_Date($end);
'month' => (int)$this->end->month,
'mday' => (int)$this->end->mday + 1));
}
- } elseif (is_array($end) && !is_a($end, 'PEAR_Error')) {
+ } elseif (is_array($end) && !($end instanceof PEAR_Error)) {
// Date field
$this->end = new Horde_Date(
array('year' => (int)$end['year'],
}
} else {
$duration = $vEvent->getAttribute('DURATION');
- if (!is_array($duration) && !is_a($duration, 'PEAR_Error')) {
+ if (!is_array($duration) && !($duration instanceof PEAR_Error)) {
$this->end = new Horde_Date($this->start);
$this->end->sec += $duration;
} else {
// vCalendar 1.0 alarms
$alarm = $vEvent->getAttribute('AALARM');
if (!is_array($alarm) &&
- !is_a($alarm, 'PEAR_Error') &&
+ !($alarm instanceof PEAR_Error) &&
intval($alarm)) {
$this->alarm = intval(($this->start->timestamp() - $alarm) / 60);
}
// X-ATTENDEE attribute is used which has the same syntax as
// ATTENDEE.
$attendee = $vEvent->getAttribute('X-ATTENDEE');
- if (!is_a($attendee, 'PEAR_Error')) {
+ if (!($attendee instanceof PEAR_Error)) {
if (!is_array($attendee)) {
$attendee = array($attendee);
// Recurrence.
$rrule = $vEvent->getAttribute('RRULE');
- if (!is_array($rrule) && !is_a($rrule, 'PEAR_Error')) {
+ if (!is_array($rrule) && !($rrule instanceof PEAR_Error)) {
$this->recurrence = new Horde_Date_Recurrence($this->start);
if (strpos($rrule, '=') !== false) {
$this->recurrence->fromRRule20($rrule);
* @param boolean $json Whether to return the free/busy data as a simple
* object suitable to be transferred as json.
*
- * @return Horde_iCalendar_vfreebusy Free/busy component on success,
- * PEAR_Error on failure.
+ * @return Horde_iCalendar_vfreebusy Free/busy component.
* @throws Kronolith_Exception
*/
public static function get($email, $json = false)
$default_domain = empty($GLOBALS['conf']['storage']['default_domain']) ? null : $GLOBALS['conf']['storage']['default_domain'];
$res = $rfc822->parseAddressList($email, $default_domain);
- if (is_a($res, 'PEAR_Error')) {
- return $res;
+ if ($res instanceof PEAR_Error) {
+ throw new Kronolith_Exception($res);
}
if (!count($res)) {
throw new Kronolith_Exception(_("No valid email address found"));
}
$http = new HTTP_Request($url, $options);
- if (is_a($response = @$http->sendRequest(), 'PEAR_Error')) {
+ $response = @$http->sendRequest();
+ if ($response instanceof PEAR_Error) {
throw new Kronolith_Exception(sprintf(_("The free/busy url for %s cannot be retrieved."), $email));
}
if ($http->getResponseCode() == 200 &&
$vFb->setAttribute('ORGANIZER', $email);
$found = false;
foreach ($components as $component) {
- if (is_a($component, 'Horde_iCalendar_vfreebusy')) {
+ if ($component instanceof Horde_iCalendar_vfreebusy) {
$found = true;
$vFb->merge($component);
}
}
$groups = &Group::singleton();
$group_list = $groups->getGroupMemberships(Horde_Auth::getAuth());
- if (!is_a($group_list, 'PEAR_Error') && count($group_list)) {
+ if (!($group_list instanceof PEAR_Error) && count($group_list)) {
$perm = $share->getPermission();
// Add the default perm, not added otherwise
$perm->addUserPermission(Horde_Auth::getAuth(), Horde_Perms::ALL, false);
}
$calendars = $GLOBALS['kronolith_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
- if (is_a($calendars, 'PEAR_Error')) {
+ if ($calendars instanceof PEAR_Error) {
Horde::logMessage($calendars, __FILE__, __LINE__, PEAR_LOG_ERR);
return array();
}
// If we can't even get a mailbox out of the address, then it is
// likely unuseable. Reject it entirely.
- if (is_a($newAttendeeParsed, 'PEAR_Error') ||
+ if ($newAttendeeParsed instanceof PEAR_Error ||
!isset($newAttendeeParsed[0]) ||
!isset($newAttendeeParsed[0]->mailbox)) {
$notification->push(
* driver being used.
*
* @return Kronolith_Driver The newly created concrete Kronolith_Driver
- * instance, or a PEAR_Error on error.
+ * instance.
* @throws Kronolith_Exception
*/
public static function getDriver($driver = null, $calendar = null)
$this->_write_db = &DB::connect($this->_params,
array('persistent' => !empty($this->_params['persistent']),
'ssl' => !empty($this->_params['ssl'])));
- if ($this->_write_db instanceof PEAR_Error) {
- throw new Kronolith_Exception($this->_write_db);
- }
+ $this->handleError($this->_write_db);
$this->_initConn($this->_write_db);
/* Check if we need to set up the read DB connection seperately. */
$this->_db = &DB::connect($params,
array('persistent' => !empty($params['persistent']),
'ssl' => !empty($params['ssl'])));
- if ($this->_db instanceof PEAR_Error) {
- throw new Kronolith_Exception($this->_db);
- }
+ $this->handleError($this->_db);
$this->_initConn($this->_db);
} else {
/* Default to the same DB handle for the writer too. */
* @param boolean $private_only (optional) Only return free/busy
* information owned by this used.
*
- * @return object Horde_iCalendar_vFreebusy on success
- * PEAR_Error on error or not found
+ * @return Horde_iCalendar_vFreebusy
* @throws Kronolith_Exception
*/
public function search($email, $private_only = false)
/* Execute the query. */
$result = $this->_write_db->query($query, $values);
+ $this->handleError($result);
+ }
+
+ /**
+ * Determines if the given result is a PEAR error. If it is, logs the event
+ * and throws an exception.
+ *
+ * @param mixed $result The result to check.
+ *
+ * @throws Horde_Exception
+ */
+ protected function handleError($result)
+ {
if ($result instanceof PEAR_Error) {
+ Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
throw new Kronolith_Exception($result);
}
}
* (array)calendarId - restrict to events contained in these calendars.
*
* @return A hash of 'calendars' and 'events' that each contain an array
- * of calendar_ids and event_uids respectively or PEAR_Error on
- * failure. Should this return the objects?
+ * of calendar_ids and event_uids respectively. Should this return
+ * the objects?
*/
public function search($tags, $filter = array())
{
if ($this->event->uid) {
/* Get the event's history. */
$history = &Horde_History::singleton();
- $log = $history->getHistory('kronolith:' . $this->event->calendar . ':' .
- $this->event->uid);
- if ($log && !is_a($log, 'PEAR_Error')) {
- foreach ($log->getData() as $entry) {
- switch ($entry['action']) {
- case 'add':
- $created = new Horde_Date($entry['ts']);
- if ($userId != $entry['who']) {
- $createdby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
- } else {
- $createdby = _("by me");
+ try {
+ $log = $history->getHistory('kronolith:' . $this->event->calendar . ':' .
+ $this->event->uid);
+ if ($log) {
+ foreach ($log->getData() as $entry) {
+ switch ($entry['action']) {
+ case 'add':
+ $created = new Horde_Date($entry['ts']);
+ if ($userId != $entry['who']) {
+ $createdby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
+ } else {
+ $createdby = _("by me");
+ }
+ break;
+
+ case 'modify':
+ $modified = new Horde_Date($entry['ts']);
+ if ($userId != $entry['who']) {
+ $modifiedby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
+ } else {
+ $modifiedby = _("by me");
+ }
+ break;
}
- break;
-
- case 'modify':
- $modified = new Horde_Date($entry['ts']);
- if ($userId != $entry['who']) {
- $modifiedby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
- } else {
- $modifiedby = _("by me");
- }
- break;
}
+ } catch (Exception $e) {
}
}
}
require KRONOLITH_BASE . '/lib/Event.php';
require KRONOLITH_BASE . '/lib/Event/Sql.php';
foreach ($components as $content) {
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
$event = new Kronolith_Event_Sql(new Driver);
$event->fromiCalendar($content);
echo (string)$event->start . "\n";
// List the events in three days (recurring event)
$a = $kron->listEvents($start, $end);
-if (is_a($a, 'PEAR_Error')) {
- var_dump($a->getMessage());
-} else {
- $events = reset($a);
- var_dump($events[0]->id);
-}
+$events = reset($a);
+var_dump($events[0]->id);
--EXPECT--
bool(true)
array(0) {
require KRONOLITH_BASE . '/lib/Event/Sql.php';
$event = new Kronolith_Event_Sql(new Driver);
foreach ($components as $content) {
- if (is_a($content, 'Horde_iCalendar_vevent')) {
+ if ($content instanceof Horde_iCalendar_vevent) {
$event->fromiCalendar($content);
var_export($event->recurrence->exceptions);
echo "\n";
switch ($actionID) {
case 'edit':
$share = $shares->getShareById(Horde_Util::getFormData('cid'));
- if (!is_a($share, 'PEAR_Error')) {
+ if (!($share instanceof PEAR_Error)) {
$perm = $share->getPermission();
} elseif (($category = Horde_Util::getFormData('share')) !== null) {
try {
case 'editform':
$share = $shares->getShareById(Horde_Util::getFormData('cid'));
- if (is_a($share, 'PEAR_Error')) {
+ if ($share instanceof PEAR_Error) {
$notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
} else {
if (!Horde_Auth::getAuth() ||
}
$result = $share->setPermission($perm, false);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push($result, 'horde.error');
} else {
$result = $share->save();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push($result, 'horde.error');
} else {
if (Horde_Util::getFormData('save_and_finish')) {
break;
}
-if (is_a($share, 'PEAR_Error')) {
+if ($share instanceof PEAR_Error) {
$title = _("Edit Permissions");
} else {
$title = sprintf(_("Edit Permissions for %s"), $share->get('name'));
}
if ($auth->hasCapability('list')) {
- $userList = $auth->listUsers();
- if (is_a($userList, 'PEAR_Error')) {
- Horde::logMessage($userList, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $userList = $auth->listUsers();
+ } catch (Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
$userList = array();
}
sort($userList);
} else {
$groupList = $groups->getGroupMemberships(Horde_Auth::getAuth(), true);
}
-if (is_a($groupList, 'PEAR_Error')) {
+if ($groupList instanceof PEAR_Error) {
Horde::logMessage($groupList, __FILE__, __LINE__, PEAR_LOG_NOTICE);
$groupList = array();
}
// Connect to database.
$db = DB::connect($dsn);
-if (is_a($db, 'PEAR_Error')) {
+if ($db instanceof PEAR_Error) {
$cli->fatal($db->toString());
}
$read_stmt = $db->prepare('SELECT reader_name FROM calendar_readers WHERE calendar_id = ?');
$write_stmt = $db->prepare('SELECT writer_name FROM calendar_writers WHERE calendar_id = ?');
$handle = $db->query('SELECT id, name, owner_name FROM calendars, calendar_owners WHERE calendars.id = calendar_owners.calendar_id');
-if (is_a($handle, 'PEAR_Error')) {
+if ($handle instanceof PEAR_Error) {
$cli->fatal($handle->toString());
}
while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
// Add permissions.
$permissions = array();
$result = $db->execute($read_stmt, array($row['id']));
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$cli->fatal($result->toString());
}
while ($perm_row = $result->fetchRow()) {
$permissions[$perm_row[0]] = Horde_Perms::READ | Horde_Perms::SHOW;
}
$result = $db->execute($write_stmt, array($row['id']));
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$cli->fatal($result->toString());
}
while ($perm_row = $result->fetchRow()) {
}
$handle = $db->query('SELECT event_id, calendar_id, ical_raw, owner_name, prefval FROM events, event_owners LEFT JOIN userprefs ON event_owners.owner_name = userprefs.user AND userprefs.prefkey = \'timezone\' WHERE events.id = event_owners.event_key ORDER BY calendar_id, userprefs.prefval, event_owners.owner_name');
-if (is_a($handle, 'PEAR_Error')) {
+if ($handle instanceof PEAR_Error) {
$cli->fatal($handle->toString());
}
$ical = new Horde_iCalendar();
}
// Parse event.
$parsed = $ical->parsevCalendar($row['ical_raw']);
- if (is_a($parsed, 'PEAR_Error')) {
+ if ($parsed instanceof PEAR_Error) {
$cli->message(' ' . $parsed->getMessage(), 'cli.warning');
continue;
}
/* Get the share entries */
$shares_result = $db->query('SELECT datatree_id, datatree_name FROM horde_datatree WHERE group_uid = \'horde.shares.kronolith\'');
-if (is_a($shares_result, 'PEAR_Error')) {
+if ($shares_result instanceof PEAR_Error) {
die($shares_result->toString());
}
/* Build an array to hold the new row data */
$nextId = $db->nextId('kronolith_shares');
- if (is_a($nextId, 'PEAR_Error')) {
+ if ($nextId instanceof PEAR_Error) {
$cli->message($nextId->toString(), 'cli.error');
$error_cnt++;
continue;
$error = false;
$db->beginTransaction();
$result = insertData('kronolith_shares', $data);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$cli->message($result->toString(), 'cli.error');
$error=true;
}
if (count($groups)) {
foreach ($groups as $group) {
$result = insertData('kronolith_shares_groups', $group);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$cli->message($result->toString(), 'cli.error');
$error = true;
}
if (count($users)) {
foreach ($users as $user) {
$result = insertData('kronolith_shares_users', $user);
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$cli->message($result->toString(), 'cli.error');
$error = true;
}
if ($delete_dt_data && !$error) {
$cli->message('DELETING datatree data for share_id: ' . $share_id, 'cli.message');
$delete = $db->prepare('DELETE FROM horde_datatree_attributes WHERE datatree_id = ?', null, MDB2_PREPARE_MANIP);
- if (is_a($delete, 'PEAR_Error')) {
+ if ($delete instanceof PEAR_Error) {
$cli->message($delete->toString(), 'cli.error');
$error = true;
} else {
$delete_result = $delete->execute(array($share_id));
- if (is_a($delete_result, 'PEAR_Error')) {
+ if ($delete_result instanceof PEAR_Error) {
$cli->message($delete_result->toString(), 'cli.error');
$error = true;
}
$delete->free();
$delete = $db->prepare('DELETE FROM horde_datatree WHERE datatree_id = ?', null, MDB2_PREPARE_MANIP);
- if (is_a($delete, 'PEAR_Error')) {
+ if ($delete instanceof PEAR_Error) {
$cli->message($delete->toString(), 'cli.error');
$error = true;
} else {
$delete_result = $delete->execute(array($share_id));
- if (is_a($delete_result, 'PEAR_Error')) {
+ if ($delete_result instanceof PEAR_Error) {
$cli->message($delete_result->toString(), 'cli.error');
$error = true;
}
$insert = $GLOBALS['db']->prepare('INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . str_repeat('?, ', count($values) - 1) . '?)',
null, MDB2_PREPARE_MANIP);
- if (is_a($insert,'PEAR_Error')) {
+ if ($insert instanceof PEAR_Error) {
return $insert;
}
$insert_result = $insert->execute($values);
<h1 class="header" style="text-align:center">
<?php
-$currentView = is_a($this, 'Kronolith_View_WorkWeek') ? 'WorkWeek' : 'Week';
+$currentView = $this instanceof Kronolith_View_WorkWeek ? 'WorkWeek' : 'Week';
$prev = $this->getWeek(-1);
$next = $this->getWeek(1);
echo $this->link(-1)->link(array('title' => _("Last week"), 'class' => 'iconNav', 'onclick' => 'return ShowView(\'' . $currentView . '\', \'' . $prev->dateString() . '\');')) . Horde::img('nav/left.png', '<', '', $GLOBALS['registry']->getImageDir('horde')) . '</a>';