Exemplo n.º 1
0
 static function getItem($payment, $app)
 {
     $list = self::getList();
     $item = $list[$payment];
     $model = new PluginSettingsModel();
     $settingMap = (include $item['dir'] . DS . 'lib' . DS . 'config' . DS . 'settings.php');
     $settingSaved = $model->get($app, $payment);
     $settingMap = array_merge(array('payment' => array('group' => 'main', 'value' => $payment, 'type' => Settings::$TYPE_HIDDEN), 'title' => array('group' => 'main', 'name' => 'Название способа оплаты', 'type' => Settings::$TYPE_INPUT, 'value' => '', 'validate' => array('rule' => 'empty')), 'description' => array('group' => 'main', 'name' => 'Описание способа оплаты', 'type' => Settings::$TYPE_TEXTAREA, 'value' => ''), 'logo' => array('group' => 'main', 'name' => 'Логотип способа оплаты', 'type' => Settings::$TYPE_INPUT, 'value' => '')), $settingMap);
     foreach ($settingSaved as $key => $value) {
         if (!isset($settingMap[$key])) {
             continue;
         }
         $settingMap[$key]['value'] = $value;
     }
     $item['settings'] = $settingMap;
     return $item;
 }
 function execute()
 {
     $payment = Request::post('payment');
     $settings = Payment::getItem($payment, 'connection');
     $keys = array_keys($settings['settings']);
     $data = array();
     foreach ($keys as $key) {
         if (!isset($_POST[$key])) {
             continue;
         }
         $data[$key] = Request::post($key);
     }
     if (isset($data['payment'])) {
         unset($data['payment']);
     }
     $model = new PluginSettingsModel();
     $model->updateSetting('connection', $payment, $data);
     return true;
 }