some work on mod group

This commit is contained in:
Mario 2018-06-17 16:58:12 +02:00
parent 9e29c13678
commit 9c5df51141
11 changed files with 181 additions and 171 deletions

View File

@ -7,6 +7,17 @@ require_once('include/group.php');
class Group extends \Zotlabs\Web\Controller { class Group extends \Zotlabs\Web\Controller {
function init() {
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
\App::$profile_uid = local_channel();
nav_set_selected('Privacy Groups');
}
function post() { function post() {
if(! local_channel()) { if(! local_channel()) {
@ -22,12 +33,10 @@ class Group extends \Zotlabs\Web\Controller {
$r = group_add(local_channel(),$name,$public); $r = group_add(local_channel(),$name,$public);
if($r) { if($r) {
info( t('Privacy group created.') . EOL ); info( t('Privacy group created.') . EOL );
$r = group_byname(local_channel(),$name);
if($r)
goaway(z_root() . '/group/' . $r);
} }
else else {
notice( t('Could not create privacy group.') . EOL ); notice( t('Could not create privacy group.') . EOL );
}
goaway(z_root() . '/group'); goaway(z_root() . '/group');
} }
@ -76,29 +85,58 @@ class Group extends \Zotlabs\Web\Controller {
} }
// Switch to text mode interface if we have more than 'n' contacts or group members // Switch to text mode interface if we have more than 'n' contacts or group members
$switchtotext = get_pconfig(local_channel(),'system','groupedit_image_limit'); $switchtotext = get_pconfig(local_channel(),'system','groupedit_image_limit');
if($switchtotext === false) if($switchtotext === false)
$switchtotext = get_config('system','groupedit_image_limit'); $switchtotext = get_config('system','groupedit_image_limit');
if($switchtotext === false) if($switchtotext === false)
$switchtotext = 400; $switchtotext = 400;
$tpl = get_markup_template('group_edit.tpl');
$context = array('$submit' => t('Submit'));
if((argc() == 2) && (argv(1) === 'new')) { if((argc() == 1) || ((argc() == 2) && (argv(1) === 'new'))) {
return replace_macros($tpl, $context + array( $new = (((argc() == 2) && (argv(1) === 'new')) ? true : false);
'$title' => t('Create a group of channels.'),
'$gname' => array('groupname',t('Privacy group name: '), '', ''), $groups = q("SELECT id, gname FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
'$gid' => 'new', intval(local_channel())
'$public' => array('public',t('Members are visible to other channels'), false, ''), );
$i = 0;
foreach($groups as $group) {
$entries[$i]['name'] = $group['gname'];
$entries[$i]['id'] = $group['id'];
$entries[$i]['count'] = count(group_get_members($group['id']));
$i++;
}
$tpl = get_markup_template('privacy_groups.tpl');
$o = replace_macros($tpl, [
'$title' => t('Privacy Groups'),
'$add_new_label' => t('Add Group'),
'$new' => $new,
// new group form
'$gname' => array('groupname',t('Privacy group name')),
'$public' => array('public',t('Members are visible to other channels'), false),
'$form_security_token' => get_form_security_token("group_edit"), '$form_security_token' => get_form_security_token("group_edit"),
)); '$submit' => t('Submit'),
// groups list
'$title' => t('Privacy Groups'),
'$name_label' => t('Name'),
'$count_label' => t('Members'),
'$entries' => $entries
]);
return $o;
} }
$context = array('$submit' => t('Submit'));
$tpl = get_markup_template('group_edit.tpl');
if((argc() == 3) && (argv(1) === 'drop')) { if((argc() == 3) && (argv(1) === 'drop')) {
check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); check_form_security_token_redirectOnErr('/group', 'group_drop', 't');
@ -173,21 +211,16 @@ class Group extends \Zotlabs\Web\Controller {
} }
} }
$drop_tpl = get_markup_template('group_drop.tpl');
$drop_txt = replace_macros($drop_tpl, array(
'$id' => $group['id'],
'$delete' => t('Delete'),
'$form_security_token' => get_form_security_token("group_drop"),
));
$context = $context + array( $context = $context + array(
'$title' => t('Privacy group editor'), '$title' => sprintf(t('Privacy Group: %s'), $group['gname']),
'$details_label' => t('Edit'),
'$gname' => array('groupname',t('Privacy group name: '),$group['gname'], ''), '$gname' => array('groupname',t('Privacy group name: '),$group['gname'], ''),
'$gid' => $group['id'], '$gid' => $group['id'],
'$drop' => $drop_txt, '$drop' => $drop_txt,
'$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''), '$public' => array('public',t('Members are visible to other channels'), $group['visible'], ''),
'$form_security_token' => get_form_security_token('group_edit'), '$form_security_token_edit' => get_form_security_token('group_edit'),
'$delete' => t('Delete Group'),
'$form_security_token_drop' => get_form_security_token("group_drop"),
); );
} }
@ -196,14 +229,14 @@ class Group extends \Zotlabs\Web\Controller {
return; return;
$groupeditor = array( $groupeditor = array(
'label_members' => t('Members'), 'label_members' => t('Group members'),
'members' => array(), 'members' => array(),
'label_contacts' => t('All Connected Channels'), 'label_contacts' => t('Not in this group'),
'contacts' => array(), 'contacts' => array(),
); );
$sec_token = addslashes(get_form_security_token('group_member_change')); $sec_token = addslashes(get_form_security_token('group_member_change'));
$textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : 'card');
foreach($members as $member) { foreach($members as $member) {
if($member['xchan_url']) { if($member['xchan_url']) {
$member['archived'] = (intval($member['abook_archived']) ? true : false); $member['archived'] = (intval($member['abook_archived']) ? true : false);
@ -219,7 +252,7 @@ class Group extends \Zotlabs\Web\Controller {
); );
if(count($r)) { if(count($r)) {
$textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : 'card');
foreach($r as $member) { foreach($r as $member) {
if(! in_array($member['xchan_hash'],$preselected)) { if(! in_array($member['xchan_hash'],$preselected)) {
$member['archived'] = (intval($member['abook_archived']) ? true : false); $member['archived'] = (intval($member['abook_archived']) ? true : false);
@ -230,7 +263,7 @@ class Group extends \Zotlabs\Web\Controller {
} }
$context['$groupeditor'] = $groupeditor; $context['$groupeditor'] = $groupeditor;
$context['$desc'] = t('Click on a channel to add or remove.'); $context['$desc'] = t('Click a channel to toggle membership');
if($change) { if($change) {
$tpl = get_markup_template('groupeditor.tpl'); $tpl = get_markup_template('groupeditor.tpl');

View File

@ -8,6 +8,9 @@ class Collections {
function widget($args) { function widget($args) {
if(argc() < 2)
return;
$mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation'); $mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation');
switch($mode) { switch($mode) {
case 'conversation': case 'conversation':

6
app/group.apd Normal file
View File

@ -0,0 +1,6 @@
version: 1
url: $baseurl/group
requires: local_channel
name: Privacy Groups
photo: icon:users
categories: Networking

View File

@ -280,14 +280,6 @@ function group_side($every="connections",$each="group",$edit = false, $group_id
$groups = array(); $groups = array();
$groups[] = array(
'text' => t('All Channels'),
'id' => 0,
'selected' => (($group_id == 0) ? 'group-selected' : ''),
'href' => $every . (($every === 'network') ? '?f=&gid=0' : ''),
);
$r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", $r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC",
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );

View File

@ -1018,21 +1018,30 @@ function magiclink_url($observer,$myaddr,$url) {
function micropro($contact, $redirect = false, $class = '', $textmode = false) { function micropro($contact, $redirect = false, $class = '', $mode = false) {
if($contact['click']) if($contact['click'])
$url = '#'; $url = '#';
else else
$url = chanlink_hash($contact['xchan_hash']); $url = chanlink_hash($contact['xchan_hash']);
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
$tpl = 'micropro_img.tpl';
if($mode === true)
$tpl = 'micropro_txt.tpl';
if($mode === 'card')
$tpl = 'micropro_card.tpl';
return replace_macros(get_markup_template($tpl), array(
'$click' => (($contact['click']) ? $contact['click'] : ''), '$click' => (($contact['click']) ? $contact['click'] : ''),
'$class' => $class . (($contact['archived']) ? ' archived' : ''), '$class' => $class . (($contact['archived']) ? ' archived' : ''),
'$oneway' => (($contact['oneway']) ? true : false), '$oneway' => (($contact['oneway']) ? true : false),
'$url' => $url, '$url' => $url,
'$photo' => $contact['xchan_photo_s'], '$photo' => $contact['xchan_photo_s'],
'$name' => $contact['xchan_name'], '$name' => $contact['xchan_name'],
'$addr' => $contact['xchan_addr'],
'$title' => $contact['xchan_name'] . ' [' . $contact['xchan_addr'] . ']', '$title' => $contact['xchan_name'] . ' [' . $contact['xchan_addr'] . ']',
'$network' => sprintf(t('Network: %s'), $contact['xchan_network'])
)); ));
} }

View File

@ -1,66 +1,19 @@
.mpall,
#group-new-submit-wrapper { .mpgroup {
margin-top: 30px; line-height: 1.2;
} overflow: hidden;
/* white-space: nowrap;
#group-edit-form > label { text-overflow: ellipsis;
float: left;
width: 300px;
} }
#group-edit-form input { #groups-index th:nth-child(1),
float: left; #groups-index td:nth-child(1){
width: 175px; white-space: nowrap;
padding: 7px 3px 7px 10px;
} }
#group-edit-form .field { #groups-index th:nth-child(2),
clear: both; #groups-index td:nth-child(2){
} text-align: center;
*/ padding: 7px 10px 7px 7px;
#group-edit-submit-wrapper input {
clear: both;
width: 100px;
}
#group-edit-select-end {
clear: both;
}
/*
#group-edit-name-label {
float: left;
width: 175px;
margin-top: 20px;
margin-bottom: 20px;
}
#group-edit-name {
float: left;
width: 225px;
margin-top: 20px;
margin-bottom: 20px;
}
#group-edit-name-wrapper {
}
*/
#group_members_select_label {
display: block;
float: left;
width: 175px;
}
.group_members_select {
float: left;
width: 230px;
overflow: auto;
}
#group_members_select_end {
clear: both;
}
#group-edit-name-end {
clear: both;
} }

View File

@ -693,31 +693,6 @@ nav .acpopup {
margin-bottom: 15px; margin-bottom: 15px;
} }
#group-members {
margin-top: 20px;
padding: 10px;
height: 250px;
overflow: auto;
border: 1px solid #ddd;
}
#group-separator {
margin-top: 10px;
margin-bottom: 10px;
}
#group-all-contacts {
padding: 10px;
height: 450px;
overflow: auto;
border: 1px solid #ddd;
}
#group-edit-desc {
margin-top: 15px;
}
#prof-members { #prof-members {
margin-top: 20px; margin-top: 20px;
padding: 10px; padding: 10px;
@ -830,7 +805,7 @@ div.jGrowl div.jGrowl-notification {
.dropdown-notification, .dropdown-notification,
.notification, .notification,
.member-item { .member-item {
line-height: 1.1em; line-height: 1.2em;
font-size: 0.75rem; font-size: 0.75rem;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -1177,6 +1152,7 @@ img.mail-conv-sender-photo {
.wall-item-ago, .wall-item-ago,
.dropdown-sub-text { .dropdown-sub-text {
color: #777; color: #777;
display: block;
} }
.wall-item-content, .wall-item-content,
@ -1416,6 +1392,9 @@ main.fullscreen .generic-content-wrapper {
main.fullscreen .section-title-wrapper { main.fullscreen .section-title-wrapper {
border-radius: 0px; border-radius: 0px;
position: sticky;
top: 0;
z-index: 1020;
} }
main.fullscreen .section-content-wrapper, main.fullscreen .section-content-wrapper,
@ -1429,6 +1408,7 @@ main.fullscreen .section-content-wrapper-np {
.atoken-index-row:hover td, .atoken-index-row:hover td,
.chatroom-index-row:hover td, .chatroom-index-row:hover td,
.group-index-row:hover td,
.wikis-index-row:hover td, .wikis-index-row:hover td,
.locs-index-row:hover td, .locs-index-row:hover td,
[id^="cloud-index-"]:hover td, [id^="cloud-index-"]:hover td,

View File

@ -1,26 +1,30 @@
<div class="generic-content-wrapper-styled"> <div class="generic-content-wrapper">
<h2>{{$title}}</h2> <div class="section-title-wrapper">
<div class="float-right">
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="openClose('group_tools')"><i class="fa fa-pencil"></i> {{$details_label}}</button>
<button id="fullscreen-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen();"><i class="fa fa-expand"></i></button>
<button id="inline-btn" type="button" class="btn btn-outline-secondary btn-sm" onclick="makeFullScreen(false);"><i class="fa fa-compress"></i></button>
</div>
<h2>{{$title}}</h2>
</div>
<div id="group_tools" class="clearfix section-content-tools-wrapper" style="display: none">
<div id="group-edit-wrapper" >
<form action="group/{{$gid}}" id="group-edit-form" method="post" > <form action="group/{{$gid}}" id="group-edit-form" method="post" >
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'> <input type='hidden' name='form_security_token' value='{{$form_security_token_edit}}'>
{{include file="field_input.tpl" field=$gname}} {{include file="field_input.tpl" field=$gname}}
{{include file="field_checkbox.tpl" field=$public}} {{include file="field_checkbox.tpl" field=$public}}
{{if $drop}}{{$drop}}{{/if}} <a href="group/drop/{{$gid}}?t={{$form_security_token_drop}}" onclick="return confirmDelete();" class="btn btn-sm btn-danger">
<div id="group-edit-submit-wrapper" > {{$delete}}
<input type="submit" name="submit" value="{{$submit}}" > </a>
</div> <button type="submit" name="submit" class="btn btn-sm btn-primary float-right">{{$submit}}</button>
<div id="group-edit-select-end" ></div>
</form> </form>
</div> </div>
<div class="section-content-info-wrapper">
{{$desc}}
{{if $groupeditor}} </div>
<div id="group-update-wrapper"> <div class="section-content-wrapper">
<div id="group-update-wrapper" class="clearfix">
{{include file="groupeditor.tpl"}} {{include file="groupeditor.tpl"}}
</div> </div>
{{/if}} </div>
{{if $desc}}<div id="group-edit-desc">{{$desc}}</div>{{/if}}
</div> </div>

View File

@ -1,16 +1,12 @@
<div id="group"> <div id="contacts" class="list-group float-left w-50 pr-2">
<h3>{{$groupeditor.label_members}}</h3> <h3>{{$groupeditor.label_contacts}}</h3>
<div id="group-members" class="contact_list"> <div id="group-all-contacts" class="contact_list">
{{foreach $groupeditor.members as $c}} {{$c}} {{/foreach}} {{foreach $groupeditor.contacts as $m}} {{$m}} {{/foreach}}
</div>
</div> </div>
<div id="group-members-end"></div> <div id="group" class="list-group float-right w-50">
<hr id="group-separator" /> <h3>{{$groupeditor.label_members}}</h3>
</div> <div id="group-members" class="contact_list">
{{foreach $groupeditor.members as $c}} {{$c}} {{/foreach}}
<div id="contacts"> </div>
<h3>{{$groupeditor.label_contacts}}</h3>
<div id="group-all-contacts" class="contact_list">
{{foreach $groupeditor.contacts as $m}} {{$m}} {{/foreach}}
</div>
<div id="group-all-contacts-end"></div>
</div> </div>

View File

@ -0,0 +1,6 @@
<a class="list-group-item{{if $class}} {{$class}}{{/if}} fakelink" href="{{if $click}}#{{else}}{{$url}}{{/if}}" {{if $click}}onclick="{{$click}}"{{/if}}>
<img class="menu-img-3" src="{{$photo}}" title="{{$title}}" alt="" />{{if $oneway}}<i class="fa fa-fw fa-minus-circle oneway-overlay text-danger"></i>{{/if}}
<span class="contactname">{{$name}}</span>
<span class="dropdown-sub-text">{{$addr}}</span>
<span class="dropdown-sub-text">{{$network}}</span>
</a>

View File

@ -0,0 +1,28 @@
<div class="generic-content-wrapper">
<div class="clearfix section-title-wrapper">
<button type="button" class="btn btn-sm btn-success float-right" onclick="openClose('group_tools')"><i class="fa fa-plus-circle"></i> {{$add_new_label}}</button>
<h2>{{$title}}</h2>
</div>
<div id="group_tools" class="clearfix section-content-tools-wrapper"{{if ! $new}} style="display: none"{{/if}}>
<form action="group/new" id="group-edit-form" method="post" >
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
{{include file="field_input.tpl" field=$gname}}
{{include file="field_checkbox.tpl" field=$public}}
<button type="submit" name="submit" class="btn btn-sm btn-primary float-right">{{$submit}}</button>
</form>
</div>
<table id="groups-index">
<tr>
<th width="99%">{{$name_label}}</th>
<th width="1%">{{$count_label}}</th>
</tr>
{{foreach $entries as $group}}
<tr id="groups-index-{{$group.id}}" class="group-index-row">
<td><a href="group/{{$group.id}}">{{$group.name}}</a></td>
<td>{{$group.count}}</td>
</tr>
{{/foreach}}
</table>
</div>