/**
  * Unsubscribe current user to a given object
  *
  * @param void
  * @return null
  */
 function unsubscribe()
 {
     $user_id = $this->request->getId('user_id');
     if ($user_id) {
         $user = Users::findById($user_id);
         if (!instance_of($user, 'User')) {
             $this->httpError(HTTP_ERR_NOT_FOUND);
             // user ID provided, but no user found
         }
         // if
     } else {
         $user = $this->logged_user;
     }
     // if
     if (!$this->active_object->canUnsubscribe($this->logged_user, $user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     if (isset($_GET['async']) && $_GET['async']) {
         if ($this->request->isSubmitted()) {
             db_begin_work();
             $action = $this->active_object->unsubscribe($user);
             if ($action && !is_error($action)) {
                 db_commit();
             } else {
                 db_rollback();
             }
             // if
         }
         // if
         require_once RESOURCES_MODULE_PATH . '/helpers/function.object_subscription.php';
         print smarty_function_object_subscription(array('object' => $this->active_object, 'user' => $user, 'render_wrapper' => false), $this->smarty);
         die;
     } else {
         $this->executeOnActiveObject('unsubscribe', array($user), lang('You are no longer subscribed to ":name" :type', array('type' => $this->active_object->getVerboseType(true), 'name' => $this->active_object->getName())), lang('Failed to unsubscribe you from ":name" :type', array('type' => $this->active_object->getVerboseType(true), 'name' => $this->active_object->getName())));
     }
     // if
 }