* finish task #2667,2669.

This commit is contained in:
wangyidong
2016-10-13 17:35:02 +08:00
parent 4bcc1a7980
commit 8feda80cd9
21 changed files with 722 additions and 63 deletions

4
db/update8.2.6.sql Normal file
View File

@@ -0,0 +1,4 @@
ALTER TABLE `zt_doclib` ADD `product` mediumint(8) unsigned NOT NULL AFTER `id`,
ADD `project` mediumint(8) unsigned NOT NULL AFTER `product`,
ADD `groups` varchar(255) COLLATE 'utf8_general_ci' NOT NULL AFTER `name`,
ADD `users` text COLLATE 'utf8_general_ci' NOT NULL AFTER `groups`;

View File

@@ -795,6 +795,12 @@ class actionModel extends model
$table = $this->config->objectTables[$action->objectType];
$this->dao->update($table)->set('deleted')->eq(0)->where('id')->eq($action->objectID)->exec();
/* Revert doclib when undelet product or project. */
if($action->objectType == 'project' or $action->objectType == 'product')
{
$this->dao->update(TABLE_DOCLIT)->set('deleted')->eq(0)->where($action->objectType)->eq($action->objectID)->exec();
}
/* Update action record in action table. */
$this->dao->update(TABLE_ACTION)->set('extra')->eq(ACTIONMODEL::BE_UNDELETED)->where('id')->eq($actionID)->exec();
$this->create($action->objectType, $action->objectID, 'undeleted');

View File

@@ -262,10 +262,10 @@ $lang->doc = new stdclass();
$lang->doc->menu = new stdclass();
$lang->doc->menu->list = array('link' => '%s', 'fixed' => true);
$lang->doc->menu->index = 'Index|doc|index|';
$lang->doc->menu->product = array('link' => $lang->productCommon . '|doc|browse|type=product');
$lang->doc->menu->project = array('link' => $lang->projectCommon . '|doc|browse|type=project');
$lang->doc->menu->custom = array('link' => 'Custom|doc|browse|type=custom');
$lang->doc->menu->index = array('link' => '<i class="icon-home"></i>&nbsp;Homepage|doc|index|', 'float' => 'right');
$lang->doc->menu->create = array('link' => '<span class="icon-plus">&nbsp;</span>New Library|doc|createLib', 'float' => 'right');
/* Report menu. */

View File

@@ -77,10 +77,10 @@ $lang->testtask->menuOrder = $lang->testcase->menuOrder;
/* doc menu order. */
$lang->doc->menuOrder[5] = 'list';
$lang->doc->menuOrder[10] = 'index';
$lang->doc->menuOrder[15] = 'product';
$lang->doc->menuOrder[20] = 'project';
$lang->doc->menuOrder[25] = 'custom';
$lang->doc->menuOrder[10] = 'product';
$lang->doc->menuOrder[15] = 'project';
$lang->doc->menuOrder[20] = 'custom';
$lang->doc->menuOrder[25] = 'index';
$lang->doc->menuOrder[30] = 'create';
/* report menu order. */

View File

@@ -262,10 +262,10 @@ $lang->doc = new stdclass();
$lang->doc->menu = new stdclass();
$lang->doc->menu->list = array('link' => '%s', 'fixed' => true);
$lang->doc->menu->index = '首页|doc|index|';
$lang->doc->menu->product = array('link' => $lang->productCommon . '|doc|browse|type=product');
$lang->doc->menu->project = array('link' => $lang->projectCommon . '|doc|browse|type=project');
$lang->doc->menu->custom = array('link' => '自定义|doc|browse|type=custom');
$lang->doc->menu->product = array('link' => $lang->productCommon . '|doc|allLibs|type=product');
$lang->doc->menu->project = array('link' => $lang->projectCommon . '|doc|allLibs|type=project');
$lang->doc->menu->custom = array('link' => '自定义|doc|allLibs|type=custom');
$lang->doc->menu->index = array('link' => '<i class="icon-home"></i>&nbsp;文档主页|doc|index|', 'float' => 'right');
$lang->doc->menu->create = array('link' => '<i class="icon-plus"></i>&nbsp;添加文档库|doc|createLib', 'float' => 'right');
/* 统计视图菜单设置。*/

View File

@@ -25,7 +25,6 @@ class doc extends control
$this->loadModel('action');
$this->loadModel('product');
$this->loadModel('project');
$this->libs = $this->doc->getLibs();
}
/**
@@ -36,7 +35,25 @@ class doc extends control
*/
public function index()
{
$this->locate(inlink('browse'));
$products[] = $this->lang->doc->systemLibs['product'];
unset($this->lang->doc->menu->index);
$this->doc->setMenu($products);
$limit = 6;
$products = $this->doc->getLimitLibs('product');
$projects = $this->doc->getLimitLibs('project');
$customLibs = $this->doc->getLimitLibs('custom');
$subLibs['product'] = $this->doc->getSubLibGroups('product', array_keys($products));
$subLibs['project'] = $this->doc->getSubLibGroups('project', array_keys($projects));
$this->view->title = $this->lang->doc->index;
$this->view->position[] = $this->lang->doc->index;
$this->view->products = $products;
$this->view->projects = $projects;
$this->view->customLibs = $customLibs;
$this->view->subLibs = $subLibs;
$this->display();
}
/**
@@ -53,16 +70,32 @@ class doc extends control
* @access public
* @return void
*/
public function browse($libID = 'product', $moduleID = 0, $productID = 0, $projectID = 0, $browseType = 'byModule', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
public function browse($libID = 0, $browseType = 'byModule', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$this->loadModel('search');
/* Set browseType.*/
$browseType = strtolower($browseType);
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
$moduleID = ($browseType == 'bymodule') ? (int)$param : 0;
$type = 'custom';
if($libID)
{
$lib = $this->doc->getLibByID($libID);
if($lib->product or $lib->project) $type = $lib->product ? 'product' : 'project';
}
if(empty($libID)) $type = 'product';
$this->libs = $this->doc->getLibs($type);
if(empty($libID))
{
$libID = key($this->libs);
$lib = $this->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($libID)->orderBy('id')->fetch();
}
/* Set menu, save session. */
$this->doc->setMenu($this->libs, $libID, 'doc');
$this->doc->setMenu($this->libs, $libID, $type);
$this->session->set('docList', $this->app->getURI(true));
/* Set header and position. */
@@ -77,14 +110,14 @@ class doc extends control
$sort = $this->loadModel('common')->appendOrder($orderBy);
/* Get docs by browse type. */
$docs = $this->doc->getDocsByBrowseType($productID, $projectID, $browseType, $libID, $queryID, $moduleID, $sort, $pager);
$docs = $this->doc->getDocsByBrowseType($libID, $browseType, $queryID, $moduleID, $sort, $pager);
/* Get the tree menu. */
$moduleTree = $this->doc->getDocTreeMenu($libID);
/* Build the search form. */
$actionURL = $this->createLink('doc', 'browse', "libID=$libID&moduleID=$moduleID&procuctID=$productID&projectID=$projectID&browseType=bySearch&queryID=myQueryID");
$this->doc->buildSearchForm($libID, $this->libs, $queryID, $actionURL);
$actionURL = $this->createLink('doc', 'browse', "lib=$libID&browseType=bySearch&queryID=myQueryID");
$this->doc->buildSearchForm($libID, $this->libs, $queryID, $actionURL, $type);
$this->view->libID = $libID;
$this->view->libName = $this->libs[$libID];
@@ -95,10 +128,9 @@ class doc extends control
$this->view->pager = $pager;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->orderBy = $orderBy;
$this->view->productID = $productID;
$this->view->projectID = $projectID;
$this->view->browseType = $browseType;
$this->view->param = $param;
$this->view->type = $type;
$this->display();
}
@@ -124,6 +156,8 @@ class doc extends control
echo js::error(dao::getError());
}
}
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->loadModel('user')->getPairs();
die($this->display());
}
@@ -410,4 +444,111 @@ class doc extends control
die(js::locate($this->session->docList, 'parent'));
}
}
/**
* Ajax get drop menu.
*
* @param int $productID
* @param string $module
* @param string $method
* @param string $extra
* @access public
* @return void
*/
public function ajaxGetDropMenu($libID, $module, $method, $extra)
{
$this->view->link = $this->doc->getDocLink($module, $method, $extra);
$this->view->libID = $libID;
$this->view->module = $module;
$this->view->method = $method;
$this->view->extra = $extra;
$this->view->libs = $this->doc->getLibs($extra);
$this->display();
}
/**
* The results page of search.
*
* @param string $keywords
* @param string $module
* @param string $method
* @param mix $extra
* @access public
* @return void
*/
public function ajaxGetMatchedItems($keywords, $module, $method, $extra)
{
$libs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)
->andWhere('name')->like("%$keywords%")
->beginIF($extra == 'product' or $extra == 'project')->andWhere($extra)->ne(0)->fi()
->orderBy('`id` desc')
->fetchAll();
foreach($libs as $key => $lib)
{
if(!$this->doc->checkPriv($lib)) unset($libs[$key]);
}
$this->view->link = $this->doc->getDocLink($module, $method, $extra);
$this->view->libs = $libs;
$this->view->keywords = $keywords;
$this->display();
}
/**
* Show all libs by type.
*
* @param string $type
* @param string $extra
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function allLibs($type, $extra = '', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
$libName = isset($this->lang->doc->systemLibs[$type]) ? $this->lang->doc->systemLibs[$type] : $this->lang->doc->custom;
$this->doc->setMenu(array($libName), 0, $type);
$this->view->title = $libName;
$this->view->position[] = $libName;
/* Load pager. */
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$libs = $this->doc->getAllLibs($type, $pager, $extra);
$subLibs = array();
if($type == 'product' or $type == 'project') $subLibs = $this->doc->getSubLibGroups($type, array_keys($libs), $limit = 0);
$this->view->type = $type;
$this->view->libs = $libs;
$this->view->subLibs = $subLibs;
$this->view->pager = $pager;
$this->display();
}
/**
* Show libs for product or project
*
* @param string $type
* @param int $objectID
* @access public
* @return void
*/
public function showLibs($type, $objectID)
{
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$object = $this->dao->select('id,name')->from($table)->where('id')->eq($objectID)->fetch();
$this->doc->setMenu(array($object->name), 0, $type);
$this->view->title = $object->name;
$this->view->position[] = $object->name;
$this->view->type = $type;
$this->view->object = $object;
$this->view->libs = $this->doc->getLibsByObject($type, $objectID);
$this->display();
}
}

View File

@@ -1 +1,4 @@
.outer{overflow:auto}
.lib{border:1px solid #ddd; padding:5px;white-space:nowrap;overflow:hidden}
.panel-heading{white-space:nowrap;overflow:hidden}
.lib a{display:block;}

View File

@@ -32,5 +32,5 @@ $(document).ready(function()
{
$('[data-id="create"] a').modalTrigger({type: 'iframe', width: 500});
$('[data-id="edit"] a').modalTrigger({type: 'iframe', width: 500});
if(config.currentMethod == 'browse')$('#modulemenu .nav li.active').removeClass('active');
if(typeof(type) != 'undefined') $('#modulemenu .nav li[data-id="' + type + '"]').addClass('active');
});

View File

@@ -46,6 +46,8 @@ $lang->doc->manageType = '维护分类';
$lang->doc->addType = '增加分类';
$lang->doc->libName = '文档库名称';
$lang->doc->custom = '自定义文档库';
$lang->doc->subLib = '子文档库';
$lang->doc->createLib = '创建文档库';
$lang->doc->editLib = '编辑文档库';
$lang->doc->deleteLib = '删除文档库';

View File

@@ -22,19 +22,12 @@ class docModel extends model
* @access public
* @return void
*/
public function setMenu($libs, $libID, $extra = '')
public function setMenu($libs, $libID = 0, $extra = 'product')
{
$currentModule = $this->app->getModuleName();
$currentMethod = $this->app->getMethodName();
$selectHtml = "<div class='dropdown'>" . html::a('javascript:;', $libs[$libID] . " <span class='caret'></span>", '', "data-toggle='dropdown'") . "<ul class='dropdown-menu'>";
foreach ($libs as $key => $value)
{
$class = $libID == $key ? 'active' : '';
$selectHtml .= "<li class='$class'>" . html::a("javascript:switchDocLib(\"$key\", \"$currentModule\", \"$currentMethod\", \"$extra\");", $value) . '</li>';
}
$selectHtml .= '</ul></div>';
$currentModule = 'doc';
$currentMethod = 'browse';
$selectHtml = "<a id='currentItem' href=\"javascript:showDropMenu('doc', '$libID', '$currentModule', '$currentMethod', '$extra')\">{$libs[$libID]} <span class='icon-caret-down'></span></a><div id='dropMenu'><i class='icon icon-spin icon-spinner'></i></div>";
common::setMenuVars($this->lang->doc->menu, 'list', $selectHtml);
foreach($this->lang->doc->menu as $key => $menu)
{
@@ -60,10 +53,23 @@ class docModel extends model
* @access public
* @return array
*/
public function getLibs()
public function getLibs($type = '')
{
$libs = $this->dao->select('id, name')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->fetchPairs();
return $this->lang->doc->systemLibs + $libs;
if($type == 'product' or $type == 'project')
{
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where($type)->ne(0)->andWhere('deleted')->eq(0)->query();
}
else
{
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('product')->eq('0')->andWhere('project')->eq(0)->query();
}
$libPairs = array();
while($lib = $stmt->fetch())
{
if($this->checkPriv($lib)) $libPairs[$lib->id] = $lib->name;
}
return $libPairs;
}
/**
@@ -120,13 +126,13 @@ class docModel extends model
* @access public
* @return array
*/
public function getDocsByBrowseType($productID, $projectID, $browseType, $libID, $queryID, $moduleID, $sort, $pager)
public function getDocsByBrowseType($libID, $browseType, $queryID, $moduleID, $sort, $pager)
{
if($browseType == "bymodule")
{
$modules = 0;
if($moduleID) $modules = $this->loadModel('tree')->getAllChildId($moduleID);
$docs = $this->getDocs($libID, $productID, $projectID, $modules, $sort, $pager);
$docs = $this->getDocs($libID, $modules, $sort, $pager);
}
elseif($browseType == "bysearch")
{
@@ -170,23 +176,11 @@ class docModel extends model
* @access public
* @return void
*/
public function getDocs($libID, $productID, $projectID, $module, $orderBy, $pager)
public function getDocs($libID, $module, $orderBy, $pager)
{
$products = $this->loadModel('product')->getPairs();
$projects = $this->loadModel('project')->getPairs();
$keysOfProducts = array_keys($products);
$keysOfProjects = array_keys($projects);
$allKeysOfProjects = $keysOfProjects;
$allKeysOfProjects[] = 0;
return $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
->beginIF(is_numeric($libID))->andWhere('lib')->eq($libID)->fi()
->beginIF($libID == 'product')->andWhere('product')->in($keysOfProducts)->andWhere('project')->in($allKeysOfProjects)->fi()
->beginIF($libID == 'project')->andWhere('project')->in($keysOfProjects)->fi()
->beginIF($productID > 0)->andWhere('product')->eq($productID)->fi()
->beginIF($projectID > 0)->andWhere('project')->eq($projectID)->fi()
->beginIF((string)$projectID == 'int')->andWhere('project')->gt(0)->fi()
->andWhere('lib')->in($libID)
->beginIF($module)->andWhere('module')->in($module)->fi()
->orderBy($orderBy)
->page($pager)
@@ -306,7 +300,7 @@ class docModel extends model
* @access public
* @return void
*/
public function buildSearchForm($libID, $libs, $queryID, $actionURL)
public function buildSearchForm($libID, $libs, $queryID, $actionURL, $type)
{
$this->config->doc->search['actionURL'] = $actionURL;
$this->config->doc->search['queryID'] = $queryID;
@@ -316,7 +310,7 @@ class docModel extends model
$this->config->doc->search['params']['type']['values'] = array(''=>'') + $this->config->doc->search['params']['type']['values'];
/* Get the modules. */
if($libID == 'product' or $libID == 'project')
if($type == 'product' or $type == 'project')
{
$moduleOptionMenu = $this->loadModel('tree')->getOptionMenu(0, $libID . 'doc', $startModuleID = 0);
}
@@ -442,4 +436,203 @@ class docModel extends model
}
return $css;
}
/**
* Check priv.
*
* @param object $docLib
* @access public
* @return bool
*/
public function checkPriv($docLib)
{
if(empty($docLib->groups) and empty($docLib->users)) return true;
$account = ',' . $this->app->user->account . ',';
if(strpos($this->app->company->admins, $account) !== false) return true;
if(strpos(",$docLib->users,", $account) !== false) return true;
$userGroups = $this->app->user->groups;
foreach($userGroups as $groupID)
{
if(strpos(",$docLib->groups,", ",$groupID,") !== false) return true;
}
return false;
}
/**
* Get doc link.
*
* @param string $module
* @param string $method
* @param string $extra
* @access public
* @return string
*/
public function getDocLink($module, $method, $extra = '')
{
return helper::createLink($module, $method, "type=custom&libID=%s");
}
/**
* Get all libs by type.
*
* @param string $type
* @param int $pager
* @param string $extra
* @access public
* @return void
*/
public function getAllLibs($type, $pager = null, $extra = '')
{
if($extra)
{
parse_str($extra);
if(isset($product) and $type == 'project') $projects = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('product')->eq($product)->fetchPairs('project', 'project');
}
$key = ($type == 'product' or $type == 'project') ? $type : 'id';
$stmt = $this->dao->select("DISTINCT $key")->from(TABLE_DOCLIB)->where('deleted')->eq(0);
if($type == 'product' or $type == 'project')
{
$stmt = $stmt->andWhere($type)->ne(0);
}
else
{
$stmt = $stmt->andWhere('project')->eq(0)->andWhere('product')->eq(0);
}
if(isset($projects)) $stmt = $stmt->andWhere('project')->in($projects);
$condition = '';
$account = ',' . $this->app->user->account . ',';
if(strpos($this->app->company->admins, $account) === false)
{
$condition .= "(groups='' and users='')";
foreach($this->app->user->groups as $groupID) $condition .= " OR (CONCAT(',', groups, ',') like '%,$groupID,%')";
$condition .= " OR (CONCAT(',', users, ',') like '%$account%')";
}
$idList = $stmt->beginIF($condition)->andWhere("($condition)")->fi()->orderBy("{$key}_desc")->page($pager)->fetchPairs($key, $key);
if($type == 'product' or $type == 'project')
{
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$libs = $this->dao->select('id,name')->from($table)->where('id')->in($idList)->orderBy('`order` desc, id desc')->fetchAll('id');
}
else
{
$libs = $this->dao->select('id,name')->from(TABLE_DOCLIB)->where('id')->in($idList)->orderBy('id desc')->fetchAll('id');
}
return $libs;
}
/**
* Get limit libs.
*
* @param string $type
* @param int $limit
* @access public
* @return array
*/
public function getLimitLibs($type, $limit = 6)
{
if($type == 'product' or $type == 'project')
{
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->ne(0)->orderBy("$type desc")->query();
}
else
{
$stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere('project')->eq(0)->andWhere('product')->eq(0)->orderBy('id desc')->query();
}
$i = 1;
$libs = array();
while($docLib = $stmt->fetch())
{
if($i > $limit) break;
$key = ($type == 'product' or $type == 'project') ? $type : 'id';
if($this->checkPriv($docLib) and !isset($libs[$docLib->$key]))
{
$libs[$docLib->$key] = $docLib->name;
$i++;
}
}
if($type == 'product' or $type == 'project')
{
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
$libs = $this->dao->select('id,name')->from($table)->where('id')->in(array_keys($libs))->orderBy('`order` desc, id desc')->fetchAll('id');
}
return $libs;
}
/**
* Get project or product libs groups.
*
* @param string $type
* @param array $idList
* @param int $limit
* @access public
* @return array
*/
public function getSubLibGroups($type, $idList, $limit = 3)
{
$libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('id desc')->fetchGroup($type, 'id');
if($type == 'product')
{
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->in($idList)
->andWhere('t2.deleted')->eq(0)
->fetchPairs('product', 'product');
}
$buildGroups = array();
foreach($libGroups as $objectID => $libs)
{
$i = 1;
foreach($libs as $lib)
{
if($limit and $i > $limit) break;
if($this->checkPriv($lib))
{
$buildGroups[$objectID][$lib->id] = $lib->name;
$i++;
}
}
if($type == 'product' and isset($hasProject[$objectID])) $buildGroups[$objectID]['project'] = $this->lang->doc->systemLibs['project'];
}
return $buildGroups;
}
/**
* Get libs by object.
*
* @param string $type
* @param int $objectID
* @access public
* @return array
*/
public function getLibsByObject($type, $objectID)
{
$objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->eq($objectID)->orderBy('id desc')->fetchAll('id');
if($type == 'product')
{
$hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->eq($objectID)
->andWhere('t2.deleted')->eq(0)
->fetchPairs('product', 'product');
}
$libs = array();
foreach($objectLibs as $lib)
{
if($this->checkPriv($lib)) $libs[$lib->id] = $lib->name;
}
if($type == 'product' and isset($hasProject[$objectID])) $libs['project'] = $this->lang->doc->systemLibs['project'];
return $libs;
}
}

View File

@@ -0,0 +1,17 @@
<?php js::set('libID', $libID);?>
<?php js::set('module', $module);?>
<?php js::set('method', $method);?>
<?php js::set('extra', $extra);?>
<input type='text' class='form-control' id='search' value='' placeholder='<?php echo $this->app->loadLang('search')->search->common;?>'/>
<div id='searchResult'>
<div id='defaultMenu' class='search-list'>
<ul>
<?php
foreach($libs as $libID => $libName)
{
echo "<li>" . html::a(sprintf($link, $libID), "<i class='icon-cube'></i> " . $libName, '', "class='text-important'"). "</li>";
}
?>
</ul>
</div>
</div>

View File

@@ -0,0 +1,11 @@
<div class='search-list'>
<ul>
<?php if(!$products) echo "<li class='no-result-tip'>" . sprintf($lang->product->noMatched, $keywords) . '</li>';?>
<?php
foreach($products as $product)
{
echo "<li>" . html::a(sprintf($link, $product->id), "<i class='icon-cube'></i> " . $product->name, '', "class='$product->status'"). "</li>";
}
?>
</ul>
</div>

View File

@@ -0,0 +1,57 @@
<?php
/**
* The allLibs view file of doc module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package doc
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='panel'>
<div class='panel-heading'>
<strong><?php echo isset($lang->doc->systemLibs[$type]) ? $lang->doc->systemLibs[$type] : $lang->doc->custom?></strong>
</div>
<div class='panel-body row'>
<?php foreach($libs as $lib):?>
<div class='col-md-4'>
<?php if($type == 'project' or $type == 'product'):?>
<div class='panel'>
<div class='panel-heading'>
<?php echo $lib->name?>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'showLibs')) echo html::a(inlink('showLibs', "type=$type&objectID=$lib->id"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php if(isset($subLibs[$lib->id])):?>
<?php foreach($subLibs[$lib->id] as $subLibID => $subLibName):?>
<div class='col-md-4'>
<div class='lib' title='<?php echo $subLibName?>'>
<?php
if($subLibID == 'project')
{
echo html::a(inlink('allLibs', "type=project&extra=product=$lib->id"), $subLibName);
}
else
{
echo html::a(inlink('browse', "libID=$subLibID"), $subLibName);
}
?>
</div>
</div>
<?php endforeach?>
<?php endif?>
</div>
</div>
<?php else:?>
<div class='lib' title='<?php echo $lib->name?>'><?php echo html::a(inlink('browse', "libID=$lib->id"), $lib->name);?></div>
<?php endif;?>
</div>
<?php endforeach;?>
</div>
<div class='panel-footer'><?php $pager->show();?><div style='clear:both'></div></div>
</div>
<?php js::set('type', $type);?>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -15,6 +15,7 @@
<?php js::set('confirmDelete', $lang->doc->confirmDelete)?>
<script language='Javascript'>
var browseType = '<?php echo $browseType;?>';
var type = '<?php echo $type;?>';
</script>
<div id='featurebar'>
<ul class='nav'>
@@ -22,7 +23,7 @@ var browseType = '<?php echo $browseType;?>';
<li id='bysearchTab'><a href='#'><i class='icon-search icon'></i>&nbsp;<?php echo $lang->doc->searchDoc;?></a></li>
</ul>
<div class='actions'>
<?php common::printIcon('doc', 'create', "libID=$libID&moduleID=$moduleID&productID=$productID&projectID=$projectID&from=doc");?>
<?php common::printIcon('doc', 'create', "libID=$libID&moduleID=$moduleID&from=doc");?>
</div>
<div id='querybox' class='<?php if($browseType == 'bysearch') echo 'show';?>'></div>
</div>
@@ -44,7 +45,7 @@ var browseType = '<?php echo $browseType;?>';
<table class='table table-condensed table-hover table-striped tablesorter table-fixed' id='docList'>
<thead>
<tr>
<?php $vars = "libID=$libID&module=$moduleID&productID=$productID&projectID=$projectID&browseType=$browseType&param=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
<?php $vars = "libID=$libID&browseType=$browseType&param=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
<th class='w-id'> <?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?></th>
<th> <?php common::printOrderLink('title', $orderBy, $vars, $lang->doc->title);?></th>
<th class='w-100px'><?php common::printOrderLink('type', $orderBy, $vars, $lang->doc->type);?></th>

View File

@@ -0,0 +1,92 @@
<?php
/**
* The index view file of doc module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package doc
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='panel'>
<div class='panel-heading'>
<strong><?php echo $lang->doc->systemLibs['product']?></strong>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'allLibs')) echo html::a(inlink('allLibs', "type=product"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php foreach($products as $product):?>
<div class='col-md-4'>
<div class='panel'>
<div class='panel-heading'>
<?php echo $product->name?>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'showLibs')) echo html::a(inlink('showLibs', "type=product&objectID=$product->id"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php if(isset($subLibs['product'][$product->id])):?>
<?php foreach($subLibs['product'][$product->id] as $libID => $libName):?>
<div class='col-md-4'>
<div class='lib' title='<?php echo $libName?>'>
<?php
if($libID == 'project')
{
echo html::a(inlink('allLibs', "type=project&extra=product=$product->id"), $libName);
}
else
{
echo html::a(inlink('browse', "type=custom&libID=$libID"), $libName);
}
?>
</div>
</div>
<?php endforeach?>
<?php endif?>
</div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<div class='panel'>
<div class='panel-heading'>
<strong><?php echo $lang->doc->systemLibs['project']?></strong>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'allLibs')) echo html::a(inlink('allLibs', "type=project"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php foreach($projects as $project):?>
<div class='col-md-4'>
<div class='panel'>
<div class='panel-heading'>
<?php echo $project->name?>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'showLibs')) echo html::a(inlink('showLibs', "type=project&objectID=$project->id"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php if(isset($subLibs['project'][$project->id])):?>
<?php foreach($subLibs['project'][$project->id] as $libID => $libName):?>
<div class='col-md-4'>
<div class='lib' title='<?php echo $libName?>'><?php echo html::a(inlink('browse', "type=custom&libID=$libID"), $libName);?></div>
</div>
<?php endforeach?>
<?php endif?>
</div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<div class='panel'>
<div class='panel-heading'>
<strong><?php echo $lang->doc->custom?></strong>
<div class='panel-actions pull-right'><?php if(common::hasPriv('doc', 'allLibs')) echo html::a(inlink('allLibs', "type=custom"), $lang->more, '', "class='btn btn-sm'")?></div>
</div>
<div class='panel-body row'>
<?php foreach($customLibs as $libID => $libName):?>
<div class='col-md-4'>
<div class='lib' title='<?php echo $libName?>'><?php echo html::a(inlink('browse', "type=custom&libID=$libID"), $libName);?></div>
</div>
<?php endforeach;?>
</div>
</div>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -0,0 +1,38 @@
<?php
/**
* The showLibs view file of doc module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package doc
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<div class='panel'>
<div class='panel-heading'>
<strong><?php echo $object->name?></strong>
</div>
<div class='panel-body row'>
<?php foreach($libs as $libID => $libName):?>
<div class='col-md-3'>
<div class='lib' title='<?php echo $libName?>'>
<?php
if($libID == 'project')
{
echo html::a(inlink('allLibs', "type=project&extra=product=$object->id"), $libName);
}
else
{
echo html::a(inlink('browse', "libID=$libID"), $libName);
}
?>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<?php js::set('type', $type);?>
<?php include '../../common/view/footer.html.php';?>

View File

@@ -387,6 +387,7 @@ class product extends control
else
{
$this->product->delete(TABLE_PRODUCT, $productID);
$this->dao->update(TABLE_DOCLIB)->set('deleted')->eq(1)->where('product')->eq($productID)->exec();
$this->session->set('product', ''); // 清除session。
die(js::locate($this->createLink('product', 'browse'), 'parent'));
}

View File

@@ -253,6 +253,15 @@ class productModel extends model
$productID = $this->dao->lastInsertID();
$this->dao->update(TABLE_PRODUCT)->set('`order`')->eq($productID * 5)->where('id')->eq($productID)->exec();
/* Create doc lib. */
$lib = new stdclass();
$lib->product = $productID;
$lib->name = $product->name;
if($product->acl == 'custom') $lib->groups = $product->whitelist;
if($product->acl == 'private') $lib->users = $this->app->user->account;
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
return $productID;
}
@@ -279,7 +288,16 @@ class productModel extends model
->check('code', 'unique', "id != $productID and deleted = '0'")
->where('id')->eq($productID)
->exec();
if(!dao::isError()) return common::createChanges($oldProduct, $product);
if(!dao::isError())
{
if($product->acl != $oldProduct->acl)
{
if($product->acl == 'open') $this->dao->update(TABLE_DOCLIB)->set('groups')->eq('')->set('users')->eq('')->where('product')->eq($productID)->exec();
if($product->acl == 'custom') $this->dao->update(TABLE_DOCLIB)->set('groups')->eq($product->whitelist)->where('product')->eq($productID)->exec();
if($product->acl == 'private') $this->dao->update(TABLE_DOCLIB)->set('users')->eq($oldProduct->createdBy)->set('groups')->eq('')->where('product')->eq($productID)->exec();
}
return common::createChanges($oldProduct, $product);
}
}
/**
@@ -816,6 +834,11 @@ class productModel extends model
{
$link = helper::createLink($module, $method, "productID=%s&type=$extra&currentModuleID=0" . ($branch ? "&branch=%s" : ''));
}
else if($module == 'doc')
{
$link = helper::createLink($module, $method, "type=product&libID=%s");
}
return $link;
}

View File

@@ -1410,6 +1410,7 @@ class project extends control
else
{
$this->project->delete(TABLE_PROJECT, $projectID);
$this->dao->update(TABLE_DOCLIB)->set('deleted')->eq(1)->where('project')->eq($projectID)->exec();
$this->session->set('project', '');
die(js::locate(inlink('index'), 'parent'));
}

View File

@@ -268,6 +268,18 @@ class projectModel extends model
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
}
/* Create doc lib. */
$lib = new stdclass();
$lib->project = $projectID;
$lib->name = $project->name;
if($project->acl == 'custom') $lib->groups = $project->whitelist;
if($project->acl == 'private')
{
$teams = $this->dao->select('account')->from(TABLE_TEAM)->where('project')->eq($projectID)->fetchPairs('account', 'account');
$lib->users = join(',', $teams);
}
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
return $projectID;
}
}
@@ -322,7 +334,20 @@ class projectModel extends model
}
}
}
if(!dao::isError()) return common::createChanges($oldProject, $project);
if(!dao::isError())
{
if($project->acl != $oldProject->acl)
{
if($project->acl == 'open') $this->dao->update(TABLE_DOCLIB)->set('groups')->eq('')->set('users')->eq('')->where('project')->eq($projectID)->exec();
if($project->acl == 'custom') $this->dao->update(TABLE_DOCLIB)->set('groups')->eq($project->whitelist)->where('project')->eq($projectID)->exec();
if($project->acl == 'private')
{
$teams = $this->dao->select('account')->from(TABLE_TEAM)->where('project')->eq($projectID)->fetchPairs('account', 'account');
$this->dao->update(TABLE_DOCLIB)->set('users')->eq(join(',', $teams))->set('groups')->eq('')->where('project')->eq($projectID)->exec();
}
}
return common::createChanges($oldProject, $project);
}
}
/**
@@ -1392,7 +1417,20 @@ class projectModel extends model
$member->join = helper::today();
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
}
}
}
$acl = $this->dao->select('acl')->from(TABLE_PROJECT)->where('project')->eq($projectID)->fetch('acl');
if($acl == 'private')
{
$docLibs = $this->dao->select('id,users')->from(TABLE_DOCLIB)->where('project')->eq($projectID)->fetchAll('id');
foreach($docLibs as $lib)
{
if(empty($lib->users)) continue;
$docUsers = $accounts + explode(',', $lib->users);
$docUsers = array_unique($docUsers);
$this->dao->update(TABLE_DOCLIB)->set('users')->eq(join(',', $docUsers))->where('id')->eq($lib->id)->exec();
}
}
}
/**
@@ -1706,6 +1744,8 @@ class projectModel extends model
{
$link = helper::createLink($module, $method, "projectID=%s");
}
if($module == 'doc') $link = helper::createLink($module, $method, "type=project&libID=%s");
return $link;
}

View File

@@ -1157,14 +1157,26 @@ class upgradeModel extends model
public function adjustDocModule()
{
$productDocModules = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('productdoc')->orderBy('grade,id')->fetchAll('id');
$allProductIdList = $this->dao->select('id')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->fetchPairs('id', 'id');
foreach($allProductIdList as $productID)
$allProductIdList = $this->dao->select('id,name,acl,whitelist,createdBy')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->fetchAll('id');
foreach($allProductIdList as $productID => $product)
{
$this->dao->delete()->from(TABLE_DOCLIB)->where('product')->eq($productID)->exec();
$lib = new stdclass();
$lib->product = $productID;
$lib->name = $product->name;
if($product->acl == 'custom') $lib->groups = $product->whitelist;
if($product->acl == 'private') $lib->users = $product->createdBy;
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
$libID = $this->dao->lastInsertID();
$relation = array();
foreach($productDocModules as $moduleID => $module)
{
unset($module->id);
$module->root = $productID;
$module->root = $libID;
$module->type = 'doc';
$this->dao->insert(TABLE_MODULE)->data($module)->exec();
$newModuleID = $this->dao->lastInsertID();
@@ -1180,18 +1192,34 @@ class upgradeModel extends model
$this->dao->update(TABLE_MODULE)->set('path')->eq($newPaths)->where('id')->eq($newModuleID)->exec();
$this->dao->update(TABLE_DOC)->set('module')->eq($newModuleID)->where('product')->eq($productID)->andWhere('module')->eq($moduleID)->andWhere('lib')->eq('product')->exec();
}
$this->dao->update(TABLE_DOC)->set('lib')->eq($libID)->where('product')->eq($productID)->andWhere('lib')->eq('product')->exec();
}
$this->dao->delete()->from(TABLE_MODULE)->where('id')->in(array_keys($productDocModules))->exec();
$projectDocModules = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('projectdoc')->orderBy('grade,id')->fetchAll('id');
$allProjectIdList = $this->dao->select('id')->from(TABLE_PROJECT)->where('deleted')->eq('0')->fetchPairs('id', 'id');
foreach($allProjectIdList as $projectID)
$allProjectIdList = $this->dao->select('id,name,acl,whitelist')->from(TABLE_PROJECT)->where('deleted')->eq('0')->fetchAll('id');
foreach($allProjectIdList as $projectID => $project)
{
$this->dao->delete()->from(TABLE_DOCLIB)->where('project')->eq($projectID)->exec();
$lib = new stdclass();
$lib->project = $projectID;
$lib->name = $project->name;
if($project->acl == 'custom') $lib->groups = $project->whitelist;
if($project->acl == 'private')
{
$teams = $this->dao->select('project, account')->from(TABLE_TEAM)->where('project')->eq($projectID)->fetchPairs('account', 'account');
$lib->users = join(',', $teams);
}
$this->dao->insert(TABLE_DOCLIB)->data($lib)->exec();
$libID = $this->dao->lastInsertID();
$relation = array();
foreach($projectDocModules as $moduleID => $module)
{
unset($module->id);
$module->root = $projectID;
$module->root = $libID;
$module->type = 'doc';
$this->dao->insert(TABLE_MODULE)->data($module)->exec();
$newModuleID = $this->dao->lastInsertID();
@@ -1207,6 +1235,7 @@ class upgradeModel extends model
$this->dao->update(TABLE_MODULE)->set('path')->eq($newPaths)->where('id')->eq($newModuleID)->exec();
$this->dao->update(TABLE_DOC)->set('module')->eq($newModuleID)->where('project')->eq($projectID)->andWhere('module')->eq($moduleID)->andWhere('lib')->eq('project')->exec();
}
$this->dao->update(TABLE_DOC)->set('lib')->eq($libID)->where('project')->eq($projectID)->andWhere('lib')->eq('project')->exec();
}
$this->dao->delete()->from(TABLE_MODULE)->where('id')->in(array_keys($projectDocModules))->exec();