Пример #1
0
 /**
  * The board page.
  * 
  * @param int    $boardID       the board id
  * @param string $mode
  * @param int    $pageID        the current page id
  * @access public
  * @return void
  */
 public function board($boardID = 0, $mode = '', $pageID = 1)
 {
     $board = $this->loadModel('tree')->getByID($boardID, 'forum');
     if (!$board) {
         die(js::locate('back'));
     }
     /* Build search form. */
     $this->loadModel('search', 'sys');
     $this->config->forum->search['actionURL'] = $this->createLink('forum', 'board', "boardID={$boardID}&mode=bysearch");
     $this->search->setSearchParams($this->config->forum->search);
     /* Get common threads. */
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, 10, $pageID);
     if ($mode != 'bysearch') {
         $threads = $this->loadModel('thread')->getList($board->id, $orderBy = 'repliedDate_desc', $pager);
     }
     if ($mode == 'bysearch') {
         $threads = $this->loadModel('thread')->getBySearch($board->id, 'bysearch', $orderBy = 'repliedDate_desc', $pager);
     }
     $this->view->boardID = $boardID;
     $this->view->title = $board->name;
     $this->view->mode = $mode;
     $this->view->keywords = $board->keywords;
     $this->view->desc = strip_tags($board->desc);
     $this->view->board = $board;
     $this->view->boards = $this->forum->getBoards();
     $this->view->sticks = $this->thread->getSticks($board->id);
     $this->view->threads = $threads;
     $this->view->pager = $pager;
     $this->display();
 }
Пример #2
0
 /**
  * Edit a reply.
  * 
  * @param string $replyID 
  * @access public
  * @return void
  */
 public function edit($replyID)
 {
     if ($this->app->user->account == 'guest') {
         die(js::locate($this->createLink('user', 'login')));
     }
     /* Judge current user has priviledge to edit the reply or not. */
     $reply = $this->reply->getByID($replyID);
     if (!$reply) {
         die(js::locate('back'));
     }
     $thread = $this->loadModel('thread')->getByID($reply->thread);
     if (!$this->thread->canManage($thread->board, $reply->author)) {
         die(js::locate('back'));
     }
     $this->thread->setEditor($thread->board, 'edit');
     if ($_POST) {
         $this->reply->update($replyID);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('thread', 'view', "threaID={$thread->id}")));
     }
     $this->view->title = $this->lang->reply->edit . $this->lang->colon . $thread->title;
     $this->view->reply = $reply;
     $this->view->thread = $thread;
     $this->view->board = $this->loadModel('tree')->getById($thread->board);
     $this->view->boards = $this->loadModel('forum')->getBoards();
     $this->display();
 }
Пример #3
0
 /**
  * Edit a reply.
  * 
  * @param string $replyID 
  * @access public
  * @return void
  */
 public function edit($replyID)
 {
     if ($this->app->user->account == 'guest') {
         die(js::locate($this->createLink('user', 'login')));
     }
     /* Judge current user has priviledge to edit the reply or not. */
     $reply = $this->reply->getByID($replyID);
     if (!$reply) {
         die(js::locate('back'));
     }
     $thread = $this->loadModel('thread')->getByID($reply->thread);
     if (!$this->thread->canManage($thread->board, $reply->author)) {
         die(js::locate('back'));
     }
     if ($this->thread->canManage($thread->board)) {
         $this->config->reply->editor->edit['tools'] = 'full';
     }
     if ($_POST) {
         /* If no captcha but is garbage, return the error info. */
         if ($this->post->captcha === false and $this->loadModel('captcha')->isEvil($_POST['content'])) {
             $this->send(array('result' => 'fail', 'reason' => 'needChecking', 'captcha' => $this->captcha->create4Thread()));
         }
         $this->reply->update($replyID);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('thread', 'view', "threaID={$thread->id}")));
     }
     $this->view->title = $this->lang->reply->edit . $this->lang->colon . $thread->title;
     $this->view->reply = $reply;
     $this->view->thread = $thread;
     $this->view->board = $this->loadModel('tree')->getById($thread->board);
     $this->display();
 }
Пример #4
0
 /**
  * Set menu.
  * 
  * @param  array  $projects 
  * @param  int    $projectID 
  * @param  string $extra
  * @access public
  * @return void
  */
 public function setMenu($projects, $projectID, $extra = '')
 {
     /* Check the privilege. */
     $project = $this->getById($projectID);
     /* Unset story, bug, build and testtask if type is ops. */
     if ($project and $project->type == 'ops') {
         unset($this->lang->project->menu->story);
         unset($this->lang->project->menu->bug);
         unset($this->lang->project->menu->build);
         unset($this->lang->project->menu->testtask);
     }
     if ($projects and !isset($projects[$projectID]) and !$this->checkPriv($project)) {
         echo js::alert($this->lang->project->accessDenied);
         die(js::locate('back'));
     }
     $moduleName = $this->app->getModuleName();
     $methodName = $this->app->getMethodName();
     if ($this->cookie->projectMode == 'noclosed' and $project->status == 'done') {
         setcookie('projectMode', 'all');
         $this->cookie->projectMode = 'all';
     }
     $selectHtml = $this->select($projects, $projectID, $moduleName, $methodName, $extra);
     foreach ($this->lang->project->menu as $key => $menu) {
         $replace = $key == 'list' ? $selectHtml : $projectID;
         common::setMenuVars($this->lang->project->menu, $key, $replace);
     }
 }
Пример #5
0
 /**
  * The board page.
  * 
  * @param int    $boardID       the board id
  * @param int    $pageID        the current page id
  * @access public
  * @return void
  */
 public function board($boardID = 0, $pageID = 1)
 {
     $board = $this->loadModel('tree')->getByID($boardID, 'forum');
     if (!$board) {
         die(js::locate('back'));
     }
     if ($board->link) {
         helper::header301($board->link);
     }
     /* Get common threads. */
     $recPerPage = !empty($this->config->site->forumRec) ? $this->config->site->forumRec : $this->config->forum->recPerPage;
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, $recPerPage, $pageID);
     $threads = $this->loadModel('thread')->getList($board->id, $orderBy = 'repliedDate_desc', $pager);
     $this->view->title = $board->name;
     $this->view->keywords = $board->keywords . '' . $this->config->site->keywords;
     $this->view->desc = strip_tags($board->desc);
     $this->view->board = $board;
     $this->view->sticks = $this->thread->getSticks($board->id);
     $this->view->threads = $threads;
     $this->view->pager = $pager;
     $this->view->mobileURL = helper::createLink('forum', 'board', "borderID={$boardID}&pageID={$pageID}", "category={$board->alias}", 'mhtml');
     $this->view->desktopURL = helper::createLink('forum', 'board', "borderID={$boardID}&pageID={$pageID}", "category={$board->alias}", 'html');
     $this->display();
 }
Пример #6
0
 /**
  * Change password , if use default password ,go to change
  * 
  * @access public
  * @return void
  */
 public function changePassword()
 {
     if ($this->app->user->account == 'guest') {
         die(js::alert('guest') . js::locate('back'));
     }
     if (!empty($_POST)) {
         $password1 = $_POST['password1'];
         if (!$password1) {
             die(js::error('Please input password!'));
         }
         $isDefult = $this->dao->select('password')->from(TABLE_DEFAULTPASSWORD)->Where('password')->eq($this->post->password1)->fetchAll();
         //如果用户使用默认密码则跳到修改密码界面
         if ($isDefult) {
             die(js::error('Password can not in default list!') . js::locate($this->createLink('my', 'changePassword', 'type=forbidden'), 'parent'));
         }
         $this->user->updatePassword($this->app->user->id);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         die(js::locate($this->createLink('my', 'profile'), 'parent'));
     }
     $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->changePassword;
     $this->view->position[] = $this->lang->my->changePassword;
     $this->view->user = $this->user->getById($this->app->user->id);
     $this->display();
 }
Пример #7
0
 /**
  * Create an article.
  * 
  * @access public
  * @return void
  */
 public function create()
 {
     if (!empty($_POST)) {
         $blogID = $this->blog->create();
         if (dao::isError()) {
             die(js::error(dao::getError()) . js::locate('back'));
         }
         die(js::locate(inlink('index')));
     }
     $this->view->title = $this->lang->blog->add;
     $this->display();
 }
Пример #8
0
 public function test()
 {
     $pubuConfig = $this->pubu->getConfig();
     $this->view->position[] = html::a(inlink('index'), $this->lang->pubu->common);
     $this->view->position[] = '测试';
     $ping = $this->pubu->sendNotification($pubuConfig->webhook, array('type' => 'ping', "data" => array("hello" => "zentao")));
     $this->view->ping = $ping;
     if (is_string($ping)) {
         echo js::alert($ping);
         die(js::locate('back'));
     }
     $this->display();
 }
Пример #9
0
 /**
  * Set configs of converter.
  *
  * This is the extrance of every system. It will call the set function of corresponding module.
  * 
  * @access public
  * @return void
  */
 public function setConfig()
 {
     if (!$this->post->source) {
         echo js::alert($this->lang->convert->mustSelectSource);
         die(js::locate('back'));
     }
     list($sourceName, $version) = explode('_', $this->post->source);
     $setFunc = "set{$sourceName}";
     $this->view->title = $this->lang->convert->setting;
     $this->view->source = $sourceName;
     $this->view->version = $version;
     $this->view->setting = $this->fetch('convert', $setFunc, "version={$version}");
     $this->display();
 }
Пример #10
0
 /**
  * Bind zentao.
  * 
  * @access public
  * @return void
  */
 public function bind()
 {
     if ($_POST) {
         $response = $this->admin->bindByAPI();
         if ($response == 'success') {
             $this->loadModel('setting')->setItem('system', 'common', 'global', 'community', $this->post->account);
             echo js::alert($this->lang->admin->bind->success);
             die(js::locate(inlink('index'), 'parent'));
         }
         die($response);
     }
     $this->view->sn = $this->loadModel('setting')->getItem('system', 'common', 'global', 'sn', 0);
     $this->display();
 }
Пример #11
0
 /**
  * Set menu.
  * 
  * @param  array  $projects 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function setMenu($projects, $projectID)
 {
     /* Check the privilege. */
     if ($projects and !isset($projects[$projectID]) and !$this->checkPriv($this->getById($projectID))) {
         echo js::alert($this->lang->project->accessDenied);
         die(js::locate('back'));
     }
     $moduleName = $this->app->getModuleName();
     $methodName = $this->app->getMethodName();
     $selectHtml = $this->select($projects, $projectID, $moduleName, $methodName);
     foreach ($this->lang->project->menu as $key => $menu) {
         $replace = $key == 'list' ? $selectHtml : $projectID;
         common::setMenuVars($this->lang->project->menu, $key, $replace);
     }
 }
Пример #12
0
 /**
  * Edit cron. 
  * 
  * @param  int    $cronID 
  * @access public
  * @return void
  */
 public function edit($cronID)
 {
     if ($_POST) {
         $this->cron->update($cronID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         die(js::locate(inlink('index'), 'parent'));
     }
     $this->view->title = $this->lang->cron->edit . $this->lang->cron->common;
     $this->view->position[] = html::a(inlink('index'), $this->lang->cron->common);
     $this->view->position[] = $this->lang->cron->edit;
     $this->view->cron = $this->cron->getById($cronID);
     $this->display();
 }
Пример #13
0
 /**
  * Create a blog.
  * 
  * @param  int    $categoryID
  * @access public
  * @return void
  */
 public function create($categoryID = '')
 {
     $categories = $this->loadModel('tree')->getOptionMenu('blog', 0, $removeRoot = true);
     if (empty($categories)) {
         die(js::locate($this->createLink('tree', 'redirect', "type=blog")));
     }
     if ($_POST) {
         $this->article->create('blog');
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('team.blog')));
     }
     $this->view->title = $this->lang->blog->create;
     $this->view->currentCategory = $categoryID;
     $this->view->categories = $this->loadModel('tree')->getOptionMenu('blog', 0, $removeRoot = true);
     $this->view->type = 'blog';
     $this->display();
 }
Пример #14
0
 public function getLibs($type = 'info')
 {
     if (!$this->app->dbh->query('show tables from `' . $this->config->db->name . '` where `Tables_in_' . $this->config->db->name . "`='" . $this->config->db->prefix . "info'")->fetch(PDO::FETCH_OBJ)->{'Tables_in_' . $this->config->db->name}) {
         echo js::alert('You Hava Delete All the Database Related To This Plugin!!!\\nPlease delete this plugin!');
         die(js::locate(helper::createLink('extension', 'browse'), 'parent'));
     }
     //此处有一个历史遗留问题,0.3版本以前的infolib库里无type列
     $test = $this->app->dbh->query('desc ' . TABLE_INFOLIB . ' type')->fetch(PDO::FETCH_OBJ);
     //print $test->Field.'<br />';
     if (!$test->Field) {
         $infolibs = $this->dao->select('id, name')->from(TABLE_INFOLIB)->where('deleted')->eq(0)->fetchPairs();
         //echo js::alert($this->lang->info->pleaseUpgrade);
     } else {
         $infolibs = $this->dao->select('id, name')->from(TABLE_INFOLIB)->where('deleted')->eq(0)->andWhere('type')->eq($type)->fetchPairs();
     }
     //		while (list($key, $val) = each($test)) {
     //			echo "$key => $val\n";
     //		}
     return $infolibs;
 }
Пример #15
0
 /**
  * Build query
  * 
  * @access public
  * @return void
  */
 public function buildQuery($queryID = '')
 {
     if ($queryID) {
         $query = $this->search->getQuery($queryID);
         if ($query) {
             $this->session->set($query->module . 'Query', $query->sql);
             $this->session->set($query->module . 'Form', $query->form);
             $this->session->set('queryID', $queryID);
             if (!empty($query->form['actionURL'])) {
                 die(js::locate($query->form['actionURL']));
             } else {
                 die(js::locate('back'));
             }
         } else {
             die(js::locate('back'));
         }
     }
     $this->search->buildQuery();
     die(js::locate($this->post->actionURL, 'parent'));
 }
Пример #16
0
 /**
  * Bind zentao.
  * 
  * @access public
  * @return void
  */
 public function bind()
 {
     if ($_POST) {
         $response = $this->admin->bindByAPI();
         if ($response == 'success') {
             $this->loadModel('setting')->setItem('system.common.global.community', $this->post->account);
             echo js::alert($this->lang->admin->bind->success);
             die(js::locate(inlink('index'), 'parent'));
         } else {
             $response = json_decode($response);
             if ($response->result == 'fail') {
                 die(js::alert($response->message));
             }
         }
     }
     $this->view->title = $this->lang->admin->bind->caption;
     $this->view->position[] = $this->lang->admin->bind->caption;
     $this->view->sn = $this->config->global->sn;
     $this->display();
 }
Пример #17
0
 /**
  * Set menu. 
  * 
  * @param  array  $products 
  * @param  int    $productID 
  * @param  string $extra 
  * @access public
  * @return void
  */
 public function setMenu($products, $productID, $extra = '')
 {
     /* Has access privilege?. */
     if ($products and !isset($products[$productID]) and !$this->checkPriv($this->getById($productID))) {
         echo js::alert($this->lang->product->accessDenied);
         die(js::locate('back'));
     }
     $currentModule = $this->app->getModuleName();
     $currentMethod = $this->app->getMethodName();
     /* init currentModule and currentMethod for report and story. */
     if ($currentModule == 'story' and $currentMethod != 'create' and $currentMethod != 'batchcreate') {
         $currentModule = 'product';
     }
     if ($currentMethod == 'report') {
         $currentMethod = 'browse';
     }
     $selectHtml = $this->select($products, $productID, $currentModule, $currentMethod, $extra);
     foreach ($this->lang->product->menu as $key => $menu) {
         $replace = $key == 'list' ? $selectHtml : $productID;
         common::setMenuVars($this->lang->product->menu, $key, $replace);
     }
 }
Пример #18
0
 /**
  * The board page.
  * 
  * @param int    $boardID       the board id
  * @param int    $pageID        the current page id
  * @access public
  * @return void
  */
 public function board($boardID = 0, $pageID = 1)
 {
     $board = $this->loadModel('tree')->getByID($boardID, 'forum');
     if (!$board) {
         die(js::locate('back'));
     }
     if ($board->link) {
         helper::header301($board->link);
     }
     /* Get common threads. */
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, $this->config->forum->recPerPage, $pageID);
     $threads = $this->loadModel('thread')->getList($board->id, $orderBy = 'repliedDate_desc', $pager);
     $this->view->title = $board->name;
     $this->view->keywords = $board->keywords . '' . $this->config->site->keywords;
     $this->view->desc = strip_tags($board->desc);
     $this->view->board = $board;
     $this->view->sticks = $this->thread->getSticks($board->id);
     $this->view->threads = $threads;
     $this->view->pager = $pager;
     $this->display();
 }
Пример #19
0
 /**
  * Create an announce.
  * 
  * @param  int    $categoryID
  * @access public
  * @return void
  */
 public function create($categoryID = '')
 {
     $this->loadModel('article');
     $categories = $this->loadModel('tree')->getOptionMenu('announce', 0, $removeRoot = true);
     if (empty($categories)) {
         die(js::locate($this->createLink('tree', 'redirect', "type=announce")));
     }
     if ($_POST) {
         $announceID = $this->article->create('announce');
         $actionID = $this->loadModel('action')->create('announce', $announceID, 'created');
         $users = $this->loadModel('user')->getPairs('nodeleted,noclosed,noempty');
         $this->loadModel('action')->sendNotice($actionID, array_keys($users), true);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('announce', 'browse')));
     }
     unset($this->lang->announce->menu);
     $this->view->title = $this->lang->announce->create;
     $this->view->currentCategory = $categoryID;
     $this->view->categories = $this->loadModel('tree')->getOptionMenu('announce', 0, $removeRoot = true);
     $this->display();
 }
Пример #20
0
 /**
  * Delete a product.
  * 
  * @param  int    $productID 
  * @param  string $confirm    yes|no
  * @access public
  * @return void
  */
 public function delete($productID, $confirm = 'no')
 {
     if ($confirm == 'no') {
         die(js::confirm($this->lang->product->confirmDelete, $this->createLink('product', 'delete', "productID={$productID}&confirm=yes")));
     } else {
         $this->product->delete(TABLE_PRODUCT, $productID);
         $this->session->set('product', '');
         // 清除session。
         die(js::locate($this->createLink('product', 'browse'), 'parent'));
     }
 }
Пример #21
0
 /**
  * Index 
  * 
  * @access public
  * @return void
  */
 public function index()
 {
     die(js::locate(inlink('set')));
 }
Пример #22
0
 /**
  * batch unlink story.
  * 
  * @param  int    $projectID 
  * @access public
  * @return void
  */
 public function batchUnlinkStory($projectID)
 {
     if (isset($_POST['storyIDList'])) {
         foreach ($this->post->storyIDList as $storyID) {
             $this->project->unlinkStory($projectID, $storyID);
         }
     }
     die(js::locate($this->createLink('project', 'story', "projectID={$projectID}")));
 }
Пример #23
0
 /**
  * Batch change the stage of story.
  * 
  * @param  string    $stage 
  * @access public
  * @return void
  */
 public function batchChangeStage($stage)
 {
     $storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
     $allChanges = $this->story->batchChangeStage($storyIDList, $stage);
     if (dao::isError()) {
         die(js::error(dao::getError()));
     }
     foreach ($allChanges as $storyID => $changes) {
         $actionID = $this->action->create('story', $storyID, 'Edited');
         $this->action->logHistory($actionID, $changes);
         $this->sendmail($storyID, $actionID);
     }
     die(js::locate($this->session->storyList, 'parent'));
 }
 public function editplan($todoID)
 {
     if (!empty($_POST)) {
         $changes = $this->todo->update($todoID);
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         if ($changes) {
             $actionID = $this->loadModel('action')->create('todo', $todoID, 'edited');
             $this->action->logHistory($actionID, $changes);
         }
         die(js::locate(inlink('view', "todoID={$todoID}"), 'parent'));
     }
     /* Judge a private todo or not, If private, die. */
     $todo = $this->todo->getById($todoID);
     if ($todo->private and $this->app->user->account != $todo->account) {
         die('private');
     }
     $header['title'] = $this->lang->my->common . $this->lang->colon . $this->lang->todo->edit;
     $position[] = $this->lang->todo->edit;
     $this->view->header = $header;
     $this->view->position = $position;
     $this->view->times = $this->todo->buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
     $this->view->todo = $todo;
     $this->display();
 }
Пример #25
0
 /**
  * Batch unlink story. 
  * 
  * @param  int $releaseID 
  * @access public
  * @return void
  */
 public function batchUnlinkBug($releaseID)
 {
     $this->release->batchUnlinkBug($releaseID);
     die(js::locate($this->createLink('release', 'view', "releaseID={$releaseID}&type=bug"), 'parent'));
 }
Пример #26
0
 /**
  * Edit a product.
  * 
  * @param  int $productID 
  * @access public
  * @return void
  */
 public function edit($productID)
 {
     $categories = $this->loadModel('tree')->getOptionMenu('product', 0, $removeRoot = true);
     if (empty($categories)) {
         die(js::alert($this->lang->tree->noCategories) . js::locate($this->createLink('tree', 'browse', 'type=product')));
     }
     if ($_POST) {
         $this->product->update($productID);
         if (dao::isError()) {
             $this->send(array('result' => 'fail', 'message' => dao::getError()));
         }
         $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('admin')));
     }
     $product = $this->product->getByID($productID);
     if (empty($product->attributes)) {
         $attribute = new stdclass();
         $attribute->order = 0;
         $attribute->label = '';
         $attribute->value = '';
         $product->attributes = array($attribute);
     }
     $this->view->title = $this->lang->product->edit;
     $this->view->product = $product;
     $this->view->categories = $categories;
     $this->display();
 }
Пример #27
0
 /**
  * Delete a todo.
  * 
  * @param  int    $todoID 
  * @param  string $confirm yes|no
  * @access public
  * @return void
  */
 public function delete($todoID, $confirm = 'no')
 {
     if ($confirm == 'no') {
         echo js::confirm($this->lang->todo->confirmDelete, $this->createLink('todo', 'delete', "todoID={$todoID}&confirm=yes"));
         exit;
     } else {
         $this->dao->delete()->from(TABLE_TODO)->where('id')->eq($todoID)->exec();
         $this->loadModel('action')->create('todo', $todoID, 'erased');
         /* if ajax request, send result. */
         if ($this->server->ajax) {
             if (dao::isError()) {
                 $response['result'] = 'fail';
                 $response['message'] = dao::getError();
             } else {
                 $response['result'] = 'success';
                 $response['message'] = '';
             }
             $this->send($response);
         }
         die(js::locate($this->session->todoList, 'parent'));
     }
 }
Пример #28
0
 /**
  * View a thread.
  * 
  * @param  int    $threadID 
  * @param  int    $pageID 
  * @access public
  * @return void
  */
 public function view($threadID, $pageID = 1)
 {
     $thread = $this->thread->getByID($threadID);
     if (!$thread) {
         die(js::locate('back'));
     }
     if ($thread->link) {
         $this->thread->plusCounter($threadID);
         helper::header301($thread->link);
     }
     /* Set editor for current user. */
     $this->thread->setEditor($thread->board, 'view');
     /* Get thread board. */
     $board = $this->loadModel('tree')->getById($thread->board);
     /* Get replies. */
     $this->app->loadConfig('reply');
     $this->app->loadClass('pager', $static = true);
     $pager = new pager(0, $this->config->reply->recPerPage, $pageID);
     $replies = $this->loadModel('reply')->getByThread($threadID, $pager);
     /* Get all speakers. */
     $speakers = $this->thread->getSpeakers($thread, $replies);
     $speakers = $this->loadModel('user')->getBasicInfo($speakers);
     foreach ($speakers as $account => $speaker) {
         $speaker->isModerator = strpos(",{$board->moderators},", ",{$account},") !== false;
     }
     /* Set the views counter + 1; */
     $this->thread->plusCounter($threadID);
     $this->view->title = $thread->title . $this->lang->minus . $board->name;
     $this->view->board = $board;
     $this->view->thread = $thread;
     $this->view->replies = $replies;
     $this->view->pager = $pager;
     $this->view->speakers = $speakers;
     $this->display();
 }
Пример #29
0
 /**
  * Undelete a record.
  * 
  * @param  int      $actionID 
  * @access public
  * @return void
  */
 public function undelete($actionID)
 {
     $action = $this->getById($actionID);
     if ($action->action != 'deleted') {
         return;
     }
     if ($action->objectType == 'product') {
         $product = $this->dao->select('name,code')->from(TABLE_PRODUCT)->where('id')->eq($action->objectID)->fetch();
         $count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PRODUCT)->where('name')->eq($product->name)->orWhere('code')->eq($product->code)->fetch('count');
         if ($count > 0) {
             echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['product']));
             die(js::locate(helper::createLink('product', 'edit', "productID={$action->objectID}&action=undelete&extra={$actionID}"), 'parent'));
         }
     } elseif ($action->objectType == 'project') {
         $project = $this->dao->select('name,code')->from(TABLE_PROJECT)->where('id')->eq($action->objectID)->fetch();
         $count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PROJECT)->where('name')->eq($project->name)->orWhere('code')->eq($project->code)->fetch('count');
         if ($count > 0) {
             echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['project']));
             die(js::locate(helper::createLink('project', 'edit', "projectID={$action->objectID}&action=undelete&extra={$actionID}"), 'parent'));
         }
     }
     /* Update deleted field in object table. */
     $table = $this->config->objectTables[$action->objectType];
     $this->dao->update($table)->set('deleted')->eq(0)->where('id')->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');
 }
Пример #30
0
 /**
  * Delete a contact list.
  * 
  * @param  int    $listID 
  * @param  string $confirm 
  * @access public
  * @return void
  */
 public function deleteContacts($listID, $confirm = 'no')
 {
     if ($confirm == 'no') {
         echo js::confirm($this->lang->user->contacts->confirmDelete, inlink('deleteContacts', "listID={$listID}&confirm=yes"));
         exit;
     } else {
         $this->user->deleteContactList($listID);
         echo js::locate(inlink('manageContacts'), 'parent');
         exit;
     }
 }