public function service() { $adminManager = AdminManager::getInstance($this->config, $this->args); $price_group = $_REQUEST['price_group']; $adminManager->setPriceGroup($this->getUserId(), $price_group); $this->ok(); }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $adminManager = AdminManager::getInstance($this->config, $this->args); $userManager = UserManager::getInstance($this->config, $this->args); $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args); $allAdmins = $adminManager->selectAll(); if ($this->getUserLevel() === UserGroups::$COMPANY) { $allCompanies = $companyManager->getAllCompanies(); $companyDealersJoindWithUsersFullInfo = $companyDealersManager->getCompanyDealersJoindWithUsersFullInfo($this->getUserId()); $this->addParam('allCompanies', $allCompanies); $this->addParam('allDealers', $companyDealersJoindWithUsersFullInfo); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$SERVICE_COMPANY) { $allCompanies = $companyManager->getAllCompanies(); $this->addParam('allCompanies', $allCompanies); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$ADMIN) { $allCompanies = $companyManager->getAllCompanies(true, true); $allUsers = $userManager->selectAll(); $this->addParam('allCompanies', $allCompanies); $this->addParam('allUsers', $allUsers); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$USER) { $allCompanies = $companyManager->getAllCompanies(); $allUsers = $userManager->selectAll(); $dealerCompanies = $companyManager->getUserCompaniesJoindWithFullInfo($this->getUserId()); $this->addParam('allCompanies', $dealerCompanies); //$this->addParam('allUsers', $allUsers); $this->addParam('allAdmins', $allAdmins); } }
public function service() { $categoryManager = CategoryManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $categoryId = $this->secure($_REQUEST["category_id"]); $adminManager = AdminManager::getInstance($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { if ($categoryHierarchyManager->hasCategoryChildren($categoryId)) { $jsonArr = array('status' => "err", "errText" => "You can only remove 'Leaf' categories!"); echo json_encode($jsonArr); return false; } $categoryManager->deleteByPK($categoryId); $categoryHierarchyManager->removeCategoryHierarchyByChildCategoryID($categoryId); //todo remove category name from items table `categories_names` field. $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
/** * register guest user * * @return int userId */ public function register() { $this->setCookieParam("ut", UserGroups::$ADMIN); $user = AdminManager::getInstance()->register(); $this->setUniqueId($user->getHashcode()); $this->setId($user->getId()); return $user->getId(); }
public function service() { $sound_on = $_REQUEST['on'] == 1 ? 1 : 0; if ($this->getUserLevel() != UserGroups::$GUEST) { $customerId = $this->getUserId(); switch ($this->getUserLevel()) { case UserGroups::$USER: $userManager = UserManager::getInstance($this->config, $this->args); $userManager->enableSound($customerId, $sound_on); break; case UserGroups::$COMPANY: $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->enableSound($customerId, $sound_on); break; case UserGroups::$ADMIN: $adminManager = AdminManager::getInstance($this->config, $this->args); $adminManager->enableSound($customerId, $sound_on); break; } $this->ok(); } }
private function getOnlineAdminsEmails() { $adminManager = AdminManager::getInstance(null, null); $adminsDtos = $adminManager->selectAll(); $onlineUsersManager = OnlineUsersManager::getInstance(null, null); $ret = array(); foreach ($adminsDtos as $adminDto) { $adminEmail = $adminDto->getEmail(); $onlineAdminDto = $onlineUsersManager->selectByField('email', $adminEmail); if (!empty($onlineAdminDto)) { $ret[] = $adminEmail; } } return $ret; }
public function getItemProfitFormula($userId, $userLevel) { $vipCustomer = false; $userManager = UserManager::getInstance($this->config, $this->args); if ($userLevel === UserGroups::$USER) { $userDto = $userManager->selectByPK($userId); $vipCustomer = $userManager->isVipAndVipEnabled($userDto); } if ($userLevel === UserGroups::$ADMIN) { $adminManager = AdminManager::getInstance($this->config, $this->args); $adminDto = $adminManager->selectByPK($userId); $vipCustomer = $adminDto->getPriceGroup() === 'vip'; } if ($vipCustomer) { $customer_items_price_formula = $this->getCmsVar("vip_customer_items_price_formula"); } else { $customer_items_price_formula = $this->getCmsVar("customer_items_price_formula"); } //$10->25%,$1000->8% $bottomItemPriceLimit = (double) substr($customer_items_price_formula, 1); $topItemPriceLimit = (double) substr($customer_items_price_formula, strrpos($customer_items_price_formula, '$') + 1); $bottomItemPriceProfitRatio = (double) substr($customer_items_price_formula, strrpos($customer_items_price_formula, '>') + 1) / 100; $topItemPriceProfitRatio = (double) substr($customer_items_price_formula, strpos($customer_items_price_formula, '>') + 1) / 100; $discount_percent_for_all_items = $this->getCmsVar("discount_percent_for_all_items"); return "IF (`items`.`%s`<{$bottomItemPriceLimit},`items`.`%s`*(1+ {$topItemPriceProfitRatio}),IF (`items`.`%s`>{$topItemPriceLimit},`items`.`%s`*(1+ {$bottomItemPriceProfitRatio}),\t\t\t\n\t\t\t(1+ {$topItemPriceProfitRatio} + ({$bottomItemPriceProfitRatio}-{$topItemPriceProfitRatio})/({$topItemPriceLimit}-{$bottomItemPriceLimit})*`items`.`%s`)*`items`.`%s`\n\t\t\t))"; }
/** * Creates en instance of admin user class and * initializes class members necessary for validation. * * @param object $adminId * @return */ public function __construct($id) { parent::__construct($id); $this->setCookieParam("ut", UserGroups::$ADMIN); $this->adminManager = AdminManager::getInstance(null, null); }
public function sendSmsToAdminIfUploaderIsNotItself($companyName) { $adminManager = AdminManager::getInstance($this->config, $this->args); $adminsToReceiveSms = $adminManager->getSmsEnabledAdmins(); $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args); foreach ($adminsToReceiveSms as $key => $admin) { if ($this->getUserLevel() === UserGroups::$ADMIN && $this->getUserId() == $admin->getId()) { continue; } $numberToReceiveSmsOnPriceUpload = $admin->getNumberToReceiveSmsOnPriceUpload(); if (!empty($numberToReceiveSmsOnPriceUpload)) { $sentSmsManager->sendSmsToArmenia($numberToReceiveSmsOnPriceUpload, "'" . $companyName . "' just uploaded price on PcStore! Best Regards www.pcstore.am"); } } }
public function addOnlineUser($userLevel, $customerDto) { $browserInfo = $this->getBrowser(); // if ($browserInfo["name"] === 'Unknown') { // return false; // } $userEmail = ''; if (isset($customerDto)) { $userEmail = $customerDto->getEmail(); } //last ping time set for customer $previousPing = null; switch ($userLevel) { case UserGroups::$ADMIN: $adminManager = AdminManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $adminManager->setLastPingToNow($customerDto->getId()); break; case UserGroups::$COMPANY: $companyManager = CompanyManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $companyManager->setLastPingToNow($customerDto->getId($customerDto->getId())); break; case UserGroups::$USER: $userManager = UserManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $userManager->setLastPingToNow($customerDto->getId($customerDto->getId())); break; } if (isset($customerDto)) { $onlineUser = $this->getOnlineUserByEmail($userEmail); if (isset($onlineUser)) { $this->updateOnlineUserAttributes($onlineUser); return false; } } $guest_online_table_id = $_COOKIE['guest_online_table_id']; $oldRow = $this->selectByPK($guest_online_table_id); $ip = $_SERVER["REMOTE_ADDR"]; $host = gethostbyaddr($_SERVER['REMOTE_ADDR']); $country = $_SERVER["GEOIP_COUNTRY_NAME"]; $browser = $browserInfo["name"]; $browserVersion = $browserInfo["version"]; $platform = $browserInfo["platform"]; $status = "online"; if ($browser != 'Unknown' && $platform != 'Unknown' && $browserVersion != '?') { if (!isset($oldRow)) { $dto = $this->mapper->createDto(); } else { $dto = $oldRow; } $dto->setEmail($userEmail); $dto->setIp($ip); $dto->setHost($host); $dto->setCountry($country); $dto->setBrowserName($browser); $dto->setBrowserVersion($browserVersion); $dto->setBrowserPlatform($platform); $dto->setLoginDateTime(date('Y-m-d H:i:s')); $dto->setStatus($status); if (!isset($oldRow)) { $id = $this->mapper->insertDto($dto); } else { $this->mapper->updateByPK($dto); $id = $dto->getId(); } } $loginHistoryManager = LoginHistoryManager::getInstance($this->config, $this->args); $ulstring = $this->getUserLevelString($userLevel); $loginHistoryManager->addRow($userEmail, $ulstring, $ip, $host, $country, $browser, $browserVersion, $platform); $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $customerMessagesAfterLoginManager->addCustomerMessagesAfterLoginByPreviousPing($customerDto, $userLevel, $previousPing); return $id; }