public function canProcess() { if (!\Auth::loggedIn()) { Redirect::to('/admin/access')->now(); } return true; }
public function renderImport() { $videoId = $this->getInt('id'); $postData = $this->request()->postVariables(); Captionify::create($videoId, $postData['text']); Redirect::to('/admin/video/' . $videoId . '/caption/' . $videoId . '/edit')->now(); }
public function renderDestroy() { $userId = $this->getInt('id'); $user = new User($userId); $user->delete(); Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'User was successfully deleted'))->now(); }
public function renderDestroy() { $platformId = $this->getInt('id'); $platform = new Platform($platformId); $platform->delete(); $msg = new \stdClass(); $msg->type = 'success'; $msg->text = 'Platform was successfully deleted'; Redirect::to('/' . $this->baseUri())->with('msg', $msg)->now(); }
public function renderDestroy() { $VideoId = $this->getInt('id'); $Video = new Video($VideoId); $Video->delete(); $msg = new \stdClass(); $msg->type = 'success'; $msg->text = 'Video was successfully deleted'; Redirect::to('/' . $this->baseUri())->with('msg', $msg)->now(); }
public function renderDestroy() { $categoryId = $this->getInt('id'); $articlesInCategory = Article::collection(['category_id' => $categoryId]); $videosInCategory = Video::collection(['category_id' => $categoryId]); if ($articlesInCategory->hasMappers() || $videosInCategory->hasMappers()) { Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('error', 'Category cannot be deleted. Some Articles/Videos belong to it'))->now(); } else { $category = new Category($categoryId); $category->delete(); Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Category was successfully deleted'))->now(); } }
public function renderDestroy() { $articleId = $this->getInt('id'); $article = new Article($articleId); $article->delete(); $sections = ArticleSection::collection(['article_id' => $articleId]); foreach ($sections as $section) { $articleSection = new ArticleSection($section->id()); $articleSection->delete(); $sectionBlocks = ArticleSectionBlock::collection(['article_section_id' => $section->id()]); foreach ($sectionBlocks as $block) { $block->delete(); } } Redirect::to('/' . $this->baseUri())->with('msg', new TransportMessage('success', 'Article was successfully deleted'))->now(); }
public function actionDestroy($id) { $contact = new Contact($id); $campaign = new Campaign($this->_campaignId); $campaignContact = CampaignContact::collection()->loadOneWhere(["campaign_id" => $this->_campaignId, "contact_id" => $id]); if (!$campaignContact instanceof RecordMapper) { if ($id == $campaign->contactId) { $message = "Can't delete the default contact. Please edit the " . "campaign instead."; } else { $message = "Couldn't find contact id {$id}."; } return Redirect::to(sprintf("/campaigns/%d", $this->_campaignId))->with('msg', new TransportMessage('error', $message)); } $campaignContact->delete(); return Redirect::to(sprintf("/campaigns/%d", $this->_campaignId))->with('msg', new TransportMessage('info', "Contact '{$contact->name}' deleted from '{$campaign->name}'.")); }
/** * Render the search results index * * @param string $term * * @return SearchIndexView */ public function renderIndex($term = '') { if (!$term) { $url = '/'; $searchPost = $this->request()->postVariables('term'); if ($searchPost) { $url = '/search/' . urlencode($searchPost); } Redirect::to($url)->now(); } /** @var SearchIndexView $view */ $view = $this->getView('SearchIndexView'); $view->setTerm($term); $searchObject = new SearchObject(); $searchObject->addLike('title', $term); // todo currently waiting on http://phabricator.cubex.io/T171 //$articles = Article::collection($searchObject); return $this->setView($view); }
public function projectPrepare() { $config = Container::config()->get("sidekix", new Config()); $security = $config->getStr("security_key", null); $request = Container::request(); if ($request === null) { return; } $version = $request->getVariables("DIFFUSE_VERSION", null); $secKey = $request->getVariables("SEC", null); if ($version !== null && $secKey === $security) { $cookie = new StandardCookie($config->getStr("diffuse_cookie", "CUBEX_VERSION"), $version); Cookies::set($cookie); $redirect = $config->getStr("diffuse_cookie_redirect", null); if ($redirect) { Redirect::to($redirect)->now(); } } }
public function renderIndex() { $campaign = new Campaign($this->getInt('id')); $dataSource = $campaign->getDataSource(); $dataSource->setExists(); $form = (new DeferoForm('source'))->bindMapper($dataSource); foreach ($dataSource->getFixedProperties() as $name => $value) { $form->get($name)->addAttribute('disabled'); } $dataSource->configureForm($form, $campaign); if ($post = $this->request()->postVariables()) { $form->hydrate($post); if ($form->isValid() && $form->csrfCheck()) { $dataSource->hydrate($form->jsonSerialize()); $campaign->dataSourceOptions = $dataSource->jsonSerialize(); $campaign->getAttribute('dataSourceOptions')->setModified(); $campaign->saveChanges(); $msg = 'Data Source Saved'; return Redirect::to('/campaigns/' . $campaign->id())->with("msg", new TransportMessage("info", $msg)); } } return new CampaignSourceView($form); }
/** * If we go directly to the wizard page we redirect to the first step. * * @return Redirect */ public function actionGoToFirstStep() { $uri = sprintf("%s%s", $this->baseUri(), $this->_wizardIterator->offsetGet(0)->getBaseUri()); return \Cubex\Facade\Redirect::to($uri); }
/** * @param Request $request * @param Response $response * @param IWizardStepIterator $steps * @param IController $controller * * @return IRenderable */ private function _handlePost(Request $request, Response $response, IWizardStepIterator $steps, IController $controller) { $form = $this->_buildCampaignForm($controller->baseUri(), $request); $form->hydrate($request->postVariables()); if ($form->isValid() && $form->csrfCheck(true)) { $form->saveChanges(); $msg = sprintf("Campaign '%s' Created", $form->name); $id = $form->getMapper()->id(); $uri = sprintf("%s%s?campaign_id=%d&%s", $controller->baseUri(), $steps->getNextStep()->getBaseUri(), $id, WizardHelper::getGetRequestString($request, ["campaign_id"])); return Redirect::to($uri)->with("msg", new TransportMessage("info", $msg)); } return new CampaignFormView($form); }
/** * Helper method to handle create and update of contacts. Will redirect to * the specific contact on success with a message. If there are any * validation or CSRF errors we render the form again with information. * * @param null|int $id * * @return \Qubes\Defero\Applications\Defero\Views\Contacts\ContactFormView */ private function _updateContact($id = null) { $form = $this->_buildContactForm($id); $form->hydrate($this->request()->postVariables()); if ($form->isValid() && $form->csrfCheck(true)) { $form->saveChanges(); $msg = "Contact '{$form->name}'"; $msg .= $id ? " Updated" : " Created"; return Redirect::to("/contacts/{$form->getMapper()->id()}")->with("msg", new TransportMessage("info", $msg)); } return $this->renderEdit($id, $form); }
/** * @param string $query */ private static function _tryTagMatchAndRedirect($query) { if (preg_match("/^(?:.* |)(?<tag>[CcP][0-9]+)(?:.* |)\$/", $query, $matches)) { $tag = $matches['tag']; $id = substr($tag, 1); $map = null; $ep = null; switch (substr($tag, 0, 1)) { case 'C': $ep = "/campaigns/%d"; $map = new Campaign($id); break; case 'c': $ep = "/contacts/%d"; $map = new Contact($id); break; } if ($map instanceof RecordMapper) { if ($map->exists()) { Redirect::to(sprintf($ep, $map->id()))->now(); } } } }
public function logout() { \Auth::logout(); Redirect::to('/' . $this->baseUri())->now(); }
public function renderDestroy() { $sectionId = $this->getInt('id'); $articleSection = new ArticleSection($sectionId); $articleSection->delete(); $sectionBlocks = ArticleSectionBlock::collection(['article_section_id' => $sectionId]); foreach ($sectionBlocks as $block) { $block->delete(); } Redirect::to('/admin/article/' . $articleSection->articleId . '/edit')->now(); die; }
public function renderEdit($pid) { $processors = $this->_campaign->processors; $definedProcessors = $this->config('processors')->jsonSerialize(); if (!isset($processors[$pid])) { return $this->renderNew(); } $pData = $processors[$pid]; $form = new DeferoForm('edit_processor'); $form->addSelectElement('processorType', array_map('class_shortname', $definedProcessors)); $form->getElement('processorType')->addAttribute('disabled'); $processor = $this->config('processors')->getStr($pData->processorType); $processor = new $processor(); // populate types $class = new \ReflectionClass($processor); foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $p) { $default = $p->getValue($processor); // get property type (enum) // use reflection to check for enumclass if ($t = DocBlockHelper::getBlock($processor, $p->getName(), 'enumclass')) { $form->addSelectElement($p->getName(), (new OptionBuilder(new $t()))->getOptions(), $default); } else { $form->addTextElement($p->getName(), $default); } } $form->addSubmitElement(); $form->hydrate((array) $processor); $form->hydrate((array) $pData); if ($this->request()->postVariables()) { $form->hydrate($this->request()->postVariables()); if ($form->isValid() && $form->csrfCheck()) { $processors[$pid] = $form->jsonSerialize(); $this->_campaign->processors = $processors; $this->_campaign->saveChanges(); return Redirect::to('/campaigns/' . $this->getInt('cid')); } } echo $form; }
/** * Delete a campaign * * @param int $id * * @return \Cubex\Core\Http\Redirect */ public function actionDestroy($id) { $campaign = new Campaign($id); $campaign->forceLoad(); $campaign->delete(); return Redirect::to('/campaigns')->with('msg', new TransportMessage('info', "Campaign '{$campaign->name}' deleted.")); }
public function renderTranslate() { $campaign = new Campaign($this->getInt('id')); $message = $campaign->message(); $message->reload(); $subject = $this->translateString($message->subject); $plainText = $this->translateString($message->plainText); $language = $this->getStr('hl'); $htmlContent = $message->htmlContent; while ($this->translateBlock($htmlContent)) { } $message->setLanguage($language); $message->reload(); $message->subject = $subject; $message->plainText = $plainText; $message->htmlContent = $htmlContent; $message->saveChanges(); if ($campaign->availableLanguages == null) { $campaign->availableLanguages = [$language => $language]; } else { $availableLanguages = (array) $campaign->availableLanguages; $availableLanguages[$language] = $language; $campaign->availableLanguages = $availableLanguages; } $campaign->saveChanges(); return Redirect::to('/campaigns/' . $this->getStr('id') . '/message/' . $this->getStr('hl')); }