diff options
-rwxr-xr-x | include/items.php | 12 | ||||
-rw-r--r-- | mod/locs.php | 15 | ||||
-rw-r--r-- | view/tpl/locmanage.tpl | 2 |
3 files changed, 24 insertions, 5 deletions
diff --git a/include/items.php b/include/items.php index 657168601..b209e55c5 100755 --- a/include/items.php +++ b/include/items.php @@ -4417,6 +4417,18 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) { intval($item['uid']) ); + // remove delivery reports + + $c = q("select channel_hash from channel where channel_id = %d limit 1", + intval($item['uid']) + ); + if($c) { + q("delete from dreport where dreport_xchan = '%s' and dreport_mid = '%s'", + dbesc($c[0]['channel_hash']), + dbesc($item['mid']) + ); + } + // network deletion request. Keep the message structure so that we can deliver delete notifications. // Come back after several days (or perhaps a month) to do the lowlevel delete (DROPITEM_PHASE2). diff --git a/mod/locs.php b/mod/locs.php index 3f8bd9029..3c6a5da67 100644 --- a/mod/locs.php +++ b/mod/locs.php @@ -50,8 +50,17 @@ function locs_post(&$a) { return; } if(intval($r[0]['hubloc_primary'])) { - notice( t('Primary location cannot be removed.') . EOL); - return; + $x = q("select hubloc_id from hubloc where hubloc_primary = 1 and hubloc_hash = '%s'", + dbesc($channel['channel_hash']) + ); + if(! $x) { + notice( t('Location lookup failed.')); + return; + } + if(count($x) == 1) { + notice( t('Please select another location to become primary before removing the primary location.') . EOL); + return; + } } $r = q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d and hubloc_hash = '%s'", @@ -91,8 +100,6 @@ function locs_content(&$a) { $r[$x]['deleted'] = (intval($r[$x]['hubloc_deleted']) ? true : false); } - - $o = replace_macros(get_markup_template('locmanage.tpl'), array( '$header' => t('Manage Channel Locations'), '$loc' => t('Location (address)'), diff --git a/view/tpl/locmanage.tpl b/view/tpl/locmanage.tpl index 944b3c3f4..e0232547f 100644 --- a/view/tpl/locmanage.tpl +++ b/view/tpl/locmanage.tpl @@ -19,7 +19,7 @@ function drophub(id) { {{if $hub.primary}}<button class="btn btn-std"><i class="icon-check"></i></button>{{else}}<button class="btn btn-std" onclick="primehub({{$hub.hubloc_id}}); return false;" ><i class="icon-check-empty" ></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-trash"></i></button>{{/if}}{{/if}}</td> +<td>{{if ! $hub.deleted}}<button class="btn btn-std" onclick="drophub({{$hub.hubloc_id}}); return false;"><i class="icon-trash"></i></button>{{/if}}</td> </tr> {{/foreach}} </table> |