/**
  * create core and configuration for it
  * @depends testDBConnect
  */
 public function testCreateCore()
 {
     $SQL = 'SELECT `active` ' . ' FROM `' . DEFAULT_TEST_CBPREFIX . '__casebox`.`cores`  ' . ' WHERE name LIKE "' . DEFAULT_TEST_CORENAME . '" ';
     $rCore = \CB\DB\dbQuery($SQL);
     $CoreData = $rCore->fetch_assoc();
     $this->assertTrue($CoreData['active'] == '1');
 }
Exemple #2
0
 /**
  *  returns CB nodes as simple array
  *  @param  int $id          [description]
  *  @param  string $path     [description]
  *  @param  string $level    depth
  *  @param  ary $env
  *  @return [type]           [description]
  */
 public static function getChildren($id, $path, $env, $fileId)
 {
     // error_log('WebDAV/Utils.getChildren(' . $id . ',' . $path . ')');
     $defaultFileTemplate = \CB\Config::get('default_file_template');
     $data = Utils::solrGetChildren($id, $fileId);
     // process SOLR results into a simple array
     $fileIds = array();
     $ary = array();
     foreach ($data->response->docs as $item) {
         $el = array('id' => $item->id, 'name' => $item->name, 'template_id' => $item->template_id, 'size' => $item->size, 'cdate' => $item->cdate, 'uid' => $item->uid, 'udate' => $item->udate, 'path' => $path . DIRECTORY_SEPARATOR . $item->name);
         // PropertyStorage will use filename as path, without the 'edit-{nodeId}' folder
         if ($env['mode'] == 'edit') {
             $el['path'] = $item->name;
         }
         // remember Files: more properties will be fetched below
         if ($item->template_id == $defaultFileTemplate) {
             $fileIds[] = $el['id'];
         }
         $ary[$el['id']] = $el;
     }
     // fetch additional info required for files
     // !!! to be refactored using CB API
     // are there any files in Directory?
     if (!empty($fileIds)) {
         $res = \CB\DB\dbQuery('SELECT
                 f.id
                 ,CONCAT(c.path, \'/\', f.content_id) `content_path`
                 ,c.md5
                 ,c.type
             FROM files f
             LEFT JOIN files_content c ON f.content_id = c.id
             WHERE f.id in (' . implode(',', $fileIds) . ')') or die(DB\dbQueryError());
         // append additional file info (content_path, MD5, type)
         while ($r = $res->fetch_assoc()) {
             $ary[$r['id']] = array_merge($ary[$r['id']], $r);
         }
         $res->close();
     }
     // save the nodes in Cache for later use in WebDAV\PropertyStorage (creationdate and other props)
     Utils::cacheNodes($ary);
     return $ary;
 }
Exemple #3
0
 public static function getNodeContent($id, $myPath, $onlyFileId = null)
 {
     $s = new \CB\Search();
     $query = 'pid:' . $id;
     $params = array('fl' => 'id,name,template_id,date,cdate,udate,size', 'fq' => array('dstatus:0', 'system:[0 TO 1]'), 'sort' => 'sort_name asc');
     if (is_array($onlyFileId)) {
         $params['fq'][] = 'id:(' . implode(' OR ', $onlyFileId) . ')';
     }
     $data = $s->search($query, 0, 9999, $params);
     $fileIds = array();
     $array = array();
     foreach ($data->response->docs as $item) {
         $el = array('id' => $item->id, 'name' => $item->name, 'template_id' => $item->template_id, 'size' => $item->size, 'cdate' => $item->cdate, 'udate' => $item->udate, 'path' => $myPath . DIRECTORY_SEPARATOR . $item->name);
         if ($item->template_id != \CB\Config::get('default_file_template')) {
             $el['path'] = $myPath . DIRECTORY_SEPARATOR . $item->name;
         } else {
             $fileIds[] = $el['id'];
         }
         $array[$el['id']] = $el;
     }
     /* select additional info required for files */
     if (!empty($fileIds)) {
         $res = \CB\DB\dbQuery('SELECT
                 f.id
                 ,CONCAT(c.path, \'/\', f.content_id) `content_path`
                 ,c.md5
                 ,c.type
             FROM files f
             LEFT JOIN files_content c ON f.content_id = c.id
             WHERE f.id in (' . implode(',', $fileIds) . ')') or die(DB\dbQueryError());
         while ($r = $res->fetch_assoc()) {
             $array[$r['id']] = array_merge($array[$r['id']], $r);
         }
         $res->close();
     }
     return $array;
 }
 /**
  * @dataProvider fieldsTeplateProvider
  */
 public function testFieldsTemplateCRUD($data_field)
 {
     $tpl_obj = new \CB\Objects\Template();
     $TPL_SQL = 'select id from tree where `name` like "Test fields CRUD" and pid = 3 and template_id = 11 limit 1';
     $tpl_r = \CB\DB\dbQuery($TPL_SQL);
     if ($tpl = $tpl_r->fetch_assoc()) {
         $data_template['id'] = $tpl['id'];
         $this->assertTrue($data_template['id'] > 0, ' Error on load Template');
     } else {
         // first add empty template
         $data_template = ["pid" => 3, "template_id" => 11, "type" => "object", "name" => "Test fields CRUD", "title" => "Test fields CRUD", 'l1' => "Test fields CRUD", 'l2' => "Test fields CRUD", 'l3' => "Test fields CRUD", 'l4' => "Test fields CRUD", 'order' => '1', 'visible' => '1', 'iconCls' => "icon-bell", "cfg" => ['createMethod' => 'inline', 'object_plugins' => ['objectProperties', 'comments', 'systemProperties']], "title_template" => "{name}"];
         $data_template['id'] = $tpl_obj->create($data_template);
         $this->assertTrue($data_template['id'] > 0, ' Error on create Template');
     }
     // CREATE FIELDS
     if (isset($data_template['id']) && $data_template['id'] > 0) {
         $data_field['pid'] = $data_template['id'];
         $obj_field = new \CB\Objects\TemplateField();
         $data_field['id'] = $obj_field->create($data_field);
         $this->assertTrue($data_field['id'] > 0, ' Error on create Field');
     }
 }
Exemple #5
0
    if (!\CB\DB\dbQuery('CREATE DATABASE `' . $dbName . '` CHARACTER SET utf8 COLLATE utf8_general_ci')) {
        if (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE')) {
            echo 'Cant create database "' . $dbName . '".';
        } else {
            trigger_error('Cant create database "' . $dbName . '".', E_USER_ERROR);
        }
        $applyDump = false;
    }
}
if ($applyDump) {
    shell_exec('mysql --host=' . $cfg['db_host'] . ' --user='******' --password='******' ' . $dbName . ' < ' . $sqlFile);
    showMessage();
}
$cbDb = $cfg['prefix'] . '__casebox';
echo 'Registering core .. ';
\CB\DB\dbQuery('INSERT INTO ' . $cbDb . ' .cores (name, cfg) VALUES ($1, $2)', array($coreName, '{}'));
showMessage();
//ask to provide root email & password
$email = '';
$pass = '';
do {
    $email = readParam('core_root_email');
} while (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE') && empty($email));
do {
    $pass = readParam('core_root_pass');
} while (\CB\Cache::get('RUN_SETUP_INTERACTIVE_MODE') && empty($pass));
DB\dbQuery("use `{$dbName}`") or die(DB\dbQueryError());
if (!empty($email) || !empty($pass)) {
    DM\User::updateByName(array('name' => 'root', 'password' => $pass, 'email' => $email, 'data' => '{"email": "' . $email . '"}'));
}
//set core languages