Revision 2069
Added by darkviper almost 12 years ago
| branches/2.8.x/CHANGELOG | ||
|---|---|---|
| 11 | 11 |
! = Update/Change |
| 12 | 12 |
=============================================================================== |
| 13 | 13 |
|
| 14 |
03 Jan-2014 Build 2069 Manuela v.d.Decken(DarkViper) |
|
| 15 |
! module News: some little fixes, implementation of AccessFile completed. |
|
| 14 | 16 |
03 Jan-2014 Build 2068 Manuela v.d.Decken(DarkViper) |
| 15 | 17 |
# admin/users/user_list corrected multibyte handling |
| 16 | 18 |
# Droplet - iEditThisPage: copy/past error fixed (object reference) |
| branches/2.8.x/wb/admin/interface/version.php | ||
|---|---|---|
| 51 | 51 |
|
| 52 | 52 |
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled) |
| 53 | 53 |
if(!defined('VERSION')) define('VERSION', '2.8.4');
|
| 54 |
if(!defined('REVISION')) define('REVISION', '2068');
|
|
| 54 |
if(!defined('REVISION')) define('REVISION', '2069');
|
|
| 55 | 55 |
if(!defined('SP')) define('SP', '');
|
| branches/2.8.x/wb/modules/news/view.php | ||
|---|---|---|
| 23 | 23 |
} |
| 24 | 24 |
/* -------------------------------------------------------- */ |
| 25 | 25 |
global $post_id, $post_section,$TEXT,$MESSAGE; |
| 26 |
$sMediaUrl = WB_URL.MEDIA_DIRECTORY; |
|
| 27 |
|
|
| 28 | 26 |
// load module language file |
| 29 | 27 |
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php'; |
| 30 | 28 |
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang ); |
| branches/2.8.x/wb/modules/news/upgrade.php | ||
|---|---|---|
| 188 | 188 |
. 'WHERE `published_when`=0 OR `published_when`>`posted_when`'; |
| 189 | 189 |
$oDb->query($sql); |
| 190 | 190 |
} |
| 191 |
/* --- insert SYSVAR placeholders and repair already existing ------------------------- */ |
|
| 192 |
$sql = 'SELECT `post_id`, `content_long`, `content_short` ' |
|
| 193 |
. 'FROM `'.$oDb->TablePrefix.'mod_news_posts` '; |
|
| 194 |
if (($oEntrySet = $oDb->doQuery($sql))) {
|
|
| 195 |
$iRecords = 0; |
|
| 196 |
$iReplaced = 0; |
|
| 197 |
$aSearch = array( '/\{SYSVAR\:MEDIA_REL\}[\/\\\\]?/sU',
|
|
| 198 |
'/\{SYSVAR\:WB_URL\}[\/\\\\]?/sU',
|
|
| 199 |
'/(\{SYSVAR\:AppUrl\.MediaDir\})[\/\\\\]?/sU',
|
|
| 200 |
'/(\{SYSVAR\:AppUrl\})[\/\\\\]?/sU'
|
|
| 201 |
); |
|
| 202 |
$aReplace = array( '{SYSVAR:AppUrl.MediaDir}', '{SYSVAR:AppUrl}', '\1', '\1' );
|
|
| 203 |
while (($aEntry = $oEntrySet->fetchRow(MYSQL_ASSOC))) {
|
|
| 204 |
$iCount = 0; |
|
| 205 |
$aSubject = array($aEntry['content_long'], $aEntry['content_short']); |
|
| 206 |
$aNewContents = preg_replace($aSearch, $aReplace, $aSubject, -1, $iCount); |
|
| 207 |
if ($iCount > 0) {
|
|
| 208 |
$iReplaced += $iCount; |
|
| 209 |
$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` ' |
|
| 210 |
. 'SET `content_long`=\''.$oDb->escapeString($aNewContents[0]).'\', ' |
|
| 211 |
. '`content_short`=\''.$oDb->escapeString($aNewContents[1]).'\' ' |
|
| 212 |
. 'WHERE `post_id`='.$aEntry['post_id']; |
|
| 213 |
$oDb->doQuery($sql); |
|
| 214 |
$iRecords++; |
|
| 215 |
} |
|
| 216 |
} |
|
| 217 |
$msg[] = '['.$iRecords.'] records with ['.$iReplaced.'] SYSVAR placeholder(s) repaired'." $OK"; |
|
| 218 |
} |
|
| 219 |
try {
|
|
| 220 |
$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '; |
|
| 221 |
$sql .= 'SET `content` = REPLACE(`content`, \'"'.$oReg->AppPath.$oReg->MediaDir.'\', \'"{SYSVAR:AppPath.MediaDir}\')';
|
|
| 222 |
$oDb->doQuery($sql); |
|
| 223 |
$msg[] = 'Change internal absolute Media links into SYSVAR placeholders'." $OK"; |
|
| 224 |
} catch(WbDatabaseException $e) {
|
|
| 225 |
$msg[] = ''.$oDb->get_error(); |
|
| 226 |
} |
|
| 227 |
try {
|
|
| 228 |
$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '; |
|
| 229 |
$sql .= 'SET `content` = REPLACE(`content`, \'"'.$oReg->AppPath.'\', \'"{SYSVAR:AppPath}\')';
|
|
| 230 |
$oDb->doQuery($sql); |
|
| 231 |
$msg[] = 'Change internal absolute links into SYSVAR placeholders'." $OK"; |
|
| 232 |
} catch(WbDatabaseException $e) {
|
|
| 233 |
$msg[] = ''.$oDb->get_error(); |
|
| 234 |
} |
|
| 191 | 235 |
/* --- rebuild all access files ------------------------------------------------------- */ |
| 192 | 236 |
$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
|
| 193 | 237 |
$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED); |
| branches/2.8.x/wb/modules/news/modify_post.php | ||
|---|---|---|
| 65 | 65 |
$sMediaUrl = WB_URL.MEDIA_DIRECTORY; |
| 66 | 66 |
// Get header and footer |
| 67 | 67 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id; |
| 68 |
if($oPostRes = $database->query($sql)){
|
|
| 68 |
if (($oPostRes = $database->query($sql))) {
|
|
| 69 | 69 |
$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC); |
| 70 |
$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
|
|
| 71 |
$aPostRec['content_long'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
|
|
| 70 |
$sFilterApi = WB_PATH.'/modules/output_filter/OutputFilterApi.php'; |
|
| 71 |
if (is_readable($sFilterApi)) {
|
|
| 72 |
require_once($sFilterApi); |
|
| 73 |
$aPostRec['content_short'] = OutputFilterApi('ReplaceSysvar', $aPostRec['content_short']);
|
|
| 74 |
$aPostRec['content_long'] = OutputFilterApi('ReplaceSysvar', $aPostRec['content_long']);
|
|
| 75 |
} |
|
| 72 | 76 |
} |
| 73 | 77 |
//$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
|
| 74 | 78 |
|
| branches/2.8.x/wb/modules/news/save_post.php | ||
|---|---|---|
| 16 | 16 |
*/ |
| 17 | 17 |
error_reporting(E_ALL); |
| 18 | 18 |
require('../../config.php');
|
| 19 |
require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php"); |
|
| 19 |
$oReg = WbAdaptor::getInstance(); |
|
| 20 |
$oDb = WbDatabase::getInstance(); |
|
| 21 |
$sNewsLinkSubdir = 'posts/'; |
|
| 22 |
// require_once($oReg->AppPath."include/jscalendar/jscalendar-functions.php"); |
|
| 20 | 23 |
// Get post_id |
| 21 |
if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
|
|
| 22 |
header("Location: ".ADMIN_URL."/pages/index.php");
|
|
| 24 |
if (!isset($_POST['post_id']) || !($post_id = intval($_POST['post_id']))) {
|
|
| 25 |
header("Location: ".$oReg->AcpUrl.'pages/index.php');
|
|
| 23 | 26 |
exit( 0 ); |
| 24 |
}else {
|
|
| 25 |
$post_id = intval($_POST['post_id']); |
|
| 26 |
} |
|
| 27 |
|
|
| 27 |
} |
|
| 28 |
// if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
|
|
| 29 |
// header("Location: ".$oReg->AcpUrl.'pages/index.php');
|
|
| 30 |
// exit( 0 ); |
|
| 31 |
// }else {
|
|
| 32 |
// $post_id = intval($_POST['post_id']); |
|
| 33 |
// } |
|
| 28 | 34 |
$admin_header = false; |
| 29 | 35 |
// Tells script to update when this page was last updated |
| 30 | 36 |
$update_when_modified = true; |
| 31 | 37 |
// Include WB admin wrapper script |
| 32 |
require(WB_PATH.'/modules/admin.php');
|
|
| 33 |
|
|
| 38 |
require($oReg->AppPath.'modules/admin.php');
|
|
| 39 |
$oReg->getWbConstants(); |
|
| 34 | 40 |
if (!$admin->checkFTAN()) {
|
| 35 | 41 |
$admin->print_header(); |
| 36 | 42 |
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], |
| 37 |
ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
|
|
| 43 |
$oReg->AcpUrl.'pages/modify.php?page_id='.$page_id );
|
|
| 38 | 44 |
} |
| 39 | 45 |
$admin->print_header(); |
| 40 | 46 |
|
| 41 | 47 |
// Validate all fields |
| 42 |
$title = $admin->StripCodeFromText($admin->get_post('title'));
|
|
| 43 |
$commenting = $admin->StripCodeFromText($admin->get_post('commenting'));
|
|
| 44 |
$active = intval($admin->get_post('active'));
|
|
| 45 |
$old_link = $admin->StripCodeFromText($admin->get_post('link'));
|
|
| 46 |
$group_id = intval($admin->get_post('group'));
|
|
| 47 |
|
|
| 48 | 48 |
if($admin->get_post('title') == '' AND $admin->get_post('url') == '') {
|
| 49 |
$recallUrl = WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.
|
|
| 49 |
$recallUrl = $oReg->AppUrl.'modules/news/modify_post.php?page_id='.$page_id.
|
|
| 50 | 50 |
'§ion_id='.$section_id.'&post_id='.$admin->getIDKEY($post_id); |
| 51 | 51 |
$admin->print_error($MESSAGE['GENERIC_FILL_IN_ALL'], $recallUrl); |
| 52 | 52 |
} else {
|
| 53 |
$short = $admin->get_post('short');
|
|
| 54 |
$long = $admin->get_post('long');
|
|
| 55 |
$short = $admin->ReplaceAbsoluteMediaUrl($short); |
|
| 56 |
$long = $admin->ReplaceAbsoluteMediaUrl($long); |
|
| 53 |
$short = $admin->ReplaceAbsoluteMediaUrl($admin->get_post('short'));
|
|
| 54 |
$long = $admin->ReplaceAbsoluteMediaUrl($admin->get_post('long'));
|
|
| 57 | 55 |
} |
| 58 |
|
|
| 56 |
$title = $admin->StripCodeFromText($admin->get_post('title'));
|
|
| 57 |
$commenting = $admin->StripCodeFromText($admin->get_post('commenting'));
|
|
| 58 |
$active = intval($admin->get_post('active'));
|
|
| 59 |
$group_id = intval($admin->get_post('group'));
|
|
| 59 | 60 |
// Include WB functions file |
| 60 |
require(WB_PATH.'/framework/functions.php'); |
|
| 61 |
// Work-out what the link should be |
|
| 62 |
$sNewFile = page_filename($title).PAGE_SPACER.$post_id; |
|
| 63 |
$newLink = '/posts/'.$sNewFile; |
|
| 64 |
$sPagesPath = WB_PATH.PAGES_DIRECTORY; |
|
| 65 |
$sBackUrl = ADMIN_URL.'/pages/modify.php?page_id='.$page_id; |
|
| 66 |
$sNewFilename = $sPagesPath.$newLink.PAGE_EXTENSION; |
|
| 67 |
$sOldFilename = $sPagesPath.$old_link.PAGE_EXTENSION; |
|
| 68 |
|
|
| 61 |
require($oReg->AppPath.'framework/functions.php'); |
|
| 62 |
// Work-out all needed path and filenames |
|
| 63 |
$sAccessFsileRootPath = $oReg->AppPath.$oReg->PagesDir.$sNewsLinkSubdir; |
|
| 64 |
$sOldLink = preg_replace('/^\/?'.preg_quote($sNewsLinkSubdir, '/').'/', '', str_replace('\\', '/', $admin->StripCodeFromText($admin->get_post('link'))));
|
|
| 65 |
$sOldFilename = $sAccessFileRootPath.$sOldLink.$oReg->PageExtension; |
|
| 66 |
$sNewLink = page_filename($title).$oReg->PageSpacer.$post_id; |
|
| 67 |
$sNewFilename = $sAccessFileRootPath.$sNewLink.$oReg->PageExtension; |
|
| 68 |
$sBackUrl = $oReg->AcpUrl.'pages/modify.php?page_id='.$page_id; |
|
| 69 | 69 |
// get publisedwhen and publisheduntil |
| 70 |
$publishedwhen = jscalendar_to_timestamp($admin->get_post_escaped('publishdate'));
|
|
| 71 |
if($publishedwhen == '' || $publishedwhen < 1) { $publishedwhen=0; }
|
|
| 72 |
$publisheduntil = jscalendar_to_timestamp($admin->get_post_escaped('enddate'), $publishedwhen);
|
|
| 73 |
if($publisheduntil == '' || $publisheduntil < 1) { $publisheduntil=0; }
|
|
| 74 |
// Update row |
|
| 75 |
$sql = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` '
|
|
| 70 |
$x = strtotime(preg_replace('/^(\d{1,2})\.(\d{1,2})\.(\d{2,4})(.*)$/s', '\2/\1/\3\4', $admin->get_post_escaped('publishdate')));
|
|
| 71 |
$publishedwhen = $x ? $x : 0;
|
|
| 72 |
$x = strtotime(preg_replace('/^(\d{1,2})\.(\d{1,2})\.(\d{2,4})(.*)$/s', '\2/\1/\3\4', $admin->get_post_escaped('enddate')), $publishedwhen);
|
|
| 73 |
$publisheduntil = $x ? $x : 0;
|
|
| 74 |
// Update row in database
|
|
| 75 |
$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
|
|
| 76 | 76 |
. 'SET `group_id`='.(int)$group_id.', ' |
| 77 |
. '`title`=\''.$database->escapeString($title).'\', '
|
|
| 78 |
. '`link`=\''.$database->escapeString($newLink).'\', '
|
|
| 79 |
. '`content_short`=\''.$database->escapeString($short).'\', '
|
|
| 80 |
. '`content_long`=\''.$database->escapeString($long).'\', '
|
|
| 81 |
. '`commenting`=\''.$database->escapeString($commenting).'\', '
|
|
| 77 |
. '`title`=\''.$oDb->escapeString($title).'\', '
|
|
| 78 |
. '`link`=\''.$oDb->escapeString('/'.$sNewsLinkSubdir.$sNewLink).'\', '
|
|
| 79 |
. '`content_short`=\''.$oDb->escapeString($short).'\', '
|
|
| 80 |
. '`content_long`=\''.$oDb->escapeString($long).'\', '
|
|
| 81 |
. '`commenting`=\''.$oDb->escapeString($commenting).'\', '
|
|
| 82 | 82 |
. '`active`='.(int)$active.', ' |
| 83 | 83 |
. '`published_when`='.(int)$publishedwhen.', ' |
| 84 | 84 |
. '`published_until`='.(int)$publisheduntil.', ' |
| 85 | 85 |
. '`posted_when`='.time().', ' |
| 86 | 86 |
. '`posted_by`='.(int)$admin->get_user_id().' ' |
| 87 | 87 |
. 'WHERE `post_id`='.(int)$post_id; |
| 88 |
if( $database->query($sql) ) {
|
|
| 89 |
// create new accessfile |
|
| 90 |
$sDoWhat = (($newLink == $old_link) && (file_exists($sNewFilename))) ? "nothing" : "action"; |
|
| 91 |
if($sDoWhat == "action") {
|
|
| 92 |
$sDoWhat = (($sDoWhat == "action") && file_exists($sOldFilename)) ? "update" : "create"; |
|
| 93 |
} |
|
| 94 |
|
|
| 88 |
if ($oDb->query($sql)) {
|
|
| 89 |
// create new accessfile |
|
| 90 |
$sDoWhat = (($sNewLink == $sOldLink) && (file_exists($sNewFilename))) |
|
| 91 |
? "nothing" |
|
| 92 |
: ((file_exists($sOldFilename)) ? "update" : "create"); |
|
| 95 | 93 |
switch($sDoWhat) |
| 96 | 94 |
{
|
| 97 | 95 |
case "update": |
| 98 | 96 |
try {
|
| 99 |
// prozedural rename accessfile if link has changed, has to be changed to accessfile class when fixed |
|
| 100 |
if(($sNewFilename != $sOldFilename) && (is_writable($sOldFilename))) {
|
|
| 101 |
if(!rename($sOldFilename,$sNewFilename)) {
|
|
| 102 |
$admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'].' - '.$oldLink,$sBackUrl); |
|
| 103 |
} |
|
| 104 |
} |
|
| 105 |
// $oAF = new AccessFile($sOldFilename, $page_id);
|
|
| 106 |
// $oAF->rename($sNewFile);
|
|
| 107 |
// unset($oAF);
|
|
| 97 |
//// prozedural rename accessfile if link has changed, has to be changed to accessfile class when fixed
|
|
| 98 |
// if(($sNewFilename != $sOldFilename) && (is_writable($sOldFilename))) {
|
|
| 99 |
// if(!rename($sOldFilename,$sNewFilename)) {
|
|
| 100 |
// $admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'].' - '.$oldLink,$sBackUrl);
|
|
| 101 |
// }
|
|
| 102 |
// }
|
|
| 103 |
$oAF = new AccessFile($sAccessFileRootPath, $sOldLink, $page_id);
|
|
| 104 |
$oAF->rename($sNewLink);
|
|
| 105 |
unset($oAF); |
|
| 108 | 106 |
}catch(AccessFileException $e) {
|
| 109 | 107 |
$admin->print_error($e,$sBackUrl); |
| 110 | 108 |
} |
| 111 | 109 |
break; |
| 112 | 110 |
case "create": |
| 113 | 111 |
try {
|
| 114 |
$oAF = new AccessFile($sNewFilename, $page_id);
|
|
| 112 |
$oAF = new AccessFile($sAccessFileRootPath, $sNewLink, $page_id);
|
|
| 115 | 113 |
$oAF->addVar('section_id', $section_id, AccessFile::VAR_INT);
|
| 116 | 114 |
$oAF->addVar('post_id', $post_id, AccessFile::VAR_INT);
|
| 117 | 115 |
$oAF->addVar('post_section', $section_id, AccessFile::VAR_INT);
|
| ... | ... | |
| 124 | 122 |
} |
| 125 | 123 |
} |
| 126 | 124 |
// Check if there is a db error, otherwise say successful |
| 127 |
if($database->is_error()) {
|
|
| 128 |
$recallUrl = WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.
|
|
| 125 |
if($oDb->is_error()) {
|
|
| 126 |
$recallUrl = $oReg->AppUrl.'modules/news/modify_post.php?page_id='.$page_id.
|
|
| 129 | 127 |
'§ion_id='.$section_id.'&post_id='.$admin->getIDKEY($post_id); |
| 130 |
$admin->print_error($database->get_error(), $recallUrl);
|
|
| 128 |
$admin->print_error($oDb->get_error(), $recallUrl);
|
|
| 131 | 129 |
}else {
|
| 132 |
$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
|
|
| 130 |
$admin->print_success($TEXT['SUCCESS'], $oReg->AcpUrl.'pages/modify.php?page_id='.$page_id);
|
|
| 133 | 131 |
} |
| 134 | 132 |
// Print admin footer |
| 135 |
$admin->print_footer(); |
|
| 133 |
$admin->print_footer(); |
|
Also available in: Unified diff
! module News: some little fixes, implementation of AccessFile completed.