public function service()
 {
     $userPendingSubUsersManager = new UserPendingSubUsersManager($this->config, $this->args);
     $pendingUserEmail = $userPendingSubUsersManager->secure($_REQUEST["user_email"]);
     $userId = $this->sessionManager->getUser()->getId();
     if ($userPendingSubUsersManager->getByUserIdAndPendingSubUserEmail($userId, $pendingUserEmail)) {
         $userPendingSubUsersManager->removePendingSubUserFromUser($userId, $pendingUserEmail);
         $jsonArr = array('status' => "ok", "message" => "Invitation successfully removed!");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => "System Error: Email dosn't exist in your pending emails list!");
         echo json_encode($jsonArr);
         return false;
     }
 }
Beispiel #2
0
 public function setSubUser($invitation_code, $subUserId, $pendingEmail = null)
 {
     if (!empty($invitation_code)) {
         $userPendingSubUsersManager = new UserPendingSubUsersManager($this->config, $this->args);
         $inviterUserDto = $this->getUserByInvitationCode($invitation_code);
         if ($inviterUserDto) {
             if (isset($pendingEmail)) {
                 $invitedDto = $userPendingSubUsersManager->getByUserIdAndPendingSubUserEmail($inviterUserDto->getId(), $pendingEmail);
                 if ($invitedDto) {
                     $userPendingSubUsersManager->removePendingSubUserFromUser($inviterUserDto->getId(), $pendingEmail);
                 }
             }
             $userSubUsersManager = UserSubUsersManager::getInstance($this->config, $this->args);
             $userSubUsersManager->addSubUserToUser($subUserId, $inviterUserDto->getId());
             return $inviterUserDto->getId();
         }
     }
     return 0;
 }