Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super user feature #841

Merged
merged 17 commits into from Jul 21, 2020
Merged

Super user feature #841

merged 17 commits into from Jul 21, 2020

Conversation

guillegiu
Copy link
Collaborator

No description provided.

$authorsMatch = RedBean::getAll($authorsQuery, [':query' => "%" .$query . "%",':queryAtBeginning' => $query . "%"] );
$authors = [];
if(!$searchUser){
$sqlQuery = "SELECT id,name,level FROM staff " . $this->generateAuthorsIdQuery($query) . " LIMIT 10";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move SELECT inside the funcltion, also you only need id,level

@ivandiazwm ivandiazwm self-requested a review July 19, 2020 17:25
@@ -102,7 +104,8 @@ public function validations() {
}

public function handler() {

$this->supervisor = Controller::request('supervisor') ? Controller::request('supervisor') : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->ignoreDeparmentFilter = (bool)Controller::request('supervisor')

$superUser = User::getDataStore(Controller::request('userId'));

foreach ($clearedList as $item) {
if($item == $superUser->id) throw new Exception(ERRORS::SUPERVISOR_CAN_NOT_SELECT_HIMSELF);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUPERVISOR_CAN_NOT_SUPERVISE_HIMSELF

public function handler() {
$userIdList = $this->getUserIdListCleared();
$superUser = User::getDataStore(Controller::request('userId'));
$supervisedRelation = SupervisedRelation::getDataStore($superUser->supervisedrelation_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(!$superUser->supervisedrelation) {
    $superUser->supervisedrelation = new SupervisedRelation();
}
$superUser->supervisedrelation->sharedUserList->clear();

foreach ($userIdList as $userId) {
    $user = User::getDataStore($userId);
    $superUser->supervisedrelation->sharedUserList->add($user);
}

$superUser->supervisedrelation->store();
$superUser->store();

// Datastorelist

    public function clear() {
        foreach($index => $item as $this->list) {
            unset($this->list[$index]);
        }
    }


public function handler() {
$this->page = Controller::request('page') ? Controller::request('page') : 1;
$this->showOwnTickets = Controller::request('showOwnTickets') ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(bool)Controller::request('showOwnTickets')

* @apiPermission user
*
* @apiParam {id[]} supervisedUsers arrays of users Ids.
* @apiParam {boolean} showOwnTickets boolean to show or not own tickets.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showOwnTickets boolean to show or not current logged user tickets

}

render() {
return (
<div className="dashboard-ticket-list">
<Header title={i18n('TICKET_LIST')} description={i18n('TICKET_LIST_DESCRIPTION')} />
<TicketList tickets={this.props.tickets} type="primary"/>
{this.props.userUsers ? this.showSupervisorOptions() : null}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should be this.props.userUsers.length

});
}

updateTicketList(object = {}){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateTicketList({users, page, ownTickets}) {

@guillegiu guillegiu merged commit cd73606 into master Jul 21, 2020
@ivandiazwm ivandiazwm deleted the super-user-feature branch December 26, 2020 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants