Exemple #1
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
     if ($this->application->user->type < 100) {
         echo 'Недостаточно прав доступа';
         exit;
     }
     $this->referenceNames = $this->application->cgi->getGPC('referenceName', array());
 }
Exemple #2
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
     $this->type = BM_RP_TYPE_JSON;
 }
Exemple #3
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
 }
Exemple #4
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
     if ($this->application->user->type < 100) {
         echo 'Недостаточно прав доступа';
         exit;
     }
     // Собираем все данные из хтмл-формы в единый массив объектов
     $allFieldsArray = array('identifier', 'propertyName', 'fieldName', 'referencedObjectId', 'referencedObjectType', 'oldReferencedObjectType', 'dataType', 'defaultValue', 'localName', 'oldFieldName', 'oldDataType', 'oldDefaultValue');
     foreach ($allFieldsArray as $field) {
         $name = $field . 'Array';
         ${$name} = $this->application->cgi->getGPC($field, array());
     }
     $droppedFieldIds = $this->application->cgi->getGPC('droppedFieldIds', array());
     $countArrayName = $allFieldsArray[0] . 'Array';
     $count = count(${$countArrayName});
     for ($i = 0; $i < $count; ++$i) {
         $item = new stdClass();
         foreach ($allFieldsArray as $field) {
             $fieldArrayName = $field . 'Array';
             $fieldArray = ${$fieldArrayName};
             $item->{$field} = $fieldArray[$i];
         }
         $this->dataFields[$i] = $item;
     }
     // Собрали данные в массив, теперь идем по каждому элементу массиву
     $count = count($this->dataFields);
     for ($i = 0; $i < $count; ++$i) {
         $currentItem =& $this->dataFields[$i];
         // проверяем правильность введенных данных
         if ($currentItem->propertyName == '' || $currentItem->fieldName == '' || $currentItem->dataType == 0) {
             unset($this->dataFields[$i]);
         } else {
             $stringPattern = '/^[a-zA-Z][a-zA-Z0-9]+$/';
             $localNamePattern = '/[\'\\"<>]/';
             if (!preg_match($stringPattern, $currentItem->propertyName)) {
                 echo 'Ошибка: имя свойства может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
                 exit;
             }
             if (!preg_match($stringPattern, $currentItem->fieldName)) {
                 echo 'Ошибка: имя поля может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
                 exit;
             }
             if (preg_match($localNamePattern, $currentItem->localName)) {
                 echo 'Ошибка: в названии для пользователя содержатся недопустимые символы';
                 exit;
             }
             if ($currentItem->dataType == BM_VT_OBJECT && $currentItem->referencedObjectId == 0) {
                 echo 'Ошибка: не указан связанный объект';
                 exit;
             }
             if ($currentItem->dataType == BM_VT_INTEGER || $currentItem->dataType == BM_VT_DATETIME) {
                 $currentItem->defaultValue = intval($currentItem->defaultValue);
             }
             if ($currentItem->dataType == BM_VT_FLOAT) {
                 $currentItem->defaultValue = floatval($currentItem->defaultValue);
             }
         }
         // Проверили, теперь смотрим, что и с каким объектом делать
         $currentItem->actions = array();
         if (in_array($currentItem->identifier, $droppedFieldIds)) {
             $currentItem->actions[] = 'delete';
         } elseif ($currentItem->identifier == 0) {
             $currentItem->actions[] = 'add';
         } elseif ($currentItem->oldFieldName != $currentItem->fieldName || $currentItem->oldDefaultValue != $currentItem->defaultValue) {
             $currentItem->actions[] = 'change';
         } elseif ($currentItem->oldDataType != $currentItem->dataType) {
             $currentItem->actions[] = 'changeType';
         }
     }
     $this->dataFields = array_values($this->dataFields);
     // Сбрасываем индекс массива
     // Проверяем на дубли
     //   и на два главных или два зависимых объекта
     $count = count($this->dataFields);
     $referencedObjectTypesCount = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
     for ($i = 0; $i < $count; ++$i) {
         for ($j = 0; $j < $count; ++$j) {
             if ($i != $j) {
                 if ($this->dataFields[$i]->propertyName == $this->dataFields[$j]->propertyName || $this->dataFields[$i]->fieldName == $this->dataFields[$j]->fieldName) {
                     echo 'Ошибка: не должно быть дублей имен свойств и полей.';
                     exit;
                 }
             }
         }
         ++$referencedObjectTypesCount[$this->dataFields[$i]->referencedObjectType];
     }
     if ($referencedObjectTypesCount[BM_RT_MAIN] > 1 || $referencedObjectTypesCount[BM_RT_REFERRED] > 1) {
         echo 'Ошибка: в связи не может быть двух главных или двух зависимых объектов';
         exit;
     }
 }
Exemple #5
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
     if ($this->application->user->type < 100) {
         echo 'Недостаточно прав доступа';
         exit;
     }
     $propertyNameArray = $this->application->cgi->getGPC('propertyName', array());
     $droppedFieldIds = $this->application->cgi->getGPC('droppedFieldIds', array());
     if (count($propertyNameArray) > 0) {
         foreach ($propertyNameArray as $key => $value) {
             $this->dataFields[$key] = new stdClass();
             $value = $this->application->validateValue($value, BM_VT_STRING);
             $this->dataFields[$key]->propertyName = $value;
         }
         $this->setValues('dataFields', 'identifier', BM_VT_INTEGER, 0);
         $this->setValues('dataFields', 'oldFieldName', BM_VT_STRING, '');
         $this->setValues('dataFields', 'oldDataType', BM_VT_INTEGER, 0);
         $this->setValues('dataFields', 'oldDefaultValue', BM_VT_STRING, '');
         $this->setValues('dataFields', 'fieldName', BM_VT_STRING, '');
         $this->setValues('dataFields', 'dataType', BM_VT_INTEGER, 0);
         $this->setValues('dataFields', 'defaultValue', BM_VT_STRING, '');
         $this->setValues('dataFields', 'localName', BM_VT_STRING, '');
     }
     $i = 0;
     $counter = 0;
     $count = count($this->dataFields);
     for ($i = 0; $i < $count; ++$i) {
         $currentItem =& $this->dataFields[$i];
         if ($currentItem->propertyName == '' || $currentItem->fieldName == '' || $currentItem->dataType == 0) {
             unset($this->dataFields[$i]);
         } else {
             $stringPattern = '/^[a-zA-Z]+[a-zA-Z0-9]*$/';
             $localNamePattern = '/[\'\\"<>]/';
             if (!preg_match($stringPattern, $currentItem->propertyName)) {
                 echo 'Ошибка: имя свойства может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
                 exit;
             }
             if (!preg_match($stringPattern, $currentItem->fieldName)) {
                 echo 'Ошибка: имя поля может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
                 exit;
             }
             if (preg_match($localNamePattern, $currentItem->localName)) {
                 echo 'Ошибка: в названии для пользователя содержатся недопустимые символы';
                 exit;
             }
             if ($currentItem->dataType == BM_VT_INTEGER || $currentItem->dataType == BM_VT_DATETIME) {
                 $currentItem->defaultValue = intval($currentItem->defaultValue);
             }
             if ($currentItem->dataType == BM_VT_FLOAT) {
                 $currentItem->defaultValue = floatval($currentItem->defaultValue);
             }
             $currentItem->action = 'none';
             if (in_array($currentItem->identifier, $droppedFieldIds)) {
                 $currentItem->action = 'delete';
             } elseif ($currentItem->identifier == 0) {
                 $currentItem->action = 'add';
             } elseif ($currentItem->oldFieldName != $currentItem->fieldName || $currentItem->oldDataType != $currentItem->dataType || $currentItem->oldDefaultValue != $currentItem->defaultValue) {
                 $currentItem->action = 'change';
             }
         }
     }
     $count = count($this->dataFields);
     for ($i = 0; $i < $count; ++$i) {
         for ($j = 0; $j < $count; ++$j) {
             if ($i != $j) {
                 if ($this->dataFields[$i]->propertyName == $this->dataFields[$j]->propertyName || $this->dataFields[$i]->fieldName == $this->dataFields[$j]->fieldName) {
                     echo 'Ошибка: не должно быть дублей имен свойств и полей.';
                     exit;
                 }
             }
         }
     }
 }