예제 #1
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $params = $request->getParameter($form->getName());
     $this->forward404Unless($this->location = Doctrine::getTable('Location')->find(array($params['location_id'])), sprintf('Location does not exist (%s).', $params['location_id']));
     $form->bind($params);
     if ($form->isValid()) {
         $detailsData = (array) json_decode($form->getValue('details'));
         $photosData = (array) json_decode($form->getValue('photos'));
         print_r($photosData);
         die;
         $form->save()->updateDetails($detailsData)->updatePhotos($photosData);
         BotNet::create()->spammed($form->getObject(), 'description', $form->getObject()->getLocation()->getDateTimeObject('created_at')->format('U'));
         if ($cache = $this->getContext()->getViewCacheManager()) {
             $cache->remove('@sf_cache_partial?module=profit&action=_last&sf_cache_key=profit', '', 'all');
         }
         $this->redirect('profit/show?id=' . $form->getObject()->getId());
     } else {
         //            foreach ($form->getFormFieldSchema() as $name => $formField) {
         //                if ($formField->getError() != "") {
         //                    echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError();
         //                }
         //            }
     }
     return null;
 }
예제 #2
0
 /**
  *
  * @return BotNet 
  */
 public static function create()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #3
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $talk = $form->save();
         BotNet::create()->spammed($talk, 'message');
         $this->redirect('talk/show?id=' . $talk->getId());
     }
 }
예제 #4
0
 public function executeFor(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     //@todo: check component name input
     $componentName = $request->getParameter('component');
     $commentName = 'Comment' . $componentName;
     $formName = $commentName . 'Form';
     $form = new $formName();
     $toward = $form->getToward();
     $data = $request->getParameter($form->getName());
     $tree = Doctrine::getTable($commentName)->getTree();
     $tree->setBaseQuery(Doctrine_Query::create()->from($commentName . ' c')->where('c.' . $toward . '_id = ?', $data[$toward . '_id']));
     $form->bind($data, $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $root = $tree->fetchRoots()->getFirst();
         if (!$root) {
             $root = new $commentName();
             $root->message = 'root';
             $root[$toward . '_id'] = $data[$toward . '_id'];
             $root->parent = null;
             $root->save();
             $tree->createRoot($root);
             $getterCommented = "get{$componentName}";
             BotNet::create()->attachTo($root, BotNet::create()->getRandomBot(), $root->{$getterCommented}()->getDateTimeObject('created_at')->format('U'));
         }
         $parent = $root;
         if ($data['parent']) {
             $parent = Doctrine_Core::getTable('Comment')->find($data['parent']);
         }
         $data['parent'] = $parent->getId();
         $form->bind($data, $request->getFiles($form->getName()));
         $this->comment = $form->save();
         $this->comment->getNode()->insertAsLastChildOf($parent);
         $prevCom = $parent;
         if ($parent->message == 'root') {
             $sibling = $this->comment->getNode()->getPrevSibling();
             if ($sibling) {
                 $prevCom = $sibling;
             }
         }
         BotNet::create()->spammed($this->comment, 'message', $prevCom->getDateTimeObject('created_at')->format('U'));
         $this->noVote = $form->getValue('noVote', false);
         if ($cache = $this->getContext()->getViewCacheManager()) {
             $cache->remove('@sf_cache_partial?module=comment&action=_last&sf_cache_key=comment', '', 'all');
         }
         $this->setTemplate('created');
     } else {
         foreach ($form->getFormFieldSchema() as $name => $formField) {
             if ($formField->getError() != "") {
                 echo "ActionClassName::methodName( ): Field Error for :" . $name . " : " . $formField->getError();
             }
         }
     }
 }
예제 #5
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $params = $request->getParameter($form->getName());
     $this->forward404Unless($this->location = Doctrine::getTable('Location')->find(array($params['location_id'])), sprintf('Location does not exist (%s).', $params['location_id']));
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $fish_event = $form->save();
         BotNet::create()->spammed($fish_event, 'description');
         if ($cache = $this->getContext()->getViewCacheManager()) {
             $cache->remove('@sf_cache_partial?module=event&action=_last&sf_cache_key=event', '', 'all');
         }
         $this->redirect('@event_show?id=' . $fish_event->getId());
     }
 }
예제 #6
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()));
     if ($form->isValid()) {
         $addressData = (array) json_decode($form->getValue('address'));
         $photos = (array) json_decode($form->getValue('photos'));
         $loc = $form->save()->updateAddress($addressData)->updatePhotos($photos);
         BotNet::create()->spammed($loc, 'description');
         return $loc;
     }
     return null;
 }
예제 #7
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeAddbot(sfWebRequest $request)
 {
     $bn = BotNet::create();
     $lcoations = Doctrine_Query::create()->from('Location')->execute();
     foreach ($lcoations as $loc) {
         LuceneEngine::updateLuceneIndexFor($loc);
     }
 }