示例#1
0
 /**
  * saves the category in a specific order and change the parent
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     if (Menu::change_order(Core::get('order'))) {
         Core::delete_cache();
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
示例#2
0
 public function action_cache()
 {
     $this->template->title = __('Cache');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     $cache_config = Core::config('cache.' . Core::config('cache.default'));
     //force clean cache
     if (Core::get('force') == 1) {
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('All cache deleted'));
     } elseif (Core::get('force') == 2) {
         Cache::instance()->garbage_collect();
         Theme::delete_minified();
         Alert::set(Alert::SUCCESS, __('Deleted expired cache'));
     }
     $this->template->content = View::factory('oc-panel/pages/tools/cache', array('cache_config' => $cache_config));
 }
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Interactive map')));
     $this->template->title = __('Interactive map');
     $this->template->styles = array('css/map-generator.css' => 'screen');
     $this->template->scripts['footer'][] = '//www.google.com/jsapi';
     $this->template->scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/jscolor.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/map-generator.js';
     $map_active = Core::post('map_active', Core::Config('appearance.map_active'));
     $map_settings = Core::post('current_settings', Core::Config('appearance.map_settings'));
     // change map
     if (Theme::get('premium') == 1 and Core::post('jscode')) {
         Model_Config::set_value('appearance', 'map_active', Core::post('map_active'));
         Model_Config::set_value('appearance', 'map_settings', Core::post('current_settings'));
         Model_Config::set_value('appearance', 'map_jscode', Kohana::$_POST_ORIG['jscode']);
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('Map saved.'));
     }
     $this->template->content = View::factory('oc-panel/pages/map', array('map_active' => $map_active, 'map_settings' => $map_settings));
 }
示例#4
0
 public function action_update()
 {
     $name = $this->request->param('id');
     $field = new Model_UserField();
     $field_data = $field->get($name);
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $name));
     $this->template->title = __('Edit Custom Field for Advertisement');
     if ($_POST) {
         try {
             $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE, 'show_profile' => Core::post('show_profile') == 'on' ? TRUE : FALSE, 'show_register' => Core::post('show_register') == 'on' ? TRUE : FALSE, 'admin_privilege' => Core::post('admin_privilege') == 'on' ? TRUE : FALSE);
             if ($field->update($name, Core::post('values'), $options)) {
                 Core::delete_cache();
                 Alert::set(Alert::SUCCESS, sprintf(__('Field %s edited'), $name));
             } else {
                 Alert::set(Alert::ERROR, sprintf(__('Field %s cannot be edited'), $name));
             }
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'userfields', 'action' => 'index')));
     }
     $this->template->content = View::factory('oc-panel/pages/userfields/update', array('field_data' => $field_data, 'name' => $name));
 }
示例#5
0
 /**
  * deletes all the locations
  * @return void 
  */
 public function action_delete_all()
 {
     if (core::post('confirmation')) {
         //delete location icons
         $locations = new Model_Location();
         if ($id_location = intval(Core::post('id_location')) and $id_location > 0) {
             $selected_location = new Model_Location($id_location);
             $locations->where('id_location', 'in', $selected_location->get_siblings_ids())->where('id_location', '!=', $selected_location->id_location);
         } else {
             $locations->where('id_location', '!=', '1')->find_all();
         }
         $locations = $locations->find_all();
         foreach ($locations as $location) {
             $root = DOCROOT . 'images/locations/';
             //root folder
             if (is_dir($root)) {
                 @unlink($root . $location->seoname . '.png');
                 // delete icon from Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/locations/' . $location->seoname . '.png');
                 }
             }
         }
         $query_update = DB::update('ads');
         $query_delete = DB::delete('locations');
         if ($id_location = intval(Core::post('id_location')) and $id_location > 0) {
             $query_update->set(array('id_location' => $selected_location->id_location));
             $query_delete->where('id_location', 'in', $selected_location->get_siblings_ids())->where('id_location', '!=', $selected_location->id_location);
         } else {
             $query_update->set(array('id_location' => '1'));
             $query_delete->where('id_location', '!=', '1');
         }
         $query_update->execute();
         $query_delete->execute();
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('All locations were deleted.'));
     } else {
         Alert::set(Alert::ERROR, __('You did not confirmed your delete action.'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')));
 }
示例#6
0
 /**
  * recalculating the deep of all the categories
  * @return [type] [description]
  */
 public function action_deep()
 {
     Core::delete_cache();
     //getting all the cats as array
     $cats_arr = Model_Category::get_as_array();
     $cats = new Model_Category();
     $cats = $cats->order_by('order', 'asc')->find_all()->cached()->as_array('id_category');
     foreach ($cats as $cat) {
         $deep = 0;
         //getin the parent of this category
         $id_category_parent = $cats_arr[$cat->id_category]['id_category_parent'];
         //counting till we find the begining
         while ($id_category_parent != 1 and $id_category_parent != 0 and $deep < 10) {
             $id_category_parent = $cats_arr[$id_category_parent]['id_category_parent'];
             $deep++;
         }
         //saving the category only if different deep
         if ($cat->parent_deep != $deep) {
             $cat->parent_deep = $deep;
             $cat->save();
         }
     }
     //Alert::set(Alert::INFO, __('Success'));
     //HTTP::redirect(Route::url('oc-panel',array('controller'  => 'location','action'=>'index')));
 }
示例#7
0
 public function action_subscribe()
 {
     $this->auto_render = FALSE;
     // Update subscribe config action
     Model_Config::set_value('general', 'subscribe', 1);
     Core::delete_cache();
     die('OK');
 }
示例#8
0
 public function action_import_tool()
 {
     $this->template->title = __('Import tool for locations and categories');
     Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
     //sending a CSV
     if ($_POST) {
         foreach ($_FILES as $file => $path) {
             $csv = $path["tmp_name"];
             $csv_2[] = $file;
             if ($path['size'] > 1048576) {
                 Alert::set(Alert::ERROR, __('1 MB file'));
                 $this->redirect(Route::url('oc-panel', array('controller' => 'tools', 'action' => 'import_tool')));
             }
             if ($file == 'csv_file_categories' and $csv != FALSE) {
                 $expected_header = array('name', 'category_parent', 'price');
                 $cat_array = Core::csv_to_array($csv, $expected_header);
                 if (count($cat_array) > 10000) {
                     Alert::set(Alert::ERROR, __('limited to 10.000 at a time'));
                     $this->redirect(Route::url('oc-panel', array('controller' => 'tools', 'action' => 'import_tool')));
                 }
                 if ($cat_array === FALSE) {
                     Alert::set(Alert::ERROR, __('Something went wrong, please check format of the file! Remove single quotes or strange characters, in case you have any.'));
                 } else {
                     foreach ($cat_array as $cat) {
                         //category parent was sent?
                         if ($cat[1]) {
                             $category_parent = new Model_Category();
                             $category_parent->where('name', '=', $cat[1])->limit(1)->find();
                             if ($category_parent->loaded()) {
                                 $cat[1] = $category_parent->id_category;
                             } else {
                                 $cat[1] = 1;
                             }
                         } else {
                             $cat[1] = 1;
                         }
                         Model_Category::create_name($cat[0], 0, $cat[1], 0, $cat[2]);
                     }
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, __('Categories successfully imported.'));
                 }
             } elseif ($file == 'csv_file_locations' and $csv != FALSE) {
                 $expected_header = array('name', 'location_parent', 'latitude', 'longitude');
                 $loc_array = Core::csv_to_array($csv, $expected_header);
                 if (count($loc_array) > 10000) {
                     Alert::set(Alert::ERROR, __('limited to 10.000 at a time'));
                     $this->redirect(Route::url('oc-panel', array('controller' => 'tools', 'action' => 'import_tool')));
                 }
                 if ($loc_array === FALSE) {
                     Alert::set(Alert::ERROR, __('Something went wrong, please check format of the file! Remove single quotes or strange characters, in case you have any.'));
                 } else {
                     foreach ($loc_array as $loc) {
                         //location parent was sent?
                         if ($loc[1]) {
                             $location_parent = new Model_Location();
                             $location_parent->where('name', '=', $loc[1])->limit(1)->find();
                             if ($location_parent->loaded()) {
                                 $loc[1] = $location_parent->id_location;
                             } else {
                                 $loc[1] = 1;
                             }
                         } else {
                             $loc[1] = 1;
                         }
                         Model_Location::create_name($loc[0], 0, $loc[1], 0, $loc[2], $loc[3]);
                     }
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, __('Locations successfully imported.'));
                 }
             }
         }
     }
     $this->template->content = View::factory('oc-panel/pages/tools/import_tool');
 }
示例#9
0
 /**
  * saves the content in a specific order
  * @return void 
  */
 public function action_saveorder()
 {
     $this->auto_render = FALSE;
     $this->template = View::factory('js');
     $locale = core::get('locale_select', core::config('i18n.locale'));
     if ($contents = Model_Content::get_contents(core::get('type'), $locale)) {
         $order = Core::get('order');
         //using order they send us
         foreach ($order as $key => $value) {
             $c = new Model_Content($value);
             $c->order = $key;
             $c->save();
         }
         Core::delete_cache();
         $this->template->content = __('Saved');
     } else {
         $this->template->content = __('Error');
     }
 }
示例#10
0
 /**
  * Creates multiple categories just with name
  * @return void      
  */
 public function action_multy_categories()
 {
     $this->auto_render = FALSE;
     //update the elements related to that ad
     if ($_POST) {
         // d($_POST);
         if (core::post('multy_categories') !== "") {
             $multy_cats = explode(',', core::post('multy_categories'));
             $obj_category = new Model_Category();
             $insert = DB::insert('categories', array('name', 'seoname', 'id_category_parent'));
             foreach ($multy_cats as $name) {
                 $insert = $insert->values(array($name, $obj_category->gen_seoname($name), 1));
             }
             // Insert everything with one query.
             $insert->execute();
             Core::delete_cache();
         } else {
             Alert::set(Alert::INFO, __('Select some categories first.'));
         }
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'category', 'action' => 'index')));
 }
 /**
  * Import multiple locations from geonames
  * @return void      
  */
 public function action_geonames_locations()
 {
     $this->auto_render = FALSE;
     //update the elements related to that ad
     if (core::post('geonames_locations') !== "") {
         $geonames_locations = json_decode(core::post('geonames_locations'));
         if (count($geonames_locations) > 0) {
             $obj_location = new Model_Location();
             $locations_array = array();
             $insert = DB::insert('locations', array('name', 'seoname', 'id_location_parent', 'latitude', 'longitude'));
             foreach ($geonames_locations as $location) {
                 if (!in_array($location->name, $locations_array)) {
                     $insert = $insert->values(array($location->name, $obj_location->gen_seoname($location->name), Core::get('id_location', 1), isset($location->lat) ? $location->lat : NULL, isset($location->long) ? $location->long : NULL));
                     $locations_array[] = $location->name;
                 }
             }
             // Insert everything with one query.
             $insert->execute();
             Core::delete_cache();
         }
     } else {
         Alert::set(Alert::INFO, __('Select some locations first.'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'location', 'action' => 'index')) . '?id_location=' . Core::get('id_location', 1));
 }
示例#12
0
 /**
  * STEP 4 and last
  * updates all themes to latest version from API license
  * @return void 
  */
 public function action_themes()
 {
     $licenses = array();
     //getting the licenses unique. to avoid downloading twice
     $themes = core::config('theme');
     foreach ($themes as $theme) {
         $settings = json_decode($theme, TRUE);
         if (isset($settings['license'])) {
             if (!in_array($settings['license'], $licenses)) {
                 $licenses[] = $settings['license'];
             }
         }
     }
     //only if theres work to do ;)
     if (count($licenses) > 0) {
         //activate maintenance mode
         Model_Config::set_value('general', 'maintenance', 1);
         //for each unique license then download!
         foreach ($licenses as $license) {
             Theme::download($license);
         }
         Alert::set(Alert::SUCCESS, __('Themes Updated'));
         //deactivate maintenance mode
         Model_Config::set_value('general', 'maintenance', 0);
         //clean cache
         Core::delete_cache();
     }
     //finished the entire update process
     $this->redirect(Route::url('oc-panel', array('controller' => 'update', 'action' => 'index')));
 }
 public function action_template()
 {
     if ($_POST) {
         $cf_templates = '
                         {
                             "cars": [
                                 {
                                     "name": "for-sale-by",
                                     "type": "select",
                                     "label": "For sale by",
                                     "tooltip": "For sale by",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Owner,Dealer"
                                 },
                                 {
                                     "name": "ad-type",
                                     "type": "select",
                                     "label": "Ad type",
                                     "tooltip": "Ad type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "I’m selling my car,I’m looking for a car to buy"
                                 },
                                 {
                                     "name": "make",
                                     "type": "select",
                                     "label": "Make",
                                     "tooltip": "Make",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Acura,Alfa Romeo,AM General,AMC,Aston Martin,Audi,Austin-Healey,Bently,BMW,Bricklin,Bugatti,Buick,Cadillac,Chevrolet,Chrysler,Daewoo,Datsun,Diahatsu,Dodge,Eagle,Ferrari,Fiat,Ford,Geo,GMC,Honda,HUMMER,Hyundai,Infiniti,International Harvester,Isuzu,Jaguar,Jeep,Kia,Lamborghini,Land Rover,Lexus,Lincoln,Lotus,Maserati,Maybach,Mazda,Mercedes-Benz,Mercury,MG,MINI,Mitsubishi,Nissan,Oldsmobile,Opel,Peugeot,Plymouth,Pontiac,Porsche,Ram,Renault,Rolls-Royce,Saab,Saturn,Scion,Shelby,Smart,Subaru,Suzuki,Toyota,Triumph,Volkswagen,Volvo,Other"
                                 },
                                 {
                                     "name": "other-make",
                                     "type": "string",
                                     "label": "Other make",
                                     "tooltip": "Other make",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "model",
                                     "type": "string",
                                     "label": "Model",
                                     "tooltip": "Model",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "year",
                                     "type": "integer",
                                     "label": "Year",
                                     "tooltip": "Year",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "kilometers",
                                     "type": "integer",
                                     "label": "Kilometers",
                                     "tooltip": "Kilometers",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "body-type",
                                     "type": "select",
                                     "label": "Body type",
                                     "tooltip": "Body type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Convertible,Coupe (2 door),Hatchback,Minivan or Van,Pickup Truck,Sedan,SUV. crossover,Wagon,Other"
                                 },
                                 {
                                     "name": "transmission",
                                     "type": "select",
                                     "label": "Transmission",
                                     "tooltip": "Transmission",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Automatic,Manual,Other"
                                 },
                                 {
                                     "name": "drivetrain",
                                     "type": "select",
                                     "label": "Drivetrain",
                                     "tooltip": "Drivetrain",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "4 x 4,All-wheel drive (AWD),Front-wheel drive (FWD),Rear-wheel drive (RWD),Other"
                                 },
                                 {
                                     "name": "color",
                                     "type": "select",
                                     "label": "Color",
                                     "tooltip": "Color",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Black,Blue,Brown,Burgundy,Gold,Green,Grey,Orange,Pink,Purple,Red,Silver,Tan,Teal,White,Yellow,Other"
                                 },
                                 {
                                     "name": "fuel-type",
                                     "type": "select",
                                     "label": "Fuel Type",
                                     "tooltip": "Fuel Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Diesel,Gasoline,Hybrid-Electric,Other"
                                 },
                                 {
                                     "name": "type",
                                     "type": "select",
                                     "label": "Type",
                                     "tooltip": "Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Damaged,Lease Takeover,New,Used"
                                 }
                             ],
                             "houses": [
                                 {
                                     "name": "furnished",
                                     "type": "select",
                                     "label": "Furnished",
                                     "tooltip": "Furnished",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "bedrooms",
                                     "type": "select",
                                     "label": "Bedrooms",
                                     "tooltip": "Bedrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Studio,1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "bathrooms",
                                     "type": "select",
                                     "label": "Bathrooms",
                                     "tooltip": "Bathrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "pets",
                                     "type": "select",
                                     "label": "Pets",
                                     "tooltip": "Pets",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "yes,No"
                                 },
                                 {
                                     "name": "agencybroker-fee",
                                     "type": "select",
                                     "label": "Agency\\/broker fee",
                                     "tooltip": "Agency\\/broker fee",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "square-meters",
                                     "type": "string",
                                     "label": "Square meters",
                                     "tooltip": "Square meters",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "price-negotiable",
                                     "type": "checkbox",
                                     "label": "Price negotiable",
                                     "tooltip": "Price negotiable",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 }
                             ],
                             "jobs": [
                                 {
                                     "name": "job-type",
                                     "type": "select",
                                     "label": "Job type",
                                     "tooltip": "Job type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Full-time,Part-time"
                                 },
                                 {
                                     "name": "experience-in-years",
                                     "type": "select",
                                     "label": "Experience in Years",
                                     "tooltip": "Experience in Years",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Less than 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,More than 20"
                                 },
                                 {
                                     "name": "salary",
                                     "type": "integer",
                                     "label": "Salary",
                                     "tooltip": "Salary",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "salary-type",
                                     "type": "select",
                                     "label": "Salary type",
                                     "tooltip": "Salary type",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Hourly,Daily,Weekly,Monthly,Quarterly,Yearly"
                                 },
                                 {
                                     "name": "extra-information",
                                     "type": "textarea",
                                     "label": "Extra information",
                                     "tooltip": "Extra information",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ],
                             "dating": [
                                 {
                                     "name": "age",
                                     "type": "integer",
                                     "label": "Age",
                                     "tooltip": "Age",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "body",
                                     "type": "select",
                                     "label": "Body",
                                     "tooltip": "Body",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "-,Athletic,Average,big,Curvy,Fit,Heavy,HWP,Skinny,Thin,"
                                 },
                                 {
                                     "name": "height",
                                     "type": "select",
                                     "label": "Height",
                                     "tooltip": "Height",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Taller than 6.8 (203 cm),6.7 (200 cm),6.6 (198 cm),6.5 (195 cm),6.4 (194cm),6.3 (190 cm),6.2 (187 cm),6.1 (185 cm),6.0 (182 cm),5.11 (180 cm),5.10 (177 cm),5.9 (175 cm),5.8 (172 cm),5.7 (170 cm),5.6 (167 cm),5.5 (165 cm),5.4 (162 cm),5.3 (160 cm),5.2 (157 cm),5.1 (154 cm),5.0 (152 cm),4.11 (150 cm),4.10 (147 cm),4.9 (145 cm),4.8 (142 cm) or less"
                                 },
                                 {
                                     "name": "status",
                                     "type": "select",
                                     "label": "Status",
                                     "tooltip": "Status",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Single,In a Relationship,Engaged,Married,Separated,Divorced,Widowed"
                                 },
                                 {
                                     "name": "occupation",
                                     "type": "string",
                                     "label": "Occupation",
                                     "tooltip": "Occupation",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "hair",
                                     "type": "string",
                                     "label": "Hair",
                                     "tooltip": "Hair",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "eye-color",
                                     "type": "string",
                                     "label": "Eye color",
                                     "tooltip": "Eye color",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ]
                         }
                         ';
         $cf_templates = json_decode($cf_templates, TRUE);
         $field = new Model_Field();
         foreach ($cf_templates[Core::post('type')] as $custom_field) {
             try {
                 $name = $custom_field['name'];
                 $options = array('label' => $custom_field['label'], 'tooltip' => $custom_field['tooltip'], 'required' => $custom_field['required'], 'searchable' => $custom_field['searchable'], 'admin_privilege' => $custom_field['admin_privilege'], 'show_listing' => $custom_field['show_listing']);
                 if ($field->create($name, $custom_field['type'], $custom_field['values'], Core::post('categories'), $options)) {
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
                 } else {
                     Alert::set(Alert::ERROR, sprintf(__('Field %s already exists'), $name));
                 }
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     }
 }
示例#14
0
 /**
  * CRUD controller: DELETE
  */
 public function action_delete()
 {
     $this->auto_render = FALSE;
     $forum = new Model_Forum($this->request->param('id'));
     //update the elements related to that ad
     if ($forum->loaded()) {
         try {
             $forum->delete();
             $this->template->content = 'OK';
             Core::delete_cache();
             Alert::set(Alert::SUCCESS, __('Forum deleted'));
         } catch (Exception $e) {
             Alert::set(Alert::ERROR, $e->getMessage());
         }
     } else {
         Alert::set(Alert::ERROR, __('Forum not deleted'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'forum', 'action' => 'index')));
 }
示例#15
0
 /**
  * deletes all the categories
  * @return void 
  */
 public function action_delete_all()
 {
     if (core::post('confirmation')) {
         //delete categories icons
         $categories = new Model_Category();
         $categories = $categories->where('id_category', '!=', '1')->find_all();
         foreach ($categories as $category) {
             $root = DOCROOT . 'images/categories/';
             //root folder
             if (is_dir($root)) {
                 @unlink($root . $category->seoname . '.png');
                 // delete icon from Amazon S3
                 if (core::config('image.aws_s3_active')) {
                     $s3->deleteObject(core::config('image.aws_s3_bucket'), 'images/categories/' . $category->seoname . '.png');
                 }
             }
         }
         //set home category to all the ads
         $query = DB::update('ads')->set(array('id_category' => '1'))->execute();
         //delete all categories
         $query = DB::delete('categories')->where('id_category', '!=', '1')->execute();
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('All categories were deleted.'));
     } else {
         Alert::set(Alert::ERROR, __('You did not confirmed your delete action.'));
     }
     HTTP::redirect(Route::url('oc-panel', array('controller' => 'category', 'action' => 'index')));
 }
示例#16
0
 /**
  * remove category from custom field
  * @return void 
  */
 public function action_remove_category()
 {
     if (Core::get('id_category')) {
         $name = $this->request->param('id');
         $field = new Model_Field();
         $field_data = $field->get($name);
         $category = new Model_Category(Core::get('id_category'));
         // category or custom field not found
         if (!$category->loaded() or !$field_data) {
             $this->redirect(Route::get('oc-panel')->uri(array('controller' => Request::current()->controller(), 'action' => 'index')));
         }
         // remove current category from custom field categories
         if (is_array($field_data['categories']) and ($key = array_search($category->id_category, $field_data['categories'])) !== FALSE) {
             unset($field_data['categories'][$key]);
         }
         try {
             // update custom field categories
             if ($field->update($name, $field_data['values'], $field_data['categories'], $field_data)) {
                 Core::delete_cache();
                 Alert::set(Alert::SUCCESS, sprintf(__('Field %s removed'), $name));
             } else {
                 Alert::set(Alert::ERROR, sprintf(__('Field %s cannot be removed'), $name));
             }
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         $this->redirect(Route::get('oc-panel')->uri(array('controller' => 'category', 'action' => 'update', 'id' => $category->id_category)));
     }
     $this->redirect(Route::get('oc-panel')->uri(array('controller' => Request::current()->controller(), 'action' => 'index')));
 }
示例#17
0
 public static function copy($from_locale, $to_locale, $type)
 {
     //get the contents for type locale
     $contents = self::get_contents($type, $from_locale);
     $i = 0;
     foreach ($contents as $content) {
         $to_locale_content = new self();
         $to_locale_content = $to_locale_content->where('seotitle', '=', $content->seotitle)->where('locale', '=', $to_locale)->where('type', '=', $type)->limit(1)->cached()->find();
         if (!$to_locale_content->loaded()) {
             $to_locale_content = new self();
             $to_locale_content->locale = $to_locale;
             $to_locale_content->order = $content->order;
             $to_locale_content->title = $content->title;
             $to_locale_content->seotitle = $content->seotitle;
             $to_locale_content->description = $content->description;
             $to_locale_content->from_email = $content->from_email;
             $to_locale_content->created = $content->created;
             $to_locale_content->type = $content->type;
             $to_locale_content->status = $content->status;
             try {
                 $to_locale_content->save();
                 $i++;
             } catch (Exception $e) {
                 Alert::set(Alert::ERROR, $e->getMessage());
             }
         }
     }
     Core::delete_cache();
     if ($i > 0) {
         return TRUE;
     }
     return FALSE;
 }