| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | |
| 8 | 8 | class Field_m extends Winter_MVC_Model { |
| 9 | 9 | |
| 10 | 10 | public $_table_name = 'wdk_fields'; |
| 11 | - public $_order_by = 'order_index'; | |
| 11 | + public $_order_by = 'order_index,idfield'; | |
| 12 | 12 | public $_primary_key = 'idfield'; |
| 13 | 13 | public $_own_columns = array(); |
| 14 | 14 | public $_timestamps = TRUE; |
| 15 | 15 | protected $_primary_filter = 'intval'; |
| @@ -14,10 +14,32 @@ | ||
| 14 | 14 | public $_timestamps = TRUE; |
| 15 | 15 | protected $_primary_filter = 'intval'; |
| 16 | 16 | public $form_admin = array(); |
| 17 | 17 | public $fields_list = NULL; |
| 18 | + | |
| 19 | + public $fields_validations = array(); | |
| 20 | + public $fields_autosuggestions = array(); | |
| 18 | 21 | |
| 19 | 22 | public function __construct(){ |
| 23 | + $this->fields_validations = array( | |
| 24 | + 'is_numerical'=> __('Numerical', 'wpdirectorykit'), | |
| 25 | + 'is_phone'=> __('Phone', 'wpdirectorykit'), | |
| 26 | + 'is_phone|wdk_viber'=> __('Phone(viber)', 'wpdirectorykit'), | |
| 27 | + 'is_phone|wdk_whatsapp'=> __('Phone(whatsApp)', 'wpdirectorykit'), | |
| 28 | + 'is_email'=> __('Email', 'wpdirectorykit'), | |
| 29 | + ); | |
| 30 | + | |
| 31 | + $this->fields_autosuggestions = array( | |
| 32 | + 'google_api_cities'=> __('Google Api Cities', 'wpdirectorykit'), | |
| 33 | + 'google_api_countries'=> __('Google Api Countries', 'wpdirectorykit'), | |
| 34 | + 'rapid_api_cities'=> __('Rapid Api Cities', 'wpdirectorykit'), | |
| 35 | + 'rapid_api_countries'=> __('Rapid Api Countries', 'wpdirectorykit'), | |
| 36 | + 'countries'=> __('Countries', 'wpdirectorykit'), | |
| 37 | + 'db_locations'=> __('Db Locations', 'wpdirectorykit'), | |
| 38 | + 'db_categories'=> __('Db Categories', 'wpdirectorykit'), | |
| 39 | + 'db_selft_field'=> __('Current Field Values', 'wpdirectorykit'), | |
| 40 | + ); | |
| 41 | + | |
| 20 | 42 | parent::__construct(); |
| 21 | 43 | } |
| 22 | 44 | |
| 23 | 45 | /* [START] For dynamic data table */ |
| @@ -61,9 +83,9 @@ | ||
| 61 | 83 | } |
| 62 | 84 | |
| 63 | 85 | public function check_deletable($id) |
| 64 | 86 | { |
| 65 | - if(wmvc_user_in_role('administrator')) return true; | |
| 87 | + if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')) return true; | |
| 66 | 88 | |
| 67 | 89 | return false; |
| 68 | 90 | } |
| 69 | 91 | |
| @@ -124,8 +146,9 @@ | ||
| 124 | 146 | "field_label" => "Unsection", |
| 125 | 147 | "prefix" => '', |
| 126 | 148 | "suffix" => '', |
| 127 | 149 | "values_list" => '', |
| 150 | + "placeholder" => '', | |
| 128 | 151 | "hint" =>'' |
| 129 | 152 | ); |
| 130 | 153 | |
| 131 | 154 | foreach ($this->field_m->get() as $field) { |
| @@ -145,8 +168,9 @@ | ||
| 145 | 168 | "field_label" => wmvc_show_data('field_label',$field), |
| 146 | 169 | "prefix" => wmvc_show_data('prefix',$field), |
| 147 | 170 | "suffix" => wmvc_show_data('suffix',$field), |
| 148 | 171 | "values_list" => wmvc_show_data('values_list',$field), |
| 172 | + "placeholder" => wmvc_show_data('placeholder',$field), | |
| 149 | 173 | "hint" =>wmvc_show_data('hint',$field), |
| 150 | 174 | "fields" => array() |
| 151 | 175 | ); |
| 152 | 176 | } else { |
| @@ -159,7 +183,29 @@ | ||
| 159 | 183 | /* only admin can edit */ |
| 160 | 184 | public function is_related($item_id, $user_id, $method = 'edit') |
| 161 | 185 | { |
| 162 | 186 | return false; |
| 187 | + } | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + public function delete($field_id, $user_id=NULL) { | |
| 192 | + | |
| 193 | + if(!$this->check_deletable($field_id, $user_id)) return false; | |
| 194 | + | |
| 195 | + $this->load->model('listingfield_m'); | |
| 196 | + | |
| 197 | + /* remove from listing fields */ | |
| 198 | + $field_data = $this->get($field_id, TRUE); | |
| 199 | + | |
| 200 | + if($field_data) | |
| 201 | + $this->listingfield_m->delete_table_column($field_data, $field_id); | |
| 202 | + | |
| 203 | + | |
| 204 | + parent::delete($field_id); | |
| 205 | + | |
| 206 | + do_action('wpdirectorykit/model/field/delete', $field_id); | |
| 207 | + | |
| 208 | + return true; | |
| 163 | 209 | } |
| 164 | 210 | } |
| 165 | 211 | ?> |