/**
  * Get the form(s) associated with the module
  */
 public function forms()
 {
     $selected_forms = explode(", ", $this->form_id);
     $forms = array();
     foreach ($selected_forms as $form_id) {
         $form = BuiltForm::find($form_id);
         if ($form) {
             $forms[] = $form;
         }
     }
     return $forms;
 }
Example #2
0
 /**
  * All forms with their categories
  * @return array
  */
 public static function all_forms()
 {
     $forms = array(0 => 'None');
     $categories = BuiltForm::get(array('category'));
     foreach ($categories as $category) {
         $names = array();
         foreach (BuiltForm::where('category', '=', $category->category)->get(array('id', 'name')) as $form) {
             // Get only the form names
             $names[$form->id] = $form->name;
         }
         $forms[FormCategory::find($category->category)->name] = $names;
     }
     return $forms;
 }
Example #3
0
 private function sendEmail($input)
 {
     $form = BuiltForm::findOrFail($input['form_id']);
     if ($form->email == '') {
         return;
     }
     $input = $this->formatInputForEmail($input, $form->data);
     $exported_var = var_export($input, true);
     $exported_var = str_replace("array (", "", $exported_var);
     $exported_var = str_replace("',", "'<br>", $exported_var);
     $exported_var = str_replace(")", "", $exported_var);
     $input['exported_var'] = $exported_var;
     Mail::send('public.' . $this->current_theme . '.email_form', $input, function ($email_message) use($input, $form) {
         $email_message->from($form->email);
         $email_message->to($form->email)->subject('Email from Form');
     });
 }
Example #4
0
 public static function create(array $attributes = array())
 {
     // dd($attributes);
     static::isValid($attributes);
     if (isset($attributes['captcha'])) {
         // Do not save the value of captcha to database
         unset($attributes['captcha']);
     }
     unset($attributes['_token']);
     $entry['form_id'] = $attributes['form_id'];
     unset($attributes['form_id']);
     $form = BuiltForm::findOrFail($entry['form_id']);
     $module_builder = new Services\ModuleBuilder();
     $form_fields = $module_builder->getFormFields($form->data);
     $fields = array_combine($form_fields['fields'], $form_fields['field_names']);
     $entry['data'] = json_encode($attributes);
     $entry['fields'] = json_encode($fields);
     // dd($entry);
     return parent::create($entry);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $form = \BuiltForm::findOrFail($id);
     if (\BuiltModule::where('form_id', '=', $id)->first()) {
         return \Redirect::back()->with('error_message', 'The form can\'t be deleted because a built module is using this form. <br> Either change the form in that built module or delete the module first to delete this form.');
     }
     if ($form->delete()) {
         return \Redirect::to('backend/form-builder')->with('success_message', 'Form was deleted.');
     } else {
         return \Redirect::to('backend/form-builder')->with('error_message', 'Form wasn\'t deleted.');
     }
 }
Example #6
0
 /**
  * The list that is displayed while selecting item for menu
  * @return array
  */
 public static function menu_lists()
 {
     $modules = array();
     foreach (Module::all(array('name', 'links')) as $module) {
         if ($module->links != '') {
             $links = json_decode($module->links);
             foreach ($links as $link) {
                 $modules['link_type/modules/' . $link->alias] = $link->name;
             }
         } else {
             $modules['link_type/modules/' . Str::slug($module->name, '_')] = $module->name;
         }
     }
     $pages = array();
     foreach (Post::type('page')->get(array('title', 'permalink')) as $page) {
         $pages['pages/' . $page->permalink] = $page->title;
     }
     $post_categories = array();
     foreach (Category::type('post')->get(array('name', 'alias')) as $page_category) {
         $post_categories['posts/category/' . $page_category->alias] = $page_category->name;
     }
     $contacts = array();
     foreach (Components\ContactManager\Models\ContactDetail::get(array('name', 'alias')) as $contact) {
         $contacts['contact/show/' . $contact->alias] = $contact->name;
     }
     $contact_categories = array();
     foreach (Components\ContactManager\Models\ContactCategory::get(array('name', 'alias')) as $contact_cat) {
         $contact_categories['contact/' . $contact_cat->alias] = $contact_cat->name;
     }
     $forms = array();
     foreach (BuiltForm::get(array('name', 'id')) as $contact_cat) {
         $forms['link_type/form/' . $contact_cat->id] = $contact_cat->name;
     }
     $report_generators = array();
     foreach (Components\ReportGenerator\Models\ReportGenerator::get(array('name', 'id')) as $report_generator) {
         $report_generators['admin/report-generators/generate/' . $report_generator->id] = $report_generator->name;
     }
     return array('/' => 'Home', 'Pages' => $pages, 'posts' => 'Posts', 'Post Categories' => $post_categories, 'Modules' => $modules, 'Contact Categories' => $contact_categories, 'Contacts' => $contacts, 'Forms' => $forms, 'Report Generators' => $report_generators, 'manual' => 'External link');
 }
Example #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $form = \BuiltForm::findOrFail($id);
     if (\BuiltModule::where('form_id', '=', $id)->first()) {
         return \Redirect::back()->with('error_message', trans('error_messages.form_delete_assoc'));
     }
     if ($form->delete()) {
         return \Redirect::to('backend/form-builder')->with('success_message', trans('success_messages.form_delete'));
     } else {
         return \Redirect::to('backend/form-builder')->with('error_message', trans('error_messages.form_delete'));
     }
 }