/** * Method to disconnect from shared tool session * * @apiMethod GET * @apiUri /tools/{session}/unshare * @return void */ public function unshareTask() { $this->requiresAuthentication(); // get the userid and attempt to load user profile $userid = App::get('authn')['user_id']; $result = User::getInstance($userid); // make sure we have a user if (!$result->get('id')) { throw new Exception(Lang::txt('Unable to find user.'), 404); } // include needed libraries require_once dirname(dirname(__DIR__)) . DS . 'tables' . DS . 'mw.viewperm.php'; // instantiate middleware database object $mwdb = \Components\Tools\Helpers\Utils::getMWDBO(); // get request vars $sessionid = Request::getVar('sessionid', ''); // check to make sure we have session id if (!$sessionid) { throw new Exception(Lang::txt('Missing session ID.'), 404); } // Delete the viewperm $mv = new \Components\Tools\Models\Middleware\Viewperm($mwdb); $mv->deleteViewperm($sessionid, $result->get('username')); //make sure we didnt have error disconnecting if (!$mv->getError()) { $object = new stdClass(); $object->session = array('session' => $sessionid, 'status' => 'disconnected', 'disconnected' => with(new Date())->toSql()); $this->send($object); } }
/** * Stop sharing a session with a specified user * * @param string $with Username * @return boolean */ public function unshare($with = null) { $mv = new \Components\Tools\Models\Middleware\Viewperm($this->_db); if (!$mv->deleteViewperm($this->get('sessnum'), $with)) { $this->setError($mv->getError()); return false; } return true; }