/** * @return SPPayment */ public static function &payment() { SPLoader::loadClass('services.payment'); return SPPayment::getInstance(); }
/** * @param int $sid * @return void */ public function loadData($sid) { if ($this->_off) { return null; } $this->sid = $sid; $fdata = Sobi::Reg('fields_data_' . $sid, array()); $this->suffix = SPLang::clean($this->suffix); if ($sid && count($fdata) && isset($fdata[$this->id])) { $this->_fData = $fdata[$this->id]; $this->lang = $this->_fData->lang; $this->_rawData = $this->_fData->baseData; $this->_data = $this->_fData->baseData; // if the field has own method we have to re-init $this->checkMethod('loadData'); if ($this->_type && method_exists($this->_type, 'loadData')) { $this->_type->loadData($sid, $this->_fData, $this->_rawData, $this->_data); } if ($this->editLimit > 0 && is_numeric($this->_fData->editLimit)) { $this->editLimit = $this->_fData->editLimit; } elseif ($this->editLimit < 0) { $this->editLimit = 2; } else { $this->editLimit = 2; } // if the limit has been reached - this field cannot be required if (!Sobi::Can('entry.manage.*') && $this->editLimit < 1 && in_array(SPRequest::task(), array('entry.save', 'entry.edit', 'entry.submit'))) { $this->required = false; $this->enabled = false; $this->_off = true; } } else { $fdata = Sobi::Reg('editcache'); if (is_array($fdata) && isset($fdata[$this->nid])) { $this->_data = $fdata[$this->nid]; $this->_rawData = $fdata[$this->nid]; } else { $this->checkMethod('loadData'); if ($this->_type && method_exists($this->_type, 'loadData')) { $this->_type->loadData($sid, $this->_fData, $this->_rawData, $this->_data); } else { $this->_rawData = SPFactory::db()->select('baseData', 'spdb_field_data', array('sid' => $this->sid, 'fid' => $this->fid, 'lang' => Sobi::Lang(false)))->loadResult(); } } } if (!$this->isFree && SPRequest::task() == 'entry.edit') { /* in case we are editing - check if this field wasn't paid already */ SPLoader::loadClass('services.payment'); if (SPPayment::check($sid, $this->id)) { $this->fee = 0; $this->isFree = true; } } }