예제 #1
0
 public function importAdminTemplatesXml(SimpleXMLElement $xml, $blockId)
 {
     $existingAdminTemplates = $this->getAdminTemplatesByBlock($blockId);
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     foreach ($xml->template as $template) {
         $templateName = (string) $template['title'];
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminTemplate');
         if (isset($existingAdminTemplates[$templateName])) {
             $dw->setExistingData($existingAdminTemplates[$templateName], true);
         }
         $dw->bulkSet(array('title' => $templateName, 'template' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($template)));
         $dw->save();
     }
     XenForo_Db::commit($db);
     return;
 }
예제 #2
0
파일: Widget.php 프로젝트: Sywooch/forums
 public function importFromFile($fileName, $deleteAll = false)
 {
     if (!file_exists($fileName) || !is_readable($fileName)) {
         throw new XenForo_Exception(new XenForo_Phrase('please_enter_valid_file_name_requested_file_not_read'), true);
     }
     try {
         $document = new SimpleXMLElement($fileName, 0, true);
     } catch (Exception $e) {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_was_not_valid_xml_file'), true);
     }
     if ($document->getName() != 'widget_framework') {
         throw new XenForo_Exception(new XenForo_Phrase('wf_provided_file_is_not_an_widgets_xml_file'), true);
     }
     $widgets = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->widget);
     XenForo_Db::beginTransaction();
     if ($deleteAll) {
         // get global widgets from database and delete them all!
         // NOTE: ignore widget page widgets
         $existingWidgets = $this->getGlobalWidgets(false, false);
         foreach ($existingWidgets as $existingWidget) {
             $dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
             $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
             $dw->setExistingData($existingWidget);
             $dw->delete();
         }
     }
     foreach ($widgets as $widget) {
         $dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
         $dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
         $dw->set('title', $widget['title']);
         $dw->set('class', $widget['class']);
         $dw->set('position', $widget['position']);
         $dw->set('display_order', $widget['display_order']);
         $dw->set('active', intval($widget['active']));
         $dw->set('options', unserialize(XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($widget->options)));
         $dw->save();
     }
     $this->buildCache();
     XenForo_Db::commit();
 }
예제 #3
0
 /**
  * Imports admin templates.
  * It does not check for conflicts.
  *
  * @param SimpleXMLElement $xml
  */
 public function importAdminTemplatesFieldXml(SimpleXMLElement $xml)
 {
     $db = $this->_getDb();
     if ($xml->template === null) {
         return;
     }
     XenForo_Db::beginTransaction($db);
     foreach ($xml->template as $template) {
         $templateName = (string) $template['title'];
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminTemplate');
         $existingTemplate = $this->_getAdminTemplateModel()->getAdminTemplateByTitle($templateName);
         if ($existingTemplate) {
             $dw->setExistingData($existingTemplate);
         }
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_DEV_OUTPUT_DIR, '');
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_FULL_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_TEST_COMPILE, false);
         $dw->bulkSet(array('title' => (string) $template['title'], 'template' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($template), 'addon_id' => (string) $template['addon_id']));
         $dw->save();
     }
     XenForo_Db::commit($db);
 }
예제 #4
0
 /**
  * Imports templates into a given style. Note that this assumes the style is already empty.
  * It does not check for conflicts.
  *
  * @param SimpleXMLElement $xml
  * @param integer $styleId
  * @param string|null $addOnId If non-null, consider only templates from this add-on to be imported
  */
 public function importTemplatesStyleXml(SimpleXMLElement $xml, $styleId, $addOnId = null)
 {
     $db = $this->_getDb();
     if ($xml->template === null) {
         return;
     }
     $existingTemplates = $this->getAllTemplatesInStyle($styleId);
     XenForo_Db::beginTransaction($db);
     foreach ($xml->template as $template) {
         $templateName = (string) $template['title'];
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Template');
         if (isset($existingTemplates[$templateName])) {
             $dw->setExistingData($existingTemplates[$templateName], true);
         }
         $dw->setOption(XenForo_DataWriter_Template::OPTION_DEV_OUTPUT_DIR, '');
         $dw->setOption(XenForo_DataWriter_Template::OPTION_FULL_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_TEST_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_CHECK_DUPLICATE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_REBUILD_TEMPLATE_MAP, false);
         $dw->bulkSet(array('style_id' => $styleId, 'title' => (string) $template['title'], 'template' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($template), 'addon_id' => (string) $template['addon_id'], 'version_id' => (int) $template['version_id'], 'version_string' => (string) $template['version_string'], 'disable_modifications' => (int) $template['disable_modifications']));
         $dw->save();
         unset($existingTemplates[$templateName]);
     }
     // removed templates
     foreach ($existingTemplates as $existingTemplate) {
         if ($addOnId !== null && $existingTemplate['addon_id'] !== $addOnId) {
             continue;
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Template');
         $dw->setExistingData($existingTemplate, true);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_DEV_OUTPUT_DIR, '');
         $dw->setOption(XenForo_DataWriter_Template::OPTION_FULL_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_TEST_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_CHECK_DUPLICATE, false);
         $dw->setOption(XenForo_DataWriter_Template::OPTION_REBUILD_TEMPLATE_MAP, false);
         $dw->delete();
     }
     XenForo_Db::commit($db);
 }
예제 #5
0
 /**
  * Imports the add-on admin templates XML.
  *
  * @param SimpleXMLElement $xml XML element pointing to the root of the data
  * @param string $addOnId Add-on to import for
  * @param integer $maxExecution Maximum run time in seconds
  * @param integer $offset Number of elements to skip
  *
  * @return boolean|integer True on completion; false if the XML isn't correct; integer otherwise with new offset value
  */
 public function importAdminTemplatesAddOnXml(SimpleXMLElement $xml, $addOnId, $maxExecution = 0, $offset = 0)
 {
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $startTime = microtime(true);
     if ($offset == 0) {
         $this->deleteAdminTemplatesForAddOn($addOnId);
     }
     $templates = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->template);
     $titles = array();
     $current = 0;
     foreach ($templates as $template) {
         $current++;
         if ($current <= $offset) {
             continue;
         }
         $titles[] = (string) $template['title'];
     }
     $existingTemplates = $this->getAdminTemplatesByTitles($titles);
     $current = 0;
     $restartOffset = false;
     foreach ($templates as $template) {
         $current++;
         if ($current <= $offset) {
             continue;
         }
         $templateName = (string) $template['title'];
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminTemplate');
         if (isset($existingTemplates[$templateName])) {
             $dw->setExistingData($existingTemplates[$templateName], true);
         }
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_DEV_OUTPUT_DIR, '');
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_FULL_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_AdminTemplate::OPTION_TEST_COMPILE, false);
         $dw->set('title', $templateName);
         $dw->set('template', XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($template));
         $dw->set('addon_id', $addOnId);
         $dw->save();
         if ($maxExecution && microtime(true) - $startTime > $maxExecution) {
             $restartOffset = $current;
             break;
         }
     }
     XenForo_Db::commit($db);
     return $restartOffset ? $restartOffset : true;
 }
예제 #6
0
파일: BbCode.php 프로젝트: Sywooch/forums
 /**
  * Imports the BB code media sites for an add-on.
  *
  * @param SimpleXMLElement $xml XML element pointing to the root of the event data
  * @param string $addOnId Add-on to import for
  */
 public function importBbCodeMediaSitesAddOnXml(SimpleXMLElement $xml, $addOnId)
 {
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $db->delete('xf_bb_code_media_site', 'addon_id = ' . $db->quote($addOnId));
     $xmlSites = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->site);
     $siteIds = array();
     foreach ($xmlSites as $site) {
         $siteIds[] = (string) $site['media_site_id'];
     }
     $sites = $this->getBbCodeMediaSites(array('mediaSiteIds' => $siteIds));
     foreach ($xmlSites as $site) {
         $siteId = (string) $site['media_site_id'];
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_BbCodeMediaSite');
         if (isset($sites[$siteId])) {
             $dw->setExistingData($sites[$siteId]);
         }
         $dw->bulkSet(array('media_site_id' => $siteId, 'site_title' => (string) $site['site_title'], 'site_url' => (string) $site['site_url'], 'match_urls' => (string) XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($site->match_urls), 'match_is_regex' => (int) $site['match_is_regex'], 'match_callback_class' => (string) $site['match_callback_class'], 'match_callback_method' => (string) $site['match_callback_method'], 'embed_html' => (string) XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($site->embed_html), 'embed_html_callback_class' => (string) $site['embed_html_callback_class'], 'embed_html_callback_method' => (string) $site['embed_html_callback_method'], 'supported' => (int) $site['supported'], 'addon_id' => $addOnId));
         $dw->save();
     }
     XenForo_Db::commit($db);
 }
예제 #7
0
파일: Smilie.php 프로젝트: Sywooch/forums
 /**
  * Imports a smilie XML file.
  *
  * @param SimpleXMLElement $document
  * @param string $smilieGroupId
  * @param integer $overwriteSmilieId
  *
  * @return array List of cache rebuilders to run
  */
 public function importSmiliesXml(SimpleXMLElement $document, $overwrite = 0)
 {
     if ($document->getName() != 'smilies') {
         throw new XenForo_Exception(new XenForo_Phrase('waindigo_provided_file_is_not_valid_smilie_xml_smilieimporter'), true);
     }
     $smilies = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->smilie);
     $db = $this->_getDb();
     /* @var $smilie SimpleXMLElement */
     XenForo_Db::beginTransaction($db);
     foreach ($smilies as $smilie) {
         $smilieText = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->smilie_text);
         $existing = $this->getSmiliesByText($smilieText);
         $updateText = array();
         foreach ($existing as $text => $existingSmilie) {
             if ($overwrite) {
                 if (isset($updateText[$existingSmilie['smilie_id']])) {
                     $existingSmilie['smilie_text'] = $updateText[$existingSmilie['smilie_id']];
                 }
                 $existingSmilie['smilie_text'] = preg_split('/\\R/m', $existingSmilie['smilie_text']);
                 unset($existingSmilie['smilie_text'][array_search($text, $existingSmilie['smilie_text'])]);
                 if (!empty($existingSmilie['smilie_text'])) {
                     $updateText[$existingSmilie['smilie_id']] = implode(PHP_EOL, $existingSmilie['smilie_text']);
                 } else {
                     $dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
                     $dw->setExistingData($existingSmilie['smilie_id']);
                     $dw->delete();
                 }
             } else {
                 $smilieText = preg_split('/\\R/m', $smilieText);
                 if (in_array($text, $smilieText)) {
                     unset($smilieText[array_search($text, $smilieText)]);
                 }
                 $smilieText = implode(PHP_EOL, $smilieText);
                 if (!trim($smilieText)) {
                     continue;
                 }
             }
         }
         foreach ($updateText as $smilieId => $updateTextItem) {
             $dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
             $dw->setExistingData($smilieId);
             $dw->set('smilie_text', $updateTextItem);
             $dw->save();
         }
         if (!trim($smilieText)) {
             continue;
         }
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
         $spriteParams = array('h' => (string) $smilie['h'], 'w' => (string) $smilie['w'], 'x' => (string) $smilie['x'], 'y' => (string) $smilie['y']);
         $dw->bulkSet(array('title' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->title), 'image_url' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->image_url), 'smilie_text' => $smilieText, 'sprite_mode' => (string) $smilie['sprite_mode'], 'sprite_params' => $spriteParams));
         $dw->save();
     }
     XenForo_Db::commit($db);
 }
예제 #8
0
 /**
  * Imports a field XML file.
  *
  * @param SimpleXMLElement $document
  * @param string $fieldGroupId
  * @param integer $overwriteFieldId
  *
  * @return array List of cache rebuilders to run
  */
 public function importFieldXml(SimpleXMLElement $document, $fieldGroupId = 0, $overwriteFieldId = 0)
 {
     if ($document->getName() != 'field') {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_is_not_valid_field_xml'), true);
     }
     $fieldId = (string) $document['field_id'];
     if ($fieldId === '') {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_is_not_valid_field_xml'), true);
     }
     $phraseModel = $this->_getPhraseModel();
     $overwriteField = array();
     if ($overwriteFieldId) {
         $overwriteField = $this->getResourceFieldById($overwriteFieldId);
     }
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $dw = XenForo_DataWriter::create('Waindigo_CustomFields_DataWriter_ResourceField');
     if (isset($overwriteField['field_id'])) {
         $dw->setExistingData($overwriteFieldId);
     } else {
         if ($overwriteFieldId) {
             $dw->set('field_id', $overwriteFieldId);
         } else {
             $dw->set('field_id', $fieldId);
         }
         if ($fieldGroupId) {
             $dw->set('field_group_id', $fieldGroupId);
         }
         $dw->set('allowed_user_group_ids', -1);
     }
     $dw->bulkSet(array('display_order' => $document['display_order'], 'field_type' => $document['field_type'], 'match_type' => $document['match_type'], 'match_regex' => $document['match_regex'], 'match_callback_class' => $document['match_callback_class'], 'match_callback_method' => $document['match_callback_method'], 'max_length' => $document['max_length'], 'display_callback_class' => $document['display_callback_class'], 'display_callback_method' => $document['display_callback_method'], 'field_choices_callback_class' => $document['field_choices_callback_class'], 'field_choices_callback_method' => $document['field_choices_callback_method'], 'field_callback_class' => $document['field_callback_class'], 'field_callback_method' => $document['field_callback_method'], 'export_callback_class' => $document['export_callback_class'], 'export_callback_method' => $document['export_callback_method'], 'display_template' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->display_template)));
     /* @var $addOnModel XenForo_Model_AddOn */
     $addOnModel = XenForo_Model::create('XenForo_Model_AddOn');
     $addOn = $addOnModel->getAddOnById($document['addon_id']);
     if (!empty($addOn)) {
         $dw->set('addon_id', $addOn['addon_id']);
     }
     $dw->setExtraData(Waindigo_CustomFields_DataWriter_ResourceField::DATA_TITLE, XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->title));
     $dw->setExtraData(Waindigo_CustomFields_DataWriter_ResourceField::DATA_DESCRIPTION, XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->description));
     $fieldChoices = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->field_choices->field_choice);
     foreach ($fieldChoices as $fieldChoice) {
         if ($fieldChoice && $fieldChoice['value']) {
             $fieldChoicesCombined[(string) $fieldChoice['value']] = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($fieldChoice);
         }
     }
     if (isset($fieldChoicesCombined)) {
         $dw->setFieldChoices($fieldChoicesCombined);
     }
     $dw->save();
     $this->getModelFromCache('Waindigo_CustomFields_Model_Template')->importTemplatesFieldXml($document->templates);
     $this->getModelFromCache('Waindigo_CustomFields_Model_AdminTemplate')->importAdminTemplatesFieldXml($document->admin_templates);
     $phraseModel->importPhrasesXml($document->phrases, 0);
     XenForo_Db::commit($db);
     if (XenForo_Application::$versionId < 1020000) {
         return array('Template', 'Phrase', 'AdminTemplate');
     }
     XenForo_Application::defer('Atomic', array('simple' => array('Phrase', 'TemplateReparse', 'Template', 'AdminTemplateReparse', 'AdminTemplate')), 'customFieldRebuild', true);
     return true;
 }
예제 #9
0
 /**
  * Imports a class XML file.
  *
  * @param SimpleXMLElement $document
  * @param string $fieldGroupId
  * @param integer $overwriteFieldId
  *
  * @return array List of cache rebuilders to run
  */
 public function importClassXml(SimpleXMLElement $document)
 {
     if ($document->getName() != 'class') {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_is_not_valid_class_xml'), true);
     }
     $classId = (string) $document['class_id'];
     if ($classId === '') {
         throw new XenForo_Exception(new XenForo_Phrase('provided_file_is_not_valid_class_xml'), true);
     }
     $addOnId = (string) $document['addon_id'];
     $overwriteClasses = $this->getClasses(array('class_id' => $classId, 'addon_id' => $addOnId));
     if (!empty($overwriteClasses)) {
         $overwriteClass = reset($overwriteClasses);
     }
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $dw = XenForo_DataWriter::create('ThemeHouse_Objects_DataWriter_Class');
     if (isset($overwriteClass)) {
         $dw->setExistingData($overwriteClass['object_class_id']);
     } else {
         $dw->set('class_id', $classId);
         $dw->set('addon_id', $addOnId);
     }
     $dw->bulkSet(array('title' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->title), 'class_id_plural' => $document['class_id_plural'], 'title_plural' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->title_plural), 'route_prefix' => $document['route_prefix'], 'route_prefix_admin' => $document['route_prefix_admin'], 'title_full' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($document->title_full), 'table_name' => $document['table_name'], 'primary_key_id' => $document['primary_key_id']));
     $dw->save();
     XenForo_Db::commit($db);
     return array();
 }
 /**
  * Imports the modifications for an add-on.
  *
  * @param SimpleXMLElement $xml XML element pointing to the root of the event data
  * @param string $addOnId Add-on to import for
  */
 public function importModificationAddOnXml(SimpleXMLElement $xml, $addOnId)
 {
     $db = $this->_getDb();
     $addonMods = $this->getModificationsByAddOnId($addOnId);
     XenForo_Db::beginTransaction($db);
     $this->deleteModificationsForAddOn($addOnId);
     $xmlEntries = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->modification);
     $keys = array();
     foreach ($xmlEntries as $entry) {
         $keys[] = (string) $entry['modification_key'];
     }
     $modifications = $this->getModificationsByKeys($keys);
     foreach ($xmlEntries as $modification) {
         $key = (string) $modification['modification_key'];
         $dw = XenForo_DataWriter::create($this->_dataWriterName);
         if (isset($modifications[$key])) {
             $dw->setExistingData($modifications[$key]);
         }
         if (isset($addonMods[$key])) {
             $enabled = $addonMods[$key]['enabled'];
         } else {
             $enabled = (string) $modification['enabled'];
         }
         $dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_FULL_TEMPLATE_COMPILE, false);
         $dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_REPARSE_TEMPLATE, false);
         $dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_VERIFY_MODIFICATION_KEY, false);
         $dw->bulkSet(array('addon_id' => $addOnId, 'template' => (string) $modification['template'], 'modification_key' => $key, 'description' => (string) $modification['description'], 'execution_order' => (int) $modification['execution_order'], 'enabled' => $enabled, 'action' => (string) $modification['action'], 'find' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($modification->find[0]), 'replace' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($modification->replace[0])));
         $this->_addExtraToAddonXmlImportDw($dw, $modification);
         $dw->save();
     }
     XenForo_Db::commit($db);
 }
예제 #11
0
 /**
  * Imports a moderators XML file.
  *
  * @param SimpleXMLElement $document
  * @param integer $overwrite
  *
  * @return array List of cache rebuilders to run
  */
 public function importModeratorsXml(SimpleXMLElement $document, $overwrite = 0)
 {
     if ($document->getName() != 'moderators') {
         throw new XenForo_Exception(new XenForo_Phrase('th_provided_file_is_not_valid_moderator_xml_moderators'), true);
     }
     $db = $this->_getDb();
     /* @var $generalModerator SimpleXMLElement */
     XenForo_Db::beginTransaction($db);
     $generalModerators = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->general_moderators->general_moderator);
     foreach ($generalModerators as $generalModerator) {
         $modPerms = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($generalModerator->moderator_permissions);
         if ($modPerms) {
             $modPerms = unserialize($modPerms);
         } else {
             $modPerms = array();
         }
         $userId = (int) $generalModerator['user_id'];
         $existing = $this->getGeneralModeratorByUserId($userId);
         if (!$overwrite && $existing) {
             continue;
         }
         $isSuperModerator = (int) $generalModerator['is_super_moderator'];
         $extra = array('extra_user_group_ids' => $generalModerator['extra_user_group_ids']);
         $this->insertOrUpdateGeneralModerator($userId, $modPerms, $isSuperModerator, $extra);
     }
     $contentModerators = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->content_moderators->content_moderator);
     foreach ($contentModerators as $contentModerator) {
         $modPerms = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($contentModerator->moderator_permissions);
         if ($modPerms) {
             $modPerms = unserialize($modPerms);
         } else {
             $modPerms = array();
         }
         $contentType = (string) $contentModerator['content_type'];
         $contentId = (int) $contentModerator['content_id'];
         $userId = (int) $contentModerator['user_id'];
         $existing = $this->getContentModeratorByContentAndUserId($contentType, $contentId, $userId);
         if (!$overwrite && $existing) {
             continue;
         }
         $this->insertOrUpdateContentModerator($userId, $contentType, $contentId, $modPerms);
     }
     XenForo_Db::commit($db);
 }