crude skeleton for location manager and the UI sucks but at least it's on a webpage and you don't have to do it by hand.
This commit is contained in:
parent
70b964d1c4
commit
038e7c8923
70
mod/locs.php
70
mod/locs.php
@ -1,34 +1,6 @@
|
|||||||
<?php /** @file */
|
<?php /** @file */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Placeholder file at present. This is going to involve a bit of work.
|
|
||||||
|
|
||||||
This file will deal with the deletion of channels and management of hublocs.
|
|
||||||
|
|
||||||
We need to provide the following functionality:
|
|
||||||
|
|
||||||
- Delete my account and all channels from the entire network
|
|
||||||
|
|
||||||
- Delete my account and all channels from this server
|
|
||||||
|
|
||||||
- Delete a channel from the entire network
|
|
||||||
|
|
||||||
- Delete a channel from this server
|
|
||||||
|
|
||||||
- List all hub locations for this channel
|
|
||||||
|
|
||||||
- Remove this/some hub location from this channel
|
|
||||||
|
|
||||||
- promote this/some hub location to primary
|
|
||||||
|
|
||||||
- Remove hub location 'xyz' from this channel, (this should possibly only be allowed if that hub has been down for a period of time)
|
|
||||||
|
|
||||||
- Some of these actions should probably require email verification
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
function locs_post(&$a) {
|
function locs_post(&$a) {
|
||||||
|
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
@ -87,4 +59,46 @@ function locs_post(&$a) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function locs_content(&$a) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(! local_user()) {
|
||||||
|
notice( t('Permission denied.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$channel = $a->get_channel();
|
||||||
|
|
||||||
|
$r = q("select * from hubloc where hubloc_hash = '%s'",
|
||||||
|
dbesc($channel['channel_hash'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if(! $r) {
|
||||||
|
notice( t('No locations found.') . EOL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for($x = 0; $x < count($r); $x ++) {
|
||||||
|
$r[$x]['primary'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false);
|
||||||
|
$r[$x]['deleted'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$o = replace_macros(get_markup_template('locmanage.tpl'), array(
|
||||||
|
'$header' => t('Manage Channel Locations'),
|
||||||
|
'$loc' => t('Location (address)'),
|
||||||
|
'$mkprm' => t('Primary Location'),
|
||||||
|
'$drop' => t('Drop location'),
|
||||||
|
'$submit' => t('Submit'),
|
||||||
|
'$hubs' => $r
|
||||||
|
));
|
||||||
|
|
||||||
|
return $o;
|
||||||
}
|
}
|
3
view/css/mod_locs.css
Normal file
3
view/css/mod_locs.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
td {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
26
view/tpl/locmanage.tpl
Normal file
26
view/tpl/locmanage.tpl
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<h2>{{$header}}</h2>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function primehub(id) {
|
||||||
|
$.post('locs','primary='+id,function(data) { window.location.href=window.location.href; });
|
||||||
|
}
|
||||||
|
function drophub(id) {
|
||||||
|
$.post('locs','drop='+id,function(data) { window.location.href=window.location.href; });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr><td>{{$loc}}</td><td>{{$mkprm}}</td><td>{{$drop}}</td></tr>
|
||||||
|
{{foreach $hubs as $hub}}
|
||||||
|
<tr><td>
|
||||||
|
{{if $hub.deleted}}<strike>{{/if}}
|
||||||
|
{{$hub.hubloc_url}} ({{$hub.hubloc_addr}}){{if $hub.deleted}}</strike>{{/if}}</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
{{if $hub.primary}}<i class="icon-check"></i>{{else}}<button class="btn btn-std"><i class="icon-check-empty" onclick="primehub({{$hub.hubloc_id}}); return false;" ></i></button>{{/if}}
|
||||||
|
</td>
|
||||||
|
<td>{{if $hub.primary}}{{else}}{{if ! $hub.deleted}}<button class="btn btn-std" onclick="drophub({{$hub.hubloc_id}}); return false;"><i class="icon-remove"></i></button>{{/if}}{{/if}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/foreach}}
|
||||||
|
</table>
|
||||||
|
|
Reference in New Issue
Block a user