public function executeApprove(dmWebRequest $request) { $this->forward404Unless($request->isXmlHttpRequest()); $this->topicId = $request->getParameter('topic_id'); $this->topicApproved = false; $this->topicDeleted = false; if ($request->hasParameter('approve')) { $topic = DmForumTopicTable::getInstance()->find($this->topicId); $topic->set('is_approved', true)->save(); $this->topicApproved = true; } elseif ($request->hasParameter('delete')) { $topic = DmForumTopicTable::getInstance()->find($this->topicId); $topic->delete(); $this->topicDeleted = true; } }
/** * Allows the upload of multiple files * * @param sfWebRequest $request */ public function executeNewMultipleFile(dmWebRequest $request) { // Retrived the folder by folder_id or by object in case of usage in dmMedia/gallery module if ($request->hasParameter('folder_id')) { $folderId = $request->getParameter('folder_id'); } else { $objectModel = $request->getParameter('model'); $objectPk = $request->getParameter('pk'); $object = dmDb::table($objectModel)->find($objectPk); $folderId = $object->getDmMediaFolder()->getId(); } $this->forward404Unless($folder = dmDb::table('DmMediaFolder')->find($folderId)); if (!$folder->isWritable()) { $this->getUser()->logAlert($this->getI18n()->__('Folder %1% is not writable', array('%1%' => $folder->fullPath))); } $form = new dmMediaUploadifyForm(); $form->setDefault('dm_media_folder_id', $folder->id); if ($request->isMethod('post') && $form->bindAndValid($request)) { $media = $form->save(); if (isset($object)) { $object->addMedia($media); // In dmMedia/gallery usage, we also need to associate with the object } return $this->renderText('success'); } $action = '+/dmMediaUploadifyerAdmin/newMultipleFile?' . (isset($object) ? "&model={$objectModel}&pk={$objectPk}" : 'folder_id=' . $folder->id); return $this->renderAsync(array('html' => $form->render('.dm_form.list.little action="' . $action . '"'), 'css' => $form->getStylesheets(), 'js' => $form->getJavascripts())); }
public function executeFormWidget(dmWebRequest $request) { $form = new OrderForm(); if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) { $order = $form->save(); $order->setUid(md5(rand(1111, 9999) . time())); $order->save(); // link order details $this->shopping_cart = $shopping_cart = $this->getUser()->getShoppingCart(); $this->items = $shopping_cart->getItems(); foreach ($shopping_cart->getItems() as $i => $item) { $od = new OrderDetail(); $od->fromArray(array('product_id' => $item->getId(), 'order_id' => $order->id, 'quantity' => $item->getQuantity(), 'price' => $item->getPrice())); $od->save(); } if (sfConfig::get('app_send_order', false)) { dm::enableMailer(); //send mail $message = $this->getMailer()->compose($_from = dmConfig::get('orderEmail'), $_to = array($order->email, dmConfig::get('orderEmail')), $_subj = '[' . dmConfig::get('siteName') . '] thanks for order'); $message->setBody($this->getPartial('order/mailOrder', array('order' => $order, 'companyName' => dmConfig::get('companyName'), 'companyPhone' => dmConfig::get('companyPhone'), 'siteUrl' => dmConfig::get('siteUrl'), 'siteName' => dmConfig::get('siteName')))); $message->setContentType('text/html'); $this->getMailer()->send($message); } // if send order // clear cart now $shopping_cart->clear(); //redirect to order info $this->redirect($this->getHelper()->link('main/ordershow?uid=' . $order->uid)->getHref()); //$this->redirectBack(); } $this->forms['Order'] = $form; }
public function executeFormWidget(dmWebRequest $request) { $form = new ArticleForm(); if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) { $form->save(); $this->redirectBack(); } $this->forms['Article'] = $form; }
public function executeFormWidget(dmWebRequest $request) { $form = new bibliotecapersonalForm(); if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) { $form->save(); $this->getUser()->setFlash('formulario_valido', true); $this->redirectBack(); } $this->forms['bibliotecapersonal'] = $form; }
public function executeRecalc_cart(dmWebRequest $request) { $shopping_cart = $this->getUser()->getShoppingCart(); foreach ($shopping_cart->getItems() as $item) { if ($this->hasRequestParameter('quantity_' . $item->getId())) { $item->setQuantity($this->getRequestParameter('quantity_' . $item->getId())); } } if ($request->hasParameter('order')) { $this->redirect($this->getHelper()->link('main/order')->getHref()); } $this->redirectBack(); }
/** * @param dmWebRequest $request * */ public function executeImport(dmWebRequest $request) { $form = new ContactImportForm(); if ($request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); $form->bind($data, $request->getFiles($form->getName())); if ($form->isValid()) { //$form->save(); $this->getUser()->setFlash('contact_form_valid', true); $this->getService('dispatcher')->notify(new sfEvent($this, 'contact_import.saved', array('contact' => $form->getObject()))); $this->redirectBack(); } } $this->form = $this->forms['ContactImport']; }
/** * Handle dmUser/form form validation and creates the user account, then authenticates the user */ public function executeFormWidget(dmWebRequest $request) { $form = new DmUserForm(); if ($request->isMethod('post') && $request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); if ($form->isCaptchaEnabled()) { $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')))); } $form->bind($data, $request->getFiles($form->getName())); if ($form->isValid()) { $user = $form->save(); $this->getUser()->signin($user); $this->redirectRegisteredUser($request); } } $this->forms['DmUser'] = $form; }
public function executeFormWidget(dmWebRequest $request) { $form = new DmContactForm(); if ($request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); if ($form->isCaptchaEnabled()) { $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')))); } $form->bind($data, $request->getFiles($form->getName())); if ($form->isValid()) { $form->save(); $this->getUser()->setFlash('contact_form_valid', true); $this->getService('dispatcher')->notify(new sfEvent($this, 'dm_contact.saved', array('contact' => $form->getObject()))); $this->redirectBack(); } } $this->forms['DmContact'] = $form; }
public function executeRefreshStep(dmWebRequest $request) { if ($request->hasParameter('dm_use_thread')) { $this->getServiceContainer()->mergeParameter('page_tree_watcher.options', array('use_thread' => $request->getParameter('dm_use_thread')))->reload('page_tree_watcher'); } $this->step = $request->getParameter('step'); try { switch ($this->step) { case 1: @$this->getService('cache_manager')->clearAll(); if ($this->getUser()->can('system')) { @$this->getService('filesystem')->sf('dmFront:generate'); @dmFileCache::clearAll(); } $data = array('msg' => $this->getI18n()->__('Page synchronization'), 'type' => 'ajax', 'url' => $this->getHelper()->link('+/dmCore/refreshStep')->param('step', 2)->getHref()); break; case 2: $this->getService('page_tree_watcher')->synchronizePages(); $data = array('msg' => $this->getI18n()->__('SEO synchronization'), 'type' => 'ajax', 'url' => $this->getHelper()->link('+/dmCore/refreshStep')->param('step', 3)->getHref()); break; case 3: $this->getService('page_tree_watcher')->synchronizeSeo(); if (count($this->getI18n()->getCultures()) > 1) { $this->getService('page_i18n_builder')->createAllPagesTranslations(); } $data = array('msg' => $this->getI18n()->__('Interface regeneration'), 'type' => 'redirect', 'url' => $this->getUser()->getAttribute('dm_refresh_back_url')); $this->context->getEventDispatcher()->notify(new sfEvent($this, 'dm.refresh', array())); $this->getUser()->getAttributeHolder()->remove('dm_refresh_back_url'); $this->getUser()->logInfo('Project successfully updated'); break; } } catch (Exception $e) { $this->getUser()->logError($this->getI18n()->__('Something went wrong when updating project')); $data = array('msg' => $this->getI18n()->__('Something went wrong when updating project'), 'type' => 'redirect', 'url' => $this->getUser()->getAttribute('dm_refresh_back_url')); if (sfConfig::get('sf_debug')) { if ($request->isXmlHttpRequest()) { $data['url'] = str_replace('dm_xhr=1', 'dm_xhr=0', $request->getUri() . '&dm_use_thread=0'); } else { throw $e; } } } return $this->renderJson($data); }
/** * executes the Guestbook form * * @param dmWebRequest $request * */ public function executeFormWidget(dmWebRequest $request) { $form = $this->forms['AlGuestbook']; if ($request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); /* recaptcha field */ if ($form->isCaptchaEnabled()) { $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'tecaptcha_response_field' => $request->getParameter('recaptcha_response_field')))); } $form->bind($data, $request->getFiles($form->getName())); /* if the form is Valid -> save */ if ($form->isValid()) { $form->save(); /* confirmations message */ $this->getUser()->setFlash('guestbook_form_valid', true); /* set new al_guestbook.saved Event */ $this->getService('dispatcher')->notify(new sfEvent($this, 'al_guestbook.saved', array('guestbook' => $form->getObject()))); $this->redirectBack(); } } }
/** * Handle dmUser/form form validation and creates the user account, then authenticates the user */ public function executeFormWidget(dmWebRequest $request) { $form = new DmUserForm(); if ($request->isMethod('post') && $request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); // if the form uses captcha, include the additional data if ($form->isCaptchaEnabled()) { $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')))); } $form->bind($data, $request->getFiles($form->getName())); if ($request->isMethod('post') && $form->bindAndValid($request)) { $form->save(); $this->getUser()->setFlash('busqueda_form_valid', true); $this->redirectBack(); } if ($form->isValid()) { $user = $form->save(); $this->getUser()->signin($user); $this->redirectRegisteredUser($request); } } // pass the form to the component $this->forms['DmUser'] = $form; }
/** * Handle dmUser/forgotPassword form validation and sends an email with a new password */ public function executeForgotPasswordWidget(dmWebRequest $request) { // step 1 if (!($forgotPasswordCode = $request->getParameter('_code'))) { $form = new DmForgotPasswordStep1Form(); if ($request->isMethod('post') && $request->hasParameter($form->getName())) { $data = $request->getParameter($form->getName()); if ($form->isCaptchaEnabled()) { $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field')))); } $form->bind($data, $request->getFiles($form->getName())); if ($form->isValid()) { $user = $form->getUserByEmail($form->getValue('email')); $user->forgot_password_code = dmString::random(12); $user->save(); $this->getService('mail')->setTemplate('dm_user_forgot_password')->addValues(array('username' => $user->username, 'email' => $user->email, 'step2_url' => $this->getHelper()->link($this->getPage())->param('_code', $user->forgot_password_code)->getAbsoluteHref()))->send(); $this->getUser()->setFlash('dm_forgot_password_email_sent', $user->email); $this->redirectBack(); } } $this->forms['DmForgotPasswordStep1'] = $form; } else { $this->forward404Unless($user = dmDb::table('DmUser')->retrieveByForgotPasswordCode($forgotPasswordCode)); $form = new DmForgotPasswordStep2Form($user); if ($request->isMethod('post') && $request->hasParameter($form->getName())) { if ($form->bindAndValid($request)) { $user->password = $form->getValue('password'); $user->forgot_password_code = null; $user->save(); $this->getUser()->setFlash('dm_forgot_password_changed', true); $this->redirectBack(); } } $this->forms['DmForgotPasswordStep2'] = $form; } }
/** * Stores behavior id and copy action in clipboard */ public function executeCopy(dmWebRequest $request) { if (!$this->getUser()->can('behavior_add')) { return $this->renderError($this->getI18n()->__('Error'), $this->getI18n()->__('You do not have privileges to copy behavior')); } if ($request->hasParameter('dm_behavior_id')) { $behavior = DmBehaviorTable::getInstance()->findOneById($request->getParameter('dm_behavior_id')); if (!$behavior) { return $this->renderError($this->getI18n()->__('Error'), $this->getI18n()->__('The behavior that you are copying does not exist anymore')); } $this->getUser()->setAttribute('dm_behavior_clipboard', array('dm_behavior_clipboard_action' => 'copy', 'dm_behavior_id' => $behavior->getId()), 'dm.front_user_behavior_clipboard'); return $this->renderJson(array('error' => false)); } else { return $this->renderError($this->getI18n()->__('Error'), $this->getI18n()->__('You must supply behavior for copying')); } }
public function executeApprove(dmWebRequest $request) { $this->forward404Unless($request->isXmlHttpRequest()); $this->postId = $request->getParameter('post_id'); $this->postApproved = false; if ($request->hasParameter('approve')) { $post = DmForumPostTable::getInstance()->find($this->postId); $post->set('is_approved', true)->save(); $this->postApproved = true; } }
public function executeClearPageCache(dmWebRequest $request) { $pageCache = $this->getService('page_cache'); if ($request->hasParameter('cache')) { $pageCache->deleteCacheByKey($request->getParameter('cache')); } else { $pageCache->emptyCache(); } return $this->redirectBack(); }