public function onPost() { $question = Html::clean(post('question')); $reply_email = post('email'); $validator = Validator::make(['question' => $question, 'reply_email' => $reply_email], ['question' => 'required', 'reply_email' => 'email']); if ($validator->fails()) { Flash::error('Please enter the question'); } else { $ask = new Question(); $ask->question = $question; /** * Saving question in DB **/ $ask->is_approved = '0'; $ask->category_id = '0'; $ask->reply_email = $reply_email; $ask->save(); /** * Sending email to admin **/ $params = compact('question'); Mail::send('redmarlin.faq::mail.asked', $params, function ($message) { $message->to(MailSettings::get('sender_email')); $email = post('email'); }); Flash::success('Your question was received correctly.'); } }
/** * Execute the console command. * @return void */ public function fire() { $base_path = base_path(''); $this->info('Dependencies installing begins here! (plugin:install)'); // DEPENDENCIES foreach (['RainLab.Translate', 'Flynsarmy.IdeHelper', 'BnB.ScaffoldTranslation', 'October.Drivers', 'RainLab.GoogleAnalytics', 'Genius.StorageClear'] as $required) { $this->info('Installing: ' . $required); Artisan::call("plugin:install", ['name' => $required]); } $this->info('Dependencies installed!'); // THEME $this->info('Installing: oc-genius-theme'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-theme themes/genius"); Theme::setActiveTheme('genius'); // ELIXIR $this->info('Installing: oc-genius-elixir'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-elixir plugins/genius/elixir"); // FORMS $this->info('Installing: oc-genius-forms'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-forms plugins/genius/forms"); // BACKUP $this->info('Installing: oc-genius-backup'); system("cd '{$base_path}' && git clone https://github.com/estudiogenius/oc-genius-backup plugins/genius/backup"); // GOOGLE ANALYTICS $this->info('Initial setup: AnalytcsSettings'); if (!AnalytcsSettings::get('project_name')) { AnalytcsSettings::create(['project_name' => 'API Project', 'client_id' => '979078159189-8afk8nn2las4vk1krbv8t946qfk540up.apps.googleusercontent.com', 'app_email' => '*****@*****.**', 'profile_id' => '112409305', 'tracking_id' => 'UA-29856398-24', 'domain_name' => 'retrans.srv.br'])->gapi_key()->add(File::create(['data' => plugins_path('genius/base/assets/genius-analytics.p12')])); } // EMAIL $this->info('Initial setup: MailSettings'); if (!MailSettings::get('mandrill_secret')) { MailSettings::create(['send_mode' => 'mandrill', 'sender_name' => 'Genius Soluções Web', 'sender_email' => '*****@*****.**', 'mandrill_secret' => 't27R2C15NPnZ8tzBrIIFTA']); } // BRAND $this->info('Initial setup: BrandSettings'); if (!BrandSettings::get('app_init')) { BrandSettings::create(['app_name' => 'Genius Soluções Web', 'app_tagline' => 'powered by Genius', "primary_color_light" => "#e67e22", "primary_color_dark" => "#d35400", "secondary_color_light" => "#34495e", "secondary_color_dark" => "#2b3e50", "custom_css" => "", 'app_init' => true])->logo()->add(File::create(['data' => plugins_path('genius/base/assets/genius-logo.png')])); } // USUARIO BASE $this->info('Initial setup: User'); $user = User::find(1); if (!$user->last_name) { $user->update(['first_name' => 'Genius', 'last_name' => 'Soluções Web', 'login' => 'genius', 'email' => '*****@*****.**', 'password' => 'genius', 'password_confirmation' => 'genius']); $user->avatar()->add(File::create(['data' => plugins_path('genius/base/assets/genius-avatar.jpg')])); } $this->info('Genius.Base is ready to rock!'); $this->info(''); $this->info('For Laravel Elixir setup run: php artisan elixir:init'); }
public function onOctoMailSent() { // Set the requested template in a variable; $this->requestTemplate = $this->loadTemplate(); if (!$this->requestTemplate) { throw new \Exception(sprintf(Lang::get('octodevel.octomail::lang.components.mailTemplate.functions.onOctoMailSent.exceptions.invalid_template'))); } // Set a second variable with request data from database $template = $this->requestTemplate->attributes; if (!$template) { throw new \Exception(sprintf(Lang::get('octodevel.octomail::lang.components.mailTemplate.functions.onOctoMailSent.exceptions.invalid_attributes'))); } // Set a global $_POST variable $post = post(); // Unset problematic variables if (isset($post['message'])) { throw new \Exception(sprintf(Lang::get('octodevel.octomail::lang.components.mailTemplate.functions.onOctoMailSent.exceptions.invalid_message_field'))); } // get the message body $this->bodyField = $this->property('bodyField'); if (isset($this->bodyField) && !empty($this->bodyField)) { if (isset($post[$this->bodyField])) { $body = strip_tags($post[$this->bodyField]); $post[$this->bodyField] = nl2br($body); } } // get name for auto-response message $this->aRName = $this->property('responseFieldName'); // get email for auto-response message $this->aREmail = $this->property('responseFieldEmail'); // Set redirect URL $redirectUrl = $this->controller->pageUrl($this->property('redirectURL')); // Get response email $responseMailTemplate = $this->property('responseTemplate'); // Get request info $request = Request::createFromGlobals(); // Set some request variables $post['ip_address'] = $request->getClientIp(); $post['user_agent'] = $request->headers->get('User-Agent'); $post['sender_name'] = $template['sender_name']; $post['sender_email'] = $template['sender_email']; $post['recipient_name'] = $template['recipient_name'] ? $template['recipient_name'] : MailSettings::get('sender_name'); $post['recipient_email'] = $template['recipient_email'] ? $template['recipient_email'] : MailSettings::get('sender_email'); $post['default_subject'] = $template['subject']; // Set some usable data $data = ['replyto_email' => isset($post[$this->aREmail]) ? $post[$this->aREmail] : false, 'replyto_name' => isset($post[$this->aRName]) ? $post[$this->aRName] : false, 'sender_name' => $template['sender_name'], 'sender_email' => $template['sender_email'], 'recipient_name' => $template['recipient_name'] ? $template['recipient_name'] : MailSettings::get('sender_name'), 'recipient_email' => $template['recipient_email'] ? $template['recipient_email'] : MailSettings::get('sender_email'), 'default_subject' => $template['subject']]; // Making custon validation $fields = explode(',', preg_replace('/\\s/', '', $template['fields'])); if ($fields) { $validation_rules = []; foreach ($fields as $field) { $rules = explode("|", $field); if ($rules) { $field_name = $rules[0]; $validation_rules[$field_name] = []; unset($rules[0]); foreach ($rules as $key => $rule) { $validation_rules[$field_name][$key] = $rule; } } } $this->rules = $validation_rules; $validation = Validator::make($post, $this->rules); if ($validation->fails()) { throw new ValidationException($validation); } } // Get recipients $recipients = DB::table($this->recipients)->where('template_id', '=', $template['id'])->leftJoin($this->recipients_table, $this->recipients_table . '.id', '=', $this->recipients . '.recipient_id')->get(); if (!$template['multiple_recipients']) { Mail::send('octodevel.octomail::mail.' . $template['slug'], $post, function ($message) use($data) { $message->from($data['sender_email'], $data['sender_name']); $message->to($data['recipient_email'], $data['recipient_name'])->subject($data['default_subject']); if ($data['replyto_email'] and $data['replyto_name']) { $message->replyTo($data['replyto_email'], $data['replyto_name']); } }); $log = new RegisterLog(); $log->template_id = $template['id']; $log->sender_agent = $post['user_agent']; $log->sender_ip = $post['ip_address']; $log->sent_at = date('Y-m-d H:i:s'); $log->data = $post; $log->save(); } else { // Multiple emails foreach ($recipients as $recipient) { $data['recipient_name'] = $recipient->name; $data['recipient_email'] = $recipient->email; Mail::send('octodevel.octomail::mail.' . $template['slug'], $post, function ($message) use($data) { $message->from($data['sender_email'], $data['sender_name']); $message->to($data['recipient_email'], $data['recipient_name'])->subject($data['default_subject']); if ($data['replyto_email'] and $data['replyto_name']) { $message->replyTo($data['replyto_email'], $data['replyto_name']); } }); $log = new RegisterLog(); $log->template_id = $template['id']; $log->sender_agent = $post['user_agent']; $log->sender_ip = $post['ip_address']; $log->sent_at = date('Y-m-d H:i:s'); $log->data = $post; $log->save(); } } if (isset($post[$this->aREmail]) and $post[$this->aREmail] and (isset($post[$this->aRName]) and $post[$this->aRName]) and (isset($template['autoresponse']) and $template['autoresponse'])) { $response = ['name' => $post[$this->aRName], 'email' => $post[$this->aREmail]]; if ($responseMailTemplate) { Mail::send($responseMailTemplate, $post, function ($autoresponse) use($response) { $autoresponse->to($response['email'], $response['name']); }); } } $this->page["result"] = true; $this->page["confirmation_text"] = $template['confirmation_text']; if ($redirectUrl) { return Redirect::intended($redirectUrl); } }