* $Horde: horde/services/links/delete.php,v 1.11 2004/01/25 19:33:25 chuck Exp $ * * Generic delete API for Horde_Links * * Copyright 2003-2004, Jeroen Huinink <*****@*****.**> * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ @define('HORDE_BASE', dirname(__FILE__) . '/../..'); require_once HORDE_BASE . '/lib/base.php'; require_once HORDE_LIBS . 'Horde/Links.php'; if (!Auth::isAuthenticated()) { Horde::authenticationFailureRedirect(); } $links =& Horde_Links::singleton($registry->getApp()); $link_data = @unserialize(Util::getFormData('link_data')); $return_url = Util::getFormData('return_url'); $result = $links->deleteLink($link_data); if (is_a($result, 'PEAR_Error')) { $notification->push($result, 'horde.error'); } elseif ($registry->hasMethod($link_data['link_params']['to_application'] . '/getLinkSummary')) { $summary = $registry->call($link_data['link_params']['to_application'] . '/getLinkSummary', array($link_data)); if (is_a($summary, 'PEAR_Error')) { $summary = $summary->getMessage(); } $notification->push(sprintf(_("The %s link to %s has been removed."), $link_data['link_params']['link_type'], $summary), 'horde.success'); } else { $notification->push(_("The link has been removed"), 'horde.success'); } header('Location: ' . $return_url);
// Do CLI checks and environment setup first. require_once HORDE_BASE . '/lib/core.php'; require_once HORDE_LIBS . 'Horde/CLI.php'; // Make sure no one runs this from the web. if (!Horde_CLI::runningFromCLI()) { exit("Must be run from the command line\n"); } // Load the CLI environment - make sure there's no time limit, init // some variables, etc. Horde_CLI::init(); require_once HORDE_BASE . '/lib/base.php'; require_once HORDE_LIBS . 'Horde/DataTree.php'; require_once HORDE_LIBS . 'Horde/Links.php'; $category =& DataTree::factory('sql'); $db =& $category->_db; $links =& Horde_Links::singleton('horde'); $old_links = $db->getAll('SELECT link_id, link_type, link_from_provider, link_from_parameter, link_to_provider, link_to_parameter FROM horde_links'); $category->_params['group'] = 'horde.links'; $category->_load(); foreach ($old_links as $id => $params) { $link_id = $params[0]; $link_type = $params[1]; $link_from_provider = $params[2]; $link_from_parameter = @unserialize($params[3]); $link_to_provider = $params[4]; $link_to_parameter = @unserialize($params[5]); // workaround for Whups client data previously saved with provider 'contacts' // now standardise these as 'clients' if (strstr($link_type, 'client') && $link_to_provider == 'contacts') {