/** * Get an appropriate editor profile * @access public * @return $profile Object */ public function getProfile($plugin = null) { if (!isset(self::$profile)) { $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $user = JFactory::getUser(); $option = $this->getComponentOption(); $query = $db->getQuery(true); if (is_object($query)) { $query->select('*')->from('#__wf_profiles')->where('published = 1')->order('ordering ASC'); } else { $query = 'SELECT * FROM #__wf_profiles' . ' WHERE published = 1' . ' ORDER BY ordering ASC'; } $db->setQuery($query); $profiles = $db->loadObjectList(); if ($option == 'com_jce') { $component_id = JRequest::getInt('component_id'); if ($component_id) { $component = WFExtensionHelper::getComponent($component_id); $option = isset($component->element) ? $component->element : $component->option; } } // get the Joomla! area (admin or site) $area = $mainframe->isAdmin() ? 2 : 1; if (!class_exists('Wf_Mobile_Detect')) { // load mobile detect class require_once dirname(__FILE__) . '/mobile.php'; } $mobile = new Wf_Mobile_Detect(); // set device values if ($mobile->isMobile()) { $device = 'phone'; } else { if ($mobile->isTablet()) { $device = 'tablet'; } else { $device = 'desktop'; } } // Joomla! 1.6+ if (method_exists('JUser', 'getAuthorisedGroups')) { $keys = $user->getAuthorisedGroups(); } else { $keys = array($user->gid); } foreach ($profiles as $item) { // at least one user group or user must be set if (empty($item->types) && empty($item->users)) { continue; } // check user groups - a value should always be set $groups = array_intersect($keys, explode(',', $item->types)); // user not in the current group... if (empty($groups)) { // no additional users set or no user match if (empty($item->users) || in_array($user->id, explode(',', $item->users)) === false) { continue; } } // check component if ($option !== 'com_jce' && $item->components && in_array($option, explode(',', $item->components)) === false) { continue; } // set device default as 'desktop,tablet,mobile' if (!isset($item->device) || empty($item->device)) { $item->device = 'desktop,tablet,phone'; } // check device if (in_array($device, explode(',', $item->device)) === false) { continue; } // check area if (!empty($item->area) && (int) $item->area != $area) { continue; } // check for individual plugin - use Editor Model as it adds "core" plugins to profile set if ($plugin) { wfimport('admin.models.editor'); $model = new WFModelEditor(); $plugins = (array) $model->getPlugins(); if (in_array($plugin, $plugins) === false) { continue; } } // decrypt params if (!empty($item->params)) { wfimport('admin.helpers.encrypt'); $item->params = WFEncryptHelper::decrypt($item->params); } // assign item to profile self::$profile = $item; // return return self::$profile; } return null; } return self::$profile; }
public function export() { wfimport('admin.helpers.encrypt'); $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $tmp = $mainframe->getCfg('tmp_path'); $buffer = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $buffer .= "\n" . '<export type="profiles">'; $buffer .= "\n\t" . '<profiles>'; $cid = JRequest::getVar('cid', array(0), 'post', 'array'); JArrayHelper::toInteger($cid, array(0)); if (count($cid) < 1) { JError::raiseError(500, WFText::_('WF_PROFILES_SELECT_ERROR')); } $cids = implode(',', $cid); $query = $db->getQuery(true); // check for name if (is_object($query)) { $query->select('*')->from('#__wf_profiles')->where('id IN (' . $cids . ')'); } else { $query = 'SELECT * FROM #__wf_profiles WHERE id IN (' . $cids . ')'; } $db->setQuery($query); $profiles = $db->loadObjectList(); foreach ($profiles as $profile) { // remove some stuff unset($profile->id); unset($profile->checked_out); unset($profile->checked_out_time); // set published to 0 $profile->published = 0; $buffer .= "\n\t\t"; $buffer .= '<profile>'; foreach ($profile as $key => $value) { if ($key == 'params') { $buffer .= "\n\t\t\t" . '<' . $key . '>'; if ($value) { // decrypt if necessary $value = WFEncryptHelper::decrypt($value); // check is valid json $valid = json_decode($value, false); // json is valid if (is_null($valid) === false) { // create array $params = explode("\n", $value); foreach ($params as $param) { if ($param !== '') { $buffer .= "\n\t\t\t\t" . '<param>' . $param . '</param>'; } } $buffer .= "\n\t\t\t\t"; } } $buffer .= '</' . $key . '>'; } else { $buffer .= "\n\t\t\t" . '<' . $key . '>' . $this->encodeData($value) . '</' . $key . '>'; } } $buffer .= "\n\t\t</profile>"; } $buffer .= "\n\t</profiles>"; $buffer .= "\n</export>"; // set_time_limit doesn't work in safe mode if (!ini_get('safe_mode')) { @set_time_limit(0); } $name = 'jce_profile_' . date('Y_m_d') . '.xml'; header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Expires: 0"); header("Content-Transfer-Encoding: binary"); header("Content-Type: text/xml"); header('Content-Disposition: attachment;' . ' filename="' . $name . '";'); echo $buffer; exit; }
/** * Overridden JTable::store to encrypt parameters * * @param boolean $updateNulls True to update fields even if they are null. * * @return boolean True on success. * * @since 2.4 */ public function store($updateNulls = false) { if ($this->id && $this->params) { $component = WFExtensionHelper::getComponent(); // get params definitions $params = new WFParameter($component->params, '', 'preferences'); if ($params->get('secureparams', 0)) { $this->params = WFEncryptHelper::encrypt($this->params); } } return parent::store($updateNulls); }
/** * Get an appropriate editor profile * @access public * @return $profile Object */ public function getProfile($plugin = "") { $options = $this->getProfileVars($plugin); $signature = serialize($options); if (!isset(self::$profile[$signature])) { $db = JFactory::getDBO(); $user = JFactory::getUser(); $query = $db->getQuery(true); if (is_object($query)) { $query->select('*')->from('#__wf_profiles')->where('published = 1')->order('ordering ASC'); } else { $query = 'SELECT * FROM #__wf_profiles' . ' WHERE published = 1' . ' ORDER BY ordering ASC'; } $db->setQuery($query); $profiles = $db->loadObjectList(); foreach ($profiles as $item) { // at least one user group or user must be set if (empty($item->types) && empty($item->users)) { continue; } // check user groups - a value should always be set $groups = array_intersect($options["groups"], explode(',', $item->types)); // user not in the current group... if (empty($groups)) { // no additional users set or no user match if (empty($item->users) || in_array($user->id, explode(',', $item->users)) === false) { continue; } } // check component if ($options["option"] !== 'com_jce' && $item->components && in_array($options["option"], explode(',', $item->components)) === false) { continue; } // set device default as 'desktop,tablet,mobile' if (!isset($item->device) || empty($item->device)) { $item->device = 'desktop,tablet,phone'; } // check device if (in_array($options["device"], explode(',', $item->device)) === false) { continue; } // check area if (!empty($item->area) && (int) $item->area != $options["area"]) { continue; } if ($options["plugin"] && in_array($options["plugin"], explode(",", $item->plugins)) === false) { continue; } // decrypt params if (!empty($item->params)) { wfimport('admin.helpers.encrypt'); $item->params = WFEncryptHelper::decrypt($item->params); } // assign item to profile self::$profile[$signature] = $item; // return return self::$profile[$signature]; } return null; } return self::$profile[$signature]; }