src/snac/server/database/SQL.php
/**
     * Really delete a role
     *
     * Used for testing only, maybe. In any case, deleting a role should be rare. To make this a little safer
     * it only deletes if the role is not in use.
     *
     * Before deleting a role, remove all privilege links for it. Otherwise it appears to the privilege code
     * that the privileges are still in use.
     *
     * What about either deleting the role from all users? Or not allowing the role to be deleted if still
     * used by some user?
     *
     * @throws \snac\exceptions\SNACDatabaseException
     *
     * @param integer $roleID An role id
     */
Really delete a role
Used for testing only, maybe. In any case, deleting a role should be rare. To make this a little safer
it only deletes if the role is not in use.

Before deleting a role, remove all privilege links for it. Otherwise it appears to the privilege code
that the privileges are still in use.





@param integer $roleID An role id
Really delete a role Used for testing only maybe . In any case deleting a role should be rare . To make this a little safer it only deletes if the role is not in use . Before deleting a role remove all privilege links for it . Otherwise it appears to the privilege code that the privileges are still in use . @param integer $roleID An role id
public function deleteRole($roleID)
    {
        $result = $this->sdb->query(
            'select appuser.username from appuser,appuser_role_link as arl where  arl.rid=$1 and arl.uid=appuser.id',
            array($roleID));
        $usernames = "";
        while($row = $this->sdb->fetchrow($result))
        {
            $usernames .= $row['username'] . " ";
        }
        if ($usernames)
        {
            throw new \snac\exceptions\SNACDatabaseException("Tried to delete role still used by users: $usernames");
        }
        else
        {
            $this->sdb->query(
                'delete from privilege_role_link where rid=$1',
                array($roleID));
            $this->sdb->query(
                'delete from role where id=$1 and id not in (select distinct(rid) from appuser_role_link)',
                array($roleID));
        }
    }
public function deleteRole ( $ roleID ) { $ result = $ this -> sdb -> query ( 'select appuser.username from appuser,appuser_role_link as arl where  arl.rid=$1 and arl.uid=appuser.id' , array ( $ roleID ) ) ; $ usernames = " " ; while ( $ row = $ this -> sdb -> fetchrow ( $ result ) ) { $ usernames .= $ row [ 'username' ] . " " ; } if ( $ usernames ) { throw new \ snac \ exceptions \ SNACDatabaseException ( " Tried to delete role still used by users:  $ usernames " ) ; } else { $ this -> sdb -> query ( 'delete from privilege_role_link where rid=$1' , array ( $ roleID ) ) ; $ this -> sdb -> query ( 'delete from role where id=$1 and id not in (select distinct(rid) from appuser_role_link)' , array ( $ roleID ) ) ; } }
Really delete a role
 Used for testing only, maybe.
Really delete a role Used for testing only maybe .