Пример #1
0
 public function execute()
 {
     SPRequest::set('task', strtolower('list.' . $this->_task));
     $task = str_replace(':', '-', SPRequest::task());
     $task = explode('.', $task);
     if (isset($task[2]) && $task[2] == 'switch' && isset($task[3])) {
         return $this->switchIndex($task[3]);
     } else {
         if (SPRequest::cmd('letter')) {
             $this->_letter = urldecode(SPRequest::cmd('letter'));
         } else {
             $this->_letter = urldecode($task[2]);
             SPRequest::set('letter', strtoupper($this->_letter));
             if (isset($task[3])) {
                 $this->determineFid($task[3]);
             } else {
                 $this->determineFid(Sobi::Cfg('alphamenu.primary_field'));
             }
         }
         if (!strlen($this->_letter) || !Sobi::Section()) {
             Sobi::Error($this->name(), SPLang::e('SITE_NOT_FOUND_MISSING_PARAMS'), SPC::NOTICE, 404, __LINE__, __FILE__);
         }
         if (!preg_match('/^[\\x20-\\x7f]*$/D', $this->_letter) && function_exists('mb_strtolower')) {
             $this->_letter = mb_strtoupper($this->_letter);
         } else {
             $this->_letter = strtoupper($this->_letter);
         }
         $this->view();
     }
 }
Пример #2
0
 /**
  */
 public function execute()
 {
     switch ($this->_task) {
         case 'add':
             $this->setModel(SPLoader::loadModel('section'));
             $this->editForm();
             break;
         case 'edit':
             Sobi::Redirect(Sobi::Url(array('task' => 'config', 'sid' => SPRequest::sid())), null, true);
             break;
         case 'view':
         case 'entries':
             Sobi::ReturnPoint();
             $this->view($this->_task == 'entries', Sobi::GetUserState('entries_filter', 'sp_entries_filter', null));
             break;
         case 'toggle.enabled':
         case 'toggle.approval':
             $this->toggleState();
             break;
         default:
             /* case plugin didn't register this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Пример #3
0
 /**
  */
 public function execute()
 {
     $r = false;
     switch ($this->_task) {
         case 'chooser':
         case 'expand':
             SPLoader::loadClass('html.input');
             $r = true;
             $this->chooser($this->_task == 'expand');
             break;
         case 'parents':
             $r = true;
             $this->parents();
             break;
         case 'icon':
             $r = true;
             $this->iconChooser();
             break;
         default:
             /* case parent didn't registered this task, it was an error */
             if (!parent::execute() && $this->name() == __CLASS__) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             } else {
                 $r = true;
             }
             break;
     }
     return $r;
 }
Пример #4
0
 protected function save()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $id = SPRequest::cmd('filter_id');
     if ($id) {
         $this->validate('field.filter', 'filter');
         $filters = $this->getFilters();
         $name = SPRequest::string('filter_name', 'Filter Name');
         $msg = str_replace(array("\n", "\t", "\r"), null, SPLang::clean(SPRequest::string('filter_message', 'The data entered in the $field field contains not allowed characters')));
         $regex = SPLang::clean(SPRequest::raw('filter_regex', '/^[\\.*]+$/'));
         $regex = str_replace('[:apostrophes:]', '\\"' . "\\'", $regex);
         $regex = base64_encode(str_replace(array("\n", "\t", "\r"), null, $regex));
         $custom = 'custom';
         if (isset($filters[$id]) && !strlen($filters[$id]['options'])) {
             $regex = $filters[$id]['params'];
             $custom = null;
         }
         $filters[$id] = array('params' => $regex, 'key' => $id, 'value' => $name, 'description' => $msg, 'options' => $custom);
         SPFactory::registry()->saveDBSection($filters, 'fields_filter');
         $this->response(Sobi::Url('filter'), Sobi::Txt('FLR.MSG_FILTER_SAVED'), false, 'success');
     } else {
         $this->response(Sobi::Url('filter'), SPLang::e('FILTER_NOT_FOUND'), true, SPC::ERROR_MSG);
     }
 }
Пример #5
0
 /**
  * @param string $title
  * @return string|void
  */
 public function setTitle($title)
 {
     if (strstr(SPRequest::task(), '.add')) {
         $title = str_replace('EDIT', 'ADD', $title);
     }
     $title = Sobi::Txt($title, array('field' => $this->get('field.name'), 'field_type' => $this->get('field.fieldType')));
     Sobi::Trigger('setTitle', $this->name(), array(&$title));
     SPFactory::header()->setTitle($title);
     $this->set($title, 'site_title');
 }
Пример #6
0
 protected function search()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     //		$selected = SPRequest::int( 'selected', 0 );
     $ssid = SPRequest::base64('ssid');
     $query = SPRequest::string('q', null);
     $session = SPFactory::user()->getUserState('userSelector', null, array());
     $setting = $session[$ssid];
     /* get the site to display */
     $site = SPRequest::int('site', 1);
     $eLim = Sobi::Cfg('user_selector.entries_limit', 18);
     $eLimStart = ($site - 1) * $eLim;
     $params = array();
     if ($query) {
         $q = '%' . $query . '%';
         $params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR');
     }
     try {
         $count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult();
         $data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList();
     } catch (SPException $x) {
         echo $x->getMessage();
         exit;
     }
     $response = array('sites' => ceil($count / $eLim), 'site' => $site);
     if (count($data)) {
         $replacements = array();
         preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements);
         $placeholders = array();
         if (isset($replacements[0]) && count($replacements[0])) {
             foreach ($replacements[0] as $placeholder) {
                 $placeholders[] = str_replace('%', null, $placeholder);
             }
         }
         if (count($replacements)) {
             foreach ($data as $index => $user) {
                 $txt = $setting['format'];
                 foreach ($placeholders as $attribute) {
                     if (isset($user[$attribute])) {
                         $txt = str_replace('%' . $attribute, $user[$attribute], $txt);
                     }
                 }
                 $data[$index]['text'] = $txt;
             }
         }
         $response['users'] = $data;
     }
     SPFactory::mainframe()->cleanBuffer();
     echo json_encode($response);
     exit;
 }
Пример #7
0
 public function execute()
 {
     $this->start = microtime(true);
     $sites = $this->getSites();
     $responses = array();
     $status = 'working';
     $message = null;
     $this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT;
     //		$this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL;
     $task = SPRequest::task();
     if (in_array($task, array('crawler.init', 'crawler.restart'))) {
         if ($task == 'crawler.restart') {
             SPFactory::cache()->cleanSection(Sobi::Section());
         }
         SPFactory::db()->truncate(self::DB_TABLE);
         $multiLang = Sobi::Cfg('lang.multimode', false);
         if ($multiLang) {
             $langs = SPFactory::CmsHelper()->getLanguages();
             if ($multiLang && $langs) {
                 foreach ($langs as $lang) {
                     $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang);
                 }
             }
         }
         $responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section());
         $sites = $this->getSites();
     }
     if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) {
         $message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult());
         SPFactory::db()->truncate(self::DB_TABLE);
         $this->response(array('status' => 'done', 'data' => array(), 'message' => $message));
     }
     if (count($sites)) {
         $i = 0;
         $timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true);
         foreach ($sites as $site) {
             if (!strlen($site)) {
                 continue;
             }
             $responses[] = $this->getResponse($site);
             $i++;
             if (microtime(true) - $this->start > $timeLimit) {
                 break;
             }
         }
         $message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites));
     }
     $this->response(array('status' => $status, 'data' => $responses, 'message' => $message));
 }
Пример #8
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');
 }
Пример #9
0
 /**
  * @param string $section - error section. I.e. Entry controller
  * @param string $msg - main message
  * @param int $type - error type
  * @param int $code - error code
  * @param int $line - file line
  * @param string $file - file name
  * @param null $sMsg - additional message
  * @return null
  */
 public static function Error($section, $msg, $type = SPC::NOTICE, $code = 0, $line = null, $file = null, $sMsg = null)
 {
     if ($type == 0) {
         $type = SPC::NOTICE;
     }
     /*
      * Mi., Jul 4, 2012
      * So now could someone explain me what was the sense of the code below and why trigger_error was commented out??!!
      *
      * Mi., Jul 4, 2012
      * Ok, it doesn't make much sense.
      * This is what actually should be removed.
      * 		if( Sobi::Cfg( 'debug.level', 0 ) < $type ) { return true; }
      * It was the problem with the ACL when error reporting was disabled.
      * But why the hell I removed the damn trigger_error from it?!!!
      * Being sloppy again?!!!!
      * Frack me - it means that since 20.07.2011 the whole error reporting went in nirvana??
      */
     if ($type == E_USER_ERROR) {
         $rType = E_ERROR;
         $code = $code ? $code : 500;
     } elseif ($type == E_USER_WARNING) {
         $rType = E_WARNING;
     } else {
         $rType = $type;
     }
     if (Sobi::Cfg('debug.level', 0) >= $rType) {
         if ($file) {
             $sMsg .= sprintf('In file %s at line %d', $file, $line);
         }
         if (SPRequest::task()) {
             $sMsg .= ' [ ' . SPRequest::task() . ' ]';
         }
         $error = array('section' => $section, 'message' => $msg, 'code' => $code, 'file' => $file, 'line' => $line, 'content' => $sMsg);
         trigger_error('json://' . json_encode($error), $type);
     }
     if ($code) {
         SPLoader::loadClass('base.mainframe');
         SPLoader::loadClass('cms.base.mainframe');
         SPFactory::mainframe()->runAway($msg, $code, SPConfig::getBacktrace());
     }
     return null;
 }
Пример #10
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');
 }
Пример #11
0
 public function cachedView($xml, $template, $cacheId, $config = array())
 {
     $this->_xml = $xml;
     Sobi::Trigger('Start', ucfirst(__FUNCTION__), array(&$this->_xml));
     $templatePackage = SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates');
     $templateOverride = SPRequest::cmd('sptpl');
     if ($templateOverride) {
         if (strstr($templateOverride, '.')) {
             $templateOverride = str_replace('.', '/', $templateOverride);
         }
         $template = $templateOverride . '.xsl';
     }
     if (file_exists(Sobi::FixPath($templatePackage . '/' . $template))) {
         $template = Sobi::FixPath($templatePackage . '/' . $template);
     } else {
         $type = SPFactory::db()->select('oType', 'spdb_object', array('id' => SPRequest::sid()))->loadResult();
         $template = $templatePackage . '/' . $type . '/' . $template;
     }
     SPFactory::registry()->set('current_template', $templatePackage);
     $this->_templatePath = $templatePackage;
     $this->_template = str_replace('.xsl', null, $template);
     $ini = array();
     if (count($config)) {
         foreach ($config as $file) {
             $file = parse_ini_file($file, true);
             foreach ($file as $section => $keys) {
                 if (isset($ini[$section])) {
                     $ini[$section] = array_merge($ini[$section], $keys);
                 } else {
                     $ini[$section] = $keys;
                 }
             }
         }
     }
     $this->setConfig($ini, SPRequest::task('get'));
     $this->parseXml();
     $this->validateData($cacheId);
     Sobi::Trigger('After', ucfirst(__FUNCTION__), array(&$this->_xml));
 }
Пример #12
0
 /**
  */
 public function execute()
 {
     /* parent class executes the plugins */
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     switch ($this->_task) {
         case 'front':
             $this->getSections();
             /** @var $view SPAdmPanelView */
             $view = SPFactory::View('front');
             /* load template config */
             //				$this->tplCfg( 'front' );
             //				$view->setConfig( $this->_tCfg, 'general' );
             $view->determineTemplate('front', SPC::DEFAULT_TEMPLATE);
             $view->assign($this->_sections, 'sections');
             $view->display();
             break;
         default:
             /* case parents or plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Пример #13
0
 public function execute()
 {
     SPRequest::set('task', $this->_type . '.' . $this->_task);
     if (strstr($this->_task, '.')) {
         $task = explode('.', $this->_task);
         $class = SPLoader::loadClass('opt.listing.' . $task[0], false, null, true);
     } else {
         $class = SPLoader::loadClass('opt.listing.' . $this->_task, false, null, true);
     }
     if ($class) {
         $imp = class_implements($class);
         if (is_array($imp) && in_array('SPListing', $imp)) {
             /** @noinspection PhpIncludeInspection $compatibility */
             $listing = new $class();
             if (!isset($class::$compatibility)) {
                 define('SOBI_LEGACY_LISTING', true);
                 if (strstr($this->_task, '.')) {
                     $t = explode('.', $this->_task);
                     $listing->setTask($t[0]);
                 } else {
                     $listing->setTask($this->_task);
                 }
             } else {
                 $listing->setTask($this->_task);
             }
             return $listing->execute();
         } else {
             Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND Wrong class definition', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
         }
     } else {
         /* case parent didn't registered this task, it was an error */
         if (!parent::execute() && $this->name() == __CLASS__) {
             Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
         }
     }
 }
Пример #14
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');
     }
 }
Пример #15
0
 protected function entry($entry, $manager, $noId = false)
 {
     $en = array();
     if (is_numeric($entry)) {
         $en = $this->cachedEntry($entry, $manager, $noId);
     }
     if (!is_array($en) || !count($en)) {
         if (is_numeric($entry)) {
             $entry = SPFactory::Entry($entry);
         }
         $en['id'] = $entry->get('id');
         $en['nid'] = $entry->get('nid');
         $en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
         $en['url_array'] = array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id'));
         if (strstr(SPRequest::task(), 'search') || $noId || Sobi::Cfg('section.force_category_id', false) && SPRequest::sid() == Sobi::Section()) {
             $en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id')));
         } else {
             $en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
         }
         if (Sobi::Cfg('list.entry_meta', true)) {
             $en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
         }
         if ($manager || Sobi::My('id') && Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own', Sobi::Section())) {
             $en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
         } else {
             if (isset($en['edit_url'])) {
                 unset($en['edit_url']);
             }
         }
         $en['edit_url_array'] = array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id'));
         $en['created_time'] = $entry->get('createdTime');
         $en['updated_time'] = $entry->get('updatedTime');
         $en['valid_since'] = $entry->get('validSince');
         $en['valid_until'] = $entry->get('validUntil');
         $this->fixTimes($en);
         if ($entry->get('state') == 0) {
             $en['state'] = 'unpublished';
         } else {
             if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
                 $en['state'] = 'expired';
             } elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
                 $en['state'] = 'pending';
             } else {
                 $en['state'] = 'published';
             }
         }
         $en['author'] = $entry->get('owner');
         $en['counter'] = $entry->get('counter');
         $en['approved'] = $entry->get('approved');
         //		$en[ 'confirmed' ] = $entry->get( 'confirmed' );
         if (Sobi::Cfg('list.entry_cats', true)) {
             $cats = $entry->get('categories');
             $categories = array();
             if (count($cats)) {
                 $cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'));
             }
             foreach ($cats as $cid => $cat) {
                 $categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name']))));
             }
             $en['categories'] = $categories;
         }
         $fields = $entry->getFields();
         if (count($fields)) {
             //				foreach ( $fields as $field ) {
             //					if ( $field->enabled( 'vcard' ) && $field->get( 'id' ) != Sobi::Cfg( 'entry.name_field' ) ) {
             //						$struct = $field->struct();
             //						$options = null;
             //						if ( isset( $struct[ '_options' ] ) ) {
             //							$options = $struct[ '_options' ];
             //							unset( $struct[ '_options' ] );
             //						}
             //						$f[ $field->get( 'nid' ) ] = array(
             //							'_complex' => 1,
             //							'_data' => array(
             //								'label' => array(
             //									'_complex' => 1,
             //									'_data' => $field->get( 'name' ),
             //									'_attributes' => array( 'lang' => Sobi::Lang( false ), 'show' => $field->get( 'withLabel' ) )
             //								),
             //								'data' => $struct,
             //							),
             //							'_attributes' => array( 'id' => $field->get( 'id' ), 'type' => $field->get( 'type' ), 'suffix' => $field->get( 'suffix' ), 'position' => $field->get( 'position' ), 'css_class' => ( strlen( $field->get( 'cssClass' ) ) ? $field->get( 'cssClass' ) : 'spField' ) )
             //						);
             //						if ( Sobi::Cfg( 'list.field_description', false ) ) {
             //							$f[ $field->get( 'nid' ) ][ '_data' ][ 'description' ] = array( '_complex' => 1, '_xml' => 1, '_data' => $field->get( 'description' ) );
             //						}
             //						if ( $options ) {
             //							$f[ $field->get( 'nid' ) ][ '_data' ][ 'options' ] = $options;
             //						}
             //						if ( isset( $struct[ '_xml_out' ] ) && count( $struct[ '_xml_out' ] ) ) {
             //							foreach ( $struct[ '_xml_out' ] as $k => $v )
             //								$f[ $field->get( 'nid' ) ][ '_data' ][ $k ] = $v;
             //						}
             //					}
             //				}
             $en['fields'] = $this->fieldStruct($fields, 'vcard');
         }
         SPFactory::cache()->addObj($entry, 'entry', $entry->get('id'))->addObj($en, 'entry_struct', $entry->get('id'));
         unset($en['url_array']);
         unset($en['edit_url_array']);
         unset($entry);
     }
     $en['counter'] = $this->getNonStaticData($en['id'], 'counter');
     /*
      * this is te special case:
      * no matter what task we currently have - if someone called this we need the data for the V-Card
      * Soe we have to trigger all these plugins we need and therefore also fake the task
      */
     $task = 'list.custom';
     SPFactory::registry()->set('task', $task);
     Sobi::Trigger('List', ucfirst(__FUNCTION__), array(&$en));
     return $en;
 }
Пример #16
0
 * $HeadURL$
 */
define('SOBI_TESTS', false);
defined('_JEXEC') || exit('Restricted access');
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15'));
define('SOBIPRO', true);
define('SOBI_TASK', 'task');
if (SOBI_CMS == 'joomla15') {
    define('SOBI_DEFLANG', JFactory::getConfig()->getValue('config.language'));
} else {
    define('SOBI_DEFLANG', JComponentHelper::getParams('com_languages')->get('site', 'en-GB'));
}
define('SOBI_ACL', 'front');
define('SOBI_ROOT', JPATH_ROOT);
define('SOBI_MEDIA', implode('/', array(JPATH_ROOT, 'media', 'sobipro')));
define('SOBI_MEDIA_LIVE', JURI::root() . 'media/sobipro');
define('SOBI_PATH', SOBI_ROOT . '/components/com_sobipro');
define('SOBI_LIVE_PATH', 'components/com_sobipro');
require_once SOBI_PATH . '/lib/base/fs/loader.php';
SPLoader::loadController('interface');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
// Try to catch direct file calls. Like /directory/piwik.php
if (preg_match('/\\.php$/', SPRequest::task()) || strlen(SPRequest::task()) > 50) {
    JError::raiseError(403, 'Unauthorized Access');
}
$class = SPLoader::loadController('sobipro');
$sobi = new $class(SPRequest::task());
$sobi->execute();
//SPConfig::debOut( SPRequest::task() );
Пример #17
0
 /**
  */
 public function execute()
 {
     switch ($this->_task) {
         case 'panel':
             $this->getSections();
             /** @var $view SPAdmPanelView */
             $view = SPFactory::View('front', true)->assign($acl, 'acl')->assign($this->_sections, 'sections')->assign($this->getNews(), 'news')->assign(Sobi::GetUserState('sections.order', 'order', 'name.asc'), 'order')->assign(SPFactory::CmsHelper()->myVersion(true), 'version')->assign(Sobi::Cfg('cpanel.show_entries', false), 'show-entries')->assign($this->getState(), 'system-state');
             if (Sobi::Cfg('cpanel.show_entries', false)) {
                 $view->assign($this->getEntries(), 'entries');
             }
             SPLang::load('com_sobipro.about');
             $view->determineTemplate('front', 'cpanel');
             Sobi::Trigger('Panel', 'View', array(&$view));
             $view->display();
             break;
         default:
             /* case plugin didn't registered this task, it was an error */
             if (!parent::execute()) {
                 Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
             }
             break;
     }
 }
Пример #18
0
 /**
  * @return void
  */
 private function frontpage()
 {
     SPLoader::loadController('front', true);
     $this->setController(new SPAdminPanel());
     Sobi::ReturnPoint();
     $this->_ctrl->setTask(SPRequest::task());
 }
Пример #19
0
 /**
  * @see #can
  * @param string $section
  * @param string $subject
  * @param string $action
  * @param string $value
  * @return bool
  */
 public function authorise($section, $subject, $action, $value)
 {
     if ($this->isAdmin()) {
         return true;
     }
     /* translate automatic created request */
     switch ($action) {
         case 'cancel':
             return true;
             break;
         case 'save':
         case 'submit':
             $id = SPRequest::int('sid', SPRequest::int('rid'));
             $action = $id ? 'edit' : 'add';
         case 'enable':
         case 'hide':
         case 'disable':
             $action = 'manage';
             break;
         case 'apply':
             $action = 'edit';
         case 'details':
         case 'view':
             $action = 'access';
     }
     if (in_array($subject, array('acl', 'config', 'extensions'))) {
         $action = 'manage';
         $section = 0;
     }
     if (!$section) {
         $value = 'global';
         if (in_array(SPRequest::task(), $this->_special)) {
             return true;
         }
     }
     /* admin panel or site front */
     $site = SOBI_ACL;
     /* initialise */
     $auth = false;
     /* if not initialised */
     if (!isset($this->_permissions[$section]) || !count($this->_permissions[$section])) {
         $this->getPermissions();
     }
     /* if already requested, return the answer */
     $i = "[{$site}][{$section}][{$action}][{$subject}][{$value}]";
     if (isset($this->_prequest[$i])) {
         return $this->_prequest[$i];
     }
     if (isset($this->_permissions[$section])) {
         if (isset($this->_permissions[$section][$subject])) {
             if (isset($this->_permissions[$section][$subject][$action])) {
                 if (isset($this->_permissions[$section][$subject][$action][$value])) {
                     $auth = $this->_permissions[$section][$subject][$action][$value];
                 } elseif (isset($this->_permissions[$section][$subject][$action]['*'])) {
                     $auth = $this->_permissions[$section][$subject][$action]['*'];
                 }
             } elseif (isset($this->_permissions[$section][$subject]['*'])) {
                 $auth = $this->_permissions[$section][$subject]['*'];
             }
         } elseif (isset($this->_permissions[$section]['*'])) {
             $auth = $this->_permissions[$section]['*'];
         }
     }
     // @@ just for tests
     //		$a = ( $auth ) ? 'GRANTED' : 'DENIED';//var_export( debug_backtrace( false ), true ) ;
     //		SPConfig::debOut("{$action} {$subject} {$value} === {$a} ");
     /* store the answer for future request */
     $this->_prequest[$i] = $auth;
     return $auth;
 }
Пример #20
0
 private function addRepo()
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::WARNING, 0, __LINE__, __FILE__);
         $this->response(Sobi::Url('extensions.browse'), SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), false, SPC::ERROR_MSG);
         exit;
     }
     $connection = SPFactory::Instance('services.remote');
     $repo = trim(preg_replace('/[^a-zA-Z0-9\\.\\-\\_]/', null, SPRequest::string('repository')));
     $ssl = $connection->certificate($repo);
     if (isset($ssl['err'])) {
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         //$response = sprintf( 'The connection could not be validated (error number %s). %s', $ssl[ 'err' ], $ssl[ 'msg' ] );
         $response = SPLang::e('NOT_VALIDATED', $ssl['err'], $ssl['msg']);
         echo json_encode(array('message' => array('type' => SPC::ERROR_MSG, 'text' => $response)));
         exit;
     } else {
         $cert = array();
         $file = SPFactory::Instance('base.fs.file', SPLoader::path('etc.repos.' . str_replace('.', '_', $repo), 'front', false, 'xml'));
         $cert['url'] = 'https://' . $repo;
         $cert['certificate']['serialNumber'] = $ssl['serialNumber'];
         $cert['certificate']['validFrom'] = Sobi::Date($ssl['validFrom_time_t']);
         $cert['certificate']['validTo'] = Sobi::Date($ssl['validTo_time_t']);
         $cert['certificate']['subject'] = $ssl['subject'];
         $cert['certificate']['issuer'] = $ssl['issuer'];
         $cert['certificate']['hash'] = $ssl['hash'];
         $def = SPFactory::Instance('types.array', $cert);
         $file->content($def->toXML($cert, 'repository'));
         $file->save();
         /** @var $view SPExtensionsView */
         $view =& SPFactory::View('extensions', true)->assign($this->_task, 'task')->assign($cert['certificate'], 'certificate')->determineTemplate('extensions', 'certificate');
         ob_start();
         $view->display();
         $response = ob_get_contents();
         $response = str_replace('id="SobiPro"', 'id="SpRepoModal"', $response);
         SPFactory::mainframe()->cleanBuffer()->customHeader();
         echo json_encode(array('message' => array('type' => SPC::INFO_MSG, 'response' => $response)));
         exit;
     }
 }
Пример #21
0
 /**
  * @param string
  * @return SPConfigAdmView
  */
 protected function getView($task)
 {
     SPLoader::loadClass('html.input');
     $sid = Sobi::Reg('current_section');
     /* create menu */
     $class = SPLoader::loadClass('views.adm.menu');
     $menu = new $class($task, $sid);
     /* load the menu definition */
     if ($sid) {
         $cfg = SPLoader::loadIniFile('etc.adm.section_menu');
     } else {
         $cfg = SPLoader::loadIniFile('etc.adm.config_menu');
     }
     Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
     if (count($cfg)) {
         foreach ($cfg as $section => $keys) {
             $menu->addSection($section, $keys);
         }
     }
     Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
     if ($sid) {
         if (Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE && strstr(SPRequest::task(), 'config')) {
             SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage();
         }
         /* create new SigsiuTree */
         $tree = SPLoader::loadClass('mlo.tree');
         $tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'position.asc'));
         /* set link */
         $tree->setHref(Sobi::Url(array('sid' => '{sid}')));
         $tree->setId('menuTree');
         /* set the task to expand the tree */
         $tree->setTask('category.expand');
         $tree->init($sid);
         /* add the tree into the menu */
         $menu->addCustom('AMN.ENT_CAT', $tree->getTree());
         $seClass = SPLoader::loadModel('section');
         $cSec = new $seClass();
         $cSec->init($sid);
     } else {
         $cSec = array('name' => Sobi::Txt('GB.CFG.GLOBAL_CONFIGURATION'));
         $menu->addCustom('GB.CFG.GLOBAL_TEMPLATES', $this->listTemplates());
     }
     $view = SPFactory::View('config', true);
     $view->assign($task, 'task');
     $view->assign($cSec, 'section');
     $view->assign($menu, 'menu');
     $view->addHidden(SPFactory::registry()->get('current_section'), 'sid');
     return $view;
 }
Пример #22
0
 /**
  * Save a rule
  *
  * @param bool $apply
  */
 protected function save($apply)
 {
     Sobi::Trigger('Save', 'Acl', array(&$this));
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $rid = SPRequest::int('rid', 'null');
     $this->validate('acl.edit', array('task' => 'acl.edit', 'rid' => $rid));
     if ($rid) {
         $this->remove($rid);
     }
     $vs = SPRequest::timestamp('set_validSince');
     $vu = SPRequest::timestamp('set_validUntil');
     $vs = $vs ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vs) : null;
     $vu = $vu ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vu) : null;
     $name = SPRequest::string('set_name');
     $nid = SPRequest::cmd('set_nid');
     $note = SPRequest::string('set_note');
     $state = SPRequest::int('set_state', 1);
     $gids = SPRequest::arr('set_groups');
     $sids = SPRequest::arr('set_sections');
     $pf = SPRequest::arr('set_permissions', array());
     $pa = SPRequest::arr('set_adm_permissions', array());
     // if can publish any, then can see any unpublished
     if (in_array(20, $pf)) {
         $pf[] = 14;
     }
     // if can publish own, then can see own unpublished
     if (in_array(21, $pf)) {
         $pf[] = 12;
     }
     if (in_array(19, $pf)) {
         $pf[] = 15;
     }
     $perms = array_merge($pf, $pa);
     /* @var SPdb $db */
     $db = SPFactory::db();
     /* update or insert the rule definition */
     try {
         $db->insertUpdate('spdb_permissions_rules', array('rid' => $rid, 'name' => $name, 'nid' => $nid, 'validSince' => $vs, 'validUntil' => $vu, 'note' => $note, 'state' => $state));
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_CREATE_RULE_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $rid = (int) $rid ? (int) $rid : $db->insertid();
     /* insert the groups ids */
     if (count($gids)) {
         foreach ($gids as $i => $gid) {
             $gids[$i] = array('rid' => $rid, 'gid' => $gid);
         }
         try {
             $db->insertArray('spdb_permissions_groups', $gids);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     try {
         $db->select('*', 'spdb_permissions', array('site' => 'adm', 'value' => 'global'));
         $admPermissions = $db->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_GET_PERMISSIONS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* create permission and section map */
     if (count($sids) && count($perms)) {
         $map = array();
         /* travel the sections */
         foreach ($sids as $sid) {
             foreach ($perms as $pid) {
                 if (in_array($pid, $admPermissions)) {
                     $map[] = array('rid' => $rid, 'sid' => 0, 'pid' => $pid);
                 } else {
                     $map[] = array('rid' => $rid, 'sid' => $sid, 'pid' => $pid);
                 }
             }
         }
         try {
             $db->insertArray('spdb_permissions_map', $map, true);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     SPFactory::cache()->cleanAll();
     /* trigger plugins */
     Sobi::Trigger('AfterSave', 'Acl', array(&$this));
     /* set redirect */
     $this->response(Sobi::Url($apply ? array('task' => 'acl.edit', 'rid' => $rid) : 'acl'), Sobi::Txt('ACL_RULE_SAVED'), !$apply, SPC::SUCCESS_MSG, array('sets' => array('rid' => $rid)));
 }
Пример #23
0
 /**
  * Checks if the field should be displayed or not
  * @param string $view
  * @param bool $new
  * @return bool
  */
 public function enabled($view, $new = false)
 {
     if ($view == 'form') {
         // while editing an entry we have to get the real data
         $this->fullInit(true);
         if ($this->get('isOutputOnly')) {
             return false;
         }
         if (!Sobi::Can('entry.adm_fields.edit')) {
             if ($this->adminField) {
                 return false;
             }
             /*
              * When the user is adding the entry very first time this should not affect because
              * the field is not editable but the user has to be able to add data for the first time
              */
             if (!$this->editable && SPRequest::task() != 'entry.add' && !($new && in_array(SPRequest::task(), array('entry.submit', 'entry.save')))) {
                 //if ( !( $this->editable ) && !( $new && in_array( SPRequest::task(), array( 'entry.add', 'entry.submit', 'entry.save' ) ) ) ) {
                 return false;
             }
             if (!$this->editLimit) {
                 return false;
             }
         }
     } else {
         if ($this->get('isInputOnly')) {
             return false;
         }
     }
     $this->currentView = $view;
     if (!$this->enabled) {
         return false;
     }
     if ($view != 'form' && !($this->showIn == $view || $this->showIn == 'both')) {
         return false;
     }
     /*
      * not every field has the same raw data
      */
     /** Thu, Jun 19, 2014 11:39:04 fix by Anibal Sanchez see #1242 */
     if (isset($this->_fData->publishDown)) {
         if (count($this->_fData) && (!(strtotime($this->_fData->publishUp) < time()) || strtotime($this->_fData->publishDown) > 0 && strtotime($this->_fData->publishDown) <= time())) {
             return false;
         }
     }
     //		if ( isset( $this->_fData->publishDown ) ) {
     //			if ( count( $this->_fData ) && ( !( strtotime( $this->_fData->publishUp ) < time() ) || ( ( ( strtotime( $this->_fData->publishDown ) > 0 ) && strtotime( $this->_fData->publishDown ) > time() ) ) ) ) {
     //				return false;
     //			}
     //		}
     return true;
 }
Пример #24
0
 /**
  */
 public function loadTable()
 {
     parent::loadTable();
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $this->icon = SPLang::clean($this->icon);
     try {
         $db->select(array('position', 'pid'), 'spdb_relations', array('id' => $this->id));
         $r = $db->loadObject();
         Sobi::Trigger($this->name(), ucfirst(__FUNCTION__), array(&$r));
         $this->position = $r->position;
         $this->parent = $r->pid;
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     if (SPRequest::task() != 'category.edit') {
         if ($this->parseDesc == SPC::GLOBAL_SETTING) {
             $this->parseDesc = Sobi::Cfg('category.parse_desc', true);
         }
         if ($this->parseDesc) {
             Sobi::Trigger('Parse', 'Content', array(&$this->description));
         }
     }
 }
Пример #25
0
 /**
  * @param string $action
  * @param string $subject
  * @param mixed $params
  * @return bool
  */
 public function trigger($action, $subject = null, $params = array())
 {
     static $actions = array();
     static $count = 0;
     $action = ucfirst($action) . ucfirst($subject);
     $action = str_replace('SP', null, $action);
     $task = Sobi::Reg('task', SPRequest::task());
     $task = strlen($task) ? $task : '*';
     if (strstr($task, '.')) {
         $t = explode('.', $task);
         $task = $t[0] . '.' . $t[1];
     }
     /**
      * Joomla! -> Unable to load renderer class
      */
     if ($action == 'ParseContent' && SPRequest::cmd('format') == 'raw') {
         return;
     }
     $actions[$count++] = $action;
     // this always
     SPFactory::mainframe()->trigger($action, $params);
     //	    SPConfig::debOut( $action, false, false, true );
     /**
      * An Application should not trigger other applications
      * Apps are running non parallel
      * Exception, if an app will an action to be
      * triggered this action has to begin with App
      */
     /*
      * it's important to write comments in own code ..
      * It may be also helpful to read own comments sometimes
      * How the hell "has to begin with App" == substr( $action, 0, 3 ) != 'App' ) ???
      * ========================================================================================
      * Note for intelligent people: it caused for example that the payment method wasn't delivered to the notification App
      */
     if ($count < 2 || substr($action, 0, 3) == 'App') {
         /* load all plugins having method for this action */
         if (!isset($this->_actions[$task])) {
             $this->load($task);
         }
         /* if there were any plugin for this action, check if these are loaded */
         if (count($this->_actions[$task])) {
             foreach ($this->_actions[$task] as $plugin) {
                 /* in case this plugin wasn't initialised */
                 if (!isset($this->_plugins[$plugin])) {
                     $this->initPlugin($plugin);
                 }
                 /* call the method */
                 if (isset($this->_plugins[$plugin]) && $this->_plugins[$plugin]->provide($action)) {
                     call_user_func_array(array($this->_plugins[$plugin], $action), $params);
                 }
             }
         }
     }
     //	    SPConfig::debOut( $action, true, false, true );
     unset($actions[$count]);
     $count--;
     return true;
 }
Пример #26
0
 protected function alphaMenu(&$data)
 {
     if ($this->key('alphamenu.show', Sobi::Cfg('alphamenu.show'))) {
         $letters = explode(',', $this->key('alphamenu.letters', Sobi::Cfg('alphamenu.letters')));
         $entry = SPFactory::Model('entry');
         $entry->loadFields(Sobi::Section());
         $fs = $entry->getFields('id');
         $defField = true;
         if (count($letters)) {
             foreach ($letters as $i => $letter) {
                 $letters[$i] = trim($letter);
             }
         }
         $field = explode('.', SPRequest::task('get'));
         if (strstr(SPRequest::task('get'), 'field') && isset($field[3])) {
             $field = $field[3];
             $defField = false;
         } else {
             $field = Sobi::Cfg('alphamenu.primary_field', SPFactory::config()->nameField()->get('id'));
             if (isset($fs[$field]) && $fs[$field] instanceof SPObject) {
                 $field = $fs[$field]->get('nid');
             } else {
                 $field = $fs[SPFactory::config()->nameField()->get('id')]->get('nid');
             }
         }
         if ($this->key('alphamenu.verify', Sobi::Cfg('alphamenu.verify'))) {
             $entries = SPFactory::cache()->getVar('alpha_entries_' . $field);
             if (!$entries) {
                 $alphCtrl = SPFactory::Instance('opt.listing.alpha');
                 $entries = array();
                 foreach ($letters as $letter) {
                     $params = array('letter' => $letter);
                     if ($field) {
                         $params['field'] = $field;
                     }
                     $alphCtrl->setParams($params);
                     $entries[$letter] = $alphCtrl->entries($field);
                 }
                 SPFactory::cache()->addVar($entries, 'alpha_entries_' . $field);
             }
             foreach ($letters as $letter) {
                 $le = array('_complex' => 1, '_data' => trim($letter));
                 $urlLetter = SPFactory::Instance('types.string', $letter)->toLower()->trim()->get();
                 if (count($entries[$letter])) {
                     if (!$defField) {
                         $task = 'list.alpha.' . $urlLetter . '.' . $field;
                     } else {
                         $task = 'list.alpha.' . $urlLetter;
                     }
                     $le['_attributes'] = array('url' => Sobi::Url(array('sid' => Sobi::Section(), 'task' => $task)));
                 }
                 $l[] = $le;
             }
         } else {
             foreach ($letters as $i => $letter) {
                 $urlLetter = SPFactory::Instance('types.string', $letter)->toLower()->trim()->get();
                 $l[] = array('_complex' => 1, '_data' => trim($letter), '_attributes' => array('url' => Sobi::Url(array('sid' => Sobi::Section(), 'task' => 'list.alpha.' . $urlLetter))));
             }
         }
         $fields = Sobi::Cfg('alphamenu.extra_fields_array');
         $extraFields = array();
         if (count($fields)) {
             array_unshift($fields, Sobi::Cfg('alphamenu.primary_field'));
             foreach ($fields as $fid) {
                 if (isset($fs[$fid]) && method_exists($fs[$fid], 'get')) {
                     if ($fs[$fid]->get('enabled')) {
                         $extraFields[$fs[$fid]->get('nid')] = $fs[$fid]->get('name');
                     }
                 }
             }
             if (count($extraFields) < 2) {
                 $extraFields = array();
             }
             $extraFields = array('_complex' => 1, '_data' => $extraFields, '_attributes' => array('current' => $field));
         }
         $data['alphaMenu'] = array('_complex' => 1, '_data' => array('letters' => $l, 'fields' => $extraFields));
     }
 }
Пример #27
0
 private function getLink($button)
 {
     $link = '#';
     if (isset($button['type'])) {
         switch ($button['type']) {
             case 'help':
                 $link = 'https://www.sigsiu.net/help_screen/' . Sobi::Reg('help_task', SPRequest::task());
                 break;
             case 'url':
                 if (isset($button['sid']) && $button['sid'] == 'true') {
                     $link = Sobi::Url(array('task' => $button['task'], 'sid' => SPRequest::sid('request', SPRequest::int('pid'), true)));
                 } else {
                     $link = Sobi::Url($button['task'] ? $button['task'] : $button['url']);
                 }
                 break;
         }
     }
     return $link;
 }
Пример #28
0
 private function section($section, $tab)
 {
     $v = null;
     if (isset($this->_custom[$tab]['before']) && is_array($this->_custom[$tab]['before'])) {
         foreach ($this->_custom[$tab]['before'] as $html) {
             $v .= "\n\t\t\t{$html}";
         }
     }
     if (count($section)) {
         $v .= "\n\t\t\t<ul>";
         foreach ($section as $pos => $label) {
             if (!SPFactory::user()->can($pos)) {
                 continue;
             }
             if (strlen($label) < 3) {
                 $label = str_replace('.', '_', $pos);
             }
             $label = Sobi::Txt($label);
             if ($this->_sid) {
                 $url = Sobi::Url(array('task' => $pos, 'pid' => $this->_sid));
             } else {
                 $url = Sobi::Url(array('task' => $pos));
             }
             if (SPRequest::task() == $pos || $this->_task == $pos) {
                 $v .= "\n\t\t\t\t<li><a href=\"{$url}\" class=\"SPMenuActive\">{$label}</a></li>";
             } else {
                 $v .= "\n\t\t\t\t<li><a href=\"{$url}\">{$label}</a></li>";
             }
         }
         $v .= "\n\t\t\t</ul>";
     }
     if (isset($this->_custom[$tab]['after']) && is_array($this->_custom[$tab]['after'])) {
         foreach ($this->_custom[$tab]['after'] as $html) {
             $v .= "\n\t\t\t{$html}";
         }
     }
     return $v;
 }
Пример #29
0
 /**
  * (non-PHPdoc)
  * @see Site/lib/models/SPDBObject#save()
  */
 public function save($request = 'post')
 {
     $this->loadFields(Sobi::Section(), true);
     // Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave"
     Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id));
     /* save the base object data */
     /* @var SPdb $db */
     $db = SPFactory::db();
     $db->transaction();
     if (!$this->nid || SPRequest::task() == 'entry.clone') {
         $this->nid = SPRequest::string($this->nameField, null, false, $request);
         $this->nid = $this->createAlias();
         $this->name = $this->nid;
     }
     if (Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) {
         SPRequest::set('entry_createdTime', 0, $request);
         SPRequest::set('entry_validSince', 0, $request);
         SPRequest::set('entry_validUntil', 0, $request);
         $this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600);
     }
     $preState = Sobi::Reg('object_previous_state');
     parent::save($request);
     $nameField = $this->nameField();
     /* get the fields for this section */
     foreach ($this->fields as $field) {
         /* @var $field SPField */
         try {
             if ($field->enabled('form', $preState['new'])) {
                 $field->saveData($this, $request);
             } else {
                 $field->finaliseSave($this, $request);
             }
             if ($field->get('id') == $nameField) {
                 /* get the entry name */
                 $this->name = $field->getRaw();
                 /* save the nid (name id) of the field where the entry name is saved */
                 $this->nameField = $field->get('nid');
             }
         } catch (SPException $x) {
             if (SPRequest::task() != 'entry.clone') {
                 $db->rollback();
                 throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()));
             } else {
                 Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
         }
     }
     $values = array();
     /* get categories */
     $cats = Sobi::Reg('request_categories');
     if (!count($cats)) {
         $cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request);
     }
     /* by default it should be comma separated string */
     if (!count($cats)) {
         $cats = SPRequest::string('entry_parent', null, $request);
         if (strlen($cats) && strpos($cats, ',')) {
             $cats = explode(',', $cats);
             foreach ($cats as $i => $cat) {
                 $c = (int) trim($cat);
                 if ($c) {
                     $cats[$i] = $c;
                 } else {
                     unset($cats[$i]);
                 }
             }
         } elseif (strlen($cats)) {
             $cats = array((int) $cats);
         }
     }
     if (is_array($cats) && count($cats)) {
         foreach ($cats as $i => $v) {
             if (!$v) {
                 unset($cats[$i]);
             }
         }
     }
     if (is_array($cats) && count($cats)) {
         /* get the ordering in these categories */
         try {
             $db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid');
             $cPos = $db->loadAssocList('pid');
             $currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid');
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
         /* set the right position */
         foreach ($cats as $i => $cat) {
             $copy = 0;
             if (!$this->approved) {
                 $copy = isset($this->categories[$cats[$i]]) ? 0 : 1;
             } else {
                 $db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry'));
             }
             if (isset($currPos[$cat])) {
                 $pos = $currPos[$cat]['position'];
             } else {
                 $pos = isset($cPos[$cat]) ? $cPos[$cat]['MAX(position)'] : 0;
                 $pos++;
             }
             $values[] = array('id' => $this->id, 'pid' => $cats[$i], 'oType' => 'entry', 'position' => $pos, 'validSince' => $this->validSince, 'validUntil' => $this->validUntil, 'copy' => $copy);
         }
         try {
             $db->insertArray('spdb_relations', $values, true);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     } elseif (!count($this->categories)) {
         throw new SPException(SPLang::e('MISSING_CAT'));
     }
     /* trigger possible state changes */
     if ($preState['approved'] != $this->approved) {
         if ($this->approved) {
             $this->approveFields(true);
             // it's being done by the method above - removing
             //Sobi::Trigger( $this->name(), 'AfterApprove', array( $this->id, $this->approved ) );
         }
     }
     if ($preState['state'] != $this->state) {
         Sobi::Trigger($this->name(), 'AfterChangeState', array($this->id, $this->state));
     }
     SPFactory::cache()->purgeSectionVars();
     SPFactory::cache()->deleteObj('entry', $this->id);
     if (count($cats)) {
         foreach ($cats as $cat) {
             SPFactory::cache()->deleteObj('category', $cat);
         }
     }
     Sobi::Trigger($this->name(), 'After' . ucfirst($preState['new'] ? __FUNCTION__ : 'Update'), array(&$this));
 }
Пример #30
0
 protected function save($apply, $clone = false)
 {
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $sets = array();
     if (!$clone) {
         $sid = SPRequest::sid() ? SPRequest::sid() : SPRequest::int('entry_id');
     } else {
         $sid = 0;
     }
     $apply = (int) $apply;
     if (!$this->_model) {
         $this->setModel(SPLoader::loadModel($this->_type));
     }
     $this->_model->init($sid);
     $tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
     $this->tplCfg($tplPackage);
     $customClass = null;
     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, 'BeforeStoreEntry')) {
             $customClass::BeforeStoreEntry($this->_model, $_POST);
         }
     }
     $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);
     $this->authorise($this->_model->get('id') ? 'edit' : 'add');
     try {
         $this->_model->validate('post');
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $data = $x->getData();
         $this->response($back, $x->getMessage(), false, 'error', array('required' => $data['field']));
     }
     try {
         $this->_model->save();
     } catch (SPException $x) {
         $back = Sobi::GetUserState('back_url', Sobi::Url(array('task' => 'entry.add', 'sid' => Sobi::Section())));
         $this->response($back, $x->getMessage(), false, 'error');
     }
     $sid = $this->_model->get('id');
     $sets['sid'] = $sid;
     $sets['entry.nid'] = $this->_model->get('nid');
     $sets['entry.id'] = $sid;
     if ($customClass && method_exists($customClass, 'AfterStoreEntry')) {
         $customClass::AfterStoreEntry($this->_model);
     }
     if (SPRequest::string('history-note') || $this->_task == 'saveWithRevision' || Sobi::Cfg('entry.versioningAdminBehaviour', 1)) {
         $this->logChanges('save', SPRequest::string('history-note'));
     }
     if ($apply || $clone) {
         if ($clone) {
             $msg = Sobi::Txt('MSG.OBJ_CLONED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg);
         } else {
             $msg = Sobi::Txt('MSG.OBJ_SAVED', array('type' => Sobi::Txt($this->_model->get('oType'))));
             $this->response(Sobi::Url(array('task' => $this->_type . '.edit', 'sid' => $sid)), $msg, false, '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->_model->get('oType')))));
     }
 }