/**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if (!($request->getHost() == gcr::rootDomainName || $request->getHost() == gcr::domainName)) {
         global $CFG;
         $this->redirect($CFG->current_app->getAppUrl());
     }
     $this->getResponse()->setTitle('Global Classroom - Cloud-based, private social network and eLearning Platform');
     $this->getResponse()->addMeta('description', 'Global Classroom provides a cloud-based private social and elearning platform for business, education, ' . 'government, non-profits, and membership organizations.');
 }
示例#2
0
 private function AddComment(sfWebRequest $request)
 {
     $text = $request->getParameter('comment_text');
     if ($request->isMethod("GET")) {
         $text = urldecode($text);
     }
     if ($this->getRequestParameter('comment_picture_url')) {
         $filename = jrFileUploader::UploadRemote($request->getParameter('comment_picture_url'));
         if ($text) {
             $text .= "<br/>";
         }
         $text .= "<img src='http://" . $request->getHost() . "/uploads/" . $filename . "' />";
     }
     if (!trim($text)) {
         return;
     }
     sfApplicationConfiguration::getActive()->loadHelpers(array('Parse', 'Text', 'Tag', 'I18N', 'Url'));
     $user = $this->getUser()->getGuardUser();
     $comment = new PostComment();
     $comment->setUser($user);
     $comment->setPost($this->post);
     if ($this->parent) {
         $comment->setParent($this->parent);
     }
     $comment->setComment(parsetext($text));
     $comment->setCommentOriginal($text);
     $comment->save();
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser) {
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId(), $this->post->getAllComments('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "comments" . $this->post->getId() . "Time", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
     }
 }
 public function getHost()
 {
     $result = parent::getHost();
     if (!$result) {
         $result = parse_url(sfConfig::get('op_base_url'), PHP_URL_HOST);
     }
     return $result;
 }
示例#4
0
 /**
  * Executes index action
  */
 public function executeIndex(sfWebRequest $r)
 {
     // If we aren't auth and when it's allowed, display register form
     if (!$this->getUser()->isAuthenticated() && sfConfig::get("app_register")) {
         $this->regform = new RegisterForm();
         // If we posted
         if ($r->isMethod('post')) {
             $params = $r->getParameter($this->regform->getName());
             $this->regform->bind($params);
             if ($this->regform->isValid()) {
                 // Blacklisted domains
                 $blacklistdomain = array('pourri.fr', 'yopmail.com', 'yopmail.fr', 'jetable.org', 'mail-temporaire.fr', 'ephemail.com', 'trashmail.net', 'kasmail.com', 'spamgourmet.com', 'tempomail.com', 'guerrillamail.com', 'mytempemail.com', 'saynotospams.com', 'tempemail.co.za', 'mailinator.com', 'mytrashmail.com', 'mailexpire.com', 'maileater.com', 'spambox.us', 'guerrillamail.com', '10minutemail.com', 'dontreg.com', 'filzmail.com', 'spamfree24.org', 'brefmail.com', '0-mail.com', 'link2mail.com', 'dodgeit.com', 'dontreg.com', 'e4ward.com', 'gishpuppy', 'guerrillamail.com', 'haltospam.com', 'kasmail.com', 'mailexpire.com', 'maileater.com', 'mailinator.com', 'mailnull.com', 'mytrashmail', 'nobulk.com', 'nospamfor.us', 'pookmail.com', 'shortmail.net', 'sneakemail.com', 'spam.la', 'spambob.com', 'spambox.us', 'spamday.com', 'spamh0le.com', 'spaml.com', 'tempinbox.com', 'temporaryinbox.com', 'willhackforfood.biz', 'willselfdestruct.com', 'wuzupmail.net', '10minutemail.com', 'klzlk.com', 'courriel.fr.nf');
                 // Checking email domain
                 if (in_array(parse_url("http://" . $params['email'], PHP_URL_HOST), $blacklistdomain)) {
                     $this->getUser()->setFlash("error", $this->getContext()->getI18N()->__("Your e-mail address is invalid."));
                     $this->redirect("@homepage");
                 }
                 // It's good : saving datas
                 $m = $this->regform->save();
                 // We're sending confirmation mail if validation is needed
                 if (sfConfig::get("app_validate")) {
                     // Launch the mailer
                     $message = $this->getMailer()->compose();
                     // Setting subject
                     $message->setSubject(sfConfig::get('app_name') . " : " . $this->getContext()->getI18N()->__("account validation"));
                     // The recipient
                     $message->setTo($m->getEmail());
                     // Our mail address
                     $message->setFrom(sfConfig::get('app_mail'));
                     // Vars inside the mail
                     $mailContext = array('id' => $m->getId(), 'cle' => $m->getPid(), 'pseudo' => $this->regform->getValue("username"), 'hote' => $r->getHost());
                     // Get the HTML version
                     $html = $this->getPartial('global/mail_validation_html', $mailContext);
                     $message->setBody($html, 'text/html');
                     // Text version (HTML with strip_tags)
                     $text = $this->getPartial('global/mail_validation_html', $mailContext);
                     $message->addPart(strip_tags($text), 'text/plain');
                     // Sending...
                     $this->getMailer()->send($message);
                     // Confirmation and redirect
                     $this->getUser()->setFlash("notice", $this->getContext()->getI18N()->__("Your account has been created. A confirmation mail has just been sent in order to activate it."));
                 } else {
                     $this->getUser()->setFlash("notice", $this->getContext()->getI18N()->__("Your account has been created. You can now proceed to login."));
                 }
                 $this->redirect("@homepage");
             }
             $c = (string) $this->regform->getErrorSchema();
             preg_match_all('#(.+) \\[(.+)\\]#U', $c, $m);
             $m[1] = array_map('trim', $m[1]);
             die(json_encode($m, JSON_FORCE_OBJECT));
         }
     }
     if (!$this->getUser()->isAuthenticated()) {
         $this->loginForm = new LoginForm();
     }
 }
示例#5
0
 public function executeUploadUrl(sfWebRequest $request)
 {
     $this->filename = '';
     if ($request->getParameter('picture_url') != null) {
         try {
             $filename = jrFileUploader::UploadRemote($request->getParameter('picture_url'));
             $this->filename = 'http://' . $request->getHost() . '/uploads/' . $filename;
         } catch (Exception $e) {
         }
     }
     return $this->renderPartial('upload', array('filename' => $this->filename));
 }
示例#6
0
 public function executeList(sfWebRequest $request)
 {
     $this->jobs = array();
     foreach ($this->getRoute()->getObjects() as $job) {
         $this->jobs[$this->generateUrl('job_show_user', $job, true)] = $job->asArray($request->getHost());
     }
     switch ($request->getRequestFormat()) {
         case 'yaml':
             $this->setLayout(false);
             $this->getResponse()->setContentType('text/yaml');
             break;
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeError404(sfWebRequest $request)
 {
     // URI
     $this->uri = $request->getUri();
     // URL
     $this->url = @current(explode('?', $this->uri));
     /*
     // main site
     $this->mainSite = Doctrine::getTable('Site')->findOneBySlug('cmais');
     
     // editorials
     $this->editorials = Doctrine_Query::create()
       ->select('s.*')
       ->from('Section s')
       ->where('s.site_id = ?', $this->mainSite->id)
       ->andWhere('s.is_active = ?', 1)
       ->andWhere('s.is_editorial = ?', 1)
       ->orderBy('s.display_order')
       ->execute();
       
     // channels
     $this->channels = array();
     $this->live = array();
     $this->coming = array();    
     $this->important = array();
     $cs = Doctrine_Query::create()
       ->select('c.*')
       ->from('Channel c')
       ->where('c.is_active = ?', 1)
       ->orderBy('c.title')
       ->execute();
       
     foreach($cs as $c){
       $this->channels[$c->slug] = $c;
       $this->live[$c->slug] = $c->retriveLiveProgram();
       $this->important[$c->slug] = $c->retriveImportantPrograms(1);
       $this->coming[$c->slug] = $c->retriveLivePrograms(3,$this->live[$c->slug][0]->getId());
     }
     */
     if ($request->getHost() == "culturafm.cmais.com.br") {
         $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura - Página não encontrada!', false);
         $this->setTemplate('sites/culturafm/error404', 'default');
     } else {
         $this->getResponse()->setTitle('cmais+ O portal de conteúdo da Cultura - Puxa, puxa que puxa! Não conseguimos encontrar a página...', false);
     }
 }
示例#8
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->curUser = $this->getUser()->getGuardUser();
     if ($this->curUser) {
         Cookie::setCookie($this->curUser, "index", Post::getNewLine('count'), time() + 24 * 60 * 60);
         Cookie::setCookie($this->curUser, "indexTime", date("Y-m-d H:i:s"), time() + 24 * 60 * 60);
         return;
     }
     $this->form = $this->applyForm();
     if (!$request->isMethod('post')) {
         return;
     }
     sfApplicationConfiguration::getActive()->loadHelpers(array('Guid'));
     $this->form->bind($request->getParameter('sfApplyApply'));
     if ($this->form->isValid()) {
         $this->form->setValidate("n" . createGuid());
         $this->form->save();
         $this->getUser()->signin($this->form->getObject()->getUser(), true);
         $post = new Post();
         $post->setText($this->getRequestParameter('text'));
         $post->setMoodName($this->getRequestParameter('mood'));
         $post->setUser($this->form->getObject()->getUser());
         $post->save();
         try {
             $mailer = $this->getMailer();
             $profile = $this->form->getObject();
             $mailContext = array('name' => $profile->getFullname(), 'validate' => $profile->getValidate(), 'partnerId' => $this->partnerId);
             $message = Swift_Message::newInstance();
             $from = sfConfig::get('app_sfApplyPlugin_from');
             $message->setFrom($from['email'], $from['fullname']);
             $message->setTo($profile->getEmail(), $profile->getUser()->getUsername());
             $message->setSubject(sfConfig::get('app_sfApplyPlugin_apply_subject', "Активация аккаунта на сайте " . $request->getHost()));
             $message->setBody($this->getPartial('global/sendValidateNew', $mailContext), 'text/html');
             $message->addPart($this->getPartial('global/sendValidateNewText', $mailContext), 'text/plain');
             $mailer->send($message);
         } catch (Exception $e) {
         }
         return 'After';
     }
 }
 /**
  * Executes parse action
  *
  * @param sfRequest $request A request object
  */
 public function executeParse(sfWebRequest $request)
 {
     //subdomain
     $subdomain = @current(explode(".", $request->getHost()));
     $param1 = FALSE;
     $param2 = FALSE;
     $param3 = FALSE;
     $param4 = FALSE;
     $param5 = FALSE;
     $param6 = FALSE;
     if (in_array($subdomain, array('tvcultura', 'tvratimbum', 'culturabrasil', 'culturafm', 'univesptv', 'multicultura', 'cmais', 'nucleodevideosp', 'm', 'radarcultura', 'fpa'))) {
         $param1 = $subdomain;
         if ($request->getParameter('param1')) {
             $param2 = $request->getParameter('param1');
         }
         if ($request->getParameter('param2')) {
             $param3 = $request->getParameter('param2');
         }
         if ($request->getParameter('param3')) {
             $param4 = $request->getParameter('param3');
         }
         if ($request->getParameter('param4')) {
             $param5 = $request->getParameter('param4');
         }
         if ($request->getParameter('param5')) {
             $param6 = $request->getParameter('param5');
         }
     } else {
         if ($request->getParameter('param1')) {
             $param1 = $request->getParameter('param1');
         }
         if ($request->getParameter('param2')) {
             $param2 = $request->getParameter('param2');
         }
         if ($request->getParameter('param3')) {
             $param3 = $request->getParameter('param3');
         }
         if ($request->getParameter('param4')) {
             $param4 = $request->getParameter('param4');
         }
         if ($request->getParameter('param5')) {
             $param5 = $request->getParameter('param5');
         }
     }
     if (!$param1) {
         $this->forward('main', 'index');
     } elseif ($param1 == "tudo" || $param2 == "tudo" || $param1 == "busca" || $param2 == "busca" && $param1 != "culturabrasil" && $param1 != "vilasesamo") {
         $this->forward('main', 'search');
     } elseif ($param1 == "criancasdobrasil" || $param1 == "criancas-do-brasil") {
         header("Location: http://tvcultura.com.br/criancasdobrasil");
         die;
     } elseif (($param1 == "cartao" || $param2 == "cartao") && ($subdomain == "cmais" || $subdomain == "tvcultura")) {
         header("Location: http://tvcultura.cmais.com.br/cartaoverde");
         die;
     } elseif ($param1 == "quintal" || $param1 == "quintal-da-cultura") {
         header("Location: http://cmais.com.br/quintaldacultura");
         die;
     } elseif ($param1 == "cmais" && $param2 == "segundatela" && $param3 == "jornaldacultura" && $param4 != "") {
         $date = date("d-m-Y");
         if ($param4 == $date) {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "online");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2331);
         } else {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "offline");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2330);
         }
         $this->getRequest()->setParameter('object', $section);
         $this->forward('_section', 'index');
         die;
     } elseif ($param1 == "cmais" && $param2 == "segundatela" && $param3 == "rodaviva" && $param4 != "") {
         $date = date("d-m-Y");
         if ($param4 == $date) {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "online");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2371);
         } else {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "offline");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2373);
         }
         $this->getRequest()->setParameter('object', $section);
         $this->forward('_section', 'index');
         die;
     } elseif ($param1 == "cmais" && $param2 == "segundatela" && $param3 == "cartaoverde" && $param4 != "") {
         $date = date("d-m-Y");
         if ($param4 == $date) {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "online");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2374);
         } else {
             //$section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1188, "offline");
             $section = $this->site = Doctrine::getTable('Section')->findOneById(2375);
         }
         $this->getRequest()->setParameter('object', $section);
         $this->forward('_section', 'index');
         die;
     } elseif ($param1 == "culturabrasil") {
         if ($param2 == "especiais") {
             if ($param3 == "") {
                 $section = $this->site = Doctrine::getTable('Section')->findOneById(2578);
                 $this->getRequest()->setParameter('object', $section);
                 $this->forward('_section', 'index');
                 die;
             } else {
                 if ($param4 == "") {
                     $parm3Object = $this->parse($param3);
                     if (get_class($parm3Object) == "Section") {
                         $section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug(1253, $param3);
                         $this->getRequest()->setParameter('object', $section);
                         $this->forward('_section', 'index');
                         die;
                     } elseif (get_class($parm3Object) == "Asset") {
                         $asset = $this->site = Doctrine::getTable('Asset')->findOneBySlug($param3);
                         $this->getRequest()->setParameter('object', $asset);
                         $this->forwardObject($asset);
                         die;
                     }
                 } else {
                     $asset = $this->site = Doctrine::getTable('Asset')->findOneBySlug($param4);
                     $this->getRequest()->setParameter('object', $asset);
                     $this->forwardObject($asset);
                     die;
                 }
             }
         }
         $parm2Object = $this->parse($param2);
         if (get_class($parm2Object) == "Site" && $param2 != "selecao-do-ouvinte") {
             $url = "http://culturabrasil.cmais.com.br/programas/{$param2}";
             if ($param3) {
                 $url = "http://culturabrasil.cmais.com.br/programas/{$param2}/{$param3}";
             }
             if ($param4) {
                 $url = "http://culturabrasil.cmais.com.br/programas/{$param2}/{$param3}/{$param4}";
             }
             header("Location: " . $url);
             die;
         }
         if ($param2 == "programas" && $param3 != "") {
             $site = $this->site = Doctrine::getTable('Site')->findOneBySlug($param3);
             $section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug($site->id, "arquivo");
             if ($param4 == "") {
                 $this->getRequest()->setParameter('object', $section);
                 $this->forward('_section', 'index');
                 die;
             } else {
                 if ($param5 == "") {
                     $section = $this->site = Doctrine::getTable('Section')->findOneBySiteIdAndSlug($site->id, $param4);
                     if ($section->slug) {
                         if ($section->slug != "arquivo") {
                             $this->getRequest()->setParameter('object', $section);
                             $this->forward('_section', 'index');
                             die;
                         } else {
                             header("Location: http://culturabrasil.cmais.com.br/programas/" . $param3);
                         }
                         die;
                     } else {
                         $this->forward404();
                     }
                 } else {
                     $asset = $this->site = Doctrine::getTable('Asset')->findOneBySlug($param5);
                     $this->getRequest()->setParameter('object', $asset);
                     $this->forwardObject($asset);
                     die;
                 }
             }
         }
     }
     if ($request->getHost() == "fpa.com.br" || $request->getHost() == "www.fpa.com.br") {
         if ($param1 == "fpa") {
             $param1 = "sic";
         }
         if ($param2 == "sic") {
             $param2 = $param3;
             $param3 = null;
         }
         //$param1 = $param2;
         //$param2 = $param3;
         //$param3 = null;
         //die('123');
     }
     if ($request->getParameter('debug') != "") {
         echo "<br>param1) " . $param1;
         echo "<br>param2) " . $param2;
         echo "<br>param3) " . $param3;
     }
     $parm1Object = $this->parse($param1);
     if ($parm1Object) {
         if ($request->getParameter('debug') != "") {
             print "<br>1main: 1>>" . $param1 . " - " . get_class($parm1Object) . ">>" . $parm1Object->id . ">>>" . $param2;
         }
         if (!$param2) {
             if ($request->getParameter('debug') != "") {
                 print "<br>forwardObject >>" . $param1;
             }
             $this->forwardObject($parm1Object);
         } else {
             $parm2Object = $this->parseWithObject($param2, $parm1Object);
             if ($request->getParameter('debug') != "") {
                 print "<br>parseWithObject >>" . $param2 . " - " . $param1;
             }
             if ($parm2Object) {
                 if ($request->getParameter('debug') != "") {
                     print "<br>main: 2>>" . get_class($parm2Object) . ">>" . $parm2Object->id;
                 }
                 if (!$param3) {
                     $this->forwardObject($parm2Object);
                 } else {
                     if ($parm1Object->slug == "m") {
                         $this->getRequest()->setParameter('object', $parm2Object);
                         $this->forward('_section', 'index');
                     }
                     /*
                                 if ($parm1Object->slug == "culturabrasil") {
                                   $this->getRequest()->setParameter('object', $parm2Object);
                                   $this->forward('_section', 'index');
                                 }*/
                     $parm3Object = $this->parseWithObject($param3, $parm2Object);
                     if ($parm3Object) {
                         if ($request->getParameter('debug') != "") {
                             print "<br>main: 3>>" . get_class($parm3Object) . ">>" . $parm3Object->id;
                         }
                         if (!$param4) {
                             $this->forwardObject($parm3Object);
                         } else {
                             $parm4Object = $this->parseWithObject($param4, $parm3Object);
                             if ($parm4Object) {
                                 if ($request->getParameter('debug') != "") {
                                     print "<br>main: 4>>" . get_class($parm4Object) . ">>" . $parm4Object->id;
                                 }
                                 if (!$param5) {
                                     $this->forwardObject($parm4Object);
                                 } else {
                                     $parm5Object = $this->parse($param5);
                                     if ($parm5Object) {
                                         if ($request->getParameter('debug') != "") {
                                             print "<br>main: 5>>" . get_class($parm5Object) . ">>" . $parm5Object->id;
                                         }
                                         if (!$param6) {
                                             $this->forwardObject($parm5Object);
                                         } else {
                                             $parm6Object = $this->parse($param6);
                                             if ($parm6Object) {
                                                 if ($request->getParameter('debug') != "") {
                                                     print "<br>main: 6>>" . get_class($parm6Object) . ">>" . $parm6Object->id;
                                                 }
                                                 $this->forwardObject($parm6Object);
                                             }
                                         }
                                     } else {
                                         $this->forward404();
                                     }
                                 }
                             } else {
                                 $this->forward404();
                             }
                         }
                     } else {
                         if (get_class($parm2Object) == "Site") {
                             if ($parm2Object->type == "Programa Simples") {
                                 $this->getRequest()->setParameter('date', $param3);
                                 $this->forwardObject($parm2Object);
                             }
                         } else {
                             if (get_class($parm2Object) == "Section") {
                                 if (in_array($parm2Object->slug, array("grade", "programacao", "guia-do-ouvinte"))) {
                                     $this->getRequest()->setParameter('date', $param3);
                                     $this->forwardObject($parm2Object);
                                 } else {
                                     if ($parm2Object->slug == "artistas") {
                                         $this->getRequest()->setParameter('artista', $param3);
                                         $this->forwardObject($parm2Object);
                                     } else {
                                         if ($parm2Object->slug == "musicas") {
                                             $this->getRequest()->setParameter('letter', $param3);
                                             $this->forwardObject($parm2Object);
                                         }
                                     }
                                 }
                             }
                         }
                         $this->forward404();
                     }
                 }
             } else {
                 $this->forward404();
             }
         }
     } else {
         if ($request->getParameter('erro') != "") {
             throw new sfException("Erro");
         } else {
             $this->forward404();
         }
     }
 }
示例#10
0
 public function executeWidgetOuter(sfWebRequest $request)
 {
     $this->fetchWidget();
     $petition = $this->widget['Petition'];
     /* @var $petition Petition */
     $petition_text = $this->widget['PetitionText'];
     /* @var $petition_text PetitionText */
     $this->count = $petition->getCount(60);
     $this->target = $this->count . '-' . Petition::calcTarget($this->count, $this->widget->getPetition()->getTargetNum());
     $image_prefix = ($request->isSecure() ? 'https://' : 'http://') . $request->getHost() . '/' . $request->getRelativeUrlRoot() . 'images/';
     $this->kind = $this->widget->getPetition()->getKind();
     $this->lang = $this->widget->getPetitionText()->getLanguageId();
     $this->getUser()->setCulture($this->lang);
     $this->label_mode = $this->widget->getPetition()->getLabelMode();
     $stylings = json_decode($this->widget->getStylings(), true);
     if (!is_array($stylings)) {
         $stylings = array();
     }
     $widget_colors = $petition->getWidgetIndividualiseDesign();
     foreach (array('title_color', 'body_color', 'button_color', 'bg_left_color', 'bg_right_color', 'form_title_color') as $style) {
         if (!$widget_colors || !isset($stylings[$style]) || !$stylings[$style]) {
             $stylings[$style] = $petition['style_' . $style];
         }
     }
     $this->stylings = $stylings;
     $this->keyvisual = $this->widget->getPetition()->getKeyVisual() ? $image_prefix . 'keyvisual/' . $this->widget->getPetition()->getKeyVisual() : null;
     $this->sprite = $image_prefix . 'policat.spr.png';
     $this->url = $this->getContext()->getRouting()->generate('sign', array('id' => $this->widget['id'], 'hash' => $this->widget->getLastHash(true)), true);
     $this->getResponse()->setContentType('text/javascript');
     $this->setLayout(false);
     $title = $this->widget->getTitle();
     if (!$petition->getWidgetIndividualiseText()) {
         $title = $petition_text->getTitle();
     }
     $this->title = Util::enc($title);
 }
示例#11
0
 public function executeVncviewer(sfWebRequest $request)
 {
     if ($request->getParameter('sleep')) {
         $tsleep = $request->getParameter('sleep');
         sleep($tsleep);
     }
     $etva_server = EtvaServerPeer::retrieveByPk($request->getParameter('id'));
     if (!$etva_server) {
         return sfView::NONE;
     }
     $etva_node = $etva_server->getEtvaNode();
     $user = $this->getUser();
     $tokens = $user->getGuardUser()->getEtvaVncTokens();
     $this->username = $tokens[0]->getUsername();
     $this->token = $tokens[0]->getToken();
     $proxyhost1 = $request->getHost();
     $proxyhost1_arr = split(':', $proxyhost1);
     $proxyhost1 = $proxyhost1_arr[0];
     $proxyport1 = $request->isSecure() ? 443 : 80;
     //$proxyport1 = 80;
     if ($proxyhost1_arr[1]) {
         $proxyport1 = $proxyhost1_arr[1];
     }
     $this->proxyhost1 = $proxyhost1;
     $this->proxyport1 = $proxyport1;
     $this->socketFactory = $request->isSecure() ? 'AuthHTTPSConnectSSLSocketFactory' : 'AuthHTTPConnectSocketFactory';
     $this->host = $etva_node->getIp();
     //if host is localhost address then is the same machine
     if ($this->host == '127.0.0.1') {
         $this->host = $proxyhost1;
     }
     $this->port = $etva_server->getVncPort();
     $response = $this->getResponse();
     $response->setTitle($etva_server->getName() . ' :: Console');
 }
示例#12
0
 /**
  * Add or edit Itinerary
  * CODE: itinerary_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $this->current_facility = "";
     $this->current_lodging = "";
     $this->current_facility_city = "";
     $this->current_facility_state = "";
     $this->current_facility_phone = "";
     $this->current_facility_phone_comment = "";
     $this->current_lodging_city = "";
     $this->current_lodging_state = "";
     $this->current_lodging_phone = "";
     $this->current_lodging_phone_comment = "";
     $this->mis2bn = false;
     $this->passenger_a = trim($this->getRequestParameter('passenger_a', '*')) == '' ? '*' : trim($this->getRequestParameter('passenger_a', '*'));
     $this->facility = trim($this->getRequestParameter('facility', '*')) == '' ? '*' : trim($this->getRequestParameter('facility', '*'));
     $this->lodging = trim($this->getRequestParameter('lodging', '*')) == '' ? '*' : trim($this->getRequestParameter('lodging', '*'));
     $this->requester_p = trim($this->getRequestParameter('requester_p', '*')) == '' ? '*' : trim($this->getRequestParameter('requester_p', '*'));
     $this->person_a = trim($this->getRequestParameter('person_a', '*')) == '' ? '*' : trim($this->getRequestParameter('person_a', '*'));
     $this->person_a_req = trim($this->getRequestParameter('person_a_req', '*')) == '' ? '*' : trim($this->getRequestParameter('person_a_req', '*'));
     $this->agency = trim($this->getRequestParameter('agency', '*')) == '' ? '*' : trim($this->getRequestParameter('agency', '*'));
     $this->hour = $request->getParameter('hour');
     $this->minut = $request->getParameter('minut');
     $this->b_weight = "";
     $this->b_type = "";
     $this->b_desc = "";
     if ($request->getParameter('id')) {
         $itine = ItineraryPeer::retrieveByPk($request->getParameter('id'));
         $mis = MissionPeer::getMissionByItineraryId($request->getParameter('id'), 1);
         $mis2 = MissionPeer::getMissionByItineraryId($request->getParameter('id'), 2);
         if (isset($mis)) {
             $this->b_weight = $mis->getBWeight();
         }
         if (isset($mis)) {
             $this->b_type = $mis->getBType();
         }
         if (isset($mis)) {
             $this->b_desc = $mis->getBDesc();
         }
         if ($mis2) {
             $this->mis2bn = true;
         } else {
             $mis2 = new Mission();
         }
         //$pp = $itine->getPassenger();
         if (isset($itine)) {
             $this->passenger_name = $itine->getPassenger()->getPerson()->getName();
             $this->current_pass_id = $itine->getPassengerId();
             $this->current_facility = $itine->getPassenger()->getFacilityName();
             $this->current_lodging = $itine->getPassenger()->getLodgingName();
             $this->companions = $itine->getPassenger()->getCompanions();
             $this->selected_companions = array();
             foreach ($mis->getMissionCompanions() as $mis_comp) {
                 $this->selected_companions[] = $mis_comp->getCompanionId();
             }
             //print_r($this->selected_companions);
         }
         $this->title = 'Edit Itinerary';
         $success = 'Itinerary has been succesfuly edited!';
         $editpassengerfac = PassengerDestPeer::getFacilityByPassengerId($this->current_pass_id, $this->current_facility);
         $editpassengerlod = PassengerDestPeer::getLodgingByPassengerId($this->current_pass_id, $this->current_lodging);
         if ($editpassengerfac) {
             $this->current_facility_city = $editpassengerfac->getFacilityCity();
             $this->current_facility_state = $editpassengerfac->getFacilityState();
             $this->current_facility_phone = $editpassengerfac->getFacPhone();
             $this->current_facility_phone_comment = $editpassengerfac->getFacilityPhoneComment();
         }
         if ($editpassengerlod) {
             $this->current_lodging_city = $editpassengerlod->getFacilityCity();
             $this->current_lodging_state = $editpassengerlod->getFacilityState();
             $this->current_lodging_phone = $editpassengerlod->getLodPhone();
             $this->current_lodging_phone_comment = $editpassengerlod->getLodPhoneComment();
         }
         if (isset($itine)) {
             $point_time = $itine->getPointTime();
             if ($point_time) {
                 $split_time = split(':', $point_time);
                 $this->hour = $split_time[0];
                 $this->minut = $split_time[1];
             }
         }
     } else {
         $itine = new Itinerary();
         $mis = new Mission();
         $mis2 = new Mission();
         //$passIti = new Passenger();
         //$itine->setWaiverNeed(1);
         //$itine->setNeedMedicalRelease(1);
         $this->title = 'Add Itinerary';
         $success = 'Itinerary has been succesfully created!';
     }
     $this->requester_a = "";
     $this->itine = $itine;
     if ($request->hasParameter('requester_a')) {
         $this->requester_a = trim($this->getRequestParameter('requester_a', '*')) == '' ? '*' : trim($this->getRequestParameter('requester_a', '*'));
     } else {
         if (isset($itine)) {
             $requester = $itine->getRequester();
             if ($requester) {
                 $this->requester_a = $requester->getPerson()->getName();
                 if ($requester->getAgency()->getName()) {
                     $this->requester_a .= ', ' . $requester->getAgency()->getName();
                 }
                 if ($requester->getTitle()) {
                     $this->requester_a .= ', ' . $requester->getTitle();
                 }
             }
         }
     }
     $this->form = new ItineraryForm($itine);
     $this->missionform1 = new MissionSmallForm($mis);
     $this->missionform2 = new MissionSmallForm($mis2);
     //$this->formI = new PassengerItiForm($passIti);
     $facandlod = new PassengerDest();
     $this->form6 = new PassengerDestForm($facandlod);
     $passenger = new Passenger();
     $this->passenger = $passenger;
     //passengers,requester uses when edit
     $c = new Criteria();
     $c->setLimit(50);
     $this->all_passengers = PassengerPeer::doSelect($c);
     $this->all_requesters = RequesterPeer::doSelect($c);
     //Passenger Form1
     $this->form1 = new PassengerPopUpForm1($passenger);
     $this->sub_title = 'Add New Passenger';
     //Passenger Form 2
     $this->form2 = new PassengerPopUpForm2();
     //Passenger Form 3
     $this->form3 = new PassengerPopUpForm3();
     //Passenger Form 4
     $this->form4 = new PassengerPopUpForm4();
     //Passenger Form 5
     $this->form5 = new PassengerPopUpForm5();
     //Requester PopUp Form  - Not Requester Passenger
     $this->persons = PersonPeer::getNotInRequester();
     $requester = new Requester();
     $this->form_req = new RequesterForm($requester);
     $companion = new Companion();
     $this->form_com = new CompanionForm($companion);
     $this->req_referer = $request->getReferer();
     $this->states = sfConfig::get('app_states');
     $this->errors = array();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('itine'));
         $this->referer = $request->getReferer();
         $k = $this->form->isValid();
         if ($k && $request->getParameter('passenger_id') && $request->getParameter('requester_id')) {
             $itine->setPassengerId($request->getParameter('passenger_id'));
             $itine->setRequesterId($request->getParameter('requester_id'));
             $itine->setDateRequested($this->form->getValue('date_requested'));
             $itine->setMissionTypeId($this->form->getValue('mission_type_id'));
             $itine->setApointTime($this->form->getValue('apoint_time'));
             if ($request->getParameter('facility')) {
                 $itine->setFacility($request->getParameter('facility'));
             }
             if ($request->getParameter('lodging')) {
                 $itine->setLodging($request->getParameter('lodging'));
             }
             if ($request->getParameter('hour') && $request->getParameter('minut') && $request->getParameter('hour') != '---' && $request->getParameter('minut') != '---') {
                 $itine->setPointTime($request->getParameter('hour') . ':' . $request->getParameter('minut') . ':00');
                 $itine->setTimetype($this->form->getValue('timetype'));
             }
             $passengerItine = PassengerPeer::retrieveByPK($request->getParameter('passenger_id'));
             if ($passengerItine instanceof Passenger) {
                 $personpasItine = $passengerItine->getPerson();
                 $origin_city = $personpasItine->getCity();
                 $origin_state = $personpasItine->getState();
                 $dest_city = $passengerItine->getFacilityCity();
                 $dest_state = $passengerItine->getFacilityState();
                 //$passengerItine->setBWeight($request->getParameter('b_weight'));
                 //$passengerItine->setBType($request->getParameter('b_type'));
                 //$passengerItine->setBDesc($request->getParameter('b_desc'));
                 $passengerItine->save();
                 //check
             }
             $itine->setOrginCity($origin_city ? $origin_city : "");
             $itine->setOrginState($origin_state ? $origin_state : "");
             $itine->setDestCity($dest_city ? $dest_city : "");
             $itine->setDestState($dest_state ? $dest_state : "");
             //$itine->setBWeight($this->form->getValue('b_weight'));
             //$itine->setBType($this->form->getValue('b_type'));
             //$itine->setBDesc($this->form->getValue('b_desc'));
             //$itine->setWaiverNeed($this->form->getValue('waiver_need'));
             //$itine->setNeedMedicalRelease($this->form->getValue('need_medical_release'));
             $itine->setComment($this->form->getValue('comment'));
             $newIti = false;
             if ($itine->isNew()) {
                 $newIti = true;
                 $itine->setCancelItinerary(1);
             }
             $itine->save();
             $companions = (array) $request->getParameter('companions');
             if (count($companions)) {
                 $c = new Criteria();
                 $c->add(CompanionPeer::ID, $companions, Criteria::IN);
                 $c->add(CompanionPeer::PASSENGER_ID, $request->getParameter('passenger_id'));
                 if (CompanionPeer::doCount($c) != count($companions)) {
                     $this->errors[] = 'Some companions not found';
                 }
             }
             $mis->setItineraryId($itine->getId());
             $mis->setMissionTypeId($this->form->getValue('mission_type_id'));
             $mis->setDateRequested($this->form->getValue('date_requested'));
             $mis->setPassengerId($request->getParameter('passenger_id'));
             $mis->setRequesterId($request->getParameter('requester_id'));
             $mis->setMissionDate($request->getParameter('mis1'));
             $mis->setBWeight($request->getParameter('b_weight'));
             $mis->setBType($request->getParameter('b_type'));
             $mis->setBDesc($request->getParameter('b_desc'));
             /*if($itine->isNew()){
                   echo $countMission; exit;
                   if(isset($countMission)){
                           foreach($misall as $misc){
                               $mLeg = MissionLegPeer::getAllMissionLegByMissionId($misc->getId());
                               $countLeg = MissionLegPeer::getMissionLegByMissionIdCount($misc->getId());
                               if(isset($countLeg)){
                                   foreach($mLeg as $ml){
                                       $ml->setCancelMissionLeg(1);
                                       $ml->save();
                                   }
                               }
                               $misc->setCancelMission(1);
                               $misc->save();
                           }
                   }
               }*/
             if ($request->getParameter('missionSelect') == 1) {
                 $mis->setApptDate($request->getParameter('appdate1'));
                 $mis->setApointTime($this->form->getValue('apoint_time'));
                 $mis->setStart(1);
             } else {
                 $mis->setStart(2);
             }
             if ($itine->getCancelItinerary() == 1) {
                 $mis->setCancelMission(1);
             }
             if (!$request->getParameter('id')) {
                 //Mission 1 externa ID
                 $c = new Criteria();
                 $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
                 $c->addDescendingOrderByColumn(MissionPeer::EXTERNAL_ID);
                 $external_mission = MissionPeer::doSelectOne($c);
                 $external_id = $external_mission->getExternalId();
                 $currentExternalId = $external_id + 1;
                 $mis->setExternalId($currentExternalId);
                 // die();
             }
             $mis->setMissionCount(1);
             $mis->save();
             if ($request->getParameter('yes_no') == 1) {
                 //Mission 2 externa ID
                 if (!$request->getParameter('id')) {
                     $c = new Criteria();
                     $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
                     $c->addDescendingOrderByColumn(MissionPeer::EXTERNAL_ID);
                     $external_mission = MissionPeer::doSelectOne($c);
                     $external_id = $external_mission->getExternalId();
                     $currentExternalId = $external_id + 1;
                     $mis2->setExternalId($currentExternalId);
                     // die();
                 }
                 $mis2->setItineraryId($itine->getId());
                 $mis2->setMissionTypeId($this->form->getValue('mission_type_id'));
                 $mis2->setDateRequested($this->form->getValue('date_requested'));
                 $mis2->setPassengerId($request->getParameter('passenger_id'));
                 $mis2->setRequesterId($request->getParameter('requester_id'));
                 $mis2->setMissionDate($request->getParameter('mis2'));
                 $mis2->setBWeight($request->getParameter('b_weight'));
                 $mis2->setBType($request->getParameter('b_type'));
                 $mis2->setBDesc($request->getParameter('b_desc'));
                 $mis2->setCancelMission(1);
                 if ($request->getParameter('missionSelect') == 1) {
                     $mis2->setStart(2);
                 } else {
                     $mis2->setStart(1);
                 }
                 $mis2->setMissionCount(2);
                 if ($itine->getCancelItinerary() == 1) {
                     $mis2->setCancelMission(1);
                 }
                 $mis2->save();
             }
             if (count($this->errors)) {
                 # error in form
                 switch ($request->getParameter('transportation')) {
                     case 'air_mission':
                         $this->origin_idents = $origin_airports;
                         $this->dest_idents = $dest_airports;
                         break;
                     case 'ground_mission':
                         break;
                     case 'commercial_mission':
                         break;
                 }
                 $this->selected_companions = $companions;
             } else {
                 $c->clear();
                 $c->add(MissionCompanionPeer::MISSION_ID, $mis->getId());
                 MissionCompanionPeer::doDelete($c);
                 foreach ($companions as $id) {
                     $mission_companion = new MissionCompanion();
                     $mission_companion->setMissionId($mis->getId());
                     $mission_companion->setCompanionId($id);
                     $mission_companion->save();
                 }
             }
             //die();
             $this->selected_companions = $companions;
             //print_r($this->selected_companions);
             //die();
             //$team_note = TeamNotePeer::retrieveByPK($id);
             //if(!$team_note) {
             //$team_note = new TeamNote();
             //}
             //$team_note->setRoleId($id);
             //$team_note->setNote(strip_tags($note, sfConfig::get('app_allowed_note_tags')));
             //$team_note->save();
             $this->getUser()->setFlash('success', $success);
             //$request->getParameter('back')
             $this->redirect('/itinerary/detail/' . $itine->getId());
         } else {
             if (!$request->getParameter('passenger_id')) {
                 $this->need_pass = 1;
             }
             if (!$request->getParameter('requester_id')) {
                 $this->need_requester_id = 1;
             }
             //if(!$request->getParameter('facility')){
             //$this->need_facility= 1;
             //}
             //if(!$request->getParameter('lodging')){
             //$this->need_lodging = 1;
             //}
             $this->referer = $request->getParameter('back');
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@itinerary';
     }
     // Block from Add person
     if ($request->getParameter('add_pass') == 'yes') {
         $this->person = new Person();
         $this->person_title = 'Step 1 : Add person';
         if ($request->getParameter('camp_id')) {
             $this->camp_id = $request->getParameter('camp_id');
         }
         $this->stepped = 1;
     }
     if ($request->getParameter('add_pass_iti') == 'yes') {
         $this->person = new Person();
         $this->person_title = 'Step 1 : Add person';
         $this->person_itine = 1;
     }
     if ($request->getParameter('add_cont') == 'yes') {
         $this->person = new Person();
         $this->person_title = 'Step 1 : Add person';
         $this->contact = 1;
     }
     if ($request->getParameter('id')) {
         $this->person = PersonPeer::retrieveByPK($request->getParameter('id'));
         $this->person_title = 'Edit person';
     } else {
         $this->person = new Person();
         $this->person_title = 'Add person';
     }
     $companion = new Companion();
     $this->form_a = new CompanionForm($companion);
     # Person Form
     $this->person_form = new PersonForm($this->person);
     $this->back = $request->getReferer();
     //session
     $this->key = $request->getParameter('key');
     if (!$this->key) {
         $this->key = rand(1000, 9999);
     }
     # Agency Form
     $agency = new Agency();
     $this->agency_title = 'Add Agency';
     $this->agency_form = new AgencyForm($agency);
     if (strstr($request->getReferer(), 'person/view')) {
         if ($this->person) {
             //session
             $referer_session = $this->getUser()->getAttribute('ref');
             if (!$referer_session) {
                 $referer_session = array($this->key => array());
                 $this->getUser()->setAttribute('ref', $referer_session);
             } elseif (!isset($referer_session[$this->key])) {
                 $a = '@person_view?id=' . $this->person->getId();
                 $referer_session[$this->key] = array('referer' => $a);
                 $this->getUser()->setAttribute('ref', $referer_session[$this->key]);
             }
         }
     }
     $this->person_referer = $request->getParameter('referer');
     if ($request->isMethod('post')) {
         $this->person_referer = $request->getParameter('referer');
         $this->person_form->bind($request->getParameter('per'));
         if ($this->person_form->isValid() && $this->person_form->getValue('first_name') && $this->person_form->getValue('last_name')) {
             $this->person->setTitle($this->person_form->getValue('title'));
             $this->person->setFirstName($this->person_form->getValue('first_name'));
             $this->person->setLastName($this->person_form->getValue('last_name'));
             $this->person->setAddress1($this->person_form->getValue('address1'));
             $this->person->setAddress2($this->person_form->getValue('address2'));
             $this->person->setCity($this->person_form->getValue('city'));
             $this->person->setCounty($this->person_form->getValue('county'));
             $this->person->setState($this->person_form->getValue('state'));
             $this->person->setCountry($this->person_form->getValue('country'));
             $this->person->setZipcode($this->person_form->getValue('zipcode'));
             $this->person->setDayPhone($this->person_form->getValue('day_phone'));
             $this->person->setDayComment($this->person_form->getValue('day_comment'));
             $this->person->setEveningPhone($this->person_form->getValue('evening_phone'));
             $this->person->setEveningComment($this->person_form->getValue('evening_comment'));
             $this->person->setMobilePhone($this->person_form->getValue('mobile_phone'));
             $this->person->setMobileComment($this->person_form->getValue('mobile_comment'));
             $this->person->setPagerPhone($this->person_form->getValue('paper_phone'));
             $this->person->setPagerComment($this->person_form->getValue('paper_comment'));
             $this->person->setOtherPhone($this->person_form->getValue('other_phone'));
             $this->person->setOtherComment($this->person_form->getValue('other_comment'));
             $this->person->setFaxPhone1($this->person_form->getValue('fax_phone1'));
             $this->person->setFaxComment1($this->person_form->getValue('fax_comment1'));
             $this->person->setAutoFax($this->person_form->getValue('auto_fax'));
             $this->person->setFaxPhone2($this->person_form->getValue('fax_phone2'));
             $this->person->setFaxComment2($this->person_form->getValue('fax_comment2'));
             $this->person->setEmail($this->person_form->getValue('email'));
             $this->person->setEmailTextOnly($this->person_form->getValue('email_text_only'));
             $this->person->setEmailBlocked($this->person_form->getValue('email_blocked'));
             $this->person->setComment($this->person_form->getValue('comment'));
             //$this->person->setBlockMailings($this->person_form->getValue('block_mailings')==0?null:$this->person_form->getValue('block_mailings'));
             $this->person->setBlockMailings($this->person_form->getValue('block_mailings'));
             $this->person->setNewsletter($this->person_form->getValue('newsletter'));
             $this->person->setGender($this->person_form->getValue('gender'));
             $this->person->setDeceased($this->person_form->getValue('deceased'));
             $this->person->setDeceasedComment($this->person_form->getValue('deceased_comment'));
             $this->person->setSecondaryEmail($this->person_form->getValue('secondary_email'));
             $this->person->setDeceasedDate($this->person_form->getValue('deceased_date'));
             $this->person->setMiddleName($this->person_form->getValue('middle_name'));
             $this->person->setSuffix($this->person_form->getValue('suffix'));
             $this->person->setNickname($this->person_form->getValue('nickname'));
             $this->person->setVeteran($this->person_form->getValue('veteran'));
             if ($this->person->isNew()) {
                 $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName();
                 ActivityPeer::log($content);
             }
             $this->person->save();
             if ($this->person->getId()) {
                 $c = new Criteria();
                 $c->add(RoleNotificationPeer::MID, 5);
                 $c->add(RoleNotificationPeer::NOTIFICATION, 1);
                 $c->addOr(RoleNotificationPeer::NOTIFICATION, 3);
                 $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID);
                 $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID);
                 $personemail = PersonPeer::doSelect($c);
                 $allemail = array();
                 $pindex = 0;
                 foreach ($personemail as $getEmail) {
                     if (strlen($getEmail->getEmail()) > 0) {
                         $allemail[$pindex++] = $getEmail->getEmail();
                     } else {
                         if (strlen($getEmail->getSecondaryEmail()) > 0) {
                             $allemail[$pindex++] = $getEmail->getSecondaryEmail();
                         }
                     }
                 }
                 //$allemail[$pindex]="*****@*****.**";
                 $email['subject'] = "New Person added";
                 $link = $request->getHost() . "/person/view/" . $this->person->getId();
                 $body = "A new person added in " . $request->getHost() . "\r\n" . $this->person->getFirstName() . " " . $this->person->getLastName() . "\r\n Profile Link: " . $link;
                 $email['body'] = $body;
                 $email['sender_email'] = "*****@*****.**";
                 $this->getComponent('mail', 'sendBulk', array('subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body']));
             }
             if ($request->hasParameter('has')) {
                 $data = '';
                 if ($request->getParameter('camp_id')) {
                     $data = '&camp_id=' . $request->getParameter('camp_id');
                 }
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!');
                 $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data);
             }
             if ($request->hasParameter('iti')) {
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!');
                 $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId());
             }
             if ($request->hasParameter('contact')) {
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!');
                 $this->redirect('@contact_create?person_id=' . $this->person->getId());
             }
             $this->getUser()->setFlash('success', 'Person information has been successfully saved!');
             $last = $request->getParameter('back');
             $referer_session = $this->getUser()->getAttribute('ref');
             $back_url = '@person_view?id=' . $this->person->getId();
             $this->redirect($back_url);
         }
     } else {
         # Set referer URL
         $this->person_referer = $request->getReferer() ? $request->getReferer() : '@person';
     }
 }
示例#13
0
 /**
  * CODE: person_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri());
         $this->redirect('dashboard/index');
     }
     if ($request->getParameter('add_pass') == 'yes') {
         $this->person = new Person();
         $this->title = 'Step 1 : Add person';
         if ($request->getParameter('camp_id')) {
             $this->camp_id = $request->getParameter('camp_id');
         }
         $this->stepped = 1;
     }
     if ($request->getParameter('add_pass_iti') == 'yes') {
         $this->person = new Person();
         $this->title = 'Step 1 : Add person';
         $this->itine = 1;
     }
     if ($request->getParameter('add_cont') == 'yes') {
         $this->person = new Person();
         $this->title = 'Step 1 : Add person';
         $this->contact = 1;
     }
     if ($request->getParameter('id')) {
         $this->person = PersonPeer::retrieveByPK($request->getParameter('id'));
         $this->title = 'Edit person';
     } else {
         $this->person = new Person();
         $this->title = 'Add person';
     }
     # Person Form
     $this->form = new PersonForm($this->person);
     $this->back = $request->getReferer();
     //session
     $this->key = $request->getParameter('key');
     if (!$this->key) {
         $this->key = rand(1000, 9999);
     }
     if (strstr($request->getReferer(), 'person/view')) {
         if ($this->person) {
             //session
             $referer_session = $this->getUser()->getAttribute('ref');
             if (!$referer_session) {
                 $referer_session = array($this->key => array());
                 $this->getUser()->setAttribute('ref', $referer_session);
             } elseif (!isset($referer_session[$this->key])) {
                 $a = '@person_view?id=' . $this->person->getId();
                 $referer_session[$this->key] = array('referer' => $a);
                 $this->getUser()->setAttribute('ref', $referer_session[$this->key]);
             }
         }
     }
     $this->referer = $request->getParameter('referer');
     if ($request->isMethod('post')) {
         $this->referer = $request->getParameter('referer');
         $this->form->bind($request->getParameter('per'));
         if ($this->form->isValid() && $this->form->getValue('first_name') && $this->form->getValue('last_name')) {
             $this->person->setTitle($this->form->getValue('title'));
             $this->person->setFirstName($this->form->getValue('first_name'));
             $this->person->setLastName($this->form->getValue('last_name'));
             $this->person->setAddress1($this->form->getValue('address1'));
             $this->person->setAddress2($this->form->getValue('address2'));
             $this->person->setCity($this->form->getValue('city'));
             $this->person->setCounty($this->form->getValue('county'));
             $this->person->setState($this->form->getValue('state'));
             $this->person->setCountry($this->form->getValue('country'));
             $this->person->setZipcode($this->form->getValue('zipcode'));
             $this->person->setDayPhone($this->form->getValue('day_phone'));
             $this->person->setDayComment($this->form->getValue('day_comment'));
             $this->person->setEveningPhone($this->form->getValue('evening_phone'));
             $this->person->setEveningComment($this->form->getValue('evening_comment'));
             $this->person->setMobilePhone($this->form->getValue('mobile_phone'));
             $this->person->setMobileComment($this->form->getValue('mobile_comment'));
             $this->person->setPagerPhone($this->form->getValue('paper_phone'));
             $this->person->setPagerComment($this->form->getValue('paper_comment'));
             $this->person->setOtherPhone($this->form->getValue('other_phone'));
             $this->person->setOtherComment($this->form->getValue('other_comment'));
             $this->person->setFaxPhone1($this->form->getValue('fax_phone1'));
             $this->person->setFaxComment1($this->form->getValue('fax_comment1'));
             $this->person->setAutoFax($this->form->getValue('auto_fax'));
             $this->person->setFaxPhone2($this->form->getValue('fax_phone2'));
             $this->person->setFaxComment2($this->form->getValue('fax_comment2'));
             $this->person->setEmail($this->form->getValue('email'));
             $this->person->setEmailTextOnly($this->form->getValue('email_text_only'));
             $this->person->setEmailBlocked($this->form->getValue('email_blocked'));
             $this->person->setComment($this->form->getValue('comment'));
             //        $this->person->setBlockMailings($this->form->getValue('block_mailings')==0?null:$this->form->getValue('block_mailings'));
             $this->person->setBlockMailings($this->form->getValue('block_mailings'));
             $this->person->setNewsletter($this->form->getValue('newsletter'));
             $this->person->setGender($this->form->getValue('gender'));
             $this->person->setDeceased($this->form->getValue('deceased'));
             $this->person->setDeceasedComment($this->form->getValue('deceased_comment'));
             $this->person->setSecondaryEmail($this->form->getValue('secondary_email'));
             $this->person->setDeceasedDate($this->form->getValue('deceased_date'));
             $this->person->setMiddleName($this->form->getValue('middle_name'));
             $this->person->setSuffix($this->form->getValue('suffix'));
             $this->person->setNickname($this->form->getValue('nickname'));
             $this->person->setVeteran($this->form->getValue('veteran'));
             if ($this->person->isNew()) {
                 $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName();
                 ActivityPeer::log($content);
             }
             $this->person->save();
             //////////////////////////////////////#bglobal omar
             if ($this->person->getId()) {
                 $c = new Criteria();
                 $c->add(RoleNotificationPeer::MID, 5);
                 $c->add(RoleNotificationPeer::NOTIFICATION, 1);
                 $c->addOr(RoleNotificationPeer::NOTIFICATION, 3);
                 $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID);
                 $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID);
                 $personemail = PersonPeer::doSelect($c);
                 $allemail = array();
                 $pindex = 0;
                 foreach ($personemail as $getEmail) {
                     if (strlen($getEmail->getEmail()) > 0) {
                         $allemail[$pindex++] = $getEmail->getEmail();
                     } else {
                         if (strlen($getEmail->getSecondaryEmail()) > 0) {
                             $allemail[$pindex++] = $getEmail->getSecondaryEmail();
                         }
                     }
                 }
                 $allemail[$pindex] = "*****@*****.**";
                 /*
                 echo "<pre>";			
                 print_r($allemail);	
                 echo "</pre>";
                 */
                 $email['subject'] = "New Person added";
                 $link = $request->getHost() . "/person/view/" . $this->person->getId();
                 $body = "A new person added in " . $request->getHost() . "\r\n" . $this->person->getFirstName() . " " . $this->person->getLastName() . "\r\n Profile Link: " . $link;
                 $email['body'] = $body;
                 $email['sender_email'] = "*****@*****.**";
                 $this->getComponent('mail', 'sendBulk', array('subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body']));
             }
             /////////////////////////////////////
             if ($request->hasParameter('has')) {
                 $data = '';
                 if ($request->getParameter('camp_id')) {
                     $data = '&camp_id=' . $request->getParameter('camp_id');
                 }
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!');
                 $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data);
             }
             if ($request->hasParameter('iti')) {
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!');
                 $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId());
             }
             if ($request->hasParameter('contact')) {
                 $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!');
                 $this->redirect('@contact_create?person_id=' . $this->person->getId());
             }
             $this->getUser()->setFlash('success', 'Person information has been successfully saved!');
             $last = $request->getParameter('back');
             $referer_session = $this->getUser()->getAttribute('ref');
             $back_url = '@person_view?id=' . $this->person->getId();
             $this->redirect($back_url);
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@person';
     }
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->getParameter('object')) {
         // asset
         $this->asset = $request->getParameter('object');
         // URI
         //$this->uri = str_replace('/index.php', '', $request->getUri());
         $this->uri = $this->asset->retriveUrl();
         // URL
         $this->url = @current(explode('?', $this->uri));
         // main site
         $this->mainSite = Doctrine::getTable('Site')->findOneBySlug('cmais');
         if ($this->asset->getIsActive() != '1' && $this->asset->Site->getType() != "Programa TVRTB") {
             header("Location: " . $this->asset->Site->retriveUrl());
             die;
         }
         if (in_array($this->asset->Site->getSlug(), array("cocorico2", "cocorico"))) {
             $this->setLayout('cocorico');
             /*
             if (preg_match("/^172\.20\.(\d+)\.(\d+)/", $_SERVER['REMOTE_ADDR']) == 0) {
               header("location: http://www3.tvcultura.com.br/cocorico");
               die();
             }
             */
         }
         if (in_array($this->asset->Site->getSlug(), array("culturabrasil"))) {
             $this->setLayout('culturabrasil');
         }
         if (in_array($this->asset->Site->getSlug(), array("cedoc", "cedoc2"))) {
             $this->setLayout('cedoc');
             /*
             if (preg_match("/^172\.20\.(\d+)\.(\d+)/", $_SERVER['REMOTE_ADDR']) == 0) {
               header("location: http://www3.tvcultura.com.br/cocorico");
               die();
             }
             */
         }
         if (in_array($this->asset->Site->getSlug(), array("vilasesamo"))) {
             $this->setLayout('vilasesamo');
         }
         /*
         if(in_array($this->asset->getSlug(), array("cadastro-de-tutor-melhor-gestao-melhor-ensino"))) {
           if (preg_match("/^172\.20\.(\d+)\.(\d+)/", $_SERVER['REMOTE_ADDR']) == 0) {
             header("location: http://cmais.com.br");
             die();
           }
         }
         */
         // related assets
         $this->relatedAssets = Doctrine_Query::create()->select('a.*, ra.id related_asset_id, ra.type related_asset_type, ra.description related_asset_description')->from('Asset a, RelatedAsset ra')->where('a.id = ra.asset_id')->andWhere('ra.parent_asset_id = ?', (int) $this->asset->id)->groupBy('ra.id')->orderBy('ra.display_order');
         // current site
         $this->site = $this->asset->Site;
         // program
         $this->program = $this->site->Program;
         // current section
         // #2 Look for a Section
         $str = $this->asset->AssetType->getSlug();
         if ($this->site->slug == 'nossalingua') {
             if ($str == 'video') {
                 $str = 'videos';
             }
         }
         if ($str == "image-gallery") {
             $str = "imagens";
         }
         $this->section = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', (int) $this->site->getId())->andWhere('s.slug = ?', (string) $str)->orderby('s.parent_section_id desc')->fetchOne();
         if (in_array($this->site->getSlug(), array("radarcultura", "culturafm", "cocorico"))) {
             $this->setLayout('radarcultura');
             if (!$this->section) {
                 $se = $this->asset->Sections;
                 $this->section = $this->asset->Sections[0];
                 /*
                           if(count($se)>0){
                             foreach($se as $s){
                               if(!$this->section){
                                 $this->section = Doctrine_Query::create()
                                   ->select('s.*')
                                   ->from('Section s')
                                   ->where('s.site_id = ?', (int)$this->site->getId())
                                   ->andWhere('s.slug = ?', $s->getSlug())
                                   ->orderby('s.parent_section_id desc')
                                   ->fetchOne();
                               }
                             }
                           }
                 */
                 if (!$this->section) {
                     $this->section = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', (int) $this->mainSite->getId())->andWhere('s.slug = ?', 'home')->orderby('s.parent_section_id desc')->fetchOne();
                 }
             }
         } else {
             if (!$this->section) {
                 $se = $this->asset->Sections;
                 if (count($se) > 0) {
                     foreach ($se as $s) {
                         if (!$this->section) {
                             $this->section = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', (int) $this->mainSite->getId())->andWhere('s.slug = ?', $s->getSlug())->orderby('s.parent_section_id desc')->fetchOne();
                         }
                     }
                 }
                 if (!$this->section) {
                     $this->section = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', (int) $this->mainSite->getId())->andWhere('s.slug = ?', 'home')->orderby('s.parent_section_id desc')->fetchOne();
                 }
             }
         }
         // siteSections
         if ($this->asset->Site->getType() == "ProgramaRadio") {
             if ($this->site->Program->Channel->getSlug() == "culturabrasil" || $this->site->getSlug() == "especiais-1") {
                 $this->siteSections = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', 1124)->andWhere('s.is_active = ?', 1)->andWhere('s.is_visible = ?', 1)->andWhere('parent_section_id IS NULL')->andWhereNotIn('s.slug', array('home', 'home-page', 'homepage'))->orderBy('s.display_order')->execute();
             } else {
                 $this->siteSections = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', 4)->andWhere('s.is_active = ?', 1)->andWhere('s.is_visible = ?', 1)->andWhere('parent_section_id IS NULL')->andWhereNotIn('s.slug', array('home', 'home-page', 'homepage'))->orderBy('s.display_order')->execute();
             }
         } elseif (in_array($this->asset->Site->getSlug(), array("sic", "revistavitrine2", "revistavitrine", "radarcultura"))) {
             $this->siteSections = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', $this->asset->Site->getId())->andWhere('s.is_active = ?', 1)->andWhere('s.is_visible = ?', 1)->andWhere('s.parent_section_id <= 0 OR s.parent_section_id IS NULL')->orderBy('s.display_order')->execute();
         } else {
             $this->siteSections = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.site_id = ?', $this->asset->Site->id)->andWhere('s.is_active = ?', 1)->andWhere('s.is_visible = ?', 1)->andWhere('s.parent_section_id <= 0 OR s.parent_section_id IS NULL')->andWhereNotIn('s.slug', array('home', 'home-page', 'homepage'))->orderBy('s.display_order')->execute();
         }
         /*
         // editorials
         $this->editorials = Doctrine_Query::create()
           ->select('s.*')
           ->from('Section s')
           ->where('s.site_id = ?', $this->mainSite->id)
           ->andWhere('s.is_active = ?', 1)
           ->andWhere('s.is_editorial = ?', 1)
           ->orderBy('s.display_order')
           ->execute();
         // channels
         $this->channels = array();
         $this->live = array();
         $this->coming = array();    
         $this->important = array();
         $cs = Doctrine_Query::create()
           ->select('c.*')
           ->from('Channel c')
           ->where('c.is_active = ?', 1)
           ->orderBy('c.title')
           ->execute();
         foreach($cs as $c){
           $this->channels[$c->slug] = $c;
           $this->live[$c->slug] = $c->retriveLiveProgram();
           $this->important[$c->slug] = $c->retriveImportantPrograms(1);
           $this->coming[$c->slug] = $c->retriveLivePrograms(3,$this->live[$c->slug][0]->getId());
           //print "<br>>>>".$c->getSlug();
         }
         */
         /*
         // blocks
         if($this->section){
           $bs = $this->section->Blocks;
           $displays = array();
           foreach($bs as $b){
             $displays[$b->getSlug()] = $b->retriveDisplays();
           }
         }
         */
         if (!isset($displays['alerta'])) {
             $block = Doctrine::getTable('Block')->findOneById(210);
             if ($block) {
                 $displays['alerta'] = $block->retriveDisplays();
             }
         }
         /*
         if(!isset($displays['publicidade-728x90'])){
           $block = Doctrine::getTable('Block')->findOneById(430);
           if($block)
             $displays['publicidade-728x90'] = $block->retriveDisplays();
         }
         if(!isset($displays['publicidade-300x50'])){
           $block = Doctrine::getTable('Block')->findOneById(429);
           if($block)
             $displays['publicidade-300x50'] = $block->retriveDisplays();
         }
         if(!isset($displays['publicidade-300x250'])){
           $block = Doctrine::getTable('Block')->findOneById(428);
           if($block)
             $displays['publicidade-300x250'] = $block->retriveDisplays();
         }
         */
         $this->displays = $displays;
         unset($displays);
         unset($bs);
     }
     if ($this->site->Program->Channel->getSlug() == "univesptv" && $this->site->getSlug() != "inglescommusica") {
         $t = explode("-old", $this->asset->getSlug());
         if (isset($_REQUEST["debug"])) {
             if ($_REQUEST["debug"] == 1) {
                 //echo $this->section->Site->getSlug();
                 echo $this->asset->Site->getSlug();
             }
         }
         if (count($t) > 1 && $_REQUEST["test"] != 1) {
             header("Location: " . $t[0]);
             die;
         }
     }
     if ($this->site->slug == 'sic') {
         $this->setLayout(false);
     }
     // mail sender
     $email_site = "";
     if ($request->getParameter('section_id') != "") {
         $this->section = Doctrine_Query::create()->select('s.*')->from('Section s')->where('s.id = ?', (int) $request->getParameter('section_id'))->fetchOne();
         $email_site = $this->section->getContactEmail();
     }
     $this->mailSent = $request->getParameter('mailSent');
     if ($this->site->Program->getIsACourse()) {
         if ($request->getParameter('bloco-de-notas')) {
             $email_site = strip_tags($request->getParameter('email'));
         }
     }
     // mail sender
     if ($email_site != "") {
         if ($request->getParameter('captcha') || $request->getParameter('mande-seu-tema') || $request->getParameter('bloco-de-notas')) {
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $email_user = strip_tags($request->getParameter('email'));
                 $nome_user = strip_tags($request->getParameter('nome'));
                 if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME']) > 0) {
                     // verifica se o servidor que ta o formulario é o mesmo que o chamou, se for um ataque de injeção de dados este valor será diferente
                     ini_set('sendmail_from', $email_site);
                     if ($this->site->Program->getIsACourse()) {
                         $msg = "<p>Veja abaixo suas anotações do curso " . $this->site->getTitle() . ":<p>";
                     } else {
                         $msg = "Formulario Preenchido em " . date("d/m/Y") . " as " . date("H:i:s") . ", seguem abaixo os dados:<br><br>";
                     }
                     if ($this->site->Program->getIsACourse()) {
                         while (list($campo, $valor) = each($_REQUEST)) {
                             if ($campo != "bloco-de-notas") {
                                 if (!in_array(ucwords($campo), array('Form_action', 'X', 'Y', 'Enviar', 'Undefinedform_action', 'Cadastro-tutoria', 'Section_id'))) {
                                     $msg .= "<b>" . ucwords($campo) . ":</b> " . strip_tags($valor) . "<br>";
                                 }
                             }
                         }
                     } else {
                         if ($request->getParameter('cadastro-tutoria')) {
                             $campos = null;
                             if ($_REQUEST["atividade_pretendida1"] != "") {
                                 $campos["atividade_pretendida1"] = $_REQUEST["atividade_pretendida1"];
                             } else {
                                 $campos["atividade_pretendida1"] = " - ";
                             }
                             if ($_REQUEST["atividade_pretendida2"] != "") {
                                 $campos["atividade_pretendida2"] = $_REQUEST["atividade_pretendida2"];
                             } else {
                                 $campos["atividade_pretendida2"] = " - ";
                             }
                             $campos["nome"] = $_REQUEST["nome"];
                             $campos["cpf"] = $_REQUEST["cpf"];
                             $campos["email"] = $_REQUEST["email"];
                             $campos["rede"] = $_REQUEST["rede"];
                             $campos["rede"] = $_REQUEST["rede"];
                             if ($_REQUEST["escola"] != "") {
                                 $campos["escola"] = $_REQUEST["escola"];
                             } else {
                                 $campos["escola"] = " - ";
                             }
                             if ($_REQUEST["atividade"] != "") {
                                 $campos["atividade"] = $_REQUEST["atividade"];
                             } else {
                                 $campos["atividade"] = " - ";
                             }
                             $campos["pcnp"] = $_REQUEST["pcnp"];
                             if ($_REQUEST["pcnp1"] != "") {
                                 $campos["pcnp1"] = $_REQUEST["pcnp1"];
                             } else {
                                 $campos["pcnp1"] = " - ";
                             }
                             if ($_REQUEST["pcnp2"] != "") {
                                 $campos["pcnp2"] = $_REQUEST["pcnp2"];
                             } else {
                                 $campos["pcnp2"] = " - ";
                             }
                             if ($_REQUEST["pcnp3"] != "") {
                                 $campos["pcnp3"] = $_REQUEST["pcnp3"];
                             } else {
                                 $campos["pcnp3"] = " - ";
                             }
                             $campos["de"] = $_REQUEST["de"];
                             $campos["rua"] = $_REQUEST["rua"];
                             $campos["numero"] = $_REQUEST["numero"];
                             if ($_REQUEST["compl"] != "") {
                                 $campos["compl"] = $_REQUEST["compl"];
                             } else {
                                 $campos["compl"] = " - ";
                             }
                             $campos["bairro"] = $_REQUEST["bairro"];
                             $campos["cep"] = $_REQUEST["cep"];
                             $campos["cidade"] = $_REQUEST["cidade"];
                             $campos["estado"] = $_REQUEST["estado"];
                             $campos["dddT"] = $_REQUEST["dddT"];
                             $campos["tel"] = $_REQUEST["tel"];
                             $campos["dddC"] = $_REQUEST["dddC"];
                             $campos["cel"] = $_REQUEST["cel"];
                             if ($_REQUEST["licenciatura1"] != "") {
                                 $campos["licenciatura1"] = $_REQUEST["licenciatura1"];
                             } else {
                                 $campos["licenciatura1"] = " - ";
                             }
                             if ($_REQUEST["licenciatura2"] != "") {
                                 $campos["licenciatura2"] = $_REQUEST["licenciatura2"];
                             } else {
                                 $campos["licenciatura2"] = " - ";
                             }
                             if ($_REQUEST["licenciatura3"] != "") {
                                 $campos["licenciatura3"] = $_REQUEST["licenciatura3"];
                             } else {
                                 $campos["licenciatura3"] = " - ";
                             }
                             $campos["certificado"] = $_REQUEST["certificado"];
                             if ($_REQUEST["ensino"] != "") {
                                 $campos["ensino"] = $_REQUEST["ensino"];
                             } else {
                                 $campos["ensino"] = " - ";
                             }
                             $campos["certificado2"] = $_REQUEST["certificado2"];
                             $filename = "/var/frontend/web/tutores-2013/cadastro.csv";
                             $csv = @file_get_contents($filename);
                             $csv .= "\r\n";
                             $fp = fopen($filename, 'w+');
                         }
                         while (list($campo, $valor) = each($campos)) {
                             if (!in_array(ucwords($campo), array('Form_action', 'X', 'Y', 'Enviar', 'Undefinedform_action'))) {
                                 $msg .= "<b>" . ucwords($campo) . ":</b> " . strip_tags($valor) . "<br>";
                                 $csv .= str_replace(',', ' ', strip_tags($valor)) . ", ";
                             }
                         }
                         if ($request->getParameter('cadastro-tutoria')) {
                             fwrite($fp, $csv);
                             fclose($fp);
                             //die('123');
                         }
                     }
                     $cabecalho = "Return-Path: " . $nome_user . " <" . $email_user . ">\r\n";
                     $cabecalho .= "From: " . $nome_user . " <" . $email_user . ">\r\n";
                     $cabecalho .= "X-Priority: 3\r\n";
                     $cabecalho .= "X-Mailer: Formmail [version 1.0]\r\n";
                     $cabecalho .= "MIME-Version: 1.0\r\n";
                     $cabecalho .= "Content-Transfer-Encoding: 8bit\r\n";
                     $cabecalho .= 'Content-Type: text/html; charset="utf-8"';
                     if (isset($this->section->id)) {
                         $subject = '[' . $this->site->getTitle() . '][' . $this->section->getTitle() . '] ' . $nome_user . ' <' . $email_user . '>';
                     } else {
                         if ($this->site->Program->getIsACourse()) {
                             if ($request->getParameter('bloco-de-notas')) {
                                 $subject = '[' . $this->site->getTitle() . '][Bloco de Notas] ' . $nome_user . ' <' . $email_user . '>';
                             }
                         }
                     }
                     if (mail($email_site, $subject, stripslashes(nl2br($msg)), $cabecalho)) {
                         //header("Location: ".$this->uri."?mailSent=1");
                         if ($request->getParameter('cadastro-tutoria')) {
                             $cabecalho = "From: Cadastro de Tututores 2013 <*****@*****.**>\r\n";
                             $cabecalho .= "X-Priority: 3\r\n";
                             $cabecalho .= "X-Mailer: Formmail [version 1.0]\r\n";
                             $cabecalho .= "MIME-Version: 1.0\r\n";
                             $cabecalho .= "Content-Transfer-Encoding: 8bit\r\n";
                             $cabecalho .= 'Content-Type: text/html; charset="utf-8"';
                             $subject = 'Cadastro efetuado com sucesso';
                             $mailto = $_REQUEST['email'];
                             $msg = "\n\rPrezado professor(a) recebemos seu cadastro, em breve faremos contato para maiores informações.\n\r\n\rAtenciosamente,\n\rEquipe de Tutoria";
                             mail($mailto, $subject, stripslashes(nl2br($msg)), $cabecalho);
                         }
                         die("1");
                     } else {
                         die("0");
                     }
                 } else {
                     header("Location: http://cmais.com.br");
                     die;
                 }
             }
         }
     }
     if ($this->site->getSlug() == "deupaulanatv") {
         unset($assets);
         $aa = Doctrine_Query::create()->select('a.*')->from('Asset a')->where('a.site_id = ?', $this->asset->Site->getId())->andWhere('a.asset_type_id = ?', 1)->andWhere('a.is_active = ?', 1)->orderby('a.created_at')->limit(150)->execute();
         for ($i = 0; $i < count($aa); $i++) {
             if ($request->getParameter('debug') != "") {
                 echo "<br>>>>>>>>>>" . $aa[$i]->getId() . " == " . $this->asset->getId();
             }
             if ($aa[$i]->getId() == $this->asset->getId()) {
                 if ($aa[$i + 1]) {
                     $this->next = $aa[$i + 1]->slug;
                 }
                 $this->prev = $aa[$i - 1]->slug;
             }
         }
         unset($aa);
         if ($request->getParameter('debug') != "") {
             echo "<br /><br /><br /><br /><br />" . $this->prev . "<br />" . $this->next . "<br /><br /><br /><br />";
         }
     }
     //if ($this->site->Program->getIsACourse() && $request->getParameter('test') == 1) {
     if ($this->site->Program->getIsACourse() || $this->site->getSlug() == "1964") {
         $sections = $this->asset->getSections();
         if (count($sections) > 0) {
             $this->section = $sections[0];
             //$start = date("Y/m/d", mktime(0,0,0, substr($this->date,5,2), substr($this->date,8,2) ,substr($this->date,0,4)));
             //$this->assets = $this->section->getAssets();
             $this->assets = Doctrine_Query::create()->select('a.*')->from('Asset a, SectionAsset sa')->where('sa.asset_id = a.id')->andWhere('sa.section_id = ?', $this->section->id)->andWhere('a.site_id = ?', $this->site->id)->andWhere('a.is_active = ?', 1)->orderBy('sa.display_order')->execute();
             for ($k = 0; $k < count($this->assets); $k++) {
                 if ($this->assets[$k]->id == $this->asset->id) {
                     if (count($this->assets) > $k + 1) {
                         $this->assetNext = $this->assets[$k + 1];
                     }
                     if ($k > 0) {
                         $this->assetPrev = $this->assets[$k - 1];
                     }
                 }
             }
         }
     }
     //metas
     if ($this->asset->Site->getSlug() != "cmais") {
         $title = $this->asset->getTitle() . ' - ' . $this->asset->Site->getTitle() . ' - cmais+ O portal de conteúdo da Cultura';
     } else {
         $title = $this->asset->getTitle() . ' - ' . $this->asset->Site->getTitle() . ' O portal de conteúdo da Cultura';
     }
     $og_description = $this->asset->getDescription() . ' - cmais+ O portal de conteúdo da Cultura';
     $tags = "";
     if (count($this->asset->getTags()) > 0) {
         foreach ($this->asset->getTags() as $t) {
             $tags .= $t . ', ';
         }
     }
     $tags .= "cultura, educacao, infantil, jornalismo";
     if ($this->site->getSlug() == "culturabrasil" || $this->site->Program->Channel->getSlug() == "culturabrasil" || $this->site->getSlug() == "especiais-1") {
         if ($this->site->getSlug() == "culturabrasil") {
             $title = $this->site->getTitle() . " - " . $this->asset->getTitle();
         } else {
             $title = "Cultura Brasil - " . $this->site->getTitle() . " - " . $this->asset->getTitle();
         }
         $tags = "";
         if (count($this->asset->getTags()) > 0) {
             foreach ($this->asset->getTags() as $t) {
                 $tags .= $t . ', ';
             }
         }
         $tags .= "musica, musica brasileira, radio cultura, radio cultura brasil, playlist";
         $og_description = "Cultura Brasil - " . $this->asset->getDescription();
     }
     $this->getResponse()->setTitle($title, false);
     //OK
     $this->getResponse()->addMeta('description', $this->asset->getDescription());
     //OK
     $this->getResponse()->addMeta('keywords', $tags);
     //OK
     $this->getResponse()->addMetaProp('og:title', $title);
     //OK
     $this->getResponse()->addMetaProp('og:type', 'article');
     //OK
     $this->getResponse()->addMetaProp('og:description', $og_description);
     //OK
     $this->getResponse()->addMetaProp('og:url', $this->uri);
     //OK
     $this->getResponse()->addMetaProp('og:site_name', 'cmais+');
     //OK
     $og_image = 'http://cmais.com.br/portal/images/logoCMAIS.jpg';
     //OK
     //ogp
     if ($this->asset->AssetType->getSlug() == "video") {
         $this->getResponse()->addMetaProp('og:type', 'video');
         $this->getResponse()->addMetaProp('og:video', 'http://www.youtube.com/v/' . $this->asset->AssetVideo->getYoutubeId() . '?version=3&amp;autohide=1');
         $this->getResponse()->addMetaProp('og:video:type', 'application/x-shockwave-flash');
         $this->getResponse()->addMetaProp('og:video:width', '640');
         $this->getResponse()->addMetaProp('og:video:height', '390');
         $og_image = 'http://i4.ytimg.com/vi/' . $this->asset->AssetVideo->getYoutubeId() . '/0.jpg';
     } elseif ($this->asset->AssetType->getSlug() == "video-gallery") {
         $rel = $this->asset->retriveRelatedAssetsByAssetTypeId(6);
         if (count($rel) > 0) {
             $this->getResponse()->addMetaProp('og:type', 'video');
             $this->getResponse()->addMetaProp('og:video', 'http://www.youtube.com/v/' . $rel[0]->AssetVideo->getYoutubeId() . '?version=3&amp;autohide=1');
             $this->getResponse()->addMetaProp('og:video:type', 'application/x-shockwave-flash');
             $this->getResponse()->addMetaProp('og:video:width', '640');
             $this->getResponse()->addMetaProp('og:video:height', '390');
             $og_image = 'http://i4.ytimg.com/vi/' . $rel[0]->AssetVideo->getYoutubeId() . '/default.jpg';
         }
     } elseif ($this->asset->AssetType->getSlug() == "audio") {
         $this->getResponse()->addMetaProp('og:type', 'audio');
         $this->getResponse()->addMetaProp('og:audio', 'http://midia.cmais.com.br/assets/audio/default/' . $this->asset->AssetAudio->getFile() . '.mp3');
         $this->getResponse()->addMetaProp('og:audio:title', $this->asset->getTitle());
         $this->getResponse()->addMetaProp('og:audio:type', 'application/mp3');
         $og_image = 'http://cmais.com.br/portal/images/logoCMAIS.jpg';
     } elseif ($this->asset->AssetType->getSlug() == "image") {
         $og_image = 'http://midia.cmais.com.br/assets/image/default/' . $this->asset->AssetImage->getFile() . '.jpg';
     } elseif ($this->asset->AssetType->getSlug() == "content") {
         $rel = $this->asset->retriveRelatedAssets();
         if (count($rel) > 0) {
             if ($rel[0]->AssetType->getSlug() == "video") {
                 $this->getResponse()->addMetaProp('og:type', 'video');
                 $this->getResponse()->addMetaProp('og:video', 'http://www.youtube.com/v/' . $rel[0]->AssetVideo->getYoutubeId() . '?version=3&amp;autohide=1');
                 $this->getResponse()->addMetaProp('og:video:type', 'application/x-shockwave-flash');
                 $this->getResponse()->addMetaProp('og:video:width', '640');
                 $this->getResponse()->addMetaProp('og:video:height', '390');
                 $og_image = 'http://i4.ytimg.com/vi/' . $rel[0]->AssetVideo->getYoutubeId() . '/0.jpg';
             } elseif ($rel[0]->AssetType->getSlug() == "video-gallery") {
                 $relatedVideos = $rel[0]->retriveRelatedAssetsByAssetTypeId(6);
                 if (count($relatedVideos) > 0) {
                     $this->getResponse()->addMetaProp('og:type', 'video');
                     $this->getResponse()->addMetaProp('og:video', 'http://www.youtube.com/v/' . $relatedVideos[0]->AssetVideo->getYoutubeId() . '?version=3&amp;autohide=1');
                     $this->getResponse()->addMetaProp('og:video:type', 'application/x-shockwave-flash');
                     $this->getResponse()->addMetaProp('og:video:width', '640');
                     $this->getResponse()->addMetaProp('og:video:height', '390');
                     $og_image = 'http://i4.ytimg.com/vi/' . $relatedVideos[0]->AssetVideo->getYoutubeId() . '/0.jpg';
                 }
             } elseif ($rel[0]->AssetType->getSlug() == "audio") {
                 /*
                 $this->getResponse()->addMetaProp('og:type', 'audio');
                 $this->getResponse()->addMetaProp('og:audio', 'http://midia.cmais.com.br/assets/audio/default/'.$related->AssetAudio->getFile().'.mp3');
                 $this->getResponse()->addMetaProp('og:audio:title', $related->getTitle());
                 $this->getResponse()->addMetaProp('og:audio:type', 'application/mp3');
                 */
                 $og_image = 'http://cmais.com.br/portal/images/logoCMAIS.jpg';
             } elseif ($rel[0]->AssetType->getSlug() == "image") {
                 $og_image = 'http://midia.cmais.com.br/assets/image/default/' . $rel[0]->AssetImage->getFile() . '.jpg';
             }
             /*
             foreach($rel as $related){
               if($related->AssetType->getSlug() == "video"){
                 $this->getResponse()->addMetaProp('og:type', 'video');
                 $this->getResponse()->addMetaProp('og:video', 'http://www.youtube.com/v/'.$related->AssetVideo->getYoutubeId().'?version=3&amp;autohide=1');
                 $this->getResponse()->addMetaProp('og:video:type', 'application/x-shockwave-flash');
                 $this->getResponse()->addMetaProp('og:video:width', '640');
                 $this->getResponse()->addMetaProp('og:video:height', '390');
                 $this->getResponse()->addMetaProp('og:image', 'http://i4.ytimg.com/vi/'.$related->AssetVideo->getYoutubeId().'/default.jpg');
               }
               elseif($related->AssetType->getSlug() == "audio"){
                 $this->getResponse()->addMetaProp('og:type', 'audio');
                 $this->getResponse()->addMetaProp('og:audio', 'http://midia.cmais.com.br/assets/audio/default/'.$related->AssetAudio->getFile().'.mp3');
                 $this->getResponse()->addMetaProp('og:audio:title', $related->getTitle());
                 $this->getResponse()->addMetaProp('og:audio:type', 'application/mp3');
               }
               elseif($related->AssetType->getSlug() == "image"){
                 $this->getResponse()->addMetaProp('og:image', 'http://midia.cmais.com.br/assets/image/default/'.$related->AssetImage->getFile().'.jpg');
               }
             }
             */
         }
     } else {
         if ($this->site->Program->getImageLive() != "") {
             $og_image = 'http://midia.cmais.com.br/programs/' . $this->site->Program->getImageLive();
         } elseif ($this->site->Program->getImageThumb() != "") {
             $og_image = 'http://midia.cmais.com.br/programs/' . $this->site->Program->getImageThumb();
         } elseif ($this->site->getImageThumb() != "") {
             $og_image = 'http://midia.cmais.com.br/programs/' . $this->site->getImageThumb();
         }
     }
     if ($this->site->getSlug() == "radarcultura") {
         $og_image = 'http://radarcultura.cmais.com.br/portal/images/capaPrograma/radarcultura/logo-radar-novo.png';
         $this->getResponse()->addMetaProp('og:description', $title . " " . $description);
     }
     if ($this->site->getSlug() == "culturabrasil" || $this->site->Program->Channel->getSlug() == "culturabrasil" || $this->site->getSlug() == "especiais-1") {
         if ($og_image == "http://cmais.com.br/portal/images/logoCMAIS.jpg") {
             $og_image = "http://midia.cmais.com.br/programs/2cc51003abe67b67284933012d9558611c68c17e.jpg";
         }
     }
     $this->getResponse()->addMetaProp('og:image', $og_image);
     if (!$this->section) {
         $this->section = Doctrine::getTable('Section')->findOneById(1);
     }
     $debug = false;
     if ($request->getParameter('debug') != "") {
         print "<br>Related>>" . count($this->relatedAssets);
         print "<br>SiteType>>" . $this->site->getType();
         print "<br>Asset>>>" . $this->asset->id;
         print "<br>AssetType>>>" . $this->asset->AssetType->getTitle();
         print "<br>1>>>" . $this->section->id;
         print "<br>2>>" . $this->section->slug;
         print "<br>Site Type>>" . $this->site->type;
         $debug = true;
     }
     $this->ipad = false;
     if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
         $this->ipad = true;
     }
     if ($this->site->getSlug() == 'radarcultura' && $this->asset->getSlug() == 'player') {
         $this->setLayout(false);
     }
     /*
         if($this->site->getSlug() == "maiscrianca")
           $this->setLayout(false);
     */
     if ($this->site->getSlug() == "castelo" && $this->asset->getSlug() != "equipe-castelo" && !isset($_REQUEST['layout'])) {
         $this->setLayout(false);
     }
     if ($this->site->getSlug() == "culturabrasil" || $this->site->Program->Channel->getSlug() == "culturabrasil" || $this->site->getSlug() == "especiais-1") {
         $this->setLayout('culturabrasil');
     }
     if ($request->getHost() == "m.cmais.com.br") {
         if (is_file(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/m/' . $this->asset->AssetType->getSlug() . 'Success.php')) {
             $this->setLayout(false);
             if ($debug) {
                 print "<br>2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/m/' . $this->asset->AssetType->getSlug();
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/m/' . $this->asset->AssetType->getSlug());
         }
     } elseif ($this->asset->getSlug() == "seumulticultura") {
         if ($debug) {
             print "<br>multicultura-1 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/seumulticultura';
         }
         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/seumulticultura');
     } elseif ($this->site->getSlug() == "cocorico") {
         $this->setLayout('cocorico');
         if ($this->section->slug == "joguinhos" && $this->asset->getSlug() != "jogo de-pintar") {
             if ($debug) {
                 print "<br>cocorico-1 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/joguinho';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/joguinho');
         }
         if ($this->section->slug == "joguinhos" && $this->asset->getSlug() == "jogo-de-pintar") {
             if ($debug) {
                 print "<br>cocorico-1 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo-de-pintar';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo-de-pintar');
         }
         if ($this->section->slug == "receitinhas") {
             if ($debug) {
                 print "<br>cocorico-receitinhas >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/receitinha';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/receitinha');
         } elseif ($this->section->slug == "tour-virtual") {
             if ($debug) {
                 print "<br>cocorico-3 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/tour-virtual';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/tour-virtual');
         } elseif ($this->section->slug == "convidados") {
             if ($debug) {
                 print "<br>cocorico-4 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/convidado';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/convidado');
         } elseif ($this->section->slug == "naslojas") {
             if ($debug) {
                 print "<br>cocorico-5 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/produto';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/produto');
         } elseif ($this->section->slug == "agenda") {
             if ($debug) {
                 print "<br>cocorico-6 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/agendapost';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/agendapost');
         } elseif ($this->section->slug == "nocinema") {
             if ($debug) {
                 print "<br>cocorico-7 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/cinemapost';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/cinemapost');
         } elseif ($this->section->slug == "bastidores" || $this->section->slug == "erros-de-gravacao") {
             $this->assetsQuery = Doctrine_Query::create()->select('a.*')->from('Asset a, AssetVideo av, SectionAsset sa')->where('sa.section_id = ?', $this->section->id)->andWhere('sa.asset_id = a.id')->andWhere('av.asset_id = a.id')->andWhere('av.youtube_id IS NOT NULL')->andWhere('a.is_active = ?', 1)->orderBy('a.created_at desc');
             $pagelimit = 12;
             $this->pager = new sfDoctrinePager('Asset', $pagelimit);
             $this->pager->setQuery($this->assetsQuery);
             $this->pager->setPage($request->getParameter('page', 1));
             $this->pager->init();
             $this->page = $request->getParameter('page');
             if ($this->section->slug == "erros-de-gravacao") {
                 if ($debug) {
                     print "<br>cocorico-8 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/erros-de-gravacao';
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/erros-de-gravacao');
             } else {
                 if ($debug) {
                     print "<br>cocorico-9 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/bastidores';
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/bastidores');
             }
         } elseif ($this->section->slug == "para-colorir") {
             if ($debug) {
                 print "<br>cocorico-10 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna');
         } elseif ($this->section->slug == "series") {
             $this->assetsQuery = Doctrine_Query::create()->select('a.*')->from('Asset a, AssetVideo av, SectionAsset sa')->where('sa.section_id = ?', $this->section->id)->andWhere('sa.asset_id = a.id')->andWhere('av.asset_id = a.id')->andWhere('av.youtube_id IS NOT NULL')->andWhere('a.is_active = ?', 1)->orderBy('a.created_at desc');
             $pagelimit = 12;
             $this->pager = new sfDoctrinePager('Asset', $pagelimit);
             $this->pager->setQuery($this->assetsQuery);
             $this->pager->setPage($request->getParameter('page', 1));
             $this->pager->init();
             $this->page = $request->getParameter('page');
             if ($debug) {
                 print "<br>cocorico-11 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/series';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/series');
         } elseif ($this->section->slug == "toda-crianca-tem-direito") {
             $this->assetsQuery = Doctrine_Query::create()->select('a.*')->from('Asset a, AssetVideo av, SectionAsset sa')->where('sa.section_id = ?', $this->section->id)->andWhere('sa.asset_id = a.id')->andWhere('av.asset_id = a.id')->andWhere('av.youtube_id IS NOT NULL')->andWhere('a.is_active = ?', 1)->orderBy('a.created_at desc');
             $pagelimit = 24;
             $this->pager = new sfDoctrinePager('Asset', $pagelimit);
             $this->pager->setQuery($this->assetsQuery);
             $this->pager->setPage($request->getParameter('page', 1));
             $this->pager->init();
             $this->page = $request->getParameter('page');
             if ($debug) {
                 print "<br>cocorico-12 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/toda-crianca-tem-direito';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/toda-crianca-tem-direito');
         } elseif ($this->section->slug == "cocorico-na-franca") {
             $this->assetsQuery = Doctrine_Query::create()->select('a.*')->from('Asset a, AssetVideo av, SectionAsset sa')->where('sa.section_id = ?', $this->section->id)->andWhere('sa.asset_id = a.id')->andWhere('av.asset_id = a.id')->andWhere('av.youtube_id IS NOT NULL')->andWhere('a.is_active = ?', 1)->orderBy('a.created_at desc');
             $pagelimit = 24;
             $this->pager = new sfDoctrinePager('Asset', $pagelimit);
             $this->pager->setQuery($this->assetsQuery);
             $this->pager->setPage($request->getParameter('page', 1));
             $this->pager->init();
             $this->page = $request->getParameter('page');
             if ($debug) {
                 print "<br>cocorico-13 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/cocorico-na-franca';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/cocorico-na-franca');
         } elseif ($this->section->slug == "se-liga-no-perigo") {
             $this->assetsQuery = Doctrine_Query::create()->select('a.*')->from('Asset a, AssetVideo av, SectionAsset sa')->where('sa.section_id = ?', $this->section->id)->andWhere('sa.asset_id = a.id')->andWhere('av.asset_id = a.id')->andWhere('av.youtube_id IS NOT NULL')->andWhere('a.is_active = ?', 1)->orderBy('a.created_at desc');
             $pagelimit = 24;
             $this->pager = new sfDoctrinePager('Asset', $pagelimit);
             $this->pager->setQuery($this->assetsQuery);
             $this->pager->setPage($request->getParameter('page', 1));
             $this->pager->init();
             $this->page = $request->getParameter('page');
             if ($debug) {
                 print "<br>cocorico-14 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/se-liga-no-perigo';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/se-liga-no-perigo');
         } elseif ($this->section->slug == "imprima-e-brinque") {
             if ($debug) {
                 print "<br>cocorico-15 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/imprima-e-brinque-interna';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/imprima-e-brinque-interna');
         } elseif ($this->section->slug == "clipes-musicais") {
             if ($debug) {
                 print "<br>cocorico-16 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/clipes-musicais';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/clipes-musicais');
             $this->assets = Doctrine_Query::create()->select('a.*')->from('Asset a, SectionAsset sa')->where('sa.asset_id = a.id')->andWhere('sa.section_id = ?', $this->section->id)->andWhere('a.site_id = ?', $this->site->id)->andWhere('a.is_active = ?', 1)->orderBy('sa.display_order')->execute();
             $pagelimit = 36;
         } elseif ($this->section->slug == "para-colorir") {
             if ($debug) {
                 print "<br>cocorico-17 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna');
         } elseif ($this->section->slug == "papel-de-parede") {
             if ($debug) {
                 print "<br>cocorico-18 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/papel-de-parede-interna';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/papel-de-parede-interna');
         } elseif ($this->section->slug == "episodios" || $this->site->getSlug() == "tvcocorico") {
             if ($debug) {
                 print "<br>cocorico-19 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/episodio';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/episodio');
         } elseif ($this->section->slug == "video") {
             if ($debug) {
                 print "<br>cocorico-20 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/episodio';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/episodio');
         } elseif ($this->section->slug == "para-colorir") {
             if ($debug) {
                 print "<br>cocorico-10 >>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/para-colorir-interna');
         }
     } elseif ($this->site->getSlug() == "quintaldacultura") {
         $slug = $this->asset->AssetType->getSlug();
         foreach ($this->asset->Sections as $s) {
             //if(in_array($s->id, array('92','98','99','100','101'))){
             if ($s->Parent->slug == "jogos") {
                 $slug = "jogo";
                 if ($request->getParameter('param3')) {
                     $this->jogoSubsection = Doctrine::getTable('Section')->findOneBySlug($request->getParameter('param3'));
                 } else {
                     $this->jogoSubsection = Doctrine::getTable('Section')->findOneBySlug('todos');
                 }
             } elseif ($s->Parent->slug == "diversao") {
                 $this->section = Doctrine::getTable('Section')->findOneById($s->id);
                 $slug = "diversao-content";
             } elseif ($s->slug == "agenda") {
                 $this->section = Doctrine::getTable('Section')->findOneById($s->id);
                 $slug = "agenda-interna";
             }
             /*
                     elseif(in_array($s->id, array('94', '103', '106', '104', '105', '127'))){
                       $this->section = Doctrine::getTable('Section')->findOneById($s->id);
                       //$slug = "atividade";
               $slug = "diversao-content";
                     }
                     elseif($s->id == '107')
                       //$slug = "atividade-colorir";
               $slug = "diversao-content";
                     elseif(in_array($s->id, array('97', '765', '764', '763', '762'))){
                       //$slug = "baixar-content";
               $slug = "diversao-content";
                     }
             */
         }
         if ($this->section->getId() == 1) {
             $this->section = $s;
         }
         if ($slug != "content" && $slug != "person") {
             $this->setLayout(false);
         }
         if ($this->asset->getId() == 59156) {
             if ($debug) {
                 print "<br>5-5>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/assets/quebra-cabeca-1Success.php';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/diversao-content');
         } elseif ($this->asset->getSlug() == 'album-de-ferias') {
             if ($debug) {
                 print "<br>5-3>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/assets/album-de-ferias';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/diversao-content');
         } elseif ($this->asset->getId() == 49018) {
             if ($debug) {
                 print "<br>5-4>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/assets/test-8';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/diversao-content');
         } elseif ($slug == "image-gallery" || $slug == "image") {
             if ($debug) {
                 print "<br>5-0>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/imagem';
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/diversao-content');
         } else {
             if ($debug) {
                 print "<br>5-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $slug;
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $slug);
         }
     } else {
         // has template
         if (is_file(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/assets/' . $this->asset->getSlug() . 'Success.php')) {
             if ($this->asset->getIsActive() != "1") {
                 header("Location: " . $this->asset->Site->retriveUrl());
                 die;
             }
             if ($debug) {
                 print "<br>1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/assets/' . $this->asset->getSlug();
             }
             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/assets/' . $this->asset->getSlug());
         } elseif (is_file(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug() . 'Success.php') && $this->site->getSlug() != "tvratimbum") {
             //die(">".$this->section->slug);
             if ($this->site->getSlug() == "radarcultura" && in_array($this->section->slug, array("entrevistas", "cincosons", "quarentoes"))) {
                 if ($debug) {
                     print "<br>2-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/contentRadar';
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/contentRadar');
             } elseif ($this->site->getSlug() == "radarcultura" && $this->section->slug == "musicas") {
                 if ($debug) {
                     print "<br>2-1b>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/musica';
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/musica');
             } elseif ($this->site->getSlug() == "radarcultura" && $this->section->slug == "playlists") {
                 if ($debug) {
                     print "<br>2-1c>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/playlist';
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/playlist');
             } else {
                 if ($this->site->getSlug() == "culturafm") {
                     $sections = $this->asset->getSections();
                     if (count($sections) >= 1) {
                         foreach ($sections as $s) {
                             if ($parentSection = $s->getParent()) {
                                 if ($parentSection->getSlug() == "colunistas") {
                                     if ($debug) {
                                         print "<br>2-2-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug() . 'Colunista';
                                     }
                                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug() . 'Colunista');
                                     break;
                                 } else {
                                     if ($debug) {
                                         print "<br>2-2-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                                     }
                                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                                 }
                             }
                         }
                     } else {
                         if ($debug) {
                             print "<br>2-2-3>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                     }
                 }
                 if ($this->site->getSlug() == "vilasesamo") {
                     // para o shape puzzle
                     //if($this->asset->id != 148169) // id do asset somente para teste, retirar assim que puderem!
                     $this->setLayout("vilasesamo");
                     $sections = $this->asset->getSections();
                     foreach ($sections as $s) {
                         if (in_array($s->getSlug(), array("atividades", "jogos", "videos", "pais-e-educadores"))) {
                             $this->section = $s;
                             break;
                         }
                     }
                     if ($this->section->getSlug() == "atividades") {
                         if ($debug) {
                             print "<br>2-3-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/atividade';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/atividade');
                     } elseif ($this->section->getSlug() == "jogos") {
                         if ($debug) {
                             print "<br>2-3-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo');
                     } elseif ($this->section->getSlug() == "videos") {
                         if ($debug) {
                             print "<br>2-3-3>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/video';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/video');
                     } elseif ($this->section->getSlug() == "pais-e-educadores") {
                         if ($debug) {
                             print "<br>2-3-4>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/artigo';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/artigo');
                     } else {
                         if ($debug) {
                             print "<br>2-3-5>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                     }
                 } else {
                     if ($debug) {
                         print "<br>2-4>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                 }
             }
         } else {
             if ($this->site->getType() == "Hotsite" || $this->site->getType() == 1) {
                 if (in_array($this->site->getSlug(), array("revistavitrine", "revistavitrine2"))) {
                     if ($debug) {
                         print "<br>3-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/online';
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/online');
                 } else {
                     if ($debug) {
                         print "<br>3-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultHotsite/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultHotsite/' . $this->asset->AssetType->getSlug());
                 }
                 if ($this->site->getSlug() == "vilasesamo") {
                     //if($this->asset->id != 148169) // id do asset somente para teste, retirar assim que puderem!
                     $this->setLayout("vilasesamo");
                     $sections = $this->asset->getSections();
                     foreach ($sections as $s) {
                         if (in_array($s->getSlug(), array("atividades", "jogos", "videos", "pais-e-educadores"))) {
                             $this->section = $s;
                             break;
                         }
                     }
                     if ($this->section->getSlug() == "atividades") {
                         if ($debug) {
                             print "<br>3-1-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/atividade';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/atividade');
                     } elseif ($this->section->getSlug() == "jogos") {
                         if ($debug) {
                             print "<br>3-1-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/jogo');
                     } elseif ($this->section->getSlug() == "videos") {
                         if ($debug) {
                             print "<br>3-1-3>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/video';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/video');
                     } elseif ($this->section->getSlug() == "pais-e-educadores") {
                         if ($debug) {
                             print "<br>3-1-4>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/artigo';
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/artigo');
                     } else {
                         if ($debug) {
                             print "<br>3-1-5>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                     }
                 } else {
                     if ($debug) {
                         print "<br>3-6>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                 }
             } elseif (($this->site->getType() == "Portal" || $this->site->getType() == 2) && $this->site->getSlug() != "tvratimbum") {
                 if (in_array($this->asset->getId(), array(121120, 121117, 120858, 121146, 121145, 122440, 127638, 127974, 130827, 131375, 131368, 131702, 139908, 140033, 140035))) {
                     if ($debug) {
                         print "<br>4-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/cmais/tutores-content';
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/cmais/tutores-content');
                 } else {
                     if ($debug) {
                         print "<br>4-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPortal/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPortal/' . $this->asset->AssetType->getSlug());
                 }
             } elseif ($this->site->getType() == "Programa" || $this->site->getType() == 3) {
                 if ($debug) {
                     print "<br>5>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPrograma/' . $this->asset->AssetType->getSlug();
                 }
                 if ($this->asset->AssetType->getSlug() == "person") {
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPrograma/content');
                 } elseif ($this->asset->AssetType->getSlug() == "episode") {
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPrograma/video-gallery');
                 } else {
                     if ($this->site->Program->getIsACourse()) {
                         /*
                         		          if(in_array($this->site->getSlug(), array("pedagogia-unesp","evs","licenciatura-em-ciencias"))){
                         		          	if($debug) print "<br>5.1>>".sfConfig::get('sf_app_template_dir').DIRECTORY_SEPARATOR.'sites/univesptv/content-cursoAntigo';
                         			          $this->setTemplate(sfConfig::get('sf_app_template_dir').DIRECTORY_SEPARATOR.'sites/univesptv/content-cursoAntigo');
                         		          }
                         							else {
                         */
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/univesptv/content-curso');
                         if ($debug) {
                             print "<br>5-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/univesptv/content-curso';
                         }
                         //}
                     } else {
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultPrograma/' . $this->asset->AssetType->getSlug());
                     }
                 }
             } elseif ($this->site->getType() == "ProgramaRadio") {
                 if (in_array($this->asset->Site->getSlug(), array("cultura-jazz", "estudio-cultura", "espirais", "brasilis", "novos-acordes", "super-8", "paralelos", "master-class", "manha-cultura", "entrelinhas-1", "cd-da-semana", "arquivo-vivo", "interprete"))) {
                     if ($debug) {
                         print "<br>2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaRadio/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaRadio/' . $this->asset->AssetType->getSlug());
                 } else {
                     if (is_file(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug() . 'Success.php')) {
                         if ($debug) {
                             print "<br>2-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug();
                         }
                         $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/' . $this->site->getSlug() . '/' . $this->asset->AssetType->getSlug());
                     } else {
                         if ($this->site->Program->Channel->getSlug() == "culturabrasil" || $this->site->getSlug() == "especiais-1") {
                             if ($debug) {
                                 print "<br>2-1-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/culturabrasil/' . $this->asset->AssetType->getSlug();
                             }
                             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/culturabrasil/' . $this->asset->AssetType->getSlug());
                         } else {
                             if ($debug) {
                                 print "<br>2-1-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaRadio/' . $this->asset->AssetType->getSlug();
                             }
                             $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaRadio/' . $this->asset->AssetType->getSlug());
                         }
                     }
                 }
             } elseif ($this->site->getType() == "Programa Infantil") {
                 if ($this->asset->AssetType->getSlug() == "image-gallery" || $this->asset->AssetType->getSlug() == "image") {
                     $this->setLayout(false);
                     if ($debug) {
                         print "<br>6-0>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/imagem';
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/diversao-content');
                 } elseif ($this->asset->AssetType->getSlug() != "content" && $this->asset->AssetType->getSlug() != "video" && $this->asset->AssetType->getSlug() != "person") {
                     if ($debug) {
                         print "<br>6-0>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug());
                 } else {
                     if ($this->asset->AssetType->getSlug() == "video") {
                         $this->setLayout(false);
                     }
                     if ($debug) {
                         print "<br>6-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/quintaldacultura/' . $this->asset->AssetType->getSlug());
                 }
             } elseif ($this->site->getType() == "Programa TVRTB" || $this->site->getSlug() == "tvratimbum") {
                 if ($this->asset->AssetType->getSlug() == "image-gallery" || $this->asset->AssetType->getSlug() == "image") {
                     if ($debug) {
                         print "<br>6-0>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/imagem';
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/imagem');
                 } elseif ($this->asset->AssetType->getSlug() != "content" && $this->asset->AssetType->getSlug() != "video" && $this->asset->AssetType->getSlug() != "person") {
                     if ($debug) {
                         print "<br>6-0>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/programas/' . $this->asset->AssetType->getSlug();
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/programas/' . $this->asset->AssetType->getSlug());
                 } else {
                     $sec = $this->asset->Sections[0];
                     //echo ">>>>>".$sec->getSlug();
                     if ($sec->getSlug() == "jogos") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "aventura") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "desafio") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "esportes") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "educativos") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "habilidade") {
                         $s = "jogo";
                     } elseif ($sec->getSlug() == "imagens") {
                         $s = "imagem";
                     } elseif ($sec->getSlug() == "videos") {
                         $s = "video";
                     } elseif ($sec->getSlug() == "baixar") {
                         $s = "baixarAsset";
                     } elseif ($sec->getSlug() == "carinhas") {
                         $s = "carinha";
                     } elseif ($sec->getSlug() == "brincadeiras") {
                         $s = "baixarAsset";
                     } elseif ($sec->getSlug() == "cartoes") {
                         $s = "baixarAsset";
                     } elseif ($sec->getSlug() == "papel-de-parede") {
                         $s = "papel-de-parede";
                     } elseif ($sec->getSlug() == "papeldeparede") {
                         $s = "papel-de-parede";
                     } elseif ($sec->getSlug() == "atividades") {
                         $s = "atividade";
                     } elseif ($sec->getSlug() == "para-colorir") {
                         $s = "para-colorir";
                     } elseif ($sec->getSlug() == "para-colorir-") {
                         $s = "para-colorir";
                     } elseif ($sec->getSlug() == "magicas") {
                         $s = "atividade";
                     } elseif ($sec->getSlug() == "experiencias") {
                         $s = "atividade";
                     } elseif ($sec->getSlug() == "receitinhas") {
                         $s = "atividade";
                     } elseif ($sec->getSlug() == "artes") {
                         $s = "atividade";
                     } elseif ($sec->getSlug() == "personagens") {
                         $s = "programas/personagen";
                     } elseif ($sec->getSlug() == "especial") {
                         $s = "especialAsset";
                     }
                     if ($debug) {
                         print "<br>6-1>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/' . $s;
                     }
                     $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/tvratimbum/' . $s);
                 }
             } elseif ($this->site->getType() == "Programa Simples" || $this->site->getType() == 4) {
                 if ($debug) {
                     print "<br>6-2>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug();
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug());
             } else {
                 if ($debug) {
                     print "<br>7>>" . sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug();
                 }
                 $this->setTemplate(sfConfig::get('sf_app_template_dir') . DIRECTORY_SEPARATOR . 'sites/defaultProgramaSimples/' . $this->asset->AssetType->getSlug());
             }
         }
     }
 }
示例#15
0
 public function executeInstrumentNotication(sfWebRequest $request)
 {
     $c = new Criteria();
     $c->add(PersonRolePeer::PERSON_ID, $this->getUser()->getId());
     $c->addJoin(PersonRolePeer::ROLE_ID, RoleNotificationPeer::ROLE_ID);
     $personNotification = RoleNotificationPeer::doSelect($c);
     $this->mid = 0;
     foreach ($personNotification as $key => $value) {
         $this->mid = $value->getMid();
         $this->notification = $value->getNotification();
         //5. person add
         if ($this->mid == 5 && ($this->notification == 2 || $this->notification == 3)) {
             $c = new Criteria();
             $c->addDescendingOrderByColumn(PersonPeer::ID);
             $c->setLimit(5);
             $this->newperson = PersonPeer::doSelect($c);
         }
     }
     $this->host = $request->getHost();
     $this->memberId = $this->getUser()->getMemberId();
     //$query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request ";
     //$query .="WHERE pilot_request.accepted = 1 AND pilot_request.processed = 1 AND pilot_request.member_id = ".$this->memberId;
     //$con = Propel::getConnection();
     //$stmt = $con->prepare($query);
     //$stmt->execute();
     /*if($rs = $stmt->fetch(PDO::FETCH_NUM)) {
         $count = (int)$rs[0];
       }else{
         $count = 0;
       }*/
     $c = new Criteria();
     $c->add(PilotRequestPeer::ACCEPTED, 1);
     $c->add(PilotRequestPeer::PROCESSED, 1);
     $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId);
     $this->totalAccepted = PilotRequestPeer::doCount($c);
     /* $this->memberId = $this->getUser()->getMemberId();
          $query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request ";
          $query .="WHERE pilot_request.accepted = 0 AND pilot_request.member_id = $this->memberId";
          $con = Propel::getConnection();
          $stmt = $con->prepare($query);
          $stmt->execute();
     
          if($rs = $stmt->fetch(PDO::FETCH_NUM)) {
            $count = (int)$rs[0];
          }else{
            $count = 0;
          }*/
     $c = new Criteria();
     $c->add(PilotRequestPeer::ACCEPTED, 0);
     $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId);
     $this->totaldeclined = PilotRequestPeer::doCount($c);
     $c = new Criteria();
     $c->add(MissionLegPeer::PILOT_ID, $this->getUser()->getPilotId());
     $c->add(MissionLegPeer::CANCEL_MISSION_LEG, 0);
     $this->totalMissionCancellation = MissionLegPeer::doCount($c);
     //total signup events count
     $pilot_id = $this->getUser()->getPilotId();
     if ($pilot_id) {
         $pilot = PilotPeer::retrieveByPK($pilot_id);
         $member_id = $pilot->getMemberId();
         $date = date('Y-m-d');
         $c = new Criteria();
         $c->add(EventReservationPeer::MEMBER_ID, $member_id, Criteria::EQUAL);
         $c->addJoin(EventPeer::ID, EventReservationPeer::EVENT_ID);
         $c->add(EventPeer::EVENT_DATE, $date, Criteria::GREATER_EQUAL);
         $this->totalSignupEvents = EventReservationPeer::doCount($c);
     }
     //
 }
示例#16
0
 public function executeView(sfWebRequest $request)
 {
     $etva_data = Etva::getEtvaModelFile();
     $this->etvamodel = $etva_data['model'];
     $this->host = $request->getHost();
 }