function destroy($args, $apidata) { parent::handle($args); if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); return; } $id = $apidata['api_arg']; # We can't subscribe to a remote person, but we can unsub $other = $this->get_profile($id); $user = $apidata['user']; $sub = new Subscription(); $sub->subscriber = $user->id; $sub->subscribed = $other->id; if ($sub->find(true)) { $sub->query('BEGIN'); $sub->delete(); $sub->query('COMMIT'); } else { $this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']); return; } $type = $apidata['content-type']; $this->init_document($type); $this->show_profile($other, $type); $this->end_document($type); }
/** * Delete a subscription * * Deletes the subscription from $subscriber_uri to $subscribed_user_uri. * Throws exceptions in case of error. * * @param string $subscriber_uri The OMB identifier URI specifying the * subscribing profile * * @param string $subscribed_user_uri The OMB identifier URI specifying the * subscribed profile * * @access public **/ public function deleteSubscription($subscriber_uri, $subscribed_user_uri) { $sub = new Subscription(); $subscribed = $this->_getAnyProfile($subscribed_user_uri); $subscriber = $this->_getAnyProfile($subscriber_uri); $sub->subscribed = $subscribed->id; $sub->subscriber = $subscriber->id; $sub->delete(); }
public function delete() { $subids = $this->getAllSubscriptions(); foreach ($subids as $id) { $subscription = new Subscription(); $subscription->load($id); $subscription->delete(); } $this->meta->delete(); }
function _deleteSubscriptions() { $sub = new Subscription(); $sub->subscriber = $this->id; $sub->find(); while ($sub->fetch()) { $other = Profile::staticGet('id', $sub->subscribed); if (empty($other)) { continue; } if ($other->id == $this->id) { continue; } Subscription::cancel($this, $other); } $subd = new Subscription(); $subd->subscribed = $this->id; $subd->find(); while ($subd->fetch()) { $other = Profile::staticGet('id', $subd->subscriber); if (empty($other)) { continue; } if ($other->id == $this->id) { continue; } Subscription::cancel($other, $this); } $self = new Subscription(); $self->subscriber = $this->id; $self->subscribed = $this->id; $self->delete(); }
function _deleteSubscriptions() { $sub = new Subscription(); $sub->subscriber = $this->getID(); $sub->find(); while ($sub->fetch()) { try { $other = $sub->getSubscribed(); if (!$other->sameAs($this)) { Subscription::cancel($this, $other); } } catch (NoResultException $e) { // Profile not found common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...'); } catch (ServerException $e) { // Subscription cancel failed common_log(LOG_INFO, 'Subscribed profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...'); } } $sub = new Subscription(); $sub->subscribed = $this->getID(); $sub->find(); while ($sub->fetch()) { try { $other = $sub->getSubscriber(); common_log(LOG_INFO, 'Subscriber profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...'); if (!$other->sameAs($this)) { Subscription::cancel($other, $this); } } catch (NoResultException $e) { // Profile not found common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...'); } catch (ServerException $e) { // Subscription cancel failed common_log(LOG_INFO, 'Subscriber profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...'); } } // Finally delete self-subscription $self = new Subscription(); $self->subscriber = $this->getID(); $self->subscribed = $this->getID(); $self->delete(); }
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete')); $sort = fCRUD::getSortColumn(array('name', 'status', 'method', 'state')); $sort_order = fCRUD::getSortDirection('asc'); $subscription_id = fRequest::get('subscription_id', 'integer'); $check_id = fRequest::get('check_id', 'integer'); $manage_url = $_SERVER['SCRIPT_NAME']; // --------------------------------- // if ('delete' == $action) { $class_name = 'Subscription'; try { $obj = new Subscription($subscription_id); $check = new Check($obj->getCheckId()); $delete_text = 'Are you sure you want to delete your subscription to <strong>' . $check->getName() . '</strong>?'; if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $obj->delete(); fMessaging::create('success', $manage_url, 'The subscription for ' . $check->getName() . ' was successfully deleted'); fURL::redirect($manage_url); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The subscription requested, ' . fHTML::encode($date) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; // --------------------------------- // } elseif ('edit' == $action) { try { $subscription = new Subscription($subscription_id); $check = new Check($subscription->getCheckId());
); $sort = fCRUD::getSortColumn(array('name','status','method','state')); $sort_order = fCRUD::getSortDirection('asc'); $subscription_id = fRequest::get('subscription_id', 'integer'); $check_id = fRequest::get('check_id', 'integer'); $manage_url = $_SERVER['SCRIPT_NAME']; // --------------------------------- // if ('delete' == $action) { try { $check = new Check($check_id); $subscription = new Subscription($subscription_id); if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $subscription->delete(); fMessaging::create('success', $manage_url, 'The subscription for ' . $check->getName() . ' was successfully deleted'); fURL::redirect($manage_url); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The subscription requested, ' . fHTML::encode($date) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete_subscription.php'; // --------------------------------- //
} if (!$g_user->hasPermission('ManageSubscriptions')) { camp_html_display_error(getGS("You do not have the right to delete subscriptions.")); exit; } $f_user_id = Input::Get('f_user_id', 'int', 0); $f_subscription_id = Input::Get('f_subscription_id', 'int', 0); $f_publication_id = Input::Get('f_publication_id'); $manageUser = new User($f_user_id); $subscription = new Subscription($f_subscription_id); $publication = new Publication($subscription->getPublicationId()); if ($subscription->delete()) { $logtext = getGS('Subscription #$1 deleted for user #$2 (Publication: $3)', $f_subscription_id, $f_user_id, $f_publication_id); Log::Message($logtext, null, 182); $uriPath = strtok($_SERVER['HTTP_REFERER'], "?"); $inSubscriptions = (strstr($uriPath, '/subscriptions') != '') || !$g_user->hasPermission('ManageUsers'); if ($inSubscriptions) { $location = "/$ADMIN/users/subscriptions/?f_user_id=$f_user_id"; } else { $location = "/$ADMIN/users/edit.php?User=$f_user_id&uType=Subscribers"; } camp_html_goto_page($location); } $crumbs = array(); $crumbs[] = array(getGS("Configure"), "");