|
From: <dac...@us...> - 2007-09-03 08:15:42
|
Revision: 53
http://thevr.svn.sourceforge.net/thevr/?rev=53&view=rev
Author: dachebodt
Date: 2007-09-02 23:28:24 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
mod version is now installed in config and compared against mod files in directory, allowing for posibility to update modules.
Made other fixes to allow complete disabling of left and right columns
Modified Paths:
--------------
mods/cms/trunk/modules/blocks/acp_blocks.php
mods/cms/trunk/modules/blocks/functions_blocks.php
mods/cms/trunk/modules/mods/acp_mods.php
mods/cms/trunk/modules/mods/info/mods_info.php
mods/cms/trunk/modules/mods/language/en/mods.php
mods/cms/trunk/modules/mods/template/acp_mods.html
mods/cms/trunk/styles/prosilver/template/layout.html
Modified: mods/cms/trunk/modules/blocks/acp_blocks.php
===================================================================
--- mods/cms/trunk/modules/blocks/acp_blocks.php 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/blocks/acp_blocks.php 2007-09-03 06:28:24 UTC (rev 53)
@@ -25,6 +25,7 @@
global $config, $cache, $db, $user, $auth, $template, $mtemplate, $phpbb_root_path, $phpbb_admin_path, $phpEx;
include($phpbb_root_path . "modules/blocks/constants.$phpEx");
+ include($phpbb_root_path . "modules/blocks/functions_blocks_admin.$phpEx");
$action = request_var('action', '');
$style_id = request_var('style', $config['default_style']);
@@ -126,7 +127,7 @@
if($sql_ary['name'] && $sql_ary['module'])
{
$db->sql_query($sql);
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
$bid = ($bid) ? $bid : $db->sql_nextid();
$this->save_block_config($bid, $sql_ary['name'], $sql_ary['module']);
@@ -163,7 +164,7 @@
if($pid)
{
$sql = 'UPDATE ' . BLOCK_POSITIONS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE pid = $pid";
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
}
else
{
@@ -202,7 +203,7 @@
{
case 'delete':
- $sql = 'SELECT name, module, weight, style
+ $sql = 'SELECT name, module, position, weight, style
FROM ' . BLOCKS_TABLE . "
WHERE bid = $bid";
$result = $db->sql_query($sql);
@@ -217,11 +218,12 @@
$sql = 'UPDATE ' . BLOCKS_TABLE . '
SET weight = weight - 1
- WHERE weight > ' . $row['weight'] . "
- AND style = $style_id";
+ WHERE weight > ' . $row['weight'] . '
+ AND position = ' . $row['position'] . '
+ AND style = ' . $row['style'];
$db->sql_query($sql);
- $this->remove_cache_file();
- $this->delete_block_config($bid);
+ remove_cache_file($this->cms_mod_list);
+ delete_block_config($bid);
break;
@@ -246,7 +248,7 @@
SET weight = $nweight
WHERE bid = $bid";
$db->sql_query($sql);
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
break;
@@ -257,7 +259,7 @@
$sql = 'UPDATE ' . BLOCKS_TABLE . " SET status = '$status' WHERE bid = $bid";
$db->sql_query($sql);
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
break;
@@ -445,7 +447,7 @@
$sql = 'DELETE FROM ' . BLOCK_POSITIONS_TABLE . " WHERE pid = $pid";
$db->sql_query($sql);
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
}
redirect($this->u_action);
}
@@ -460,7 +462,7 @@
$sql = 'UPDATE ' . BLOCK_POSITIONS_TABLE . " SET status = '$status' WHERE pid = $pid";
$db->sql_query($sql);
- $this->remove_cache_file();
+ remove_cache_file($this->cms_mod_list);
break;
@@ -620,16 +622,6 @@
return $options;
}
- function remove_cache_file()
- {
- global $cache;
-
- foreach($this->cms_mod_list as $i => $module)
- {
- $cache->destroy('_block_' . $module['mode']);
- }
- }
-
function generate_xmods($xmods_ary)
{
global $mtemplate;
@@ -747,22 +739,10 @@
);
}
// just remove old values and replace
- $this->delete_block_config($bid);
+ delete_block_config($bid);
$db->sql_multi_insert(BLOCKS_CONFIG_TABLE, $sql_ary);
$cache->destroy('_block_config');
}
-
- function delete_block_config($bid)
- {
- global $db, $cache;
-
- if($bid)
- {
- $sql = 'DELETE FROM ' . BLOCKS_CONFIG_TABLE . " WHERE bid = $bid";
- $db->sql_query($sql);
- $cache->destroy('_block_config');
- }
- }
}
?>
\ No newline at end of file
Modified: mods/cms/trunk/modules/blocks/functions_blocks.php
===================================================================
--- mods/cms/trunk/modules/blocks/functions_blocks.php 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/blocks/functions_blocks.php 2007-09-03 06:28:24 UTC (rev 53)
@@ -96,7 +96,7 @@
$style = isset($this->block_cache[$user->data['user_style']]) ? $user->data['user_style'] : $config['default_style'];
$positions_ary = $this->block_cache[$style];
- if(!$is_front)
+ if(!$is_front && sizeof($positions_ary))
{
$active_pos = array();
foreach($positions_ary as $i => $position)
@@ -121,9 +121,20 @@
}
$db->sql_freeresult($result);
+ if(!sizeof($positions_ary))
+ {
+ return;
+ }
+
foreach($positions_ary as $i => $position)
{
$blocks = $position['blocks'];
+
+ if(!sizeof($blocks))
+ {
+ continue;
+ }
+
if($is_front || $position['props']['type'])
{
foreach($blocks as $i => $row)
Modified: mods/cms/trunk/modules/mods/acp_mods.php
===================================================================
--- mods/cms/trunk/modules/mods/acp_mods.php 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/mods/acp_mods.php 2007-09-03 06:28:24 UTC (rev 53)
@@ -197,7 +197,9 @@
closedir($dh);
$db_mods[] = $mod;
- $message = 'module installed successfully in ' . implode(', ', $affected_classes);
+
+ $message = sprintf($user->lang['MOD_INSTALLED'], $mod, implode(', ', array_unique($affected_classes)));
+ set_config($mod . '_version', $dir_mods[$mod]['mod_vers']);
}
$template->assign_vars(array(
@@ -207,8 +209,53 @@
break;
+ case 'update':
+
+ if(in_array($mod, $db_mods) && $dir_mods[$mod]['mod_vers'] != $config[$mod . '_version'])
+ {
+ $update = false;
+ $dh = opendir($directory . "$mod/info/");
+
+ while (($file = readdir($dh)) !== false)
+ {
+ $file_ary = explode('_', $file);
+ $module_class = $file_ary[0];
+
+ if(in_array($module_class, $this->classrow))
+ {
+ include($directory . "$mod/info/$file");
+
+ $file = str_replace(".$phpEx", '', $file);
+ $basename = str_replace($module_class . '_', '', $file);
+
+ $c_class = $module_class . '_' . $basename . '_info';
+ $instance = new $c_class();
+
+ if(method_exists($instance, 'update'))
+ {
+ $instance->update();
+ $update = true;
+ }
+ }
+ }
+
+ $message = ($update) ? 'MOD_UPDATED_DB' : 'MOD_UPDATED_NO_DB';
+ $message = sprintf($user->lang[$message], $mod);
+ set_config($mod . '_version', $dir_mods[$mod]['mod_vers']);
+ }
+
+ $template->assign_vars(array(
+ 'S_WARNING' => true,
+ 'WARNING_MSG' => $message
+ ));
+
+ break;
+
case 'uninstall':
+ include($phpbb_root_path . "modules/blocks/constants.$phpEx");
+ include($phpbb_root_path . "modules/blocks/functions_blocks_admin.$phpEx");
+
$message = $user->lang['MOD_REQUIRED'];
if($dir_mods[$mod]['mod_type'] != 'core' && !in_array($mod, $required))
{
@@ -243,7 +290,7 @@
// which of these parents is being used by another module?
$sql = 'SELECT DISTINCT parent_id
FROM ' . MODULES_TABLE . "
- WHERE module_dir <> ''";
+ WHERE module_dir = '" . $db->sql_escape($mod) . "'";
$result = $db->sql_query($sql);
$active_parents = array();
@@ -253,6 +300,9 @@
}
$db->sql_freeresult($result);
+ $parent_ids = array_unique($parent_ids);
+ $active_parents = array_unique($active_parents);
+
$parent_ary = array_diff($parent_ids, $active_parents);
// remove parents
@@ -269,12 +319,18 @@
$_module->remove_cache_file();
}
+ $ver = $mod . '_version';
+ $sql = 'DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = '$ver'";
+ $db->sql_query($sql);
+ $cache->destroy('config');
+ delete_blocks($mod);
+
unset($db_mods[array_search($mod, $db_mods)]);
- $message = (sizeof($errors) > 0) ? $error : 'module successfully uninstalled from ' . implode(',', $affected_classes);
+ $message = (sizeof($errors) > 0) ? $error : sprintf($user->lang['MOD_UNINSTALLED'], $mod, implode(', ', $affected_classes));
}
else
{
- confirm_box(false, 'DELETE_MODULE', build_hidden_fields(array(
+ confirm_box(false, $user->lang['DELETE_MODULE'], build_hidden_fields(array(
'i' => $id,
'mode' => $mode,
'm' => $mod,
@@ -282,6 +338,10 @@
)));
}
}
+ else
+ {
+ trigger_error('MOD_REQUIRED');
+ }
$this->get_modules_list();
$template->assign_vars(array(
@@ -307,7 +367,7 @@
'MOD_AUTHOR' => $dir_mods[$mod]['mod_author'],
'MOD_CONTACT' => $dir_mods[$mod]['mod_contact'],
'MOD_DISP_NAME' => $dir_mods[$mod]['mod_disp_name'],
- 'MOD_DEPENDENTS' => $dir_mods[$mod]['mod_dependents'],
+ 'MOD_DEPENDENTS' => ($dir_mods[$mod]['mod_dependents']) ? $dir_mods[$mod]['mod_dependents'] : $user->lang['NONE'],
'MOD_COMPAT' => $dir_mods[$mod]['mod_compat'],
'MOD_ACTION' => $m_action,
@@ -324,9 +384,18 @@
ksort($dir_mods);
foreach($dir_mods as $mod => $data)
{
+ $vers = $mod . '_version';
$url = $this->u_action . '&m=' . $mod;
- $m_action = (!in_array($mod, $db_mods)) ? '<a href="' . $url . '&action=install">' . $user->lang['ENABLE'] . '</a>' : ((in_array($mod, $required) || $data['mod_type'] == 'core') ? $user->lang['MOD_REQUIRED'] : '<a href="' . $url . '&action=uninstall">' . $user->lang['DISABLE'] . '</a>');
+ if(in_array($mod, $db_mods))
+ {
+ $m_action = ($config[$vers] == $data['mod_vers']) ? ((in_array($mod, $required) || $data['mod_type'] == 'core') ? $user->lang['MOD_REQUIRED'] : '<a href="' . $url . '&action=uninstall">' . $user->lang['DISABLE'] . '</a>') : '<a href="' . $url . '&action=update">' . $user->lang['UPDATE'] . '</a>';
+ }
+ else
+ {
+ $m_action = '<a href="' . $url . '&action=install">' . $user->lang['ENABLE'] . '</a>';
+ }
+
$mtemplate->assign_block_vars('modules', array(
'MOD_NAME' => $data['mod_disp_name'],
'MOD_VERSION' => $data['mod_vers'],
Modified: mods/cms/trunk/modules/mods/info/mods_info.php
===================================================================
--- mods/cms/trunk/modules/mods/info/mods_info.php 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/mods/info/mods_info.php 2007-09-03 06:28:24 UTC (rev 53)
@@ -21,7 +21,7 @@
'mod_contact' => '',
'mod_url' => '',
'mod_vers' => '1.00',
- 'mod_compat' => 'RC1',
+ 'mod_compat' => 'RC5',
'mod_type' => 'core',
'mod_scope' => 'acp',
'mod_demo_url' => '',
Modified: mods/cms/trunk/modules/mods/language/en/mods.php
===================================================================
--- mods/cms/trunk/modules/mods/language/en/mods.php 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/mods/language/en/mods.php 2007-09-03 06:28:24 UTC (rev 53)
@@ -50,6 +50,14 @@
'MOD_DEPENDENTS' => 'Dependents',
'MOD_COMPAT' => 'Compatibility',
'MOD_CONFIG' => 'Config',
+ 'MOD_INFO' => 'Mod Info',
+ 'NONE' => 'None',
+
+ 'DELETE_MODULE' => 'Are you sure you want to remove this module?',
+ 'MOD_INSTALLED' => 'Module [%1$s] installed successfully in %2$s',
+ 'MOD_UNINSTALLED' => 'Module [%1$s] removed successfully from %2$s but you may have to remove the database manually.',
+ 'MOD_UPDATED_DB' => 'Module [%s] successfully updated',
+ 'MOD_UPDATED_NO_DB' => 'Module [%s] successfully updated but there were no update instructions. Please check the module package for any do-it-yourself instructions.',
));
?>
\ No newline at end of file
Modified: mods/cms/trunk/modules/mods/template/acp_mods.html
===================================================================
--- mods/cms/trunk/modules/mods/template/acp_mods.html 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/modules/mods/template/acp_mods.html 2007-09-03 06:28:24 UTC (rev 53)
@@ -3,9 +3,11 @@
<tr>
<th colspan="2">{L_MOD_INFO}</th>
</tr>
+ <!-- IF MOD_IMAGE -->
<tr class="row2">
<td><div style="float:right"><img src="{MOD_IMAGE}" alt="" height="35" width="35"></div></td>
</tr>
+ <!-- ENDIF -->
<tr class="row2">
<td><strong>{L_MOD_DISP_NAME}</strong></td><td>{MOD_DISP_NAME}</td>
</tr>
@@ -34,10 +36,10 @@
<td><strong>{L_MOD_DEPENDENTS}</strong></td><td>{MOD_DEPENDENTS}</td>
</tr>
<tr>
- <td class="row2" colspan="2">
- <span class="right-box">
- <!-- IF U_MOD_URL --><a href="{U_MOD_URL}">{L_SUPPORT}</a><!-- ENDIF -->
- <!-- IF U_MOD_DEMO--><a href="{U_MOD_DEMO}">{L_DEMO}</a><!-- ENDIF -->
+ <td class="row2" colspan="2" style="text-align:right">
+ <span>
+ <!-- IF U_MOD_URL --><a href="{U_MOD_URL}">{L_SUPPORT}</a> | <!-- ENDIF -->
+ <!-- IF U_MOD_DEMO--><a href="{U_MOD_DEMO}">{L_DEMO}</a> | <!-- ENDIF -->
{MOD_ACTION}
</span>
</td>
Modified: mods/cms/trunk/styles/prosilver/template/layout.html
===================================================================
--- mods/cms/trunk/styles/prosilver/template/layout.html 2007-09-02 14:07:06 UTC (rev 52)
+++ mods/cms/trunk/styles/prosilver/template/layout.html 2007-09-03 06:28:24 UTC (rev 53)
@@ -1,18 +1,21 @@
<!-- INCLUDE overall_header.html -->
-<div class="left-box" style="width:20%">
+<!-- IF .right -->
- <!-- BEGIN left -->
- <div class="panel<!-- IF left.CLASS --> {left.CLASS}<!-- ENDIF -->">
- <div class="inner">
- <span class="corners-top"><span></span></span>
- <!-- IF left.TITLE --><h3>{left.TITLE}</h3><!-- ENDIF -->
- <span>{left.CONTENT}</span>
- <span class="corners-bottom"><span></span></span>
+ <div class="left-box" style="width:20%;margin-right:.5%">
+
+ <!-- BEGIN left -->
+ <div class="panel<!-- IF left.CLASS --> {left.CLASS}<!-- ENDIF -->">
+ <div class="inner">
+ <span class="corners-top"><span></span></span>
+ <!-- IF left.TITLE --><h3>{left.TITLE}</h3><!-- ENDIF -->
+ <span>{left.CONTENT}</span>
+ <span class="corners-bottom"><span></span></span>
+ </div>
</div>
+ <!-- END left -->
</div>
- <!-- END left -->
-</div>
+<!-- ENDIF -->
<!-- IF .top_hor -->
<div class="left-box" style="width:70%;">
@@ -31,7 +34,7 @@
</div>
<!-- ENDIF -->
-<div class="left-box" style="width:<!-- IF .right -->59%<!-- ELSE -->79.4%<!-- ENDIF -->;margin-left:.5%">
+<div class="left-box" style="width:<!-- IF .right and .left -->59%<!-- ELSEIF .left || .right -->79.4%<!-- ELSE -->100%<!-- ENDIF -->">
<!-- BEGIN top -->
<div class="panel<!-- IF top.CLASS --> {top.CLASS}<!-- ENDIF -->">
@@ -75,9 +78,9 @@
</div>
- <!-- IF .right -->
+<!-- IF .right -->
-<div class="left-box" style="width:20%;margin-left:.5%">
+ <div class="left-box" style="width:20%;margin-left:.5%">
<!-- BEGIN right -->
<div class="panel<!-- IF right.CLASS --> {right.CLASS}<!-- ENDIF -->">
@@ -90,7 +93,7 @@
</div>
<!-- END right -->
-</div>
- <!-- ENDIF -->
+ </div>
+<!-- ENDIF -->
<!-- INCLUDE overall_footer.html -->
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|