diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 7e86d2bac8..fd5f308979 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -159,6 +159,7 @@ $lang->my->menu->myProject = "{$lang->projectCommon}|my|project|"; $lang->my->menu->dynamic = 'Dynamic|my|dynamic|'; $lang->my->menu->profile = array('link' => 'Profile|my|profile|', 'alias' => 'editprofile'); $lang->my->menu->changePassword = 'Change Password|my|changepassword|'; +$lang->my->menu->manageContacts = 'Contacts|my|managecontacts|'; $lang->todo = new stdclass(); $lang->todo->menu = $lang->my->menu; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index e5488e8488..60bf9f4314 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -159,6 +159,7 @@ $lang->my->menu->myProject = "{$lang->projectCommon}|my|project|"; $lang->my->menu->dynamic = '动态|my|dynamic|'; $lang->my->menu->profile = array('link' => '档案|my|profile', 'alias' => 'editprofile'); $lang->my->menu->changePassword = '密码|my|changepassword'; +$lang->my->menu->manageContacts = '联系人|my|managecontacts'; $lang->todo = new stdclass(); $lang->todo->menu = $lang->my->menu; diff --git a/module/my/control.php b/module/my/control.php index 8f61893d1c..3263a65b0d 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -378,6 +378,79 @@ class my extends control $this->display(); } + /** + * Manage contacts. + * + * @param int $listID + * @param string $mode + * @access public + * @return void + */ + public function manageContacts($listID = 0, $mode = '') + { + if($_POST) + { + if($this->post->mode == 'new') + { + $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')); + } + } + + $mode = empty($mode) ? 'edit' : $mode; + $lists = $this->user->getContactLists($this->app->user->account); + + /* Create or manage list according to mode. */ + if($mode == 'new') + { + $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->user->contacts->createList; + $this->view->position[] = $this->lang->user->contacts->createList; + } + else + { + $listID = $listID ? $listID : key($lists); + if(!$listID) die(js::alert($this->lang->user->contacts->noListYet) . js::locate($this->createLink('my', 'managecontacts', "listID=0&mode=new"), 'parent')); + + $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->user->contacts->manage; + $this->view->position[] = $this->lang->user->contacts->manage; + $this->view->list = $this->user->getContactListByID($listID); + } + + $this->view->mode = $mode; + $this->view->lists = $lists; + $this->view->listID = $listID; + $this->view->users = $this->user->getPairs('noletter|nodeleted|noempty|noclosed'); + $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; + } + } + /** * View my profile. * diff --git a/module/my/css/managecontacts.css b/module/my/css/managecontacts.css new file mode 100644 index 0000000000..f59739052c --- /dev/null +++ b/module/my/css/managecontacts.css @@ -0,0 +1,4 @@ +.panel.with-list {border: none} +.panel.with-list .panel-heading {border: 1px solid #ddd; border-bottom: none} +.panel.with-list .list-group {margin: 0} +.list-group-item.active {color: #1A4F85} diff --git a/module/my/view/managecontacts.html.php b/module/my/view/managecontacts.html.php new file mode 100644 index 0000000000..999c7ca6db --- /dev/null +++ b/module/my/view/managecontacts.html.php @@ -0,0 +1,90 @@ + + * @package my + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +