public function __construct()
 {
     //$this->beforeFilter(function(){  });
     $this->uriSegment = null;
     $this->modelName = null;
     $this->viewsPath = null;
     $this->resourceId = null;
     if (Route::input('alias') !== null) {
         $this->uriSegment = Route::input('alias');
         $this->viewsPath = File::exists(app_path('views/' . Config::get('reactiveadmin::uri') . '/' . $this->uriSegment)) ? Config::get('reactiveadmin::uri') . '.' . $this->uriSegment : 'reactiveadmin::default';
         $this->modelName = studly_case(str_singular(Route::input('alias')));
         $this->modelWrapper = App::make('model_wrapper');
         $this->modelWrapper->model($this->modelName);
         if (Route::input('id') !== null) {
             $this->resourceId = Route::input('id');
         }
         View::share('config', $this->modelWrapper->getConfig());
         // TODO: refactor this!
         // custom behavior
         switch ($this->uriSegment) {
             case 'settings':
                 View::composer(array('admin.' . $this->viewsPath . '.index'), function ($view) {
                     $view->with('settings', Settings::all());
                 });
                 break;
             default:
                 # code...
                 break;
         }
     }
     View::share('view', $this->uriSegment);
     View::share('model', $this->modelName);
 }
 public function all()
 {
     $raw_settings = Settings::all();
     $settings = new StdClass();
     foreach ($raw_settings as $raw_setting) {
         $settings->{$raw_setting->key} = json_decode($raw_setting->value);
     }
     $smtp = new StdClass();
     $smtp->from_address = Config::get('mail.from.address') == null ? '' : Config::get('mail.from.address');
     $smtp->from_name = Config::get('mail.from.name') == null ? '' : Config::get('mail.from.name');
     $smtp->reply_to_address = Config::get('mail.reply-to.address') == null ? '' : Config::get('mail.reply-to.address');
     $smtp->reply_to_name = Config::get('mail.reply-to.name') == null ? '' : Config::get('mail.reply-to.name');
     $smtp->host = Config::get('mail.host') == null ? '' : Config::get('mail.host');
     $smtp->username = Config::get('mail.username') == null ? '' : Config::get('mail.username');
     $smtp->password = Config::get('mail.password') == null ? '' : Config::get('mail.password');
     $mailgun = new StdClass();
     $mailgun->from_address = Config::get('mail.from.address') == null ? '' : Config::get('mail.from.address');
     $mailgun->from_name = Config::get('mail.from.name') == null ? '' : Config::get('mail.from.name');
     $mailgun->reply_to = Config::get('mail.reply-to.address') == null ? '' : Config::get('mail.reply-to.address');
     $mailgun->api_key = Config::get('services.mailgun.secret') == null ? '' : Config::get('services.mailgun.secret');
     $mailgun->domain = Config::get('mail.host') == null ? '' : Config::get('mail.host');
     $mailgun->use_mailgun = Config::get('mail.use_mailgun');
     $settings->smtp = $smtp;
     $settings->mailgun = $mailgun;
     $this->data['settings'] = $settings;
     return View::make('settings', $this->data);
 }
 public function contact($language)
 {
     if (!$this->setupLanguage($language)) {
         App::abort(404);
     }
     try {
         $language = Language::where('_url', '=', $language)->firstOrFail();
         $page = Pages::where('_language', $language->_id)->where("_name", "=", "contact")->get()->first();
     } catch (Exception $e) {
         App::abort(500);
     }
     // Details :
     $data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => ""));
     // Form :
     $inputs = Input::all();
     // Resultat :
     $result = array();
     // Envoi du formulaire d'ajout de mission :
     if (count(Input::all()) > 0) {
         // validation des formulaire :
         $validator = Validator::make($inputs, array('your-name' => 'required|max:60', 'your-email' => 'required|email', 'your-subject' => 'required|max:120', 'your-message' => 'required'), array('your-name.required' => Lang::get('libelle.CONTACT_FORM_ERROR_YOUR_NAME_RQ'), 'your-name.max' => Lang::get('libelle.CONTACT_FORM_ERROR_YOUR_NAME_MAX'), 'your-email.required' => Lang::get('libelle.CONTACT_FORM_ERROR_YOUR_EMAIL_RQ'), 'your-email.email' => Lang::get('libelle.CONTACT_FORM_ERROR_YOUR_EMAIL_INV'), 'your-subject.required' => Lang::get('libelle.CONTACT_FORM_ERROR_SUBJECT_RQ'), 'your-subject.max' => Lang::get('libelle.CONTACT_FORM_ERROR_SUBJECT_MAX'), 'your-message.required' => Lang::get('libelle.CONTACT_FORM_ERROR_MESSAGE_RQ')));
         // retour en cas d'erreur :
         if ($validator->fails()) {
             $result["errors"] = $validator->messages();
         } else {
             // Récupération des paramètres :
             foreach (Settings::all() as $set) {
                 $settings[$set['_key']] = $set['_value'];
             }
             // traitement du texte en paragraphe
             $texte = explode('<br />', nl2br(trim(htmlentities($inputs['your-message']))));
             $inputs['your-message'] = "";
             foreach ($texte as $key => $value) {
                 $inputs['your-message'] .= "<p>" . $value . "</p>";
             }
             // envoie du mail :
             $your_name = trim(htmlentities($inputs['your-name']));
             $your_email = trim(htmlentities($inputs['your-email']));
             $your_subject = trim($inputs['your-subject']);
             $your_message = $inputs['your-message'];
             $mail = array_merge($inputs, array("admin_mail" => $settings['mail'], "admin_name" => $settings['domain'], "domain" => $settings['domain']));
             Mail::send('emails.contact_admin', array("data" => $mail), function ($message) use($mail) {
                 $message->to($mail['admin_mail'], $mail['admin_name'])->subject("Contact :" . $mail['your-subject']);
             });
             Mail::send('emails.contact_user', array("data" => $mail), function ($message) use($mail) {
                 $message->to($mail['your-email'], $mail['your-name'])->subject("Contact :" . $mail['your-subject']);
             });
             foreach ($inputs as $key => $value) {
                 $inputs[$key] = "";
             }
             $result["success"] = Lang::get("libelle.CONTACT_FORM_SUCCESS");
         }
     } else {
         $inputs = null;
     }
     $this->layout->content = View::make('pages.contact.contact', array("data" => $data, "page" => $page, "inputs" => $inputs, "result" => $result));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (ACL::checkUserPermission('settings.index') == false) {
         return Redirect::action('dashboard');
     }
     $title = Lang::get('Setting List');
     $settingList = Settings::all();
     $acl = ACL::buildACL();
     $data = array('title' => $title, 'acl' => $acl, 'settingList' => $settingList);
     return View::make('settings/index', $data);
 }
 protected function setupLayout()
 {
     if (!is_null($this->layout)) {
         // récupération des paramétres en base :
         $settings = array();
         foreach (Settings::all() as $set) {
             $settings[$set['_key']] = $set['_value'];
         }
         View::share('settings', $settings);
         // affichage du layout :
         $this->layout = View::make($this->layout);
     }
 }
 /**
  * Attempt to migrate settings from an older version of this plugin
  *
  * @param Settings $settings
  */
 public function migrate_settings($settings)
 {
     $migrated_settings = array();
     // For each potential value, see if the WordPress option exists.
     // If so, migrate its value into the new array format.
     // If it doesn't exist, just use the default value.
     foreach ($settings->all() as $key => $default) {
         $value = get_option($key, $default);
         $migrated_settings[$key] = $value;
     }
     // Store these settings
     update_option(self::$option_name, $migrated_settings, 'no');
     // Delete the options to clean up
     array_map('delete_option', array_keys($migrated_settings));
     return $migrated_settings;
 }
 public function siteSettings()
 {
     if ($_POST) {
         $input = Input::all();
         foreach ($input as $key => $val) {
             if ($key == '_token' || $key == 'savesettings') {
                 continue;
             }
             if ($setting = Settings::where('name', $key)->first()) {
                 $setting->value = $val;
             } else {
                 $setting = new Settings();
                 $setting->name = $key;
                 $setting->value = htmlspecialchars($val);
             }
             $setting->save();
         }
         return Redirect::to('admin/site');
     }
     $settings = Settings::all();
     $this->layout->content = View::make('admin.settings')->with('settings', $settings);
 }
Example #8
0
<?php

View::composer('layouts.master', function ($view) {
    $raw_settings = Settings::all();
    $settings = new StdClass();
    foreach ($raw_settings as $raw_setting) {
        $settings->{$raw_setting->key} = json_decode($raw_setting->value);
    }
    $view->with('settings', $settings);
    $view->with('uni_department_id', User::getUniDepartment());
    $view->with('uni_company_id', User::getUniCompany());
});
Route::get('/', 'AuthController@getLogin');
Route::post('/log-errors', function () {
    $inputJSON = file_get_contents('php://input');
    $input = json_decode($inputJSON, TRUE);
    //convert JSON into array
    Log::alert("See below");
    Log::alert($input);
});
/*
Route::get('/setup', 'DashboardController@getSetup');
Route::post('/setup', 'DashboardController@postSetup');
*/
Route::get('/clean-everything', 'DashboardController@cleanDB');
Route::get('/activities/all', 'DashboardController@allActivities');
Route::get('/users/all', 'DashboardController@allUsers');
Route::get('/profile', 'AuthController@profile');
Route::get('/login', 'AuthController@getLogin');
Route::get('/register', 'AuthController@getRegister');
Route::get('/forgot-password', 'AuthController@getForgotPassword');
 public function save_settings()
 {
     $settings = Settings::all();
     foreach ($settings as $setting) {
         if (Input::get($setting->id) != NULL) {
             $temp_setting = Settings::find($setting->id);
             $temp_setting->value = Input::get($setting->id);
             $temp_setting->save();
         }
     }
     return Redirect::to('/admin/settings?success=1');
 }
 public function index()
 {
     $settings = Settings::all();
     return View::make('admin.pages.settings.index')->with(['settings' => $settings]);
 }
 function purchaseContact($_index = null, $_cache = null)
 {
     $_JSON = array();
     $_JSON['error'] = '';
     $_JSON['code'] = '';
     $_JSON['credits'] = 0;
     $_JSON['contacts'] = 0;
     if (Auth::check()) {
         $credits = Auth::user()->credits;
         $subscriptions = Auth::user()->subscription()->first();
         if ($subscriptions != null) {
             $transactions = $subscriptions->transaction()->get();
             if (count($transactions) > 0) {
                 foreach ($transactions as $transaction) {
                     $credits = $credits + $transaction->credits;
                 }
             }
         }
         $_JSON['error'] = '';
         $user = User::find(Auth::user()->id);
         $customername = $user->firstname . " " . $user->lastname;
         if ($credits == 0) {
             $_JSON['card'] = '';
             $_JSON['last4'] = '';
             $payment_profile = PaymentProfile::whereUser_id($user->id)->first();
             if (!empty($payment_profile)) {
                 $responseData = unserialize($payment_profile->response);
                 $responseData = $responseData->__toArray();
                 $cards = $responseData['cards']->__toArray();
                 if ($cards['total_count'] > 0) {
                     $card = $cards['data'][0]->__toArray();
                     $_JSON['card'] = $card['brand'];
                     $_JSON['last4'] = $card['last4'];
                 }
             }
             $_JSON['error'] = 'You don&#39;t have sufficient funds to purchase contacts';
         } else {
             $login_user_id = Auth::id();
             $index = Input::get('index', 0);
             if ($_cache == null) {
                 $CONTACTS = unserialize($user->cache);
             } else {
                 $CONTACTS = $_cache;
             }
             $_JSON['info1'] = $CONTACTS[$index]["linkedin"];
             $agents = User::where("status", "=", User::STATUS_AGENT)->get();
             $min = 1000000;
             $min_id = NULL;
             foreach ($agents as $agent) {
                 $linkedin_list = LinkedinContact::where("agent_id", "=", $agent->id)->where("status", "=", LinkedinContact::INCOMPLETE)->get();
                 $count = 0;
                 foreach ($linkedin_list as $linkedin_item) {
                     $count++;
                 }
                 if ($count < $min) {
                     $min = $count;
                     $min_id = $agent->id;
                 }
             }
             $linkedin_contact = LinkedinContact::where("url", "=", base64_decode($CONTACTS[$index]["linkedin"]))->first();
             if (!empty($min_id)) {
                 $linkedin_contact->agent_id = $min_id;
                 $linkedin_contact->started = 1;
                 $linkedin_contact->save();
             }
             // Automation Start
             $company_name = $CONTACTS[$index]['company_name'];
             $company_domain = '';
             if ($company_name != '') {
                 $obj = new GoogleCustomSearch();
                 $company_domain = $obj->makeCall($company_name);
                 //google Search Domain
             }
             if ($company_domain != '') {
                 $this->addNewLead($company_domain, $linkedin_contact->id);
             }
             // Automation End
             $_JSON['info2'] = $linkedin_contact;
             if ($linkedin_contact != null) {
                 $_JSON['info3'] = "saveToList";
                 $this->saveToList(Auth::user()->id, serialize($CONTACTS[$index]), $linkedin_contact->id);
                 $_JSON['credits'] = $credits - 1;
                 //send email to all addresses that are added from admin
                 $contact_data = array("firstname" => $linkedin_contact->firstname, "lastname" => $linkedin_contact->lastname, "title" => $linkedin_contact->title, "company" => $linkedin_contact->company, "location" => $linkedin_contact->location, "url" => $linkedin_contact->url);
                 $agent_alerts = Settings::all();
                 foreach ($agent_alerts as $alert) {
                     $contact_data['customername'] = $customername;
                     $contact_data['agentname'] = $alert['name'];
                     $contact_data['agentemail'] = $alert['value'];
                     Session::put('agentemail', $alert['value']);
                     Mail::queue('emails/agent/agent-added-contact', $contact_data, function ($message) {
                         $message->to(Session::get('agentemail'), 'abc')->subject('A new lead has been added by a user.');
                     });
                 }
                 // send to admin
                 $contact_data['customername'] = $customername;
                 $contact_data['agentname'] = 'Admin';
                 $contact_data['agentemail'] = '*****@*****.**';
                 Mail::queue('emails/agent/admin-added-contact', $contact_data, function ($message) {
                     $message->to('*****@*****.**', 'abc')->subject('A new lead has been added by a user.');
                 });
             }
         }
         $_JSON['contacts'] = count($user->lists()->first()->linkedinContact()->get());
     } else {
         $_JSON['error'] = '';
         $_JSON['code'] = '0001';
     }
     if ($_index == 5) {
         Log::notice("error");
     } else {
         Log::notice("json.response");
     }
     if ($_index == 5) {
         return $_JSON["error"];
     } else {
         return Response::json($_JSON);
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return View::make('settings.index')->with('settings', Settings::all())->with('title', 'Settings');
 }
 public function settings()
 {
     return View::make("admin::settings")->with(array("settings" => \Settings::all()));
 }