Skip to content
Permalink
Browse files

Fix for portal blocks not working. Removed COM_rdfCheck funciton

Fix for issue #795. Also Removed COM_rdfCheck since not working and
would only cache results for 1 hour. Using template cache instead now
since configurable.
  • Loading branch information...
eSilverStrike committed Jun 8, 2017
1 parent 23503ed commit 2943b0218ad6659a1be1b31e85fca70e8a3c8f5e
@@ -208,9 +208,6 @@ function overridePostdata(&$A)
if (isset($_POST['rdfurl'])) {
$A['rdfurl'] = Geeklog\Input::post('rdfurl'); // to be sanitized when saving
}
if (isset($_POST['rdfupdated'])) {
$A['rdfupdated'] = Geeklog\Input::fPost('rdfupdated');
}
if (isset($_POST['rdflimit'])) {
$A['rdflimit'] = (int) Geeklog\Input::fPost('rdflimit');
}
@@ -665,7 +662,6 @@ function cmpDynamicBlocks($a, $b)
* @param string $device Device type
* @param string $content Content of block
* @param string $rdfUrl URL to headline feed for portal blocks
* @param string $rdfUpdated Date RSS/RDF feed was last updated
* @param string $rdfLimit max. number of entries to import from feed
* @param string $phpBlockFn Name of php function to call to get content
* @param int $onLeft Flag indicates if block shows up on left or right
@@ -678,7 +674,7 @@ function cmpDynamicBlocks($a, $b)
* @param int $is_enabled Flag, indicates if block is enabled or not
* @return string HTML redirect or error message
*/
function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $content, $rdfUrl, $rdfUpdated, $rdfLimit, $phpBlockFn, $onLeft, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $is_enabled, $allow_autotags, $cache_time)
function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $content, $rdfUrl, $rdfLimit, $phpBlockFn, $onLeft, $owner_id, $group_id, $perm_owner, $perm_group, $perm_members, $perm_anon, $is_enabled, $allow_autotags, $cache_time)
{
global $_CONF, $_TABLES, $LANG21, $MESSAGE, $_USER;
@@ -736,13 +732,12 @@ function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $con
$allow_autotags = 0;
}
if ($cache_time < -1 || $cache_time == "") {
if ($cache_time < -1) {
$cache_time = $_CONF['default_cache_time_block'];
}
if ($type == 'portal') {
$content = '';
$rdfUpdated = '';
$phpBlockFn = '';
// get rid of possible extra prefixes (e.g. "feed://http://...")
@@ -759,7 +754,6 @@ function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $con
if ($type == 'gldefault') {
$content = '';
$rdfUrl = '';
$rdfUpdated = '';
$rdfLimit = 0;
$phpBlockFn = '';
}
@@ -776,12 +770,10 @@ function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $con
}
$content = '';
$rdfUrl = '';
$rdfUpdated = '';
$rdfLimit = 0;
}
if ($type == 'normal') {
$rdfUrl = '';
$rdfUpdated = '';
$rdfLimit = 0;
$phpBlockFn = '';
@@ -797,17 +789,16 @@ function saveblock($bid, $name, $title, $help, $type, $blockOrder, $device, $con
if (!empty($rdfUrl)) {
$rdfUrl = DB_escapeString($rdfUrl);
}
if (empty($rdfUpdated)) {
$rdfUpdated = 'CURRENT_TIMESTAMP';
}
$rdfUpdated = 'CURRENT_TIMESTAMP';
if ($bid > 0) {
DB_save($_TABLES['blocks'], 'bid,name,title,help,type,blockorder,device,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time,rdf_last_modified,rdf_etag', "$bid,'$name','$title','$help','$type','$blockOrder','$device','$content','$rdfUrl',$rdfUpdated,'$rdfLimit','$phpBlockFn',$onLeft,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$is_enabled,$allow_autotags,$cache_time,NULL,NULL");
} else {
$sql = array();
$sql['mysql'] = "INSERT INTO {$_TABLES['blocks']} "
. '(name,title,help,type,blockorder,device,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) '
. "VALUES ('$name','$title','$help','$type','$blockOrder','$device','$content','$rdfUrl',{$rdfUpdated},'$rdfLimit','$phpBlockFn',$onLeft,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$is_enabled,$allow_autotags,$cache_time)";
. "VALUES ('$name','$title','$help','$type','$blockOrder','$device','$content','$rdfUrl',$rdfUpdated,'$rdfLimit','$phpBlockFn',$onLeft,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$is_enabled,$allow_autotags,$cache_time)";
$sql['pgsql'] = "INSERT INTO {$_TABLES['blocks']} "
. '(bid,name,title,help,type,blockorder,device,content,rdfurl,rdfupdated,rdflimit,phpblockfn,onleft,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon,is_enabled,allow_autotags,cache_time) '
@@ -1013,15 +1004,15 @@ function deleteBlock($bid)
$device = Geeklog\Input::fPost('device', Device::ALL);
$content = Geeklog\Input::post('content', '');
$rdfurl = Geeklog\Input::post('rdfurl', ''); // to be sanitized later
$rdfupdated = Geeklog\Input::fPost('rdfupdated', '');
$rdflimit = (int) Geeklog\Input::fPost('rdflimit', 0);
$phpblockfn = Geeklog\Input::post('phpblockfn', '');
$is_enabled = Geeklog\Input::post('is_enabled', '');
$allow_autotags = Geeklog\Input::post('allow_autotags', '');
$cache_time = (int) Geeklog\Input::fPost('cache_time', $_CONF['default_cache_time_block']);
// $cache_time = (int) Geeklog\Input::fPost('cache_time', $_CONF['default_cache_time_block']); // Doesn't work as cache_time can be zero
$cache_time = (int) Geeklog\Input::fPost('cache_time');
$display .= saveblock(
$bid, $name, Geeklog\Input::post('title'), $help, Geeklog\Input::post('type'), $blockorder,
$device, $content, $rdfurl, $rdfupdated, $rdflimit, $phpblockfn, Geeklog\Input::post('onleft'),
$device, $content, $rdfurl, $rdflimit, $phpblockfn, Geeklog\Input::post('onleft'),
(int) Geeklog\Input::fPost('owner_id', 0), (int) Geeklog\Input::fPost('group_id', 0),
Geeklog\Input::post('perm_owner'), Geeklog\Input::post('perm_group'),
Geeklog\Input::post('perm_members'), Geeklog\Input::post('perm_anon'),
@@ -16,6 +16,9 @@ Future (2.1.3)
- [Bug] Censor Exact Match improved [Tom]
- [Bug] Links Plugin category links fixed when URL Rewrite is enabled [Mystralkk]
- [Bug] Language Manager search fixed [Mystralkk]
- [Bug] Fixed Blocks Cache Time could not be set to 0 [Tom]
- [Bug] Fixed Portal Blocks being able to use Cache Time [Tom]
- [Bug] Fixed displaying of portal blocks. Removed function COM_rdfCheck from lib-common.php since not needed anymore (uses cache time instead) [Tom]


March 1, 2017 (2.1.2)
@@ -81,7 +81,7 @@
<dd><input type="text" maxlength="3" value="{block_rdflimit}" name="rdflimit" id="admin-blockeditor-rdflimit" class="size1"{xhtml}></dd>

<dt><label for="admin-blockeditor-rdfupdated">{lang_lastrdfupdate}</label></dt>
<dd><input type="text" value="{block_rdfupdated}" name="rdfupdated" id="admin-blockeditor-rdfupdated" class="size3"{xhtml}></dd>
<dd>{block_rdfupdated}</dd>
</dl>
</fieldset>

@@ -82,7 +82,7 @@
<dd><input type="text" size="3" maxlength="3" value="{block_rdflimit}" name="rdflimit" id="admin-blockeditor-rdflimit" class="text"{xhtml}></dd>

<dt><label for="admin-blockeditor-rdfupdated">{lang_lastrdfupdate}</label></dt>
<dd><input type="text" size="19" value="{block_rdfupdated}" name="rdfupdated" id="admin-blockeditor-rdfupdated" class="text"{xhtml}></dd>
<dd>{block_rdfupdated}</dd>
</dl>
</fieldset>

@@ -4311,12 +4311,6 @@ function COM_formatBlock($A, $noBoxes = false, $noPosition = false)
$position = '';
}
if ($A['type'] === 'portal') {
if (COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit'])) {
$A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'");
}
}
if ($A['type'] === 'gldefault') {
$retval .= COM_showBlock($A['name'], $A['help'], $A['title'], $position);
} else {
@@ -4338,6 +4332,11 @@ function COM_formatBlock($A, $noBoxes = false, $noPosition = false)
}
}
}
if ($A['type'] === 'portal') {
COM_rdfImport($A['bid'], $A['rdfurl'], $A['rdflimit']);
$A['content'] = DB_getItem($_TABLES['blocks'], 'content', "bid = '{$A['bid']}'");
}
if (($A['type'] === 'phpblock') && !$noBoxes) {
if (!(($A['name'] === 'whosonline_block') && (DB_getItem($_TABLES['blocks'], 'is_enabled', "name='whosonline_block'") == 0))) {
@@ -4403,42 +4402,17 @@ function COM_formatBlock($A, $noBoxes = false, $noPosition = false)
return $retval;
}
/**
* Checks to see if it's time to import and RDF/RSS block again
* Updates RDF/RSS block if needed
*
* @param string $bid Block ID
* @param string $rdfUrl URL to get headlines from
* @param int $date Last time the headlines were imported
* @param int $maxHeadlines max. number of headlines to import
* @return boolean true = feed was updated, false = otherwise
* @see function COM_rdfImport
*/
function COM_rdfCheck($bid, $rdfUrl, $date, $maxHeadlines = 0)
{
$retval = false;
$nextUpdate = $date + 3600;
if ($nextUpdate < time()) {
COM_rdfImport($bid, $rdfUrl, $maxHeadlines);
$retval = true;
}
return $retval;
}
/**
* Syndication import function. Imports headline data to a portal block.
* Rewritten December 19th 2004 by Michael Jervis (mike AT fuckingbrit DOT com).
* Now utilises a Factory Pattern to open a URL and automaticaly retreive a feed
* Now utilises a Factory Pattern to open a URL and automaticaly retrieve a feed
* object populated with feed data. Then import it into the portal block.
*
* @param string $bid Block ID
* @param string $rdfUrl URL to get content from
* @param int $maxHeadlines Maximum number of headlines to display
* @return void
* @see function COM_rdfCheck
*/
*/
function COM_rdfImport($bid, $rdfUrl, $maxHeadlines = 0)
{
global $_CONF, $_TABLES, $LANG21;

0 comments on commit 2943b02

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.