Example #1
0
 public function execute()
 {
     $this->type = BM_RP_TYPE_JSON;
     $queryType = $this->application->cgi->getGPC('queryType', '', BM_VT_STRING);
     switch ($queryType) {
         case 'initialize':
             $user = $this->application->user;
             $this->output = $this->initialize($user);
             break;
         case 'login':
             $email = $this->application->cgi->getGPC('email', '', BM_VT_STRING);
             $password = $this->application->cgi->getGPC('password', '', BM_VT_STRING);
             $this->output = $this->login($email, $password);
             break;
         case 'register':
             $email = $this->application->cgi->getGPC('email', '', BM_VT_STRING);
             $password = $this->application->cgi->getGPC('password', '', BM_VT_STRING);
             $this->output = $this->register($email, $password);
             break;
         default:
             $this->output = new stdClass();
             $this->output->answer = 'error';
             $this->outpit->errorMessage = 'wrongQueryType';
             break;
     }
     return parent::execute();
 }
Example #2
0
 public function execute()
 {
     if ($this->application->user->type < 100) {
         echo 'Недостаточно прав доступа';
         exit;
     }
     if ($this->referenceMapId != 0) {
         $referenceMap = new bmReferenceMap($this->application, array('identifier' => $this->referenceMapId));
         $referenceMap->delete();
     }
     unset($referenceMap);
     parent::execute();
 }
Example #3
0
 public function execute()
 {
     $sql = "SHOW TABLES";
     $qTables = $this->application->dataLink->select($sql);
     while ($table = $qTables->nextRow()) {
         $dataObjectName = $table[0];
         if (!$this->testException($dataObjectName)) {
             $identifier = $this->getObjectIdByField('dataObjectMap', 'name', $dataObjectName);
             $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $identifier));
             if ($identifier == 0) {
                 $dataObjectMap->name = $dataObjectName;
                 $dataObjectMap->generateFields();
             }
             $dataObjectMap->generateFiles(C_ADMIN_ANCESTOR_PAGE);
             unset($dataObjectField);
         }
         parent::execute();
     }
 }
Example #4
0
 public function execute()
 {
     foreach ($this->referenceNames as $referenceMapId => $referenceName) {
         if ($referenceMapId != 0 || $referenceName != '') {
             $referenceName = trim($referenceName);
             $pattern = '/^[a-zA-Z][a-zA-Z0-9_]+$/';
             if (preg_match($pattern, $referenceName)) {
                 $referenceMap = new bmReferenceMap($this->application, array('identifier' => $referenceMapId));
                 $referenceMap->beginUpdate();
                 if ($referenceMap->type != 1) {
                     $referenceMap->name = $referenceName;
                 }
                 $referenceMap->endUpdate();
                 $referenceMap->save();
                 // $referenceMap->generateFiles(C_ADMIN_ANCESTOR_PAGE);
                 unset($referenceMap);
             } else {
                 echo 'Ошибка: имя связи может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
             }
         }
     }
     parent::execute();
 }
Example #5
0
 public function __construct($application, $parameters = array())
 {
     parent::__construct($application, $parameters);
     $this->type = BM_RP_TYPE_JSON;
 }
Example #6
0
 public function execute()
 {
     $dataLink = $this->application->dataLink;
     if ($this->referenceId != 0) {
         $referenceMap = new bmReferenceMap($this->application, array('identifier' => $this->referenceId));
         foreach ($this->dataFields as &$item) {
             if (!in_array('delete', $item->actions)) {
                 $inflectionNames = array('nominative', 'genitive', 'dative', 'accusive', 'creative', 'prepositional');
                 if ($item->localName != '') {
                     $inflections = file_get_contents('http://export.yandex.ru/inflect.xml?name=' . urlencode($item->localName));
                     $xml = simplexml_load_string($inflections);
                     $inflections = array();
                     if (count($xml->inflection) == 6) {
                         $i = 0;
                         foreach ($xml->inflection as $inflection) {
                             $inflections[$inflectionNames[$i]] = (string) $inflection;
                             $i++;
                         }
                     } else {
                         foreach ($inflectionNames as $i => $inflection) {
                             $inflections[$inflectionNames[$i]] = (string) $xml->inflection;
                         }
                     }
                 } else {
                     $inflections = array();
                     foreach ($inflectionNames as $i => $inflection) {
                         $inflections[$inflectionNames[$i]] = $item->propertyName;
                     }
                 }
                 $item->localName = serialize($inflections);
                 if ($item->dataType == BM_VT_DATETIME) {
                     if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}$/', $item->defaultValue)) {
                         $item->defaultValue = '0000-01-01 00:00:00';
                     }
                 }
                 $referenceField = new bmReferenceField($this->application, array('identifier' => $item->identifier));
                 $referenceField->propertyName = $item->propertyName;
                 $referenceField->fieldName = $item->fieldName;
                 $referenceField->dataType = $item->dataType;
                 $referenceField->defaultValue = $item->defaultValue;
                 $referenceField->localName = $item->localName;
                 if ($item->referencedObjectId != 0) {
                     $referenceField->setReferencedObject($item->referencedObjectId);
                 }
                 $referenceField->store();
                 $item->identifier = $referenceField->identifier;
             }
             $referenceMap->beginUpdate();
             foreach ($item->actions as $action) {
                 switch ($action) {
                     case 'add':
                         $referenceMap->addField($item->identifier, $item->referencedObjectType);
                         break;
                     case 'delete':
                         $referenceMap->removeField($item->identifier);
                         break;
                     case 'change':
                         $referenceMap->renameField($item->identifier, $item->oldFieldName);
                         break;
                     case 'changeType':
                         $referenceMap->changeFieldType($item->identifier, $item->referencedObjectType);
                         break;
                 }
             }
             $referenceMap->endUpdate();
         }
     }
     $referenceMap->save();
     // $referenceMap->generateFiles(C_ADMIN_ANCESTOR_PAGE);
     // unset($referenceMap);
     parent::execute();
 }
Example #7
0
 public function execute()
 {
     $this->type = BM_RP_TYPE_JSON;
     if ($this->application->user->identifer != C_DEFAULT_USER_ID) {
         if (array_key_exists('Filedata', $_FILES)) {
             $type = $this->application->cgi->getGPC('type', 'files');
             $objectName = trim($this->application->cgi->getGPC('objectName', ''));
             $propertyName = trim($this->application->cgi->getGPC('propertyName', ''));
             $fileData = $_FILES['Filedata'];
             if ($fileData['error'] == 0) {
                 $md5 = md5($objectName . $propertyName . md5_file($fileData['tmp_name']));
                 $fileId = $this->application->getObjectIdByFieldName('photo', 'md5', $md5);
                 $file = new bmPhoto($this->application, array('identifier' => $fileId));
                 if ($fileId > 0) {
                     $fileName = $file->fileName;
                 } else {
                     $fileName = md5(uniqid('', true));
                     $originalsDirectoryName = documentRoot . '/' . $type . '/' . $objectName . '/' . $propertyName . '/originals/' . mb_substr($fileName, 0, 2) . '/';
                     if (!file_exists($originalsDirectoryName)) {
                         mkdir($originalsDirectoryName, 0777, true);
                     }
                     move_uploaded_file($fileData['tmp_name'], $originalsDirectoryName . $fileName);
                     if ($type == 'images') {
                         $dimensions = trim($this->application->cgi->getGPC('dimensions', ''));
                         $dimensions = preg_split('/\\s*,\\s*/', $dimensions, -1, PREG_SPLIT_NO_EMPTY);
                         array_push($dimensions, '100');
                         $dimensions = array_unique($dimensions);
                         foreach ($dimensions as $dimension) {
                             $directoryName = documentRoot . '/' . $type . '/' . $objectName . '/' . $propertyName . '/' . $dimension . '/' . mb_substr($fileName, 0, 2) . '/';
                             if (!file_exists($directoryName)) {
                                 mkdir($directoryName, 0777, true);
                             }
                             $command = $this->prepareCommand($dimension);
                             shell_exec('convert ' . $command . ' "' . $originalsDirectoryName . '/' . $fileName . '" "' . $directoryName . '/' . $fileName . '"');
                         }
                         $metaData = new stdClass();
                         $metaData->dimensions = $dimensions;
                         $file->metadata = serialize($metaData);
                     }
                     $file->name = $fileData['name'];
                     $file->fileName = $fileName;
                     $file->md5 = $md5;
                 }
                 $this->output = new stdClass();
                 $this->output->fileName = $fileName;
                 $this->output->data = $this->application->cgi->getGPC('data', '');
             }
         }
     }
     return parent::execute();
 }