/** * @param int $access_flag * @param User $mTargetUser */ private function apply($access_flag, $mTargetUser) { if ($this->context_company->isEmpty()) { throw new NotFoundCompanyException(); } if ($access_flag == 2) { throw new UserAccessDeniedException(); } $mAccessManager = new UserAccessManager(); $tempUserFields = array(); if ($mAccessManager->can($access_flag, 'id')) { $tempUserFields['id'] = intval($mTargetUser->getId()); } if ($mAccessManager->can($access_flag, 'email')) { $tempUserFields['email'] = $mTargetUser->getEmail(); } if ($mAccessManager->can($access_flag, 'first_name')) { $tempUserFields['first_name'] = $mTargetUser->getFirstName(); } if ($mAccessManager->can($access_flag, 'last_name')) { $tempUserFields['last_name'] = $mTargetUser->getLastName(); } if ($mAccessManager->can($access_flag, 'patronymic')) { $tempUserFields['patronymic'] = $mTargetUser->getPatronymicName(); } if ($mAccessManager->can($access_flag, 'photo')) { $tempUserFields['photo'] = $mTargetUser->getPhoto(); } if ($mAccessManager->can($access_flag, 'phone')) { $tempUserFields['phone'] = $mTargetUser->getPhone(); } if ($mAccessManager->can($access_flag, 'register_time')) { $tempUserFields['register_time'] = intval($mTargetUser->getRegisterTime()); } if ($mAccessManager->can($access_flag, 'last_logged_time')) { $tempUserFields['last_logged_time'] = intval($mTargetUser->getLastLoggedTime()); } if ($mAccessManager->can($access_flag, 'company_id')) { $tempUserFields['company_id'] = intval($mTargetUser->getCompanyId()); } if ($mAccessManager->can($access_flag, 'access_flag')) { $tempUserFields['access_flag'] = intval($mTargetUser->getAccessFlag()); } if ($mAccessManager->can($access_flag, 'access_flag')) { $tempUserFields['user_group'] = $mTargetUser->getUserGroupKey(); } if ($mAccessManager->can($access_flag, 'sms_notify')) { $tempUserFields['sms_notify'] = $mTargetUser->isSmsNotificationEnabled(); } if ($mAccessManager->can($access_flag, 'recent_activity_time')) { $tempUserFields['recent_activity_time'] = intval($mTargetUser->getRecentActivityTime()); } $this->result = $tempUserFields; }
public function signIn() { $mEmail = $this->data['email']; $mPassword = $this->data['password']; $mCompanyDomain = $this->data['domain']; $user = new User($this->db); $user->allocateByEmail($mEmail); $mCompany = new Company($this->db); $mCompany->allocateByDomain($mCompanyDomain); if ($user->isEmpty() || $mCompany->isEmpty() || $mCompany->getId() != $user->getCompanyId() || !$user->isPasswordEqual($mPassword)) { return; } $user->updateRecentActivityTime(); $key_manager = new KeyManager(); $access_key = $this->generateKey(); $key = $key_manager->createKey($user->getId(), $access_key); $csrf_token = sha1($key . 'success'); $user->addAccessKey($access_key); $this->setCookie(CheckAuthorization::IDENTIFIER, $key, time() + 365 * 24 * 3600, '/', $_SERVER['HTTP_HOST']); $this->setCookie(CheckAuthorization::CSRF_TOKEN_NAME, $csrf_token, time() + 365 * 24 * 3600, '/', $_SERVER['HTTP_HOST']); $this->setSession(CheckAuthorization::IDENTIFIER, $key); $this->result = true; }
/** * @param int $access_flag * @param Company $mCompany */ private function apply($access_flag, $mCompany) { if ($mCompany->isEmpty()) { throw new NotFoundCompanyException(); } $mAccessManager = new CompanyAccessManager(); $this->result = array('company' => array()); $tempCompanyFields = array(); if ($mAccessManager->can($access_flag, 'id')) { $tempCompanyFields['id'] = intval($mCompany->getId()); } if ($mAccessManager->can($access_flag, 'name')) { $tempCompanyFields['name'] = $mCompany->getName(); } if ($mAccessManager->can($access_flag, 'country')) { $tempCompanyFields['country'] = $mCompany->getCountry(); } if ($mAccessManager->can($access_flag, 'city')) { $tempCompanyFields['city'] = $mCompany->getCity(); } if ($mAccessManager->can($access_flag, 'website')) { $tempCompanyFields['website'] = $mCompany->getWebsite(); } if ($mAccessManager->can($access_flag, 'company_type')) { $tempCompanyFields['company_type'] = intval($mCompany->getCompanyType()); } if ($mAccessManager->can($access_flag, 'company_logo')) { $tempCompanyFields['company_logo'] = $mCompany->getCompanyLogo(); } if ($mAccessManager->can($access_flag, 'user_id')) { $tempCompanyFields['user_id'] = intval($mCompany->getUserId()); } if ($mAccessManager->can($access_flag, 'domain')) { $tempCompanyFields['domain'] = $mCompany->getDomain(); } if ($mAccessManager->can($access_flag, 'contact_email')) { $tempCompanyFields['contact_email'] = $mCompany->getContactEmail(); } if ($mAccessManager->can($access_flag, 'contact_phone')) { $tempCompanyFields['contact_phone'] = $mCompany->getContactPhone(); } if ($mAccessManager->can($access_flag, 'register_time')) { $tempCompanyFields['register_time'] = intval($mCompany->getRegisterTime()); } if ($mAccessManager->can($access_flag, 'max_count_services')) { $tempCompanyFields['max_count_services'] = intval($mCompany->getMaxCountServices()); } if ($mAccessManager->can($access_flag, 'current_count_services')) { $tempCompanyFields['current_count_services'] = intval($mCompany->getCurrentCountServices()); } if ($mAccessManager->can($access_flag, 'employees_number')) { $tempCompanyFields['employees_number'] = intval($mCompany->getEmployeesNumber()); } if ($mAccessManager->can($access_flag, 'end_subscription_time')) { $tempCompanyFields['end_subscription_time'] = intval($mCompany->getEndSubscriptionTime()); } if ($mAccessManager->can($access_flag, 'end_subscription_time')) { $tempCompanyFields['remain_time'] = intval($mCompany->getRemainTime()); } if ($mAccessManager->can($access_flag, 'end_subscription_time')) { $tempCompanyFields['is_not_expired'] = $mCompany->isNotExpired(); } if ($mAccessManager->can($access_flag, 'stop_company_time')) { $tempCompanyFields['stop_company_time'] = intval($mCompany->getStopCompanyTime()); } if ($mAccessManager->can($access_flag, 'sms_enabled')) { $tempCompanyFields['sms_enabled'] = $mCompany->isSmsEnabled(); } if ($mAccessManager->can($access_flag, 'email_enabled')) { $tempCompanyFields['email_enabled'] = $mCompany->isEmailEnabled(); } $tempCompanyFields['is_active'] = $mCompany->isActive(); $this->result['company'] = $tempCompanyFields; }
public function getCompanyByDomain($domain) { $domain = mb_strtolower($domain, 'utf-8'); $company = new Company($this->db); $company->allocateByDomain($domain); return $company; }