Skip to content

Commit

Permalink
you can add a read-only member now
Browse files Browse the repository at this point in the history
  • Loading branch information
star7th committed Sep 10, 2016
1 parent 3275a17 commit 35189f4
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 10 deletions.
13 changes: 10 additions & 3 deletions Application/Home/Controller/BaseController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function sendResult($array){
echo json_encode($result);
}

//判断某用户是否有项目管理权限(项目成员和项目创建者
//判断某用户是否有项目管理权限(项目成员member_group_id为1,以及 项目创建者
protected function checkItemPermn($uid , $item_id){

if (!$uid) {
Expand All @@ -61,7 +61,7 @@ protected function checkItemPermn($uid , $item_id){
session("mamage_item_".$item_id , 1 );
return true;
}
$ItemMember = D("ItemMember")->where("item_id = '%d' and uid = '%d' ",array($item_id,$uid))->find();
$ItemMember = D("ItemMember")->where("item_id = '%d' and uid = '%d' and member_group_id = 1 ",array($item_id,$uid))->find();
if ($ItemMember) {
session("mamage_item_".$item_id , 1 );
return true;
Expand Down Expand Up @@ -92,7 +92,14 @@ protected function checkItemVisit($uid , $item_id){
return true;
}

if ($this->checkItemPermn($uid , $item_id)) {
if ($this->checkItemCreator($uid , $item_id)) {
session("visit_item_".$item_id , 1 );
return true;
}

$ItemMember = D("ItemMember")->where("item_id = '%d' and uid = '%d' ",array($item_id,$uid))->find();
if ($ItemMember) {
session("visit_item_".$item_id , 1 );
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion Application/Home/Controller/MemberController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function edit(){
//保存
public function save(){
$item_id = I("item_id/d");
$member_group_id = I("member_group_id/d");
$login_user = $this->checkLogin();
if (!$this->checkItemCreator($login_user['uid'] , $item_id)) {
$this->message(L('no_permissions'));
Expand All @@ -37,6 +38,7 @@ public function save(){
$data['username'] = $member['username'] ;
$data['uid'] = $member['uid'] ;
$data['item_id'] = $item_id ;
$data['member_group_id'] = $member_group_id ;
$data['addtime'] = time() ;


Expand Down Expand Up @@ -67,7 +69,7 @@ public function getList(){
}
}

//删除目录
//删除成员
public function delete(){
$item_id = I("item_id/d")? I("item_id/d") : 0;
$login_user = $this->checkLogin();
Expand Down
16 changes: 16 additions & 0 deletions Application/Home/Controller/UpdateController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ public function sqlite(){
}
}

//item_member表增加level字段
$columns = M("ItemMember")->getDbFields();
if ($columns) {
$has_it = 0 ;//是否存在该字段
foreach ($columns as $key => $value) {
if ($value == 'member_group_id') {
$has_it = 1 ;
}
}
if ($has_it === 0) {
$sql = "ALTER TABLE ".C('DB_PREFIX')."item_member ADD member_group_id INT( 1 ) NOT NULL DEFAULT '1' ;";
D("ItemMember")->execute($sql);
}
}


echo 'OK!';
}

Expand Down
2 changes: 1 addition & 1 deletion Application/Home/Lang/en-us.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
'member_list'=>'member list',
'click_to_delete'=>'Click to delete',
'close'=>'Close',

"member_group_id" => "Read-only(can read item ,but not edit or delete )",
//page
'input_page_title'=>'Please enter a page title',
'level_2_directory'=>'Second-level catalog',
Expand Down
1 change: 1 addition & 0 deletions Application/Home/Lang/zh-cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
'member_list'=>'成员列表',
'click_to_delete'=>'点击可删除',
'close'=>'关闭',
"member_group_id" => "只读(只能查看项目,不能修改/删除)",

//page
'input_page_title'=>'请输入页面标题',
Expand Down
2 changes: 1 addition & 1 deletion Application/Home/View/Common/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

DocConfig.hostUrl = DocConfig.host + "/" + DocConfig.app;
</script>
<script src="__PUBLIC__/js/lang.{:LANG_SET}.js?v=2"></script>
<script src="__PUBLIC__/js/lang.{:LANG_SET}.js?v=21"></script>
</head>
<body>
9 changes: 8 additions & 1 deletion Application/Home/View/Member/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ <h4>{$Think.Lang.new_member}</h4>
<input type="text" id="username" placeholder="{$Think.Lang.username}" value="">
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" id="member_group_id">{$Think.Lang.member_group_id}
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn" id="save-cat">{$Think.Lang.save}</button>
Expand Down Expand Up @@ -47,4 +54,4 @@ <h4>{$Think.Lang.member_list}&nbsp;<small>({$Think.Lang.click_to_delete})</s
</div>

<include file="Common/footer" />
<script src="__PUBLIC__/js/member/edit.js?v=1"></script>
<script src="__PUBLIC__/js/member/edit.js?v=12"></script>
1 change: 1 addition & 0 deletions Public/js/lang.en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ lang["delete_this_template"] = "Delete template";
lang["no_templ_msg"] = "<p><br>You have not saved any templates.<br>When you edit the page, click the 'save' button on the right click, select Save as template in the down menu .<br>When you create or edit a new page, click the 'More template' button, then you can use the template you save</p>";
lang["add_page_comments_msg"] = "Please enter the page comments.It can be page update log , or other you want.It will be showed in page history version convenient for you to check the change of page";

lang["confirm_to_delete_member"] = "Sure to delete this member ?";
1 change: 1 addition & 0 deletions Public/js/lang.zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ lang["no_templ_msg"] = "<p><br>你尚未保存过任何模板。<br>你可以在
lang["add_page_comments_msg"] = "请输入页面注释内容。可以填写你对页面的修改注释或者其它注释。添加后,在页面的历史版本处会显示每一个页面版本的注释,方便你查阅、追踪页面的修改";


lang["confirm_to_delete_member"] = "确认要删除该成员?";
7 changes: 5 additions & 2 deletions Public/js/member/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ $(function(){
//保存
$("#save-cat").click(function(){
var username = $("#username").val();
var member_group_id = $("#member_group_id").is(':checked') ? 0 : 1 ;
$.post(
"?s=/home/member/save",
{"username": username ,"item_id": item_id },
{"username": username ,"item_id": item_id,"member_group_id": member_group_id },
function(data){
if (data.error_code == 0) {
$("#username").val('');
Expand All @@ -56,7 +57,9 @@ $(function(){
//删除
$('#show-cat').delegate('.single-cat','click', function(){
var username = $(this).attr("data-username");

if (!confirm(lang['confirm_to_delete_member'])) {
return false;
}
if (username) {
$.post(
"?s=/home/member/delete",
Expand Down
Binary file modified Sqlite/showdoc.db.php
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "ShowDoc is a tool greatly applicable for an IT team to share documents online",
"keywords": ["showdoc","documents","Api"],
"homepage": "https://github.com/star7th/showdoc",
"version":"v1.0.4",
"version":"v1.0.5",
"license": "Apache-2.0",
"authors": [
{
Expand Down

0 comments on commit 35189f4

Please sign in to comment.