bug fix #825

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bug fix #825

Chris Larson-2

reference to bug #825.  the following table has an added form for a delete option to delete a group in the Settings/Group admin section.  this code goes in modules/Users/listgroups.php in the beginning of the file where there is currently a single form for creating a new group. 

 <table>
    <tr>
      <td>
            <form action="index.php">
             <input type="hidden" name="module" value="Users">
             <input type="hidden" name="action" value="createnewgroup">
             <input type="submit" class="button" name="Submit" value="<? echo $mod_strings['LBL_CREATE_NEW_GROUP']; ?>">
            </form>
         </td>
         <td width="10"></td>
         <td>
            <!-- DELETE GROUP -->
            <form action="index.php">
                    <input type="hidden" name="module" value="Users">
                    <input type="hidden" name="action" value="deletegroup">
                <input type="submit" class="button" name="Submit" value="<? echo $mod_strings['LBL_DELETE_GROUP']; ?>">
            </form>
            <!-- DELETE GROUP -->
          </td>
        </tr>
    </table>

--------

also, in modules\Users\language\en_us.lang.php you must add the following line
// Added fields in listgroups.php
'LBL_DELETE_GROUP'=>'Delete Group',

----------------------

in file Modules/Users/UserInfoUtil.php, add the following function for deleting a group

function deleteGroup($groupName)
{
    global $adb;
    $sql = "delete from groups where name='". mysql_real_escape_string($groupName) ."'";
    $adb->query($sql);
    header("Location: index.php?module=Users&action=listgroups");
}

and modify the following if statement to include an elseif block for deleting a group
---located around line 430(?)

if(isset($_REQUEST['actiontype']))
{
  if($_REQUEST['actiontype'] == 'createnewgroup')
  {
    $groupname = $_REQUEST['groupName'];
    $description = $_REQUEST['groupDescription'];
    //get the new group name
    createNewGroup($groupname,$description);
  }
  elseif($_REQUEST['actiontype'] == 'deletegroup')
  {
    // DELETE GROUP FROM DB
    $groupname = $_REQUEST['groupName'];
    deleteGroup($groupname);
  }
}
----------------------

last thing is to add the file modules/Users/deletegroup.php which i have attached.

---chris


deletegroup.php (3K) Download Attachment