Ejemplo n.º 1
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $data = SPRequest::string('bankdata', null, true);
     $data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
     try {
         SPLang::saveValues($data);
     } catch (SPException $x) {
         $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
         Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
         $this->response(Sobi::Back(), $message, false, 'error');
     }
     $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
 }
Ejemplo n.º 2
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section()));
     SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section());
     $data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
     try {
         SPLang::saveValues($data);
         $data['key'] = 'ppsubject';
         $data['value'] = SPRequest::string('ppsubject', true);
         SPLang::saveValues($data);
     } catch (SPException $x) {
         $message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
         Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
         $this->response(Sobi::Back(), $message, false, 'error');
     }
     $this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
 }
Ejemplo n.º 3
0
 protected function save($new = false)
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $content = SPRequest::raw('file_content', null, 'post');
     $file = $this->file(SPRequest::cmd('fileName'), !$new);
     Sobi::Trigger('Save', $this->name(), array(&$content, &$file));
     if (!$file) {
         throw new SPException(SPLang::e('Missing  file to save %s', SPRequest::cmd('fileName')));
     }
     $File = SPFactory::Instance('base.fs.file', $file);
     $File->content(stripslashes($content));
     try {
         $File->save();
         $u = array('task' => 'template.edit', 'file' => SPRequest::cmd('fileName'));
         if (Sobi::Section()) {
             $u['sid'] = Sobi::Section();
         }
         $this->response(Sobi::Url($u), Sobi::Txt('TP.FILE_SAVED'), $new, 'success');
     } catch (SPException $x) {
         $this->response(Sobi::Back(), $x->getMessage(), false, 'error');
     }
 }
Ejemplo n.º 4
0
 /**
  * Save the config
  */
 protected function save($apply, $clone = false)
 {
     $sid = Sobi::Section();
     $this->authorise($sid);
     if ($sid) {
         $this->validate('config.general', array('task' => 'config.general', 'sid' => $sid));
     } else {
         $this->validate('config.global', array('task' => 'config.global'));
     }
     $fields = array();
     $section = false;
     $data = SPRequest::arr('spcfg', array());
     // strange thing =8-O
     if (!isset($data['alphamenu.extra_fields_array'])) {
         $data['alphamenu.extra_fields_array'] = array();
     }
     if (!isset($data['template.icon_fonts_arr'])) {
         $data['template.icon_fonts_arr'] = array();
     }
     foreach ($data as $k => $v) {
         if (is_string($v)) {
             $v = htmlspecialchars_decode($v);
         }
         //			$k = str_replace( array( 'spcfg_', '.' ), array( null, '_' ), $k );
         $k = str_replace('spcfg_', null, $k);
         $s = explode('.', $k);
         $s = $s[0];
         if (!isset($fields[$s])) {
             $fields[$s] = array();
         }
         $k = str_replace("{$s}.", null, $k);
         $c = explode('_', $k);
         if ($c[count($c) - 1] == 'array' && !is_array($v)) {
             if (!strstr($v, '|')) {
                 $v = explode(',', $v);
             } else {
                 $v = explode('|', $v);
             }
         }
         $fields[$s][$k] = $v;
         if (preg_match('/^section.*/', $k)) {
             $section = true;
         }
     }
     $values = array();
     if (count($fields)) {
         foreach ($fields as $sec => $keys) {
             if (count($keys)) {
                 foreach ($keys as $k => $v) {
                     $values[] = array('sKey' => $k, 'sValue' => $v, 'section' => Sobi::Section(), 'critical' => 0, 'cSection' => $sec);
                 }
             }
         }
     }
     if ($section) {
         /* @var $sec SPSection */
         $sec = SPFactory::Model('section');
         $sec->init(SPRequest::sid());
         $sec->getRequest('section');
         $sec->save(true);
     }
     Sobi::Trigger('SaveConfig', $this->name(), array(&$values));
     try {
         SPFactory::db()->insertArray('spdb_config', $values, true);
     } catch (SPException $x) {
         $this->response(Sobi::Back(), $x->getMessage(), false, SPC::ERROR_MSG);
     }
     if (!($section && !Sobi::Section())) {
         SPFactory::cache()->cleanAll();
     } else {
         SPFactory::cache()->cleanSection();
     }
     Sobi::Trigger('After', 'SaveConfig', array(&$values));
     $this->response(Sobi::Back(), Sobi::Txt('MSG.CONFIG_SAVED'), false, 'success');
 }
Ejemplo n.º 5
0
 /**
  * @param bool $up
  */
 private function singleReorder($up)
 {
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $eq = $up ? '<' : '>';
     $dir = $up ? 'position.desc' : 'position.asc';
     $current = $this->_model->getPosition(SPRequest::int('pid'));
     try {
         $db->select('position, id', 'spdb_relations', array('position' . $eq => $current, 'oType' => 'entry', 'pid' => SPRequest::int('pid')), $dir, 1);
         $interchange = $db->loadAssocList();
         if ($interchange && count($interchange)) {
             $db->update('spdb_relations', array('position' => $interchange[0]['position']), array('oType' => 'entry', 'pid' => SPRequest::int('pid'), 'id' => $this->_model->get('id')), 1);
             $db->update('spdb_relations', array('position' => $current), array('oType' => 'entry', 'pid' => SPRequest::int('pid'), 'id' => $interchange[0]['id']), 1);
         } else {
             $current = $up ? $current-- : $current++;
             $db->update('spdb_relations', array('position' => $current), array('oType' => 'entry', 'pid' => SPRequest::int('pid'), 'id' => $this->_model->get('id')), 1);
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
     }
     $this->response(Sobi::Back(), Sobi::Txt('ENTRY_POSITION_CHANGED'), true, SPC::SUCCESS_MSG);
 }
Ejemplo n.º 6
0
 /**
  * @param bool $state
  * @return bool
  */
 protected function state($state)
 {
     $rid = SPRequest::int('rid');
     $where = null;
     if (!$rid) {
         $rid = SPRequest::arr('rid');
         if (is_array($rid) && !empty($rid)) {
             $where = array('rid' => $rid);
         }
     } else {
         $where = array('rid' => $rid);
     }
     if (!$where) {
         $this->response(Sobi::Back(), Sobi::Txt('ACL_SELECT_RULE_FIRST'), true, SPC::ERROR_MSG);
         return false;
     }
     try {
         SPFactory::db()->update('spdb_permissions_rules', array('state' => $state), $where);
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('Db reports %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     $this->response(Sobi::Back(), Sobi::Txt('ACL.MSG_STATE_CHANGED'), true, SPC::SUCCESS_MSG);
 }
Ejemplo n.º 7
0
 protected function toggle()
 {
     $plugin = SPRequest::cmd('eid');
     $plugin = explode('.', $plugin);
     $ptype = $plugin[0];
     $plugin = $plugin[1];
     $message = null;
     if (SPRequest::sid()) {
         try {
             $app = SPFactory::db()->select('name', 'spdb_plugins', array('pid' => $plugin, 'type' => $ptype))->loadResult();
             $state = !SPFactory::db()->select('enabled', 'spdb_plugin_section', array('section' => SPRequest::sid('get'), 'pid' => $plugin, 'type' => $ptype))->loadResult();
             SPFactory::db()->replace('spdb_plugin_section', array('section' => SPRequest::sid('get'), 'pid' => $plugin, 'type' => $ptype, 'enabled' => $state, 0));
             $message = $state ? Sobi::Txt('EX.APP_ENABLED', $app) : Sobi::Txt('EX.APP_DISABLED', $app);
             $messageType = $state ? 'success' : 'warning';
         } catch (SPException $x) {
             $message = Sobi::Txt('EX.CANNOT_CHANGE_STATE_ERR', 'error');
             $messageType = 'error';
             Sobi::Error('extensions', SPLang::e('CANNOT_UPDATE_PLUGIN', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     } else {
         try {
             $app = SPFactory::db()->select(array('enabled', 'name'), 'spdb_plugins', array('pid' => $plugin, 'type' => $ptype))->loadObject();
             SPFactory::db()->update('spdb_plugins', array('enabled' => !$app->enabled), array('type' => $ptype, 'pid' => $plugin));
             $message = !$app->enabled ? Sobi::Txt('EX.APP_ENABLED', $app->name) : Sobi::Txt('EX.APP_DISABLED', $app->name);
             $messageType = !$app->enabled ? 'success' : 'warning';
         } catch (SPException $x) {
             $message = Sobi::Txt('EX.CANNOT_CHANGE_STATE_ERR', 'error');
             $messageType = 'error';
             Sobi::Error('extensions', SPLang::e('CANNOT_UPDATE_PLUGIN', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     $this->response(Sobi::Back(), $message, false, $messageType);
 }
Ejemplo n.º 8
0
 private function paymentView($tsId = null, $data = null)
 {
     /* determine template package */
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     /* load template config */
     $this->tplCfg($tplPackage);
     if (isset($this->_tCfg['general']['functions']) && $this->_tCfg['general']['functions']) {
         $customClass = SPLoader::loadClass('/' . str_replace('.php', null, $this->_tCfg['general']['functions']), false, 'templates');
         if (method_exists($customClass, 'BeforePaymentView')) {
             $customClass::BeforePaymentView($data);
         }
     }
     SPFactory::mainframe()->addObjToPathway($this->_model);
     $view = SPFactory::View('payment', $this->template);
     $view->assign($this->_model, 'entry');
     $view->assign($data, 'pdata');
     $view->assign(SPFactory::user()->getCurrent(), 'visitor');
     $view->assign($this->_task, 'task');
     $view->addHidden($tsId, 'speditentry');
     $view->addHidden($tsId, 'ssid');
     $view->setConfig($this->_tCfg, $this->_task);
     $view->setTemplate($tplPackage . '.payment.' . $this->_task);
     Sobi::Trigger(ucfirst($this->_task), $this->name(), array(&$view, &$this->_model));
     if (SPRequest::cmd('method', null, 'post') == 'xhr') {
         $view->display();
         $response = ob_get_contents();
         $this->response(Sobi::Back(), $response, false, SPC::INFO_MSG);
     } else {
         $view->display();
     }
     if ($customClass && method_exists($customClass, 'AfterPaymentView')) {
         $customClass::AfterPaymentView();
     }
 }
Ejemplo n.º 9
0
 /**
  * Route task
  */
 public function execute()
 {
     /* parent class executes the plugins */
     $r = false;
     $task = $this->_task;
     if (strstr($this->_task, '.')) {
         $task = explode('.', $this->_task);
         $this->_fieldType = $task[1];
         $task = $task[0];
     }
     switch ($task) {
         case 'list':
             $r = true;
             $this->listFields();
             break;
         case 'add':
         case 'edit':
             $r = true;
             $this->edit();
             break;
         case 'cancel':
             $r = true;
             $this->checkIn();
             $this->response(Sobi::Back());
             break;
         case 'addNew':
             $r = true;
             Sobi::Redirect(Sobi::Url(array('task' => 'field.edit', 'fid' => $this->saveNew(), 'sid' => SPRequest::sid())));
             break;
         case 'apply':
         case 'save':
             $r = true;
             $this->save();
             break;
         case 'clone':
             $r = true;
             $this->save(true);
             break;
         case 'delete':
             $r = true;
             SPFactory::cache()->cleanSection();
             $this->response(Sobi::Url(array('task' => 'field.list', 'pid' => Sobi::Section())), $this->delete(), true);
             break;
         case 'reorder':
             $r = true;
             $this->reorder();
             break;
         case 'revisions':
             $r = true;
             $this->revisions();
             break;
         case 'up':
         case 'down':
             $r = true;
             $this->singleReorder($this->_task == 'up');
             break;
         case 'hide':
         case 'publish':
         case 'setRequired':
         case 'setNotRequired':
         case 'setEditable':
         case 'setNotEditable':
         case 'setFee':
         case 'setFree':
         case 'toggle':
             $r = true;
             $this->authorise($this->_task);
             SPFactory::cache()->cleanSection();
             $this->response(Sobi::Back(), $this->changeState($task), true);
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!Sobi::Trigger('Execute', $this->name(), array(&$this))) {
                 $fid = SPRequest::int('fid');
                 $method = $this->_task;
                 if ($fid) {
                     SPLoader::loadModel('field', true);
                     $fdata = $this->loadField($fid);
                     $field = new SPAdmField();
                     $field->extend($fdata);
                     try {
                         $field->{$method}();
                     } catch (SPException $x) {
                         Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
                     }
                 } elseif (!parent::execute()) {
                     Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
                 }
             }
             break;
     }
     return $r;
 }
Ejemplo n.º 10
0
 /**
  * Save an object
  * @param bool $apply
  * @param bool $clone
  */
 protected function save($apply, $clone = false)
 {
     $sets = array();
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $this->validate($this->_type . '.edit', $this->_type);
     $apply = (int) $apply;
     if (!$this->_model) {
         $this->setModel(SPLoader::loadModel($this->_type));
     }
     $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int($this->_type . '_id');
     if ($sid) {
         $this->_model->init($sid);
     }
     /** store previous state for possible triggers */
     $preState = array('approved' => $this->_model->get('approved'), 'state' => $this->_model->get('state'), 'new' => !$this->_model->get('id'));
     SPFactory::registry()->set('object_previous_state', $preState);
     $this->_model->getRequest($this->_type);
     if ($this->_model->get('id')) {
         if (Sobi::My('id') && Sobi::My('id') == $this->_model->get('owner')) {
             $this->authorise('edit', 'own');
         } else {
             $this->authorise('edit', '*');
         }
     } else {
         $this->authorise('add', 'own');
     }
     $this->_model->save();
     $sid = $this->_model->get('id');
     $sets['sid'] = $sid;
     $sets[$this->_type . '.nid'] = $this->_model->get('nid');
     $sets[$this->_type . '.id'] = $sid;
     if ($apply || $clone) {
         if ($clone) {
             $msg = Sobi::Txt('MSG.OBJ_CLONED', array('type' => Sobi::Txt($this->_type)));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, false, 'success', array('sets' => $sets));
         } else {
             $msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, $this->_type == 'section', 'success', array('sets' => $sets));
         }
     } elseif ($this->_task == 'saveAndNew') {
         $msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
         $sid = $this->_model->get('parent');
         if (!$sid) {
             $sid = Sobi::Section();
         }
         $this->response(Sobi::Url(array('task' => $this->_type . '.add', 'sid' => $sid)), $msg, true, 'success', array('sets' => $sets));
     } else {
         $this->response(Sobi::Back(), Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_type))), true, 'success');
     }
 }