aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-08-11 01:48:43 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-08-11 01:48:43 -0700
commitf4e634ad526198cc5c79e74d77b19c8a1b518942 (patch)
tree03af04ec04e2953cd3760333fc0c42fce4a0f352
parenteb6b2677cb214b018f95e621e3fcdce7e49c2d95 (diff)
downloadvolse-hubzilla-f4e634ad526198cc5c79e74d77b19c8a1b518942.tar.gz
volse-hubzilla-f4e634ad526198cc5c79e74d77b19c8a1b518942.tar.bz2
volse-hubzilla-f4e634ad526198cc5c79e74d77b19c8a1b518942.zip
group drop
-rw-r--r--database.sql1
-rw-r--r--include/group.php5
-rw-r--r--mod/group.php40
-rw-r--r--mod/network.php3
-rw-r--r--view/acl_selectors.php2
-rw-r--r--view/group_drop.tpl1
-rw-r--r--view/group_edit.tpl1
-rw-r--r--view/style.css4
8 files changed, 43 insertions, 14 deletions
diff --git a/database.sql b/database.sql
index eeba76f7e..f0cb98c7a 100644
--- a/database.sql
+++ b/database.sql
@@ -82,6 +82,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
CREATE TABLE IF NOT EXISTS `group` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
+ `deleted` tinyint(1) NOT NULL DEFAULT '0',
`name` char(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/include/group.php b/include/group.php
index 848db43bd..dfec4afa0 100644
--- a/include/group.php
+++ b/include/group.php
@@ -38,7 +38,7 @@ function group_rmv($uid,$name) {
);
// remove group
- $r = q("DELETE FROM `group` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ $r = q("UPDATE GROUP SET `deleted` = 1 WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($uid),
dbesc($name)
);
@@ -46,7 +46,6 @@ function group_rmv($uid,$name) {
$ret = $r;
}
- // TODO!! remove this group from all content ACL's !!
return $ret;
}
@@ -144,7 +143,7 @@ $o .= <<< EOT
EOT;
- $r = q("SELECT * FROM `group` WHERE `uid` = %d",
+ $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d",
intval($_SESSION['uid'])
);
if(count($r)) {
diff --git a/mod/group.php b/mod/group.php
index 099ae7dd3..a3bd750f9 100644
--- a/mod/group.php
+++ b/mod/group.php
@@ -15,7 +15,7 @@ function group_init(&$a) {
function group_post(&$a) {
if(! local_user()) {
- notice("Access denied." . EOL);
+ notice( t('Permission denied.') . EOL);
return;
}
@@ -23,13 +23,13 @@ function group_post(&$a) {
$name = notags(trim($_POST['groupname']));
$r = group_add($_SESSION['uid'],$name);
if($r) {
- notice("Group created." . EOL );
+ notice( t('Group created.') . EOL );
$r = group_byname($_SESSION['uid'],$name);
if($r)
goaway($a->get_baseurl() . '/group/' . $r);
}
else
- notice("Could not create group." . EOL );
+ notice( t('Could not create group.') . EOL );
goaway($a->get_baseurl() . '/group');
return; // NOTREACHED
}
@@ -39,7 +39,7 @@ function group_post(&$a) {
intval($_SESSION['uid'])
);
if(! count($r)) {
- notice("Group not found." . EOL );
+ notice( t('Group not found.') . EOL );
goaway($a->get_baseurl() . '/contacts');
}
$group = $r[0];
@@ -51,7 +51,7 @@ function group_post(&$a) {
intval($group['id'])
);
if($r)
- notice("Group name changed." . EOL );
+ notice( t('Group name changed.') . EOL );
}
$members = $_POST['group_members_select'];
array_walk($members,'validate_members');
@@ -73,7 +73,7 @@ function group_post(&$a) {
}
}
if($result)
- notice("Membership list updated." . EOL);
+ notice( t('Membership list updated.') . EOL);
$a->page['aside'] = group_side();
}
@@ -82,7 +82,7 @@ function group_post(&$a) {
function group_content(&$a) {
if(! local_user()) {
- notice("Access denied." . EOL);
+ notice( t('Permission denied') . EOL);
return;
}
@@ -94,7 +94,22 @@ function group_content(&$a) {
}
-
+ if(($a->argc == 3) && ($a->argv[1] == 'drop')) {
+ if(intval($argv[2])) {
+ $r = q("SELECT `name` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($argv[2]),
+ intval($_SESSION['uid'])
+ );
+ if(count($r))
+ $result = group_rmv($_SESSION['uid'],$r[0]['name']);
+ if($result)
+ notice( t('Group removed.') . EOL);
+ else
+ notice( t('Unable to remove group.') . EOL);
+ }
+ goaway($a->get_baseurl() . '/group');
+ return; // NOTREACHED
+ }
if(($a->argc == 2) && (intval($a->argv[1]))) {
@@ -104,7 +119,7 @@ function group_content(&$a) {
intval($_SESSION['uid'])
);
if(! count($r)) {
- notice("Group not found." . EOL );
+ notice( t("Group not found.") . EOL );
goaway($a->get_baseurl() . '/contacts');
}
$group = $r[0];
@@ -115,10 +130,17 @@ function group_content(&$a) {
$preselected[] = $p['id'];
}
+ $drop_tpl = file_get_contents('view/group_drop.tpl');
+ $drop_txt = replace_macros($drop_tpl, array(
+ '$id' => $group['id'],
+ '$delete' => t('Delete')
+ ));
+
$tpl = file_get_contents('view/group_edit.tpl');
$o .= replace_macros($tpl, array(
'$gid' => $group['id'],
'$name' => $group['name'],
+ '$drop' => $drop_txt,
'$selector' => contact_select('group_members_select','group_members_select',$preselected,25)
));
diff --git a/mod/network.php b/mod/network.php
index 17a670b93..59f826fd9 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -73,7 +73,7 @@ function network_content(&$a, $update = false) {
$sql_extra = '';
if($group) {
- $r = q("SELECT `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($group),
intval($_SESSION['uid'])
);
@@ -87,6 +87,7 @@ function network_content(&$a, $update = false) {
$contacts[] = $_SESSION['cid'];
$contact_str = implode(',',$contacts);
$sql_extra = dbesc(" AND `contact`.`id` IN ( $contact_str ) ");
+ $o = '<h4>' . t('Group: ') . $r[0]['name'] . '</h4>' . $o;
}
diff --git a/view/acl_selectors.php b/view/acl_selectors.php
index c0d3ddcd4..ac34fab3a 100644
--- a/view/acl_selectors.php
+++ b/view/acl_selectors.php
@@ -7,7 +7,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
$o .= "<select name=\"{$selname}[]\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" />\r\n";
- $r = q("SELECT * FROM `group` WHERE `uid` = %d ORDER BY `name` ASC",
+ $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC",
$_SESSION['uid']
);
diff --git a/view/group_drop.tpl b/view/group_drop.tpl
new file mode 100644
index 000000000..c87ea459f
--- /dev/null
+++ b/view/group_drop.tpl
@@ -0,0 +1 @@
+<div class="group-delete-wrapper" id="group-delete-wrapper-$id" ><a href="group/drop/$id" onclick="return confirmDelete();" ><img src="images/b_drophide.gif" alt="$delete" title="$delete" id="group-delete-icon-$id" class="group-delete-icon" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a></div><div class="group-delete-end"></div>
diff --git a/view/group_edit.tpl b/view/group_edit.tpl
index 7cfd0fe3e..e6c7afb49 100644
--- a/view/group_edit.tpl
+++ b/view/group_edit.tpl
@@ -13,6 +13,7 @@
$selector
</div>
+$drop
<div id="group_members_select_end"></div>
<div id="group-edit-submit-wrapper" >
<input type="submit" name="submit" value="Submit" >
diff --git a/view/style.css b/view/style.css
index 8b52693fa..70f6f45f9 100644
--- a/view/style.css
+++ b/view/style.css
@@ -1404,3 +1404,7 @@ input#dfrn-url {
margin-left: 200px;
}
+.group-delete-wrapper {
+ float: right;
+ margin-right: 50px;
+} \ No newline at end of file