Exemple #1
0
 /**
  * Provides all members of this group.
  * 
  * @return UserGroupMember[]
  */
 public function getMembers()
 {
     // First get all userIDs that are members.
     $qAllMembers = db_query(sprintf("SELECT `userID`,`access` FROM `%s_group_members` WHERE `groupID`=%d", db_prefix(), $this->getGroupID()));
     $nAllMembers = db_num($qAllMembers);
     // Verify that we got any users.
     if ($qAllMembers === false || $nAllMembers < 1) {
         return array();
     }
     $members = array();
     $userIDs = array();
     $rowsIndexedByUID = array();
     // Fetch each as User
     while ($row = db_fetch_assoc($qAllMembers)) {
         $userIDs[] = $row["userID"];
         $rowsIndexedByUID[$row["userID"]] = $row;
     }
     // Fetch the users.
     $users = UserManager::getInstance()->getUsersByID($userIDs);
     if (count($users) < 1) {
         return array();
     }
     // Create as UserGroupMember
     foreach ($users as $user) {
         $memberRow = $rowsIndexedByUID[$user->getUserID()];
         $member = new UserGroupMember($user->getUserID());
         $member->fillInfo($user->getInfo());
         // fill extra variables
         $member->setAccess($memberRow["access"]);
         $member->setGroup($this);
         $members[] = $member;
         unset($memberRow, $user, $member);
     }
     return $members;
 }
 public function load()
 {
     $userManager = UserManager::getInstance($this->config, $this->args);
     $userId = $this->getUserId();
     if ((!isset($_REQUEST['refresh']) || $_REQUEST['refresh'] != 1) && $this->getCustomer()->getLoginType() === 'pcstore') {
         $custEmail = $this->getCustomerLogin();
         if (isset($_REQUEST['password'])) {
             $password = $_REQUEST['password'];
             $dto = $userManager->getUserByEmailAndPassword($custEmail, $password);
             if (!isset($dto)) {
                 $this->addParam("message", $this->getPhraseSpan(581));
                 $this->addParam("checkPassword", 1);
                 return;
             }
         } else {
             $this->addParam("checkPassword", 1);
             return;
         }
     }
     $userPhonesArray = $userManager->getUserPhonesArray($userId);
     $this->addParam("phones", $userPhonesArray);
     $regions_phrase_ids_array = explode(',', $this->getCmsVar('armenia_regions_phrase_ids'));
     $this->addParam('regions_phrase_ids_array', $regions_phrase_ids_array);
     $region = $userManager->selectByPK($userId)->getRegion();
     $this->addParam('region_selected', $region);
     $this->addParam('userManager', $userManager);
 }
 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 load()
 {
     $emailId = $_REQUEST['email_id'];
     $customerLocalEmailsManager = CustomerLocalEmailsManager::getInstance($this->config, $this->args);
     $userManager = UserManager::getInstance($this->config, $this->args);
     $emailDto = $customerLocalEmailsManager->selectByPK($emailId);
     if (isset($emailId) && isset($emailDto) && $emailDto->getCustomerEmail() === $this->getCustomerLogin()) {
         $this->addParam("email_subject", $emailDto->getSubject());
         $this->addParam("email_body", $emailDto->getBody());
         $customerEmail = $emailDto->getFromEmail();
         if (isset($_REQUEST['reply']) && $_REQUEST['reply'] == 1) {
             $this->addParam("email_to", $customerEmail);
             $customer = $userManager->getCustomerByEmail($customerEmail);
             if (isset($customer)) {
                 $customerContactNameForEmail = $customer->getCustomerContactNameForEmail();
                 $this->addParam("email_to_name", $customerContactNameForEmail);
                 $customerTypeString = $userManager->getCustomerTypeStringFromCustomerDto($customer);
                 $this->addParam("email_to_type", $customerTypeString);
             }
         }
         if ($emailDto->getReadStatus() == 0) {
             $customerLocalEmailsManager->setReadStatus($emailId, 1);
         }
     }
 }
 /**
  * Provides the object of the user this response is by.
  * 
  * @return \User
  */
 public function getUser()
 {
     if ($this->getUserID() < 1) {
         return null;
     }
     return \UserManager::getInstance()->getUserByID($this->getUserID());
 }
Exemple #6
0
/**
 * Perform database initialization.
 *
 * @param boolean $create_database
 * @return boolean
 */
function database_initialize($create_database)
{
    global $db, $db_config, $data_path;
    $result = false;
    $database_exists = false;
    $sql_file = 'units/database/init.sql';
    $xml_file = $data_path . 'system_init.xml';
    if (!file_exists($sql_file) || !file_exists($xml_file)) {
        trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR);
        return $result;
    }
    // make a log entry
    trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE);
    // get initialization SQL
    $sql = file_get_contents($sql_file);
    // create database if needed
    if ($create_database) {
        try {
            $db->create($db_config['name']);
            $db->select($db_config['name']);
            $database_exists = true;
        } catch (Exception $error) {
            $database_exists = false;
        }
    } else {
        $database_exists = true;
    }
    // create database
    if ($database_exists && $db->multi_query($sql)) {
        $module_manager = ModuleManager::getInstance();
        $module_handler = ModuleHandler::getInstance();
        $admin_manager = UserManager::getInstance();
        // populate tables
        $raw_data = file_get_contents($xml_file);
        $data = new XMLParser($raw_data, $xml_file);
        $data->parse();
        // go over XML file and insert data
        foreach ($data->document->tagChildren as $item) {
            switch ($item->tagName) {
                case 'module':
                    // insert data
                    $module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1));
                    // initialize module
                    $module = $module_handler->_loadModule($item->tagAttrs['name']);
                    if (!is_null($module)) {
                        $module->onInit();
                    }
                    break;
                case 'user':
                    $salt = hash('sha256', UserManager::SALT . strval(time()));
                    $password = hash_hmac('sha256', $item->tagAttrs['password'], $salt);
                    $admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt));
                    break;
            }
        }
        // set result
        $result = true;
    }
    return $result;
}
 public function load()
 {
     $userManager = UserManager::getInstance($this->config, $this->args);
     $userSubUsersManager = UserSubUsersManager::getInstance($this->config, $this->args);
     $userId = $this->getUserId();
     $subUsersDtos = $userSubUsersManager->getUserSubUsers($userId);
     $this->addParam("subUsers", $subUsersDtos);
     $this->addParam("userManager", $userManager);
 }
 public function load()
 {
     $this->addParam("pcstore_contact_us_phone_number", $this->getCmsVar('pcstore_contact_us_phone_number'));
     if ($this->getUserLevel() !== UserGroups::$GUEST) {
         $userManager = UserManager::getInstance($this->config, $this->args);
         $customerEmail = $userManager->getRealEmailAddressByUserDto($this->getCustomer());
         $this->addParam("customer_email", $customerEmail);
     }
 }
 public function validateLogin($value)
 {
     //$valid = (preg_match("/^[a-z_\s0-9]{4,}$/i", $value) > 0);
     $valid = preg_match("/^[a-z0-9_\\-\\.]+@[a-z_\\-\\.]+\\.[a-z]{2,3}\$/i", $value) > 0;
     //лоинг он же email
     $this->setValidationResult("login", $valid);
     $valid = $valid && ($count = UserManager::getInstance()->getCount('login = ?', array($value))) == 0;
     if ($count > 0) {
         $this->setValidationResult("login", $valid, 'Логин должен быть уникальным');
     }
     return $valid;
 }
 public function load()
 {
     $ordersManager = OrdersManager::getInstance($this->config, $this->args);
     if ($this->getUserLevel() === UserGroups::$ADMIN) {
         $showOnlyOrdersValues = array_merge(array(-1), $ordersManager->orderStatusesValues);
         $this->addParam('showOnlyOrdersValues', $showOnlyOrdersValues);
         $orderStatusesDisplayNames = array_merge(array($this->getPhrase(153)), $ordersManager->getOrderStatusesDisplayNamesPhrases());
         $showOnlyOrdersDisplayNamesPphraseIdsArray = array_merge(array(153), $ordersManager->orderStatusesDisplayNamesIds);
         $this->addParam('showOnlyOrdersDisplayNames', $orderStatusesDisplayNames);
         $this->addParam('showOnlyOrdersDisplayNamesPphraseIdsArray', $showOnlyOrdersDisplayNamesPphraseIdsArray);
         $show_only = $showOnlyOrdersValues[1];
         if (isset($_REQUEST['show_only'])) {
             $so = $this->secure($_REQUEST['show_only']);
             if (in_array($so, $showOnlyOrdersValues)) {
                 $show_only = $so;
             }
         }
         $this->addParam('showOnlyOrdersSelected', $show_only);
         $customerOrders = $ordersManager->getAllOrdersJoinedWithDetails($show_only);
     } else {
         $customer = $this->getCustomer();
         $customerEmail = strtolower($customer->getEmail());
         $customerOrders = $ordersManager->getCustomerOrderJoinedWithDetails($customerEmail);
     }
     $groupedOrders = $this->groupCustomerOrders($customerOrders);
     $groupOrdersByOrderIdAndBundleId = $this->groupOrdersByOrderIdAndBundleId($customerOrders);
     $pv = $this->getPriceVariety($groupedOrders);
     $this->addParam('groupOrdersByOrderIdAndBundleId', $groupOrdersByOrderIdAndBundleId);
     $this->addParam('priceVariety', $pv);
     if (isset($_REQUEST['order_id'])) {
         $order_id = $_REQUEST['order_id'];
         $mess1 = $this->getPhrase(301);
         $mess2 = $this->getPhrase(329) . $order_id;
         $mess3 = $this->getPhrase(360);
         $this->addParam('customerMessages', array($mess1, $mess2, $mess3));
     }
     if (isset($_SESSION['success_message'])) {
         $this->addParam('customerMessages', array($_SESSION['success_message']));
         unset($_SESSION['success_message']);
     }
     if (isset($_SESSION['error_message'])) {
         $this->addParam('customerErrorMessages', array($_SESSION['error_message']));
         unset($_SESSION['error_message']);
     }
     $this->addParam('itemManager', ItemManager::getInstance($this->config, $this->args));
     $this->addParam('userManager', UserManager::getInstance($this->config, $this->args));
     $this->addParam('orderManager', OrdersManager::getInstance($this->config, $this->args));
     $this->addParam("orderStatusesValues", $ordersManager->orderStatusesValues);
     $this->addParam("orderStatusesDisplayNames", $ordersManager->getOrderStatusesDisplayNamesPhrases());
 }
 public function load()
 {
     $this->addParam('pcstore_contact_number', $this->getCmsVar('pcstore_sales_phone_number'));
     $customer = $this->getCustomer();
     $sms_sent = false;
     if (isset($_REQUEST['co_code'])) {
         $code = $this->secure($_REQUEST['co_code']);
         $this->addParam('co_code', $code);
         if ($customer->getLastSmsValidationCode() === $code) {
             $this->addParam('order_confirmed', true);
         } else {
             $this->addParam('errorMessage', 223);
         }
         $this->addParam('sms_sent', true);
         return true;
     }
     $cell_phone_editable = $this->secure($_REQUEST['cho_do_shipping']) != 1;
     if ($cell_phone_editable) {
         $this->addParam('infoMessage', 362);
     }
     $cell_phone_number = $this->getPhoneNumberToSendSMS();
     $validNumber = null;
     if ($cell_phone_number != null) {
         $validNumber = SentSmsManager::getValidArmenianNumber($cell_phone_number);
     }
     if ($validNumber != null) {
         $lastSmsValidationCode = substr(uniqid(rand(), true), 0, 6);
         if ($this->getUserLevel() == UserGroups::$USER) {
             $userManager = UserManager::getInstance($this->config, $this->args);
             $userManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode);
         } elseif ($this->getUserLevel() == UserGroups::$COMPANY) {
             $companyManager = CompanyManager::getInstance($this->config, $this->args);
             $companyManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode);
         }
         $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args);
         $sentSmsManager->sendSmsToArmenia($validNumber, $lastSmsValidationCode);
         $this->addParam('infoMessage', "`319` ({$validNumber})");
         $this->addParam('validNumber', "(" . $validNumber . ")");
         $this->addParam('sms_sent', true);
     } else {
         if (!empty($cell_phone_number)) {
             $this->addParam('errorMessage', 318);
         }
         $this->addParam('cell_phone_number', $cell_phone_number);
         if (!$cell_phone_editable) {
             $this->addParam('infoMessage', 387);
         }
     }
     $this->addParam('cell_phone_editable', $cell_phone_editable);
 }
 public function load()
 {
     $user = $this->getUser();
     $pccm = PcConfiguratorManager::getInstance($this->config, $this->args);
     $selectedComponents = $pccm->getSelectedComponentsDtosOrderedInArray($user);
     $itemManager = ItemManager::getInstance($this->config, $this->args);
     $this->addParam("selected_components", $selectedComponents);
     $priceGroup = null;
     if ($this->getUserLevel() === UserGroups::$ADMIN) {
         $customer = $this->getCustomer();
         $priceGroup = $customer->getPriceGroup();
     }
     list($totalUsd, $totalAmd) = $pccm->getSelectedComponentSubTotalsAndTotals($selectedComponents, $user->getLevel(), $priceGroup);
     $required_components_ids = $pccm->getRequestComponentRequiredComponents($this->sessionManager->getUser());
     if (count($required_components_ids) === 0) {
         $this->addParam("ready_to_order", "true");
     } else {
         $this->addParam("ready_to_order", "false");
     }
     if (isset($_REQUEST['configurator_mode_edit_cart_row_id']) && intval($_REQUEST['configurator_mode_edit_cart_row_id']) > 0) {
         $this->addParam("configurator_mode_edit_cart_row_id", intval($_REQUEST['configurator_mode_edit_cart_row_id']));
     }
     $this->addParam("pccm", $pccm);
     $this->addParam("total_usd", $totalUsd);
     $this->addParam("total_amd", $totalAmd);
     $vipCustomer = 0;
     if ($this->getUserLevel() === UserGroups::$USER) {
         $customer = $this->getCustomer();
         $userManager = UserManager::getInstance($this->config, $this->args);
         $vipCustomer = $userManager->isVipAndVipEnabled($customer);
     }
     if ($this->getUserLevel() === UserGroups::$ADMIN) {
         $customer = $this->getCustomer();
         $vipCustomer = $customer->getPriceGroup() === 'vip';
     }
     if ($vipCustomer) {
         $pc_configurator_discount = floatval($this->getCmsVar('vip_pc_configurator_discount'));
     } else {
         $pc_configurator_discount = floatval($this->getCmsVar('pc_configurator_discount'));
     }
     $this->addParam("pc_configurator_discount", $pc_configurator_discount);
     $selectedComponentProfitWithDiscount = $pccm->calcSelectedComponentProfitWithDiscount($selectedComponents, $user->getLevel(), $pc_configurator_discount, $priceGroup);
     $pcBuildFeeAMD = $pccm->calcPcBuildFee($selectedComponentProfitWithDiscount);
     $this->addParam("pc_build_fee_amd", $pcBuildFeeAMD);
     $this->pcGrandTotalAmd = $totalAmd * (1 - $pc_configurator_discount / 100) + $pcBuildFeeAMD;
     $this->pcGrandTotalUsd = $totalUsd;
     $this->addParam("grand_total_amd", $this->pcGrandTotalAmd);
     $this->addParam("itemManager", $itemManager);
 }
Exemple #13
0
 /**
  * @param Kiosk $kiosk
  * @param \User $staffUser
  * @return LanKioskSession|mixed
  * @throws \Exception
  */
 public static function create(Kiosk $kiosk = null, \User $staffUser = null)
 {
     if ($kiosk === null) {
         $kiosk = new LanKiosk();
     }
     if ($staffUser === null) {
         $staffUser = \UserManager::getInstance()->getOnlineUser();
     }
     try {
         return self::loadFromSession($staffUser->getUserID());
     } catch (\Exception $e) {
         // no-op
     }
     return new self($kiosk, $staffUser);
 }
 public function service()
 {
     $lc = $_REQUEST['l'];
     if ($lc === 'am' || $lc === 'en' || $lc === 'ru') {
         $this->setcookie('ul', $lc);
         $_COOKIE['ul'] = $lc;
         if ($this->getUserLevel() == UserGroups::$USER) {
             $userManager = UserManager::getInstance($this->config, $this->args);
             $userManager->setLanguageCode($this->getUserId(), $lc);
         } elseif ($this->getUserLevel() == UserGroups::$COMPANY) {
             $companyManager = CompanyManager::getInstance($this->config, $this->args);
             $companyManager->setLanguageCode($this->getUserId(), $lc);
         }
     }
 }
Exemple #15
0
 public function load()
 {
     $userManager = UserManager::getInstance($this->config, $this->args);
     $allUsersDtos = $userManager->selectAll();
     $this->addParam("users", $allUsersDtos);
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $allCompanyDealers = $companyDealersManager->getAllUsersCompaniesFull();
     $userCompanies = $this->getUserCompaniesArray($allCompanyDealers);
     $allServiceCompanyDealers = $serviceCompanyDealersManager->getAllUsersCompaniesFull();
     $userServiceCompanies = $this->getUserCompaniesArray($allServiceCompanyDealers);
     $this->addParam('userCompanies', $userCompanies);
     $this->addParam('userServiceCompanies', $userServiceCompanies);
     $this->addParam('visible_fields_names', array('id', 'email', 'name', 'lastName', 'phones', 'password', 'registeredDate', 'lastSmsValidationCode', 'vip'));
 }
 function executeDelete()
 {
     $request = fvRequest::getInstance();
     if (!($User = UserManager::getInstance()->getByPk($request->getRequestParameter('id')))) {
         $this->setFlash("Ошибка при удалении.", self::$FLASH_ERROR);
     } else {
         $User->delete();
         $this->setFlash("Данные успешно удалены", self::$FLASH_SUCCESS);
     }
     fvResponce::getInstance()->setHeader('redirect', fvSite::$fvConfig->get('dir_web_root') . $request->getRequestParameter('module') . "/");
     if (fvRequest::getInstance()->isXmlHttpRequest()) {
         return self::$FV_NO_LAYOULT;
     } else {
         return self::$FV_OK;
     }
 }
 public function load()
 {
     $this->addParam('under_construction', $this->getCmsVar('under_construction'));
     $winUid = uniqid();
     $this->addParam("winUid", $winUid);
     $refererUrl = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     if (!empty($refererUrl) && strpos($refererUrl, $_SERVER['HTTP_HOST']) === false) {
         $referersManager = ReferersManager::getInstance($this->config, $this->args);
         $referersManager->addRow($refererUrl, $_SERVER['REQUEST_URI']);
     }
     if (isset($_REQUEST["lang"])) {
         $lc = $_REQUEST["lang"];
         $this->setcookie('ul', $lc);
         $_COOKIE['ul'] = $lc;
     }
     if (isset($_REQUEST["activation_code"])) {
         $user_activation_code = $this->secure($_REQUEST["activation_code"]);
         $userManager = UserManager::getInstance($this->config, $this->args);
         $inactiveUser = $userManager->getUserByActivationCode($user_activation_code);
         if ($inactiveUser) {
             if ($inactiveUser->getActive() == 1) {
                 $this->addParam('user_activation', 'already activated');
             } else {
                 $inactiveUser->setActive(1);
                 $userManager->updateByPK($inactiveUser);
                 $userSubUsersManager = UserSubUsersManager::getInstance($this->config, $this->args);
                 $prentId = $userSubUsersManager->getUserParentId($inactiveUser->getId());
                 if ($prentId > 0) {
                     $invbonus = intval($this->getCmsVar("bonus_points_for_every_accepted_invitation"));
                     $userManager->addUserPoints($prentId, $invbonus, $invbonus . " bonus for invitation accept from user number: " . $inactiveUser->getId());
                 }
                 $this->addParam('user_activation', 'just activated');
             }
         }
     }
     $userLevel = $this->sessionManager->getUser()->getLevel();
     if ($userLevel === UserGroups::$GUEST) {
         if (isset($_GET["invc"])) {
             $this->setCookie('invc', $this->secure($_REQUEST["invc"]));
         } else {
             if (isset($_GET["invitation_code"])) {
                 //depracated should be removed
                 $this->setCookie('invc', $this->secure($_REQUEST["invitation_code"]));
             }
         }
     }
 }
 public function service()
 {
     $order_id = $_REQUEST['order_id'];
     $token = $_REQUEST['stripeToken'];
     $userManager = UserManager::getInstance($this->config, $this->args);
     $ordersManager = OrdersManager::getInstance($this->config, $this->args);
     $orderTotalUsdToPay = $ordersManager->getOrderTotalUsdToPay($order_id, true);
     Stripe::setApiKey($this->getCmsVar('stripe_secret_key'));
     $email = $userManager->getRealEmailAddressByUserDto($this->getCustomer());
     try {
         $charge = Stripe_Charge::create(array("card" => $token, "description" => $email . ' (order #' . $order_id . ')', 'amount' => $orderTotalUsdToPay * 100, 'currency' => 'usd'));
     } catch (Exception $e) {
         $this->error(array('message' => $e->getMessage()));
     }
     $ordersManager->updateTextField($order_id, '3rd_party_payment_token', $token);
     $ordersManager->updateTextField($order_id, '3rd_party_payment_received', 1);
     $this->ok();
 }
 public function service()
 {
     $mandrillEmailSenderManager = new MandrillEmailSenderManager($this->getCmsVar("mandrill_api_key_news"));
     $email_body_html = $_REQUEST['email_body_html'];
     if (empty($email_body_html)) {
         $this->error(array('errText' => 'email body is empty!'));
     }
     $fromEmail = $this->getCmsVar('pcstore_news_email');
     $fromName = 'Pcstore.am Newsletter!';
     $includeUsers = $_REQUEST['include_all_active_users'];
     $subject = 'Newsletter from PcStore.am!!!';
     $test = $_REQUEST['test'];
     if ($test == 1) {
         $testEmail = $_REQUEST['test_email'];
         $res = $mandrillEmailSenderManager->sendHtmlEmail($testEmail, $subject, $email_body_html, $fromEmail, $fromName);
         $this->ok(array('count' => 1));
     }
     $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args);
     $newsletterSubscribersManager = NewsletterSubscribersManager::getInstance($this->config, $this->args);
     $emailsArray = $newsletterSubscribersManager->getAllSubscribers();
     $filteredEmailsArray = $uninterestingEmailsManager->removeUninterestingEmailsFromList($emailsArray);
     if ($includeUsers == 1) {
         $userManager = UserManager::getInstance($this->config, $this->args);
         $allUsers = $userManager->selectAll();
         foreach ($allUsers as $userDto) {
             if ($userDto->getAvtive() == 0) {
                 continue;
             }
             $userRealEmailAddress = strtolower($userManager->getRealEmailAddressByUserDto($userDto));
             if (filter_var($userRealEmailAddress, FILTER_VALIDATE_EMAIL)) {
                 $filteredEmailsArray[] = $userRealEmailAddress;
             }
         }
     }
     //for FB, Google and TWITTER users emails may be duplicated!!!! so used array_unique
     $recipients = array_unique($filteredEmailsArray);
     if (count($recipients) === 0) {
         $this->error(array('errText' => 'There is no any recipient!'));
     }
     $email_body_html .= '<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>';
     $email_body_html .= '<p style="font-size:10px"><a href="*|UNSUB:http://pcstore.am/unsubscriber|*">Click here to unsubscribe.</a></p>';
     $res = $mandrillEmailSenderManager->sendHtmlEmail($recipients, $subject, $email_body_html, $fromEmail, $fromName);
     $this->ok(array('count' => count($recipients)));
 }
 function executeSave()
 {
     $request = fvRequest::getInstance();
     if (!($UserGroup = UserGroupManager::getInstance()->getByPk($request->getRequestParameter('id')))) {
         $UserGroup = new UserGroup();
     }
     $mg = $request->getRequestParameter('mg');
     if (empty($mg['default_group']) && $UserGroup->default_group) {
         $this->setFlash("Ошибка при сохранении данных проверте правильность введенных данных", self::$FLASH_ERROR);
         if (fvRequest::getInstance()->isXmlHttpRequest()) {
             return self::$FV_AJAX_CALL;
         } else {
             return self::$FV_OK;
         }
     }
     $UserGroup->updateFromRequest($mg);
     if ($UserGroup->save()) {
         if ($UserGroup->default_group) {
             UserGroupManager::getInstance()->massUpdate("id <> " . $UserGroup->getPk(), array('default_group' => 0));
         }
         $this->setFlash("Данные успешно сохранены", self::$FLASH_SUCCESS);
         fvResponce::getInstance()->setHeader('Id', $UserGroup->getPk());
         UserManager::getInstance()->massUpdate(sprintf('group_id = %d AND inherit = 1', $UserGroup->getPk()), array('permitions' => $UserGroup->permitions));
         /*            $Users = UserManager::getInstance()->getAll('group_id = ? AND inherit = 1 AND global_rights = 1', null, null, $UserGroup->getPk());
                     
                     foreach ($Users as $User) {
                         $User->permitions = $UserGroup->permitions;
                         $User->save();
                     }
         */
     } else {
         fvResponce::getInstance()->setHeader('X-JSON', json_encode($UserGroup->getValidationResult()));
         $this->setFlash("Ошибка при сохранении данных проверте правильность введенных данных", self::$FLASH_ERROR);
     }
     if ($request->getRequestParameter('redirect')) {
         fvResponce::getInstance()->setHeader('redirect', fvSite::$fvConfig->get('dir_web_root') . $request->getRequestParameter('module') . "/");
     }
     if (fvRequest::getInstance()->isXmlHttpRequest()) {
         return self::$FV_AJAX_CALL;
     } else {
         return self::$FV_OK;
     }
 }
 function showIndex()
 {
     $filter = fvSite::$fvSession->get(fvRequest::getInstance()->getRequestParameter("requestURL") . "/filter");
     $query = null;
     $params = array();
     if (is_array($filter)) {
         if (!empty($filter['object_name'])) {
             $query .= ($query ? " AND " : '') . "object_name LIKE ?";
             $params[] = '%' . $filter['object_name'] . "%";
             $this->__assign('filter_object_name', $filter['object_name']);
         }
         if (!empty($filter['date_from'])) {
             $query .= ($query ? " AND " : '') . "date >= ?";
             $params[] = $filter['date_from'];
             $this->__assign('filter_date_from', $filter['date_from']);
         }
         if (!empty($filter['date_to'])) {
             $query .= ($query ? " AND " : '') . "date <= ?";
             $params[] = $filter['date_to'];
             $this->__assign('filter_date_to', $filter['date_to']);
         }
         if (!empty($filter['message'])) {
             $query .= ($query ? " AND " : '') . "message LIKE ?";
             $params[] = '%' . $filter['message'] . '%';
             $this->__assign('filter_message', $filter['message']);
         }
         if (!empty($filter['operation'])) {
             $query .= ($query ? " AND " : '') . "operation = ?";
             $params[] = $filter['operation'];
             $this->__assign('filter_operation', $filter['operation']);
         }
         if (!empty($filter['manager_id'])) {
             $query .= ($query ? " AND " : '') . "manager_id = ?";
             $params[] = $filter['manager_id'];
             $this->__assign('filter_manager_id', $filter['manager_id']);
         }
     }
     $pager = new fvPager(LogManager::getInstance());
     $this->__assign('Logs', $pager->paginate($query, "date DESC", $params));
     $this->__assign('UserManager', UserManager::getInstance());
     return $this->__display('log_list.tpl');
 }
 public function load()
 {
     $customer = $this->getCustomer();
     $vipCustomer = false;
     if (isset($customer)) {
         $userManager = UserManager::getInstance($this->config, $this->args);
         $vipCustomer = $userManager->isVipAndVipEnabled($customer);
     }
     if ($vipCustomer) {
         $pccDiscount = floatval($this->getCmsVar('vip_pc_configurator_discount'));
     } else {
         $pccDiscount = floatval($this->getCmsVar('pc_configurator_discount'));
     }
     $itemManager = ItemManager::getInstance($this->config, $this->args);
     if (isset($_REQUEST["item_id"])) {
         $item_id = $_REQUEST["item_id"];
     } elseif ($this->args[0]) {
         $item_id = $this->args[0];
     }
     $selectedItemDto = $itemManager->selectByPK($item_id);
     if (isset($selectedItemDto)) {
         $this->setDescriptionTagValue($selectedItemDto->getDisplayName());
         $this->setKeywordsTagValue($selectedItemDto->getDisplayName());
         $this->setTitleTagValue($selectedItemDto->getDisplayName());
     }
     $userLevel = $this->getUserLevel();
     $userId = $this->getUserId();
     $itemDto = $itemManager->getItemsForOrder($item_id, $userId, $userLevel, true);
     $this->addParam('item_id', $item_id);
     if ($itemDto) {
         $itemManager->growItemShowsCountByOne($itemDto);
         $itemPicturesCount = $itemDto->getPicturesCount();
         $this->addParam('item', $itemDto);
         //$this->addParam('userLevel', $userLevel);
         $this->addParam('itemManager', $itemManager);
         $this->addParam('itemPicturesCount', $itemPicturesCount);
         $this->addParam('itemPropertiesHierarchy', $itemManager->getItemProperties($item_id));
     }
     if ($this->getUserLevel() === UserGroups::$ADMIN) {
         $this->initRootCategories();
     }
 }
 public function addEventIntoEventsTableForOnlineCustomers($company)
 {
     $customerAlertsManager = CustomerAlertsManager::getInstance($this->config, $this->args);
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $onlineUsersManager = OnlineUsersManager::getInstance($this->config, $this->args);
     $userManager = UserManager::getInstance($this->config, $this->args);
     $onlineRegisteredCustomers = $onlineUsersManager->getOnlineRegisteredCustomers();
     foreach ($onlineRegisteredCustomers as $onlineUsersDto) {
         $customerType = $userManager->getCustomerTypeByEmail($onlineUsersDto->getEmail());
         if ($customerType === UserGroups::$USER) {
             $userCustomer = $userManager->getUserByEmail($onlineUsersDto->getEmail());
             $dealerDto = $companyDealersManager->getByCompanyIdAndUserId($userCustomer->getId(), $company->getId());
             if (isset($dealerDto)) {
                 $customerAlertsManager->addPriceUploadCustomerAlert($onlineUsersDto->getEmail(), $company, $onlineUsersDto->getLanguageCode());
             }
         } elseif ($customerType === UserGroups::$COMPANY || $customerType === UserGroups::$ADMIN) {
             $customerAlertsManager->addPriceUploadCustomerAlert($onlineUsersDto->getEmail(), $company);
         }
     }
 }
 public function getItemsOffsetAndLimit($search_text)
 {
     $vipCustomer = 0;
     if ($this->getUserLevel() === UserGroups::$USER) {
         $customer = $this->getCustomer();
         $userManager = UserManager::getInstance($this->config, $this->args);
         $vipCustomer = $userManager->isVipAndVipEnabled($customer);
     }
     if ($vipCustomer) {
         $pc_configurator_discount = floatval($this->getCmsVar('vip_pc_configurator_discount'));
     } else {
         $pc_configurator_discount = floatval($this->getCmsVar('pc_configurator_discount'));
     }
     $this->addParam("pc_configurator_discount", $pc_configurator_discount);
     $itemManager = ItemManager::getInstance($this->config, $this->args);
     $load_more = false;
     $offset = 0;
     if (isset($_REQUEST['load_more'])) {
         $load_more = true;
         if (isset($_REQUEST['loaded_items_count'])) {
             $offset = intval($this->secure($_REQUEST['loaded_items_count']));
         }
     }
     $this->addParam('load_more', $load_more);
     if (isset($_REQUEST['take_in_count_search_text']) && $_REQUEST['take_in_count_search_text'] == 1) {
         $this->addParam('only_update_component_container', 1);
     }
     $limit = 0;
     if (!$load_more) {
         $limit = $this->getSelectedSameItemsCount();
     }
     $limit += intval($this->getCmsVar('pcc_load_more_count'));
     $itemsTotalCount = intval($itemManager->getPccItemsByCategoryFormulaCount($this->getRequiredCategoriesFormulasArray(), $search_text));
     if ($offset + $limit < $itemsTotalCount) {
         $this->addParam("load_more_reach_to_end", 'false');
     } else {
         $this->addParam("load_more_reach_to_end", 'true');
     }
     return array($offset, $limit);
 }
 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();
     }
 }
 public function load()
 {
     $loadPage = 0;
     if (isset($_REQUEST['load_page'])) {
         $loadPage = $_REQUEST['load_page'];
     }
     if ($loadPage == 1) {
         $this->addParam("page_loaded", 1);
         $userManager = UserManager::getInstance($this->config, $this->args);
         $allUsersDtos = $userManager->selectAll();
         $this->addParam("users", $allUsersDtos);
     } else {
         $this->addParam("page_loaded", 0);
     }
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $allCompanyDealers = $companyDealersManager->getAllUsersCompaniesFull();
     $userCompanies = $this->getUserCompaniesArray($allCompanyDealers);
     $allServiceCompanyDealers = $serviceCompanyDealersManager->getAllUsersCompaniesFull();
     $userServiceCompanies = $this->getUserCompaniesArray($allServiceCompanyDealers);
     $this->addParam('userCompanies', $userCompanies);
     $this->addParam('userServiceCompanies', $userServiceCompanies);
 }
 /**
  * Initializes DB mappers
  *
  * @param object $config
  * @param object $args
  * @return
  */
 function __construct($config, $args, $user)
 {
     $this->config = $config;
     $this->args = $args;
     $this->user = $user;
     $this->pccm = PcConfiguratorManager::getInstance($this->config, $this->args);
     $this->itemManager = ItemManager::getInstance($this->config, $this->args);
     $this->office_pc_components_ratio = explode(',', $this->getCmsVar('office_pc_components_ratio'));
     $this->gaming_pc_components_ratio = explode(',', $this->getCmsVar('gaming_pc_components_ratio'));
     $this->office_pc_components_ratio_only_case = explode(',', $this->getCmsVar('office_pc_components_ratio_only_case'));
     $this->gaming_pc_components_ratio_only_case = explode(',', $this->getCmsVar('gaming_pc_components_ratio_only_case'));
     $userManager = UserManager::getInstance($config, $args);
     $vipCustomer = false;
     if ($this->user->getLevel() == UserGroups::$USER) {
         $userDto = $userManager->selectByPK($this->user->getId());
         $vipCustomer = $userManager->isVipAndVipEnabled($userDto);
     }
     if ($vipCustomer) {
         $pc_configurator_discount = $this->getCmsVar('vip_pc_configurator_discount');
     } else {
         $pc_configurator_discount = $this->getCmsVar('pc_configurator_discount');
     }
 }
 /**
  * Получить сообщение лога 
  * @author Dmitriy Khoroshilov
  * @since 2011/07/26 
  *
  * @return
  */
 public function getLogMessage($operation)
 {
     $message = "{$this->getDictionaryName()}. Справочник был ";
     switch ($operation) {
         case Log::OPERATION_INSERT:
             $message .= "создан ";
             break;
         case Log::OPERATION_UPDATE:
             $message .= "изменен ";
             break;
         case Log::OPERATION_DELETE:
             $message .= "удален ";
             break;
         case Log::OPERATION_ERROR:
             $message = "Произошла ошибка при операции с записью ";
             break;
     }
     $user = fvSite::$fvSession->getUser();
     $message = "в " . date("Y-m-d H:i:s") . ".";
     if (UserManager::getInstance()->isRootInstance($user)) {
         $message .= " Пользователь [{$user->getPk()}] {$user->getLogin()} ({$user->getFullName()})";
     }
     return $message;
 }
 public function getLogMessage($operation)
 {
     $message = "Информация обратной связи была ";
     switch ($operation) {
         case Log::OPERATION_INSERT:
             $message .= "создана ";
             break;
         case Log::OPERATION_UPDATE:
             $message .= "изменена ";
             break;
         case Log::OPERATION_DELETE:
             $message .= "удалена ";
             break;
         case Log::OPERATION_ERROR:
             $message = "Произошла ошибка при операции с записью ";
             break;
     }
     $message .= "в " . date("Y-m-d H:i:s");
     $user = fvSite::$fvSession->getUser();
     if (UserManager::getInstance()->isRootInstance($user)) {
         $message .= ". Пользователь [" . $user->getPk() . "] " . $user->getLogin() . " (" . $user->getFullName() . ")";
     }
     return $message;
 }
Exemple #30
0
     if (isset($_POST['query'])) {
         $userQueryValue = htmlspecialchars($_POST['query']);
     }
     $content .= '
     <div class="searchfield">
         <form class="normal inline" action="index.php?module=' . $thisModule . '&action=changeuser&type=' . $changeType . '&ticket=' . $ticketID . '" method="post">
             <div class="form-group">
                 <input type="text" id="query-arrival" name="query" value="' . $userQueryValue . '" />
                 <input type="submit" name="doSearch" value="' . _("Search") . '" />
             </div>
         </form>
     </div>';
     $searchString = db_escape($_POST['query']);
     if (strlen($_POST['query']) > 0) {
         $str = db_escape(htmlspecialchars($_POST['query']));
         $result = UserManager::getInstance()->searchUsers($str);
         if (count($result) > 0) {
             $content .= "<table class=\"table ticket-table\"><thead><tr><th>" . _("Name") . "</th></tr></thead><tbody>";
             foreach ($result as $key => $value) {
                 $name = $value->firstName . ' ' . $value->lastName . ' (' . $value->nick . ')';
                 $content .= "\n                            <tr><td>\n                                <a href=\"index.php?module={$thisModule}&amp;action=changeuser&amp;type={$changeType}&amp;set=" . $value->ID . "&amp;ticket={$ticketID}\">{$name}</a>\n                            </td></tr>";
             }
             $content .= "</tbody></table>";
         } else {
             $content .= "<div class=\"empty-text\">" . _("No users found") . "</div>";
         }
     }
 }
 break;
 //==================================================================================
 // Ticket detail display