Skip to content

Remove_duplicates_fix_missing_glid_named_param #9

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 61 additions & 73 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GrouperGroupsController extends GrouperLiteWidgetAppController
{
public $helpers = array('Html', 'Form', 'Flash');

// Dynamic properties are deprecated so we will define the property here
// Dynamic properties are deprecated, so we will define the property here
protected $userId = null;

public $uses = array(
Expand Down Expand Up @@ -108,8 +108,8 @@ public function beforeRender() {

$this->set('title', _txt('pl.grouperlite.title.groupmember'));
$this->set('vv_is_user_owner', $this->GrouperGroup->isUserOwner($this->userId ?? '', $cfg) );
$this->set('vv_is_template_user', $this->GrouperGroup->isTemplateUser($this->userId ?? '', $cfg) );
$this->set('vv_is_grouper_visible', $this->GrouperGroup->isGrouperVisible($this->userId ?? '', $cfg));
// $this->set('vv_is_template_user', $this->GrouperGroup->isTemplateUser($this->userId ?? '', $cfg) );
// $this->set('vv_is_grouper_visible', $this->GrouperGroup->isGrouperVisible($this->userId ?? '', $cfg));
$this->set('vv_coid', $this->cur_co['Co']['id']);
}

Expand All @@ -118,28 +118,29 @@ public function beforeRender() {
*
* @return CakeResponse Redirect to MyMembership page
*/
public function index() {}
public function index(): void
{}

/**
* @return void
*/
public function groupMember()
public function groupMember(): void
{
$this->render('index');
}

/**
* @return void
*/
public function groupOptin()
public function groupOptin(): void
{
$this->render('index');
}

/**
* @return void
*/
public function groupOwner()
public function groupOwner(): void
{
$this->render('index');
}
Expand All @@ -149,7 +150,7 @@ public function groupOwner()
* Called from all pages via AJAX call
*
*/
public function groupSubscribers()
public function groupSubscribers(): void
{
$groupName = urldecode($this->request->query['groupname']);
$subscribers = 0;
Expand Down Expand Up @@ -190,35 +191,29 @@ public function groupSubscribers()
* Called from all pages via AJAX call
*
*/
public function addSubscriber() {
public function addSubscriber(): void
{
$groupName = urldecode($this->request->query['group']);
$addUserId = urldecode($this->request->query['userId']);
$resultAdd = '';
$resultAdd = false;

//Need to see if coming from AdHoc or from a WG (Working Group)
$groupNameFormatted = strpos($groupName, ':') === false ? 'ref:incommon-collab:' . $groupName . ':users'
: $groupName;
//Set initial
$scope = [
'groupName' => $groupNameFormatted,
'addUserId' => $addUserId
];

try {
$resultAdd = $this->GrouperGroup->addGrouperGroupMember($scope,
$this->userId,
$resultAdd = $this->GrouperGroup->addGrouperGroupMember($this->userId,
$groupNameFormatted,
$addUserId,
$this->CoGrouperLiteWidget->getConfig());
CakeLog::write('debug', __METHOD__ . '::response: ' . var_export($resultAdd, true));
} catch (Exception $e) {
// $this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::NotAdded);
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
$this->restResponse(HttpStatusCodesEnum::HTTP_NOT_FOUND, ErrorsEnum::Exception);
}

if ($resultAdd !== 'SUCCESS') {
$this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::Error);
$resultAdd = '';
}

$this->set(compact('resultAdd'));
$this->set(compact($resultAdd ? GrouperResultCodesEnum::SUCCESS : ''));
$this->set('_serialize', 'resultAdd');

}
Expand Down Expand Up @@ -336,37 +331,36 @@ public function findSubscriber() {
* Remove a member from a group
* Called from all pages via AJAX call
*
* TODO: We should probably save extra metadata in a data attribute and then pass that attribute to the request and not
* the Human Readable name
* TODO: We need to appropriately handle Unathenticated call. We have to bubble up the response and do something.
*/
public function removeSubscriber() {
public function removeSubscriber(): void
{
$groupName = urldecode($this->request->query['group']);
$remUserId = urldecode($this->request->query['userId']);
$resultRemove = '';
$resultRemove = false;

//Need to see if coming from AdHoc or from a WG (Working Group)
$groupNameFormatted = (strpos($groupName, ':') === false) ? 'ref:incommon-collab:' . $groupName . ':users'
: $groupName;
//Set initial
$scope = [
'groupName' => $groupNameFormatted,
'remUserId' => $remUserId
];

try {
$resultRemove = $this->GrouperGroup->removeGrouperGroupMember($scope,
$this->userId,
$resultRemove = $this->GrouperGroup->removeGrouperGroupMember($this->userId,
$groupNameFormatted,
$remUserId,
$this->CoGrouperLiteWidget->getConfig());

CakeLog::write('debug', __METHOD__ . '::response: ' . var_export($resultRemove, true));
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
}

if ($resultRemove != 'SUCCESS') {
if (!$resultRemove) {
$this->restResponse(HttpStatusCodesEnum::HTTP_NOT_FOUND, ErrorsEnum::Error);
$resultRemove = '';
}

$this->set(compact('resultRemove'));
$this->set(compact($resultRemove ? GrouperResultCodesEnum::SUCCESS : ''));
$this->set('_serialize', 'resultRemove');
}

Expand Down Expand Up @@ -529,56 +523,51 @@ public function groupCreateTemplate()
/**
* Process to join a group displayed on the "Optin" page
*
* @return CakeResponse Redirect back to "Optin" page
*/
public function joinGroup()
public function joinGroup(): void
{
$resultAdd = 'Success';
$name = urldecode($this->request->query['GroupName']);
$display = urldecode($this->request->query['GroupDisplayName']);
$resultAdd = false;

try {
if (!$this->GrouperGroup->joinGroup($this->userId,
$name,
$this->CoGrouperLiteWidget->getConfig())) {
$this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::NotAdded);
$resultAdd = '';
}
// Add myself
$resultAdd = $this->GrouperGroup->joinGroup($this->userId,
$name,
$this->CoGrouperLiteWidget->getConfig());
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
// $this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::NotAdded);
$this->restResponse(HttpStatusCodesEnum::HTTP_NOT_FOUND, ErrorsEnum::Exception);
$resultAdd = '';
}

$this->set(compact('resultAdd'));
$this->set(compact($resultAdd ? GrouperResultCodesEnum::SUCCESS : ''));
$this->set('_serialize', 'resultAdd');
}

/**
* Process to leave a group displayed on the "Member Of" page
*
* @return CakeResponse Redirect back to "Member Of" page
*/
public function leaveGroup()
public function leaveGroup(): void
{
$name = urldecode($this->request->query['GroupName']);
$display = urldecode($this->request->query['GroupDisplayName']);
$resultRemove = 'Success';
$resultRemove = false;

try {
if (!$this->GrouperGroup->leaveGroup($this->userId,
$name,
$this->CoGrouperLiteWidget->getConfig())) {
$this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::NotDeleted);
$resultRemove = '';
}
$resultRemove = $this->GrouperGroup->leaveGroup($this->userId,
$name,
$this->CoGrouperLiteWidget->getConfig());
} catch (Exception $e) {
CakeLog::write('error', __METHOD__ . ': ' . var_export($e->getMessage(), true));
$this->restResponse(HttpStatusCodesEnum::HTTP_NOT_FOUND, ErrorsEnum::Exception);
$resultRemove = '';
}

$this->set(compact('resultRemove'));
// $this->restResponse(HttpStatusCodesEnum::HTTP_UNAUTHORIZED, ErrorsEnum::NotDeleted);

if (!$resultRemove) {
$this->restResponse(HttpStatusCodesEnum::HTTP_NOT_FOUND, ErrorsEnum::Error);
}

$this->set(compact($resultRemove ? GrouperResultCodesEnum::SUCCESS : ''));
$this->set('_serialize', 'resultRemove');
}

Expand All @@ -590,10 +579,10 @@ public function leaveGroup()
* - precondition: Session.Auth holds data used for authz decisions
* - postcondition: $permissions set with calculated permissions
*
* @return Array Permissions
* @return array|bool Permissions
* @since COmanage Registry v3.2.0
*/
function isAuthorized()
function isAuthorized(): array|bool
{
$roles = $this->Role->calculateCMRoles();
$cfg = $this->CoGrouperLiteWidget->getConfig();
Expand Down Expand Up @@ -673,7 +662,8 @@ private function breakoutGroups(array $recordSet)
* @return Boolean True if sanity check is successful
*/

public function verifyRequestedId() {
public function verifyRequestedId(): bool
{
return true;
}

Expand All @@ -686,27 +676,24 @@ public function verifyRequestedId() {
* @return Integer The CO ID if found, or -1 if not
*/

public function parseCOID($data = null) {
if(!empty($this->request->params["named"]["co"])) {
return $this->request->params["named"]["co"];
public function parseCOID($data = null): int {
if(!empty($this->request->params['named']['co'])) {
return (int)$this->request->params['named']['co'];
}
if(!empty($this->request->params["named"]["glid"])) {
if(!empty($this->request->params['named']['glid'])) {
$connectionInfo = $this->CoGrouperLiteWidget->findById($this->passedArgs['glid']);
$this->CoGrouperLiteWidget->CoDashboardWidget->CoDashboard->id = $connectionInfo["CoDashboardWidget"]["co_dashboard_id"];
$this->CoGrouperLiteWidget->CoDashboardWidget->CoDashboard->id = $connectionInfo['CoDashboardWidget']['co_dashboard_id'];
$co_id = $this->CoGrouperLiteWidget->CoDashboardWidget->CoDashboard->field('co_id');

if(!empty($co_id)) {
return $co_id;
return (int)$co_id;
}
}

return -1;
}

/**
* Prepare a REST result HTTP header.
* - precondition: HTTP headers must not yet have been sent
* - postcondition: CakeResponse configured with header
*
* @param integer $status HTTP result code
* @param array $body HTTP result comment
Expand All @@ -720,7 +707,8 @@ public function parseCOID($data = null) {
public function restResponse(int $status,
array $body=[],
string $contentType = 'json',
?string $statusTxt = null) {
?string $statusTxt = null): void
{
if(isset($statusTxt)) {
// We need to update the text associated with $status
$this->response->httpCodes(array($status => $statusTxt));
Expand Down
Empty file removed GrouperWidget/Config/Schema/empty
Empty file.
Empty file.
Empty file.
71 changes: 0 additions & 71 deletions GrouperWidget/Controller/CoGrouperWidgetController.php

This file was deleted.

Empty file.
7 changes: 0 additions & 7 deletions GrouperWidget/Controller/GrouperWidgetAppController.php

This file was deleted.

Empty file removed GrouperWidget/Lib/empty
Empty file.
Empty file.
Empty file removed GrouperWidget/Model/Behavior/empty
Empty file.
9 changes: 0 additions & 9 deletions GrouperWidget/Model/CoGrouperWidget.php

This file was deleted.

Empty file.
Loading