ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilServicesUserTasks Class Reference

Class ilServicesUserTasks. More...

+ Collaboration diagram for ilServicesUserTasks:

Static Public Member Functions

static createAnonymousUsers ($context, $params)
 
static repersonalizeUsers ($context, $params)
 

Data Fields

const ANON_FIRSTNAME = 'Anonymous'
 
const ANON_LASTNAME = 'Exam-User'
 
const ANON_LOGIN_PREFIX = 'EX-'
 
const ANON_GENDER = 'm'
 
const PASSWORD_CHARACTERSET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
 

Static Protected Member Functions

static getValidLogin ()
 
static generatePassword ($length=8)
 
static createUser ($login, $password, $email)
 

Detailed Description

Class ilServicesUserTasks.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file class.ilServicesUserTasks.php.

Member Function Documentation

◆ createAnonymousUsers()

static ilServicesUserTasks::createAnonymousUsers (   $context,
  $params 
)
static
Parameters
ilNode$context
array$params
Returns
array

Definition at line 25 of file class.ilServicesUserTasks.php.

References PHPMailer\PHPMailer\$params.

26  {
27  $input_params = $params[0];
28  $output_params =$params[1];
29 
30  // IN: useridlist
31  // OUT: anonaccountlist, userIdList
32 
33  $pseudonymousUserMap = array();
34  $discloseMap = array();
35  $usrIdList = array();
36 
37  foreach ($input_params['usrIdList'] as $user_id) {
38  $source_user = new ilObjUser($user_id, false);
39  $anon_login = self::getValidLogin();
40  $anon_password = self::generatePassword();
41  $new_id = self::createUser(
42  $anon_login,
43  $anon_password,
44  $source_user->getEmail()
45  );
46 
47  $pseudonymousUserMap[] = array(
48  'Original User' => $user_id,
49  'Anonymous User' => $new_id
50  );
51 
52  $discloseMap[] = array(
53  'Original User' => $user_id,
54  'Original Login' => $source_user->getLogin(),
55  'Original Firstname' => $source_user->getFirstname(),
56  'Original Lastname' => $source_user->getLastname(),
57  'Original Matriculation' => $source_user->getMatriculation(),
58  'Original Gender' => $source_user->getGender(),
59  'Original EMail' => $source_user->getEmail(),
60  'Anon User' => $new_id,
61  'Anon Login' => $anon_login,
62  'Anon Password' => $anon_password
63  );
64 
65  $usrIdList[] = $new_id;
66  }
67 
68  return array($output_params[0] => $discloseMap);
69  }

◆ createUser()

static ilServicesUserTasks::createUser (   $login,
  $password,
  $email 
)
staticprotected
Parameters
string$login
string$password
string$email
Returns
int

Definition at line 110 of file class.ilServicesUserTasks.php.

References $DIC, $email, $login, $password, $user, and IL_PASSWD_PLAIN.

111  {
112  global $DIC;
113  $rbacadmin = $DIC['rbacadmin'];
114 
115  $user = new ilObjUser();
116  $user->setTimeLimitUnlimited(true);
117  $user->setFirstname(self::ANON_FIRSTNAME);
118  $user->setLastname(self::ANON_LASTNAME);
119  $user->setEmail($email);
120  $user->setGender(self::ANON_GENDER);
121  $user->setPasswd($password, IL_PASSWD_PLAIN);
122  $user->setLogin($login);
123  $user->setActive(true, 6);
124  $user->create();
125 
126  $user->setLastPasswordChangeTS(0);
127  $user->saveAsNew();
128 
129  $user->setPref('send_info_mails', 'n');
130  $user->writePrefs();
131 
132  $rbacadmin->assignUser(4, $user->getId(), true);
133 
134  return $user->getId();
135  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:201
const IL_PASSWD_PLAIN
global $DIC
Definition: saml.php:7
$user
Definition: migrateto20.php:57
$password
Definition: cron.php:14
$login
Definition: cron.php:13

◆ generatePassword()

static ilServicesUserTasks::generatePassword (   $length = 8)
staticprotected
Parameters
int$length
Returns
string

Definition at line 89 of file class.ilServicesUserTasks.php.

References $i, $index, and $password.

90  {
91  $random = new \ilRandom();
92  $password = array();
93  $setLength = strlen(self::PASSWORD_CHARACTERSET) - 1;
94 
95  for ($i = 0; $i < $length; $i++) {
96  $index = $random->int(0, $setLength);
97  $password[] = self::PASSWORD_CHARACTERSET[$index];
98  }
99 
100  return implode($password);
101  }
$index
Definition: metadata.php:60
$password
Definition: cron.php:14
$i
Definition: disco.tpl.php:19

◆ getValidLogin()

static ilServicesUserTasks::getValidLogin ( )
staticprotected
Returns
string

Definition at line 74 of file class.ilServicesUserTasks.php.

References $login, and ilObjUser\_loginExists().

75  {
76  $random = new \ilRandom();
77  do {
78  $login = self::ANON_LOGIN_PREFIX . str_pad($random->int(0, 9999999), 7, STR_PAD_LEFT);
80 
81  return $login;
82  }
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
$login
Definition: cron.php:13
+ Here is the call graph for this function:

◆ repersonalizeUsers()

static ilServicesUserTasks::repersonalizeUsers (   $context,
  $params 
)
static
Parameters
ilNode$context
array$params

Definition at line 141 of file class.ilServicesUserTasks.php.

References PHPMailer\PHPMailer\$params.

142  {
143  // IN: discloseMap
144  $input_params = $params[0];
145  $output_params =$params[1];
146 
147  foreach ($input_params['discloseMap'] as $disclose_entry) {
148  $anon_user = new ilObjUser($disclose_entry['Anon User'], false);
149  $anon_user->setFirstname($disclose_entry['Original Firstname']);
150  $anon_user->setLastname($disclose_entry['Original Lastname']);
151  $anon_user->setMatriculation($disclose_entry['Original Matriculation']);
152  $anon_user->setGender($disclose_entry['Original Gender']);
153  $anon_user->update();
154  }
155 
156  // OUT: void
157  }

Field Documentation

◆ ANON_FIRSTNAME

const ilServicesUserTasks::ANON_FIRSTNAME = 'Anonymous'

Definition at line 13 of file class.ilServicesUserTasks.php.

◆ ANON_GENDER

const ilServicesUserTasks::ANON_GENDER = 'm'

Definition at line 16 of file class.ilServicesUserTasks.php.

◆ ANON_LASTNAME

const ilServicesUserTasks::ANON_LASTNAME = 'Exam-User'

Definition at line 14 of file class.ilServicesUserTasks.php.

◆ ANON_LOGIN_PREFIX

const ilServicesUserTasks::ANON_LOGIN_PREFIX = 'EX-'

Definition at line 15 of file class.ilServicesUserTasks.php.

◆ PASSWORD_CHARACTERSET

const ilServicesUserTasks::PASSWORD_CHARACTERSET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'

Definition at line 17 of file class.ilServicesUserTasks.php.


The documentation for this class was generated from the following file: