/** * ÐбвеÑÑка Ð´Ð»Ñ ÑÑнкÑии _query * * @param string $queryText поиÑковÑй запÑÐ¾Ñ (в оÑигиналÑном виде) * @param integer $store ÐÐ ÑекÑÑего магазина * @param object $index Ð¸Ð½Ð´ÐµÐºÑ Ð¿Ð¾ коÑоÑÐ¾Ð¼Ñ Ð½Ñжно пÑовеÑÑи поиÑк * * @return array маÑив ÐРелеменÑов, где ÐÐ - клÑÑ, ÑелеванÑноÑÑÑ Ð·Ð½Ð°Ñение */ public function query($queryText, $store, $index) { $indexCode = $index->getCode(); $primaryKey = $index->getPrimaryKey(); $attributes = $index->getAttributes(); if ($store) { $store = array($store); } return $this->_query($queryText, $store, $indexCode, $primaryKey, $attributes); }
/** * Get an array of object properties. * * @param object $value * @param \ReflectionClass $class * @param int $propertyFilter One of \ReflectionProperty constants * * @return array */ protected function getProperties($value, \ReflectionClass $class, $propertyFilter) { $props = array(); $props['type'] = $value->getType(); $props['attributes'] = $value->getAttributes(); foreach ($value->getSubNodeNames() as $name) { $props[$name] = $value->{$name}; } return $props; }
/** * @param object $group * @param null $format * @param array $context * @return array|\Symfony\Component\Serializer\Normalizer\scalar */ public function normalize($group, $format = null, array $context = []) { /**@var Group $group * */ $normalizedGroup = ['code' => $group->getCode(), 'type' => $group->getType()->getCode()]; foreach ($group->getTranslations() as $trans) { $normalizedGroup['labels'][$trans->getLocale()] = $trans->getLabel(); } foreach ($group->getAttributes() as $attr) { $normalizedGroup['attributes'][] = $attr->getCode(); } return $normalizedGroup; }
/** * Finalize the authorization process. * * @throws AuthorizationDeniedException * @throws UnexpectedValueException */ public function authenticateFinish() { if ($this->openIdClient->mode == 'cancel') { throw new AuthorizationDeniedException('User has cancelled the authentication.'); } if (!$this->openIdClient->validate()) { throw new UnexpectedValueException('Invalid response received.'); } $openidAttributes = $this->openIdClient->getAttributes(); if (!$this->openIdClient->identity) { throw new UnexpectedValueException('Provider returned an expected response.'); } $userProfile = $this->fetchUserProfile($openidAttributes); /* with openid providers we only get user profiles once, so we store it */ $this->storage->set($this->providerId . '.user', $userProfile); }
/** * Authenticate * * @param string Username * @param string Password * @return bool true on success, false on reject */ function fetchData($username, $password, $challenge = null) { $this->log('Auth_Container_RADIUS::fetchData() called.', AUTH_LOG_DEBUG); switch ($this->authtype) { case 'CHAP_MD5': case 'MSCHAPv1': if (isset($challenge)) { $this->radius->challenge = $challenge; $this->radius->chapid = 1; $this->radius->response = pack('H*', $password); } else { require_once 'Crypt/CHAP.php'; $classname = 'Crypt_' . $this->authtype; $crpt = new $classname(); $crpt->password = $password; $this->radius->challenge = $crpt->challenge; $this->radius->chapid = $crpt->chapid; $this->radius->response = $crpt->challengeResponse(); } break; case 'MSCHAPv2': require_once 'Crypt/CHAP.php'; $crpt = new Crypt_MSCHAPv2(); $crpt->username = $username; $crpt->password = $password; $this->radius->challenge = $crpt->authChallenge; $this->radius->peerChallenge = $crpt->peerChallenge; $this->radius->chapid = $crpt->chapid; $this->radius->response = $crpt->challengeResponse(); break; default: $this->radius->password = $password; break; } $this->radius->username = $username; $this->radius->putAuthAttributes(); $result = $this->radius->send(); if (PEAR::isError($result)) { return false; } $this->radius->getAttributes(); // just for debugging // $this->radius->dumpAttributes(); return $result; }
/** * Get an array of Model object properties. * * @param object $value * @param \ReflectionClass $class * @param int $propertyFilter * @return array */ public function getProperties($value, ReflectionClass $class, $propertyFilter) { $attributes = array_merge($value->getAttributes(), $value->getRelations()); $visible = $value->getVisible(); if (count($visible) === 0) { $visible = array_diff(array_keys($attributes), $value->getHidden()); } if (!$this->showHidden($propertyFilter)) { return array_intersect_key($attributes, array_flip($visible)); } $properties = []; foreach ($attributes as $key => $value) { if (!in_array($key, $visible)) { $key = sprintf('<protected>%s</protected>', $key); } $properties[$key] = $value; } return $properties; }
/** * @param object $family * @param null $format * @param array $context * @return array|\Symfony\Component\Serializer\Normalizer\scalar * @throws Exception\NormalizeException */ public function normalize($family, $format = null, array $context = []) { /**@var Family $family * */ $normalizedFamily = ['code' => $family->getCode(), 'labels' => [], 'attribute_groups' => []]; foreach ($family->getTranslations() as $trans) { $normalizedFamily['labels'][$trans->getLocale()] = $trans->getLabel(); } $associations = $this->associationTypeRepository->findAll(); $normalizedFamily['associations'] = array(); foreach ($associations as $association) { $normalizedFamily['associations'][$association->getCode()] = array(); foreach ($association->getTranslations() as $assocTrans) { $normalizedFamily['associations'][$association->getCode()]['labels'][$assocTrans->getLocale()] = $assocTrans->getLabel(); } } foreach ($family->getAttributes() as $attr) { $normalizedFamily['attribute_groups'][$attr->getGroup()->getCode()]['code'] = $attr->getGroup()->getCode(); foreach ($attr->getGroup()->getTranslations() as $groupTrans) { $normalizedFamily['attribute_groups'][$attr->getGroup()->getCode()]['labels'][$groupTrans->getLocale()] = $groupTrans->getLabel(); } $normalizedFamily['attribute_groups'][$attr->getGroup()->getCode()]['attributes'][$attr->getCode()] = $this->attributeNormalizer->normalize($attr, null, $context); } return $normalizedFamily; }
/** * Возвращает объедененый масив атрибутов и колонок в таблице текущего индекса. * * @param object $index объект индекса * * @return array */ protected function _getAttributes($index) { $uid = Mage::helper('mstcore/debug')->start(); $attributes = $index->getAttributes(true); $columns = $this->_getTableColumns($index->getIndexer()->getTableName()); foreach ($attributes as $attr => $weight) { if (!in_array($attr, $columns)) { unset($attributes[$attr]); } } foreach ($columns as $column) { if (!in_array($column, array($index->getIndexer()->getPrimaryKey(), 'store_id', 'updated')) && !isset($attributes[$column])) { $attributes[$column] = 0; } } Mage::helper('mstcore/debug')->end($uid, array('$attributes' => $attributes, '$index' => $index)); return $attributes; }
/** * Executes the INSERT intermediate representation producing a \Phalcon\Mvc\Model\Query\Status * * @param array $intermediate * @param array $bindParams * @param array $bindTypes * @return \Phalcon\Mvc\Model\Query\StatusInterface * @throws Exception */ protected function _executeInsert(array $intermediate, array $bindParams, array $bindTypes) { $manager = $this->_manager; $modelName = $intermediate['model']; $modelsInstances = $this->_modelsInstances; if (isset($modelsInstances[$modelName]) === true) { $model = $modelsInstances[$modelName]; } else { $model = $manager->load($modelName); } //Get the model connection $connection = $model->getWriteConnection(); $automaticFields = false; //The 'fields' index may already have the fields to be used in the query if (isset($intermediate['fields']) === true) { $fields = $intermediate['fields']; } else { $automaticFields = true; $fields = $this->_metaData->getAttributes($model); if (isset($GLOBALS['_PHALCON_ORM_COLUMN_RENAMING']) === true && $GLOBALS['_PHALCON_ORM_COLUMN_RENAMING'] === true) { $columnMap = $this->_metaData->getColumnMap($model); } else { $columnMap = null; } } //The number of calculated values must be equal to the number of fields in the //model if (count($fields) !== count($intermediate['values'])) { throw new Exception('The column count does not match the values count'); } //Get the dialect to resolve the SQL expressions $dialect = $connection->getDialect(); $notExists = false; $insertValues = array(); foreach ($intermediate['values'] as $number => $value) { switch ((int) $value['type']) { case 260: case 258: case 259: $insertValue = $dialect->getSqlExpression($value['value']); break; case 332: $insertValue = null; break; case 273: case 274: if (is_array($bindParams) === false) { throw new Exception('Bound parameter cannot be replaced because placeholders is not an array'); } $wildcard = str_replace(':', '', $dialect->getSqlExpression($value['value'])); if (isset($bindParams[$wildcard]) === false) { throw new Exception("Bound parameter '" . $wildcard . "' cannot be replaced because it isn't in the placeholder list"); } $insertValue = $bindParams[$wildcard]; break; default: $insertValue = new RawValue($dialect->getSqlExpression($value['value'])); break; } $fieldName = $fields[$number]; //If the user didn't defined a column list we assume all the model's attributes are columns if ($automaticFields === true) { if (is_array($columnMap) === true) { if (isset($columnMap[$fieldName]) === true) { $attributeName = $columnMap[$fieldName]; } else { throw new Exception("Column '" . $fieldName . "\" isn't part of the column map"); } } else { $attributeName = $fieldName; } } else { $attributeName = $fieldName; } $insertValues[$attributeName] = $insertValue; } //Get a base model from the models manager $baseModel = $manager->load($modelName); //Clone the base model $insertModel = clone $baseModel; //Call 'create' to ensure that an insert is performed //Return the insertation status return new Status($insertModel->create($insertValues), $insertModel); }
/** * Get all attributes for the model. * * @param object $entity * @return array */ public function getAttributes($entity) { return $entity->getAttributes(); }
/** * Returns the attribute codes for an object * * @param object $object * * @return array */ protected function getAttributeCodes($object) { return array_map(function ($attribute) { return $attribute->getCode(); }, $object->getAttributes()->toArray()); }
/** * set_form_id * * @param object $mform * @param string $id * @return mixed default value of setting */ protected function set_form_id($mform, $id) { $attributes = $mform->getAttributes(); $attributes['id'] = $id; $mform->setAttributes($attributes); }
/** * @access public * @param object $xmldata xmldata */ function setChild($xmldata) { $name = $xmldata->getName(); $contentkey = $this->options["contentkey"]; if (isset($this->child[$name])) { if (empty($this->child[$name][0]) || $this->child[$name][0] && !is_array($this->child[$name])) { $temp = $this->child[$name]; $this->child[$name] = array(); $this->child[$name][0] = $temp; } $index = count($this->child[$name]); if (empty($this->child[$name][$index])) { $this->child[$name][$index] = array(); } if ($attributes = $xmldata->getAttributes()) { $this->child[$name][$index] = array_merge($this->child[$name][$index], $attributes); } if ($child = $xmldata->getChild()) { $this->child[$name][$index] = array_merge($this->child[$name][$index], $child); } if ($cdata = $xmldata->getCData()) { if (empty($this->child[$name][$index]) && empty($this->options["forcecontent"])) { $this->child[$name][$index] = $cdata; } else { if (@$this->child[$name][$index][$contentkey]) { $temp = $this->child[$name][$index][$contentkey]; $this->child[$name][$index][$contentkey] = array(); $this->child[$name][$index][$contentkey][0] = $temp; $this->child[$name][$index][$contentkey][1] = $cdata; } else { $this->child[$name][$index][$contentkey] = $cdata; } } } } else { $this->child[$name] = ""; if ($attributes = $xmldata->getAttributes()) { $this->child[$name] = $this->child[$name] ? array_merge($this->child[$name], $attributes) : $attributes; } if ($child = $xmldata->getChild()) { $this->child[$name] = $this->child[$name] ? array_merge($this->child[$name], $child) : $child; } if ($cdata = $xmldata->getCData()) { if (empty($this->child[$name]) && empty($this->options["forcecontent"])) { $this->child[$name] = $cdata; } else { if (@$this->child[$name][$contentkey]) { $temp = $this->child[$name][$contentkey]; $this->child[$name][$contentkey] = array(); $this->child[$name][$contentkey][0] = $temp; $this->child[$name][$contentkey][1] = $cdata; } else { $this->child[$name][$contentkey] = $cdata; } } } } }