# Conflicts:
#	module/tree/view/edit.html.php
This commit is contained in:
Catouse
2018-11-19 15:46:57 +08:00
16 changed files with 118 additions and 88 deletions

View File

@@ -192,4 +192,40 @@ class zfile
{
return rename($from, $to);
}
/**
* Get file size.
*
* @param string $file
* @access public
* @return int
*/
public function getFileSize($file)
{
return abs(filesize($file));
}
/**
* Get directory size.
*
* @param string $dir
* @access public
* @return int
*/
public function getDirSize($dir)
{
$size = 0;
foreach(glob("$dir/*") as $file)
{
if(is_dir($file))
{
$size += $this->getDirSize($file);
}
else
{
$size += $this->getFileSize($file);
}
}
return $size;
}
}

View File

@@ -21,7 +21,7 @@ class backup extends control
{
parent::__construct($moduleName, $methodName);
$this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup/' : $this->config->backup->settingDir;
$this->backupPath = empty($this->config->backup->settingDir) ? $this->app->getTmpRoot() . 'backup' . DS : $this->config->backup->settingDir;
if(!is_dir($this->backupPath))
{
if(!mkdir($this->backupPath, 0777, true)) $this->view->error = sprintf($this->lang->backup->error->noWritable, dirname($this->backupPath));
@@ -127,7 +127,7 @@ class backup extends control
$backFileName = $this->backupPath . $fileName . '.file';
if(!$nozip) $backFileName .= '.zip';
if(!$nosafe) $backFileName .= '.php';
if(!$nozip and !$nosafe) $backFileName .= '.php';
$result = $this->backup->backFile($backFileName);
if(!$result->result)
@@ -146,7 +146,7 @@ class backup extends control
$backFileName = $this->backupPath . $fileName . '.code';
if(!$nozip) $backFileName .= '.zip';
if(!$nosafe) $backFileName .= '.php';
if(!$nozip and !$nosafe) $backFileName .= '.php';
$result = $this->backup->backCode($backFileName);
if(!$result->result)
@@ -353,8 +353,11 @@ class backup extends control
if(isset($data->setting)) $setting = $data->setting;
$this->loadModel('setting')->setItem('system.backup.setting', $setting);
$settingDir = $data->settingDir;
if($data->settingDir == $this->app->getTmpRoot() . 'backup/') $settingDir = '';
$settingDir = rtrim($data->settingDir, DS) . DS;
if(!is_dir($settingDir) and mkdir($settingDir, 0777, true)) die(js::alert($this->lang->backup->error->noCreateDir));
if(!is_writable($settingDir)) die(js::alert($this->lang->backup->error->noWritable));
if($data->settingDir == $this->app->getTmpRoot() . 'backup' . DS) $settingDir = '';
$this->setting->setItem('system.backup.settingDir', $settingDir);
die(js::reload('parent.parent'));

View File

@@ -12,9 +12,11 @@ $lang->backup->time = 'Date';
$lang->backup->files = 'Files';
$lang->backup->size = 'Size';
$lang->backup->setting = 'Setting';
$lang->backup->setting = 'Setting';
$lang->backup->settingDir = 'Backup Directory';
$lang->backup->settingList['nofile'] = 'Not backup file and code.';
$lang->backup->settingList['nozip'] = 'Only copy file';
$lang->backup->settingList['nozip'] = 'Only copy file, Uncompressed';
$lang->backup->settingList['nosafe'] = 'No need to prevent downloading PHP file header.';
$lang->backup->waitting = '<span id="backupType"></span> In Progress. Please wait...';
$lang->backup->confirmDelete = 'Do you want to delete the backup';
@@ -27,6 +29,7 @@ $lang->backup->success->backup = 'Done!';
$lang->backup->success->restore = 'Restored!';
$lang->backup->error = new stdclass();
$lang->backup->error->noCreateDir = 'Directory is not exists, and can not create it';
$lang->backup->error->noWritable = "<code>%s</code> is not writable! Please check the privilege, or backup cannot be done.";
$lang->backup->error->noDelete = "%s cannot be deleted. Please modify the privilege or manually delete it.";
$lang->backup->error->restoreSQL = "Database library restoration failed. Error %s.";

View File

@@ -16,8 +16,8 @@ $lang->backup->size = '大小';
$lang->backup->setting = '设置';
$lang->backup->settingDir = '备份目录';
$lang->backup->settingList['nofile'] = '不备份附件和代码';
$lang->backup->settingList['nozip'] = '只拷贝文件';
$lang->backup->settingList['nosafe'] = '不需要防下载设置';
$lang->backup->settingList['nozip'] = '只拷贝文件,不压缩';
$lang->backup->settingList['nosafe'] = '不需要防下载PHP文件头';
$lang->backup->waitting = '<span id="backupType"></span>正在进行中,请稍候...';
$lang->backup->progressSQL = '<p>SQL备份中已备份%s</p>';
@@ -33,6 +33,7 @@ $lang->backup->success->backup = '备份成功!';
$lang->backup->success->restore = '还原成功!';
$lang->backup->error = new stdclass();
$lang->backup->error->noCreateDir = '备份目录不存在,也无法创建该目录';
$lang->backup->error->noWritable = "<code>%s</code> 不可写!请检查该目录权限,否则无法备份。";
$lang->backup->error->noDelete = "文件 %s 无法删除,修改权限或手工删除。";
$lang->backup->error->restoreSQL = "数据库还原失败,错误:%s";

View File

@@ -186,7 +186,7 @@ class backupModel extends model
public function addFileHeader($fileName)
{
$firstline = false;
$die = "<?php die();?>\n";
$die = "<?php die();?" . ">\n";
$fileSize = filesize($fileName);
$fh = fopen($fileName, 'c+');
@@ -229,7 +229,7 @@ class backupModel extends model
public function removeFileHeader($fileName)
{
$firstline = false;
$die = "<?php die();?>\n";
$die = "<?php die();?" . ">\n";
$fileSize = filesize($fileName);
$fh = fopen($fileName, 'c+');
@@ -270,18 +270,8 @@ class backupModel extends model
*/
public function getDirSize($dir)
{
$size = 0;
foreach(glob("$dir/*") as $file)
{
if(is_dir($file))
{
$size += $this->getDirSize($file);
}
else
{
$size += abs(filesize($file));
}
}
return $size;
$zfile = $this->app->loadClass('zfile');
if(!is_dir($dir)) return $zfile->getFileSize($dir);
return $zfile->getDirSize($dir);
}
}

View File

@@ -28,7 +28,7 @@ $(function()
var lastIndex = parseInt($formTbody.find('tr:last > td:first').text());
var $newRow = $(rowTpl.replace(/%s/g, lastIndex + 1));
$newRow.find('.chosen').chosen();
$newRow.find('.iframe').modalTrigger({iframe:true});;
$newRow.find('.iframe').modalTrigger({iframe:true});
$newRow.find('[data-provide="colorpicker-later"]').colorPicker();
$newRow.datepickerAll();
$formTbody.append($newRow);

View File

@@ -387,22 +387,6 @@ class doc extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('doc', 'view', "docID=$docID")));
}
$libs = $this->doc->getLibs();
foreach($libs as $id => $libName)
{
$lib = $this->doc->getLibById($id);
if($lib->project != 0)
{
$project = $this->loadModel('project')->getByID($lib->project);
$libs[$id] = $project->name . '/' . $libName;
}
if($lib->product != 0)
{
$product = $this->loadModel('product')->getByID($lib->product);
$libs[$id] = $product->name . '/' . $libName;
}
}
/* Get doc and set menu. */
$doc = $this->doc->getById($docID);
$libID = $doc->lib;
@@ -420,7 +404,7 @@ class doc extends control
$this->view->doc = $doc;
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0);
$this->view->type = $type;
$this->view->libs = $libs;
$this->view->libs = $this->doc->getCompleteLibName();
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->user->getPairs('noletter', $doc->users);
$this->display();

View File

@@ -1523,4 +1523,24 @@ class docModel extends model
return $actions;
}
public function getCompleteLibName()
{
$libPairs = array();
$products = $this->loadModel('product')->getPairs();
$projects = $this->loadModel('project')->getPairs();
$stmt = $this->dao->select('id,project,product,name')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->query();
while($lib = $stmt->fetch())
{
if($this->checkPrivLib($lib))
{
if($lib->product != 0) $lib->name = zget($products, $lib->product) . '/' . $lib->name;
if($lib->project != 0) $lib->name = zget($projects, $lib->project) . '/' . $lib->name;
$libPairs[$lib->id] = $lib->name;
}
}
return $libPairs;
}
}

View File

@@ -123,6 +123,7 @@
<?php endforeach;?>
</div>
</div>
<?php echo $this->fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true'));?>
</div>
<div class='main-actions'>
<div class="btn-toolbar">
@@ -206,9 +207,6 @@
<?php $actionFormLink = $this->createLink('action', 'comment', "objectType=doc&objectID=$doc->id");?>
<?php include '../../common/view/action.html.php';?>
</div>
<div class='cell'>
<?php echo $this->fetch('file', 'printFiles', array('files' => $doc->files, 'fieldset' => 'true'));?>
</div>
</div>
</div>

View File

@@ -33,15 +33,10 @@
<th><?php echo $lang->product->line;?></th>
<td>
<div class='input-group' id='lineIdBox'>
<?php
echo html::select('line', $lines, '', "class='form-control chosen'");
echo "<span class='input-group-addon'>";
echo html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=line", '', true), $lang->tree->manageLine, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");
echo '&nbsp; ';
echo html::a("javascript:void(0)", $lang->refresh, '', "class='refresh' onclick='loadProductLines($rootID)'");
echo '</span>';
?>
<?php echo html::select('line', $lines, '', "class='form-control chosen'");?>
<span class='input-group-addon'><?php echo html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=line", '', true), $lang->tree->manageLine, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");?></span>
</div>
<div class='hidden'><?php echo html::a("javascript:void(0)", $lang->refresh, '', "class='refresh' onclick='loadProductLines($rootID)'");?></div>
</td>
</tr>
<tr>

View File

@@ -117,7 +117,7 @@
<div class="btn-group dropup">
<button data-toggle="dropdown" type="button" class="btn"><?php echo $lang->bug->assignedTo?> <span class="caret"></span></button>
<?php
$withSearch = count($memberPairs) > 1;
$withSearch = count($memberPairs) > 10;
$actionLink = $this->createLink('bug', 'batchAssignTo', "projectID={$project->id}&type=project");
if($withSearch)

View File

@@ -1,5 +1,7 @@
function switchShow(result)
{
$('#priBox').hide();
$('#estimateBox').hide();
if(result == 'reject')
{
$('#rejectedReasonBox').show();
@@ -9,10 +11,8 @@ function switchShow(result)
$('#assignedTo').val('closed');
$('#assignedTo').trigger("chosen:updated");
}
else if(result == 'clarify')
else if(result == 'revert')
{
$('#priBox').hide();
$('#estimateBox').hide();
$('#preVersionBox').show();
$('#rejectedReasonBox').hide();
$('#duplicateStoryBox').hide();
@@ -22,8 +22,11 @@ function switchShow(result)
}
else
{
$('#priBox').show();
$('#estimateBox').show();
if(result == 'pass')
{
$('#priBox').show();
$('#estimateBox').show();
}
$('#preVersionBox').hide();
$('#rejectedReasonBox').hide();
$('#duplicateStoryBox').hide();

View File

@@ -1939,7 +1939,7 @@ class storyModel extends model
{
$property = '(' . $this->lang->story->pri . ':' . (!empty($this->lang->story->priList[$story->pri]) ? $this->lang->story->priList[$story->pri] : 0) . ',' . $this->lang->story->estimate . ':' . $story->estimate . ')';
}
$storyPairs[$story->id] = $story->id . ':' . $story->title . ' '. $property;
$storyPairs[$story->id] = $story->id . ':' . $story->title . ' ' . $property;
if($limit > 0 && ++$i > $limit)
{

View File

@@ -688,6 +688,7 @@ class taskModel extends model
{
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($task->parent)->exec();
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($task->parent);
}
$this->file->updateObjectID($this->post->uid, $taskID, 'task');
return common::createChanges($oldTask, $task);

View File

@@ -18,5 +18,5 @@ $config->testsuite->datatable = new stdclass();
$config->testsuite->datatable->defaultField = array('id', 'pri', 'title', 'type', 'assignedTo', 'lastRunner', 'lastRunDate', 'lastRunResult', 'status', 'bugs', 'results', 'actions');
$config->testsuite->custom = new stdclass();
$config->testsuite->custom->createFields = 'stage,pri,keywords';
$config->testsuite->customCreateFields = 'stage,pri,keywords';
$config->testsuite->custom->createFields = 'stage,pri,keywords';
$config->testsuite->customCreateFields = 'stage,pri,keywords';

View File

@@ -238,25 +238,9 @@ class tree extends control
$this->view->optionMenu = $this->tree->getOptionMenu($module->root, $module->type, 0, $branch);
}
$libs = $this->loadModel('doc')->getLibs();
foreach($libs as $id => $libName)
{
$lib = $this->doc->getLibById($id);
if($lib->project != 0)
{
$project = $this->loadModel('project')->getByID($lib->project);
$libs[$id] = $project->name . '/' . $libName;
}
if($lib->product != 0)
{
$product = $this->loadModel('product')->getByID($lib->product);
$libs[$id] = $product->name . '/' . $libName;
}
}
$this->view->module = $module;
$this->view->type = $type;
$this->view->libs = $libs;
$this->view->libs = $this->loadModel('doc')->getCompleteLibName();
$this->view->branch = $branch;
$this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted', $module->owner);
@@ -371,19 +355,31 @@ class tree extends control
}
if($returnType == 'html')
{
$changeFunc = '';
if($viewType == 'task' or $viewType == 'bug' or $viewType == 'case') $changeFunc = "onchange='loadModuleRelated()'";
$field = $fieldID ? "modules[$fieldID]" : 'module';
if($viewType == 'line') $field = 'line';
$output = html::select("$field", $optionMenu, '', "class='form-control' $changeFunc");
if(count($optionMenu) == 1 and $needManage)
//Code for task #5081.
if($viewType == 'line')
{
$output .= "<span class='input-group-addon'>";
$lineID = $this->dao->select('id')->from(TABLE_MODULE)->where('type')->eq('line')->andWhere('deleted')->eq(0)->orderBy('id_desc')->limit(1)->fetch('id');
$output = html::select("line", $optionMenu, $lineID, "class='form-control'");
$output .= "<span class='input-group-addon' style='border-radius: 0px 2px 2px 0px; border-right-width: 1px;'>";
$output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType&currentModuleID=0&branch=$branch", '', true), $viewType == 'line' ? $this->lang->tree->manageLine : $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");
$output .= '&nbsp; ';
$output .= $viewType == 'line' ? html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductLines($rootID)'") : html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductModules($rootID)'");
$output .= '</span>';
}
else
{
$changeFunc = '';
if($viewType == 'task' or $viewType == 'bug' or $viewType == 'case') $changeFunc = "onchange='loadModuleRelated()'";
$field = $fieldID ? "modules[$fieldID]" : 'module';
$output = html::select("$field", $optionMenu, '', "class='form-control' $changeFunc");
if(count($optionMenu) == 1 and $needManage)
{
$output .= "<span class='input-group-addon'>";
$output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType&currentModuleID=0&branch=$branch", '', true), $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'");
$output .= '&nbsp; ';
$output .= html::a("javascript:void(0)", $this->lang->refresh, '', "class='refresh' onclick='loadProductModules($rootID)'");
$output .= '</span>';
}
}
die($output);
}
if($returnType == 'mhtml')