[CS-Project-svn_notify] SF.net SVN: cs-project: [778] trunk
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-02-04 23:13:59
|
Revision: 778 http://cs-project.svn.sourceforge.net/cs-project/?rev=778&view=rev Author: crazedsanity Date: 2008-02-04 15:13:44 -0800 (Mon, 04 Feb 2008) Log Message: ----------- AJAX stuff for adding/removing users to/from groups (doesn't update UI yet). Modified Paths: -------------- trunk/includes/content/settings.inc trunk/includes/content/shared.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/includes/content/settings.inc 2008-02-04 23:13:44 UTC (rev 778) @@ -13,6 +13,14 @@ $prefObj = new pref($page->db, $_SESSION['uid']); $GLOBALS['objects']['pref'] = $prefObj; +if($user->is_admin() == 1) { + //add the template to show various admin stuff. + $page->add_template_var("admin_section", $page->templateRows['admin_section']); + + //create an object with administrative capabilities. + $adminUserClass = new adminUserClass($page->db); + $GLOBALS['objects']['admin'] = $adminUserClass; +} addAjax(); @@ -333,4 +341,45 @@ return($objResponse); }//end ajax__update_preference() + + + + +function ajax__group_user($groupId, $uid, $addRemove) { + $user = $GLOBALS['objects']['user']; + $page = $GLOBALS['objects']['page']; + $objResponse = new xajaxResponse(); + if($user->is_admin()) { + + $adminUserClass = $GLOBALS['objects']['admin']; + if($addRemove == 'add') { + $result = $adminUserClass->add_user_to_group($uid, $groupId); + } + else { + $result = $adminUserClass->remove_user_from_group($uid, $groupId); + } + + $msg = array( + 'title' => "Update Complete", + 'message' => "Result of <b>". $addRemove ."</b>: (". $result .")", + 'type' => "status" + ); + + + $page->set_message_wrapper($msg); + + //now regenerate the current users & the excluded users lists. + } + else { + $msg = array( + 'title' => "Admin Privileges Required", + 'message' => "You must have admin privileges in order to perform this action.", + 'type' => "error" + ); + $page->set_message_wrapper($msg); + } + $objResponse->addAssign('MAIN_error_message', 'innerHTML', $page->process_set_message()); + + return($objResponse); +}//end ajax__group_add_user() ?> Modified: trunk/includes/content/shared.inc =================================================================== --- trunk/includes/content/shared.inc 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/includes/content/shared.inc 2008-02-04 23:13:44 UTC (rev 778) @@ -17,6 +17,7 @@ $GLOBALS['objects']['page'] =& $page; $GLOBALS['objects']['proj'] =& $proj; $GLOBALS['objects']['tag'] =& $proj->tagObj; +$GLOBALS['objects']['user'] =& $user; /** Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:12:12 UTC (rev 777) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:13:44 UTC (rev 778) @@ -90,6 +90,8 @@ <hr> <h2><font color="red">Administrative Settings</font></h2> + +<a name="group"> <table border=1 cellpadding=3 cellspacing=0> <tr> <th colspan="3"><a href="#groupManagement"></a>Group Management</th> @@ -121,7 +123,7 @@ <table> <!-- BEGIN show_group_list__removeUser --> <tr> - <td>(<b><a href="?action=removeUser&groupId=%%group_id%%&uid=%%uid%%">Remove</a></b>) %%username%%</td> + <td>(<b><a href="javascript:void(xajax_ajax__group_user(%%group_id%%, %%uid%%, 'remove'));">Remove</a></b>) %%username%%</td> </tr> <!-- END show_group_list__removeUser --> <!-- BEGIN show_group_list__noRemoveUser --> @@ -136,7 +138,7 @@ <table> <!-- BEGIN show_group_list__selectUser --> <tr> - <td>(<b><a href="?action=addUser&groupId=%%group_id%%&uid=%%uid%%">Add</a></b>) %%username%%</td> + <td>(<b><a href="javascript:void(xajax_ajax__group_user(%%group_id%%, %%uid%%, 'add'));">Add</a></b>) %%username%%</td> </tr> <!-- END show_group_list__selectUser --> <!-- BEGIN show_group_list__noUser --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |