Example #1
0
 /**
  * Get base lang object from session.
  *
  * @return \Syscover\Pulsar\Models\Lang
  */
 function base_lang()
 {
     if (session('baseLang') === null) {
         session(['baseLang' => \Syscover\Pulsar\Models\Lang::getBaseLang()]);
     }
     return session('baseLang');
 }
Example #2
0
 public function editCustomRecord($parameters)
 {
     $parameters['langs'] = Lang::all();
     $parameters['groups'] = Group::all();
     $parameters['genres'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('pulsar.genres'));
     $parameters['treatments'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('pulsar.treatments'));
     $parameters['states'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('pulsar.states'));
     // get attachments elements
     $attachments = AttachmentLibrary::getRecords('crm', 'crm-customer', $parameters['object']->id_301, base_lang()->id_001);
     // merge parameters and attachments array
     $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'cms-article']);
     $parameters = array_merge($parameters, $attachments);
     return $parameters;
 }
Example #3
0
 /**
  * Handle a login request to the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(Request $request)
 {
     $this->validate($request, ['user' => 'required', 'password' => 'required']);
     $credentials = $request->only('user', 'password');
     if (auth('pulsar')->attempt($credentials, $request->has('remember'))) {
         // check if user has access
         if (!auth('pulsar')->user()->access_010) {
             auth('pulsar')->logout();
             return redirect($this->loginPath)->withInput($request->only('user', 'remember'))->withErrors(['loginErrors' => 3]);
         }
         // set user access control list
         session(['userAcl' => AclLibrary::getProfileAcl(auth('pulsar')->user()->profile_id_010)]);
         // check if user has permission to access
         if (!is_allowed('pulsar', 'access')) {
             auth('pulsar')->logout();
             return redirect($this->loginPath)->withInput($request->only('user', 'remember'))->withErrors(['loginErrors' => 2]);
         }
         session(['packages' => Package::getRecords(['active_012' => true, 'orderBy' => ['column' => 'sorting_012', 'order' => 'desc']])]);
         session(['baseLang' => Lang::getBaseLang()]);
         return redirect()->intended($this->redirectTo);
     }
     return redirect($this->loginPath)->withInput($request->only('user', 'remember'))->withErrors(['loginErrors' => 1]);
 }
Example #4
0
 public static function getActivesLangs()
 {
     return Lang::where('active_001', true)->get();
 }
Example #5
0
 public function ajaxDeleteImage($id)
 {
     $object = Lang::find($id);
     File::delete(public_path() . '/packages/syscover/pulsar/storage/langs/' . $object->image_001);
     Lang::where('id_001', $id)->update(['image_001' => null]);
 }
 public function run()
 {
     Lang::insert([['id_001' => 'de', 'name_001' => 'Alemán', 'image_001' => 'de.jpg', 'sorting_001' => '0', 'base_001' => '0', 'active_001' => '1'], ['id_001' => 'en', 'name_001' => 'Inglés', 'image_001' => 'en.jpg', 'sorting_001' => '0', 'base_001' => '0', 'active_001' => '1'], ['id_001' => 'es', 'name_001' => 'Español', 'image_001' => 'es.jpg', 'sorting_001' => '1', 'base_001' => '1', 'active_001' => '1'], ['id_001' => 'fr', 'name_001' => 'Francés', 'image_001' => 'fr.jpg', 'sorting_001' => '0', 'base_001' => '0', 'active_001' => '1']]);
 }
Example #7
0
 public function editCustomRecord($parameters)
 {
     $parameters['langs'] = Lang::getActivesLangs();
     $parameters['profiles'] = Profile::all();
     return $parameters;
 }
Example #8
0
 public function getCountries()
 {
     // get base lang from database because this function is call from cron, without create session variable baseLang
     $baseLang = Lang::getBaseLang()->id_001;
     return EmailCampaign::belongsToMany('Syscover\\Pulsar\\Models\\Country', '005_045_email_campaigns_countries', 'campaign_id_045', 'country_id_045')->where('001_002_country.lang_id_002', $baseLang);
 }
Example #9
0
 /**
  * @access      public
  * @return      \Illuminate\Support\Facades\View
  */
 public function createRecord()
 {
     // get parameters from url route
     $parameters = $this->request->route()->parameters();
     $parameters['urlParameters'] = $parameters;
     // check if create route has modal
     // is necessary to have modal paramenter in all routes for proper operation
     if (Route::current()->hasParameter('modal')) {
         // check if this element is modal, to mark in your url petition
         if (isset($parameters['modal']) && $parameters['modal'] == 1) {
             $parameters['urlParameters']['modal'] = 1;
         } else {
             $parameters['urlParameters']['modal'] = 0;
         }
     }
     // get lang object
     if (isset($parameters['lang'])) {
         $parameters['lang'] = Lang::builder()->find($parameters['lang']);
     }
     $parameters = $this->createCustomRecord($parameters);
     // check if parameters is a RedirectResponse object, to send request to other url
     if (is_object($parameters) && get_class($parameters) == \Illuminate\Http\RedirectResponse::class) {
         return $parameters;
     }
     $parameters['resource'] = $this->resource;
     $parameters['package'] = $this->package;
     $parameters['folder'] = $this->folder;
     $parameters['routeSuffix'] = $this->routeSuffix;
     $parameters['icon'] = $this->icon;
     // traslate of object that we are operate, this variable is instance in controller
     $parameters['objectTrans'] = isset($this->objectTrans) && $this->objectTrans != null ? Miscellaneous::getObjectTransValue($parameters, $this->objectTrans) : null;
     // check if action is store or storeLang
     if (isset($parameters['id']) && isset($parameters['lang'])) {
         // set baseLang to get baseLang object
         $parametersAux = $parameters;
         $parametersAux['lang'] = base_lang()->id_001;
         $parameters['object'] = call_user_func($this->model . '::getTranslationRecord', $parametersAux);
         $parameters['action'] = 'storeLang';
     } else {
         $parameters['action'] = 'store';
     }
     // set viewParamentes on parameters for throw to view
     $parameters['viewParameters'] = $this->viewParameters;
     // check if exist create view, default all request go to common view
     if (view()->exists($this->package . '::' . $this->folder . '.create', $parameters)) {
         return view($this->package . '::' . $this->folder . '.create', $parameters);
     } else {
         return view($this->package . '::' . $this->folder . '.form', $parameters);
     }
 }