This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
May 29, 2010
1 parent
65921e7
commit 1b10f91
Showing
4 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?php | ||
/*---------------------------------------------------------------------+ | ||
| ExiteCMS Content Management System | | ||
+----------------------------------------------------------------------+ | ||
| Copyright 2010 Exite BV, The Netherlands | | ||
| for support, please visit http://www.exitecms.org | | ||
+----------------------------------------------------------------------+ | ||
| Some code derived from PHP-Fusion, copyright 2002 - 2006 Nick Jones | | ||
+----------------------------------------------------------------------+ | ||
| Released under the terms & conditions of v2 of the GNU General Public| | ||
| License. For details refer to the included gpl.txt file or visit | | ||
| http://gnu.org | | ||
+----------------------------------------------------------------------+ | ||
| $Id:: newsletters.php 2043 2008-11-16 14:25:18Z WanWizard $| | ||
+----------------------------------------------------------------------+ | ||
| Last modified by $Author:: WanWizard $| | ||
| Revision number $Rev:: 2043 $| | ||
+---------------------------------------------------------------------*/ | ||
require_once dirname(__FILE__)."/../../includes/core_functions.php"; | ||
require_once PATH_ROOT."/includes/theme_functions.php"; | ||
|
||
// load the locale for this module | ||
locale_load("modules.merge_forums"); | ||
|
||
// temp storage for template variables | ||
$variables = array('error' => '', | ||
'forum_from_id' => 0, | ||
'forum_to_id' => 0, | ||
'prefix' => '[prefix]' | ||
); | ||
|
||
// check for the proper admin access rights | ||
if (!checkrights("mF") || !defined("iAUTH") || $aid != iAUTH) fallback(BASEDIR."index.php"); | ||
|
||
/*---------------------------------------------------+ | ||
| Local functions | | ||
+----------------------------------------------------*/ | ||
|
||
/*---------------------------------------------------+ | ||
| Main code | | ||
+----------------------------------------------------*/ | ||
|
||
// response processing | ||
|
||
if (isset($_POST['merge'])) { | ||
// validate the parameters | ||
if (!isset($_POST['forum_from_id']) or !is_numeric($_POST['forum_from_id'])) { | ||
$forum_from_id = false; | ||
} else { | ||
$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id = ".mysql_real_escape_string($_POST['forum_from_id'])); | ||
if ($data = dbarray($result)) { | ||
$forum_from_id = $data['forum_id']; | ||
$forum_from_name = $data['forum_name']; | ||
} else { | ||
$forum_from_id = false; | ||
} | ||
} | ||
if (!isset($_POST['forum_to_id']) or !is_numeric($_POST['forum_to_id'])) { | ||
$forum_to_id = false; | ||
} else { | ||
$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_id = ".mysql_real_escape_string($_POST['forum_to_id'])); | ||
if ($data = dbarray($result)) { | ||
$forum_to_id = $data['forum_id']; | ||
$forum_to_name = $data['forum_name']; | ||
} else { | ||
$forum_to_id = false; | ||
} | ||
} | ||
if (!isset($_POST['prefix'])) { | ||
$prefix = false; | ||
} else { | ||
if (empty($_POST['prefix'])) { | ||
$prefix = ''; | ||
} else { | ||
$prefix = '['.rtrim(ltrim(trim($_POST['prefix']), '['), ']').'] '; | ||
} | ||
} | ||
|
||
// complete? | ||
if ($forum_from_id === false or $forum_to_id === false or $prefix === false) { | ||
$variables['error'] = $locale['mf502']; | ||
} else { | ||
// all is well | ||
$variables['forum_from_id'] = $forum_from_id; | ||
$variables['forum_to_id'] = $forum_to_id; | ||
$variables['prefix'] = $prefix; | ||
// first, add our prefix | ||
$result = dbquery("UPDATE ".$db_prefix."threads SET thread_subject = CONCAT('".mysql_real_escape_string($prefix)."', thread_subject) WHERE LEFT(thread_subject,1) != '[' AND forum_id = ".$forum_from_id); | ||
// move all threads to the new forum | ||
$result = dbquery("UPDATE ".$db_prefix."threads SET forum_id = ".$forum_to_id." WHERE forum_id = ".$forum_from_id); | ||
// add our prefix to the post subjects as well | ||
$result = dbquery("UPDATE ".$db_prefix."posts SET post_subject = CONCAT('".mysql_real_escape_string($prefix)."', post_subject) WHERE LEFT(post_subject,1) != '[' AND forum_id = ".$forum_from_id); | ||
// move all posts to the new forum as well | ||
$result = dbquery("UPDATE ".$db_prefix."posts SET forum_id = ".$forum_to_id." WHERE forum_id = ".$forum_from_id); | ||
// move all thread read pointers | ||
$result = dbquery("UPDATE ".$db_prefix."threads_read SET forum_id = ".$forum_to_id." WHERE forum_id = ".$forum_from_id); | ||
// update the to forum last user and post timestamp | ||
$result = dbquery("SELECT MAX(post_datestamp) AS postdate, MAX(post_edittime) AS editdate FROM ".$db_prefix."posts WHERE forum_id = ".$forum_to_id); | ||
if ($data = dbarray($result)) { | ||
if ($data['postdate'] > $data['editdate']) { | ||
$result = dbquery("SELECT post_author FROM ".$db_prefix."posts WHERE post_datestamp = (SELECT MAX(post_datestamp) FROM ".$db_prefix."posts WHERE forum_id = ".$forum_to_id.")"); | ||
if ($data2 = dbarray($result)) { | ||
$result = dbquery("UPDATE ".$db_prefix."forums SET forum_lastuser = ".$data2['post_author'].", forum_lastpost = ".$data['postdate']." WHERE forum_id = ".$forum_to_id); | ||
} | ||
} else { | ||
$result = dbquery("SELECT post_edituser FROM ".$db_prefix."posts WHERE post_edittime = (SELECT MAX(post_edittime) FROM ".$db_prefix."posts WHERE forum_id = ".$forum_to_id.")"); | ||
if ($data2 = dbarray($result)) { | ||
$result = dbquery("UPDATE ".$db_prefix."forums SET forum_lastuser = ".$data2['post_edituser'].", forum_lastpost = ".$data['editdate']." WHERE forum_id = ".$forum_to_id); | ||
} | ||
} | ||
} | ||
|
||
$variables['error'] = sprintf($locale['mf503'], $forum_from_name, $forum_to_name); | ||
} | ||
|
||
// steps: | ||
// | ||
// update the thread subjects of the old forum id with the prefix (if defined) | ||
// update threads, replace old forum_id by new_forum_id | ||
// update posts, replace old forum_id by new_forum_id | ||
// update threads_read, replace old forum_id by new_forum_id | ||
|
||
} | ||
|
||
// prepare the forum selection panel | ||
$variables['forums'] = array(); | ||
$result = dbquery("SELECT * FROM ".$db_prefix."forums WHERE forum_cat > 0 ORDER BY forum_name"); | ||
while ($data = dbarray($result)) { | ||
$variables['forums'][$data['forum_id']] = $data['forum_name']; | ||
} | ||
|
||
// define the forum merge body panel | ||
$template_panels[] = array('type' => 'body', 'name' => 'modules.merge_forums', 'template' => 'modules.merge_forums.tpl', 'locale' => "modules.merge_forums"); | ||
$template_variables['modules.merge_forums'] = $variables; | ||
|
||
// Call the theme code to generate the output for this webpage | ||
require_once PATH_THEME."/theme.php"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
/*---------------------------------------------------------------------+ | ||
| ExiteCMS Content Management System | | ||
+----------------------------------------------------------------------+ | ||
| Copyright 2010 Exite BV, The Netherlands | | ||
| for support, please visit http://www.exitecms.org | | ||
+----------------------------------------------------------------------+ | ||
| Some code derived from PHP-Fusion, copyright 2002 - 2006 Nick Jones | | ||
+----------------------------------------------------------------------+ | ||
| Released under the terms & conditions of v2 of the GNU General Public| | ||
| License. For details refer to the included gpl.txt file or visit | | ||
| http://gnu.org | | ||
+----------------------------------------------------------------------+ | ||
| $Id:: module_installer.php 2043 2008-11-16 14:25:18Z WanWizard $| | ||
+----------------------------------------------------------------------+ | ||
| Last modified by $Author:: WanWizard $| | ||
| Revision number $Rev:: 2043 $| | ||
+---------------------------------------------------------------------*/ | ||
if (!checkrights("I") || !defined("iAUTH") || $aid != iAUTH || !defined('INIT_CMS_OK')) fallback(BASEDIR."index.php"); | ||
|
||
/*---------------------------------------------------+ | ||
| Module identification | | ||
+----------------------------------------------------*/ | ||
$mod_title = "Merge Forums"; | ||
$mod_description = "Move all posts from one forum to another, optionally with a subject prefix."; | ||
$mod_version = "1.0.1"; | ||
$mod_folder = "merge_forums"; // sub-folder of the /modules folder | ||
$mod_developer = "WanWizard"; // author's name | ||
$mod_email = "[email protected]"; | ||
$mod_weburl = "http://www.exitecms.org/"; | ||
$mod_type = "M"; | ||
|
||
/*---------------------------------------------------+ | ||
| Module administration panel installation details | | ||
+----------------------------------------------------*/ | ||
|
||
$mod_admin_image = "mergeforums.gif"; // icon to be used for the admin panel | ||
$mod_admin_panel = "merge_forums.php"; // name of the admin panel for this module | ||
$mod_admin_rights = "mF"; // admin rights code. This HAS to be assigned by ExiteCMS to avoid duplicates! | ||
$mod_admin_page = 1; // admin page this panel has to be placed on | ||
|
||
/*---------------------------------------------------+ | ||
| Version and revision control | | ||
+----------------------------------------------------*/ | ||
|
||
// check for a minumum version of the ExiteCMS engine | ||
if (str_replace(".", "", $settings['version']) < 720) { | ||
$mod_errors .= sprintf($locale['mod001'], '7.20'); | ||
} | ||
// check for a maximum version of the ExiteCMS engine | ||
if (str_replace(".", "", $settings['version']) > 730) { | ||
$mod_errors .= sprintf($locale['mod002'], '7.30'); | ||
} | ||
// check for a specific revision number range that is supported | ||
if ($settings['revision'] < 0 || $settings['revision'] > 999999) { | ||
$mod_errors .= sprintf($locale['mod003'], 0, 999999); | ||
} | ||
|
||
/*---------------------------------------------------+ | ||
| Menu entries for this module | | ||
+----------------------------------------------------*/ | ||
|
||
$mod_site_links = array(); // site_links definitions. Multiple can be defined | ||
|
||
/*---------------------------------------------------+ | ||
| locale strings for this module | | ||
+----------------------------------------------------*/ | ||
|
||
$localestrings = array(); | ||
|
||
$localestrings['en'] = array(); | ||
$localestrings['en']['mf400'] = 'Merge forums'; | ||
$localestrings['en']['mf401'] = 'Forum to move from'; | ||
$localestrings['en']['mf402'] = 'Forum to move to'; | ||
$localestrings['en']['mf403'] = 'Subject prefix'; | ||
$localestrings['en']['mf404'] = 'Start'; | ||
|
||
$localestrings['en']['mf500'] = 'You can not move a forum to itself!'; | ||
$localestrings['en']['mf501'] = 'Are you sure you want to move all posts from this forum?\\\nMoving is irreversable! Make sure you have a backup!'; | ||
$localestrings['en']['mf502'] = 'Can not start the merge. Parameter values are not correct!'; | ||
$localestrings['en']['mf503'] = 'All the posts of the "%s" forum have been moved to "".'; | ||
|
||
$localestrings['nl'] = array(); | ||
|
||
/*---------------------------------------------------+ | ||
| commands to execute when installing this module | | ||
+----------------------------------------------------*/ | ||
|
||
$mod_install_cmds = array(); // commands to execute when installing this module | ||
|
||
/*---------------------------------------------------+ | ||
| commands to execute when uninstalling this module | | ||
+----------------------------------------------------*/ | ||
|
||
$mod_uninstall_cmds = array(); // commands to execute when uninstalling this module | ||
|
||
/*---------------------------------------------------+ | ||
| function to upgrade from a previous revision | | ||
+----------------------------------------------------*/ | ||
if (!function_exists('module_upgrade')) { | ||
function module_upgrade($current_version) { | ||
|
||
global $db_prefix, $locale; | ||
|
||
switch($current_version) { | ||
case "1.0.0": | ||
// Initial version. no upgrade actions for this release | ||
|
||
default: | ||
// do this at every upgrade | ||
} | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{***************************************************************************} | ||
{* ExiteCMS Content Management System *} | ||
{***************************************************************************} | ||
{* Copyright 2010 Exite BV, The Netherlands *} | ||
{* for support, please visit http://www.exitecms.org *} | ||
{*-------------------------------------------------------------------------*} | ||
{* Released under the terms & conditions of v2 of the GNU General Public *} | ||
{* License. For details refer to the included gpl.txt file or visit *} | ||
{* http://gnu.org *} | ||
{***************************************************************************} | ||
{* $Id:: modules.newsletters.tpl 2043 2008-11-16 14:25:18Z WanWizard $*} | ||
{*-------------------------------------------------------------------------*} | ||
{* Last modified by $Author:: WanWizard $*} | ||
{* Revision number $Rev:: 2043 $*} | ||
{***************************************************************************} | ||
{* *} | ||
{* Template for the admin installable module 'merge_forums' *} | ||
{* *} | ||
{***************************************************************************} | ||
{include file="_opentable.tpl" name=$_name title=$locale.mf400 state=$_state style=$_style} | ||
{if $error != ""} | ||
<p style="text-align:center;font-weight:bold;color:red;">{$error}</p> | ||
{/if} | ||
|
||
<form name='selectform' method='post' action='{$smarty.const.FUSION_SELF}{$aidlink}' onsubmit='return ValidateSelection(this);' > | ||
<table align='center' cellpadding='0' cellspacing='1' width='800' class='tbl-border'> | ||
<tr> | ||
<td align='left' class='tbl2'> | ||
<b>{$locale.mf401}</b> | ||
</td> | ||
<td align='left' class='tbl1'> | ||
<select name='forum_from_id' class='textbox' style='width:600px;'> | ||
{foreach from=$forums key=forum_id item=forum} | ||
<option value='{$forum_id}' {if $forum_id==$forum_from_id}selected="selected"{/if}>{$forum}</option> | ||
{/foreach} | ||
</select> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align='left' class='tbl2'> | ||
<b>{$locale.mf402}</b> | ||
</td> | ||
<td align='left' class='tbl1'> | ||
<select name='forum_to_id' class='textbox' style='width:600px;'> | ||
{foreach from=$forums key=forum_id item=forum} | ||
<option value='{$forum_id}' {if $forum_id==$forum_to_id}selected="selected"{/if}>{$forum}</option> | ||
{/foreach} | ||
</select> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align='left' class='tbl2'> | ||
<b>{$locale.mf403}</b> | ||
</td> | ||
<td align='left' class='tbl1'> | ||
<input type='text' name='prefix' value='{$prefix}' class='textbox' style='width:600px' /> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<center> | ||
<br /> | ||
<input type='submit' name='merge' value='{$locale.mf404}' class='button' onclick='return AreYouSure();'/> | ||
<br /> | ||
</center> | ||
</form> | ||
{include file="_closetable.tpl"} | ||
<script type="text/javascript"> | ||
{literal} | ||
function ValidateSelection(frm) { | ||
if (frm.forum_from_id.selectedIndex == frm.forum_to_id.selectedIndex) { | ||
alert('{/literal}{$locale.mf500}{literal}'); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
} | ||
function AreYouSure(frm) { | ||
return confirm('{/literal}{$locale.mf501}{literal}'); | ||
} | ||
{/literal} | ||
</script> | ||
{***************************************************************************} | ||
{* End of template *} | ||
{***************************************************************************} |