1
1
Fork 0

contactedit-actions-button: doing some availability checks for the actions

This commit is contained in:
rabuzarus 2016-02-08 15:00:53 +01:00
parent 991cbd604a
commit cc18fd7ad9

View file

@ -565,7 +565,7 @@ function contacts_content(&$a) {
($contact['rel'] == CONTACT_IS_FOLLOWER)) ($contact['rel'] == CONTACT_IS_FOLLOWER))
$follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]); $follow = $a->get_baseurl(true)."/follow?url=".urlencode($contact["url"]);
$contact_actions = contact_action_menu($contact); $contact_actions = contact_actions($contact);
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
@ -959,64 +959,77 @@ function _contact_detail_for_template($rr){
} }
function contact_action_menu($contact) { /**
* @brief Gives a array with actions which can performed to a given contact
*
* This includes actions like e.g. 'block', 'hide', 'archive', 'delete' and others
*
* @param array $contact Data about the Contact
* @return array with actions related actions
*/
function contact_actions($contact) {
$contact_action_menu = array( $poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL, NETWORK_MAIL2));
'suggest' => array( $contact_action_menu = array();
if($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array(
'label' => t('Suggest friends'), 'label' => t('Suggest friends'),
'url' => app::get_baseurl(true) . '/fsuggest/' . $contact['id'], 'url' => app::get_baseurl(true) . '/fsuggest/' . $contact['id'],
'title' => '', 'title' => '',
'sel' => '', 'sel' => '',
'id' => 'suggest', 'id' => 'suggest',
), );
}
'update' => array( if($poll_enabled) {
$contact_actions['update'] = array(
'label' => t('Update now'), 'label' => t('Update now'),
'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/update', 'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/update',
'title' => '', 'title' => '',
'sel' => '', 'sel' => '',
'id' => 'update', 'id' => 'update',
), );
}
'repair' => array( $contact_actions['repair'] = array(
'label' => t('Repair'), 'label' => t('Repair'),
'url' => app::get_baseurl(true) . '/crepair/' . $contact['id'], 'url' => app::get_baseurl(true) . '/crepair/' . $contact['id'],
'title' => t('Advanced Contact Settings'), 'title' => t('Advanced Contact Settings'),
'sel' => '', 'sel' => '',
'id' => 'repair', 'id' => 'repair',
), );
'block' => array( $contact_actions['block'] = array(
'label' => (intval($contact['blocked']) ? t('Unblock') : t('Block') ), 'label' => (intval($contact['blocked']) ? t('Unblock') : t('Block') ),
'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/block', 'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/block',
'title' => t('Toggle Blocked status'), 'title' => t('Toggle Blocked status'),
'sel' => (intval($contact['blocked']) ? 'active' : ''), 'sel' => (intval($contact['blocked']) ? 'active' : ''),
'id' => 'toggle-block', 'id' => 'toggle-block',
), );
'ignore' => array( $contact_actions['ignore'] = array(
'label' => (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ), 'label' => (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/ignore', 'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/ignore',
'title' => t('Toggle Ignored status'), 'title' => t('Toggle Ignored status'),
'sel' => (intval($contact['readonly']) ? 'active' : ''), 'sel' => (intval($contact['readonly']) ? 'active' : ''),
'id' => 'toggle-ignore', 'id' => 'toggle-ignore',
), );
'archive' => array( $contact_actions['archive'] = array(
'label' => (intval($contact['archive']) ? t('Unarchive') : t('Archive') ), 'label' => (intval($contact['archive']) ? t('Unarchive') : t('Archive') ),
'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/archive', 'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/archive',
'title' => t('Toggle Archive status'), 'title' => t('Toggle Archive status'),
'sel' => (intval($contact['archive']) ? 'active' : ''), 'sel' => (intval($contact['archive']) ? 'active' : ''),
'id' => 'toggle-archive', 'id' => 'toggle-archive',
), );
'delete' => array( $contact_actions['delete'] = array(
'label' => t('Delete'), 'label' => t('Delete'),
'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/drop', 'url' => app::get_baseurl(true) . '/contacts/' . $contact['id'] . '/drop',
'title' => t('Delete contact'), 'title' => t('Delete contact'),
'sel' => '', 'sel' => '',
'id' => 'delete', 'id' => 'delete',
)
); );
return $contact_action_menu; return $contact_action_menu;