public function config_delete() { $this->assertLoggedIn(); $this->set('area', 'slicers'); try { //load the data and check for errors. $config = new SliceConfig($this->args('id')); if (!$config->isHydrated()) { throw new Exception("That slice config does not exist."); } if ($config->get('user_id') != User::$me->id && !User::isAdmin()) { throw new Exception("You do not have access to view this config."); } $this->setTitle("Delete Slice Config - " . $config->getName()); //create our form $form = new Form(); $form->action = $config->getUrl() . "/delete"; $form->add(WarningField::name('warning')->value("<strong>Warning</strong>: deleting the " . $config->getLink() . " slice config is permanent. Are you really sure you want to do this?")); $this->set('form', $form); //check our form if ($form->checkSubmitAndValidate($this->args())) { $config->delete(); $this->forwardToUrl("/slicers"); } } catch (Exception $e) { $this->setTitle("Delete Slice Config - Error"); $this->set('megaerror', $e->getMessage()); } }
public function revoke_app() { $this->assertLoggedIn(); $this->set('area', 'app'); try { $token = new OAuthToken($this->args('id')); if (!$token->isHydrated()) { throw new Exception("This app does not exist."); } /** @var User $user */ $user = new User($token->get('user_id')); if ($user->isHydrated() && $user->id != User::$me->id) { throw new Exception("You are not authorized to delete this app."); } $form = new Form(); $field = WarningField::name('warning'); if ($token->isVerified()) { $this->setTitle('Revoke App Permissions - ' . $token->getName()); $form->submitText = "Revoke App Permissions"; $field->value("Are you sure you want to revoke access to this app? Any apps currently using these credentials to print will be broken"); } else { $this->setTitle('Deny App - ' . $token->getName()); $form->submitText = "Deny App"; $field->value("Are you sure you want to deny access to this app?"); } $form->add($field); $this->set('form', $form); if ($form->checkSubmitAndValidate($this->args())) { if ($token->isVerified()) { Activity::log("removed the app named " . $token->getLink() . "."); } else { Activity::log("denied the app named " . $token->getLink() . "."); } $token->delete(); $this->forwardToUrl("/apps"); } } catch (Exception $e) { $this->setTitle('Error'); $this->set('megaerror', $e->getMessage()); } }