diff --git a/xuanxuan/module/chat/ext/model/class/xuanxuan.class.php b/xuanxuan/module/chat/ext/model/class/xuanxuan.class.php index 59b02c9c66..bf4f2cc50d 100644 --- a/xuanxuan/module/chat/ext/model/class/xuanxuan.class.php +++ b/xuanxuan/module/chat/ext/model/class/xuanxuan.class.php @@ -78,19 +78,21 @@ class xuanxuanChat extends chatModel $this->session->set('user', $user); $this->app->user = $this->session->user; - $products = explode(',', $this->app->user->view->products); - $projects = explode(',', $this->app->user->view->projects); - $libids = array_keys($this->loadModel('doc')->getLibs('all')); - $productID = isset($products[0]) ? $products[0] : 1; - $projectID = isset($projects[0]) ? $projects[0] : 1; - $libID = isset($libids[0]) ? $libids[0] : 1; + $products = trim($this->app->user->view->products, ','); + $projects = trim($this->app->user->view->projects, ','); + $products = empty($products) ? array() : explode(',', $products); + $projects = empty($projects) ? array() : explode(',', $projects); + $libIdList = array_keys($this->loadModel('doc')->getLibs('all')); + $productID = isset($products[0]) ? $products[0] : 1; + $projectID = isset($projects[0]) ? $projects[0] : 1; + $libID = isset($libIdList[0]) ? $libIdList[0] : 1; $actions = new stdclass(); - if(common::hasPriv('bug', 'create')) $actions->createBug = array('title' => $this->lang->chat->createBug, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('bug', 'create', "product=$productID", 'xhtml')), 'height' => "600px", 'width' => "800px"); - if(common::hasPriv('doc', 'create')) $actions->createDoc = array('title' => $this->lang->chat->createDoc, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('doc', 'create', "libID=$libID", 'xhtml')), 'height' => "600px", 'width' => "800px"); - if(common::hasPriv('story', 'create')) $actions->createStory = array('title' => $this->lang->chat->createStory, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('story', 'create', "product=$productID", 'xhtml')), 'height' => "600px", 'width' => "800px"); - if(common::hasPriv('task', 'create')) $actions->createTask = array('title' => $this->lang->chat->createTask, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('task', 'create', "project=$projectID", 'xhtml')), 'height' => "600px", 'width' => "800px"); - if(common::hasPriv('todo', 'create')) $actions->createTodo = array('title' => $this->lang->chat->createTodo, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('todo', 'create', '', 'xhtml')), 'height' => "600px", 'width' => "800px"); + if(common::hasPriv('bug', 'create') and !empty($products)) $actions->createBug = array('title' => $this->lang->chat->createBug, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('bug', 'create', "product=$productID", 'xhtml')), 'height' => "600px", 'width' => "800px"); + if(common::hasPriv('doc', 'create') and !empty($libIdList))$actions->createDoc = array('title' => $this->lang->chat->createDoc, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('doc', 'create', "libID=$libID", 'xhtml')), 'height' => "600px", 'width' => "800px"); + if(common::hasPriv('story', 'create') and !empty($products)) $actions->createStory = array('title' => $this->lang->chat->createStory, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('story', 'create', "product=$productID", 'xhtml')), 'height' => "600px", 'width' => "800px"); + if(common::hasPriv('task', 'create') and !empty($projects)) $actions->createTask = array('title' => $this->lang->chat->createTask, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('task', 'create', "project=$projectID", 'xhtml')), 'height' => "600px", 'width' => "800px"); + if(common::hasPriv('todo', 'create')) $actions->createTodo = array('title' => $this->lang->chat->createTodo, 'url' => $baseURL . str_replace('/xuanxuan.php', '/index.php', helper::createLink('todo', 'create', '', 'xhtml')), 'height' => "600px", 'width' => "800px"); $urls = array(); foreach($this->config->chat->cards as $moduleName => $methods)