[prev in list] [next in list] [prev in thread] [next in thread]
List: gallery-checkins
Subject: [Gallery-checkins] integration/gallery2/phpBB2/admin admin_gallery2.php,1.1,1.2 gallery2_export.php,
From: Dariush Molavi <dmolavi () users ! sourceforge ! net>
Date: 2005-08-30 23:10:51
Message-ID: E1EAFFo-0003rj-EG () mail ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/gallery/integration/gallery2/phpBB2/admin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20407/gallery2/phpBB2/admin
Modified Files:
admin_gallery2.php gallery2_export.php
Log Message:
UPDATE:
* Added group sync to admin control panel.
New users are *not* added to their groups
yet, that will be next.
Index: gallery2_export.php
===================================================================
RCS file: /cvsroot/gallery/integration/gallery2/phpBB2/admin/gallery2_export.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gallery2_export.php 25 Aug 2005 22:27:18 -0000 1.1
+++ gallery2_export.php 30 Aug 2005 23:10:48 -0000 1.2
@@ -35,6 +35,8 @@
$failures = array();
+$sync_type = ($_GET['type'] == "user") ? "user" : "group";
+$sync_title = ($_GET['type'] == "user") ? "Users" : "Groups";
/*********************************************************/
/* True if init() was called, else false */
@@ -297,6 +299,50 @@
echo "<form><input type=\"button\" value=\"Close Window\" \
onclick=\"window.close()\"></form>"; }
+function groupExport()
+{
+ global $db, $gallery, $failures;
+
+ // init G2 transaction, load G2 API, if not already done so
+ if (!init()) {
+ return false;
+ }
+
+ // Load all existing phpnuke <-> G2 mappings
+ list ($ret, $mapsbyentityid, $mapsbyexternalid) = g2getallexternalIdmappings();
+ if (!$ret) {
+ return false;
+ }
+
+ $sql = "SELECT group_id, group_name FROM " . GROUPS_TABLE . " WHERE \
group_single_user = 0"; + $result = $db->sql_query($sql);
+ while( $row = $db->sql_fetchrow($result) )
+ {
+ $ret = GalleryEmbed :: createGroup($row['group_id'],$row['group_name']);
+ if (!$ret->isSuccess()) {
+ $failures[] = $row['group_name'];
+ }
+ $g_sql ="SELECT u.username, ug.user_id FROM " . USERS_TABLE . " u, " . \
USER_GROUP_TABLE . " ug WHERE ug.user_id = u.user_id AND ug.group_id = " \
.$row['group_id']; + $g_result = $db->sql_query($g_sql) or die(mysql_error());
+ while( $g_row = $db->sql_fetchrow($g_result) )
+ {
+ $ret = GalleryEmbed :: addUserToGroup($g_row['user_id'],$row['group_id']);
+ if (!$ret->isSuccess()) {
+ $failures[] = $row['group_name'];
+ }
+ }
+ }
+ if(count($failures) != 0)
+ {
+ echo "<br />The import of the following phpBB2 groups failed:<br />";
+ foreach($failures as $bad_id)
+ {
+ echo $bad_id."<br />";
+ }
+ }
+ echo "<form><input type=\"button\" value=\"Close Window\" \
onclick=\"window.close()\"></form>"; +}
+
?>
<html><head>
<script type="text/javascript">
@@ -385,7 +431,7 @@
</div>
<?php
echo "<p>";
- userExport();
+ $sync_type == "user" ? userExport() : groupExport();
echo "</p>";
?>
Index: admin_gallery2.php
===================================================================
RCS file: /cvsroot/gallery/integration/gallery2/phpBB2/admin/admin_gallery2.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- admin_gallery2.php 25 Aug 2005 22:27:18 -0000 1.1
+++ admin_gallery2.php 30 Aug 2005 23:10:48 -0000 1.2
@@ -59,6 +59,10 @@
{
$mode = "sync_intro";
}
+ else if( isset($HTTP_POST_VARS['gr_sync_intro']) )
+ {
+ $mode = "gr_sync_intro";
+ }
else
{
$mode = "";
@@ -81,7 +85,8 @@
}
$sql = "SELECT * FROM phpbb_gallery2";
- if(!$result = $db->sql_query($sql))
+ $result = $db->sql_query($sql);
+ if(!$db->sql_numrows($result))
{
$sql = "INSERT INTO phpbb_gallery2 (fullPath, embedPath, embedURI, relativePath, \
loginPath, cookiePath, activeUserID) VALUES ('" . $fullPath . "', '" . $embedPath \
."', '" . $embedURI . "', '" . $relativePath . "','" . $loginPath . "','" . \
$cookiePath . "',$activeUserID)"; @@ -109,7 +114,8 @@
);
$sql = "SELECT * FROM phpbb_gallery2";
- if(!$result = $db->sql_query($sql))
+ $result = $db->sql_query($sql);
+ if(!$db->sql_numrows($result))
{
$sql = "SELECT *
FROM " . CONFIG_TABLE . " WHERE config_name='cookie_path'";
@@ -180,7 +186,7 @@
);
$template->assign_vars(array(
- 'S_G2_ACTION' => append_sid("gallery2_export.$phpEx"),
+ 'S_G2_ACTION' => append_sid("gallery2_export.$phpEx?type=user"),
'L_SYNC_TITLE' => 'Export phpBB Users to Gallery 2',
'L_SYNC_EXPLAIN' => 'This will export your current phpBB2 users to Gallery 2. \
Note that for large numbers of users, this may take some time. Once you click the \
button, a new window will pop up showing you the progress of the export.', 'L_SYNC' \
=> 'Begin user export') @@ -190,6 +196,23 @@
include('./page_footer_admin.'.$phpEx);
}
+else if( $mode == "gr_sync_intro" )
+{
+ $template->set_filenames(array(
+ "body" => "admin/gallery2_sync_intro_body.tpl")
+ );
+
+ $template->assign_vars(array(
+ 'S_G2_ACTION' => append_sid("gallery2_export.$phpEx?type=group"),
+ 'L_SYNC_TITLE' => 'Export phpBB Groups to Gallery 2',
+ 'L_SYNC_EXPLAIN' => 'This will export your current phpBB2 groups to Gallery 2. \
Note that for groups with large numbers of users, this may take some time. Once you \
click the button, a new window will pop up showing you the progress of the export.', \
+ 'L_SYNC' => 'Begin group export') + );
+
+ $template->pparse("body");
+
+ include('./page_footer_admin.'.$phpEx);
+}
else
{
$template->set_filenames(array(
@@ -200,6 +223,7 @@
'S_G2_ACTION' => append_sid("admin_gallery2.$phpEx"),
'L_CONFIG' => 'Configure Gallery 2 Integration',
'L_SYNC' => 'Synchronize phpBB2 Users to Gallery 2',
+ 'L_GR_SYNC' => 'Synchronize phpBB2 Groups to Gallery 2',
'G2_TITLE' => 'Gallery 2 Administration',
'G2_ADMIN_TASK' => 'Choose your Gallery 2 Adminstration Task')
);
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
__[ g a l l e r y - c h e c k i n s ]_________________________
[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic