Example #1
0
 public function executePaymentSuccess(sfWebRequest $request)
 {
     $payment_type = $request->getParameter('type');
     /** @var sfGuardUser $user */
     $user = $this->getUser()->getGuardUser();
     /** @var PaymentTransaction $payment */
     $payment = $user->getLastNotPayedTransaction($payment_type);
     $gtw = new PaypalGateway(array('amount' => $payment->amount, 'success_url' => $this->generateUrl('payment\\success', array('type' => $payment_type)), 'cancel_url' => $this->generateUrl('payment\\cancel'), 'token' => $request->getParameter('token'), 'payer_id' => $request->getParameter('PayerID')));
     $res = $gtw->doExpressCheckout();
     if ($res) {
         $payment->is_payed = true;
         $payment->date_payed = date('Y-m-d H:i:s');
         $payment->status_code = 'success';
         $payment->stamp = $request->getParameter('PayerID');
         $payment->save();
         $user->account_type = $payment->type;
         $user->credit = $payment->type == 'basic' ? 12 : -1;
         $user->last_payment_date = date('Y-m-d H:i:s');
         $user->save();
         $this->getUser()->setFlash('notice', 'The payment is accepted, thank you!');
     } else {
         $this->getUser()->setFlash('error', 'PayPal connection error');
     }
     $this->redirect('/project/user/account');
 }
 public function executeSave_slots(sfWebRequest $request)
 {
     $this->contentSlots = array();
     $this->failedContentSlots = array();
     $this->errors = array();
     $slotIds = $request->getParameter('slot_ids');
     $contentIds = $request->getParameter('content_ids');
     foreach ($slotIds as $slotId) {
         $content = Doctrine_Core::getTable('sfSympalContent')->find($contentIds[$slotId]);
         $contentSlot = Doctrine_Core::getTable('sfSympalContentSlot')->find($slotId);
         $contentSlot->setContentRenderedFor($content);
         $form = $contentSlot->getEditForm();
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             if ($request->getParameter('preview')) {
                 $form->updateObject();
             } else {
                 $form->save();
             }
             $this->contentSlots[] = $contentSlot;
         } else {
             $this->failedContentSlots[] = $contentSlot;
             foreach ($form as $name => $field) {
                 if ($field->hasError()) {
                     $this->errors[$contentSlot->getName()] = $field->getError();
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Ajax method. Returns JSON data.
  * @param sfWebRequest $request
  */
 public function executeSelect(sfWebRequest $request)
 {
     $this->getResponse()->addCacheControlHttpHeader('no-cache');
     $this->getResponse()->setContentType('application/json');
     $this->getResponse()->sendHttpHeaders();
     $group = $request->getParameter('group');
     $type = $request->getParameter('type');
     $amps = $request->getParameter('amps');
     $choices_made = array();
     if (intval($group) != -1) {
         $choices_made['grp'] = $group;
     }
     if (intval($type) != -1) {
         $choices_made['frame_type'] = $type;
     }
     if (intval($amps) != -1) {
         $choices_made['amps'] = $amps;
     }
     $manuf_id = intval($request->getParameter('manuf_id'));
     $category = new BUCategory();
     $dependent_dropdowns = $category->fetchSelectionCriteriaByManuf($manuf_id, $choices_made);
     $matching_parts = $category->fetchMatchingParts($manuf_id, $choices_made);
     $json_data = json_encode(array_merge($dependent_dropdowns, $matching_parts));
     return $this->renderText($json_data);
 }
 public function executeActivityBox(sfWebRequest $request)
 {
     $id = $request->getParameter('id', $this->getUser()->getMemberId());
     $this->activities = Doctrine::getTable('ActivityData')->getActivityList($id, null, $this->gadget->getConfig('row'));
     $this->member = Doctrine::getTable('Member')->find($id);
     $this->isMine = $id == $this->getUser()->getMemberId();
 }
Example #5
0
    public function executeIndex(sfWebRequest $request) {
        if ($request->isMethod('post')){
            $from = $request->getParameter('From');
            
            if (!Utils::isEmptyStr($from)){
                if (Utils::startsWith($from, "+1")) $from = substr($from, 2);

                //look up the user by phone number
                $guardUser = Doctrine::getTable('SfGuardUser')->findOneByPhone($from);
                if ($guardUser){
		        //get the last response
		        $response = Doctrine::getTable('BlastResponse')->createQuery()->where('user_id = ?', $guardUser->getId())
		                ->orderBy('updated_at desc')->fetchOne();

		        if ($response) {
				$this->redirect('phoneResponse/intro?responseId=' . $response->getId());
		        }
		}
            }
       }
?>
<Response>
     <Say>Thanks for calling Make A Minyan dot com.  Please visit us online at Make A Minyan dot com.  Thank you!  Goodbye.</Say>
     <Hangup />
</Response>
<?
       return sfView::NONE;
    }
Example #6
0
 public function executeJoin(sfWebRequest $request)
 {
     $eventId = $request['id'];
     $this->forward400If(!$this->isAllowed($this->event, $this->getUser()->getMember(), 'addComment'), 'You are not allowed to join this event');
     $eventMember = Doctrine::getTable('CommunityEventMember')->retrieveByEventIdAndMemberId($eventId, $this->member->getId());
     $flag = $request->getParameter('leave');
     if ($flag && 'true' === $flag) {
         if (!$eventMember) {
             $this->forward400('You can\'t leave this event.');
         }
         if ($this->event->isClosed()) {
             $this->forward400('This event has already been finished.');
         }
         if ($this->event->isExpired()) {
             $this->forward400('This event has already been expired.');
         }
         $eventMember->delete();
     } else {
         try {
             if ($eventMember) {
                 throw new opCommunityTopicAPIRuntimeException('You are already this event member.');
             }
             $this->event->toggleEventMember($this->member->getId());
         } catch (RuntimeException $e) {
             $this->forward400($e->getMessage());
         }
     }
 }
Example #7
0
 public function executeDownloadDocument(sfWebRequest $request)
 {
     $student_disciplinary_sanction = StudentDisciplinarySanctionPeer::retrieveByPK($request->getParameter('id'));
     if ($student_disciplinary_sanction && $student_disciplinary_sanction->getDocument()) {
         $filePath = $student_disciplinary_sanction->getDocumentFullPath();
         $response = $this->getResponse();
         $response->setHttpHeader('Pragma', '');
         $response->setHttpHeader('Cache-Control', '');
         $data = file_get_contents($filePath);
         $file_exploded = explode('.', $student_disciplinary_sanction->getDocument());
         $file_extension = end($file_exploded);
         if ($file_extension == 'pdf') {
             $response->setHttpHeader('Content-Type', 'application/pdf');
         } else {
             if ($file_extension == 'jpg') {
                 $content_type = 'jpeg';
             } else {
                 $content_type = $file_extension;
             }
             $response->setHttpHeader('Content-Type', 'image/' . $content_type);
         }
         $response->setHttpHeader('Content-Disposition', "attachment; filename=\"" . $student_disciplinary_sanction->getDocument() . "\"");
         $response->setContent($data);
     }
     return sfView::NONE;
 }
Example #8
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->album->delete();
     $this->getUser()->setFlash('notice', 'The album was deleted successfully.');
     $this->redirect('album/list');
 }
Example #9
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));
     //On récupère l'image source
     $imgSource = $this->getRoute()->getObject()->getFichierSource();
     //Ainsi que le dossier qui la contient
     $uploadFolder = sfConfig::get('app_images_upload_dir');
     //On en déduit son nom est son extension
     $filename = substr($imgSource, 0, strrpos($imgSource, '.'));
     $extension = substr(strrchr($imgSource, '.'), 1);
     //On supprime l'image de base
     unlink($uploadFolder . $imgSource);
     //Puis pour chacune des tailles prédefinies à laquelle l'image a pu être redimensionnée
     foreach (convertImageToThumb::$predefinedSizes as $suffix => $infos) {
         //On supprime aussi le bon fichier
         unlink($uploadFolder . $filename . "_" . $suffix . "." . $extension);
     }
     $this->getRoute()->getObject()->delete();
     //$this->getUser()->setFlash('notice', 'The item was deleted successfully.');
     $this->json['success'] = true;
     $this->setRequestParameter('json', $this->json);
     $this->forward($this->getModuleName(), 'jsonResponse');
     //$this->redirect('@illustration');
 }
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         try {
             $peticion = $form->save();
             $aux = Doctrine_Query::create()->from('sfGuardUser s')->where('s.email_address = ?', $peticion->getEmailAddress());
             $aux1 = $aux->fetchOne();
             if (!$aux1) {
                 $auxU = Doctrine_Query::create()->from('sfGuardUser s')->where('s.username = ?', $peticion->getUsername());
                 $auxU1 = $auxU->fetchOne();
                 if (!$auxU1) {
                     $this->redirect('peticion/notificacion');
                 } else {
                     $peticion->delete();
                     $this->getUser()->setFlash('error', 'El nombre de usuario "' . $peticion->getUsername() . '" no esta disponible.', false);
                 }
             } else {
                 $peticion->delete();
                 $this->getUser()->setFlash('error', 'El correo electrónico "' . $peticion->getEmailAddress() . '" ya se encuentra registrado.', false);
             }
         } catch (Exception $e) {
             $this->getUser()->setFlash('error', 'El correo electrónico ingresado ya se encuentra registrado.', false);
         }
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!$request->hasParameter('page')) {
         //$this->forward404();
     }
     $this->page = $request->getParameter('page');
 }
Example #12
0
 public function executeImage(sfWebRequest $request)
 {
     $member = $this->getRoute()->getMember();
     if (!$member) {
         return sfView::NONE;
     }
     $community = Doctrine::getTable('Community')->find($request->getParameter('id'));
     if (!$community) {
         return sfView::ERROR;
     }
     $isAdmin = Doctrine::getTable('CommunityMember')->isAdmin($member->getId(), $community->getId());
     if (!$isAdmin || $community->getImageFileName()) {
         return sfView::ERROR;
     }
     $message = $request->getMailMessage();
     if ($images = $message->getImages()) {
         $image = array_shift($images);
         $validator = new opValidatorImageFile();
         $validFile = $validator->clean($image);
         $file = new File();
         $file->setFromValidatedFile($validFile);
         $file->setName('c_' . $community->getId() . '_' . $file->getName());
         $community->setFile($file);
         $community->save();
     }
     return sfView::NONE;
 }
Example #13
0
 public function executeGuardar(sfWebRequest $request)
 {
     $this->datos = $request->getParameter('datos');
     $unidadeducativa = Doctrine::getTable('SdatRueUnidadEducativa')->find(array($this->datos['codue'], $this->datos['subcea'], $this->datos['periodo']));
     if ($unidadeducativa) {
         $conn = Doctrine_Manager::connection();
         $conn->beginTransaction();
         try {
             $unidadeducativa->setTelefono1($this->datos['telefono1']);
             $unidadeducativa->setTelefono2($this->datos['telefono2']);
             $unidadeducativa->setReferenciaTelefono2($this->datos['referenciatelefono2']);
             $unidadeducativa->setFax($this->datos['fax']);
             $unidadeducativa->setEmail($this->datos['email']);
             $unidadeducativa->setCasilla($this->datos['casilla']);
             $unidadeducativa->setCiDirector($this->datos['cidirector']);
             $unidadeducativa->setDirector($this->datos['director']);
             $unidadeducativa->setItemDirector($this->datos['itemdirector']);
             $unidadeducativa->setCodCerradaId($this->datos['cerrada']);
             if ($this->datos['turno'] == '-999') {
                 $unidadeducativa->setTurnoId('0');
             } else {
                 $unidadeducativa->setTurnoId($this->datos['turno']);
             }
             $unidadeducativa->setFechaConsolidacion(date('Y-m-d H:i:s'));
             $unidadeducativa->save();
             $conn->commit();
             $this->getUser()->setFlash('notice_error', "SE CREO CORRECTAMENTE");
             $this->redirect('cea_crear_inicio/index');
         } catch (Doctrine_Exception $e) {
             $conn->rollback();
             $this->getUser()->setFlash('notice_error', "ERROR AL CREAR INICIO DE GESTION DEL CEA");
             $this->redirect('cea_crear_inicio/index');
         }
     }
 }
Example #14
0
 public function executeDetails(sfWebRequest $request) {
   $this->forward404Unless($presta_id = $request->getParameter('id'));
   $this->presta = PrestaTable::getInstance()->find($presta_id);
   $this->gmap = new GMap();
   $this->gmap->addMarker(new GMapMarker($this->presta->getLatitude(), $this->presta->getLongitude()));
   $this->gmap->centerAndZoomOnMarkers();
 }
Example #15
0
 public function executeSave(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $invoices = (array) $request->getParameter('invoices', array());
     $estimates = (array) $request->getParameter('estimates', array());
     // check that there is only one template for each one
     if (count($invoices) > 1 || count($estimates) > 1) {
         $this->getUser()->error($this->getContext()->getI18N()->__('There must be only one template for model.'));
         $this->redirect('@templates');
     }
     $templates = Doctrine::getTable('Template')->createQuery()->execute();
     foreach ($templates as $t) {
         $models = array();
         if (in_array($t->getId(), $invoices)) {
             $models[] = 'Invoice';
         }
         if (in_array($t->getId(), $estimates)) {
             $models[] = 'Estimate';
         }
         $t->setModels(implode(',', $models));
         $t->save();
     }
     $this->getUser()->info($this->getContext()->getI18N()->__('Successfully saved.'));
     $this->redirect('@templates');
 }
Example #16
0
 public function executeI18nForm(sfWebRequest $request)
 {
     $this->form = new I18nForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('i18n'));
     }
 }
Example #17
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     // Download the image
     $url = $request->getParameter("url");
     $remote_file = $url;
     //urldecode( $url );
     //$remote_file   = "/Users/robbymillsap/Sites/eventflo.dev/web/images/myface.jpg";
     $remote_handle = fopen($remote_file, "r");
     $temp = tempnam(sfConfig::get('sf_upload_dir'), 'Img') . '.jpg';
     $temp_handle = fopen($temp, "w");
     while ($cline = fgets($remote_handle)) {
         fwrite($temp_handle, $cline);
     }
     fclose($temp_handle);
     fclose($remote_handle);
     //$url_to_tmp = realpath(dirname($temp));
     // Process the image
     /*
           $path = sfConfig::get('sf_upload_dir') . '/';
           $src  = "myface.jpg";
           $new  = "myface.jpg";
     *
     */
     // Run image magick
     $cmd = "convert {$temp} -resize " . $request->getParameter("size") . " " . $temp;
     shell_exec($cmd);
     // show image
     $this->showImage($temp);
     shell_exec("rm {$temp}");
     return sfView::NONE;
 }
Example #18
0
 protected function processForm(sfWebRequest $request, sfForm $form)
 {
     $parameters = $request->getParameter($form->getName());
     $form->bind($parameters, $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getContext()->getConfiguration()->loadHelpers('Number');
         // On crée la transaction correspondante
         $transaction = new Transaction();
         $transaction->asso_id = $parameters['asso_id'];
         $transaction->compte_id = $parameters['compte_id'];
         $transaction->libelle = 'Remboursement ' . $parameters['nom'];
         $transaction->commentaire = "Remboursement des achats suivants :\n";
         // Voir ci-dessous
         $transaction->montant = 0;
         // On fera le total plus tard !
         $transaction->date_transaction = date('Y-m-d');
         $transaction->moyen_id = $parameters['moyen_id'];
         $transaction->moyen_commentaire = $parameters['moyen_commentaire'];
         $transaction->save();
         $form->setValue('transaction_id', $transaction->getPrimaryKey());
         $note_de_frais = $form->save();
         foreach ($parameters['transactions'] as $transaction_id) {
             $transaction2 = $note_de_frais->addAchatFromId($transaction_id);
             $transaction->commentaire .= $this->format_transaction($transaction2) . "\n";
         }
         $transaction->save();
         $this->redirect('ndf', $note_de_frais->getAsso());
     }
 }
Example #19
0
 /**
  * ajax action for customer name autocompletion
  *
  * @return JSON
  * @author Enrique Martinez
  **/
 public function executeAjaxCustomerAutocomplete(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $q = $request->getParameter('q');
     $items = Doctrine::getTable('Customer')->simpleRetrieveForSelect($request->getParameter('q'), $request->getParameter('limit'));
     return $this->renderText(json_encode($items));
 }
Example #20
0
 public function executeCommand(sfWebRequest $request)
 {
     $command = trim($request->getParameter("dm_command"));
     if (substr($command, 0, 2) == "sf") {
         $command = substr($command, 3);
         $exec = sprintf('%s "%s" %s --color', sfToolkit::getPhpCli(), dmProject::getRootDir() . '/symfony', $command);
     } else {
         $options = substr(trim($command), 0, 2) == 'll' || substr(trim($command), 0, 2) == 'ls' ? '--color' : '';
         $parts = explode(" ", $command);
         $parts[0] = dmArray::get($this->getAliases(), $parts[0], $parts[0]);
         $command = implode(" ", $parts);
         $parts = explode(" ", $command);
         $command = dmArray::get($this->getAliases(), $command, $command);
         if (!in_array($parts[0], $this->getCommands())) {
             return $this->renderText(sprintf("%s<li>This command is not available. You can do: <strong>%s</strong></li>", $this->renderCommand($command), implode(' ', $this->getCommands())));
         }
         $exec = sprintf("%s {$options}", $command);
     }
     ob_start();
     passthru($exec . ' 2>&1', $return);
     $raw = dmAnsiColorFormatHtmlRenderer::render(ob_get_clean());
     $arr = explode("\n", $raw);
     $res = $this->renderCommand($command);
     foreach ($arr as $a) {
         $res .= "<li class='dm_result_command'><pre>" . $a . "</pre></li>";
     }
     return $this->renderText($res);
 }
 public function executeSidebar(sfWebRequest $request)
 {
     $route = sfContext::getInstance()->getRouting()->getCurrentRouteName();
     $this->route = $route;
     $id = $request->getParameter('catalogId');
     $stm = Propel::getConnection()->prepare('
         SELECT title,id FROM category WHERE parent_id=4
     ');
     $stm->execute();
     $menu = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->menu = $menu;
     $stm = Propel::getConnection()->prepare('
         SELECT
             title,id
         FROM
             category_has_product
         INNER JOIN product ON product.id = category_has_product.product_id
         WHERE
             category_has_product.category_id = :id
     ');
     $stm->bindParam(':id', $id);
     $stm->execute();
     $product = $stm->fetchAll(PDO::FETCH_OBJ);
     $this->product = $product;
 }
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->hasParameter('object_id') && $request->hasParameter('object_class')) {
         $this->object = Doctrine::getTable($request->getParameter('object_class'))->find($request->getParameter('object_id'));
     }
     $this->setLayout(false);
 }
 public function executeUndo_tree_ajax(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $id_tree = $request->getParameter('treeId');
     $production = $request->getParameter('production');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree = TreeScPeer::retrieveByPK($id_tree);
         if (is_object($tree)) {
             //si es el dueño del arbol
             if ($tree->getUserId() == $user->getId()) {
                 $tree->setFlag(1);
                 if ($production == 'production') {
                     $tree->setProduccion('production');
                 }
                 $tree->save();
                 return sfView::SUCCESS;
             } else {
                 $this->message = 'owner not found';
                 return sfView::ERROR;
             }
         } else {
             $this->message = 'objet not found';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expird';
         return sfView::ERROR;
     }
 }
Example #24
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeLoad(sfWebRequest $request)
  {
    $this->setLayout(false);
    $this->getResponse()->setContent('text/javascript');
    $this->setTemplate($request->getParameter('filename'));
    return ".js".chr(0);
  }
Example #25
0
 public function executeUpload(sfWebRequest $request)
 {
     $language = LanguageTable::getInstance()->find($request->getParameter('id'));
     /* @var $language Language */
     if (!$language) {
         return $this->notFound();
     }
     if ($request->getPostParameter('csrf_token') == UtilCSRF::gen('language_upload', $language->getId())) {
         $this->ajax()->setAlertTarget('#upload', 'append');
         $file = $request->getFiles('file');
         if ($file && $file['tmp_name']) {
             $parser = new sfMessageSource_XLIFF();
             if ($parser->loadData($file['tmp_name'])) {
                 $dir = dirname($language->i18nFileWidget());
                 if (!file_exists($dir)) {
                     mkdir($dir);
                 }
                 move_uploaded_file($file['tmp_name'], $language->i18nFileWidget());
                 $language->i18nCacheWidgetClear();
                 return $this->ajax()->alert('Language file updated.', '', null, null, false, 'success')->render(true);
             }
             return $this->ajax()->alert('File invalid.', '', null, null, false, 'error')->render(true);
         }
         return $this->ajax()->alert('Upload failed.', '', null, null, false, 'error')->render(true);
     }
     return $this->notFound();
 }
Example #26
0
 public function executeShow(sfWebRequest $request)
 {
     $p = $request->getParameter('page', 'unavailable');
     $this->title = sfConfig::get('app_message_with_layout_' . $p . '_title');
     $this->text = sfConfig::get('app_message_with_layout_' . $p . '_text');
     sfConfig::set('sf_web_debug', false);
 }
Example #27
0
 public function executeIndex(sfWebRequest $request)
 {
     app::setPageTitle('Gantt Chart', $this->getResponse());
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('view', false, $this->projects);
     } else {
         $this->checkTasksAccess('view');
     }
     if (!$this->getUser()->hasAttribute('gantt_filter' . $this->get_pid($request))) {
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), Tasks::getDefaultFilter($request, $this->getUser(), 'ganttChart'));
     }
     $this->filter_by = $this->getUser()->getAttribute('gantt_filter' . $this->get_pid($request));
     if ($fb = $request->getParameter('filter_by')) {
         $this->filter_by[key($fb)] = current($fb);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     if ($request->hasParameter('remove_filter')) {
         unset($this->filter_by[$request->getParameter('remove_filter')]);
         $this->getUser()->setAttribute('gantt_filter' . $this->get_pid($request), $this->filter_by);
         $this->redirect('ganttChart/index' . $this->add_pid($request));
     }
     $this->tasks_tree = array();
     $this->tasks_list = $this->getTasks($request, $this->tasks_tree);
 }
 public function executeInterface(sfWebRequest $request)
 {
     $this->form = new interfaceSettingsForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $interface = array();
             $bdd = unserialize(peanutConfig::get('interface'));
             foreach ($this->form->getValues() as $name => $value) {
                 if ($name == 'logo' || $name == 'background') {
                     if ($value) {
                         $extension = $value->getExtension($value->getOriginalExtension());
                         $value->save(sfConfig::get('sf_upload_dir') . '/admin/' . $value->getOriginalName());
                         $interface[$name] = $value->getOriginalName();
                     } else {
                         $interface[$name] = $bdd[$name];
                     }
                 } else {
                     $interface[$name] = $value;
                 }
             }
             peanutConfig::set('interface', serialize($interface));
         }
     }
 }
 public function executeCreate_tree(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $title = $request->getParameter('item_title');
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         try {
             $conn = Propel::getConnection();
             $conn->beginTransaction();
             $tree_bean = new TreeSc();
             $tree_bean->setName($title);
             $tree_bean->setUserId($user->getId());
             $tree_bean->setConfigureFlag('');
             $tree_bean->setConfigureDesign('');
             $tree_bean->setFlag(1);
             $tree_bean->save();
             $tree_user_bean = new TreeUser();
             $tree_user_bean->setUserId($tree_bean->getUserId());
             $tree_user_bean->setTreeId($tree_bean->getId());
             $tree_user_bean->save();
             $conn->commit();
             $this->message = 'success';
             $this->treepk = $tree_bean->getId();
             $this->title = $tree_bean->getName();
             return sfView::SUCCESS;
         } catch (Exception $e) {
             $this->message = $e->getMessage();
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         return sfView::ERROR;
     }
 }
Example #30
0
 public function executeTest(sfWebRequest $request)
 {
     $sfGuardUser = $request->getParameter('sfGuardUser');
     $sfOauthConsumer = $request->getParameter('sfOauthConsumer');
     $this->infos = array('userId' => $sfGuardUser ? $sfGuardUser->getId() : null, 'consumerId' => $sfOauthConsumer->getId());
     //return $this->renderText(json_encode($this->infos));
 }