Esempio n. 1
0
 protected function deleteCustomData($permanent)
 {
     if ($permanent) {
         $d =& $this->data['data'];
         DM\Config::delete(DM\Config::toId($d['_title'], 'param'));
     }
     parent::deleteCustomData($permanent);
 }
Esempio n. 2
0
 /**
  * sync config table ids with those from tree
  * @return void
  */
 protected function syncConfigIds()
 {
     echo "Sync config ids .. ";
     $rootId = Browser::getRootFolderId();
     $pid = Objects::getChildId($rootId, 'System');
     $pid = Objects::getChildId($pid, 'Config');
     $ref = array();
     $left = array();
     $lastLength = 0;
     $rows = DM\Config::readAll();
     //add root nodes
     foreach ($rows as &$r) {
         if (empty($r['pid'])) {
             $tr = DM\Tree::getChildByName($pid, $r['param']);
             if (empty($tr)) {
                 DM\Config::delete($r['id']);
             } else {
                 $ref[$r['id']] =& $r;
                 $r['treeRecord'] = $tr;
             }
         } else {
             $left[] =& $r;
         }
     }
     while (!empty($left) && sizeof($left) != $lastLength) {
         $rows = $left;
         $lastLength = sizeOf($left);
         $left = array();
         foreach ($rows as &$r) {
             if (isset($ref[$r['pid']]) && !empty($ref[$r['pid']]['treeRecord'])) {
                 $ref[$r['id']] =& $r;
                 $r['treeRecord'] = DM\Tree::getChildByName($ref[$r['pid']]['treeRecord']['id'], $r['param']);
             } else {
                 $left[] =& $r;
             }
         }
     }
     //iterate and update config table
     foreach ($ref as &$r) {
         $tr = $r['treeRecord'];
         $pid = empty($ref[$r['pid']]['treeRecord']) ? null : $ref[$r['pid']]['treeRecord']['id'];
         DB\dbQuery('UPDATE config
             SET
                 id = $2
                 ,pid = $3
             WHERE id = $1', array($r['id'], $tr['id'], $pid));
     }
     echo "Ok \n";
 }