/**
  * Export the settings
  *
  * @access	private
  * @return	void
  */
 private function _finishExportingSettings()
 {
     $ids = array();
     $groups = array();
     //-----------------------------------------
     // get ids...
     //-----------------------------------------
     foreach ($_POST as $key => $value) {
         if (preg_match("/^id_(\\d+)\$/", $key, $match)) {
             if ($this->request[$match[0]]) {
                 $ids[] = $match[1];
             }
         }
     }
     $ids = IPSLib::cleanIntArray($ids);
     //-----------------------------------------
     // Got any?
     //-----------------------------------------
     if (!count($ids)) {
         $this->registry->output->global_message = $this->lang->words['s_sometoexport'];
         $this->_startExportingSettings();
         return;
     }
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'class_xml.php';
     $xml = new class_xml();
     $xml->xml_set_root('settingexport', array('exported' => time()));
     //-----------------------------------------
     // Get groups
     //-----------------------------------------
     $xml->xml_add_group('settinggroup');
     $this->_settingsGetGroups();
     $entry = array();
     $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_id IN (" . implode(",", $ids) . ")", 'order' => 'conf_position, conf_title'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $content = array();
         $groups[$r['conf_group']] = $r['conf_group'];
         $r['conf_value'] = '';
         //-----------------------------------------
         // Add in setting key
         //-----------------------------------------
         $r['conf_title_keyword'] = $this->setting_groups[$r['conf_group']]['conf_title_keyword'];
         foreach ($r as $k => $v) {
             $content[] = $xml->xml_build_simple_tag($k, $v);
         }
         $entry[] = $xml->xml_build_entry('setting', $content);
     }
     //-----------------------------------------
     // Add in groups...
     //-----------------------------------------
     if (is_array($groups) and count($groups)) {
         foreach ($groups as $conf_group_id) {
             $content = array();
             $thisconf = array('conf_is_title' => 1, 'conf_title_keyword' => $this->setting_groups[$conf_group_id]['conf_title_keyword'], 'conf_title_title' => $this->setting_groups[$conf_group_id]['conf_title_title'], 'conf_title_desc' => $this->setting_groups[$conf_group_id]['conf_title_desc'], 'conf_title_noshow' => $this->setting_groups[$conf_group_id]['conf_title_noshow'], 'conf_title_module' => $this->setting_groups[$conf_group_id]['conf_title_module']);
             foreach ($thisconf as $k => $v) {
                 $content[] = $xml->xml_build_simple_tag($k, $v);
             }
             $entry[] = $xml->xml_build_entry('setting', $content);
         }
     }
     $xml->xml_add_entry_to_group('settinggroup', $entry);
     $xml->xml_format_document();
     $doc = $xml->xml_document;
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($doc, 'ipb_settings_partial.xml', '', 0);
 }
 /**
  * Build XML file from array of data
  *
  * @access	private
  * @param	array 		Entries to add
  * @return	string		XML Document
  */
 private function _buildXML($data = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $entry = array();
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'class_xml.php';
     $xml = new class_xml();
     $xml->doc_type = IPS_DOC_CHAR_SET;
     $xml->xml_set_root('export', array('exported' => time()));
     //-----------------------------------------
     // Set group
     //-----------------------------------------
     $xml->xml_add_group('group');
     foreach ($data as $thisentry => $r) {
         $content = array();
         if ($r['login_folder_name'] == 'internal') {
             $r['login_enabled'] = 1;
         } else {
             if ($r['login_folder_name'] == 'ipconverge') {
                 $r['login_maintain_url'] = '';
                 $r['login_register_url'] = '';
                 $r['login_login_url'] = '';
                 $r['login_logout_url'] = '';
                 $r['login_enabled'] = 0;
             } else {
                 $r['login_enabled'] = 0;
             }
         }
         //-----------------------------------------
         // Sort the fields...
         //-----------------------------------------
         foreach ($r as $k => $v) {
             if (in_array($k, array('login_id', 'login_date'))) {
                 continue;
             }
             $content[] = $xml->xml_build_simple_tag($k, $v);
         }
         $entry[] = $xml->xml_build_entry('row', $content);
     }
     $xml->xml_add_entry_to_group('group', $entry);
     $xml->xml_format_document();
     return $xml->xml_document;
 }
 /**
  * Exports the groups to a master XML file for distribution
  *
  * @access	public
  * @return	void		[Outputs to screen]
  */
 public function masterXMLExport()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $entry = array();
     $skip = IPSLib::fetchNonDefaultGroupFields();
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'class_xml.php';
     $xml = new class_xml();
     $xml->doc_type = IPS_DOC_CHAR_SET;
     $xml->xml_set_root('export', array('exported' => time()));
     //-----------------------------------------
     // Set group
     //-----------------------------------------
     $xml->xml_add_group('group');
     //-----------------------------------------
     // Grab our default 6 groups
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'groups', 'order' => 'g_id ASC', 'limit' => array(0, 6)));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $content = array();
         $r['g_icon'] = '';
         //-----------------------------------------
         // Sort the fields...
         //-----------------------------------------
         foreach ($r as $k => $v) {
             if (!in_array($k, $skip)) {
                 $content[] = $xml->xml_build_simple_tag($k, $v);
             }
         }
         $entry[] = $xml->xml_build_entry('row', $content);
     }
     $xml->xml_add_entry_to_group('group', $entry);
     $xml->xml_format_document();
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($xml->xml_document, 'groups.xml', '', 0);
 }
 /**
  * Builds the attachment type xml export
  *
  * @access	public
  * @return	void
  **/
 public function attachmentTypeExport()
 {
     /* Get XML Class */
     require_once IPS_KERNEL_PATH . 'class_xml.php';
     $xml = new class_xml();
     /* Set the root of the XML document */
     $xml->xml_set_root('attachtypesexport');
     /* Add the attachment type group */
     $xml->xml_add_group('attachtypesgroup');
     /* Query the attachment Types */
     $this->DB->build(array('select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'order' => "atype_extension"));
     $this->DB->execute();
     /* Loop through the types */
     $entry = array();
     while ($r = $this->DB->fetch()) {
         /* INI */
         $content = array();
         /* Build the tag */
         foreach ($r as $k => $v) {
             $content[] = $xml->xml_build_simple_tag($k, $v);
         }
         /* Add to the entry */
         $entry[] = $xml->xml_build_entry('attachtype', $content);
     }
     /* Add entries to the group and build the document */
     $xml->xml_add_entry_to_group('attachtypesgroup', $entry);
     $xml->xml_format_document();
     /* Send for download */
     $this->registry->output->showDownload($xml->xml_document, 'attachments.xml', "unknown/unknown", false);
 }