Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added detection for a whole lot more urls I found stored as channel p…

…references, bringing the average detected settings to about 35
  • Loading branch information...
commit 23c9b90d56cebdacf77907bcb4eb1aa81beaa2f8 1 parent 58a4436
@adrianmacneil adrianmacneil authored
View
1  language/english/lang.reelocate.php
@@ -17,6 +17,7 @@
'reelocate_replacement_value' => 'Replacement Value',
'reelocate_site_prefs' => 'Site Preferences',
+ 'reelocate_channel_prefs' => 'Channel Preferences',
'reelocate_upload_prefs' => 'Upload Preferences',
'reelocate_current_value' => 'Current Value',
'reelocate_new_value' => 'New Value',
View
49 mcp.reelocate.php
@@ -64,6 +64,7 @@ function preview()
$this->EE->cp->set_breadcrumb(BASE.AMP.REELOCATE_CP, lang('reelocate_module_name'));
$this->EE->cp->set_variable('cp_page_title', lang('reelocate_preview_changes'));
$this->EE->lang->loadfile('admin');
+ $this->EE->lang->loadfile('admin_content');
$this->EE->lang->loadfile('design');
$this->EE->lang->loadfile('tools');
@@ -98,6 +99,7 @@ function preview()
}
$data['site_prefs'] = $this->_find_site_prefs($search, $replace);
+ $data['channel_prefs'] = $this->_find_channel_prefs($search, $replace);
$data['upload_prefs'] = $this->_find_upload_prefs($search, $replace);
return $this->EE->load->view('reelocate_preview', $data, TRUE);
@@ -132,6 +134,39 @@ function _find_site_prefs($search, $replace)
return $results;
}
+ function _find_channel_prefs($search, $replace)
+ {
+ if (!is_array($search) OR !is_array($replace)) return;
+ if (count($search) != count($replace)) return;
+
+ // search for upload preferences
+ $results = array();
+ $channel_prefs = $this->EE->db->get('channels')->result_array();
+ // loop through channels
+ foreach ($channel_prefs as $row)
+ {
+ // loop through find/replace strings
+ foreach ($search as $id => $search_str)
+ {
+ // loop through channel preference names
+ foreach (array('channel_url', 'channel_notify_emails', 'comment_url', 'search_results_url', 'ping_return_url', 'rss_url') as $upload_pref_name)
+ {
+ if (stripos($row[$upload_pref_name], $search_str) !== FALSE)
+ {
+ $key = 'channel_id_'.$row['channel_id'].'_'.$upload_pref_name;
+ $results[$key]['title'] = $row['channel_title'].': '.lang($upload_pref_name);
+ $results[$key]['current'] = $row[$upload_pref_name];
+ $results[$key]['current_html'] = preg_replace('/('.preg_quote($search_str, '/').')/i', '<strong>$1</strong>', $row[$upload_pref_name]);
+ $results[$key]['updated'] = str_ireplace($search_str, $replace[$id], $row[$upload_pref_name]);
+ }
+ }
+ }
+ }
+
+ ksort($results);
+ return $results;
+ }
+
function _find_upload_prefs($search, $replace)
{
if (!is_array($search) OR !is_array($replace)) return;
@@ -177,6 +212,7 @@ function update()
}
$site_prefs = array();
+ $channel_prefs = array();
$upload_prefs = array();
// loop through the POST data
@@ -192,6 +228,12 @@ function update()
// standard site preference
$site_prefs[$setting_id] = $this->EE->input->post($setting_id, TRUE);
}
+ elseif (strpos($setting_id, 'channel_id_') !== FALSE)
+ {
+ // channel preference
+ preg_match('/channel_id_([\d]+)_([\w]+)/i', $setting_id, $matches);
+ $channel_prefs[$matches[1]][$matches[2]] = $this->EE->input->post($setting_id, TRUE);
+ }
elseif (strpos($setting_id, 'upload_dir_') !== FALSE)
{
// upload dir preference
@@ -205,6 +247,13 @@ function update()
$this->EE->config->update_site_prefs($site_prefs);
$updated_count = count($site_prefs);
+ // update the channel prefs
+ foreach ($channel_prefs as $id => $data)
+ {
+ $this->EE->db->update('channels', $data, array('channel_id' => $id));
+ $updated_count += count($data);
+ }
+
// update the upload prefs
foreach ($upload_prefs as $id => $data)
{
View
2  views/reelocate_preview.php
@@ -2,7 +2,7 @@
<?php
$results = FALSE;
- foreach (array('site_prefs', 'upload_prefs') as $pref_type)
+ foreach (array('site_prefs', 'channel_prefs', 'upload_prefs') as $pref_type)
{
if (!empty($$pref_type))
{
Please sign in to comment.
Something went wrong with that request. Please try again.