示例#1
0
文件: front.php 项目: pelloq1/SobiPro
 protected function addEntries($ids)
 {
     static $sections = array();
     $entries = array();
     if (count($ids)) {
         foreach ($ids as $sid) {
             $entry = SPFactory::Entry($sid);
             if (!isset($sections[$entry->get('section')])) {
                 $sections[$entry->get('section')] = SPFactory::Section($entry->get('section'));
             }
             $entry->setProperty('section', $sections[$entry->get('section')]);
             $entries[] = $entry;
         }
     }
     return $entries;
 }
示例#2
0
 /**
  */
 protected function approval($approve)
 {
     $sids = SPRequest::arr('e_sid', array());
     if (!count($sids)) {
         if ($this->_model->get('id')) {
             $sids = array($this->_model->get('id'));
         } else {
             $sids = array();
         }
     }
     if (!count($sids)) {
         $this->response(Sobi::Back(), Sobi::Txt('CHANGE_NO_ID'), false, SPC::ERROR_MSG);
     } else {
         foreach ($sids as $sid) {
             try {
                 SPFactory::db()->update('spdb_object', array('approved' => $approve ? 1 : 0), array('id' => $sid, 'oType' => 'entry'));
                 $entry = SPFactory::Entry($sid);
                 if ($approve) {
                     $entry->approveFields($approve);
                 } else {
                     SPFactory::cache()->deleteObj('entry', $sid);
                 }
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
         }
         $this->logChanges('approve');
         SPFactory::cache()->purgeSectionVars();
         $this->response(Sobi::Back(), Sobi::Txt($approve ? 'EMN.APPROVED' : 'EMN.UNAPPROVED', $entry->get('name')), false, SPC::SUCCESS_MSG);
     }
 }
示例#3
0
 public function entryLabel($sid)
 {
     return Sobi::Txt('MENU_LINK_TO_SELECTED_ENTRY', SPFactory::Entry($sid)->get('name'));
 }
示例#4
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;
 }
 /**
  * Called whenever the administrator asks to refresh integration status.
  *
  * @param $user_id int The Joomla! user ID to refresh information for.
  */
 public function onAKUserRefresh($user_id)
 {
     static $hasZoo = null;
     static $hasK2 = null;
     static $hasSobipro = null;
     if (is_null($hasZoo) || is_null($hasK2) || is_null($hasSobipro)) {
         JLoader::import('joomla.filesystem.folder');
         $hasZoo = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_zoo');
         $hasK2 = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_k2');
         $hasSobipro = JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_sobipro');
         if (@(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php')) {
             if (!method_exists('Sobi', 'Initialise')) {
                 // We require SOBIPro 1.1 or later
                 $hasSobipro = false;
             }
         } else {
             $hasSobipro = false;
         }
     }
     // Get all of the user's subscriptions
     $subscriptions = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->user_id($user_id)->getList();
     // Make sure there are subscriptions set for the user
     if (!count($subscriptions)) {
         return;
     }
     // Get active/inactive subscription level IDs
     $active = array();
     foreach ($subscriptions as $subscription) {
         if (!$subscription->enabled) {
             continue;
         }
         if (!in_array($subscription->akeebasubs_level_id, $active)) {
             $active[] = $subscription->akeebasubs_level_id;
         }
     }
     $inactive = array();
     foreach ($subscriptions as $subscription) {
         if ($subscription->enabled) {
             continue;
         }
         if (!in_array($subscription->akeebasubs_level_id, $active)) {
             $inactive[] = $subscription->akeebasubs_level_id;
         }
     }
     $db = JFactory::getDbo();
     // Unpublish articles for inactive subscriptions
     if (!empty($inactive)) {
         foreach ($inactive as $level_id) {
             if (array_key_exists($level_id, $this->unpublishCore)) {
                 if ($this->unpublishCore[$level_id]) {
                     // Unpublish core articles
                     $query = $db->getQuery(true)->update($db->qn('#__content'))->set($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' <= ' . $db->q('1'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->unpublishK2) && $hasK2) {
                 if ($this->unpublishK2[$level_id]) {
                     // Unpublish K2 items
                     $query = $db->getQuery(true)->update($db->qn('#__k2_items'))->set($db->qn('published') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->unpublishSobipro) && $hasSobipro) {
                 if ($this->unpublishSobipro[$level_id]) {
                     if (!class_exists('Sobi')) {
                         @(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php');
                     }
                     if (class_exists('Sobi')) {
                         Sobi::Initialise();
                         // Unpublish SOBI Pro items
                         $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__sobipro_object'))->where($db->qn('oType') . ' = ' . $db->q('entry'))->where($db->qn('owner') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q(1));
                         $db->setQuery($query);
                         $ids = $db->loadColumn();
                         if (count($ids)) {
                             foreach ($ids as $id) {
                                 SPFactory::Entry($id)->unpublish();
                             }
                         }
                     }
                 }
             }
             if (array_key_exists($level_id, $this->unpublishZOO) && array_key_exists($level_id, $this->removeGroups) && $hasZoo) {
                 if ($this->unpublishZOO[$level_id]) {
                     $apps = $this->removeGroups[$level_id];
                     if (!empty($apps)) {
                         $temp = array();
                         foreach ($apps as $app) {
                             $temp[] = $db->q($app);
                         }
                         // Unpublish ZOO items
                         $query = $db->getQuery(true)->update($db->qn('#__zoo_item'))->set($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' <= ' . $db->q('1'))->where($db->qn('application_id') . ' IN (' . implode(',', $temp) . ')');
                         $db->setQuery($query);
                         $db->execute();
                     }
                 }
             }
         }
     }
     // Publish articles for active subscriptions
     if (!empty($active)) {
         foreach ($active as $level_id) {
             if (array_key_exists($level_id, $this->publishCore)) {
                 if ($this->publishCore[$level_id]) {
                     // Publish core Joomla! articles
                     $query = $db->getQuery(true)->update($db->qn('#__content'))->set($db->qn('state') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q('0'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->publishK2) && $hasK2) {
                 if ($this->publishK2[$level_id]) {
                     // Publish K2 content
                     $query = $db->getQuery(true)->update($db->qn('#__k2_items'))->set($db->qn('published') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('published') . ' = ' . $db->q('0'));
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
             if (array_key_exists($level_id, $this->publishSobipro) && $hasSobipro) {
                 if ($this->publishSobipro[$level_id]) {
                     if (!class_exists('Sobi')) {
                         @(include_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php');
                     }
                     if (class_exists('Sobi')) {
                         Sobi::Initialise();
                         // Publish SOBI Pro items
                         $query = $db->getQuery(true)->select($db->qn('id'))->from($db->qn('#__sobipro_object'))->where($db->qn('oType') . ' = ' . $db->q('entry'))->where($db->qn('owner') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q(0));
                         $db->setQuery($query);
                         $ids = $db->loadColumn();
                         if (count($ids)) {
                             foreach ($ids as $id) {
                                 SPFactory::Entry($id)->publish();
                             }
                         }
                     }
                 }
             }
             if (array_key_exists($level_id, $this->publishZOO) && array_key_exists($level_id, $this->addGroups) && $hasZoo) {
                 if ($this->publishZOO[$level_id]) {
                     $apps = $this->addGroups[$level_id];
                     if (!empty($apps)) {
                         $temp = array();
                         foreach ($apps as $app) {
                             $temp[] = $db->q($app);
                         }
                         // Publish ZOO items
                         $query = $db->getQuery(true)->update($db->qn('#__zoo_item'))->set($db->qn('state') . ' = ' . $db->q('1'))->where($db->qn('created_by') . ' = ' . $db->q($user_id))->where($db->qn('state') . ' = ' . $db->q('0'))->where($db->qn('application_id') . ' IN (' . implode(',', $temp) . ')');
                         $db->setQuery($query);
                         $db->execute();
                     }
                 }
             }
         }
     }
 }
示例#6
0
 /**
  * Shows the field in the edit entry or add entry form
  * @param bool $return return or display directly
  * @return string
  */
 public function field($return = false)
 {
     if (!$this->enabled) {
         return false;
     }
     if (!$this->sid) {
         $this->sid = SPRequest::sid();
     }
     $this->_selectedCats = $this->cleanData();
     $this->loadCategories();
     if (!$this->_selectedCats && $this->sid) {
         $entry = SPFactory::Entry($this->sid);
         $this->_selectedCats = array_keys($entry->get('categories'));
     } else {
         $this->cleanData();
     }
     if (!$this->_selectedCats || !count($this->_selectedCats)) {
         $sid = SPRequest::sid();
         if ($sid != Sobi::Section() && $sid != $this->sid) {
             $this->_selectedCats = array(SPRequest::sid());
         }
     }
     $this->showLabel = true;
     if (!(int) $this->catsMaxLimit) {
         $this->catsMaxLimit = 1;
     }
     if (count($this->_selectedCats) > $this->catsMaxLimit) {
         $this->_selectedCats = array_slice($this->_selectedCats, 0, $this->catsMaxLimit);
     }
     switch ($this->method) {
         case 'fixed':
             $this->showLabel = false;
             $this->isOutputOnly = true;
             return null;
             break;
         case 'tree':
             $field = $this->tree();
             break;
         case 'select':
             $field = $this->select();
             break;
         case 'mselect':
             $field = $this->mSelect();
             break;
     }
     if (!$return) {
         echo $field;
     } else {
         return $field;
     }
 }
示例#7
0
 protected function determineObjectType($sid)
 {
     if ($this->task) {
         $this->oTypeName = Sobi::Txt('TASK_' . strtoupper($this->task));
         $this->oType = $this->task;
     } elseif ($sid) {
         $this->oType = SPFactory::db()->select('oType', 'spdb_object', array('id' => $sid))->loadResult();
         $this->oTypeName = Sobi::Txt('OTYPE_' . strtoupper($this->oType));
     }
     switch ($this->oType) {
         case 'entry':
             $this->oName = SPFactory::Entry($sid)->get('name');
             break;
         case 'section':
             $this->oName = SPFactory::Section($sid)->get('name');
             break;
         case 'category':
             $this->oName = SPFactory::Category($sid)->get('name');
             break;
         default:
             $this->oName = null;
             break;
     }
 }
示例#8
0
 /**
  * @return bool
  */
 private function routeObj()
 {
     try {
         $ctrl = SPFactory::Controller($this->_model->oType);
         if ($ctrl instanceof SPController) {
             $this->setController($ctrl);
             if ($this->_model->id == SPRequest::sid()) {
                 // just to use the pre-fetched entry
                 if ($this->_model->oType == 'entry') {
                     $e = SPFactory::Entry($this->_model->id);
                     // object has been stored anyway in the SPFactory::object method
                     // and also already initialized
                     // therefore it will be now rewritten and because the init flag is set to true
                     // the name is getting lost
                     // $e->extend( $this->_model );
                     $this->_ctrl->setModel($e);
                 } else {
                     $this->_ctrl->setModel(SPLoader::loadModel($this->_model->oType));
                     $this->_ctrl->extend($this->_model);
                 }
             } else {
                 $this->_ctrl->extend(SPFactory::object(SPRequest::sid()));
             }
             $this->_ctrl->setTask($this->_task);
         }
     } catch (SPException $x) {
         if (defined('SOBI_TESTS')) {
             Sobi::Error('CoreCtrl', SPLang::e('Cannot set controller. %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         } else {
             SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true);
         }
     }
     return true;
 }