diff --git a/module/sso/control.php b/module/sso/control.php index 6873a2bad4..0d90bc44ff 100644 --- a/module/sso/control.php +++ b/module/sso/control.php @@ -183,4 +183,61 @@ class sso extends control $this->view->data = $ssoData; $this->display(); } + + /** + * Get pairs of user. + * + * @access public + * @return void + */ + public function getUserPairs() + { + $users = $this->loadModel('user')->getPairs('noclosed,nodeleted'); + die(json_encode($users)); + } + + /** + * Get bind users with ranzhi. + * + * @access public + * @return void + */ + public function getBindUsers() + { + $users = $this->sso->getBindUsers(); + die(json_encode($users)); + } + + /** + * Bind user from ranzhi. + * + * @access public + * @return void + */ + public function bindUser() + { + if($_POST) + { + $this->dao->update(TABLE_USER)->set('ranzhi')->eq('')->where('ranzhi')->eq($this->post->ranzhiAccount)->exec(); + $this->dao->update(TABLE_USER)->set('ranzhi')->eq($this->post->ranzhiAccount)->where('account')->eq($this->post->zentaoAccount)->exec(); + if(dao::isError()) die(dao::getError()); + die('success'); + } + } + + /** + * Create user from ranzhi. + * + * @access public + * @return void + */ + public function createUser() + { + if($_POST) + { + $result = $this->sso->createUser(); + if($result['status'] != 'success') die($result['data']); + die('success'); + } + } } diff --git a/module/sso/model.php b/module/sso/model.php index 8ca975c34b..d34a334f8b 100644 --- a/module/sso/model.php +++ b/module/sso/model.php @@ -26,6 +26,17 @@ class ssoModel extends model return $this->dao->select('*')->from(TABLE_USER)->where('bindRanzhi')->eq($user)->andWhere('deleted')->eq('0')->fetch(); } + /** + * Get bind users with ranzhi. + * + * @access public + * @return array + */ + public function getBindUsers() + { + return $this->dao->select('account,ranzhi')->from(TABLE_USER)->where('ranzhi')->ne('')->andWhere('deleted')->eq('0')->fetchPairs('ranzhi', 'account'); + } + /** * Bind user. * @@ -75,4 +86,28 @@ class ssoModel extends model return $user; } + + /** + * Create a user from ranzhi. + * + * @access public + * @return void + */ + public function createUser() + { + $user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($this->post->account)->fetch(); + if($user) return array('status' => 'fail', 'data' => $this->lang->sso->bindHasAccount); + + $user = new stdclass(); + $user->account = $this->post->account; + $user->realname = $this->post->realname; + $user->email = $this->post->email; + $user->gender = $this->post->gender; + $user->ranzhi = $this->post->account; + + $this->dao->insert(TABLE_USER)->data($user)->autoCheck()->exec(); + + if(dao::isError()) return array('status' => 'fail', 'data' => dao::getError()); + return array('status' => 'success'); + } } diff --git a/module/story/control.php b/module/story/control.php index d7d13be58d..e2ac4458ee 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -253,6 +253,7 @@ class story extends control $this->view->position[] = $this->lang->story->common; $this->view->position[] = $this->lang->story->batchCreate; $this->view->products = $products; + $this->view->product = $product; $this->view->moduleID = $moduleID; $this->view->moduleOptionMenu = $moduleOptionMenu; $this->view->plans = $plans; @@ -264,6 +265,7 @@ class story extends control $this->view->storyTitle = $title; $this->view->spec = $spec; $this->view->branch = $branch; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts($productID); $this->display(); } diff --git a/module/story/view/batchcreate.html.php b/module/story/view/batchcreate.html.php index 0b082f2a6c..450779ef0c 100644 --- a/module/story/view/batchcreate.html.php +++ b/module/story/view/batchcreate.html.php @@ -14,7 +14,11 @@
icons['story']);?> - icons['batchCreate']);?> story->batchCreate;?> + + icons['batchCreate']);?> + story->batchCreate;?> + type !== 'normal') echo '' . $branchGroups[$productID][$branch] . '';?> +
createLink('file', 'uploadImages', 'module=story¶ms=' . helper::safe64Encode("productID=$productID&moduleID=$moduleID")), $lang->uploadImages, '', "data-toggle='modal' data-type='iframe' class='btn' data-width='600px'")?> pasteText, "data-toggle='myModal'")?>