model.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * The model file of qa module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package qa
  9. * @version $Id$
  10. * @link https://www.zentao.net
  11. */
  12. class qaModel extends model
  13. {
  14. /**
  15. * 设置测试应用下导航权限和链接。
  16. * Set qa menu.
  17. *
  18. * @param int $productID
  19. * @param int|string $branch
  20. * @access public
  21. * @return void
  22. */
  23. public function setMenu($productID = 0, $branch = '')
  24. {
  25. if(!$this->app->user->admin && strpos(",{$this->app->user->view->products},", ",$productID,") === false && $productID != 0 && !commonModel::isTutorialMode())
  26. {
  27. $this->app->loadLang('product');
  28. return $this->app->control->sendError($this->lang->product->accessDenied, helper::createLink('qa', 'index'));
  29. }
  30. if($this->session->branch) $branch = $this->session->branch;
  31. if($this->cookie->preBranch !== '' and $branch === '') $branch = $this->cookie->preBranch;
  32. helper::setcookie('preBranch', (string)$branch);
  33. $product = $this->loadModel('product')->getByID($productID);
  34. if($product and $product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
  35. if(!common::hasPriv('zahost', 'browse') and !common::hasPriv('zanode', 'browse')) unset($this->lang->qa->menu->automation);
  36. common::setMenuVars('qa', $productID);
  37. return true;
  38. }
  39. }