Beispiel #1
0
 public function make($data)
 {
     $data = is_object($data) && $data instanceof Container ? $data->assoc() : $data;
     if (!Arrays::isAssoc($data)) {
         throw new Exception("This method needs a valid object to process.");
     }
     $e = $data['entity'] = $this->entity;
     $class = $this;
     $obj = new Container();
     $store = function () use($obj, $e) {
         $class = new Attributes($e);
         return $class->save($obj);
     };
     $remove = function () use($obj, $e) {
         $class = new Attributes($e);
         return $class->delete($obj);
     };
     $date = function ($f) use($obj) {
         return date('Y-m-d H:i:s', $obj->{$f});
     };
     $display = function ($f, $echo = true) use($obj) {
         if (false === $echo) {
             return Html\Helper::display($obj->{$f});
         } else {
             echo Html\Helper::display($obj->{$f});
         }
     };
     $obj->event('store', $store)->event('trash', $remove)->event('date', $date)->event('display', $display);
     foreach ($data as $k => $v) {
         if (!isset($obj->{$k})) {
             $obj->{$k} = $v;
         }
     }
     return $obj;
 }
Beispiel #2
0
 /**
  * Renders the alert
  *
  * @return string
  */
 public function render()
 {
     $attributes = new Attributes($this->attributes, ['class' => "alert {$this->type}"]);
     if ($this->closer) {
         $attributes->addClass('alert-dismissable');
         $this->contents = "<button type='button' class='close' " . "data-dismiss='alert' aria-hidden='true'>{$this->closer}" . "</button>{$this->contents}";
     }
     return "<div {$attributes}>{$this->contents}</div>";
 }
Beispiel #3
0
 public function render()
 {
     $attributes = new Attributes(['class' => $this->vertical ? 'btn-group-vertical' : 'btn-group', 'data-toggle' => 'buttons']);
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     $contents = $this->renderContents();
     return "<div {$attributes}>{$contents}</div>";
 }
Beispiel #4
0
 /**
  * Renders the progress bar
  *
  * @return string
  */
 public function render()
 {
     $string = "<div class='progress'>";
     $attributes = new Attributes($this->attributes, ['class' => "progress-bar {$this->type}", 'role' => 'progressbar', 'aria-valuenow' => "{$this->value}", 'aria-valuemin' => '0', 'aria-valuemax' => '100', 'style' => $this->value ? "width: {$this->value}%" : '']);
     if ($this->striped) {
         $attributes->addClass('progress-bar-striped');
     }
     if ($this->animated) {
         $attributes->addClass('active');
     }
     $string .= "<div {$attributes}>";
     $string .= $this->visible ? sprintf($this->visibleString, $this->value) : "<span class='sr-only'>{$this->value}% complete</span>";
     $string .= "</div>";
     $string .= "</div>";
     return $string;
 }
Beispiel #5
0
 /**
  * Create a listing HTML element.
  *
  * @param  string  $type
  * @param  array   $list
  * @param  array   $attributes
  *
  * @return string
  */
 public static function make($type, array $list, array $attributes = [])
 {
     if (count($list) == 0) {
         return '';
     }
     $html = static::makeElements($type, $list);
     $attributes = Attributes::make($attributes);
     return "<{$type}{$attributes}>{$html}</{$type}>";
 }
Beispiel #6
0
 /**
  * Registers a new value for a given attribute.
  * If the attribute hasn't changed yet, the new value is stored
  * as the original value of the attribute. If the attribute already has
  * an original value stored, and the new value equals to it, the attribute
  * change is unregistered. Otherwise, the new value is ignored; the
  * original value is kept.
  *
  * @return void
  */
 public function registerAttributeChange($attrName, $newValue)
 {
     if (!$this->attributeChanged($attrName)) {
         $oldValue = $this->attributes->get($attrName);
         if ((string) $newValue != (string) $oldValue) {
             $this->changedAttributes[$attrName] = $oldValue;
         }
     } elseif ((string) $newValue == (string) $this->changedAttributes[$attrName]) {
         unset($this->changedAttributes[$attrName]);
     }
 }
Beispiel #7
0
 /**
  * Sets an attribute value.
  * Will convert the value to the proper, internal PHP/Modlr data type.
  * Will do a dirty check immediately after setting.
  *
  * @param   string  $key    The attribute key (field) name.
  * @param   mixed   $value  The value to apply.
  * @return  self
  */
 protected function setAttribute($key, $value)
 {
     if (true === $this->isCalculatedAttribute($key)) {
         return $this;
     }
     $this->touch();
     $value = $this->convertAttributeValue($key, $value);
     $this->attributes->set($key, $value);
     $this->doDirtyCheck();
     return $this;
 }
Beispiel #8
0
 public function __construct()
 {
     Attributes::$database_connect = mysql_connect(self::DATABASE_HOST, self::DATABASE_USER, self::DATABASE_PASSWORD);
     if (!Attributes::$database_connect) {
         echo "Unable to connect to DB: " . mysql_error(Attributes::$database_connect);
         exit;
     }
     mysql_query("SET NAMES 'UTF8'", Attributes::$database_connect);
     if (!mysql_select_db(self::DATABASE_NAME, Attributes::$database_connect)) {
         echo "Unable to select mydbname: " . mysql_error(Attributes::$database_connect);
         exit;
     }
     $this->parser = xml_parser_create();
     xml_set_object($this->parser, $this);
     xml_set_element_handler($this->parser, "tag_open", "tag_close");
     xml_set_character_data_handler($this->parser, "cdata");
 }
	function addApplet ($appattr, $param) {
		$appattr = str_replace('\"', '"', $appattr);
		$param = str_replace('\"', '"', $param);
		$attr = new Attributes($appattr);
		$this->attribs = $attr->getAttribs();
		preg_replace('#\s*<param\s+(.*?)\s*/?>#sie', "\$this->addParam('$1')", $param);
	}
Beispiel #10
0
 /**
  * Returns a new Attribute queried by its Attribute ID from
  * the database.
  * @param   integer     $id        The Attribute ID
  * @return  Attribute            The Attribute object
  * @global  ADONewConnection
  * @static
  */
 static function getById($id)
 {
     $arrName = Attributes::getArrayById($id);
     if ($arrName === false) {
         return false;
     }
     $objAttribute = new self($arrName['name'], $arrName['type'], $id);
     return $objAttribute;
 }
Beispiel #11
0
 /**
  * Returns a string containing an Javascript array variable definition
  * with the first option ID for each Attribute
  *
  * The array has the form
  *  optionId[Attribute ID] = first option ID;
  * Additionally, the variable "index" is set to the highest option ID
  * encountered.  This is incremented for each new option added
  * on the page.
  * @static
  * @access    private
  * @return    string    $jsVars    Javascript variables list
  */
 static function getAttributeJSVars()
 {
     $jsVars = '';
     $highestIndex = 0;
     foreach (Attributes::getOptionArray() as $attribute_id => $arrOption) {
         $first = true;
         foreach (array_keys($arrOption) as $option_id) {
             if ($first) {
                 $jsVars .= "optionId[{$attribute_id}] = {$option_id};\n";
             }
             $first = false;
             if ($option_id > $highestIndex) {
                 $highestIndex = $option_id;
             }
         }
     }
     $jsVars .= "\nindex = " . $highestIndex . ";\n";
     return $jsVars;
 }
 /**
  * Return Overview Information
  *
  * @param $post
  * @return mixed|string
  */
 public function column_overview($post)
 {
     $data = '';
     $attributes = ud_get_wp_property('property_stats');
     $stat_count = 0;
     $hidden_count = 0;
     $display_stats = array();
     $meta = get_post_custom($post->ID);
     foreach ($meta as $k => $value) {
         if (!array_key_exists($k, $attributes)) {
             continue;
         }
         //** If has _ prefix it's a built-in WP key */
         if ('_' == $k[0]) {
             continue;
         }
         $attribute = Attributes::get_attribute_data($k);
         if (!$attribute['multiple']) {
             $value = $value[0];
         }
         $value = apply_filters("wpp::attribute::display", $value, $k);
         $value = apply_filters("wpp_stat_filter_{$k}", $value);
         $stat_count++;
         $stat_row_class = '';
         if ($stat_count > 5) {
             $stat_row_class = 'hidden wpp_overview_hidden_stats';
             $hidden_count++;
         }
         $display_stats[$k] = '<li class="' . $stat_row_class . '"><span class="wpp_label">' . $attributes[$k] . ':</span> <span class="wpp_value">' . $value . '</span></li>';
     }
     if (is_array($display_stats) && count($display_stats) > 0) {
         if ($stat_count > 5) {
             $display_stats['toggle_advanced'] = '<li class="wpp_show_advanced" advanced_option_class="wpp_overview_hidden_stats">' . sprintf(__('Toggle %1s more.', ud_get_wp_property()->domain), $hidden_count) . '</li>';
         }
         $data = '<ul class="wpp_overview_column_stats wpp_something_advanced_wrapper">' . implode('', $display_stats) . '</ul>';
     }
     return $data;
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $options_list = new UserOptions();
     $options_text = new UserText();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Users']) || isset($_POST['UserText']) || isset($_POST['UserOptions'])) {
         if (isset($_POST['Users'])) {
             $model->attributes = $_POST['Users'];
             $model->save();
         }
         if (isset($_POST['UserText'])) {
             $options_text->attributes = $_POST['UserText'];
             foreach ($options_text->Value as $key => $data) {
                 if (UserText::model()->findByAttributes(array('UserId' => $id, 'AttributeId' => $key))) {
                     $res = UserText::model()->findByAttributes(array('UserId' => $id, 'AttributeId' => $key));
                     if ($data) {
                         $res->Value = $data;
                         $res->save();
                     } else {
                         $res->delete();
                     }
                 } else {
                     if ($data) {
                         $options_text = new UserText();
                         $options_text->UserId = $id;
                         $options_text->AttributeId = $key;
                         $options_text->Value = $data;
                         $options_text->save();
                     }
                 }
             }
         }
         if (isset($_POST['UserOptions'])) {
             $options_list->attributes = $_POST['UserOptions'];
             $result = $options_list->AttributeValueId;
             foreach ($result as $key => $data) {
                 if (Attributes::model()->findByPk($key)->Type == 'checkbox') {
                     if (!empty($data)) {
                         $existed = array();
                         if (UserOptions::model()->findAllByAttributes(array('UserId' => $id, 'AttributeId' => $key))) {
                             $res = UserOptions::model()->findAllByAttributes(array('UserId' => $id, 'AttributeId' => $key));
                             foreach ($res as $val) {
                                 $existed[] = $val->AttributeValueId;
                             }
                         }
                         $toInsert = array_diff($data, $existed);
                         $toDelete = array_diff($existed, $data);
                         if (!empty($toInsert)) {
                             foreach ($toInsert as $insert) {
                                 $options_list = new UserOptions();
                                 $options_list->UserId = $id;
                                 $options_list->AttributeId = $key;
                                 $options_list->AttributeValueId = $insert;
                                 $options_list->save();
                             }
                         }
                         if (!empty($toDelete)) {
                             foreach ($toDelete as $delete) {
                                 UserOptions::model()->findByAttributes(array('UserId' => $id, 'AttributeId' => $key, 'AttributeValueId' => $delete))->delete();
                             }
                         }
                     } else {
                         if (UserOptions::model()->findAllByAttributes(array('UserId' => $id, 'AttributeId' => $key))) {
                             UserOptions::model()->deleteAllByAttributes(array('UserId' => $id, 'AttributeId' => $key));
                         }
                     }
                 } else {
                     if (UserOptions::model()->findByAttributes(array('UserId' => $id, 'AttributeId' => $key))) {
                         $res = UserOptions::model()->findByAttributes(array('UserId' => $id, 'AttributeId' => $key));
                         if ($data) {
                             $res->AttributeValueId = $data;
                             $res->save();
                         } else {
                             $res->delete();
                         }
                     } else {
                         $options_list = new UserOptions();
                         $options_list->UserId = $id;
                         $options_list->AttributeId = $key;
                         $options_list->AttributeValueId = $data;
                         $options_list->save();
                     }
                 }
             }
         }
         $this->redirect(array('update', 'id' => $model->Objid));
     }
     $this->render('update', array('model' => $model, 'options_list' => $options_list, 'options_text' => $options_text));
 }
Beispiel #14
0
 /**
  * Select a Product by ID from the database.
  * @static
  * @param       integer     $id             The Product ID
  * @return      Product                     The Product object on success,
  *                                          false otherwise
  * @global      ADONewConnection
  * @author      Reto Kohli <*****@*****.**>
  */
 static function getById($id)
 {
     global $objDatabase;
     if (!$id) {
         return NULL;
     }
     $arrSql = \Text::getSqlSnippets('`product`.`id`', FRONTEND_LANG_ID, 'Shop', array('name' => self::TEXT_NAME, 'short' => self::TEXT_SHORT, 'long' => self::TEXT_LONG, 'keys' => self::TEXT_KEYS, 'code' => self::TEXT_CODE, 'uri' => self::TEXT_URI));
     $query = "\n            SELECT `product`.`id`, `product`.`category_id`,\n                   `product`.`ord`, `product`.`active`, `product`.`weight`,\n                   `product`.`picture`,\n                   `product`.`normalprice`, `product`.`resellerprice`,\n                   `product`.`discountprice`, `product`.`discount_active`,\n                   `product`.`stock`, `product`.`stock_visible`,\n                   `product`.`distribution`,\n                   `product`.`date_start`, `product`.`date_end`,\n                   `product`.`manufacturer_id`,\n                   `product`.`b2b`, `product`.`b2c`,\n                   `product`.`vat_id`,\n                   `product`.`flags`,\n                   `product`.`usergroup_ids`,\n                   `product`.`group_id`, `product`.`article_id`,\n                   `product`.`minimum_order_quantity`, " . $arrSql['field'] . "\n              FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_products` AS `product`" . $arrSql['join'] . "\n             WHERE `product`.`id`={$id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return self::errorHandler();
     }
     if ($objResult->RecordCount() != 1) {
         return false;
     }
     $id = $objResult->fields['id'];
     $strCode = $objResult->fields['code'];
     if ($strCode === null) {
         $strCode = \Text::getById($id, 'Shop', self::TEXT_CODE)->content();
     }
     $strName = $objResult->fields['name'];
     if ($strName === null) {
         $strName = \Text::getById($id, 'Shop', self::TEXT_NAME)->content();
     }
     $strShort = $objResult->fields['short'];
     if ($strShort === null) {
         $strShort = \Text::getById($id, 'Shop', self::TEXT_SHORT)->content();
     }
     $strLong = $objResult->fields['long'];
     if ($strLong === null) {
         $strLong = \Text::getById($id, 'Shop', self::TEXT_LONG)->content();
     }
     $strUri = $objResult->fields['uri'];
     if ($strUri === null) {
         $strUri = \Text::getById($id, 'Shop', self::TEXT_URI)->content();
     }
     $strKeys = $objResult->fields['keys'];
     if ($strKeys === null) {
         $strKeys = \Text::getById($id, 'Shop', self::TEXT_KEYS)->content();
     }
     $objProduct = new Product($strCode, $objResult->fields['category_id'], $strName, $objResult->fields['distribution'], $objResult->fields['normalprice'], $objResult->fields['active'], $objResult->fields['ord'], $objResult->fields['weight'], $objResult->fields['id']);
     $objProduct->pictures = $objResult->fields['picture'];
     $objProduct->resellerprice = floatval($objResult->fields['resellerprice']);
     $objProduct->short = $strShort;
     $objProduct->long = $strLong;
     $objProduct->stock($objResult->fields['stock']);
     $objProduct->stock_visible($objResult->fields['stock_visible']);
     $objProduct->discountprice = floatval($objResult->fields['discountprice']);
     $objProduct->discount_active($objResult->fields['discount_active']);
     $objProduct->b2b($objResult->fields['b2b']);
     $objProduct->b2c($objResult->fields['b2c']);
     $objProduct->date_start($objResult->fields['date_start']);
     $objProduct->date_end($objResult->fields['date_end']);
     $objProduct->manufacturer_id = $objResult->fields['manufacturer_id'];
     $objProduct->uri = $strUri;
     $objProduct->vat_id = $objResult->fields['vat_id'];
     $objProduct->flags = $objResult->fields['flags'];
     $objProduct->usergroup_ids = $objResult->fields['usergroup_ids'];
     $objProduct->group_id = $objResult->fields['group_id'];
     $objProduct->article_id = $objResult->fields['article_id'];
     $objProduct->keywords = $strKeys;
     $objProduct->minimum_order_quantity = $objResult->fields['minimum_order_quantity'];
     // Fetch the Product Attribute relations
     $objProduct->arrRelations = Attributes::getRelationArray($objProduct->id);
     //die("dfhreh: ".$objProduct->category_id());
     return $objProduct;
 }
 /**
  * Renders the dropdown button
  *
  * @return string
  */
 public function render()
 {
     if ($this->dropup) {
         $string = "<div class='btn-group dropup'>";
     } else {
         $string = "<div class='btn-group'>";
     }
     $attributes = new Attributes($this->attributes, ['class' => "btn {$this->type} dropdown-toggle", 'data-toggle' => 'dropdown', 'type' => 'button']);
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     if ($this->split) {
         $splitAttributes = new Attributes(['class' => $attributes['class'], 'type' => 'button']);
         $splitAttributes['class'] = str_replace(' dropdown-toggle', '', $splitAttributes['class']);
         $string .= "<button {$splitAttributes}>{$this->label}</button>";
         $string .= "<button {$attributes}><span class='caret'></span></button>";
     } else {
         $string .= "<button {$attributes}>{$this->label} <span class='caret'></span></button>";
     }
     $string .= "<ul class='dropdown-menu' role='menu' aria-labelledby='dLabel'>";
     $string .= $this->renderItems();
     $string .= "</ul>";
     $string .= "</div>";
     return $string;
 }
Beispiel #16
0
 /**
  * @throws \ErrorException
  *
  * @return object
  */
 protected function scanAttributes()
 {
     if (substr($this->input, 0, 1) === '(') {
         // cant use ^ anchor in the regex because the pattern is recursive
         // but this restriction is asserted by the if above
         //$this->input = preg_replace('/([a-zA-Z0-9\'"\\]\\}\\)])([\t ]+[a-zA-Z])/', '$1,$2', $this->input);
         if (!preg_match('/\\((?:"(?:\\\\.|[^"\\\\])*"|\'(?:\\\\.|[^\'\\\\])*\'|[^()\'"]++|(?R))*+\\)/', $this->input, $matches)) {
             throw new \ErrorException('Unable to find attributes closing parenthesis.', 21);
         }
         $this->consume($matches[0]);
         //$str = preg_replace('/()([a-zA-Z0-9_\\x7f-\\xff\\)\\]\\}"\'])(\s+[a-zA-Z_])/', '$1,$2', $str);
         $token = $this->token('attributes');
         $token->attributes = array();
         $token->escaped = array();
         $token->selfClosing = false;
         $parser = new Attributes($token);
         $parser->parseWith(substr($matches[0], 1, strlen($matches[0]) - 2));
         if ($this->length() && '/' === $this->input[0]) {
             $this->consume(1);
             $token->selfClosing = true;
         }
         return $token;
     }
 }
/**
 *	Function read array of URIs and for each URI get the domain id,
 *	obtain value of attribute 'send_missed_calls'. If at least one attribute
 *	is true, this function return 1. Otherwise return 0. 
 *
 *	If no domain has the attribute set, the output of function depends on global 
 *	attribute 'send_missed_calls'
 *	
 *	@param	array	$uris
 *	@return	int				or FALSE on error
 */
function get_send_mc_of_dom($uris, &$mail_from)
{
    global $config;
    $an = $config->attr_names;
    $send = null;
    $mail_from = null;
    foreach ($uris as $uri) {
        $da =& Domain_Attrs::singleton($uri->get_did());
        if (false === ($s = $da->get_attribute($an['send_mc']))) {
            return false;
        }
        if (is_null($send)) {
            $send = $s;
        } else {
            $send = ($send or $s);
        }
        if ($s and !$mail_from) {
            $o = array('did' => $uri->get_did());
            if (false === ($from_header = Attributes::get_attribute($an['contact_email'], $o))) {
                return false;
            }
            if ($from_header) {
                $mail_from = $from_header;
            }
        }
    }
    if (is_null($send)) {
        $ga =& Global_Attrs::singleton();
        if (false === ($send = $ga->get_attribute($an['send_mc']))) {
            return false;
        }
    }
    return $send ? 1 : 0;
}
Beispiel #18
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'));
 }
 function validate_form(&$errors)
 {
     global $lang_str, $data, $config;
     if (false === parent::validate_form($errors)) {
         return false;
     }
     $an =& $config->attr_names;
     $d_h =& Domains::singleton();
     if (is_null($this->opt['register_in_domain']) and is_null($this->opt['create_new_domain'])) {
         if (!isset($_POST['domain']) or $_POST['domain'] === "") {
             $errors[] = $lang_str['fe_domain_not_selected'];
             return false;
         }
         $this->did = $_POST['domain'];
         if (!isset($this->domain_names[$this->did])) {
             $errors[] = "You haven't access to domain which you selected: " . $d_h->get_domain_name($this->did);
             return false;
         }
     } elseif (!is_null($this->opt['register_in_domain'])) {
         $this->did = $this->opt['register_in_domain'];
     } else {
         $this->did = null;
     }
     /* vhen user do not have admin privilege, check username assignment mode */
     if (!$this->opt['admin_priv']) {
         if (false === ($this->uname_assign_mode = $this->get_uname_assign_mode($this->did))) {
             return false;
         }
         switch ($this->uname_assign_mode) {
             case "adminonly":
                 $errors[] = "Only admins could register users in this domain";
                 return false;
                 break;
             case "email":
                 //email verification
                 $email_parts = explode("@", $_POST['email'], 2);
                 $email_username = $email_parts[0];
                 $email_domain = $email_parts[1];
                 //set username by the email username
                 $_POST['uname'] = $email_username;
                 if ($this->opt['create_new_domain'] and $email_domain != $this->opt['create_new_domain']) {
                     $errors[] = $lang_str["err_domain_of_email_not_match"];
                     return false;
                 } else {
                     if (false === ($domain_names = $d_h->get_domain_names($this->did))) {
                         return false;
                     }
                     if (!in_array($email_domain, $domain_names)) {
                         $errors[] = $lang_str["err_domain_of_email_not_match"];
                         return false;
                     }
                 }
                 /* confirmation of registration is always required in this case */
                 $this->opt['require_confirmation'] = true;
                 break;
             case "fcfs":
                 //first come first served
                 break;
             default:
                 ErrorHandler::log_errors(PEAR::raiseError("Unknown value of username assignment mode: '" . $this->uname_assign_mode . "'"));
                 return false;
         }
     }
     if (is_null($this->opt['create_new_domain'])) {
         if (0 === ($user_exists = $data->is_user_exists($_POST['uname'], $this->did))) {
             return false;
         }
         if ($user_exists < 0) {
             $errors[] = $lang_str['fe_uname_already_choosen_1'] . " '" . $_POST['uname'] . "' " . $lang_str['fe_uname_already_choosen_2'];
             return false;
         }
     }
     if ($this->opt['choose_passw'] and $_POST['passwd'] != $_POST['passwd_r']) {
         $errors[] = $lang_str['fe_passwords_not_match'];
         return false;
     }
     if ($this->opt['terms_file'] and empty($_POST['accept'])) {
         $errors[] = $lang_str['fe_not_accepted_terms'];
         return false;
     }
     //check values of attributes
     $opt = array();
     if (false === Attributes::validate_form_attrs($this->attributes, $opt, $errors)) {
         return false;
     }
     /* Check email for the case somebody makes the attribute optional.
      * We need it.
      */
     if (!$_POST[$an['email']]) {
         $errors[] = $lang_str['fe_not_valid_email'];
         return false;
     }
     return true;
 }
Beispiel #20
0
 public function actionSaveProduct()
 {
     $product = Products::model()->findByPk($_POST['productId']);
     $attributes = json_decode($_POST['attributes']);
     //удмлим все значения, связанные с текущим атрибутом и сам атрибут
     $attributes_AR = Attributes::model()->findAll("product_id=:product_id", array(':product_id' => $_POST['productId']));
     foreach ($attributes_AR as $attribute) {
         Values::model()->deleteAll("attribute_id=:attribute_id", array(':attribute_id' => $attribute->id));
         $attribute->delete();
     }
     foreach ($attributes as $attribute) {
         $attribute_AR = new Attributes();
         $attribute_AR->product_id = $product->id;
         $attribute_AR->name = $attribute->name;
         $res = $attribute_AR->save();
         if ($res == false) {
             echo "false-attr";
             return;
         }
         foreach ($attribute->values as $value) {
             $value_AR = new Values();
             $value_AR->name = $value->name;
             $value_AR->add_price = $value->add_price;
             $value_AR->attribute_id = $attribute_AR->id;
             $res = $value_AR->save();
             if ($res == false) {
                 echo "false-value";
                 return;
             }
         }
     }
     $product->discount = $_POST['discount'];
     $product->name = $_POST['name'];
     $product->text = $_POST['text'];
     if ($_POST['photo'] != '') {
         $product->photo = $_POST['photo'];
     }
     $product->main_price = $_POST['main_price'];
     $product->sostav = $_POST['sostav'];
     $res = $product->update();
     if ($res == false) {
         var_dump($product->errors);
         echo "false-prod";
         return;
     }
     echo "true";
 }
 /**
  * Prepare Property Meta Box based on Attributes' Groups for registration.
  *
  * @since 2.0
  * @author peshkov@UD
  */
 public function get_property_meta_box($group = array(), $post = false)
 {
     $group = wp_parse_args($group, array('id' => false, 'name' => __('NO NAME', ud_get_wp_property()->domain)));
     $fields = array();
     /**
      * Get all data we need to operate with.
      */
     $attributes = ud_get_wp_property('property_stats', array());
     $geo_type_attributes = ud_get_wp_property('geo_type_attributes', array());
     $hidden_attributes = ud_get_wp_property('hidden_attributes', array());
     $inherited_attributes = ud_get_wp_property('property_inheritance', array());
     $property_stats_groups = ud_get_wp_property('property_stats_groups', array());
     $predefined_values = ud_get_wp_property('predefined_values', array());
     $descriptions = ud_get_wp_property('descriptions', array());
     $input_types = ud_get_wp_property('admin_attr_fields');
     //** Detect attributes that were taken from a range of child properties. */
     $aggregated_attributes = !empty($post->system['upwards_inherited_attributes']) ? (array) $post->system['upwards_inherited_attributes'] : array();
     /**
      * If group ID is not defined, it means that we're registering main Meta Box
      * So, here, we're adding custom fields for management!
      */
     if ($group['id'] == false) {
         /* May be add Property Parent field - 'Falls Under' */
         $field = $this->get_parent_property_field($post);
         if ($field) {
             $fields[] = $field;
         }
         /* May be add Property Type field. */
         if (!array_key_exists('property_type', $attributes)) {
             $field = $this->get_property_type_field($post);
             if ($field) {
                 $fields[] = $field;
             }
         }
         /* May be add Meta fields */
         foreach (ud_get_wp_property()->get('property_meta', array()) as $slug => $label) {
             $field = apply_filters('wpp::rwmb_meta_box::field', array_filter(array('id' => $slug, 'name' => $label, 'type' => 'textarea', 'desc' => __('Meta description.', ud_get_wp_property()->domain))), $slug, $post);
             if ($field) {
                 $fields[] = $field;
             }
         }
     }
     /**
      * Loop through all available attributes and determine if any of them must be added to current meta box.
      */
     foreach ($attributes as $slug => $label) {
         /**
          * Determine if we should add attribute's field in this meta box
          */
         //** Show ( or not ) attribute field on Edit property page for current Property. */
         if (!apply_filters('wpp::metabox::attribute::show', true, $slug, $post->ID)) {
             continue;
         }
         //* Determine if attribute is assigned to group. */
         if (!empty($property_stats_groups[$slug]) && $property_stats_groups[$slug] != $group['id']) {
             continue;
         }
         //** Do not show attribute in group's meta box if it's not assigned to groups at all */
         if (empty($property_stats_groups[$slug]) && !empty($group['id'])) {
             continue;
         }
         //* Ignore Hidden Attributes */
         if (!empty($post->property_type) && !empty($hidden_attributes[$post->property_type]) && in_array($slug, (array) $hidden_attributes[$post->property_type])) {
             continue;
         }
         /**
          * Looks like we have to add attribute's field to the current meta box.
          * So, setup data for it now.
          */
         //* HACK. If property_type is set as attribute, we register it here. */
         if ($slug == 'property_type') {
             $field = $this->get_property_type_field($post);
             if ($field) {
                 $fields[] = $field;
             }
             continue;
         }
         $attribute = Attributes::get_attribute_data($slug);
         $description = array();
         $description[] = isset($attribute['numeric']) || isset($attribute['currency']) ? __('Numbers only.', ud_get_wp_property()->domain) : '';
         $description[] = !empty($descriptions[$slug]) ? $descriptions[$slug] : '';
         /**
          * PREPARE INPUT TYPE
          * May be convert input_type to valid type.
          */
         $input_type = !empty($input_types[$slug]) ? $input_types[$slug] : 'text';
         //* Geo Attributes */
         if (in_array($slug, $geo_type_attributes)) {
             $input_type = 'wpp_readonly';
             $description[] = __('The value is being generated automatically on Google Address Validation.', ud_get_wp_property()->domain);
         }
         //* Legacy compatibility */
         if (in_array($input_type, array('input'))) {
             $input_type = 'text';
         }
         //* Legacy compatibility */
         if (in_array($input_type, array('dropdown'))) {
             $input_type = 'select';
         }
         //* Legacy compatibility */
         if (in_array($input_type, array('checkbox'))) {
             $input_type = 'wpp_checkbox';
         }
         //* Legacy compatibility */
         if (in_array($input_type, array('multi_checkbox'))) {
             $input_type = 'checkbox_list';
         }
         //* Fix currency */
         if ($input_type == 'currency') {
             $input_type = 'text';
             // HTML5 does not allow to use float, so we have to use default 'text' here
             $description[] = __('Currency.', ud_get_wp_property('domain'));
         }
         if ($input_type == 'number') {
             $input_type = 'text';
             // HTML5 does not allow to use float, so we have to use default 'text' here
         }
         //** Determine if current attribute is used by Google Address Validator. */
         if (ud_get_wp_property('configuration.address_attribute') == $slug) {
             $input_type = 'wpp_address';
             // Too obvious, I believe. -potanin@UD
             // $description[] = __( 'The value is being used by Google Address Validator to determine and prepare address to valid format. However you can set coordinates manually.', ud_get_wp_property()->domain );
         }
         //* Is current attribute inherited from parent? If so, set it as readonly!. */
         if (isset($post->post_parent) && $post->post_parent > 0 && isset($post->property_type) && !empty($inherited_attributes[$post->property_type]) && in_array($slug, $inherited_attributes[$post->property_type])) {
             $input_type = 'wpp_inherited';
             $description[] = sprintf(__('The value is inherited from Parent %s.', ud_get_wp_property()->domain), \WPP_F::property_label());
         }
         //** Is current attribute's value aggregated from child properties? If so, set it as readonly! */
         if (!empty($aggregated_attributes) && in_array($slug, $aggregated_attributes)) {
             $input_type = 'wpp_aggregated';
             $description[] = sprintf(__('The value is aggregated from Child %s.', ud_get_wp_property()->domain), \WPP_F::property_label('plural'));
         }
         //** Determine if current attribute is used by Google Address Validator. */
         if (ud_get_wp_property('configuration.address_attribute') == $slug) {
             if ($input_type == 'wpp_inherited') {
                 $input_type = 'wpp_inherited_address';
             } else {
                 $input_type = 'wpp_address';
                 //$description[] = __( 'The value is being used by Google Address Validator to determine and prepare address to valid format. However you can set coordinates manually.', ud_get_wp_property()->domain );
             }
         }
         /**
          * Check for pre-defined values
          */
         $options = array();
         if ($input_type == 'select') {
             $options[''] = __('Not Selected', ud_get_wp_property()->domain);
         }
         if (!empty($predefined_values[$slug]) && is_string($predefined_values[$slug])) {
             $_options = explode(',', trim($predefined_values[$slug]));
             foreach ($_options as $option) {
                 $option = trim(preg_replace("/\r|\n/", "", $option));
                 $options[esc_attr($option)] = apply_filters('wpp_stat_filter_' . $slug, $option);
             }
         }
         /**
          * Well, init field now.
          */
         $fields[] = apply_filters('wpp::rwmb_meta_box::field', array_filter(array('id' => $slug, 'name' => $label, 'type' => $input_type, 'desc' => implode(' ', (array) $description), 'options' => $options)), $slug, $post);
     }
     $meta_box = apply_filters('wpp::rwmb_meta_box', array('id' => !empty($group['id']) ? $group['id'] : '_general', 'title' => $group['name'], 'pages' => array('property'), 'context' => 'normal', 'priority' => 'high', 'fields' => $fields), $group, $post);
     return $meta_box;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Attributes the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Attributes::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #23
0
 /**
  * Renders the accordion
  *
  * @return string
  */
 public function render()
 {
     if (!$this->name) {
         $this->name = Helpers::generateId($this);
     }
     $attributes = new Attributes($this->attributes, ['class' => 'panel-group', 'id' => $this->name]);
     $string = "<div {$attributes}>";
     $count = 0;
     foreach ($this->contents as $item) {
         $itemAttributes = array_key_exists('attributes', $item) ? $item['attributes'] : [];
         $itemAttributes = new Attributes($itemAttributes, ['class' => 'panel panel-default']);
         $string .= "<div {$itemAttributes}>";
         $string .= "<div class='panel-heading'>";
         $string .= "<h4 class='panel-title'>";
         $string .= "<a data-toggle='collapse' data-parent='#{$this->name}' " . "href='#{$this->name}-{$count}'>{$item['title']}</a>";
         $string .= "</h4>";
         $string .= "</div>";
         $bodyAttributes = new Attributes(['id' => "{$this->name}-{$count}", 'class' => 'panel-collapse collapse']);
         if ($this->opened == $count) {
             $bodyAttributes->addClass('in');
         }
         $string .= "<div {$bodyAttributes}>";
         $string .= "<div class='panel-body'>{$item['contents']}</div>";
         $string .= "</div>";
         $string .= "</div>";
         $count++;
     }
     $string .= "</div>";
     return $string;
 }
function doApplet ($pagename, $attrstr) {
	$attribs = new Attributes($attrstr);
	$attr = $attribs->getAttribs('fo');
	if (isset($attr['file'])) {
		$embed = new Embed($pagename, $attrstr);
		return Keep($embed->getWikiXML());
	}
	return '';
}
Beispiel #25
0
 /**
  * __construct
  *
  * @param array $attributes array of attribute name => value pairs for img tag
  */
 public function __construct($attributes = array())
 {
     parent::__construct($attributes);
 }
Beispiel #26
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;
     // The Customer clicked the confirm button; this must not be the case
     // the first time this method is called.
     if (isset($_POST['process'])) {
         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;
 }
 /**
  *	Validate given credentials and return UID if they are valid
  *
  *	@static
  *	@param	string	$username	
  *	@param	string	$did		
  *	@param	string	$password	
  *	@param	array	$optionals		
  *	@return	string				UID if credentials are valid, false otherwise
  */
 function validate_credentials($username, $did, $password, &$optionals)
 {
     global $lang_str, $data_auth, $config;
     $o_check_pw = isset($optionals['check_pw']) ? (bool) $optionals['check_pw'] : true;
     $data_auth->add_method('check_credentials');
     $data_auth->add_method('get_domain_flags');
     // check flags of domain
     if (false === ($flags = $data_auth->get_domain_flags($did, null))) {
         return false;
     }
     if ($flags['disabled']) {
         sw_log("validate_credentials: authentication failed: domain with id '" . $did . "' is disabled", PEAR_LOG_INFO);
         ErrorHandler::add_error($lang_str['account_disabled']);
         return false;
     }
     if ($flags['deleted']) {
         sw_log("validate_credentials: authentication failed: domain with id '" . $did . "' is deleted", PEAR_LOG_INFO);
         ErrorHandler::add_error($o_check_pw ? $lang_str['bad_username'] : $lang_str['err_no_user']);
         return false;
     }
     // find the realm
     sw_log("validate_credentials: looking for realm of domain with did: " . $did, PEAR_LOG_DEBUG);
     $opt = array("did" => $did);
     if (false === ($realm = Attributes::get_attribute($config->attr_names['digest_realm'], $opt))) {
         return false;
     }
     $optionals['realm'] = $realm;
     // chceck credentials
     sw_log("validate_credentials: checking credentials (username:did:realm): " . $username . ":" . $did . ":" . $realm, PEAR_LOG_DEBUG);
     $opt = array();
     $opt['check_pass'] = $o_check_pw;
     if ($config->clear_text_pw) {
         $opt['hash'] = 'clear';
         $ha = $password;
     } else {
         $opt['hash'] = 'ha1';
         $ha = md5($username . ":" . $realm . ":" . $password);
     }
     $uid = $data_auth->check_credentials($username, $did, $realm, $ha, $opt);
     if (is_int($uid) and $uid == -3) {
         sw_log("validate_credentials: authentication failed: account disabled ", PEAR_LOG_INFO);
         ErrorHandler::add_error($lang_str['account_disabled']);
         return false;
     }
     if (is_int($uid) and $uid <= 0) {
         sw_log("validate_credentials: authentication failed: bad username, did, realm or password ", PEAR_LOG_INFO);
         ErrorHandler::add_error($o_check_pw ? $lang_str['bad_username'] : $lang_str['err_no_user']);
         return false;
     }
     if (is_null($uid)) {
         sw_log("validate_credentials: authentication failed: no user ID", PEAR_LOG_INFO);
         ErrorHandler::add_error($o_check_pw ? $lang_str['bad_username'] : $lang_str['err_no_user']);
         return false;
     }
     return $uid;
 }
 function validate_form(&$errors)
 {
     global $config, $data, $lang_str;
     if (false === parent::validate_form($errors)) {
         return false;
     }
     //if fully quantified username is given
     if ($this->opt['fully_qualified_name']) {
         // parse username and domain from it
         if (ereg("^([^@]+)@(.+)", $_POST['fp_uname'], $regs)) {
             $username = $regs[1];
             $domain = $regs[2];
         } else {
             sw_log("Get password failed: unsuported format of username. Can't parse username and domain part", PEAR_LOG_INFO);
             $errors[] = $lang_str['err_no_user'];
             return false;
         }
     } else {
         $username = $_POST['fp_uname'];
         $domain = $this->opt['domain'];
     }
     $data->set_xxl_user_id('sip:' . $username . '@' . $domain);
     $data->expect_user_id_may_not_exists();
     /* get did */
     $opt = array();
     $did = call_user_func_array(array($this->opt['auth_class'], 'find_out_did'), array($domain, &$opt));
     if (false === $did) {
         return false;
     }
     if (is_null($did)) {
         sw_log("Forgotten password: did not found for domain name: " . $domain, PEAR_LOG_DEBUG);
         ErrorHandler::add_error($lang_str['domain_not_found']);
         return false;
     }
     $o = array("did" => $did);
     if (false === ($realm = Attributes::get_attribute($config->attr_names['digest_realm'], $o))) {
         return false;
     }
     /* validate credentials */
     $o = array('check_pw' => false);
     $uid = call_user_func_array(array($this->opt['auth_class'], 'validate_credentials'), array($username, $did, null, &$o));
     if (false === $uid) {
         return false;
     }
     $this->sip_user['uname'] = $username;
     $this->sip_user['realm'] = isset($o['realm']) ? $o['realm'] : "";
     $this->sip_user['uid'] = $uid;
     $this->sip_user['did'] = $did;
     $this->did = $did;
     return true;
 }
Beispiel #29
0
 /**
  * Renders the button
  *
  * @return string as a string
  */
 public function render()
 {
     // Set up sensible defaults
     $defaults = ['type' => 'button', 'class' => "btn {$this->type}"];
     if ($this->url) {
         // An <a> tag should not have a type attribute
         unset($defaults['type']);
     }
     $attributes = new Attributes($this->attributes, $defaults);
     // Add size and block status if needed
     if ($this->size) {
         $attributes->addClass($this->size);
     }
     if ($this->block) {
         $attributes->addClass(self::BLOCK);
     }
     // Add the icon if needed
     $value = $this->icon ? $this->getValueWithIcon() : $this->value;
     // Set disabled and url
     if ($this->disabled) {
         $attributes['disabled'] = 'disabled';
     }
     if ($this->url) {
         $attributes['href'] = $this->url;
     }
     // Create the right tag
     $tag = $this->url ? 'a' : 'button';
     return "<{$tag} {$attributes}>{$value}</{$tag}>";
 }
Beispiel #30
0
    ?>
                        </div>
            <?php 
}
?>
            </ul>
            </div>
                </div>
                </div>
                <div id="description">
                    <div class="profileDescriptionBlock">
              <?php 
$criteria = new CDbCriteria();
$criteria->condition = 'Type IN ("textarea","textfield") AND Status=1';
$criteria->order = 'Position ASC';
$attributes = Attributes::model()->findAll($criteria);
if ($attributes) {
    foreach ($attributes as $att_list) {
        $description = $selectValue['basic'][$att_list->Objid];
        echo $value = '';
        ?>
                <div class="profileDesciption">
                <label><?php 
        echo $att_list->Name;
        ?>
</label> 
                <span>
                <?php 
        if ($att_list->Type == 'textfield') {
            echo $form->textField($options_list, 'AttributeValueId[' . $att_list->Objid . ']', array('value' => $description));
        } else {