Exemplo n.º 1
0
 /**
  * @return SPMessage
  */
 private function __construct()
 {
     $this->messages = Sobi::GetUserData('messages-queue', $this->messages);
     $registry = SPFactory::registry()->loadDBSection('messages')->get('messages.queue.params');
     if ($registry) {
         $this->store = SPConfig::unserialize($registry);
     }
     $reports = SPFactory::registry()->loadDBSection('reports')->get('reports.queue.params');
     if ($reports) {
         $this->reports = SPConfig::unserialize($reports);
     }
 }
Exemplo n.º 2
0
 private function prepareStoredData(&$settings)
 {
     $store = Sobi::GetUserData('requirements', array());
     if (Sobi::Lang() != 'en-GB' && file_exists(JPATH_ADMINISTRATOR . self::langFile)) {
         $file = parse_ini_file(JPATH_ADMINISTRATOR . self::langFile);
     }
     if (count($store)) {
         foreach ($store as $key => $data) {
             if (Sobi::Lang() != 'en-GB') {
                 $translate = $file['SP.' . $data['message']['org']['label']];
                 if (count($data['message']['org']['params'])) {
                     foreach ($data['message']['org']['params'] as $param => $value) {
                         $translate = str_replace("var:[{$param}]", $value, $translate);
                     }
                 }
                 $settings[$key] = array('key' => $key, 'response' => array('en-GB' => $translate, Sobi::Lang() => $data['message']['current']), 'status' => $data['value']);
             } else {
                 $settings[$key] = array('key' => $key, 'response' => array('en-GB' => $data['message']['current']), 'status' => $data['value']);
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @param $params
  * @param bool $count
  * @return array
  */
 protected function entries($params, $count = false)
 {
     if ($params->get('fieldOrder')) {
         $eOrder = $params->get('fieldOrder');
     } else {
         $eOrder = $params->get('spOrder');
     }
     $entriesRecursive = true;
     $conditions = array();
     $db = SPFactory::db();
     $limits = $params->get('spLimit');
     if ($limits) {
         $limits = explode('::', $limits);
         $fid = $limits[0];
         $value = $limits[1] == 'group' ? $limits[2] : $limits[1];
         $condition = array('fid' => $fid, 'optValue' => $value);
         if ($limits[1] == 'group') {
             $condition['optValue'] = $db->select('optValue', 'spdb_field_option', array('optParent' => $value, 'fid' => $fid))->loadResultArray();
         }
         $conditions['spo.id'] = $db->select('sid', 'spdb_field_option_selected', $condition)->loadResultArray();
         if (!count($conditions['spo.id'])) {
             return array();
         }
     }
     $eDir = $params->get('spOrderDir');
     $oPrefix = null;
     /* get the site to display */
     if ($params->get('engine') != 'static') {
         $site = SPRequest::int('site', 1);
     } else {
         $site = 1;
     }
     $eLimit = $params->get('entriesLimit');
     $eLimStart = ($site - 1) * $eLimit;
     /* get the ordering and the direction */
     if (strstr($eOrder, '.')) {
         $eOrder = explode('.', $eOrder);
         $eDir = $eOrder[1];
         $eOrder = $eOrder[0];
     }
     $sid = $params->get('sid');
     $section = $params->get('section');
     $this->setModel($sid == $section ? 'section' : 'category');
     $this->_model->init($sid);
     $catId = SPRequest::int('pid');
     $catId = $catId ? $catId : SPRequest::sid();
     if ($params->get('autoListing', false) && $catId && $catId != Sobi::Section()) {
         $entries = Sobi::GetUserData('currently-displayed-entries', array());
         if (!count($entries) && $catId) {
             $entries = SPFactory::Category($catId)->getChilds('entry', true, 1);
             $entries = array_unique($entries);
         }
         if (count($entries)) {
             $conditions['spo.id'] = $entries;
         }
     } else {
         if ($entriesRecursive) {
             $pids = $this->_model->getChilds('category', true);
             // getChilds doesn't includes the category id itself
             $pids[$this->_model->get('id')] = $this->_model->get('id');
             if (is_array($pids)) {
                 $pids = array_keys($pids);
             }
             $conditions['sprl.pid'] = $pids;
         } else {
             $conditions['sprl.pid'] = $sid;
         }
         if ($sid == -1) {
             unset($conditions['sprl.pid']);
         }
     }
     if (count($conditions)) {
         /* sort by field */
         if (is_numeric($eOrder)) {
             static $fields = array();
             $specificMethod = false;
             $field = isset($fields[$sid]) ? $fields[$sid] : null;
             if (!$field) {
                 try {
                     $fType = $db->select('fieldType', 'spdb_field', array('fid' => $eOrder))->loadResult();
                 } catch (SPException $x) {
                     Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
                 }
                 if ($fType) {
                     $field = SPLoader::loadClass('opt.fields.' . $fType);
                 }
                 $fields[$sid] = $field;
             }
             if ($field && method_exists($field, 'sortBy')) {
                 $table = null;
                 $oPrefix = null;
                 $specificMethod = call_user_func_array(array($field, 'sortBy'), array(&$table, &$conditions, &$oPrefix, &$eOrder, &$eDir));
             }
             if (!$specificMethod) {
                 $table = $db->join(array(array('table' => 'spdb_field', 'as' => 'fdef', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('fdata.sid', 'spo.id')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('fdata.sid', 'sprl.id'))));
                 $oPrefix = 'spo.';
                 $conditions['spo.oType'] = 'entry';
                 $conditions['fdef.fid'] = $eOrder;
                 $eOrder = 'baseData.' . $eDir;
             }
         } else {
             $table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
             $conditions['spo.oType'] = 'entry';
             if ($eOrder == 'validUntil') {
                 $eOrder = 'spo.validUntil';
             }
             $eOrder = $eOrder . '.' . $eDir;
             $oPrefix = 'spo.';
         }
         /* check user permissions for the visibility */
         if (Sobi::My('id')) {
             $this->userPermissionsQuery($conditions, $oPrefix);
         } else {
             $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
         }
         $conditions['sprl.copy'] = '0';
         try {
             if (!$count) {
                 $results = $db->select($oPrefix . 'id', $table, $conditions, $eOrder, $eLimit, $eLimStart, true)->loadResultArray();
             } else {
                 $results = $db->select("COUNT( DISTINCT {$oPrefix}id )", $table, $conditions, $eOrder)->loadResult();
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         if ($count) {
             return $results;
         }
         $entries = array();
         if (count($results)) {
             foreach ($results as $i => $sid) {
                 $entries[$i] = $sid;
             }
         }
         return $entries;
     } else {
         return array();
     }
 }