[prev in list] [next in list] [prev in thread] [next in thread]
List: bzflag-commits
Subject: SF.net SVN: bzflag: [16453] trunk/db/bzgrpmgr
From: macsforme () users ! sourceforge ! net
Date: 2008-01-07 7:21:24
Message-ID: E1JBmIW-00041g-H0 () sc8-pr-svn2 ! sourceforge ! net
[Download RAW message or body]
Revision: 16453
http://bzflag.svn.sourceforge.net/bzflag/?rev=16453&view=rev
Author: macsforme
Date: 2008-01-06 23:21:23 -0800 (Sun, 06 Jan 2008)
Log Message:
-----------
Organization registration and name changes now work.
Misc. data class bug fixes.
Updated button links on index page.
Misc. stylesheet changes.
Modified Paths:
--------------
trunk/db/bzgrpmgr/TODO
trunk/db/bzgrpmgr/include/data.class.inc
trunk/db/bzgrpmgr/index.php
trunk/db/bzgrpmgr/template/styles.css
Added Paths:
-----------
trunk/db/bzgrpmgr/orgs.php
Modified: trunk/db/bzgrpmgr/TODO
===================================================================
--- trunk/db/bzgrpmgr/TODO 2008-01-07 05:17:18 UTC (rev 16452)
+++ trunk/db/bzgrpmgr/TODO 2008-01-07 07:21:23 UTC (rev 16453)
@@ -1,5 +1,9 @@
+The PRECIOUS PHP line:
+ header( "Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] );
+
When finished, run HTML validation.
MySQL queries need to be checked for mysql_error() before running mysql_num_rows()
+All data class functions (especially updating/manipulation functions) should check \
for errors and return as such
Check this SQL query (courtesy of AAA_awright) for the converter:
INSERT INTO groups_orgs SELECT null as orgid, SUBSTRING_INDEX(group_name,'.',1) AS \
orgname, group_moderator as contact FROM phpbb_groups GROUP BY orgname @@ -31,6 +35,8 \
@@ Ban Control
History & Logs
System Stats
+ Maintenance
+ Purge unassociated groups
Ban control should have:
by IP/Hostmask
Modified: trunk/db/bzgrpmgr/include/data.class.inc
===================================================================
--- trunk/db/bzgrpmgr/include/data.class.inc 2008-01-07 05:17:18 UTC (rev 16452)
+++ trunk/db/bzgrpmgr/include/data.class.inc 2008-01-07 07:21:23 UTC (rev 16453)
@@ -218,7 +218,7 @@
// Manipulation functions
public function createOrg( $name, $userid ) {
// Don't create duplicate groups
- if( getOrgID( $name ) )
+ if( $this->getOrgID( $name ) )
return false;
// Create the organization
@@ -242,14 +242,20 @@
return false;
// Set the owner group to have admin perms
- setOrgAdminGroup( $adminGroup, $orgid );
+ $this->setOrgAdminGroup( $ownerGroup, $orgid );
// Add the registrant to the owner group
$this->addMember( $userid, $ownerGroup );
return $myOrgID;
}
+ public function setOrgName( $orgid, $orgname ) {
+ $sql = "UPDATE ".$this->tbl_prf."orgs SET ORGNAME = \"".
+ $orgname."\" WHERE orgid = ".$orgid;
+ mysql_query( $sql );
+ }
+
// ============================================================
// ===================== Group interface ======================
// ============================================================
@@ -323,19 +329,19 @@
// Manipulation functions
public function createGroup( $groupname, $desc, $orgid ) {
// Don't create duplicate groups
- $sql = "SELECT groupid FROM groups WHERE ".
+ $sql = "SELECT groupid FROM ".$this->tbl_prf."groups WHERE ".
"groupname=\"".$groupname."\" AND ".
"orgid=".$orgid;
$result = mysql_query( $sql, $this->conn );
if( $result && mysql_num_rows( $result ) > 0 )
return false;
- $sql = "INSERT INTO groups (groupname, description, orgid) ".
+ $sql = "INSERT INTO ".$this->tbl_prf."groups (groupname, description, orgid) ".
"VALUES (\"".$groupname."\", \"".$desc.
"\", ".$orgid.")";
mysql_query( $sql, $this->conn );
- $sql = "SELECT groupid FROM groups WHERE ".
+ $sql = "SELECT groupid FROM ".$this->tbl_prf."groups WHERE ".
"orgid=".$orgid." AND ".
"groupname=\"".$groupname."\"";
$result = mysql_query( $sql, $this->conn );
@@ -345,7 +351,7 @@
return false;
}
public function updateGroup( $groupid, $groupname, $desc, $orgid ) {
- $sql = "SELECT groupid FROM groups WHERE ".
+ $sql = "SELECT groupid FROM ".$this->tbl_prf."groups WHERE ".
"groupid=".$groupid;
$result = mysql_query( $sql, $this->conn );
if( ! $result || mysql_num_rows( $result ) < 1 )
@@ -361,7 +367,7 @@
return true;
}
- public function addMember( $groupid, $userid ) {
+ public function addMember( $userid, $groupid ) {
$sql = "INSERT INTO ".$this->tbl_prf."memberships ".
"(userid, groupid) VALUES ".
"(".$userid.", ".$groupid.")";
Modified: trunk/db/bzgrpmgr/index.php
===================================================================
--- trunk/db/bzgrpmgr/index.php 2008-01-07 05:17:18 UTC (rev 16452)
+++ trunk/db/bzgrpmgr/index.php 2008-01-07 07:21:23 UTC (rev 16453)
@@ -52,7 +52,10 @@
asort( $group_array );
foreach( $group_array as $groupname => $groupid )
- echo "<tr><td>".$groupname."</td><td>".count( $data->getGroupMembers( $groupid ) \
)."</td></tr>\n"; + echo "<tr><td>".
+ "<a href=\"groups.php?action=members&id=".$groupid."\">".
+ $groupname."</td><td>".count( $data->getGroupMembers( $groupid ) ).
+ "</a></td></tr>\n";
echo "</table>\n";
}
@@ -73,13 +76,6 @@
<?php
-/*
-++ Organization Name<info/admin link> ++
-++++ Group Name<members link> ++++ <admin> ++++ <delete> ++++ (adminlevel) ++++
-++++ Add a group ++++
-++ Add an organization ++
-*/
-
// Generate array of orgid's[groupid's]
$orgs = array();
foreach( $data->getGroupsByUser( $auth->getUserID() ) as $membergroupid ) {
@@ -121,7 +117,8 @@
// Org info
echo "<tr class=\"org\"><td colspan=\"3\">".$data->getOrgName( $orgid )."</td>".
"<td>".( $data->isOrgAdmin( $auth->getUserID(), $orgid ) ?
- "<img src=\"img/wrench.png\">" : " " )."</td>".
+ "<a href=\"orgs.php?action=detail&id=".$orgid."\">".
+ "<img src=\"img/wrench.png\">" : " " )."</a></td>".
"<td colspan=\"2\"> </td></tr>\n";
// Group name and links (if applicable)
@@ -132,10 +129,15 @@
( $data->isSpecialAdminGroup( $groupid ) ?
"<img src=\"img/key_low.png\">" : " " ) )."</td>".
"<td> </td>".
- "<td>".$data->getGroupName( $groupid )."</td>".
+ "<td><a href=\"groups.php?action=members&id=".$groupid."\">".
+ $data->getGroupName( $groupid ).
+ "</a></td>".
( $data->isGroupAdmin( $auth->getUserID(), $groupid ) ?
- "<td style=\"padding: 0\"><img src=\"img/wrench.png\"></td>".
- "<td><img src=\"img/delete.png\"></td>" :
+ "<td style=\"padding: 0\">".
+ "<a href=\"groups.php?action=detail&id=".$groupid."\">".
+ "<img src=\"img/wrench.png\"></a></td>".
+ "<td><a href=\"groups.php?action=delete&id=".$groupid."\">".
+ "<img src=\"img/delete.png\"></td>" :
"<td> </td><td> </td>" ).
"</tr>\n";
@@ -153,7 +155,7 @@
?>
-<br><a href="">Click here to register a new organization.</a>
+<br><a href="orgs.php?action=detail">Click here to register a new organization.</a>
</p>
@@ -176,227 +178,4 @@
require_once( 'template/footer.inc' );
-
-
-
-
-
-
-/*
-require_once( "data_phpbb2.class.php" );
-require_once( "functions.inc" );
-require_once( "config.php" );
-
-// Temporary userdata settings... will incorporate with weblogin later
-$userdata['bzid'] = 2;
-$userdata['callsign'] = $data->getUsername( $userdata['bzid'] );
-$userdata['admin'] = true;
-
-// Begin main logic
-$output = "";
-
-// Auth section
-
-// Action section
-switch( $_REQUEST['action'] ) {
- case "showmembers":
- if( ! $_GET['id'] ) die( "Missing parameter.\n" );
-
- $output .= "\t\t<b>Members:</b><br><br>\n\n";
- $output .= "\t\tGroup Name: <i>".
- $data->getOrgName( $data->getOrg( $_GET['id'] ) ).".".
- $data->getGroupName( $_GET['id'] ).
- "</i><br><br>\n\n";
-
- // FIXME: check data input
- $members = false;
- foreach( $data->getMembers( $_GET['id'] ) as $memberid ) {
- $members = true;
- $output .= $data->getUsername( $memberid )."<br>\n";
- }
- if( ! $members ) {
- $output .= "\t\t<i>No members.</i>\n";
- }
-
- $output .= "\t\t<br><br>\n\n";
-
- break;
- case "createorg":
- // User has clicked the "new organization" link
- $output .= <<<ENCLOSE
- <form method="POST" action="bzgrpmgr.php">
- <input type="hidden" name="action" value="submitcreateorg">
- <table>
- <tr>
- <td>Organization name:</td>
- <td><input type="text" name="orgname" value="" size="20"></td>
- </tr>
- <tr><td> </td><td><input type="submit" name="submit" \
value="Create"></td></tr>
- </table>
- </form>
-
- <i>Note: The organization name must not be the username of an existing user.</i>
-
-ENCLOSE;
- break;
- case "submitcreateorg":
- // FIXME validate data entry
- // FIXME check against user data
- // FIXME block against reserved group names
-
- // check for existing group name
- // FIXME create clean sitewide die method?
- if( $data->orgExists( $_POST['orgname'] ) ) {
- $output .= "The given organization name already exists.<br>\n";
-
- print_header( "" );
- echo $output;
- print_footer();
- exit;
- }
-
- // Create the organization
- $data->createOrg( $_POST['orgname'], $userdata['bzid'] );
- header( "Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] );
- break;
- case "editgroup":
- // FIXME check for group validity, etc.
- // FIXME add support for group state
-
- // User is editing the settings of a group or has clicked the "new group" link
- if( $_GET['groupid'] )
- // We're editing
- $output .= "\t\tEditing settings for group <b>".
- $data->getOrgName( $data->getOrg( $_GET['groupid'] ) ).".".
- $data->getGroupName( $_GET['groupid'] )."</b>.<br><br>\n\n";
- else
- // We're creating a new group
- $output .= "\t\tCreate a group for the</i> <b>".
- $data->getOrgName($_GET['orgid'])."</b> organization.<br><br>\n\n";
-
-
- // create values array
- $values = array(
- 'groupname' => $data->getGroupName( $_GET['groupid'] ),
- 'description' => $data->getGroupDescription( $_GET['groupid'] ),
- 'adminusers' => $data->isUserAdminGroup( $_GET['groupid'] ),
- 'admingroups' => $data->isGroupAdminGroup( $_GET['groupid'] ),
- 'admin' => $data->isAdminGroup( $_GET['groupid'] )
- );
-
- // output form
- $output .= <<<ENCLOSE
- <form method="POST" action="bzgrpmgr.php">
- <input type="hidden" name="action" value="submiteditgroup">
- <input type="hidden" name="orgid" value="
-ENCLOSE;
- $output .= $_GET['orgid'];
- $output .= <<<ENCLOSE
-">
- <input type="hidden" name="groupid" value="
-ENCLOSE;
- $output .= ( $_GET['groupid'] ? $_GET['groupid'] : "0" );
- $output .= <<<ENCLOSE
-">
- <table>
- <tr>
- <td>Group name:</td>
- <td><input type="text" name="groupname" value="
-ENCLOSE;
- $output .= $values['groupname'];
- $output .= <<<ENCLOSE
-" size="20"></td>
- </tr>
- <tr>
- <td>Group description:</td>
- <td><input type="text" name="description" value="
-ENCLOSE;
- $output .= $values['description'];
- $output .= <<<ENCLOSE
-" size="40"></td>
- </tr>
- <tr>
- <td>Members are full organization admins?</td>
- <td><input type="checkbox" name="admingroups"
-ENCLOSE;
- if( $values['admin'] ) $output .= " checked";
- $output .= <<<ENCLOSE
-></td>
- </tr>
- <tr>
- <td>Members may manage users for the organization?</td>
- <td><input type="checkbox" name="admingroups"
-ENCLOSE;
- if( $values['admingroups'] ) $output .= " checked";
- $output .= <<<ENCLOSE
-></td>
- </tr>
- <td>Members may manage groups for the organization?</td>
- <td><input type="checkbox" name="admingroups"
-ENCLOSE;
- if( $values['adminusers'] ) $output .= " checked";
- $output .= <<<ENCLOSE
-></td>
- </tr>
- <tr><td> </td><td><input type="submit" name="submit" value="
-ENCLOSE;
- $output .= ( $_GET['groupid'] ? "Update" : "Create" );
- $output .= <<<ENCLOSE
-"></td></tr>
- </table>
- </form>
-
-ENCLOSE;
- break;
- case "submiteditgroup":
- // FIXME validate data entry
- // FIXME check against user data
- // check for existing group name
-
-// foreach( $_POST as $key => $value ) $output .= $key." => ".$value."<br>\n";
-
- // If new group, make sure the group name doesn't already exist in the \
organization
- $existingGroupNames = array();
- foreach( $data->getOrgGroups( $_POST['orgid'] ) as $groupid ) {
- $existingGroupNames[$data->getGroupName( $groupid )] = 1;
- }
- if( $existingGroupNames[$_POST['groupname']] ) {
- $output .= "The given organization name already exists.<br>\n";
-
- print_header( "" );
- echo $output;
- print_footer();
- exit;
- }
-
- // FIXME parse the post data for validity
- if( $_POST['groupid'] ) {
- // Update the group
- $data->updateGroup( $_POST['groupid'], $_POST['groupname'],
- $_POST['description'], $_POST['orgid'] );
-
- // Redirect to home
- header( "Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] );
- } else {
- // Create the group
- $myGroupid = $data->createGroup( $_POST['groupname'], $_POST['description'], \
$_POST['orgid'] );
- $data->setUserAdminGroup( $_POST['groupid'], $_POST['adminusers'] );
- $data->setGroupAdminGroup( $_POST['groupid'], $_POST['admingroups'] );
- $data->setAdminGroup( $_POST['groupid'], $_POST['admin'] );
-
- // Redirect to home
- header( "Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'] );
- }
-
- break;
- default:
- break;
-}
-
-
-// Dump output
-print_header( "" );
-echo $output;
-print_footer();
-*/
?>
\ No newline at end of file
Added: trunk/db/bzgrpmgr/orgs.php
===================================================================
--- trunk/db/bzgrpmgr/orgs.php (rev 0)
+++ trunk/db/bzgrpmgr/orgs.php 2008-01-07 07:21:23 UTC (rev 16453)
@@ -0,0 +1,84 @@
+<?php
+
+// Includes
+require_once( 'include/global.inc' );
+
+// Main action switch
+switch( $_GET['action'] ) {
+ case "detail":
+ // Editing new or existing organization
+
+ // Verify auth
+ if( $_GET['id'] && ! $data->isOrgAdmin( $auth->getUserID(), $_GET['id'] ) )
+ header( "Location: ." );
+
+ require_once( 'template/header.inc' );
+
+ ?>
+
+<form method="POST" action="orgs.php?action=update">
+ <?php if( $_GET['id'] ) echo "<input type=\"hidden\" name=\"id\" \
value=\"".$_GET['id']."\">"; ?> + <table>
+ <tr>
+ <td>Organization name:</td>
+ <td><input type="text" name="orgname" value="<?php
+if( $_GET['id'] ) echo $data->getOrgName( $_GET['id'] );
+ ?>" size="20"></td>
+ </tr>
+ <tr><td> </td><td><input type="submit" name="submit" value="<?php
+if( $_GET['id'] ) echo "Update"; else echo "Create";
+ ?>"></td></tr>
+ </table>
+</form>
+
+<i>Note: The organization name must not be the username of an existing user.</i>
+
+<?php
+
+ require_once( 'template/footer.inc' );
+
+ break;
+ case "update":
+ // FIXME validate data entry
+ // FIXME check against user data
+ // FIXME block against reserved group names
+
+ // check for existing group name
+ // FIXME create clean sitewide die method?
+
+ // Various checks
+ if( ! $_POST['orgname'] ) {
+ // Where's our bloody data?
+ header( "Location: ." );
+
+ exit;
+ } else if( $_POST['id'] && ! $data->isOrgAdmin( $auth->getUserID(), $_POST['id'] ) \
) + // User is not an admin of this org
+ graceful_exit( "Sorry, you are not authorized to administer that organization." \
); + else if( $data->getUserID( $_POST['orgname'] ) &&
+ strtolower( $auth->getUserName() ) != strtolower( $_POST['orgname'] ) )
+ // Username equal to specified org name exists and is not this user
+ graceful_exit( "Sorry, you cannot name an organization with the username of \
another user." ); + else if( $data->getOrgID( $_POST['orgname'] ) &&
+ $data->getOrgID( $_POST['orgname'] != $_POST['id'] ) )
+ // Org name exists and is not this same org
+ graceful_exit( "Sorry, an organization with that name already exists." );
+
+
+ if( $_POST['id'] )
+ // Update the organization's name
+ $data->setOrgName( $_POST['id'], $_POST['orgname'] );
+ else
+ // Create the organization
+ $data->createOrg( $_POST['orgname'], $auth->getUserID() );
+
+ header( "Location: ." );
+
+ break;
+ default:
+ header( "Location: ." );
+
+ break;
+}
+
+?>
\ No newline at end of file
Modified: trunk/db/bzgrpmgr/template/styles.css
===================================================================
--- trunk/db/bzgrpmgr/template/styles.css 2008-01-07 05:17:18 UTC (rev 16452)
+++ trunk/db/bzgrpmgr/template/styles.css 2008-01-07 07:21:23 UTC (rev 16453)
@@ -47,13 +47,18 @@
a,a:visited {
color: #000000;
+ text-decoration: none;
}
a:hover {
- color: #591700;
- text-decoration: none;
+// color: #591700;
+ text-decoration: underline;
}
+img {
+ border-style: none;
+}
+
.large {
font-size: 14pt;
font-weight: bold;
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
BZFlag-commits mailing list
BZFlag-commits@lists.SourceForge.net
https://lists.SourceForge.net/lists/listinfo/bzflag-commits
irc: #BZFlag @ irc.freenode.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic