+ add the feature to manage user contacts.
This commit is contained in:
@@ -86,6 +86,7 @@ define('TABLE_GROUP', '`' . $config->db->prefix . 'group`');
|
||||
define('TABLE_GROUPPRIV', '`' . $config->db->prefix . 'groupPriv`');
|
||||
define('TABLE_USERGROUP', '`' . $config->db->prefix . 'userGroup`');
|
||||
define('TABLE_USERQUERY', '`' . $config->db->prefix . 'userQuery`');
|
||||
define('TABLE_USERCONTACT', '`' . $config->db->prefix . 'userContact`');
|
||||
|
||||
define('TABLE_BUG', '`' . $config->db->prefix . 'bug`');
|
||||
define('TABLE_CASE', '`' . $config->db->prefix . 'case`');
|
||||
|
||||
@@ -4,3 +4,12 @@ ALTER TABLE `zt_product` CHANGE `QM` `QD` VARCHAR( 30 ) CHARACTER SET utf8 COLLA
|
||||
ALTER TABLE `zt_project` CHANGE `QM` `QD` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '',
|
||||
CHANGE `RM` `RD` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';
|
||||
ALTER TABLE `zt_product` CHANGE `RM` `RD` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `zt_userContact` (
|
||||
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`company` mediumint(8) unsigned NOT NULL,
|
||||
`account` char(30) NOT NULL,
|
||||
`listName` varchar(60) NOT NULL,
|
||||
`userList` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
function batchEdit()
|
||||
{
|
||||
$('#userListForm').attr('action', createLink('user', 'batchEdit', 'dept=' + deptID));
|
||||
}
|
||||
function manageContacts()
|
||||
{
|
||||
$('#userListForm').attr('action', createLink('user', 'manageContacts'));
|
||||
}
|
||||
@@ -14,10 +14,9 @@
|
||||
include '../../common/view/header.html.php';
|
||||
include '../../common/view/treeview.html.php';
|
||||
?>
|
||||
<script>deptID = <?php echo $deptID;?></script>
|
||||
<table class='cont-lt1'>
|
||||
<tr>
|
||||
<td colspan='3'><div id='querybox'><?php echo $searchForm?></div></td>
|
||||
</tr>
|
||||
<tr><td colspan='3'><div id='querybox'><?php echo $searchForm?></div></td></tr>
|
||||
<tr valign='top'>
|
||||
<td class='side'>
|
||||
<div class='box-title'><?php echo $lang->dept->common;?></div>
|
||||
@@ -52,10 +51,10 @@ include '../../common/view/treeview.html.php';
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<form action='<?php echo $this->createLink('user', 'batchEdit', "deptID=$deptID")?>' method='post'>
|
||||
<form action='<?php echo $this->createLink('user', 'batchEdit', "deptID=$deptID")?>' method='post' id='userListForm'>
|
||||
<?php foreach($users as $user):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo "<input type='checkbox' name='userIDList[]' value='$user->id'> "; printf('%03d', $user->id);?></td>
|
||||
<td><?php echo "<input type='checkbox' name='users[]' value='$user->account'> "; printf('%03d', $user->id);?></td>
|
||||
<td><?php if(!common::printLink('user', 'view', "account=$user->account", $user->realname)) echo $user->realname;?></td>
|
||||
<td><?php echo $user->account;?></td>
|
||||
<td><?php echo $lang->user->roleList[$user->role];?></td>
|
||||
@@ -80,7 +79,8 @@ include '../../common/view/treeview.html.php';
|
||||
<td colspan='11'>
|
||||
<?php
|
||||
echo html::selectAll() . html::selectReverse();
|
||||
echo html::submitButton($lang->user->batchEdit);
|
||||
echo html::submitButton($lang->user->batchEdit, 'onclick=batchEdit()');
|
||||
echo html::submitButton($lang->user->contacts->manage, 'onclick=manageContacts()');
|
||||
$pager->show();
|
||||
?>
|
||||
</td>
|
||||
@@ -90,5 +90,5 @@ include '../../common/view/treeview.html.php';
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script lanugage='Javascript'>$('#dept<?php echo $deptID;?>').addClass('active');</script>
|
||||
<script lanugage='javascript'>$('#dept<?php echo $deptID;?>').addClass('active');</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
+82
-3
@@ -342,9 +342,9 @@ class user extends control
|
||||
*/
|
||||
public function batchEdit($deptID = 0)
|
||||
{
|
||||
if(isset($_POST['userIDList']))
|
||||
if(isset($_POST['users']))
|
||||
{
|
||||
$this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('id')->in($this->post->userIDList)->orderBy('id')->fetchAll('id');
|
||||
$this->view->users = $this->dao->select('*')->from(TABLE_USER)->where('account')->in($this->post->users)->orderBy('id')->fetchAll('id');
|
||||
}
|
||||
elseif($_POST)
|
||||
{
|
||||
@@ -624,6 +624,86 @@ class user extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage contacts.
|
||||
*
|
||||
* @param int $listID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function manageContacts($listID = 0)
|
||||
{
|
||||
$lists = $this->user->getContactLists($this->app->user->account);
|
||||
|
||||
/* If set $mode, need to update database. */
|
||||
if($this->post->mode)
|
||||
{
|
||||
/* The mode is new: append or new a list. */
|
||||
if($this->post->mode == 'new')
|
||||
{
|
||||
if($this->post->list2Append)
|
||||
{
|
||||
$this->user->append2ContactList($this->post->list2Append, $this->post->users);
|
||||
die(js::locate(inlink('manageContacts', "listID={$this->post->list2Append}"), 'parent'));
|
||||
}
|
||||
elseif($this->post->newList)
|
||||
{
|
||||
$listID = $this->user->createContactList($this->post->newList, $this->post->users);
|
||||
die(js::locate(inlink('manageContacts', "listID=$listID"), 'parent'));
|
||||
}
|
||||
}
|
||||
elseif($this->post->mode == 'edit')
|
||||
{
|
||||
$this->user->updateContactList($this->post->listID, $this->post->listName, $this->post->users);
|
||||
die(js::locate(inlink('manageContacts', "listID={$this->post->listID}"), 'parent'));
|
||||
}
|
||||
}
|
||||
if($this->post->users)
|
||||
{
|
||||
$mode = 'new';
|
||||
$users = $this->user->getContactUserPairs($this->post->users);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mode = 'edit';
|
||||
$listID= $listID ? $listID : key($lists);
|
||||
if(!$listID) die(js::alert($this->lang->user->contacts->noListYet) . js::locate($this->createLink('company', 'browse'), 'parent'));
|
||||
|
||||
$list = $this->user->getContactListByID($listID);
|
||||
$users = explode(',', $list->userList);
|
||||
$users = $this->user->getContactUserPairs($users);
|
||||
$this->view->list = $list;
|
||||
}
|
||||
|
||||
$this->view->lists = $this->user->getContactLists($this->app->user->account);
|
||||
$this->view->users = $users;
|
||||
$this->view->mode = $mode;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user for ajax
|
||||
*
|
||||
@@ -641,5 +721,4 @@ class user extends control
|
||||
$html .= '</form>';
|
||||
echo $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.userSpan{display:block; width:100px; float:left}
|
||||
@@ -46,6 +46,7 @@ $lang->user->create = "Add";
|
||||
$lang->user->batchCreate = "Batch add user";
|
||||
$lang->user->read = "Info";
|
||||
$lang->user->edit = "Edit";
|
||||
$lang->user->batchEdit = "Batch Edit";
|
||||
$lang->user->unlock = "Unlock";
|
||||
$lang->user->update = "Upgrade";
|
||||
$lang->user->delete = "Delete";
|
||||
@@ -114,3 +115,18 @@ $lang->user->error->realname = "ID %s,please input realname";
|
||||
$lang->user->error->password = "ID %s,password must be six letters at least";
|
||||
$lang->user->error->mail = "ID %s,please input correct email address";
|
||||
$lang->user->error->role = "ID %s,please input role";
|
||||
|
||||
$lang->user->contacts = new stdclass();
|
||||
$lang->user->contacts->common = 'Contacts';
|
||||
$lang->user->contacts->listName = 'List name';
|
||||
$lang->user->contacts->userList = 'User list';
|
||||
|
||||
$lang->user->contacts->manage = 'Manage List';
|
||||
$lang->user->contacts->contactsList = 'List';
|
||||
$lang->user->contacts->selectedUsers= 'Users';
|
||||
$lang->user->contacts->selectList = 'List';
|
||||
$lang->user->contacts->appendToList = 'Append to a list';
|
||||
$lang->user->contacts->createList = 'Createa a list';
|
||||
$lang->user->contacts->noListYet = 'No contacts list yet.';
|
||||
$lang->user->contacts->confirmDelete= 'Are you sure to delete this list?';
|
||||
$lang->user->contacts->or = ' or ';
|
||||
|
||||
@@ -117,9 +117,16 @@ $lang->user->error->mail = "ID %s,请填写正确的邮箱地址";
|
||||
$lang->user->error->role = "ID %s,角色不能为空";
|
||||
|
||||
$lang->user->contacts = new stdclass();
|
||||
$lang->user->contacts->common = '联系人';
|
||||
$lang->user->contacts->id = '编号';
|
||||
$lang->user->contacts->company = '所属公司';
|
||||
$lang->user->contacts->account = '所有人';
|
||||
$lang->user->contacts->group = '列表名称';
|
||||
$lang->user->contacts->contacts= '联系人列表';
|
||||
$lang->user->contacts->common = '联系人';
|
||||
$lang->user->contacts->listName = '列表名称';
|
||||
$lang->user->contacts->userList = '联系人列表';
|
||||
|
||||
$lang->user->contacts->manage = '维护列表';
|
||||
$lang->user->contacts->contactsList = '已有列表';
|
||||
$lang->user->contacts->selectedUsers= '选择用户';
|
||||
$lang->user->contacts->selectList = '选择列表';
|
||||
$lang->user->contacts->appendToList = '追加至已有列表:';
|
||||
$lang->user->contacts->createList = '创建新列表:';
|
||||
$lang->user->contacts->noListYet = '还没有创建任何列表。';
|
||||
$lang->user->contacts->confirmDelete= '您确定要删除这个列表吗?';
|
||||
$lang->user->contacts->or = ' 或者 ';
|
||||
|
||||
+105
-1
@@ -236,7 +236,6 @@ class userModel extends model
|
||||
if($users->realname[$i] == '') die(js::error(sprintf($this->lang->user->error->realname, $i+1)));
|
||||
if($users->email[$i] and !validater::checkEmail($users->email[$i])) die(js::error(sprintf($this->lang->user->error->mail, $i+1)));
|
||||
$users->password[$i] = (isset($prev['password']) and $users->ditto[$i] == 'on' and empty($users->password[$i])) ? $prev['password'] : $users->password[$i];
|
||||
a($users->password[$i]);
|
||||
if(!validater::checkReg($users->password[$i], '|(.){6,}|')) die(js::error(sprintf($this->lang->user->error->password, $i+1)));
|
||||
if(empty($users->role[$i])) die(js::error(sprintf($this->lang->user->error->role, $id)));
|
||||
|
||||
@@ -649,4 +648,109 @@ class userModel extends model
|
||||
{
|
||||
$this->dao->update(TABLE_USER)->set('fails')->eq(0)->set('locked')->eq('0000-00-00 00:00:00')->where('account')->eq($account)->exec(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contact list of a user.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getContactLists($account)
|
||||
{
|
||||
return $this->dao->select('id, listName')->from(TABLE_USERCONTACT)->where('account')->eq($account)->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a contact list by id.
|
||||
*
|
||||
* @param int $listID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getContactListByID($listID)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_USERCONTACT)->where('id')->eq($listID)->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user account and realname pairs from a contact list.
|
||||
*
|
||||
* @param string $accountList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getContactUserPairs($accountList)
|
||||
{
|
||||
return $this->dao->select('account, realname')->from(TABLE_USER)->where('account')->in($accountList)->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a contact list.
|
||||
*
|
||||
* @param string $listName
|
||||
* @param string $userList
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function createContactList($listName, $userList)
|
||||
{
|
||||
$data = new stdclass();
|
||||
$data->listName = $listName;
|
||||
$data->userList = join(',', $userList);
|
||||
$data->account = $this->app->user->account;
|
||||
|
||||
$this->dao->insert(TABLE_USERCONTACT)->data($data)->exec();
|
||||
return $this->dao->lastInsertID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Append some users to a contact list.
|
||||
*
|
||||
* @param int $listID
|
||||
* @param string $userList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function append2ContactList($listID, $userList)
|
||||
{
|
||||
$list = $this->getContactListByID($listID);
|
||||
if($list->userList) $userList = array_merge($userList, explode(',', $list->userList));
|
||||
|
||||
$userList = array_unique($userList);
|
||||
sort($userList);
|
||||
$userList = join(',', $userList);
|
||||
|
||||
$this->dao->update(TABLE_USERCONTACT)->set('userList')->eq($userList)->where('id')->eq($listID)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a contact list.
|
||||
*
|
||||
* @param int $listID
|
||||
* @param string $listName
|
||||
* @param string $userList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updateContactList($listID, $listName, $userList)
|
||||
{
|
||||
$data = new stdclass();
|
||||
$data->listName = $listName;
|
||||
$data->userList = join(',', $userList);
|
||||
|
||||
$this->dao->update(TABLE_USERCONTACT)->data($data)->where('id')->eq($listID)->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a contact list.
|
||||
*
|
||||
* @param int $listID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteContactList($listID)
|
||||
{
|
||||
return $this->dao->delete()->from(TABLE_USERCONTACT)->where('id')->eq($listID)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* The contacts manage page of user module.
|
||||
*
|
||||
* @copyright Copyright 2009-2012 青岛易软天创网络科技有限公司 (QingDao Nature Easy Soft Network Technology Co,LTD www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author chunsheng wang <chunsheng@cnezsoft.com>
|
||||
* @package user
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<table class='cont-lt1'>
|
||||
<tr valign='top'>
|
||||
<td class='side'>
|
||||
<div class='box-title'><?php echo $lang->user->contacts->contactsList;?></div>
|
||||
<div class='box-content'>
|
||||
<?php
|
||||
foreach($lists as $listID => $listName) echo html::a(inlink('managecontacts', "listID=$listID"), $listName) . '<br />';
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
<td class=='divider'></td>
|
||||
<td>
|
||||
<form method='post' target='hiddenwin' id='dataform' style='margin:0 0 0 10px; padding:0'>
|
||||
<div class='box-title' style='height:15px'>
|
||||
<div class='f-left'><?php echo $lang->user->contacts->manage;?></div>
|
||||
<div class='f-right'><?php if($mode == 'edit') echo html::a(inlink('deleteContacts', "listID=$listID"), $lang->delete, 'hiddenwin');?></div>
|
||||
</div>
|
||||
<table class='table-1 fixed'>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->user->contacts->selectedUsers;?></th>
|
||||
<td>
|
||||
<?php
|
||||
foreach($this->view->users as $account => $realname)
|
||||
{
|
||||
echo "<span class='userSpan'><input type='checkbox' name='users[]' value='$account' checked='checked'>$realname</span>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class='rowhead'><?php $mode == 'new' ? print($lang->user->contacts->selectList) : print($lang->user->contacts->listName);?></th>
|
||||
<td>
|
||||
<?php
|
||||
if($mode == 'new')
|
||||
{
|
||||
if($lists)
|
||||
{
|
||||
echo $lang->user->contacts->appendToList;
|
||||
echo html::select('list2Append', array('' => '') + $lists, '', "class='select-2'") . $lang->user->contacts->or;
|
||||
}
|
||||
echo $lang->user->contacts->createList;
|
||||
echo html::input('newList', '', "class='text-2'");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::input('listName', $list->listName, "class='text-2'");
|
||||
echo html::hidden('listID', $list->id);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td></td><td><?php echo html::submitButton() . html::hidden('mode', $mode);?></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user