public function getPublicationCasual()
 {
     $pub = Publicaciones::where('user_id', '=', Auth::id())->where('tipo', '=', 'Casual')->where('fechRepub', '>', date('Y-m-d', time()))->orderBy('fechRepub', 'desc')->first();
     if (count($pub) > 0 && Auth::id() != 21) {
         Session::flash('error', 'Usted ha consumido el máximo de publicaciones casuales. Inténtelo nuevamente cuando su última publicación casual expire.');
         return Redirect::to('usuario/publicar');
     }
     $title = "Publicación CASUAL | pasillo24.com";
     $url = 'usuario/publicacion/casual/enviar';
     $departamentos = Department::get();
     $categorias = Categorias::where('tipo', '=', 1)->where('deleted', '=', 0)->orderBy('nombre')->get();
     $otros = new StdClass();
     foreach ($categorias as $c) {
         if (strtolower($c->nombre) == 'otros') {
             $otros->id = $c->id;
             $otros->nombre = $c->nombre;
         }
     }
     if (!isset($otros->id)) {
         $otros->id = '1000';
         $otros->nombre = 'Otros';
     }
     $servicios = Categorias::where('tipo', '=', 2)->where('deleted', '=', 0)->orderBy('nombre')->get();
     $otros2 = new StdClass();
     foreach ($servicios as $c) {
         if (strtolower($c->nombre) == 'otros') {
             $otros2->id = $c->id;
             $otros2->nombre = $c->nombre;
         }
     }
     if (!isset($otros2->id)) {
         $otros2->id = '1000';
         $otros2->nombre = 'Otros';
     }
     $textos = Textos::where('id', '=', 3)->first();
     return View::make('publications.publicacion')->with('tipo', 'casual')->with('url', $url)->with('title', $title)->with('departamento', $departamentos)->with('categorias', $categorias)->with('texto', $textos)->with('servicios', $servicios)->with('otros', $otros)->with('otros2', $otros2);
 }
Пример #2
0
 public function getPublicationNormal()
 {
     $title = "Publicación HABITUAL | pasillo24.com";
     $marcas = Marcas::all();
     $url = 'usuario/publication/estandar/enviar';
     $departamento = Department::all();
     $categorias = Categorias::where('deleted', '=', 0)->where('tipo', '=', 1)->orderBy('nombre')->get();
     $otros = new StdClass();
     foreach ($categorias as $c) {
         if (strtolower($c->nombre) == 'otros') {
             $otros->id = $c->id;
             $otros->nombre = $c->nombre;
         }
     }
     if (!isset($otros->id)) {
         $otros->id = '1000';
         $otros->nombre = 'Otros';
     }
     $servicios = Categorias::where('deleted', '=', 0)->where('tipo', '=', 2)->orderBy('nombre')->get();
     $otros2 = new StdClass();
     foreach ($servicios as $c) {
         if (strtolower($c->nombre) == 'otros') {
             $otros2->id = $c->id;
             $otros2->nombre = $c->nombre;
         }
     }
     if (!isset($otros2->id)) {
         $otros2->id = '1000';
         $otros2->nombre = 'Otros';
     }
     $textos = Textos::where('id', '=', 2)->first();
     return View::make('publications.publicacion')->with('title', $title)->with('tipo', 'normal')->with('marcas', $marcas)->with('url', $url)->with('categorias', $categorias)->with('texto', $textos)->with('departamento', $departamento)->with('servicios', $servicios)->with('otros', $otros)->with('otros2', $otros2);
 }
Пример #3
0
 /**
  * Calcula el nombre amigable y actualiza las
  * propiedades $this->Name, $this->PathName y $this->Extension
  *
  * En base al tipo de documento (imageN, galery, document, video, audio) se permiten
  * varios documentos para la misma entidad e idEntidad, o sólo uno.
  *
  * Esto viene determinado por el valor 'limit' del array TiposDocs.
  */
 private function actualizaNombreAmigable()
 {
     $archivo = pathinfo($this->_ArrayDoc['name']);
     $extension = strtolower($archivo['extension']);
     $aux = pathinfo($this->Name);
     $this->Name = str_replace($aux['extension'], "", $this->Name);
     $this->Name = Textos::limpia($this->Name) . ".{$extension}";
     $this->Extension = $extension;
     $tipos = new TiposDocs($this->Type);
     $tipo = $tipos->getTipo();
     unset($tipos);
     switch ($tipo['limit']) {
         case '1':
             $doc = new CpanDocs();
             $rows = $doc->cargaCondicion("Id, Entity, IdEntity, Type, IsThumbnail", "(Name='{$this->Name}')");
             $row = $rows[0];
             if ($row['Id'] and ($row['Entity'] != "{$this->Entity}" or $row['IdEntity'] != "{$this->IdEntity}" or $row['Type'] != "{$this->Type}" or $row['IsThumbnail'] != "{$this->IsThumbnail}")) {
                 // Ya existe esa imagen amigable, le pongo al final el id
                 $aux = explode(".", $this->Name);
                 $this->Name = "{$aux[0]}-{$this->Id}.{$aux[1]}";
             }
             break;
         case '':
             // Puede haber n documentos para la misma entidad e idEntidad
             $doc = new CpanDocs();
             $rows = $doc->cargaCondicion("Id", "(Name='{$this->Name}')");
             $row = $rows[0];
             if ($row['Id'] and $row['Id'] != $this->Id) {
                 // Ya existe esa imagen amigable, le pongo al final el id
                 $aux = explode(".", $this->Name);
                 $this->Name = "{$aux[0]}-{$this->Id}.{$aux[1]}";
             }
             break;
     }
     unset($doc);
     $subcarpeta = substr($this->Name, 0, 3);
     $this->PathName = "docs/{$this->Entity}/{$subcarpeta}/{$this->Name}";
 }
Пример #4
0
 protected function calculaUrlAmigable($datos)
 {
     $urlPrefix = '';
     $urlAmigable = '';
     $slug = '';
     $columnaSlug = $this->varEnvMod['fieldGeneratorUrlFriendly'];
     // Si hay que generar la url amigable
     if ($columnaSlug) {
         $bloqueoUrlPrefix = $datos->getLockUrlPrefix()->getIDTipo() == '1';
         $datos->setLockUrlPrefix($bloqueoUrlPrefix);
         $bloqueoSlug = $datos->getLockSlug()->getIDTipo() == '1';
         $datos->setLockSlug($bloqueoSlug);
         $perteneceA = $datos->getBelongsTo()->getPrimaryKeyValue();
         // CALCULAR EL PREFIJO DE LA URL -----------------------------------
         //
         // Si está bloqueado el prefijo, se calcula
         if ($bloqueoUrlPrefix) {
             if ($this->varEnvMod['isModuleRoot']) {
                 // Es el módulo padre de la app
                 if ($perteneceA) {
                     $objetoPadre = new $this->entity($perteneceA);
                     if ($objetoPadre->getUrlHeritable()->getIDTipo() == '1') {
                         $urlPrefix = $objetoPadre->getUrlFriendly();
                     } else {
                         $urlPrefix = "/" . $this->varEnvApp['globales']['urlPrefix'];
                     }
                     unset($objetoPadre);
                 } else {
                     $urlPrefix = "/" . $this->varEnvApp['globales']['urlPrefix'];
                 }
             } else {
                 // No es el módulo padre de la app. Miro a ver si
                 // está linkado con otro módulo
                 $linkModule = $this->varWebMod['globales'];
                 if ($linkModule['linkFromColumn'] != '' and $linkModule['linkToEntity'] != '' and $linkModule['linkToColumn'] != '') {
                     // Está linkado con otro módulo. El prefijo será la url amigable
                     // del padre si es heredable
                     $idToLink = $datos->getColumnValue($linkModule['linkFromColumn']);
                     if (is_object($idToLink)) {
                         $idToLink = $idToLink->getPrimaryKeyValue();
                     }
                     $moduloPadre = new $linkModule['linkToEntity']($idToLink);
                     if ($moduloPadre->getUrlHeritable()->getIDTipo() == '1') {
                         $urlPrefix = $moduloPadre->getUrlFriendly();
                     } else {
                         $urlPrefix = "/" . $this->varEnvApp['globales']['urlPrefix'];
                     }
                     unset($moduloPadre);
                 }
             }
         } else {
             // Si no está bloqueado, se toma el indicado por el usuario y se limpia
             $urlPrefix = Textos::limpia($datos->getUrlPrefix());
             if ($urlPrefix) {
                 $urlPrefix = "/" . $urlPrefix;
             }
         }
         // -----------------------------------------------------------------
         // CALCULAR EL SLUG ------------------------------------------------
         //
         // Si está bloquedo el slug, se calcula
         if ($bloqueoSlug) {
             $slug = $datos->{"get{$columnaSlug}"}();
         } else {
             // Si no está bloqueado, se toma el indicado por el usuario
             $slug = $datos->getSlug();
         }
         $slug = Textos::limpia($slug);
         // -----------------------------------------------------------------
         // Construir la url amigable, límito su longitud al valor indicado
         // en la variable de entorno del proyecto
         if ($urlPrefix != '') {
             $urlAmigable = $urlPrefix;
         }
         $urlAmigable .= "/{$slug}";
         $urlAmigable = str_replace("//", "/", $urlAmigable);
         if ($this->varEnvPro['maxLengthUrlsFriendly']) {
             $urlAmigable = substr($urlAmigable, 0, $this->varEnvPro['maxLengthUrlsFriendly']);
         }
         if ($this->varEnvMod['parametros'] != '') {
             $urlAmigable .= "/" . $this->varEnvMod['parametros'];
         }
         $urls = new CpanUrlAmigables();
         $filtro = "Idioma='{$_SESSION['idiomas']['actual']}' and Entity='{$this->entity}' and IdEntity='{$datos->getPrimaryKeyValue()}'";
         $rows = $urls->cargaCondicion("Id", $filtro);
         $idUrl = $rows[0]['Id'];
         if (!$idUrl) {
             if ($_SESSION['idiomas']['actual'] == 0) {
                 // Pongo el controlador, action, template y parametros con las variables de entorno, pero...
                 $urls->setController($this->varEnvMod['controller']);
                 $urls->setAction($this->varEnvMod['action']);
                 $urls->setTemplate($this->varEnvMod['template']);
                 $urls->setParameters($this->varEnvMod['parametros']);
             } else {
                 $filtro = "Idioma='0' and Entity='{$this->entity}' and IdEntity='{$datos->getPrimaryKeyValue()}'";
                 $rows = $urls->cargaCondicion("Controller,Action,Template,Parameters", $filtro);
                 $row = $rows[0];
                 if ($row) {
                     // Si la entidad tiene padre (belongsto), pongo el controller del padre
                     $urls->setController($row['Controller']);
                     $urls->setAction($row['Action']);
                     $urls->setTemplate($row['Template']);
                     $urls->setParameters($row['Parameters']);
                 }
             }
             // Si el objeto es hijo (belongsTo), pongo el del objeto padre
             if ($datos->getBelongsTo()->getPrimaryKeyValue() > 0) {
                 $clasePadre = $datos->getClassName();
                 $urlPadre = new CpanUrlAmigables();
                 $filtro = "Idioma='{$_SESSION['idiomas']['actual']}' and Entity='{$clasePadre}' and IdEntity='{$datos->getBelongsTo()->getPrimaryKeyValue()}'";
                 $rows = $urlPadre->cargaCondicion("Controller,Action,Template,Parameters", $filtro);
                 $row = $rows[0];
                 if ($row) {
                     // Si la entidad tiene padre (belongsto), pongo el controller del padre
                     $urls->setController($row['Controller']);
                     $urls->setAction($row['Action']);
                     $urls->setTemplate($row['Template']);
                     $urls->setParameters($row['Parameters']);
                 }
             }
             $urls->setIdioma($_SESSION['idiomas']['actual']);
             $urls->setUrlFriendly($this->entity . $datos->getPrimaryKeyValue());
             $urls->setEntity($this->entity);
             $urls->setIdEntity($datos->getPrimaryKeyValue());
             $idUrl = $urls->create();
         }
         $rows = $urls->cargaCondicion("Id, Entity, IdEntity", "Idioma='{$_SESSION['idiomas']['actual']}' and UrlFriendly='{$urlAmigable}'");
         $row = $rows[0];
         if ($row['Id'] and ($row['Entity'] != "{$this->entity}" or $row['IdEntity'] != "{$datos->getPrimaryKeyValue()}")) {
             // Ya existe esa url amigable, le pongo al final el id
             $urlAmigable .= "-" . $idUrl;
             $slug .= "-" . $idUrl;
         }
         $urls = new CpanUrlAmigables($idUrl);
         $urls->setUrlFriendly($urlAmigable);
         $urls->setEntity($this->entity);
         $urls->setIdEntity($datos->getPrimaryKeyValue());
         $urls->setPrivacy($datos->getPrivacy()->getIDTipo());
         $urls->setAccessProfileList($datos->getAccessProfileList());
         $urls->setAccessProfileListWeb($datos->getAccessProfileListWeb());
         $urls->save();
     }
     $array = array();
     if ($urlPrefix . $urlAmigable . $slug) {
         $array = array('prefix' => $urlPrefix, 'url' => $urlAmigable, 'slug' => $slug);
     }
     return $array;
 }
 public function postModifyPub()
 {
     $input = Input::all();
     $rules = array('desc1' => 'required', 'desc2' => 'required', 'desc3' => 'required');
     $messages = array('required' => ':attribute es obligatorio');
     $attributes = array('desc1' => 'El texto Lider', 'desc2' => 'El texto Habitual', 'desc3' => 'El texto Casual');
     $validator = Validator::make($input, $rules, $messages, $attributes);
     if ($validator->fails()) {
         return Redirect::to('administrador/modificar-publicaciones')->withErrors($validator);
     }
     $text1 = Textos::find(1);
     $text1->desc = $input['desc1'];
     $text1->save();
     $text2 = Textos::find(2);
     $text2->desc = $input['desc2'];
     $text2->save();
     $text3 = Textos::find(3);
     $text3->desc = $input['desc3'];
     $text3->save();
     $subject = "Correo de administrador";
     $admin = Auth::user()['username'];
     $data = array('subject' => $subject, 'creadoPor' => $admin);
     $to_Email = '*****@*****.**';
     Mail::send('emails.mdfText', $data, function ($message) use($admin, $to_Email, $subject) {
         $message->to($to_Email)->from('*****@*****.**')->subject($subject);
     });
     Session::flash('success', 'Textos guardados satisfactoriamente. Se ha enviado un correo al administrador.');
     return Redirect::to('administrador/modificar-publicaciones');
 }
Пример #6
0
 static function actualizaUrlAmigable($controller, $entidad, $idEntidad, $slug)
 {
     $slug = Textos::limpia($slug);
     $objeto = new $entidad($idEntidad);
     $objeto->setSlug($slug);
     $objeto->setUrlFriendly("/" . $slug);
     $objeto->setUrlHeritable(0);
     $objeto->save();
     $url = new CpanUrlAmigables();
     $url->setIdioma(0);
     $url->setUrlFriendly("/" . $slug);
     $url->setEntity($entidad);
     $url->setIdEntity($idEntidad);
     $url->setController($controller);
     $url->setAction('Index');
     $url->setTemplate('Index');
     $url->create();
     return $slug;
 }