Пример #1
0
 /**
  * update objects custom data
  * @return void
  */
 protected function updateCustomData()
 {
     parent::updateCustomData();
     $od = $this->oldObject->getData();
     $id = DM\Config::toId($od['data']['_title'], 'param');
     $d =& $this->data;
     $dd =& $d['data'];
     $p = array('id' => $id, 'pid' => empty($d['pid']) ? null : $this->getDMPid($d['pid']), 'param' => $dd['_title'], 'value' => empty($dd['value']) ? '' : $dd['value']);
     if (isset($dd['order'])) {
         $p['order'] = $dd['order'];
     }
     DM\Config::update($p);
 }
Пример #2
0
 protected function moveCustomDataTo($targetId)
 {
     DM\Config::update(array('id' => $this->id, 'pid' => $targetId));
 }
Пример #3
0
 /**
  * transfer config options to tree
  * @return void
  */
 protected function syncConfigToTree()
 {
     $o = new \CB\Objects\Object();
     $co = new \CB\Objects\Config();
     $recs = DM\Config::readAll();
     foreach ($recs as $r) {
         //detect option type
         $type = '';
         switch ($r['param']) {
             case 'default_event_template':
             case 'default_file_template':
             case 'default_folder_template':
             case 'default_task_template':
                 $type = 'int';
                 break;
             case 'default_language':
             case 'languages':
             case 'project_name_en':
             case 'project_name_ru':
                 $type = 'varchar';
                 break;
             case 'folder_templates':
             case 'max_files_version_count':
             case 'templateIcons':
                 $type = 'text';
                 break;
             case 'facet_configs':
             case 'js':
             case 'maintenance_cfg':
             case 'node_facets':
             case 'rootNode':
             case 'object_type_plugins':
             case 'treeNodes':
                 $type = 'json';
                 break;
             case 'responsible_party':
             case 'responsible_party_default':
             case 'task_categories':
             case 'maintenance_mode':
                 continue;
             default:
                 if (is_numeric($r['value'])) {
                     $type = 'int';
                 } else {
                     $type = 'text';
                 }
         }
         if (empty($type)) {
             continue;
         }
         $childs = array();
         if ($r['param'] == 'folder_templates') {
             $r['value'] .= ',' . $this->templateIds["Config json option"];
             DM\Config::update($r);
         }
         if ($r['param'] == 'treeNodes') {
             $childs = Util\toJSONArray($r['value']);
             $r['value'] = '';
             DM\Config::update($r);
         }
         $pid = $o->create(array('id' => null, 'pid' => $this->cfg['configFolderId'], 'template_id' => $this->templateIds["Config {$type} option"], 'name' => $r['param'], 'data' => array('_title' => $r['param'], 'value' => $r['value'])));
         $i = 1;
         foreach ($childs as $k => $v) {
             $co->create(array('id' => null, 'pid' => $pid, 'template_id' => $this->templateIds["Config {$type} option"], 'name' => $k, 'data' => array('_title' => $k, 'value' => json_encode($v, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), 'order' => $i++)));
         }
     }
     //add menu rule for Menus folder
     $pid = Objects::getChildId($this->systemFolderId, 'Menus');
     $tempalteIds = DM\Templates::getIdsByType('menu');
     $o->create(array('id' => null, 'pid' => $pid, 'template_id' => $tempalteIds[0], 'name' => 'Create config options rule', 'data' => array('_title' => 'Create config options rule', 'node_ids' => $this->cfg['configFolderId'], 'menu' => $this->templateIds['Config int option'] . ',' . $this->templateIds['Config varchar option'] . ',' . $this->templateIds['Config text option'] . ',' . $this->templateIds['Config json option'])));
 }