public function execute() { if (!$this->getUser()->getRights('shop', 'settings')) { throw new waRightsException(_w('Access denied')); } if ($plugin_id = waRequest::post('plugin_id')) { $model = new shopPluginModel(); if ($plugin = $model->getByField(array('id' => $plugin_id, 'type' => 'payment'))) { $settings_model = new shopPluginSettingsModel(); $settings_model->del($plugin['id'], null); $model->deleteById($plugin['id']); } else { throw new waException("Payment plugin {$plugin_id} not found", 404); } } }
public function deleteByField($field, $value = null) { if (is_array($field)) { $items = $this->getByField($field, $this->id); $ids = array_keys($items); } else { if ($field == $this->id) { $ids = $value; } else { $items = $this->getByField($field, $value, $this->id); $ids = array_keys($items); } } $res = false; if ($ids) { if ($res = parent::deleteByField($this->id, $ids)) { $model = new shopPluginSettingsModel(); $model->deleteByField('id', $ids); } } return $res; }