function user_patterns_export_all_users in Patterns 7.2
Returns a set of PATTERNS_CREATE or PATTERNS_MODIFY actions with the whole set of users currently stored in the system.
Parameters
array $args Set of arguments received from the form.:
string $result Current set of actions for the whole process.:
Return value
array $result Set of actions
1 string reference to 'user_patterns_export_all_users'
- user_patterns in patterns_components/
components/ user.inc - Implements hook_patterns() for the user module.
File
- patterns_components/
components/ user.inc, line 136
Code
function user_patterns_export_all_users($args = NULL, &$result = NULL) {
//Fetch all user objects except the anonymous
$users = _user_patterns_get_all_users();
$result = array();
switch ($args['type']) {
case PATTERNS_CREATE:
foreach ($users as $user) {
//Create operation generate a new random password
$data = array(
'tag' => 'user',
);
$data['name'] = $user->name;
$data['mail'] = $user->mail;
$data['password'] = user_password();
$data['timezone'] = $user->timezone;
$data['status'] = $user->status;
$action = array(
PATTERNS_CREATE => $data,
);
array_push($result, $action);
}
break;
case PATTERNS_MODIFY:
foreach ($users as $uid => $user) {
//Modify operations override all the available fields but password.
$data = array(
'tag' => 'user',
);
$data['uid'] = $uid;
$data['name'] = $user->name;
$data['mail'] = $user->mail;
$data['timezone'] = $user->timezone;
$data['status'] = $user->status;
$action = array(
PATTERNS_MODIFY => $data,
);
array_push($result, $action);
}
break;
}
return $result;
}