/**
  * Subscribe current user to a given object
  *
  * @param void
  * @return null
  */
 function subscribe()
 {
     if (!$this->active_object->canSubscribe($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     $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 (isset($_GET['async']) && $_GET['async']) {
         if ($this->request->isSubmitted()) {
             db_begin_work();
             $action = $this->active_object->subscribe($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('subscribe', array($user), lang('You are subscribed to ":name" :type now', array('type' => $this->active_object->getVerboseType(true), 'name' => $this->active_object->getName())), lang('Failed to subscribe you to ":name" :type', array('type' => $this->active_object->getVerboseType(true), 'name' => $this->active_object->getName())));
     }
     // if
 }