gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/db 20040804.sql, NONE, 1.1 migrateforum.php, NO


From: tperdue
Subject: [Gforge-commits] gforge/db 20040804.sql, NONE, 1.1 migrateforum.php, NONE, 1.1 migraterbac.php, NONE, 1.1
Date: Wed, 04 Aug 2004 11:18:45 -0500

Update of /cvsroot/gforge/gforge/db
In directory db.perdue.net:/home/tperdue/share/dev.gforge.org/db

Added Files:
        20040804.sql migrateforum.php migraterbac.php 
Log Message:
RBAC, DELETION, AND FORUM EMAIL GATEWAY

--- NEW FILE: 20040804.sql ---
CREATE TABLE user_type (
type_id serial unique,
type_name text
);
INSERT into user_type (type_name) VALUES ('User');
INSERT into user_type (type_name) VALUES ('UserPool');

ALTER TABLE users ADD COLUMN type_id INT;
ALTER TABLE users ALTER COLUMN type_id SET DEFAULT 1;
UPDATE users SET type_id=1;
ALTER TABLE users ADD CONSTRAINT users_typeid
        FOREIGN KEY (type_id) REFERENCES user_type(type_id) MATCH FULL;

--
--      Each FRS Package now has public/private flags
--
ALTER TABLE frs_package ADD COLUMN is_public INT;
ALTER TABLE frs_package ALTER COLUMN is_public SET DEFAULT 1;
UPDATE frs_package SET is_public=1;

DROP TABLE role;
CREATE TABLE role (
role_id serial unique,
group_id int not null REFERENCES groups(group_id) ON DELETE CASCADE,
role_name text
);
CREATE UNIQUE INDEX role_groupidroleid ON role(group_id,role_id);

INSERT INTO role (group_id,role_name) VALUES (1,'Default');

--DROP TABLE role_section;
--DROP SEQUENCE role_section_section_id_seq;
--DROP TABLE role_value;
--DROP VIEW role_section_value_vw;

--
--
--      This new table will store separate perms for each task manager 
subproject
--
--
CREATE TABLE project_perm (
id serial unique,
group_project_id int not null REFERENCES project_group_list(group_project_id) 
ON DELETE CASCADE,
user_id int not null REFERENCES users(user_id) MATCH FULL,
perm_level int not null default 0
);
CREATE UNIQUE INDEX projectperm_groupprojiduserid ON 
project_perm(group_project_id,user_id);

DELETE FROM project_perm;
INSERT INTO project_perm (group_project_id,user_id,perm_level) 
        SELECT 
project_group_list.group_project_id,user_group.user_id,user_group.project_flags
        FROM user_group,project_group_list
        WHERE project_group_list.group_id=user_group.group_id
        AND NOT EXISTS (SELECT user_id FROM project_perm WHERE 
project_perm.group_project_id=
        project_group_list.group_project_id);

--
--
--      This new table will store separate perms for each forum
--
--
CREATE TABLE forum_perm (
id serial unique,
group_forum_id int not null REFERENCES forum_group_list(group_forum_id) ON 
DELETE CASCADE,
user_id int not null REFERENCES users(user_id) MATCH FULL,
perm_level int not null default 0
);
CREATE UNIQUE INDEX forumperm_groupforumiduserid ON 
forum_perm(group_forum_id,user_id);

DELETE FROM forum_perm;
INSERT INTO forum_perm (group_forum_id,user_id,perm_level) 
        SELECT 
forum_group_list.group_forum_id,user_group.user_id,user_group.forum_flags
        FROM user_group,forum_group_list
        WHERE forum_group_list.group_id=user_group.group_id
        AND NOT EXISTS (SELECT user_id FROM forum_perm WHERE 
forum_perm.group_forum_id=
        forum_group_list.group_forum_id);


--
--      Add to all trackers
--
INSERT INTO artifact_perm (group_artifact_id,user_id,perm_level) 
        SELECT 
artifact_group_list.group_artifact_id,user_group.user_id,user_group.artifact_flags
        FROM user_group,artifact_group_list
        WHERE artifact_group_list.group_id=user_group.group_id
        AND NOT EXISTS (SELECT user_id FROM artifact_perm WHERE 
artifact_perm.group_artifact_id=
        artifact_group_list.group_artifact_id);

--
--      This table contains all the settings for this particular role
--
--      example; 1,'docman',$category_id,1
--
DROP TABLE role_setting;
CREATE TABLE role_setting (
role_id int not null REFERENCES role(role_id) ON DELETE CASCADE,
section_name text not null,
ref_id int not null, --optional ID for something like artifact_type_id or 
doc_category_id
value varchar(2) not null
);
CREATE INDEX rolesetting_roleidsectionid ON role_setting(role_id,section_name);

ALTER TABLE user_group ADD COLUMN role_id INT;
ALTER TABLE user_group ALTER COLUMN role_id SET DEFAULT 1;
UPDATE user_group SET role_id='1';
ALTER TABLE user_group ADD CONSTRAINT usergroup_roleid
        FOREIGN KEY (role_id) REFERENCES role(role_id) MATCH FULL;



--- NEW FILE: migrateforum.php ---
#! /usr/bin/php4 -f
<?php
/**
 * GForge Forum Renamer - forum names are now unix-format for email gateway
 *
 * Copyright 2004 GForge, LLC
 * http://gforge.org/
 *
 * @version   $Id: migrateforum.php,v 1.1 2004/08/04 16:18:35 tperdue Exp $
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */

require_once('www/include/squal_pre.php');

//
//      Convert forum names to new legal syntax
//
db_begin();
$res=db_query("SELECT group_forum_id,forum_name FROM forum_group_list");
echo db_error();

for ($i=0; $i<db_numrows($res); $i++) {

        $sql="UPDATE forum_group_list 
                SET forum_name='". ereg_replace('[^_\.0-9a-z-]','-', 
strtolower(db_result($res,$i,'forum_name')) )."' 
                WHERE group_forum_id='".db_result($res,$i,'group_forum_id')."'";
        $res2=db_query($sql);
        echo db_error();

}

//
//      Long-standing oddity in GForge - 
//      forums were ZERO-pen Discussion, not Oh-pen Discussion
//
db_query("UPDATE forum_group_list SET forum_name='open-discussion' 
        WHERE forum_name='0pen-discussion'");

db_commit();

?>

--- NEW FILE: migraterbac.php ---
#! /usr/bin/php4 -f
<?php
/**
 * GForge Group Role Generator
 *
 * Copyright 2004 GForge, LLC
 * http://gforge.org/
 *
 * @version   $Id: migraterbac.php,v 1.1 2004/08/04 16:18:35 tperdue Exp $
 *
 * This file is part of GForge.
 *
 * GForge is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * GForge is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */

require_once('www/include/squal_pre.php');
require_once('common/include/Role.class');

//
//      Set up this script to run as the site admin
//
$id=db_result(db_query("SELECT user_id FROM user_group WHERE admin_flags='A' 
AND group_id='1'"),0,0);
session_set_new($id);

//
//      Clear out role settings in case this was run before
//
db_begin();
db_query("UPDATE user_group SET role_id=1");
db_query("DELETE FROM role_setting");
db_query("DELETE FROM role WHERE role_id>1");

$res=db_query("SELECT group_id FROM groups WHERE status != 'P'");
$arr = util_result_column_to_array($res);

for ($i=0; $i<count($arr); $i++) {
        $g =& group_get_object($arr[$i]);
        //
        //
        //  Set Default Roles
        //
        //
        $role = new Role($g);
        $todo = array_keys($role->defaults);
        for ($c=0; $c<count($todo); $c++) {
                $role = new Role($g);
                if (!$role->createDefault($todo[$c])) {
                        $this->setError($role->getErrorMessage());
                        db_rollback();
                        echo "Could Not Create Default Roles: ".$arr[$i];
                }
        }
}
db_commit();

?>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]