Skip to content

Commit a59ecf1

Browse files
committed
UnityUser as well
1 parent bab6f45 commit a59ecf1

21 files changed

+201
-210
lines changed

resources/init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@
119119
$SEND_PIMESG_TO_ADMINS = $CONFIG["mail"]["send_pimesg_to_admins"];
120120

121121
$SQL->addLog(
122-
$OPERATOR->getUID(),
122+
$OPERATOR->uid,
123123
$_SERVER['REMOTE_ADDR'],
124124
"user_login",
125-
$OPERATOR->getUID()
125+
$OPERATOR->uid
126126
);
127127

128128
if (!$_SESSION["user_exists"]) {

resources/lib/UnityGroup.php

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_
7474
}
7575

7676
// check if account deletion request already exists
77-
if ($this->SQL->accDeletionRequestExists($this->getOwner()->getUID())) {
77+
if ($this->SQL->accDeletionRequestExists($this->getOwner()->uid)) {
7878
return;
7979
}
8080

81-
$this->SQL->addRequest($this->getOwner()->getUID(), $firstname, $lastname, $email, $org);
81+
$this->SQL->addRequest($this->getOwner()->uid, $firstname, $lastname, $email, $org);
8282

8383
if ($send_mail) {
8484
// send email to requestor
@@ -90,7 +90,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_
9090
$this->WEBHOOK->sendWebhook(
9191
"group_request_admin",
9292
array(
93-
"user" => $this->getOwner()->getUID(),
93+
"user" => $this->getOwner()->uid,
9494
"org" => $org,
9595
"name" => "$firstname $lastname",
9696
"email" => $email
@@ -102,7 +102,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_
102102
"admin",
103103
"group_request_admin",
104104
array(
105-
"user" => $this->getOwner()->getUID(),
105+
"user" => $this->getOwner()->uid,
106106
"org" => $org,
107107
"name" => "$firstname $lastname",
108108
"email" => $email
@@ -114,7 +114,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_
114114
"pi_approve",
115115
"group_request_admin",
116116
array(
117-
"user" => $this->getOwner()->getUID(),
117+
"user" => $this->getOwner()->uid,
118118
"org" => $org,
119119
"name" => "$firstname $lastname",
120120
"email" => $email
@@ -128,7 +128,7 @@ public function requestGroup($firstname, $lastname, $email, $org, $send_mail_to_
128128
*/
129129
public function approveGroup($operator = null, $send_mail = true)
130130
{
131-
$uid = $this->getOwner()->getUID();
131+
$uid = $this->getOwner()->uid;
132132
$request = $this->SQL->getRequest($uid, UnitySQL::REQUEST_BECOME_PI);
133133

134134
// check for edge cases...
@@ -152,15 +152,15 @@ public function approveGroup($operator = null, $send_mail = true)
152152

153153
// remove the request from the sql table
154154
// this will silently fail if the request doesn't exist
155-
$this->SQL->removeRequest($this->getOwner()->getUID());
155+
$this->SQL->removeRequest($this->getOwner()->uid);
156156

157-
$operator = is_null($operator) ? $this->getOwner()->getUID() : $operator->getUID();
157+
$operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid;
158158

159159
$this->SQL->addLog(
160160
$operator,
161161
$_SERVER['REMOTE_ADDR'],
162162
"approved_group",
163-
$this->getOwner()->getUID()
163+
$this->getOwner()->uid
164164
);
165165

166166
// send email to the newly approved PI
@@ -178,19 +178,19 @@ public function approveGroup($operator = null, $send_mail = true)
178178
public function denyGroup($operator = null, $send_mail = true)
179179
{
180180
// remove request - this will fail silently if the request doesn't exist
181-
$this->SQL->removeRequest($this->getOwner()->getUID());
181+
$this->SQL->removeRequest($this->getOwner()->uid);
182182

183183
if ($this->exists()) {
184184
return;
185185
}
186186

187-
$operator = is_null($operator) ? $this->getOwner()->getUID() : $operator->getUID();
187+
$operator = is_null($operator) ? $this->getOwner()->uid : $operator->uid;
188188

189189
$this->SQL->addLog(
190190
$operator,
191191
$_SERVER['REMOTE_ADDR'],
192192
"denied_group",
193-
$this->getOwner()->getUID()
193+
$this->getOwner()->uid
194194
);
195195

196196
// send email to the requestor
@@ -204,17 +204,17 @@ public function denyGroup($operator = null, $send_mail = true)
204204

205205
public function cancelGroupRequest($send_mail = true)
206206
{
207-
if (!$this->SQL->requestExists($this->getOwner()->getUID())) {
207+
if (!$this->SQL->requestExists($this->getOwner()->uid)) {
208208
return;
209209
}
210210

211-
$this->SQL->removeRequest($this->getOwner()->getUID());
211+
$this->SQL->removeRequest($this->getOwner()->uid);
212212

213213
if ($send_mail) {
214214
$this->MAILER->sendMail(
215215
"admin",
216216
"group_request_cancelled",
217-
["uid" => $this->getOwner()->getUID()],
217+
["uid" => $this->getOwner()->uid],
218218
);
219219
}
220220
}
@@ -225,14 +225,14 @@ public function cancelGroupJoinRequest($user, $send_mail = true)
225225
return;
226226
}
227227

228-
$this->SQL->removeRequest($user->getUID(), $this->gid);
228+
$this->SQL->removeRequest($user->uid, $this->gid);
229229

230230
if ($send_mail) {
231231
// send email to requestor
232232
$this->MAILER->sendMail(
233233
$this->getOwner()->getMail(),
234234
"group_join_request_cancelled",
235-
["uid" => $user->getUID()]
235+
["uid" => $user->uid]
236236
);
237237
}
238238
}
@@ -260,7 +260,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true)
260260
// $ldapPiGroupEntry->delete();
261261
// $this->REDIS->removeCacheArray("sorted_groups", "", $this->gid);
262262
// foreach ($users as $user) {
263-
// $this->REDIS->removeCacheArray($user->getUID(), "groups", $this->gid);
263+
// $this->REDIS->removeCacheArray($user->uid, "groups", $this->gid);
264264
// }
265265
// }
266266

@@ -281,7 +281,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true)
281281
*/
282282
public function approveUser($new_user, $send_mail = true)
283283
{
284-
$uid = $new_user->getUID();
284+
$uid = $new_user->uid;
285285
$request = $this->SQL->getRequest($uid, $this->gid);
286286
// check if user exists
287287
if (!$new_user->exists()) {
@@ -296,7 +296,7 @@ public function approveUser($new_user, $send_mail = true)
296296
// add user to the LDAP object
297297
$this->addUserToGroup($new_user);
298298

299-
$this->SQL->removeRequest($new_user->getUID(), $this->gid);
299+
$this->SQL->removeRequest($new_user->uid, $this->gid);
300300

301301
// send email to the requestor
302302
if ($send_mail) {
@@ -312,22 +312,22 @@ public function approveUser($new_user, $send_mail = true)
312312
"group_user_added_owner",
313313
array(
314314
"group" => $this->gid,
315-
"user" => $new_user->getUID(),
315+
"user" => $new_user->uid,
316316
"name" => $request["firstname"] . " " . $request["lastname"],
317317
"email" => $request["email"],
318318
"org" => $request["org"],
319-
)
319+
)
320320
);
321321
}
322322
}
323323

324324
public function denyUser($new_user, $send_mail = true)
325325
{
326-
$uid = $new_user->getUID();
326+
$uid = $new_user->uid;
327327
$request = $this->SQL->getRequest($uid, $this->gid);
328328

329329
// remove request, this will fail silently if the request doesn't exist
330-
$this->SQL->removeRequest($new_user->getUID(), $this->gid);
330+
$this->SQL->removeRequest($new_user->uid, $this->gid);
331331

332332
if ($send_mail) {
333333
// send email to the user
@@ -343,11 +343,11 @@ public function denyUser($new_user, $send_mail = true)
343343
"group_user_denied_owner",
344344
array(
345345
"group" => $this->gid,
346-
"user" => $new_user->getUID(),
346+
"user" => $new_user->uid,
347347
"name" => $new_user->getFullName(),
348348
"email" => $new_user->getMail(),
349349
"org" => $new_user->getOrg()
350-
)
350+
)
351351
);
352352
}
353353
}
@@ -358,7 +358,7 @@ public function removeUser($new_user, $send_mail = true)
358358
return;
359359
}
360360

361-
if ($new_user->getUID() == $this->getOwner()->getUID()) {
361+
if ($new_user->uid == $this->getOwner()->uid) {
362362
throw new Exception("Cannot delete group owner from group. Disband group instead");
363363
}
364364

@@ -379,11 +379,11 @@ public function removeUser($new_user, $send_mail = true)
379379
"group_user_removed_owner",
380380
array(
381381
"group" => $this->gid,
382-
"user" => $new_user->getUID(),
382+
"user" => $new_user->uid,
383383
"name" => $new_user->getFullName(),
384384
"email" => $new_user->getMail(),
385385
"org" => $new_user->getOrg()
386-
)
386+
)
387387
);
388388
}
389389
}
@@ -400,12 +400,12 @@ public function newUserRequest($new_user, $firstname, $lastname, $email, $org, $
400400
return;
401401
}
402402

403-
if ($this->SQL->accDeletionRequestExists($new_user->getUID())) {
403+
if ($this->SQL->accDeletionRequestExists($new_user->uid)) {
404404
throw new Exception("user '$new_user' requested account deletion");
405405
return;
406406
}
407407

408-
$this->addRequest($new_user->getUID(), $firstname, $lastname, $email, $org);
408+
$this->addRequest($new_user->uid, $firstname, $lastname, $email, $org);
409409

410410
if ($send_mail) {
411411
// send email to user
@@ -421,11 +421,11 @@ public function newUserRequest($new_user, $firstname, $lastname, $email, $org, $
421421
"group_user_request_owner",
422422
array(
423423
"group" => $this->gid,
424-
"user" => $new_user->getUID(),
424+
"user" => $new_user->uid,
425425
"name" => "$firstname $lastname",
426426
"email" => $email,
427427
"org" => $org,
428-
)
428+
)
429429
);
430430
}
431431
}
@@ -464,17 +464,17 @@ public function getGroupMembers($ignorecache = false)
464464
{
465465
$members = $this->getGroupMemberUIDs($ignorecache);
466466
$out = array();
467-
$owner_uid = $this->getOwner()->getUID();
467+
$owner_uid = $this->getOwner()->uid;
468468
foreach ($members as $member) {
469-
$user_obj = new UnityUser(
470-
$member,
471-
$this->LDAP,
472-
$this->SQL,
473-
$this->MAILER,
474-
$this->REDIS,
475-
$this->WEBHOOK
476-
);
477-
array_push($out, $user_obj);
469+
$user_obj = new UnityUser(
470+
$member,
471+
$this->LDAP,
472+
$this->SQL,
473+
$this->MAILER,
474+
$this->REDIS,
475+
$this->WEBHOOK
476+
);
477+
array_push($out, $user_obj);
478478
}
479479
return $out;
480480
}
@@ -505,7 +505,7 @@ public function requestExists($user)
505505
$requesters = $this->getRequests();
506506
if (count($requesters) > 0) {
507507
foreach ($requesters as $requester) {
508-
if ($requester[0]->getUID() == $user->getUID()) {
508+
if ($requester[0]->uid == $user->uid) {
509509
return true;
510510
}
511511
}
@@ -531,7 +531,7 @@ private function init()
531531

532532
$ldapPiGroupEntry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS);
533533
$ldapPiGroupEntry->setAttribute("gidnumber", strval($nextGID));
534-
$ldapPiGroupEntry->setAttribute("memberuid", array($owner->getUID()));
534+
$ldapPiGroupEntry->setAttribute("memberuid", array($owner->uid));
535535
$ldapPiGroupEntry->write();
536536
}
537537

@@ -544,25 +544,25 @@ private function addUserToGroup($new_user)
544544
{
545545
// Add to LDAP Group
546546
$pi_group = $this->getLDAPPiGroup();
547-
$pi_group->appendAttribute("memberuid", $new_user->getUID());
547+
$pi_group->appendAttribute("memberuid", $new_user->uid);
548548
$pi_group->write();
549-
$this->REDIS->appendCacheArray($this->gid, "members", $new_user->getUID());
550-
$this->REDIS->appendCacheArray($new_user->getUID(), "groups", $this->gid);
549+
$this->REDIS->appendCacheArray($this->gid, "members", $new_user->uid);
550+
$this->REDIS->appendCacheArray($new_user->uid, "groups", $this->gid);
551551
}
552552

553553
private function removeUserFromGroup($old_user)
554554
{
555555
// Remove from LDAP Group
556556
$pi_group = $this->getLDAPPiGroup();
557-
$pi_group->removeAttributeEntryByValue("memberuid", $old_user->getUID());
557+
$pi_group->removeAttributeEntryByValue("memberuid", $old_user->uid);
558558
$pi_group->write();
559-
$this->REDIS->removeCacheArray($this->gid, "members", $old_user->getUID());
560-
$this->REDIS->removeCacheArray($old_user->getUID(), "groups", $this->gid);
559+
$this->REDIS->removeCacheArray($this->gid, "members", $old_user->uid);
560+
$this->REDIS->removeCacheArray($old_user->uid, "groups", $this->gid);
561561
}
562562

563563
public function userExists($user)
564564
{
565-
return in_array($user->getUID(), $this->getGroupMemberUIDs());
565+
return in_array($user->uid, $this->getGroupMemberUIDs());
566566
}
567567

568568
private function addRequest($uid, $firstname, $lastname, $email, $org)

resources/lib/UnityOrg.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ public function getLDAPOrgGroup()
5252

5353
public function inOrg($user, $ignorecache = false)
5454
{
55-
return in_array($user->getUID(), $this->getOrgMemberUIDs($ignorecache));
55+
return in_array($user->uid, $this->getOrgMemberUIDs($ignorecache));
5656
}
5757

5858
public function getOrgMembers($ignorecache = false)
5959
{
6060
$members = $this->getGroupMemberUIDs($ignorecache);
6161
$out = array();
62-
$owner_uid = $this->getOwner()->getUID();
62+
$owner_uid = $this->getOwner()->uid;
6363
foreach ($members as $member) {
64-
$user_obj = new UnityUser(
65-
$member,
66-
$this->LDAP,
67-
$this->SQL,
68-
$this->MAILER,
69-
$this->REDIS,
70-
$this->WEBHOOK
71-
);
72-
array_push($out, $user_obj);
64+
$user_obj = new UnityUser(
65+
$member,
66+
$this->LDAP,
67+
$this->SQL,
68+
$this->MAILER,
69+
$this->REDIS,
70+
$this->WEBHOOK
71+
);
72+
array_push($out, $user_obj);
7373
}
7474
return $out;
7575
}
@@ -98,16 +98,16 @@ public function getOrgMemberUIDs($ignorecache = false)
9898
public function addUser($user)
9999
{
100100
$org_group = $this->getLDAPOrgGroup();
101-
$org_group->appendAttribute("memberuid", $user->getUID());
101+
$org_group->appendAttribute("memberuid", $user->uid);
102102
$org_group->write();
103-
$this->REDIS->appendCacheArray($this->gid, "members", $user->getUID());
103+
$this->REDIS->appendCacheArray($this->gid, "members", $user->uid);
104104
}
105105

106106
public function removeUser($user)
107107
{
108108
$org_group = $this->getLDAPOrgGroup();
109-
$org_group->removeAttributeEntryByValue("memberuid", $user->getUID());
109+
$org_group->removeAttributeEntryByValue("memberuid", $user->uid);
110110
$org_group->write();
111-
$this->REDIS->removeCacheArray($this->gid, "members", $user->getUID());
111+
$this->REDIS->removeCacheArray($this->gid, "members", $user->uid);
112112
}
113113
}

0 commit comments

Comments
 (0)