Issue Details (XML | Word | Printable)

Key: MDL-13127
Type: Sub-task Sub-task
Status: Reopened Reopened
Priority: Minor Minor
Assignee: David Castro
Reporter: Martin Dougiamas
Votes: 0
Watchers: 4
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-20806

delete_users

Created: 24/Jan/08 02:57 PM   Updated: 11/Nov/09 11:05 AM
Return to search
Component/s: Administration
Affects Version/s: 1.9
Fix Version/s: None

Participants: David Castro, Jerome Mouneyrac, Jordi Piguillem Poch, Ludo ( Marc Alier), Martin Dougiamas and Tusefomal
Security Level: None
Resolved date: 10/Oct/08
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
Delete one or more users

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
David Castro added a comment - 27/Jun/08 07:46 PM
We have implemented this functionality only by userid .

If we want delete some users by different criteria, we could do some functions like delete_users_by_id, delete_users_by_idnumber, delete_users_by_email, etc.

Or do it in a function delete_users ($array, $criteria);
where $criteria is a string {id, idnumber or email}
and $array is the array with values for specified criteria.


Ludo ( Marc Alier) added a comment - 28/Jun/08 11:11 PM
This is a general problem that we will find in all the API.
Shall we have just one funcion with complex parameters or do we want a looong list of functions.
Anyway : Maintenance is the issue.
IMO we should have only one function to do the actual work (so it can be modified when needed): The currently implemented delete_user(id) or similar.
The we can have a set of functions (or just one with complex parameters) that using this one allows more functionality.

Insigths?


Jerome Mouneyrac added a comment - 30/Jun/08 10:07 AM - edited
Hi David, hi ludo,
I read the specification (http://docs.moodle.org/en/Development:Web_services) and there is one delete_users() function with an array as parameter. Is that your question?

Ludo ( Marc Alier) added a comment - 30/Jun/08 02:16 PM
According to current spec: The function receives and array with

idnumber or
email or
id or
login

OK; NOW how do I know WHAT IS a value in the array ?
This is the question...

David Castro added a comment - 04/Jul/08 11:26 PM
Hi,

We think that the easiest way to solve this functionality is deleting only by id or idnumber, because all of them are unique on Moodle.


Jordi Piguillem Poch added a comment - 09/Jul/08 07:29 PM
Some more PHPDoc from spec

/**

  • Deletes an user
  • User is marked as deleted
  • All it's role assignments are destroyed
  • @private ?
  • @param string $field Possible values:
  • <ul>
  • <li>id</li>
  • <li>idnumber</li>
  • <li>login</li>
  • <li>email</li>
  • </ul>
  • @param string $value
  • @return boolean
    */
    function delete_user($field, $values){
    }

/**

  • Deletes several users
  • Users are marked as deleted
  • All their role assignments are destroyed
  • @param string $field Possible values:
  • <ul>
  • <li>id</li>
  • <li>idnumber</li>
  • <li>login</li>
  • <li>email</li>
  • </ul>
  • @param array $values
  • @uses delete_user
    *
  • @return boolean
    */
    function delete_users($field, $values){
    }

Tusefomal added a comment - 16/Sep/08 12:59 AM
I've just added in the CVS the add_user function working with an associative array as it's suggested. It can be find here:

http://cvs.moodle.org/contrib/patches/dfws/webservice/apis/user.lib.php?revision=1.4&view=markup

The name of the function is:

array mdl_user_delete_instances($userids, $idtype='idnumber')

The particles of the name are explained here: http://tracker.moodle.org/browse/MDL-13126?focusedCommentId=56209#action_56209

The function gets one mandatory param and am optional one, and returns an associative array of identifier=>boolean. The hot point of this function is that users can be identified by several fields:

-username
-email
-internal id
-idnumber (in my point of view is the best way)

So, to implement this function we decided to allow all of them. The default is 'idnumber' but, you can pass an array of internal ids, usernames or emails too, just by specify it in the second parameter.


Tusefomal added a comment - 17/Sep/08 12:12 AM
As Martin wants (and Pigui remember me), in delete_users the first param will be a criteria and the second an array of users. This makes default value impossible, but it's may be more polite. New code can be found threre:

http://cvs.moodle.org/contrib/patches/dfws/webservice/apis/user.lib.php?revision=1.5&view=markup


David Castro added a comment - 10/Oct/08 01:40 AM
Implemented and finished on CVS.