Merge branch 'master' of github.com:easysoft/zentaopms

This commit is contained in:
wangyidong
2015-11-11 11:08:38 +08:00
4 changed files with 99 additions and 1 deletions
+57
View File
@@ -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');
}
}
}
+35
View File
@@ -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');
}
}
+2
View File
@@ -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();
}
+5 -1
View File
@@ -14,7 +14,11 @@
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['story']);?></span>
<strong><small class='text-muted'><?php echo html::icon($lang->icons['batchCreate']);?></small> <?php echo $lang->story->batchCreate;?></strong>
<strong>
<small class='text-muted'><?php echo html::icon($lang->icons['batchCreate']);?></small>
<?php echo $lang->story->batchCreate;?>
<?php if($product->type !== 'normal') echo '<span class="label label-danger">' . $branchGroups[$productID][$branch] . '</span>';?>
</strong>
<div class='actions'>
<?php if(common::hasPriv('file', 'uploadImages')) echo html::a($this->createLink('file', 'uploadImages', 'module=story&params=' . helper::safe64Encode("productID=$productID&moduleID=$moduleID")), $lang->uploadImages, '', "data-toggle='modal' data-type='iframe' class='btn' data-width='600px'")?>
<?php echo html::commonButton($lang->pasteText, "data-toggle='myModal'")?>