コード例 #1
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 public function executeEdit(dmWebRequest $request)
 {
     $this->forward404Unless($this->autoSeo = dmDb::table('DmAutoSeo')->find($request->getParameter('pk')));
     if (!$this->autoSeo->getTargetDmModule() instanceof dmProjectModule) {
         throw new dmException($this->autoSeo->getTargetDmModule() . ' is not a project module');
     }
     $this->form = new DmAutoSeoForm($this->autoSeo);
     if ($request->isMethod('post')) {
         $this->form->setSeoSynchronizer($this->getService('seo_synchronizer'));
         if ($this->form->bindAndValid($request)) {
             if ($request->getParameter('save')) {
                 $this->form->save();
                 $this->getUser()->logInfo('The item was updated successfully.');
                 return $this->redirectBack();
             } else {
                 $tryMode = true;
             }
         }
     }
     $this->previewRules = array();
     foreach ($this->form->getRules() as $ruleKey) {
         $this->previewRules[$ruleKey] = isset($tryMode) ? $this->form->getValue($ruleKey) : $this->form->getDefault($ruleKey);
     }
     $this->dispatcher->notify(new sfEvent($this, 'admin.edit_object', array('object' => $this->autoSeo)));
     $this->autoSeos = $this->getDmAutoSeos();
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: rafix/dmshop
 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;
 }
コード例 #3
0
 public function executeSaveFile(dmWebRequest $request)
 {
     // modify existing media
     if ($mediaId = dmArray::get($request->getParameter('dm_admin_media_form'), 'id')) {
         $this->forward404Unless($media = dmDb::table('DmMedia')->find($mediaId));
         $form = new DmAdminMediaForm($media);
     } else {
         $media = null;
         $this->forward404Unless($folder = dmDb::table('DmMediaFolder')->find($request->getParameter('folder_id')));
         if (!$folder->isWritable()) {
             $this->getUser()->logAlert($this->getI18n()->__('Folder %1% is not writable', array('%1%' => $folder->fullPath)));
         }
         $form = new DmAdminMediaForm();
         $form->setDefault('dm_media_folder_id', $folder->id);
     }
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $redirect = $form->getValue('file') || $media->dm_media_folder_id != $form->getValue('dm_media_folder_id');
         $media = $form->save();
         if ($redirect) {
             $this->getUser()->setFlash('dm_media_open', $media->id, false);
             return $this->renderText($this->getRouting()->getMediaUrl(dmDb::table('DmMediaFolder')->find($media->dm_media_folder_id)));
         }
     }
     $action = $media ? 'dmMediaLibrary/saveFile' : 'dmMediaLibrary/saveFile?folder_id=' . $folder->id;
     return $this->renderText($form->render('.dm_form.list.little action="' . $action . '"'));
 }
コード例 #4
0
 public function executeEdit(dmWebRequest $request)
 {
     $widget = $this->requireWidget();
     try {
         $widgetType = $this->getService('widget_type_manager')->getWidgetType($widget);
         $formClass = $widgetType->getFormClass();
         $form = new $formClass($widget);
     } catch (Exception $e) {
         if (sfConfig::get('dm_debug')) {
             throw $e;
         }
         return $this->renderError();
     }
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->updateWidget();
         if ($request->hasParameter('and_save')) {
             $widget->save();
             return $this->renderText('saved');
         }
         $widgetArray = $widget->toArrayWithMappedValue();
         try {
             $widgetRenderer = $this->getServiceContainer()->setParameter('widget_renderer.widget', $widgetArray)->getService('widget_renderer');
             $js = $widgetRenderer->getJavascripts();
             $css = $widgetRenderer->getStylesheets();
         } catch (Exception $e) {
             $js = $css = array();
         }
         return $this->renderAsync(array('html' => $this->renderEdit(new $formClass($widget), $widgetType, false) . dmString::ENCODING_SEPARATOR . $this->getService('page_helper')->renderWidget($widgetArray), 'js' => $js, 'css' => $css), true);
     }
     return $this->renderAsync(array('html' => $this->renderEdit($form, $widgetType, $request->isMethod('get')), 'js' => array_merge(array('lib.hotkeys'), $form->getJavascripts()), 'css' => $form->getStylesheets()), true);
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: jdart/diem
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = $this->forms['DmTestComment'];
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->save();
         $this->redirectBack();
     }
 }
コード例 #6
0
ファイル: actions.class.php プロジェクト: rafix/Diem-Dealr
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new ArticleForm();
     if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
         $form->save();
         $this->redirectBack();
     }
     $this->forms['Article'] = $form;
 }
コード例 #7
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new PluginCommentForm();
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->save();
         $this->redirectBack();
     }
     $this->forms['PluginComment'] = $form;
 }
コード例 #8
0
 public function executeCurrentVersion(dmWebRequest $request)
 {
     if ($branch = $request->getParameter('branch')) {
         $version = dmDb::pdo('SELECT v.number FROM version v INNER JOIN branch b ON v.branch_id = b.id AND b.number = ? WHERE v.is_active = ? ORDER BY v.position ASC LIMIT 1', array(str_replace(array('_', '-'), '.', $branch), true))->fetchColumn();
     } else {
         $version = dmDb::pdo('SELECT v.number FROM version v WHERE v.is_active = ? ORDER BY v.position ASC LIMIT 1', array(true))->fetchColumn();
     }
     return $this->renderText($version);
 }
コード例 #9
0
ファイル: actions.class.php プロジェクト: rafix/bibliocnic
 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;
 }
コード例 #10
0
 protected function getGalleryRecord(dmWebRequest $request)
 {
     $this->forward404Unless($record = dmDb::table($request->getParameter('model'))->find($request->getParameter('pk')), 'Record not found');
     $this->forward404Unless($module = $record->getDmModule(), 'Module not found');
     $this->forwardSecureUnless($this->getUser()->canAccessToModule($module));
     if (!$record->getTable()->hasTemplate('DmGallery')) {
         throw new dmException($record . ' should act as DmGallery');
     }
     return $record;
 }
コード例 #11
0
ファイル: actions.class.php プロジェクト: jdart/diem
 public function executeRevert(dmWebRequest $request)
 {
     $model = $request->getParameter('model');
     $pk = $request->getParameter('pk');
     $version = $request->getParameter('version');
     $this->forward404Unless($record = dmDb::table($model)->find($pk));
     $record->revert($version);
     $record->save();
     $this->getUser()->logInfo($this->getI18n()->__('%1% has been reverted to version %2%', array('%1%' => $record->__toString(), '%2%' => $version)));
     return $this->redirectBack();
 }
コード例 #12
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 public function executeSaveFile(dmWebRequest $request)
 {
     try {
         // disable warnings because they break json response
         @$this->getService('code_editor')->saveFile($request->getParameter('file'), $request->getParameter('code'));
     } catch (Exception $e) {
         return $this->renderJson(array('type' => 'error', 'message' => 'Save failed: ' . $e->getMessage()));
     }
     $this->getService('cache_cleaner')->clearTemplate();
     return $this->renderJson(array('type' => 'ok', 'message' => $this->getI18n()->__('Your modifications have been saved')));
 }
コード例 #13
0
ファイル: actions.class.php プロジェクト: rafix/bibliocnic
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new respuestaBusquedaForm();
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->save();
         $user = $this->getUser()->getDmUser();
         $this->getService('mail')->setTemplate('respuesta_busqueda')->addValues(array('busqueda_id' => $form->getValue('busqueda_id'), 'email' => $user->getEmail(), 'mensaje' => $form->getValue('mensaje'), 'username' => $user->getUsername(), 'nombre' => $user->getNombre(), 'apellidos' => $user->getApellidos(), 'create_at' => $form->getValue('create_at')))->send();
         $this->redirectBack();
     }
     $this->forms['respuestaBusqueda'] = $form;
 }
コード例 #14
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 public function executeIndex(dmWebRequest $request)
 {
     $setting = dmDb::table('DmSetting')->fetchOneByName('gwt_key');
     if ($this->getUser()->can($setting->get('credentials'))) {
         $this->form = new dmConfigForm();
         $this->form->addSetting($setting);
         if ($request->isMethod('post') && $this->form->bindAndValid($request)) {
             $this->form->save();
             return $this->redirect('@dm_google_webmaster_tools');
         }
     }
 }
コード例 #15
0
 public function executeToggleBoolean(dmWebRequest $request)
 {
     $this->forward404Unless($page = dmDb::table('DmPage')->find($request->getParameter('page_id')));
     $field = $request->getParameter('field');
     if ('is_active' === $field) {
         $page->setIsActiveManually(!$page->get($field));
     } else {
         $page->set($field, !$page->get($field));
     }
     $page->save();
     return $this->renderText($page->{$field} ? '1' : '0');
 }
コード例 #16
0
ファイル: actions.class.php プロジェクト: rafix/bibliocnic
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new busquedaForm();
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->save();
         $this->getUser()->setFlash('busqueda_form_valid', true);
         $user = $this->getUser()->getDmUser();
         $this->getService('mail')->setTemplate('solicitud_busqueda_especializada')->addValues(array('titulo' => $form->getValue('titulo'), 'email' => $user->getEmail(), 'mensaje' => $form->getValue('mensaje'), 'tematica' => $form->getValue('tematica'), 'fecha_antes' => $form->getValue('fecha_antes'), 'fecha_despues' => $form->getValue('fecha_despues'), 'nombre' => $user->getNombre(), 'apellidos' => $user->getApellidos()))->send();
         $this->redirectBack();
     }
     $this->forms['busqueda'] = $form;
 }
コード例 #17
0
ファイル: actions.class.php プロジェクト: rafix/bibliocnic
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new preguntaForm();
     if ($request->isMethod('post') && $form->bindAndValid($request)) {
         $form->save();
         $this->getUser()->setFlash('pregunta_form_valid', true);
         $user = $this->getUser()->getDmUser();
         $this->getService('mail')->setTemplate('pregunte_al_bibliotecario')->addValues(array('titulo' => $form->getValue('titulo'), 'email' => $user->getEmail(), 'mensaje' => $form->getValue('mensaje'), 'username' => $user->getUsername(), 'nombre' => $user->getNombre(), 'apellidos' => $user->getApellidos()))->send();
         $this->redirectBack();
     }
     $this->forms['pregunta'] = $form;
 }
コード例 #18
0
ファイル: actions.class.php プロジェクト: rafix/dmshop
 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();
 }
コード例 #19
0
 public function executeLoadMediaFolder(dmWebRequest $request)
 {
     $this->folder = null;
     if ($request->getParameter('folder_id')) {
         $this->folder = dmDb::table('DmMediaFolder')->find($request->getParameter('folder_id'));
     }
     if (!$this->folder) {
         $this->forward404Unless($this->folder = dmDb::table('DmMediaFolder')->checkRoot());
     }
     $this->folder->sync();
     $this->getUser()->setAttribute('dm_media_browser_folder_id', $this->folder->get('id'));
     return $this->renderPartial('mediaBarInner');
 }
コード例 #20
0
 public function executeUpdateFromGit(dmWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     $repoDir = sfConfig::get('sf_root_dir') . '/data/diem-docs';
     // include phpGitRepo
     require_once sfConfig::get('sf_root_dir') . '/lib/vendor/php-git-repo/lib/phpGitRepo.php';
     // create a git repo instance
     $repo = new phpGitRepo($repoDir);
     // run the synchronizer passing it the repo instance
     $synchronizer = new gitDocumentationSynchronizer($repo);
     $synchronizer->execute();
     $this->getService('cache_cleaner')->setOption('applications', array('front'))->clearTemplate();
     return $this->renderText('done');
 }
コード例 #21
0
 public function executeDownload(dmWebRequest $request)
 {
     $this->forward404Unless($versionNumber = $request->getParameter('v'));
     $this->forward404Unless($version = dmDb::table('Version')->findOneByNumber($versionNumber));
     $this->forward404Unless($package = $version->Package);
     $this->forward404Unless($package->exists());
     $fileName = sprintf('diem-%s%s', $version->number, dmOs::getFileExtension($package->fullPath));
     $this->getService('event_log')->setOption('enabled', false);
     $version->mapValue('disable_versioning', true);
     $version->downloads = $version->downloads + 1;
     $version->save();
     $this->context->getEventDispatcher()->notify(new sfEvent($this, 'download.package', array('version' => $version->number)));
     return $this->download($package->fullPath, array('file_name' => $fileName));
 }
コード例 #22
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new SnippetCommentForm();
     if ($request->isMethod('post')) {
         $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
         $form->bind(array_merge($request->getParameter($form->getName()), array('captcha' => $captcha)));
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('form_saved', true);
             $this->redirectBack();
         }
     }
     $this->forms['SnippetComment'] = $form;
 }
コード例 #23
0
 public function executeRefresh(dmWebRequest $request)
 {
     $data = array();
     $nbEntries = array('request' => 8, 'event' => 8, 'static' => 8);
     foreach (array('static', 'request', 'event') as $logKey) {
         $log = $this->getService($logKey . '_log');
         $view = $this->getServiceContainer()->setParameter('log_view.class', get_class($log) . 'ViewLittle')->setParameter('log_view.log', $log)->getService('log_view')->setMax($nbEntries[$logKey]);
         $hash = $view->getHash();
         if ($hash != $request->getParameter($logKey[0] . 'h')) {
             $data[$logKey] = array('hash' => $hash, 'html' => $view->renderBody($nbEntries));
         }
     }
     return $this->renderJson($data);
 }
コード例 #24
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 public function executeMove(dmWebRequest $request)
 {
     $this->forward404Unless($module = $this->context->getModuleManager()->getModuleOrNull($request->getParameter('dm_module')));
     $this->forward404Unless($module instanceof dmProjectModule && $module->getTable() instanceof dmDoctrineTable && $module->getTable()->isNestedSet());
     $this->forward404Unless($model = $module->getTable()->find($request->getParameter('model')));
     if ($nextToModel = $module->getTable()->find($request->getParameter('previous'))) {
         $model->Node->moveAsNextSiblingOf($nextToModel);
     } elseif ($inModel = $module->getTable()->find($request->getParameter('to'))) {
         $model->Node->moveAsFirstChildOf($inModel);
     } else {
         $this->forward404('Bad operation');
     }
     return $this->renderText('ok');
 }
コード例 #25
0
 /**
  * @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'];
 }
コード例 #26
0
 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;
     }
 }
コード例 #27
0
ファイル: actions.class.php プロジェクト: jdart/diem
 public function executeIndex(dmWebRequest $request)
 {
     $this->engine = $this->getService('search_engine');
     $this->form = $this->getSearchForm();
     if ($this->query = trim($request->getParameter('query'))) {
         $this->form->bind(array('query' => $this->query));
         $this->pager = $this->getSearchPager($this->query);
     } else {
         $this->pager = null;
     }
     if ($this->getUser()->can('system')) {
         $this->shellUser = dmConfig::canSystemCall() ? exec('whoami') : 'www-data';
         $this->phpCli = dmConfig::canSystemCall() ? sfToolkit::getPhpCli() : '/path/to/php';
         $this->rootDir = sfConfig::get('sf_root_dir');
     }
 }
コード例 #28
0
 public function executeShowWidget(dmWebRequest $request)
 {
     $form = new PluginCommentForm();
     if ($request->isMethod('post') && ($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);
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('form_saved', true);
             $this->redirectBack();
         }
     }
     $this->forms['PluginComment'] = $form;
 }
コード例 #29
0
 public function executeInit(dmWebRequest $request)
 {
     $this->forward404Unless($branch = dmDb::table('Branch')->findOneById($request->getParameter('pk')));
     $this->forward404Unless($fromBranch = dmDb::table('Branch')->findOneById($request->getParameter('from')));
     $branch->Docs->delete();
     foreach ($fromBranch->Docs as $doc) {
         $newDoc = dmDb::table('Doc')->create(array('branch_id' => $branch->id, 'name' => $doc->name, 'type' => $doc->type, 'resume' => $doc->resume, 'is_active' => $doc->is_active))->saveGet();
         $newDoc->position = $doc->position + 1000;
         $newDoc->save();
         foreach ($doc->Pages as $docPage) {
             $newDocPage = dmDb::table('DocPage')->create(array('doc_id' => $newDoc->id, 'name' => $docPage->name, 'resume' => $docPage->resume, 'is_active' => $docPage->is_active, 'is_done' => $docPage->is_done, 'position' => $docPage->position + 1000))->saveGet();
             $newDocPage->position = $docPage->position + 1000;
             $newDocPage->setTags($docPage->getTagsString())->save();
         }
     }
     $this->redirectBack();
 }
コード例 #30
0
 public function executeSignin(dmWebRequest $request)
 {
     if ($this->getUser()->isAuthenticated()) {
         return $this->redirect('@homepage');
     }
     $this->setLayout(realpath(dirname(__FILE__) . '/..') . '/templates/layout');
     if ($request->getParameter('skip_browser_detection')) {
         $this->getService('browser_check')->markAsChecked();
     } elseif (!$this->getService('browser_check')->check()) {
         return 'Browser';
     }
     $this->form = new DmSigninAdminForm();
     if ($request->isMethod('post')) {
         $this->form->bindRequest($request);
         if ($this->form->isValid()) {
             $this->getUser()->signin($this->form->getValue('user'), $this->form->getValue('remember'));
             if ($this->getUser()->can('admin')) {
                 $redirectUrl = $this->getUser()->getReferer($request->getReferer());
                 $this->redirect($redirectUrl ? $redirectUrl : '@homepage');
             } else {
                 try {
                     $this->redirect($this->getService('script_name_resolver')->get('front'));
                 } catch (dmException $e) {
                     // user can't go in admin, and front script_name can't be found.
                     $this->redirect('@homepage');
                 }
             }
         }
     } else {
         if ($request->isXmlHttpRequest()) {
             $this->getResponse()->setHeaderOnly(true);
             $this->getResponse()->setStatusCode(401);
             return sfView::NONE;
         }
         // if we have been forwarded, then the referer is the current URL
         // if not, this is the referer of the current request
         $this->getUser()->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
         $module = sfConfig::get('sf_login_module');
         if ($this->getModuleName() != $module) {
             return $this->redirect($module . '/' . sfConfig::get('sf_login_action'));
         }
         $this->getResponse()->setStatusCode(401);
     }
 }