Esempio n. 1
0
 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();
                 }
             }
         }
     }
 }