private static function installProfile($name)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     if (is_object($query)) {
         $query->select('COUNT(id)')->from('#__wf_profiles')->where('name = ' . $db->Quote($name));
     } else {
         $query = 'SELECT COUNT(id) FROM #__wf_profiles WHERE name = ' . $db->Quote($name);
     }
     $db->setQuery($query);
     $id = $db->loadResult();
     if (!$id) {
         // Blogger
         $file = JPATH_ADMINISTRATOR . '/components/com_jce/models/profiles.xml';
         $xml = self::loadXMLFile($file);
         if ($xml) {
             foreach ($xml->profiles->children() as $profile) {
                 if ((string) $profile->attributes()->name == $name) {
                     $row = JTable::getInstance('profiles', 'WFTable');
                     require_once JPATH_ADMINISTRATOR . '/components/com_jce/models/profiles.php';
                     $groups = WFModelProfiles::getUserGroups((int) $profile->children('area'));
                     foreach ($profile->children() as $item) {
                         switch ((string) $item->getName()) {
                             case 'types':
                                 $row->types = implode(',', $groups);
                                 break;
                             case 'area':
                                 $row->area = (int) $item;
                                 break;
                             case 'rows':
                                 $row->rows = (string) $item;
                                 break;
                             case 'plugins':
                                 $row->plugins = (string) $item;
                                 break;
                             default:
                                 $key = $item->getName();
                                 $row->{$key} = (string) $item;
                                 break;
                         }
                     }
                     $row->store();
                 }
             }
         }
     }
 }
Beispiel #2
0
 public function repair()
 {
     $app = JFactory::getApplication();
     $type = JRequest::getWord('type', 'tables');
     switch ($type) {
         case 'tables':
             wfimport('admin.models.profiles');
             $profiles = new WFModelProfiles();
             $profiles->installProfiles();
             $this->setRedirect(JRoute::_('index.php?option=com_jce&view=cpanel', false));
             break;
         case 'editor':
             $source = dirname(__FILE__) . '/packages/editors';
             if (is_dir($source)) {
                 jimport('joomla.installer.installer');
                 $installer = new JInstaller();
                 if ($installer->install($source)) {
                     $app->enqueueMessage(WFText::_('WF_EDITOR_INSTALL_SUCCESS'));
                 } else {
                     $app->enqueueMessage(WFText::_('WF_EDITOR_INSTALL_FAILED'));
                 }
                 $this->setRedirect(JRoute::_('index.php?option=com_jce&view=cpanel', false));
             }
             break;
     }
 }