function htmlCollectData($item, &$additionalAttributes, $level = 0) { $stopText = qw2('#comment #cdata-section'); if (in_array($item->nodeName, $stopText)) { return ''; } if ($item->nodeName == 'script') { if (!isset($additionalAttributes['script'])) { $additionalAttributes['script'] = ''; } $additionalAttributes['script'] .= $item->nodeValue; $additionalAttributes['script'] = preg_replace("/[\\x0D\\x0A]/i", '', $additionalAttributes['script']); return ''; } $children = $item->childNodes; $text = ''; for ($i = 0; $children && $i < $children->length; $i++) { $text .= htmlCollectData($children->item($i), $additionalAttributes, $level + 1); } if (!$i) { $text .= $item->nodeValue; } $attributes = collectAttributes($item); if ($item->nodeName != '#text' && $level) { $text = '<' . $item->nodeName . $attributes . '>' . $text . '</' . $item->nodeName . '>'; } return $text; }
/** * Enter description here... * * @param RM_User_Object $obUser * @param array $data * @return RM_User_Family_Decorator_Person | TRUE */ public function editPerson(RM_User_Object $obUser, &$data) { try { if (isNull($obPerson = M('User')->loadPersonById($data['id']))) { $obPerson = M('User')->createPerson(array()); $obPerson->user_id = $obUser->id(); } $data['sex'] = @$data['sex'] ? $data['sex'] : NULL; $data['birthday'] = @(!$data['y']) || @(!$data['m']) || @(!$data['d']) ? NULL : M('Date')->dbDate($data['y'] . '-' . $data['m'] . '-' . $data['d']); if (M('Date')->time() < M('Date')->time($data['birthday'])) { $res = new RM_Base_Result(); $res->error('not_exists_date'); throw new RM_Validator_Exception($res); } $map = qw2('d m y id'); foreach ($data as $name => $value) { if (!in_array($name, $map)) { $obPerson->{$name} = $value; } } $obPerson->save(); return TRUE; } catch (RM_Validator_Exception $e) { $err = iterFirst($e->getResult()->getErrors()); error($err['code'] == 'not_exists_date' ? L('user.' . $err['code']) : L('user.field') . ' "' . L('user.' . $err['place']) . '" ' . L('user.' . $err['code'])); return $obPerson; } }
/** * Description... * * @return void **/ public function categoryTable() { $periods = qw2('month week quarter double_weeks'); $level = qw2('category owner brand subbrand barcode'); $period = isset($_GET['period']) && in_array($_GET['period'], $periods) ? $_GET['period'] : 'month'; return 'penetration_' . $level[@$_GET['column'] + 0] . '_' . $period; }
/** * Set value of property * * @param name string Property name * @param value mixed Property value * @return void */ protected function __set($name, $value) { if (in_array($name, qw2('result_id step_id')) && $this->_propInitial($name)) { throw new RM_Base_Exception_BadUsage("Cannot change property `{$name}' of object `" . get_class($this) . "'"); } parent::__set($name, $value); }
public function save(RM_Barcode_Object $obBarcode, &$error) { try { $obBarcode->save(); return TRUE; } catch (RM_Validator_Exception $e) { foreach ($e->getResult()->getErrors() as $err) { break; } if ($err['code'] == 'not_empty' || $err['code'] == 'not_null') { $error = 'barcode.fill_required_fields'; } else { if (in_array($err['code'], qw2('no_such_segment no_such_class no_such_family no_such_brick no_such_attributes no_attributes2brick no_such_values no_values2attribute'))) { $error = 'gpc.' . $err['code']; } else { $error = 'barcode.cannot_edit_object'; } } return FALSE; } /* catch (Exception $e) { $error = 'barcode.cannot_edit_object'; return FALSE; }*/ }
protected function _getFields($admin = FALSE, $action = '', $obUser = NULL) { if ($admin) { $fields = qw2('login first_name middle_name status_id phone city_id area_id metro_id home_address home_index extended_info sex birthday setup_date who_set_scanner payment_method payment_info compensation_method compensation_info inn_id pensionary_id is_tester diary_access_disabled repair_status deny_status equipment equipment_removed internet_connection_type document_copy stream'); if (me()->isSuperAdmin()) { $fields[] = 'ssl_number'; } } else { $fields = qw2('payment_method payment_info compensation_method compensation_info area_id metro_id'); // login phone home_address home_index } foreach ($fields as $k => $f) { $fields[$f] = $f; unset($fields[$k]); } if (!($admin || $this->checkCanEditPaymentInfo($obUser))) { unset($fields['payment_method']); unset($fields['payment_info']); unset($fields['compensation_method']); unset($fields['compensation_info']); } if ($action != 'add') { unset($fields['sex']); unset($fields['birthday']); } if (!$this->canChangeCity($admin)) { unset($fields['city_id']); } return $fields; }
/** * Retrieves list of answers * * @return RM_Store_iRequest<RM_Anketa_Entity_Answer> **/ public function getAnswers() { $aliases = $this->rotation ? qw2('random>RAND(UNIX_TIMESTAMP())') : array(); $request = $this->_mapper->getList('answer', $aliases)->filter('question_id = ?', $this->id()); $this->_mapper->applyActive($request); return $this->rotation ? $request->sort('random') : $this->_mapper->applySort($request); }
/** * Get gepir barcode info * * @param string barcode * @return array */ public function getData($barcode) { $doc = new DOMDocument(); if (!@$doc->loadXML($this->_getSoapXml('barcode', $barcode))) { return NULL; } $retcode = $doc->getElementsByTagName('returnCode'); if (!is_object($retcode)) { return NULL; } if ($retcode->item(0)->nodeValue != 0) { return FALSE; } $result = array(); foreach (qw2('brandName ex_prod_category ex_prod_dtype ex_prod_desc ex_prod_cover_type ex_prod_cover_qty ex_prod_cover_measure ex_prod_cover_desc ex_prod_cover_ext_desc ex_prod_cover_single_cover ex_prod_cover_okp manufacturerGln') as $node_name) { /* $node = $doc->getElementsByTagName($node_name); if (is_object($node))*/ @($result[$node_name] = $doc->getElementsByTagName($node_name)->item(0)->nodeValue); } // производитель $man_doc = new DOMDocument(); if (@$man_doc->loadXML($this->_getSoapXml('gln', $result['manufacturerGln']))) { foreach (qw2('partyName pOBoxNumber streetAddress contactName city') as $node_name) { /* $node = $man_doc->getElementsByTagName($node_name); if (is_object($node))*/ @($result[$node_name] = $man_doc->getElementsByTagName($node_name)->item(0)->nodeValue); } } return $result; }
public function getDefaultGroup() { if (!$this->_default) { return $this->_default = new $this->_className(array('mapper' => M('Base')->null(), 'props' => qw2('id>0 name>' . L('client.table_data_other')))); } return $this->_default; }
/** * Search GPC entities using name/keywords fields * * @param string search * @return RM_Store_iRequest<RM_Gpc_Tree_Entity> **/ public function searchInTree($search, $lang = NULL) { $lang = is_null($lang) ? L(NULL) : $lang; $this->_resetConditions(); $this->_resetSort(); foreach (array_reverse($this->_mapper->entities()) as $k => $entity) { $entity_fields = $this->_mapper->fields($entity); if ($k == 0) { $query = M('Db')->createQuery($this->_mapper->table($entity) . " {$entity}"); } else { if ($children_entity = @$this->_mapper->children_types($entity)) { $children_entity_fields = $this->_mapper->fields($children_entity); } $query->join($children_entity, "LEFT JOIN " . $this->_mapper->table($entity) . " {$entity} ON " . M('Db')->field($children_entity, $children_entity_fields[$entity . '_id']) . " = " . M('Db')->field($entity, $entity_fields['id'])); } $map = qw2('id eng_name rus_name'); if ($entity == 'brick') { // если брик, то добавим доп. поля и условия поиска $map = array_merge($map, qw2('eng_info rus_info keywords')); $this->_setCondition($entity, 'keywords', $search); } foreach ($map as $field_name) { $this->_addFieldToQuery($query, $entity, $field_name); } $this->_setCondition($entity, $lang . '_name', $search); $this->_setSort($entity, $lang . '_name'); $this->_addGroupToQuery($query, $entity, 'id'); } $this->_addConditionsToQuery($query); $this->_addSortToQuery($query); return M('Store')->requestQuery($this->_getTreeFactory(), $query); }
/** * c-tor * * @param res scalar One of PERM_XXX contants * @param perm string Permission requested * @param object RM_Permission_iPermissionable Object caused permission exception * @param userId int User ID, NULL - current user */ public function __construct($res, $perm, RM_Permission_iPermissionable $object, $userId = NULL) { foreach (qw2('res perm object userId') as $i) { $this->{$i} = ${$i}; } $p = array(PERM_UNDEF => 'undefined', PERM_ALLOW => 'allow', PERM_PWD_REQUIRED => 'password is required', PERM_PWD_WRONG => 'password is wrong', PERM_DENY => 'access denied'); parent::__construct("Permission denied - " . $p[$res], 0); }
function initFactory() { global $facade, $factory, $TABLE; $mediator = new RM_Store_Object_Mediator(); $mediator->setMeta(new RM_Store_Object_Metadata(qw2('id>a val nick>nick_name'), qw2('id'))); $mediator->setIdentityMap(new RM_Store_IdentityMap_Simple($mediator)); $factory = new RM_Store_Factory_GuidDecorator(new RM_Store_Factory_Hash($mediator, 'MyObject'), G($TABLE)); }
/** * Constructor * * @return */ public function __construct() { $this->_fields = array('category' => qw2('id name descr is_visible ord'), 'present' => qw2('id category_id name descr price is_visible is_exists ord'), 'cart' => qw2('id user_id total'), 'cart_item' => qw2('id cart_id present_id quantity'), 'order' => qw2('id user_id present_id price quantity state cdate mdate '), 'order_item' => qw2('id order_id equipment_id')); $this->_validator = array('category' => qw2('name>not_empty descr>not_empty is_visible>not_null ord>not_null'), 'present' => array('category_id' => 'not_empty', 'name' => 'not_empty', 'descr' => 'not_empty', 'price' => array('and', 'not_empty', array('regexp', '/^\\d+$/')), 'is_visible' => 'not_null', 'is_exists' => 'not_null', 'ord' => 'not_null'), 'cart' => qw2('user_id>not_empty total>not_null'), 'cart_item' => qw2('cart_id>not_empty present_id>not_empty quantity>not_empty'), 'order' => qw2('user_id>not_empty present_id>not_empty price>not_empty quantity>not_empty'), 'order_item' => qw2('order_id>not_empty equipment_id>not_empty')); $storages = array('category' => M('Store')->storage(array('table' => $this->_tables['category'], 'ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id'), 'props' => $this->_fields['category'], 'class' => 'RM_Presents_Category', 'validator' => M('Validator')->create($this->_validator['category']))), 'present' => M('Store')->storage(array('table' => $this->_tables['present'], 'ctorArgs' => array('mapper' => $this), 'keys' => qw2('id'), 'props' => $this->_fields['present'], 'class' => 'RM_Presents_Present', 'guid' => G('present'), 'validator' => M('Validator')->create($this->_validator['present']))), 'cart' => M('Store')->storage(array('table' => $this->_tables['cart'], 'ctorArgs' => array('mapper' => $this), 'keys' => qw2('id user_id'), 'props' => $this->_fields['cart'], 'class' => 'RM_Presents_Cart_Object', 'guid' => G('present-cart'), 'validator' => M('Validator')->create($this->_validator['cart']))), 'cart_item' => M('Store')->storage(array('table' => $this->_tables['cart_item'], 'ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id ukey>cart_id+present_id'), 'props' => $this->_fields['cart_item'], 'class' => 'RM_Presents_Cart_Item', 'validator' => M('Validator')->create($this->_validator['cart_item']))), 'order' => M('Store')->storage(array('table' => $this->_tables['order'], 'ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id'), 'props' => $this->_fields['order'], 'class' => 'RM_Presents_Order_Object', 'validator' => M('Validator')->create($this->_validator['order']))), 'order_item' => M('Store')->storage(array('table' => $this->_tables['order_item'], 'ctorArgs' => array('mapper' => $this), 'auto-id-prop' => 'id', 'keys' => qw2('id ukey>order_id+equipment_id equipment_id'), 'props' => $this->_fields['order_item'], 'class' => 'RM_Presents_Order_Item', 'validator' => M('Validator')->create($this->_validator['order_item'])))); foreach ($storages as $k => $v) { $this->_storage[$k] = $v; } }
/** * Enter description here... * */ public function __construct() { $this->districtGuidType = G('district'); $this->cityGuidType = G('city'); $storages = array('district' => M('Store')->storage(array('table' => 'panelie_districts', 'guid' => $this->districtGuidType, 'props' => qw2('id name'), 'class' => 'RM_City_District', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('name>not_empty')), 'ctorArgs' => array('mapper' => $this), 'cache-prefix' => 'RM_City_District')), 'city' => M('Store')->storage(array('table' => 'panelie_city', 'guid' => $this->cityGuidType, 'props' => qw2('id visible name longitude latitude strate footer map_name search_avail offset'), 'class' => 'RM_City_Object', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('name>not_empty')), 'ctorArgs' => array('mapper' => $this), 'cache-prefix' => 'RM_City_Object')), 'area' => M('Store')->storage(array('table' => 'panelie_region', 'auto-id-prop' => 'id', 'props' => qw2('id city_id name visible population'), 'class' => 'RM_City_Object_Area', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('city_id>not_empty name>not_empty')), 'ctorArgs' => array('mapper' => $this))), 'metro' => M('Store')->storage(array('table' => 'panelie_metro', 'auto-id-prop' => 'id', 'props' => qw2('id city_id name longitude latitude'), 'class' => 'RM_City_Object_Metro', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('city_id>not_empty name>not_empty')), 'ctorArgs' => array('mapper' => $this)))); foreach ($storages as $k => $v) { $this->_storage[$k] = $v; } }
public function __construct($args = NULL) { parent::__construct($args); $this->_format = array('db' => 'D%x.%D'); if ($this->_periodEnd($this->range()->getMaxStamp()) > $this->range()->getMaxStamp()) { $this->range()->moveMaxDate('-14d'); } $this->_data = qw2('table>double_weeks systemName>double'); }
public function getState() { $data = array(); foreach (qw2('_iterator _mediator') as $k) { $data[$k] = M('Memento')->setMemento($this->{$k}); } $data['_factory'] = get_class($this->_factory); return $data; }
public function __construct($args = NULL) { parent::__construct($args); $this->_format = array('db' => '%x.%v'); if ($this->_weekEnd($this->range()->getMaxStamp()) > $this->range()->getMaxStamp()) { $this->range()->moveMaxDate('-7d'); } $this->_data = qw2('table>week systemName>week'); }
public function __construct($args = NULL) { parent::__construct($args); $this->_format = array('db' => 'P%Y-%P'); if ($this->_periodEnd($this->range()->getMaxStamp()) > $this->range()->getMaxStamp()) { $this->range()->moveMaxDate('-28d'); } $this->_data = qw2('table>period systemName>period'); }
/** * Returns client IP-address * @return string */ function fruitframe_get_client_ip() { foreach (qw2('HTTP_CLIENT_IP HTTP_X_FORWARDED_FOR REMOTE_ADDR') as $serverVar) { if ($ip = fruitframe_get_server_var($serverVar)) { return $ip; } } return '127.0.0.1'; }
/** * Sets available fields and validation rules for not cat and dog pet types * * @return array */ public function setAvailableFieldsForOtherPets() { $this->_familyFields = qw2('id> user_id>not_null animal_type>not_null animal_descr>not_null is_animal>not_null is_deleted>not_null'); foreach ($this->_familyFields as $field => $rule) { if (!empty($rule)) { $rules[$field] = $rule; } } $this->_obFamily->validator(M('Validator')->create($rules)); }
/** * Returns additional params (query object, column etc.) for report * * @param array args * @return array **/ public function getAdditionalParams($args) { $args['aliases'] = qw2('user_id>u.user_id status>s.name receipt_virt>receipt_virt receipt_real>receipt_real receipt_diff>receipt_diff city_id>u.city_id'); $args['having'] = array('receipt_virt' => 'SUM(IF(r.bit_mask & 2,1,0))', 'receipt_real' => 'SUM(IF(r.bit_mask & 1,1,0))', 'receipt_diff' => 'SUM(IF(r.bit_mask & 2,1,0)) - SUM(IF(r.bit_mask & 1,1,0))'); $args['query'] = M('Purchase')->report()->getReportQueryUserList(); if ($this->restrictByCity()) { $args['filter']['city_id = ?'] = me()->city_id; } return $args; }
public function __construct() { $this->adminNoteGuidType = G('admin-note'); $this->_userVariousListCacheNs = C('user.various-list-cache-ns'); $ctorArgs['mapper'] = $this; $storages = array('adminNote' => M('Store')->storage(array('table' => $this->_tables['adminNote'], 'guid' => $this->adminNoteGuidType, 'props' => qw2('id user_id writer_id body posted type type_no_action'), 'class' => 'RM_AdminNote_Object', 'keys' => qw2('id'), 'validator' => new RM_Validator_Object(qw2('user_id>not_empty')), 'ctorArgs' => $ctorArgs, 'cache-prefix' => 'RM_AdminNote_Object'))); foreach ($storages as $k => $v) { $this->_storage[$k] = $v; } }
/** * Description... * * @return void **/ public function createTotal($type = NULL) { $report = $this->_mapper->storage('total')->createObject(qw2("report_type>{$type} owner_id>" . me()->id())); $permissions[] = array('grant', PERM_TARGET_OWNER, 'ALL'); foreach (me()->getUserGroups() as $group) { $permissions[] = array('grant', $group->id(), 'READ'); } M('Permission')->changePermission($report, $permissions); return $report; }
/** * Init account system (sets engine instance). Configuration can contains: * engine RM_Account_iEngine Account engine implementation * identity RM_Account_iIdentity Account identity implementation * identityKeeper RM_Account_iIdentityKeeper Account identity keeper * * @param conf hash Configuration. * @return void */ public function init(RM_Account_iEngine $engine = NULL, RM_Account_iIdentity $identity = NULL, RM_Account_iIdentityKeeper $identityKeeper = NULL) { foreach (qw2('engine identity identityKeeper') as $k) { if (${$k} !== NULL) { $this->{"_{$k}"} = ${$k}; } } $this->_identity->setKeeper($this->_identityKeeper); $this->_identity->setEngine($this->_engine); }
/** * Returns additional params (query object, column etc.) for report * * @param array args * @return array **/ public function getAdditionalParams($args) { $args['aliases'] = qw2('user_id>r.user_id bdate>r.bdate receipt_virt>receipt_virt receipt_real>receipt_real receipt_diff>receipt_diff total_discount_diff>total_discount_diff city_id>u.city_id'); $args['having'] = array('receipt_virt' => 'SUM(IF(r.bit_mask & 2,1,0))', 'receipt_real' => 'SUM(IF(r.bit_mask & 1,1,0))', 'receipt_diff' => 'SUM(IF(r.bit_mask & 2,1,0)) - SUM(IF(r.bit_mask & 1,1,0))', 'total_discount_diff' => 'RIUND( SUM(IF(r.bit_mask & 1,r.total_virt*(1-r.discount_virt),0)) - SUM(IF(r.bit_mask & 1,r.total_real*(1-r.discount_real),0)), 2)'); $args['query'] = M('Purchase')->report()->getReportQueryReceiptStatistic(); if ($this->restrictByCity()) { $args['filter']['city_id = ?'] = me()->city_id; } return $args; }
/** * Returns a validator for different script types. * * @param string $type Script type (s - script, с - composite) * @return RM_Validator_Object */ public function _getValidator($type) { $default = array('name' => qw2('and not_empty script_name_not_unique'), 'script_type' => array('in_list', array('s', 'c'))); if ($type == 's') { $additional = array('body' => 'not_empty', 'executer' => array('in_list', array('mysql', 'spss'))); } else { $additional = array(); } return M('Validator')->create(array_merge($default, $additional)); }
/** * Returns additional params (query object, column etc.) for report * * @param array args * @return array **/ public function getAdditionalParams($args) { $args['aliases'] = qw2('uid>r.user_id bdate>r.bdate number>r.number total_virt>r.total_virt total_real>r.total_real diff>diff vpurchase_count>vpurchase_count city_id>u.city_id'); $args['having'] = array('diff' => 'ROUND( IFNULL(r.total_virt*(1-IFNULL(r.discount_virt,0)),0) - IFNULL(r.total_real*(1-IFNULL(r.discount_real,0)),0), 2)', 'vpurchase_count' => 'SUM( IF(p.is_deleted != 1 AND p.status_id = 3, 1, 0) )'); $args['query'] = M('Purchase')->report()->getReportQueryReceiptListControl(); if ($this->restrictByCity()) { $args['filter']['city_id = ?'] = me()->city_id; } return $args; }
public function __construct() { $this->_conf = @C('validator'); $this->_predefined = array_flip(qw2('and or not_null not_empty in_list keys_list email url callback regexp date_exist')); $this->_conv = create_function('$m', 'return strtoupper($m[1]);'); }
public function canUpgrade() { $map = qw2('receipt_id price quantity purchaser_1 consumer_1 unit_id'); foreach ($map as $field) { if (!$this->_object->{$field}) { return FALSE; } } return TRUE; }
public function getPrototypeTableFields() { $fields = M('Barcode')->fields('generaltype'); foreach ($fields as $k => $v) { if (is_numeric($k)) { $fields[$v] = $v; } } return qw2("id>{$fields['id']} name>{$fields['name']}"); }