[CS-Project-svn_notify] SF.net SVN: cs-project: [779] trunk
Brought to you by:
crazedsanity
From: <cra...@us...> - 2008-02-04 23:31:54
|
Revision: 779 http://cs-project.svn.sourceforge.net/cs-project/?rev=779&view=rev Author: crazedsanity Date: 2008-02-04 15:31:49 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Changes to generate/regenerate group member lists via AJAX. Modified Paths: -------------- trunk/includes/content/settings.inc trunk/templates/content/settings/index.content.tmpl Modified: trunk/includes/content/settings.inc =================================================================== --- trunk/includes/content/settings.inc 2008-02-04 23:13:44 UTC (rev 778) +++ trunk/includes/content/settings.inc 2008-02-04 23:31:49 UTC (rev 779) @@ -152,7 +152,7 @@ } else { //some display settings. - $x = $page->set_all_block_rows("content"); + $x = $page->set_all_block_rows("content", array('group_nonMembers', 'group_currentMembers')); @@ -223,84 +223,7 @@ $showGroup = $_SESSION['login_group_id']; } $page->ui->set_cache("settings/showGroup", $showGroup); - - //get a complete list of users. - $allUsers = $adminUserClass->get_users(); - - //display the list of available groups. - $repArr = $adminUserClass->get_groups(FALSE); - $displayGroupList = array_as_option_list( - $myGroups, $showGroup, "select", $page->templateRows['show_group_list'], $repArr - ); - $page->add_template_var('show_group_list', $displayGroupList); - - //set this for later use... - $myGroupData = $repArr[$showGroup]; - - //now show all the users (if there are any) associated with that group. - $groupData = $adminUserClass->get_group_user($showGroup); - $page->add_template_var('groupId', $showGroup); - $page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); - - if(is_array($groupData) && count($groupData)) { - $baseRow = $page->templateRows['show_group_list__selectUser']; - $addUsersRow = ""; - $removeUsersRow = ""; - - //build the list of users that CAN be added, and the list that can be removed. - $addUsers = 0; - $removeUsers = 0; - $changeLeaderOptionArr = array(); - foreach($allUsers as $uid=>$userData) { - $userData['group_id'] = $showGroup; - if(isset($groupData[$uid])) { - //they're already in this group. - $removeUsersRow .= mini_parser($page->templateRows['show_group_list__removeUser'], $userData, '%%', '%%'); - $removeUsers++; - $changeLeaderOptionArr[$uid] = $userData['username']; - } - else { - //not in this group. - $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); - $addUsers++; - } - } - - //set the option list for changing the leader! - $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); - $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); - - if($removeUsers) { - //show 'em the list to be removed. - $page->add_template_var('show_group_list__removeUser', $removeUsersRow); - } - else { - //tell 'em there's no users to be removed. - $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); - } - - if($addUsers) { - //show 'em. - $page->add_template_var('show_group_list__selectUser', $addUsersRow); - } - else { - //no users to add. - $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); - } - } - else { - //show the row that says there's no users. - $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); - - //now put ALL users into the list that can be added... - foreach($allUsers as $uid=>$userData) { - $userData['group_id'] = $showGroup; - $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); - $addUsers++; - } - $page->add_template_var('show_group_list__selectUser', $addUsersRow); - $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); - } + regenerate_group_lists($showGroup); } } } @@ -382,4 +305,109 @@ return($objResponse); }//end ajax__group_add_user() + + +function regenerate_group_lists($groupId) { + $user = $GLOBALS['objects']['user']; + $page = $GLOBALS['objects']['page']; + $page->ui = new sessionCache("/userInput/content"); + $objResponse = new xajaxResponse(); + + if($user->is_admin()) { + $page->set_all_block_rows(); + $adminUserClass = $GLOBALS['objects']['admin']; + $myGroups = $adminUserClass->get_groups(TRUE); + + //get a complete list of users. + $allUsers = $adminUserClass->get_users(); + + //display the list of available groups. + $repArr = $adminUserClass->get_groups(FALSE); + $displayGroupList = array_as_option_list( + $myGroups, $groupId, "select", $page->templateRows['show_group_list'], $repArr + ); + $page->add_template_var('show_group_list', $displayGroupList); + + //set this for later use... + $myGroupData = $repArr[$groupId]; + + //now show all the users (if there are any) associated with that group. + $groupData = $adminUserClass->get_group_user($groupId); + $page->add_template_var('groupId', $groupId); + $page->add_template_var('currentGroupLeader', $allUsers[$myGroupData['leader_uid']]['username']); + + $addUsers = 0; + $removeUsers = 0; + if(is_array($groupData) && count($groupData)) { + $baseRow = $page->templateRows['show_group_list__selectUser']; + $addUsersRow = ""; + $removeUsersRow = ""; + + //build the list of users that CAN be added, and the list that can be removed. + $addUsers = 0; + $removeUsers = 0; + $changeLeaderOptionArr = array(); + foreach($allUsers as $uid=>$userData) { + $userData['group_id'] = $groupId; + if(isset($groupData[$uid])) { + //they're already in this group. + $removeUsersRow .= mini_parser($page->templateRows['show_group_list__removeUser'], $userData, '%%', '%%'); + $removeUsers++; + $changeLeaderOptionArr[$uid] = $userData['username']; + } + else { + //not in this group. + $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); + $addUsers++; + } + } + + //set the option list for changing the leader! + $changeLeaderOption = array_as_option_list($changeLeaderOptionArr, $myGroupData['leader_uid']); + $page->add_template_var('changeGroupLeader_list', $changeLeaderOption); + + if($removeUsers) { + //show 'em the list to be removed. + $page->add_template_var('show_group_list__removeUser', $removeUsersRow); + } + else { + //tell 'em there's no users to be removed. + $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); + } + + if($addUsers) { + //show 'em. + $page->add_template_var('show_group_list__selectUser', $addUsersRow); + } + else { + //no users to add. + $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); + } + } + else { + //show the row that says there's no users. + $page->add_template_var('show_group_list__selectUser', $page->templateRows['show_group_list__noUser']); + + //now put ALL users into the list that can be added... + foreach($allUsers as $uid=>$userData) { + $userData['group_id'] = $groupId; + $addUsersRow .= mini_parser($page->templateRows['show_group_list__selectUser'], $userData, '%%', '%%'); + $addUsers++; + } + $page->add_template_var('show_group_list__selectUser', $addUsersRow); + $page->add_template_var('show_group_list__removeUser', $page->templateRows['show_group_list__noRemoveUser']); + } + } + 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 regenerate_group_lists() ?> Modified: trunk/templates/content/settings/index.content.tmpl =================================================================== --- trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:13:44 UTC (rev 778) +++ trunk/templates/content/settings/index.content.tmpl 2008-02-04 23:31:49 UTC (rev 779) @@ -120,6 +120,8 @@ </td> <td> + <div id="group_nonMembers"> + <!-- BEGIN group_nonMembers --> <table> <!-- BEGIN show_group_list__removeUser --> <tr> @@ -132,9 +134,13 @@ </tr> <!-- END show_group_list__noRemoveUser --> </table> + <!-- END group_nonMembers --> + </div> </td> <td> + <div id="group_currentMembers"> + <!-- BEGIN group_currentMembers --> <table> <!-- BEGIN show_group_list__selectUser --> <tr> @@ -147,6 +153,8 @@ </tr> <!-- END show_group_list__noUser --> </table> + <!-- END group_currentMembers --> + </div> </td> </tr> </table> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |