Hi All,
The below will add a Maintenance menu to the settings section of mibew messenger where at the moment will allow messages to be archived by number specified in the box Default: 30 day's.
Make sure you backup your files & database before implementing always use a proper file editor like
Notepad++ for doing file edits.
Do the following edits & upload the uncompressed attached rar files to the relevant directories or make the files if the rar goes missing or gets corrupt.
The following directories/files can be found inside the main messenger directory as
Default called webim, However, you may of changed its name.
Open:
libs/common.phpFind:?>
Add Above:// This function will archive ALL messages greater than ? days
function archive()
{
// date function minus ? days tells us what we need to select and move it over
$link = connect();
$sqlresult = mysql_query("UPDATE chatmessage CROSS JOIN chatconfig SET chatmessage.archive = '1' WHERE chatconfig.vckey = 'archive_date' AND chatmessage.dtmcreated < CURRENT_DATE - INTERVAL CAST(chatconfig.vcvalue AS UNSIGNED) DAY",$link) or die(' Query failed: '.mysql_error().": ".$query);
// This adds all information from chatmessage to archivechatmessage
$sqlArchive = mysql_query("INSERT INTO archivechatmessage SELECT * FROM chatmessage WHERE archive = '1'",$link) or die(' Query failed: '.mysql_error().": ".$query);
// This deletes from chatmessage
$sqlDelete = mysql_query("DELETE FROM chatmessage WHERE archive = '1'",$link) or die(' Query failed: '.mysql_error().": ".$query);
}
// end of archive function
Open:
libs/settings.phpFind: getlocal("page_settings.tab.themes") => $active != 3 ? "$webimroot/operator/themes.php" : "",
Add Below: getlocal("page_settings.tab.maintenance") => $active != 4 ? "$webimroot/operator/maintenance.php" : "",
Open:
locales/en/propertiesAt the very bottom add the following lines or add them into the list alphabetically.
maintenance.intro=Welcome to the maintenance page.
maintenance.archivemessagespage=Set amount of day's to archive, Default: 30
maintenance.archivemessagespagedo=What would you like to do?
maintenance.archivemessages=Archive messages older than set above.
maintenance.error=Field Correctly eg, 30 numeric only.
maintenance.noautherror=Not an administrator.
page_settings.tab.maintenance=Maintenance
The Default database name is webim, YOU! may of called it something else, make sure your in the correct database before running the following.
BACKUP the database Create the following table for the messages to be archived too .CREATE TABLE IF NOT EXISTS `archivechatmessage` (
`messageid` int(11) NOT NULL AUTO_INCREMENT,
`threadid` int(11) NOT NULL,
`ikind` int(11) NOT NULL,
`agentId` int(11) NOT NULL DEFAULT '0',
`tmessage` text NOT NULL,
`dtmcreated` datetime DEFAULT '0000-00-00 00:00:00',
`tname` varchar(64) DEFAULT NULL,
`archive` int(1) NOT NULL,
PRIMARY KEY (`messageid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Add the following.INSERT INTO `chatconfig` (`id`, `vckey`, `vcvalue`) VALUES (' ', 'archive_date', '30');
ALTER TABLE chatmessage ADD column archive int (1) DEFAULT 0;
Regards
Only if uploaded rar is missing or corrupt.Make a new file called
maintenance.php & upload to the operator directory.
<?php
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once('../libs/common.php');
require_once('../libs/operator.php');
require_once('../libs/settings.php');
// If box is checked, it grabs the box and then does the maintenance
$archive = isset($_POST['archive']);
if($archive == '1'){
archive();
}
$operator = check_login();
csrfchecktoken();
$page = array('agentId' => '');
$errors = array();
$options = array('archive_date');
loadsettings();
if ($settings['featuresversion'] != $featuresversion) {
$settings['featuresversion'] = $featuresversion;
update_settings();
}
foreach ($options as $opt) {
$page[$opt] = $settings[$opt];
}
if (isset($_POST['archivedate'])) {
$page['archive_date'] = getparam('archivedate');
if (!is_numeric($page['archive_date'])) {
$errors[] = wrong_field("maintenance.error");
}
if (count($errors) == 0) {
foreach ($options as $opt) {
$settings[$opt] = $page[$opt];
}
update_settings();
header("Location: $webimroot/operator/maintenance.php?stored");
exit;
}
}
if (isset($_POST['sent'])) {
if (is_capable($can_administrate, $operator)) {
foreach ($options as $opt) {
$settings[$opt] = verifyparam($opt, "/^on$/", "") == "on" ? "1" : "0";
}
update_settings();
header("Location: $webimroot/operator/maintenance.php?stored");
exit;
} else {
$errors[] = "maintenance.noautherror";
}
}
$page['formarchivedate'] = $page['archive_date'];
$page['canmodify'] = is_capable($can_administrate, $operator);
$page['stored'] = isset($_GET['stored']);
prepare_menu($operator);
setup_settings_tabs(4);
start_html_output();
require('../view/maintenance.php');
?>
Make a new file called
maintenance.php & upload to the view directory.
<?php
/*
* Copyright 2005-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once("inc_menu.php");
require_once("inc_tabbar.php");
$page['title'] = getlocal("settings.title");
$page['menuid'] = "settings";
function tpl_content() { global $page, $webimroot, $errors;
?>
<?php echo getlocal("maintenance.intro") ?>
<br />
<br />
<?php
require_once('inc_errors.php');
?>
<?php if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("settings.saved") ?></div>
<?php } ?>
<form name="maintenance" method="post" action="<?php echo $webimroot ?>/operator/maintenance.php">
<?php print_csrf_token_input() ?>
<div>
<?php print_tabbar(); ?>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm">
<div class="field">
<div class="flabel"><?php echo getlocal('maintenance.archivemessagespagedo') ?></div>
<br clear="all"/>
<div class="fvalue">
<input type="text" name="archivedate" size="4" value="<?php echo form_value('archivedate') ?>" class="formauth"/>
</div>
<div class="fdescr"> — <?php echo getlocal('maintenance.archivemessagespage') ?></div>
<br clear="all"/>
</div>
<div class="fbutton">
<input type="image" name="archivedate" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/>
</div>
</div>
</div>
<div class="formbottom"><div class="formbottomi"></div></div></div>
</div>
</form>
<br clear="all"/>
<form name="maintenance" method="post" action="<?php echo $webimroot ?>/operator/maintenance.php">
<?php print_csrf_token_input() ?>
<div>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm">
<div class="field">
<input type="checkbox" name="archive" value='1' /> — <?php echo getlocal('maintenance.archivemessages') ?>
</div>
</div>
<div class="fbutton">
<input type="image" name="save" value="" src='<?php echo $webimroot.getlocal("image.button.save") ?>' alt='<?php echo getlocal("button.save") ?>'/>
</div>
</div>
<div class="formbottom"><div class="formbottomi"></div></div></div>
</div>
</form>
<?php
} /* content */
require_once('inc_main.php');
?>