|
From: <and...@us...> - 2007-10-13 15:03:00
|
Revision: 68
http://thevr.svn.sourceforge.net/thevr/?rev=68&view=rev
Author: andrewbelcher
Date: 2007-10-13 08:03:02 -0700 (Sat, 13 Oct 2007)
Log Message:
-----------
Made changes to the way permissions work and how the sites are managed. There are also a couple database edits that will need including... The sites table needs the field 'all' added to it (added to thevr_pms_install.php) and the user table needs the field 'user_sites' added to it (will update thevr_pms_install.php when I've finished sorting it).
@TODO
Create a UCP panel to manage site memberships.
Modified Paths:
--------------
mods/pms/branches/permissions/adm/style/acp_sites.html
mods/pms/branches/permissions/common.php
mods/pms/branches/permissions/includes/acp/acp_sites.php
mods/pms/branches/permissions/includes/auth.php
mods/pms/branches/permissions/includes/functions_thevr.php
mods/pms/branches/permissions/includes/session.php
mods/pms/branches/permissions/includes/ucp/ucp_groups.php
mods/pms/branches/permissions/language/en/acp/sites.php
mods/pms/branches/permissions/thevr_pms_install.php
Modified: mods/pms/branches/permissions/adm/style/acp_sites.html
===================================================================
--- mods/pms/branches/permissions/adm/style/acp_sites.html 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/adm/style/acp_sites.html 2007-10-13 15:03:02 UTC (rev 68)
@@ -39,6 +39,11 @@
<dd><select id="style" name="style"><option value="0">{L_DEFAULT_STYLE}</option>{S_STYLES_OPTIONS}</select></dd>
</dl>
+ <dl>
+ <dt><label for="all">{L_SITE_ALL}:</label><br /><span>{L_SITE_ALL_EXPLAIN}</span></dt>
+ <dd><label><input type="radio" class="radio" name="all" value="1"<!-- IF SITE_ALL --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
+ <label><input type="radio" class="radio" name="all" value="0"<!-- IF not SITE_ALL --> checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
+ </dl>
<!-- IF S_EDIT_SITE -->
<input id="id" name="id" type="hidden" value="{SITE_ID}">
<!-- ENDIF -->
Modified: mods/pms/branches/permissions/common.php
===================================================================
--- mods/pms/branches/permissions/common.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/common.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -229,38 +229,39 @@
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
- if (empty($row['site_id']))
- {
- $config['site_id'] = -1;
- }
- else
- {
- // Store the information in a config array $config
- $config = array_merge($config, array(
- 'site_id' => $row['site_id'],
- 'site_uname' => $row['name'],
- 'site_desc' => $row['description'],
- 'site_group_id' => $row['group_id'],
- 'site_home' => $row['home'],
- 'site_domain' => $domain,
- 'site_file' => $filename,
- 'site_vars' => $vars)
+if (empty($row['site_id']))
+{
+ $config['site_id'] = -1;
+}
+else
+{
+ // Store the information in a config array $config
+ $config = array_merge($config, array(
+ 'site_id' => $row['site_id'],
+ 'site_uname' => $row['name'],
+ 'site_desc' => $row['description'],
+ 'site_group_id' => $row['group_id'],
+ 'site_home' => $row['home'],
+ 'site_all' => $row['site_all'],
+ 'site_domain' => $domain,
+ 'site_file' => $filename,
+ 'site_vars' => $vars)
- );
- }
- //Fetch site specific config data:
- $sql = 'SELECT * FROM ' . SITE_CONFIG_TABLE . ' WHERE site_id = ' . $config['site_id'] . ' AND overide=1';
- $result = $db->sql_query($sql);
+ );
+}
+//Fetch site specific config data:
+$sql = 'SELECT * FROM ' . SITE_CONFIG_TABLE . ' WHERE site_id = ' . $config['site_id'] . ' AND overide=1';
+$result = $db->sql_query($sql);
- while ( $row = $db->sql_fetchrow($result) )
- {
- $config[$row['config_name']] = $row['config_value'];
- }
+while ( $row = $db->sql_fetchrow($result) )
+{
+ $config[$row['config_name']] = $row['config_value'];
+}
- if ($domain_bits[0] == 'm' OR $domain_bits[0] == 'mobile')
- {
- define('MOBILE_VERSION', true);
- }
+if ($domain_bits[0] == 'm' OR $domain_bits[0] == 'mobile')
+{
+ define('MOBILE_VERSION', true);
+}
/***** END *****/
?>
\ No newline at end of file
Modified: mods/pms/branches/permissions/includes/acp/acp_sites.php
===================================================================
--- mods/pms/branches/permissions/includes/acp/acp_sites.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/includes/acp/acp_sites.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -58,6 +58,7 @@
$site['group_id'] = request_var('group_id', $temp_data['group_id']);
$site['home'] = request_var('home', $temp_data['home']);
$site['style'] = request_var('style', $temp_data['default_style']);
+ $site['all'] = request_var('all', $temp_data['site_all']);
}
else
{
@@ -67,6 +68,7 @@
$site['group_id'] = request_var('group_id', '');
$site['home'] = request_var('home', '');
$site['style'] = request_var('style', '');
+ $site['all'] = request_var('all', '');
}
if ($submit)
@@ -130,6 +132,7 @@
'SITE_DESC' => $site['desc'],
'SITE_GROUP' => $site['group_id'],
'SITE_HOME' => $site['home'],
+ 'SITE_ALL' => $site['site_all'],
'S_STYLES_OPTIONS' => $styles_list
));
break;
@@ -448,7 +451,9 @@
'description' => $data['desc'],
'group_id' => $data['group_id'],
'home' => $data['home'],
- 'default_style' => $data['style'] );
+ 'default_style' => $data['style'],
+ 'site_all' => $data['all']
+ );
//Insert into sites table.
if( !$db->sql_query('INSERT INTO '.SITES_TABLE.' '.$db->sql_build_array('INSERT',$site_ins)))
@@ -485,7 +490,8 @@
'description' => $data['desc'],
'group_id' => $data['group_id'],
'home' => $data['home'],
- 'default_style' => $data['style']
+ 'default_style' => $data['style'],
+ 'site_all' => $data['all']
);
$sql = 'UPDATE '.SITES_TABLE.' SET '.$db->sql_build_array('UPDATE',$site_upd).' WHERE site_id='.$id;
Modified: mods/pms/branches/permissions/includes/auth.php
===================================================================
--- mods/pms/branches/permissions/includes/auth.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/includes/auth.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -94,6 +94,7 @@
*/
function acl_get($opt, $f = 0)
{
+ global $user;
$negate = false;
if (strpos($opt, '!') === 0)
@@ -124,13 +125,14 @@
if (isset($this->acl[$f]) && isset($this->acl[$f][$this->acl_options['local'][$opt]]))
{
$this->cache[$f][$opt] |= $this->acl[$f][$this->acl_options['local'][$opt]];
- }
- if (check_forum($f) == false)
- {
- $this->cache[$f][$opt] = false;
}
-
+ // Check that this forum is on this site's list
+ // If not, set permissions to false
+ if (!in_array($f, $user->data['site_forums']))
+ {
+ $this->cache[$f][$opt] = false;
+ }
}
}
Modified: mods/pms/branches/permissions/includes/functions_thevr.php
===================================================================
--- mods/pms/branches/permissions/includes/functions_thevr.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/includes/functions_thevr.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -8,50 +8,6 @@
*
*/
-function check_forum($f)
-{
- global $db, $config, $auth;
- if (isset($auth->cache['site_forums']))
- {
- $forums = $auth->cache['site_forums'];
-
- if (isset($forums[$f]))
- {
- return (isset($forums[$f])) ? true: false;
- }
- else
- {
- return false;
- }
- }
- else
- {
- $sql = 'SELECT f.forum_id, f.site_id
- FROM ' . FORUMS_TABLE . " as f
- WHERE ( f.site_id = '" . $config['site_id'] . "'
- OR f.site_id = '0' )";
- $result = $db->sql_query($sql);
-
- $forums = array();
-
- while ($row = $db->sql_fetchrow($result))
- {
- $forums[$row['forum_id']] = $row['site_id'];
- }
-
- $auth->cache['site_forums'] = $forums;
-
- if (isset($forums[$f]))
- {
- return (isset($forums[$f])) ? true: false;
- }
- else
- {
- return false;
- }
- }
-}
-
/*********************************
* Basically a clone of the function style_select().
* It creates a select box from all the sites
Modified: mods/pms/branches/permissions/includes/session.php
===================================================================
--- mods/pms/branches/permissions/includes/session.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/includes/session.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -1567,6 +1567,27 @@
}
}
+ // Set up the user's site/forum access
+ if ($config['site_all'] == true && isset($this->data['user_sites']))
+ {
+ $sql_site_list = '(0,' . $config['site_id'] . ',' . $this->data['user_sites'] . ')';
+ }
+ else
+ {
+ $sql_site_list = '(0,' . $config['site_id'] . ')';
+ }
+
+ $sql_where = '
+ WHERE f.site_id IN ' . $sql_site_list;
+
+ $sql = 'SELECT f.forum_id
+ FROM ' . FORUMS_TABLE . ' AS f' . $sql_where;
+ $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $this->data['site_forums'][] = $row['forum_id'];
+ }
+
return;
}
Modified: mods/pms/branches/permissions/includes/ucp/ucp_groups.php
===================================================================
--- mods/pms/branches/permissions/includes/ucp/ucp_groups.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/includes/ucp/ucp_groups.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -12,7 +12,7 @@
* ucp_groups
* @package ucp
*/
-class ucp_groups
+class ucp_sites
{
var $u_action;
Modified: mods/pms/branches/permissions/language/en/acp/sites.php
===================================================================
--- mods/pms/branches/permissions/language/en/acp/sites.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/language/en/acp/sites.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -83,6 +83,8 @@
'SITE_EDIT_EXPLAIN' => '',
'SITE_ADMIN' => 'Manage Sites',
'SITE_ADMIN_EXPLAIN' => '',
+ 'SITE_ALL' => 'All Sites',
+ 'SITE_ALL_EXPLAIN' => 'Makes this site display forums from all sites that the user is a member of.',
'SITE_DELETE' => 'Delete site',
'SITE_DELETE_EXPLAIN' => '',
'SITE_URL_ADMIN' => 'Manage Site URLs',
Modified: mods/pms/branches/permissions/thevr_pms_install.php
===================================================================
--- mods/pms/branches/permissions/thevr_pms_install.php 2007-09-27 07:24:47 UTC (rev 67)
+++ mods/pms/branches/permissions/thevr_pms_install.php 2007-10-13 15:03:02 UTC (rev 68)
@@ -18,12 +18,12 @@
$mode = request_var('mode','');
if($auth->acl_gets('acl_a_server'))
-{
+{
trigger_error('You are nto permitted to install this modification');
}
switch ($mode)
-{
+{
case 'install':
/***
* Create New Tables
@@ -34,15 +34,15 @@
`config_value` varchar(255) character set latin1 collate latin1_general_ci NOT NULL,
`is_dynamic` tinyint(1) NOT NULL,
`site_id` mediumint(4) NOT NULL,
- `overide` tinyint(1) NOT NULL
+ `overide` tinyint(1) NOT NULL,
)";
if($db->sql_query($sql))
- {
+ {
$success[] = 'site_config';
}
else
- {
+ {
define('ERROR',true);
}
@@ -72,6 +72,7 @@
`group_id` mediumint(8) NOT NULL default '1',
`home` varchar(255) character set utf8 collate utf8_bin NOT NULL default 'index.php',
`default_style` tinyint(4) NOT NULL default '1',
+ `site_all` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`site_id`)
)";
@@ -86,9 +87,9 @@
if(defined('ERROR'))
- {
+ {
foreach($success as $i => $table)
- {
+ {
$sql = "DROP TABLE " . $table_prefix . $table . " ";
@$db->sql_query($sql);
}
@@ -238,7 +239,7 @@
);
if(!$db->sql_multi_insert(MODULES_TABLE,$modules))
- {
+ {
foreach($success as $i => $table)
{
$sql = "DROP TABLE " . $table_prefix . $table . " ";
@@ -307,7 +308,7 @@
$errors[] = $user->lang['SITE_ADD_FAIL'];
}
else
- {
+ {
$success2[] = 'sites';
}
$data['site_id'] = $db->sql_nextid;
@@ -327,7 +328,7 @@
}
if (defined('ERROR'))
- {
+ {
foreach($success as $i => $table)
{
$sql = "DROP TABLE " . $table_prefix . $table . " ";
@@ -348,7 +349,7 @@
@$db->sql_query($sql);
foreach($modules as $array)
- {
+ {
$sql = 'DELETE
FROM ' . MODULES_TABLE . '
WHERE left_id = ' . $array['left_id'];
@@ -356,9 +357,9 @@
}
foreach($success2 as $ob)
- {
+ {
switch ($ob)
- {
+ {
case 'groups':
group_delete($group_id);
break;
@@ -379,7 +380,7 @@
$error = '';
foreach($errors as $message)
- {
+ {
$error .= $message;
}
@@ -392,7 +393,7 @@
case 'update':
$vers = request_var('v','');
switch ($vers)
- {
+ {
case '':
default:
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|