| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- /**
- * The control file of entry module of ZenTaoPMS.
- *
- * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
- * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
- * @author Gang Liu <liugang@cnezsoft.com>
- * @package entry
- * @version $Id$
- * @link https://www.zentao.net
- */
- class entry extends control
- {
- /**
- * 接入禅道列表页面。
- * Browse entries.
- *
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
- * @access public
- * @return void
- */
- public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 10, $pageID = 1)
- {
- $this->app->loadClass('pager', true);
- $pager = new pager($recTotal, $recPerPage, $pageID);
- $this->view->title = $this->lang->entry->common . $this->lang->hyphen . $this->lang->entry->list;
- $this->view->entries = $this->entry->getList($orderBy, $pager);
- $this->view->orderBy = $orderBy;
- $this->view->pager = $pager;
- $this->display();
- }
- /**
- * 添加应用接入禅道。
- * Create an entry.
- *
- * @access public
- * @return void
- */
- public function create()
- {
- if($_POST)
- {
- if($this->post->freePasswd) unset($this->config->entry->form->create['account']);
- $entry = form::data($this->config->entry->form->create)
- ->setIF($this->post->allIP === 'on', 'ip', '*')
- ->add('createdBy', $this->app->user->account)
- ->add('createdDate', helper::now())
- ->remove('allIP')
- ->get();
- $id = $this->entry->create($entry);
- if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- $this->loadModel('action')->create('entry', $id, 'created');
- if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $id));
- return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
- }
- $this->view->title = $this->lang->entry->common . $this->lang->hyphen . $this->lang->entry->create;
- $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed');
- $this->display();
- }
- /**
- * 编辑应用。
- * Edit an entry.
- *
- * @param int $id
- * @access public
- * @return void
- */
- public function edit($id)
- {
- if($_POST)
- {
- if($this->post->freePasswd) unset($this->config->entry->form->edit['account']);
- $entry = form::data($this->config->entry->form->edit)
- ->setIF($this->post->allIP === 'on', 'ip', '*')
- ->add('editedBy', $this->app->user->account)
- ->add('editedDate', helper::now())
- ->remove('allIP')
- ->get();
- $changes = $this->entry->update($id, $entry);
- if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- if($changes)
- {
- $actionID = $this->loadModel('action')->create('entry', $id, 'edited');
- $this->action->logHistory($actionID, $changes);
- }
- return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
- }
- $entry = $this->entry->getById($id);
- $this->view->title = $this->lang->entry->edit . $this->lang->hyphen . $entry->name;
- $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed');
- $this->view->entry = $entry;
- $this->display();
- }
- /**
- * 删除应用。
- * Delete an entry.
- *
- * @param int $id
- * @access public
- * @return void
- */
- public function delete($id)
- {
- $this->entry->delete(TABLE_ENTRY, $id);
- if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
- return $this->send(array('result' => 'success', 'load' => true));
- }
- /**
- * 浏览日志。
- * Browse logs of an entry.
- *
- * @param int $id
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
- * @access public
- * @return void
- */
- public function log($id, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
- {
- $this->app->loadClass('pager', true);
- $pager = new pager($recTotal, $recPerPage, $pageID);
- $entry = $this->entry->getByID($id);
- $this->view->title = $this->lang->entry->log . $this->lang->hyphen . $entry->name;
- $this->view->logs = $this->entry->getLogs($id, $orderBy, $pager);
- $this->view->entry = $entry;
- $this->view->orderBy = $orderBy;
- $this->view->pager = $pager;
- $this->display();
- }
- }
|