Exemplo n.º 1
0
 /**
  * Log in
  */
 public function action_login()
 {
     $this->title = __('user.authorization');
     if ($this->request->is_post()) {
         // If not logged
         if (!$this->auth->login($this->request->post('email'), $this->request->post('password'), (bool) $this->request->post('remember'))) {
             Message::error(__('user.error_authorization'));
             HTTP::redirect(Route::url('b_auth', ['action' => 'login']));
         }
     }
     $this->user = $this->auth->get_user();
     if ($this->user and !$this->user->confirmed) {
         Message::warning(__('user.email_сheck_and_confirm', [':email' => $this->user->email]));
         $this->auth->logout();
         HTTP::redirect(Route::url('b_auth', ['action' => 'login']));
     }
     // If user is admin
     if ($this->auth->logged_in('admin')) {
         Message::success(__('user.hello_username', [':username' => $this->user->username]));
         HTTP::redirect(Route::url('b_dashboard'));
     }
     // If user is user
     if ($this->auth->logged_in()) {
         Message::set('success', __('user.hello_username', [':username' => $this->user->username]));
         HTTP::redirect(Route::url('f_user_profile'));
     }
     $this->content = View::factory('auth/backend/v_login');
 }
 /**
  * Display the  time of the newest SysLog entry from Cron
  * 
  * @global type $_ARRAYLANG
  */
 public function showSettings()
 {
     global $_ARRAYLANG;
     $logRepo = $this->em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
     $nameSpace = explode('\\', $this->getNamespace());
     array_shift($nameSpace);
     $logger = implode('/', $nameSpace);
     $cronSysLogs = $logRepo->findLatestLogEntryByLogger($logger);
     $lastSysLogExecutionTime = $_ARRAYLANG['TXT_CORE_MODULE_CRON_NEVER'];
     if (!empty($cronSysLogs)) {
         $lastSysLogEntry = current($cronSysLogs);
         $lastSysLogExecutionTime = $lastSysLogEntry->getTimestamp()->format(ASCMS_DATE_FORMAT_DATETIME);
     } else {
         \Message::warning($_ARRAYLANG['TXT_CORE_MODULE_CRON_ERROR_MSG']);
     }
     $this->template->setVariable(array('CRON_LAST_EXECUTION' => $_ARRAYLANG['TXT_CORE_MODULE_CRON_LAST_EXECUTION'], 'CRON_LAST_EXECUTION_TIME' => $lastSysLogExecutionTime, 'CRON_SETTINGS' => $_ARRAYLANG['TXT_CORE_MODULE_CRON_ACT_SETTINGS']));
 }
Exemplo n.º 3
0
 protected function testTheEnvironment()
 {
     $message = new Message();
     if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
         $message->error('HTMLy requires at least PHP 5.3 to run.');
     }
     if (!in_array('https', stream_get_wrappers())) {
         $message->error('Installer needs the https wrapper, please install openssl.');
     }
     if (function_exists('apache_get_modules') && !in_array('mod_rewrite', apache_get_modules())) {
         $message->warning('mod_rewrite must be enabled if you use Apache.');
     }
     if (!is__writable("./")) {
         $message->error('no permission to write in the Directory.');
     }
     return $message->run();
 }
Exemplo n.º 4
0
 private function checkWritePermissions()
 {
     global $_ARRAYLANG;
     $this->writable = true;
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable(self::getSettingsFile())) {
         $this->writable = false;
         \Message::warning(sprintf($_ARRAYLANG['TXT_SETTINGS_ERROR_NO_WRITE_ACCESS'], self::getSettingsFile()));
     }
     if (!\Cx\Lib\FileSystem\FileSystem::makeWritable($this->configFile)) {
         $this->writable = false;
         \Message::warning(sprintf($_ARRAYLANG['TXT_SETTINGS_ERROR_NO_WRITE_ACCESS'], $this->configFile));
     }
 }
Exemplo n.º 5
0
 /**
  * Display a section of settings present in the $arrSettings class array
  *
  * See the description of {@see show()} for details.
  * @param   \Cx\Core\Html\Sigma $objTemplateLocal   The Template object,
  *                                                  by reference
  * @param   string              $section      The optional section header
  *                                            text to add
  * @param   string              $prefix       The optional prefix for
  *                                            language variables.
  *                                            Defaults to 'TXT_'
  * @return  boolean                           True on success, false otherwise
  */
 static function show_section(&$objTemplateLocal, $section = '', $prefix = 'TXT_', $readOnly = false)
 {
     global $_ARRAYLANG, $_CORELANG;
     $arrSettings = self::getCurrentSettings();
     self::verify_template($objTemplateLocal);
     // This is set to multipart if necessary
     $enctype = '';
     $i = 0;
     if ($objTemplateLocal->blockExists('core_setting_row')) {
         $objTemplateLocal->setCurrentBlock('core_setting_row');
     }
     foreach ($arrSettings as $name => $arrSetting) {
         // Determine HTML element for type and apply values and selected
         $element = '';
         $value = $arrSetting['value'];
         $values = self::splitValues($arrSetting['values']);
         $type = $arrSetting['type'];
         // Not implemented yet:
         // Warn if some mandatory value is empty
         if (empty($value) && preg_match('/_mandatory$/', $type)) {
             \Message::warning(sprintf($_CORELANG['TXT_CORE_SETTING_WARNING_EMPTY'], $_ARRAYLANG[$prefix . strtoupper($name)], $name));
         }
         // Warn if some language variable is not defined
         if (empty($_ARRAYLANG[$prefix . strtoupper($name)])) {
             \Message::warning(sprintf($_CORELANG['TXT_CORE_SETTING_WARNING_MISSING_LANGUAGE'], $prefix . strtoupper($name), $name));
         }
         //DBG::log("Value: $value -> align $value_align");
         switch ($type) {
             // Dropdown menu
             case self::TYPE_DROPDOWN:
                 $matches = null;
                 if (preg_match('/^\\{src:([a-z0-9_\\\\:]+)\\(\\)\\}$/i', $arrSetting['values'], $matches)) {
                     $arrValues = self::splitValues(call_user_func($matches[1]));
                 } else {
                     $arrValues = self::splitValues($arrSetting['values']);
                 }
                 //DBG::log("Values: ".var_export($arrValues, true));
                 $element = \Html::getSelect($name, $arrValues, $value, '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;' . (isset($arrValues[$value]) && is_numeric($arrValues[$value]) ? 'text-align: right;' : '') . '"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
             case self::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE:
                 $element = \Html::getSelect($name, User_Profile_Attribute::getCustomAttributeNameArray(), $arrSetting['value'], '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
             case self::TYPE_DROPDOWN_USERGROUP:
                 $element = \Html::getSelect($name, UserGroup::getNameArray(), $arrSetting['value'], '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
             case self::TYPE_WYSIWYG:
                 // These must be treated differently, as wysiwyg editors
                 // claim the full width
                 if ($readOnly) {
                     // TODO: this might be dangerous! should be rewritten probably
                     $element = $value;
                 } else {
                     $element = new \Cx\Core\Wysiwyg\Wysiwyg($name, $value);
                 }
                 $objTemplateLocal->setVariable(array('CORE_SETTING_ROW' => $_ARRAYLANG[$prefix . strtoupper($name)], 'CORE_SETTING_ROWCLASS1' => ++$i % 2 ? '1' : '2'));
                 $objTemplateLocal->parseCurrentBlock();
                 $objTemplateLocal->setVariable(array('CORE_SETTING_ROW' => $element . '<br /><br />', 'CORE_SETTING_ROWCLASS1' => ++$i % 2 ? '1' : '2'));
                 $objTemplateLocal->parseCurrentBlock();
                 // Skip the part below, all is done already
                 continue 2;
             case self::TYPE_FILEUPLOAD:
                 //echo("\Cx\Core\Setting\Controller\Setting::show_section(): Setting up upload for $name, $value<br />");
                 $element = \Html::getInputFileupload($name, $value ? $name : false, Filetype::MAXIMUM_UPLOAD_FILE_SIZE, $arrSetting['values'], 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''), true, $value ? $value : 'media/' . (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'other'));
                 // File uploads must be multipart encoded
                 $enctype = 'enctype="multipart/form-data"';
                 break;
             case self::TYPE_BUTTON:
                 // The button is only available to trigger some event.
                 $event = 'onclick=\'' . 'if (confirm("' . $_ARRAYLANG[$prefix . strtoupper($name) . '_CONFIRM'] . '")) {' . 'document.getElementById("' . $name . '").value=1;' . 'document.formSettings_' . self::$tab_index . '.submit();' . '}\'';
                 //DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Event: $event");
                 $element = \Html::getInputButton('__' . $name, $_ARRAYLANG[strtoupper($prefix . $name) . '_LABEL'], 'button', false, $event . ($readOnly ? \Html::ATTRIBUTE_DISABLED : '')) . \Html::getHidden($name, 0, '');
                 //DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Element: $element");
                 break;
             case self::TYPE_TEXTAREA:
                 $element = \Html::getTextarea($name, $value, 80, 8, $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 //                        'style="width: '.self::DEFAULT_INPUT_WIDTH.'px;'.$value_align.'"');
                 break;
             case self::TYPE_CHECKBOX:
                 $arrValues = self::splitValues($arrSetting['values']);
                 $value_true = current($arrValues);
                 $element = \Html::getCheckbox($name, $value_true, false, in_array($value, $arrValues), '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 break;
             case self::TYPE_CHECKBOXGROUP:
                 $checked = self::splitValues($value);
                 $element = \Html::getCheckboxGroup($name, $values, $values, $checked, '', '', '<br />', $readOnly ? \Html::ATTRIBUTE_DISABLED : '', '');
                 break;
                 // 20120508 UNTESTED!
             // 20120508 UNTESTED!
             case self::TYPE_RADIO:
                 $checked = $value;
                 $element = \Html::getRadioGroup($name, $values, $checked, '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 break;
             case self::TYPE_PASSWORD:
                 $element = \Html::getInputPassword($name, $value, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
                 //datepicker
             //datepicker
             case self::TYPE_DATE:
                 $element = \Html::getDatepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
                 break;
                 //datetimepicker
             //datetimepicker
             case self::TYPE_DATETIME:
                 $element = \Html::getDatetimepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
                 break;
                 // Default to text input fields
             // Default to text input fields
             case self::TYPE_TEXT:
             case self::TYPE_EMAIL:
             default:
                 $element = \Html::getInputText($name, $value, false, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;' . (is_numeric($value) ? 'text-align: right;' : '') . '"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
         }
         //add Tooltip
         $toolTips = '';
         $toolTipsHelp = '';
         if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'])) {
             // generate tooltip for configuration option
             $toolTips = '  <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'] . '</span>';
         }
         if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'])) {
             // generate tooltip for configuration option
             $toolTipsHelp = '  <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'] . '</span>';
         }
         $objTemplateLocal->setVariable(array('CORE_SETTING_NAME' => (isset($_ARRAYLANG[$prefix . strtoupper($name)]) ? $_ARRAYLANG[$prefix . strtoupper($name)] : $name) . $toolTips, 'CORE_SETTING_VALUE' => $element . $toolTipsHelp, 'CORE_SETTING_ROWCLASS2' => ++$i % 2 ? '1' : '2'));
         $objTemplateLocal->parseCurrentBlock();
         //echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $prefix): shown $name => $value<br />");
     }
     // Set form encoding to multipart if necessary
     if (!empty($enctype)) {
         $objTemplateLocal->setVariable('CORE_SETTING_ENCTYPE', $enctype);
     }
     if (!empty($section) && $objTemplateLocal->blockExists('core_setting_section')) {
         //echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $header, $prefix): creating section $header<br />");
         $objTemplateLocal->setVariable(array('CORE_SETTING_SECTION' => $section));
         //$objTemplateLocal->parse('core_setting_section');
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * Returns an array with all placeholders and their values to be
  * replaced in any shop mailtemplate for the given order ID.
  *
  * You only have to set the 'substitution' index value of your MailTemplate
  * array to the array returned.
  * Customer data is not included here.  See {@see Customer::getSubstitutionArray()}.
  * Note that this method is now mostly independent of the current session.
  * The language of the mail template is determined by the browser
  * language range stored with the order.
  * @access  private
  * @static
  * @param   integer $order_id     The order ID
  * @param   boolean $create_accounts  If true, creates User accounts
  *                                    and Coupon codes.  Defaults to true
  * @return  array                 The array with placeholders as keys
  *                                and values from the order on success,
  *                                false otherwise
  */
 static function getSubstitutionArray($order_id, $create_accounts = true)
 {
     global $_ARRAYLANG;
     /*
                 $_ARRAYLANG['TXT_SHOP_URI_FOR_DOWNLOAD'].":\r\n".
                 'http://'.$_SERVER['SERVER_NAME'].
                 "/index.php?section=download\r\n";
     */
     $objOrder = Order::getById($order_id);
     if (!$objOrder) {
         // Order not found
         return false;
     }
     $lang_id = $objOrder->lang_id();
     if (!intval($lang_id)) {
         $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id);
     }
     $status = $objOrder->status();
     $customer_id = $objOrder->customer_id();
     $customer = Customer::getById($customer_id);
     $payment_id = $objOrder->payment_id();
     $shipment_id = $objOrder->shipment_id();
     $arrSubstitution = array('CUSTOMER_COUNTRY_ID' => $objOrder->billing_country_id(), 'LANG_ID' => $lang_id, 'NOW' => date(ASCMS_DATE_FORMAT_DATETIME), 'TODAY' => date(ASCMS_DATE_FORMAT_DATE), 'ORDER_ID' => $order_id, 'ORDER_ID_CUSTOM' => ShopLibrary::getCustomOrderId($order_id), 'ORDER_DATE' => date(ASCMS_DATE_FORMAT_DATE, strtotime($objOrder->date_time())), 'ORDER_TIME' => date(ASCMS_DATE_FORMAT_TIME, strtotime($objOrder->date_time())), 'ORDER_STATUS_ID' => $status, 'ORDER_STATUS' => $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $status], 'MODIFIED' => date(ASCMS_DATE_FORMAT_DATETIME, strtotime($objOrder->modified_on())), 'REMARKS' => $objOrder->note(), 'ORDER_SUM' => sprintf('% 9.2f', $objOrder->sum()), 'CURRENCY' => Currency::getCodeById($objOrder->currency_id()));
     $arrSubstitution += $customer->getSubstitutionArray();
     if ($shipment_id) {
         $arrSubstitution += array('SHIPMENT' => array(0 => array('SHIPMENT_NAME' => sprintf('%-40s', Shipment::getShipperName($shipment_id)), 'SHIPMENT_PRICE' => sprintf('% 9.2f', $objOrder->shipment_amount()))), 'SHIPPING_ADDRESS' => array(0 => array('SHIPPING_COMPANY' => $objOrder->company(), 'SHIPPING_TITLE' => $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->gender())], 'SHIPPING_FIRSTNAME' => $objOrder->firstname(), 'SHIPPING_LASTNAME' => $objOrder->lastname(), 'SHIPPING_ADDRESS' => $objOrder->address(), 'SHIPPING_ZIP' => $objOrder->zip(), 'SHIPPING_CITY' => $objOrder->city(), 'SHIPPING_COUNTRY_ID' => $objOrder->country_id(), 'SHIPPING_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($objOrder->country_id()), 'SHIPPING_PHONE' => $objOrder->phone())));
     }
     if ($payment_id) {
         $arrSubstitution += array('PAYMENT' => array(0 => array('PAYMENT_NAME' => sprintf('%-40s', Payment::getNameById($payment_id)), 'PAYMENT_PRICE' => sprintf('% 9.2f', $objOrder->payment_amount()))));
     }
     $arrItems = $objOrder->getItems();
     if (!$arrItems) {
         \Message::warning($_ARRAYLANG['TXT_SHOP_ORDER_WARNING_NO_ITEM']);
     }
     // Deduct Coupon discounts, either from each Product price, or
     // from the items total.  Mind that the Coupon has already been
     // stored with the Order, but not redeemed yet.  This is done
     // in this method, but only if $create_accounts is true.
     $coupon_code = NULL;
     $coupon_amount = 0;
     $objCoupon = Coupon::getByOrderId($order_id);
     if ($objCoupon) {
         $coupon_code = $objCoupon->code();
     }
     $orderItemCount = 0;
     $total_item_price = 0;
     // Suppress Coupon messages (see Coupon::available())
     \Message::save();
     foreach ($arrItems as $item) {
         $product_id = $item['product_id'];
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             //die("Product ID $product_id not found");
             continue;
         }
         //DBG::log("Orders::getSubstitutionArray(): Item: Product ID $product_id");
         $product_name = substr($item['name'], 0, 40);
         $item_price = $item['price'];
         $quantity = $item['quantity'];
         // TODO: Add individual VAT rates for Products
         //            $orderItemVatPercent = $objResultItem->fields['vat_percent'];
         // Decrease the Product stock count,
         // applies to "real", shipped goods only
         $objProduct->decreaseStock($quantity);
         $product_code = $objProduct->code();
         // Pick the order items attributes
         $str_options = '';
         // Any attributes?
         if ($item['attributes']) {
             $str_options = '  ';
             // '[';
             $attribute_name_previous = '';
             foreach ($item['attributes'] as $attribute_name => $arrAttribute) {
                 //DBG::log("Attribute /$attribute_name/ => ".var_export($arrAttribute, true));
                 // NOTE: The option price is optional and may be left out
                 foreach ($arrAttribute as $arrOption) {
                     $option_name = $arrOption['name'];
                     $option_price = $arrOption['price'];
                     $item_price += $option_price;
                     // Recognize the names of uploaded files,
                     // verify their presence and use the original name
                     $option_name_stripped = ShopLibrary::stripUniqidFromFilename($option_name);
                     $path = Order::UPLOAD_FOLDER . $option_name;
                     if ($option_name != $option_name_stripped && \File::exists($path)) {
                         $option_name = $option_name_stripped;
                     }
                     if ($attribute_name != $attribute_name_previous) {
                         if ($attribute_name_previous) {
                             $str_options .= '; ';
                         }
                         $str_options .= $attribute_name . ': ' . $option_name;
                         $attribute_name_previous = $attribute_name;
                     } else {
                         $str_options .= ', ' . $option_name;
                     }
                     // TODO: Add proper formatting with sprintf() and language entries
                     if ($option_price != 0) {
                         $str_options .= ' ' . Currency::formatPrice($option_price) . ' ' . Currency::getActiveCurrencyCode();
                     }
                 }
             }
             //                $str_options .= ']';
         }
         // Product details
         $arrProduct = array('PRODUCT_ID' => $product_id, 'PRODUCT_CODE' => $product_code, 'PRODUCT_QUANTITY' => $quantity, 'PRODUCT_TITLE' => $product_name, 'PRODUCT_OPTIONS' => $str_options, 'PRODUCT_ITEM_PRICE' => sprintf('% 9.2f', $item_price), 'PRODUCT_TOTAL_PRICE' => sprintf('% 9.2f', $item_price * $quantity));
         //DBG::log("Orders::getSubstitutionArray($order_id, $create_accounts): Adding article: ".var_export($arrProduct, true));
         $orderItemCount += $quantity;
         $total_item_price += $item_price * $quantity;
         if ($create_accounts) {
             // Add an account for every single instance of every Product
             for ($instance = 1; $instance <= $quantity; ++$instance) {
                 $validity = 0;
                 // Default to unlimited validity
                 // In case there are protected downloads in the cart,
                 // collect the group IDs
                 $arrUsergroupId = array();
                 if ($objProduct->distribution() == 'download') {
                     $usergroupIds = $objProduct->usergroup_ids();
                     if ($usergroupIds != '') {
                         $arrUsergroupId = explode(',', $usergroupIds);
                         $validity = $objProduct->weight();
                     }
                 }
                 // create an account that belongs to all collected
                 // user groups, if any.
                 if (count($arrUsergroupId) > 0) {
                     // The login names are created separately for
                     // each product instance
                     $username = self::usernamePrefix . "_{$order_id}_{$product_id}_{$instance}";
                     $userEmail = $username . '-' . $arrSubstitution['CUSTOMER_EMAIL'];
                     $userpass = \User::make_password();
                     $objUser = new \User();
                     $objUser->setUsername($username);
                     $objUser->setPassword($userpass);
                     $objUser->setEmail($userEmail);
                     $objUser->setAdminStatus(false);
                     $objUser->setActiveStatus(true);
                     $objUser->setGroups($arrUsergroupId);
                     $objUser->setValidityTimePeriod($validity);
                     $objUser->setFrontendLanguage(FRONTEND_LANG_ID);
                     $objUser->setBackendLanguage(FRONTEND_LANG_ID);
                     $objUser->setProfile(array('firstname' => array(0 => $arrSubstitution['CUSTOMER_FIRSTNAME']), 'lastname' => array(0 => $arrSubstitution['CUSTOMER_LASTNAME']), 'company' => array(0 => $arrSubstitution['CUSTOMER_COMPANY']), 'address' => array(0 => $arrSubstitution['CUSTOMER_ADDRESS']), 'zip' => array(0 => $arrSubstitution['CUSTOMER_ZIP']), 'city' => array(0 => $arrSubstitution['CUSTOMER_CITY']), 'country' => array(0 => $arrSubstitution['CUSTOMER_COUNTRY_ID']), 'phone_office' => array(0 => $arrSubstitution['CUSTOMER_PHONE']), 'phone_fax' => array(0 => $arrSubstitution['CUSTOMER_FAX'])));
                     if (!$objUser->store()) {
                         \Message::error(implode('<br />', $objUser->getErrorMsg()));
                         return false;
                     }
                     if (empty($arrProduct['USER_DATA'])) {
                         $arrProduct['USER_DATA'] = array();
                     }
                     $arrProduct['USER_DATA'][] = array('USER_NAME' => $username, 'USER_PASS' => $userpass);
                 }
                 //echo("Instance $instance");
                 if ($objProduct->distribution() == 'coupon') {
                     if (empty($arrProduct['COUPON_DATA'])) {
                         $arrProduct['COUPON_DATA'] = array();
                     }
                     //DBG::log("Orders::getSubstitutionArray(): Getting code");
                     $code = Coupon::getNewCode();
                     //DBG::log("Orders::getSubstitutionArray(): Got code: $code, calling Coupon::addCode($code, 0, 0, 0, $item_price)");
                     Coupon::storeCode($code, 0, 0, 0, $item_price, 0, 0, 10000000000.0, true);
                     $arrProduct['COUPON_DATA'][] = array('COUPON_CODE' => $code);
                 }
             }
             // Redeem the *product* Coupon, if possible for the Product
             if ($coupon_code) {
                 $objCoupon = Coupon::available($coupon_code, $item_price * $quantity, $customer_id, $product_id, $payment_id);
                 if ($objCoupon) {
                     $coupon_code = NULL;
                     $coupon_amount = $objCoupon->getDiscountAmount($item_price, $customer_id);
                     if ($create_accounts) {
                         $objCoupon->redeem($order_id, $customer_id, $item_price * $quantity);
                     }
                 }
                 //\DBG::log("Orders::getSubstitutionArray(): Got Product Coupon $coupon_code");
             }
         }
         if (empty($arrSubstitution['ORDER_ITEM'])) {
             $arrSubstitution['ORDER_ITEM'] = array();
         }
         $arrSubstitution['ORDER_ITEM'][] = $arrProduct;
     }
     $arrSubstitution['ORDER_ITEM_SUM'] = sprintf('% 9.2f', $total_item_price);
     $arrSubstitution['ORDER_ITEM_COUNT'] = sprintf('% 4u', $orderItemCount);
     // Redeem the *global* Coupon, if possible for the Order
     if ($coupon_code) {
         $objCoupon = Coupon::available($coupon_code, $total_item_price, $customer_id, null, $payment_id);
         if ($objCoupon) {
             $coupon_amount = $objCoupon->getDiscountAmount($total_item_price, $customer_id);
             if ($create_accounts) {
                 $objCoupon->redeem($order_id, $customer_id, $total_item_price);
             }
         }
     }
     \Message::restore();
     // Fill in the Coupon block with proper discount and amount
     if ($objCoupon) {
         $coupon_code = $objCoupon->code();
         //\DBG::log("Orders::getSubstitutionArray(): Coupon $coupon_code, amount $coupon_amount");
     }
     if ($coupon_amount) {
         //\DBG::log("Orders::getSubstitutionArray(): Got Order Coupon $coupon_code");
         $arrSubstitution['DISCOUNT_COUPON'][] = array('DISCOUNT_COUPON_CODE' => sprintf('%-40s', $coupon_code), 'DISCOUNT_COUPON_AMOUNT' => sprintf('% 9.2f', -$coupon_amount));
     } else {
         //\DBG::log("Orders::getSubstitutionArray(): No Coupon for Order ID $order_id");
     }
     Products::deactivate_soldout();
     if (Vat::isEnabled()) {
         //DBG::log("Orders::getSubstitutionArray(): VAT amount: ".$objOrder->vat_amount());
         $arrSubstitution['VAT'] = array(0 => array('VAT_TEXT' => sprintf('%-40s', Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL']), 'VAT_PRICE' => $objOrder->vat_amount()));
     }
     return $arrSubstitution;
 }
Exemplo n.º 7
0
 /**
  * Restores the Cart from the Order ID given
  *
  * Redirects to the login when nobody is logged in.
  * Redirects to the history overview when the Order cannot be loaded,
  * or when it does not belong to the current Customer.
  * When $editable is true, redirects to the detail view of the first
  * Item for editing.  Editing will be disabled otherwise.
  * @global  array   $_ARRAYLANG
  * @param   integer $order_id   The Order ID
  * @param   boolean $editable   Items in the Cart are editable iff true
  */
 static function from_order($order_id, $editable = false)
 {
     global $_ARRAYLANG;
     $objCustomer = Shop::customer();
     if (!$objCustomer) {
         \Message::information($_ARRAYLANG['TXT_SHOP_ORDER_LOGIN_TO_REPEAT']);
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'login') . '?redirect=' . base64_encode(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart') . '?order_id=' . $order_id));
     }
     $customer_id = $objCustomer->getId();
     $order = Order::getById($order_id);
     if (!$order || $order->customer_id() != $customer_id) {
         \Message::warning($_ARRAYLANG['TXT_SHOP_ORDER_INVALID_ID']);
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'history'));
     }
     // Optional!
     self::destroy();
     $_SESSION['shop']['shipperId'] = $order->shipment_id();
     $_SESSION['shop']['paymentId'] = $order->payment_id();
     $order_attributes = $order->getOptionArray();
     $count = null;
     $arrAttributes = Attributes::getArray($count, 0, -1, null, array());
     // Find an Attribute and option IDs for the reprint type
     $attribute_id_reprint = $option_id_reprint = NULL;
     if (!$editable) {
         //DBG::log("Cart::from_order(): Checking for reprint...");
         foreach ($arrAttributes as $attribute_id => $objAttribute) {
             if ($objAttribute->getType() == Attribute::TYPE_EZS_REPRINT) {
                 //DBG::log("Cart::from_order(): TYPE reprint");
                 $options = $objAttribute->getOptionArray();
                 if ($options) {
                     $option_id_reprint = current(array_keys($options));
                     $attribute_id_reprint = $attribute_id;
                     //DBG::log("Cart::from_order(): Found reprint Attribute $attribute_id_reprint, option $option_id_reprint");
                     break;
                 }
             }
         }
     }
     foreach ($order->getItems() as $item) {
         $item_id = $item['item_id'];
         $attributes = $order_attributes[$item_id];
         $options = array();
         foreach ($attributes as $attribute_id => $attribute) {
             //                foreach (array_keys($attribute['options']) as $option_id) {
             foreach ($attribute['options'] as $option_id => $option) {
                 //DBG::log("Cart::from_order(): Option: ".var_export($option, true));
                 switch ($arrAttributes[$attribute_id]->getType()) {
                     case Attribute::TYPE_TEXT_OPTIONAL:
                     case Attribute::TYPE_TEXT_MANDATORY:
                     case Attribute::TYPE_TEXTAREA_OPTIONAL:
                     case Attribute::TYPE_TEXTAREA_MANDATORY:
                     case Attribute::TYPE_EMAIL_OPTIONAL:
                     case Attribute::TYPE_EMAIL_MANDATORY:
                     case Attribute::TYPE_URL_OPTIONAL:
                     case Attribute::TYPE_URL_MANDATORY:
                     case Attribute::TYPE_DATE_OPTIONAL:
                     case Attribute::TYPE_DATE_MANDATORY:
                     case Attribute::TYPE_NUMBER_INT_OPTIONAL:
                     case Attribute::TYPE_NUMBER_INT_MANDATORY:
                     case Attribute::TYPE_NUMBER_FLOAT_OPTIONAL:
                     case Attribute::TYPE_NUMBER_FLOAT_MANDATORY:
                     case Attribute::TYPE_EZS_ACCOUNT_3:
                     case Attribute::TYPE_EZS_ACCOUNT_4:
                     case Attribute::TYPE_EZS_IBAN:
                     case Attribute::TYPE_EZS_IN_FAVOR_OF:
                     case Attribute::TYPE_EZS_REFERENCE:
                     case Attribute::TYPE_EZS_CLEARING:
                     case Attribute::TYPE_EZS_DEPOSIT_FOR_6:
                     case Attribute::TYPE_EZS_DEPOSIT_FOR_2L:
                     case Attribute::TYPE_EZS_DEPOSIT_FOR_2H:
                     case Attribute::TYPE_EZS_PURPOSE_35:
                     case Attribute::TYPE_EZS_PURPOSE_50:
                         $options[$attribute_id][] = $option['name'];
                         break;
                     case Attribute::TYPE_EZS_REDPLATE:
                     case Attribute::TYPE_EZS_CONFIRMATION:
                         if (!$attribute_id_reprint) {
                             //DBG::log("Cart::from_order(): No reprint, adding option {$option['name']}");
                             $options[$attribute_id][] = $option_id;
                         }
                         break;
                     case Attribute::TYPE_EZS_REPRINT:
                         // Automatically added below when appropriate
                         break;
                     default:
                         //                        case Attribute::TYPE_EZS_ZEWOLOGO:
                         //                        case Attribute::TYPE_EZS_EXPRESS:
                         //                        case Attribute::TYPE_EZS_PURPOSE_BOLD:
                         $options[$attribute_id][] = $option_id;
                         break;
                 }
                 //DBG::log("Cart::from_order(): Added option: ".var_export($options, true));
             }
         }
         if ($attribute_id_reprint) {
             $options[$attribute_id_reprint][] = $option_id_reprint;
             //DBG::log("Cart::from_order(): Item has reprint Attribute, added $attribute_id_reprint => ($option_id_reprint)");
         }
         self::add_product(array('id' => $item['product_id'], 'quantity' => $item['quantity'], 'options' => $options));
     }
     if ($attribute_id_reprint) {
         // Mark the Cart as being unchanged since the restore, so the
         // additional cost for some Attributes won't be added again.
         self::restored_order_id($order_id);
     }
     \Message::information($_ARRAYLANG['TXT_SHOP_ORDER_RESTORED']);
     // Enable for production
     \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart'));
 }
Exemplo n.º 8
0
       } else {
           $pluginID = $dbQuery->fetchColumn(0);
           // Have they uploaded stuff before?
           $dbQuery2 = Database::select('plugin_downloads', '*', array('pid = ?', $pluginID));
           $message = '';
           if ($dbQuery2->rowCount() == 0) {
               $message = Message::notice('Hi there! It looks like this is the first time you\'ve uploaded files for this plugin. Simply select the files you wish to upload using the file selector below, and then provide details of your uploads in the form which will appear.');
           } else {
               $listNess = $dbQuery2->fetchAll();
               $list = '';
               foreach ($listNess as $fnameThing) {
                   $list .= '<li>' . $fnameThing['dfname'] . '</li>';
               }
               $message = Message::notice('The files you currently have on Fill are called:<br /><ul>' . $list . '</ul>');
           }
           $message .= Message::warning('Remember: if you want to upload a new version of a file, that file must be named EXACTLY the same.<br /><br />Example: I previously uploaded AwesomePlugin.jar - to upload a new version, you must ensure that it is named exactly the same.<br /><br /><b>File names cannot be changed once uploaded.</b>');
           Content::addAdditionalCSS('uploadify.css');
           Content::addAdditionalJS('jquery.uploadify.min.js');
           Content::addAdditionalJS('upload.js');
           $session = array('name' => session_name(), 'id' => session_id());
           Content::setContent(<<<EOT
t\t\t\t<h1>Upload Files</h1>
t\t\t\t{$message}
t\t\t\t<div id="uploadBox"></div>
t\t\t\t<!--<form action="/uploadComplete/{$params[0]}/{$params[1]}/" method="POST" id="uploadFormForm">-->
t\t\t\t<form action="http://www.postbin.org/1ffsuan" method="POST" id="uploadFormForm">
t\t\t\t<div id="uploadFormArea"></div>
t\t\t\t<input type="submit" id="bigSubmitButton" disabled="disabled" value="Save Data" />
t\t\t\t</form>
t\t\t\t<script type="text/javascript">
tuploadURI = '/handleUpload/{$params[0]}/{$params[1]}/&{$session['name']}={$session['id']}&loadSessionFromGET=true';
Exemplo n.º 9
0
 /**
  * Generates an overview of the Order for the Customer to confirm
  *
  * Forward her to the processing of the Order after the button has been
  * clicked.
  * @return  boolean             True on success, false otherwise
  */
 static function confirm()
 {
     global $_ARRAYLANG;
     // If the cart or address is missing, return to the shop
     if (!self::verifySessionAddress()) {
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', ''));
     }
     self::$show_currency_navbar = false;
     $stockStatus = Cart::checkProductStockStatus();
     if ($stockStatus) {
         \Message::warning($stockStatus);
     }
     // The Customer clicked the confirm button; this must not be the case
     // the first time this method is called.
     if (isset($_POST['process']) && !$stockStatus) {
         return self::process();
     }
     // Show confirmation page.
     self::$objTemplate->hideBlock('shopProcess');
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     // It may be necessary to refresh the cart here, as the customer
     // may return to the cart, then press "Back".
     self::_initPaymentDetails();
     foreach (Cart::get_products_array() as $arrProduct) {
         $objProduct = Product::getById($arrProduct['id']);
         if (!$objProduct) {
             // TODO: Implement a proper method
             //                unset(Cart::get_product_id($cart_id]);
             continue;
         }
         $price_options = 0;
         $attributes = Attributes::getAsStrings($arrProduct['options'], $price_options);
         $attributes = $attributes[0];
         // Note:  The Attribute options' price is added
         // to the price here!
         $price = $objProduct->get_custom_price(self::$objCustomer, $price_options, $arrProduct['quantity']);
         // Test the distribution method for delivery
         $productDistribution = $objProduct->distribution();
         $weight = $productDistribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '-';
         $vatId = $objProduct->vat_id();
         $vatRate = Vat::getRate($vatId);
         $vatPercent = Vat::getShort($vatId);
         $vatAmount = Vat::amount($vatRate, $price * $arrProduct['quantity']);
         self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CUSTOM_ID' => $objProduct->code(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price * $arrProduct['quantity']), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => Currency::formatPrice($price), 'SHOP_UNIT' => Currency::getActiveCurrencySymbol()));
         if ($attributes && self::$objTemplate->blockExists('attributes')) {
             self::$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $attributes);
         }
         if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => $weight, 'TXT_WEIGHT' => $_ARRAYLANG['TXT_WEIGHT']));
         }
         if (Vat::isEnabled()) {
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $vatPercent, 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($vatAmount) . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         }
         self::$objTemplate->parse("shopCartRow");
     }
     $total_discount_amount = 0;
     if (Cart::get_discount_amount()) {
         $total_discount_amount = Cart::get_discount_amount();
         self::$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
     }
     self::$objTemplate->setVariable(array('SHOP_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTALITEM' => Cart::get_item_count(), 'SHOP_PAYMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['payment_price']), 'SHOP_TOTALPRICE' => Currency::formatPrice(Cart::get_price()), 'SHOP_PAYMENT' => Payment::getProperty($_SESSION['shop']['paymentId'], 'name'), 'SHOP_GRAND_TOTAL' => Currency::formatPrice($_SESSION['shop']['grand_total_price']), 'SHOP_COMPANY' => stripslashes($_SESSION['shop']['company']), 'SHOP_TITLE' => stripslashes($_SESSION['shop']['gender']), 'SHOP_GENDER' => stripslashes($_SESSION['shop']['gender']), 'SHOP_LASTNAME' => stripslashes($_SESSION['shop']['lastname']), 'SHOP_FIRSTNAME' => stripslashes($_SESSION['shop']['firstname']), 'SHOP_ADDRESS' => stripslashes($_SESSION['shop']['address']), 'SHOP_ZIP' => stripslashes($_SESSION['shop']['zip']), 'SHOP_CITY' => stripslashes($_SESSION['shop']['city']), 'SHOP_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId']), 'SHOP_EMAIL' => stripslashes($_SESSION['shop']['email']), 'SHOP_PHONE' => stripslashes($_SESSION['shop']['phone']), 'SHOP_FAX' => stripslashes($_SESSION['shop']['fax'])));
     if (!empty($_SESSION['shop']['lastname2'])) {
         self::$objTemplate->setVariable(array('SHOP_COMPANY2' => stripslashes($_SESSION['shop']['company2']), 'SHOP_TITLE2' => stripslashes($_SESSION['shop']['gender2']), 'SHOP_LASTNAME2' => stripslashes($_SESSION['shop']['lastname2']), 'SHOP_FIRSTNAME2' => stripslashes($_SESSION['shop']['firstname2']), 'SHOP_ADDRESS2' => stripslashes($_SESSION['shop']['address2']), 'SHOP_ZIP2' => stripslashes($_SESSION['shop']['zip2']), 'SHOP_CITY2' => stripslashes($_SESSION['shop']['city2']), 'SHOP_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_PHONE2' => stripslashes($_SESSION['shop']['phone2'])));
     }
     if (!empty($_SESSION['shop']['note'])) {
         self::$objTemplate->setVariable(array('SHOP_CUSTOMERNOTE' => $_SESSION['shop']['note']));
     }
     if (Vat::isEnabled()) {
         self::$objTemplate->setVariable(array('TXT_TAX_RATE' => $_ARRAYLANG['TXT_SHOP_VAT_RATE'], 'SHOP_TAX_PRICE' => Currency::formatPrice($_SESSION['shop']['vat_price']), 'SHOP_TAX_PRODUCTS_TXT' => $_SESSION['shop']['vat_products_txt'], 'SHOP_TAX_GRAND_TXT' => $_SESSION['shop']['vat_grand_txt'], 'TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL']));
         if (Vat::isIncluded()) {
             self::$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice($_SESSION['shop']['grand_total_price'] - $_SESSION['shop']['vat_price'])));
         }
     }
     // TODO: Make sure in payment() that those two are either both empty or
     // both non-empty!
     if (!Cart::needs_shipment() && empty($_SESSION['shop']['shipperId'])) {
         if (self::$objTemplate->blockExists('shipping_address')) {
             self::$objTemplate->hideBlock('shipping_address');
         }
     } else {
         // Shipment is required, so
         if (empty($_SESSION['shop']['shipperId'])) {
             \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment'));
         }
         self::$objTemplate->setVariable(array('SHOP_SHIPMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['shipment_price']), 'SHOP_SHIPMENT' => Shipment::getShipperName($_SESSION['shop']['shipperId'])));
     }
     // Custom.
     // Enable if Discount class is customized and in use.
     //self::showCustomerDiscount(Cart::get_price());
     return true;
 }
Exemplo n.º 10
0
 /**
  * Confirmed password change
  */
 public function action_confirmed_restore()
 {
     $this->title = __('user.password_change');
     $token = $this->request->param('token');
     if ($token === null) {
         HTTP::redirect(Route::url('f_auth', ['action' => 'login']));
     }
     $o_confirm = ORM::factory('User_Confirm', ['token' => $token, 'type' => Model_User_Confirm::TYPE_RESTORE]);
     if (!$o_confirm->loaded()) {
         HTTP::redirect(Route::url('f_auth', ['action' => 'login']));
     }
     if (!$o_confirm->user->confirmed) {
         Message::warning(__('user.email_сheck_and_confirm', [':email' => $this->user->email]));
         HTTP::redirect(Route::url('f_auth', ['action' => 'login']));
     }
     // If current time > time recovery password
     if (time() > $o_confirm->expires) {
         $o_confirm->delete();
         Message::error(__('user.error_time_confirm_password_expired'));
         HTTP::redirect(Route::url('f_auth', ['action' => 'login']));
     }
     if ($this->request->is_post()) {
         $o_validation = Model_User::get_password_validation($_POST)->rule('password', 'not_empty')->rule('password_confirm', 'not_empty')->labels(['password' => __('user.password_new'), 'password_confirm' => __('user.password_confirm')]);
         if ($o_validation->check()) {
             $o_confirm->user->password = $o_validation['password'];
             $o_confirm->user->save();
             $this->auth->force_login($o_confirm->user->username);
             $o_confirm->delete();
             Message::success(__('user.password_changed'));
             HTTP::redirect(Route::url('f_user_profile', ['action' => 'view']));
         } else {
             Message::error(__('settings.error_saving'));
             $errors = $o_validation->errors('validation');
         }
     }
     $this->content = View::factory('auth/frontend/v_confirmed_restore')->bind('errors', $errors);
 }
Exemplo n.º 11
0
 /**
  * Returns an array of items contained in this Order
  * @global  ADONewConnection    $objDatabase
  * @global  array               $_ARRAYLANG
  * @return  array                               The items array on success,
  *                                              false otherwise
  * @todo    Let items be handled by their own class
  */
 function getItems()
 {
     global $objDatabase, $_ARRAYLANG;
     $query = "\n            SELECT `id`, `product_id`, `product_name`,\n                   `price`, `quantity`, `vat_rate`, `weight`\n              FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items`\n             WHERE `order_id`=?";
     $objResult = $objDatabase->Execute($query, array($this->id));
     if (!$objResult) {
         return self::errorHandler();
     }
     $arrProductOptions = $this->getOptionArray();
     $items = array();
     while (!$objResult->EOF) {
         $item_id = $objResult->fields['id'];
         $product_id = $objResult->fields['product_id'];
         $name = $objResult->fields['product_name'];
         $price = $objResult->fields['price'];
         $quantity = $objResult->fields['quantity'];
         $vat_rate = $objResult->fields['vat_rate'];
         // Get missing product details
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             \Message::warning(sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_NOT_FOUND'], $product_id));
             $objProduct = new Product('', 0, $name, '', $price, 0, 0, 0, $product_id);
         }
         $code = $objProduct->code();
         $distribution = $objProduct->distribution();
         $vat_id = $objProduct->vat_id();
         $weight = '0';
         if ($distribution != 'download') {
             $weight = $objResult->fields['weight'];
         }
         $item = array('product_id' => $product_id, 'quantity' => $quantity, 'name' => $name, 'price' => $price, 'item_id' => $item_id, 'code' => $code, 'vat_id' => $vat_id, 'vat_rate' => $vat_rate, 'weight' => $weight, 'attributes' => array());
         if (isset($arrProductOptions[$item_id])) {
             $item['attributes'] = $arrProductOptions[$item_id];
         }
         $items[] = $item;
         $objResult->MoveNext();
     }
     return $items;
 }
Exemplo n.º 12
0
 /**
  * Set the active status of one or more Users
  *
  * The $mix_user_id parameter may either be a user ID or an array thereof.
  * Sets appropriate messages.
  * @param   mixed   $mix_user_id        The User ID or an array of those
  * @param   boolean $active             Activate (true) or deactivate
  *                                      (false) the User(s).
  * @return  void
  */
 static function set_active($mix_user_id, $active)
 {
     global $_CORELANG;
     if (empty($mix_user_id)) {
         return;
     }
     if (!is_array($mix_user_id)) {
         $mix_user_id = array($mix_user_id);
     }
     $count = 0;
     global $objFWUser;
     $objUser = $objFWUser->objUser;
     foreach ($mix_user_id as $user_id) {
         $objUser = $objUser->getUser($user_id);
         if (!$objUser) {
             Message::warning(sprintf($_CORELANG['TXT_ACCESS_NO_USER_WITH_ID'], $user_id));
             continue;
         }
         //$objUser = new User();
         $objUser->setActiveStatus($active);
         if (!$objUser->store()) {
             Message::warning(sprintf($_CORELANG['TXT_SHOP_ERROR_CUSTOMER_UPDATING'], $user_id));
             continue;
         }
         ++$count;
     }
     if ($count) {
         Message::ok($_CORELANG['TXT_ACCESS_USER_ACCOUNT' . ($count > 1 ? 'S' : '') . '_' . ($active ? '' : 'DE') . 'ACTIVATED']);
     }
     return;
 }
Exemplo n.º 13
0
 /**
  * Edit a pricelist
  * @global  ADOConnection   $objDatabase
  * @global  array           $_ARRAYLANG
  * @return  boolean                         True on success, false otherwise
  */
 static function view_pricelist_edit()
 {
     global $_ARRAYLANG;
     $list_id = null;
     $objList = PriceList::getFromPost();
     if ($objList) {
         $result = $objList->store();
         if ($result) {
             if (isset($_REQUEST['list_id'])) {
                 unset($_REQUEST['list_id']);
             }
             //die("Showing lists");
             return self::view_pricelists();
         }
     }
     $list_id = isset($_GET['list_id']) ? $_GET['list_id'] : null;
     $objList = PriceList::getById($list_id);
     if (!$objList) {
         $objList = new PriceList(null);
     }
     $list_id = $objList->id();
     self::$objTemplate->loadTemplateFile("module_shop_pricelist_details.html");
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     self::$objTemplate->setVariable(array('SHOP_PRICELIST_EDIT' => $_ARRAYLANG[$list_id ? 'TXT_SHOP_PRICELIST_EDIT' : 'TXT_SHOP_PRICELIST_ADD'], 'SHOP_PRICELIST_ID' => $list_id, 'SHOP_PRICELIST_LINK_PDF' => $list_id ? PriceList::getUrl($list_id) : '', 'SHOP_PRICELIST_NAME' => $objList->name(), 'SHOP_PRICELIST_LANGUAGE_MENUOPTIONS' => \Html::getOptions(\FWLanguage::getNameArray(), $objList->lang_id()), 'SHOP_PRICELIST_BORDER_CHECKED' => $objList->border() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_CHECKED' => $objList->header() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_LEFT' => $objList->header_left(), 'SHOP_PRICELIST_HEADER_RIGHT' => $objList->header_right(), 'SHOP_PRICELIST_FOOTER_CHECKED' => $objList->footer() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_FOOTER_LEFT' => $objList->footer_left(), 'SHOP_PRICELIST_FOOTER_RIGHT' => $objList->footer_right()));
     $category_ids = $objList->category_ids();
     $category_all = false;
     if (empty($category_ids) || $category_ids == '*') {
         $category_all = true;
         self::$objTemplate->setVariable('SHOP_PRICELIST_CATEGORY_ALL_CHECKED', \Html::ATTRIBUTE_CHECKED);
     }
     // Get all categories
     $arrCategories = ShopCategories::getTreeArray(true, false);
     if (empty($arrCategories)) {
         Message::warning($_ARRAYLANG['TXT_SHOP_WARNING_NO_CATEGORIES']);
     }
     $i = 0;
     foreach ($arrCategories as $objCategory) {
         $category_id = $objCategory['id'];
         $selected = $category_all || preg_match('/(?:^|,)\\s*' . $category_id . '\\s*(?:,|$)/', $category_ids);
         //DBG::log("Category ID $category_id, ".($selected ? "selected" : "NOT"));
         self::$objTemplate->setVariable(array('SHOP_CATEGORY_ID' => contrexx_raw2xhtml($category_id), 'SHOP_CATEGORY_NAME' => contrexx_raw2xhtml($objCategory['name']), 'SHOP_CATEGORY_LEVELSPACE' => str_repeat('|----', $objCategory['level']), 'SHOP_CATEGORY_DISABLED' => $category_all ? \Html::ATTRIBUTE_DISABLED : '', 'SHOP_CATEGORY_CHECKED' => $selected ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_CATEGORY_ROWCLASS' => 'row' . (++$i % 2 + 1)));
         self::$objTemplate->parse('shop_category');
     }
     return true;
 }