Esempio n. 1
0
/**
 * Implements hook_civicrm_navigationMenu().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_navigationMenu
 */
function tournament_civicrm_navigationMenu(&$menu)
{
    $domain = array('domain' => domain());
    $path = path();
    $name = $path;
    // This inserts a menu at the end the bar. TODO: How to insert at beginning?
    _tournament_civix_insert_navigation_menu($menu, NULL, array('label' => ts('Tournament', $domain), 'name' => $name, 'url' => ''));
    $path = $name;
    $name = 'tournament_dashboard';
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Dashboard', $domain), 'name' => $name, 'url' => 'civicrm', 'permission' => 'access Contact Dashboard'));
    $name = 'individual_profile';
    $billing_contact = billing_contact_get();
    $billing_contact_id = $billing_contact["id"];
    $record = named_profile_get("Billing Individual Profile");
    $gid = $record["id"];
    $delim = '?';
    $HREF = contact_profile_HREF_data($billing_contact, $record, $delim);
    $label = $HREF['title'];
    $url = $HREF['relativeURL'];
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts($label, $domain), 'name' => $name, 'url' => $url, 'permission' => 'edit my contact'));
    $name = 'organization_profile';
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts("Organizations", $domain), 'name' => $name, 'url' => ''));
    $path .= "/{$name}";
    $profile = named_profile_get("Billing Organization Profile");
    $billing_organizations = billing_organizations_get($billing_contact_id);
    if (count($billing_organizations) > 0) {
        foreach ($billing_organizations as $org) {
            $HREF = contact_profile_HREF_data($org, $profile, $delim);
            $label = $HREF['title'];
            $url = $HREF['relativeURL'];
            _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts($label, $domain), 'name' => "{$name}_{$organization_name}", 'url' => $url, 'permission' => 'access contact reference fields'));
        }
    }
    $path = path();
    $name = 'Profiles';
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Your players, coaches, etc.', $domain), 'name' => $name, 'permission' => 'profile edit', 'separator' => 1));
    $path .= "/{$name}";
    // add a menu item for each of the session billing contact's profiles
    $registrationProfiles = get_registrationProfiles($billing_contact_id);
    if (count($registrationProfiles) > 0) {
        foreach ($registrationProfiles as $profile) {
            $id = $profile["id"];
            $title = $profile["title"];
            _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts("{$title}", array('domain' => $domain)), 'name' => "{$name}_{$id}", 'permission' => 'profile edit'));
            _tournament_civix_insert_navigation_menu($menu, "{$path}/{$name}_{$id}", array('label' => ts("Find Contacts", array('domain' => $domain)), 'name' => "{$name}_{$id}_list", 'url' => "civicrm/profile?gid={$id}&reset=1&force=1", 'permission' => 'profile edit'));
            _tournament_civix_insert_navigation_menu($menu, "{$path}/{$name}_{$id}", array('label' => ts("New Contact", array('domain' => $domain)), 'name' => "{$name}_{$id}_add", 'url' => "civicrm/profile/create?gid={$id}&reset=1", 'permission' => 'profile create'));
        }
    }
    $path = path();
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Register Contacts for Tournament', $domain), 'name' => 'registration', 'permission' => 'edit event participants', 'separator' => 1));
    _tournament_civix_insert_navigation_menu($menu, "{$path}/registration", array('label' => ts('Register a contact', $domain), 'name' => 'registerParticipant', 'url' => registrationRelativeURL("?"), 'permission' => 'edit event participants'));
    _tournament_civix_insert_navigation_menu($menu, "{$path}/registration", array('label' => ts('List/edit contacts already registered', $domain), 'name' => 'participantList', 'url' => registrationReportRelativeURL("?"), 'permission' => 'edit event participants'));
    $path = path();
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Team Builder', array('domain' => $domain)), 'name' => "teamBuilder", 'permission' => 'edit groups', 'separator' => 1));
    _tournament_civix_insert_navigation_menu($menu, "{$path}/teamBuilder", array('label' => ts('New Team', array('domain' => $domain)), 'name' => 'NewTeam', 'url' => "civicrm/tournament/team/add?reset=1", 'permission' => 'edit groups'));
    _tournament_civix_insert_navigation_menu($menu, "{$path}/teamBuilder", array('label' => ts('List/edit existing teams', array('domain' => $domain)), 'name' => 'teamList', 'url' => "civicrm/tournament/team/search", 'permission' => 'edit groups'));
    $path = path();
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Advanced Operations', $domain), 'name' => 'bulkOperations', 'permission' => 'edit event participants', 'url' => bulkOperationsRelativeURL("?"), 'separator' => 1));
    $path = null;
    $name = "TournamentAdmin";
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Tournament Admins', array('domain' => $domain)), 'name' => $name, 'permission' => 'edit all contacts'));
    $path = $name;
    $record = named_profile_get("Billing Organization Profile");
    $id = $record["id"];
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Billing Organizations', array('domain' => $domain)), 'name' => 'BillingOrganizations', 'url' => "civicrm/profile?gid={$id}", 'permission' => 'view all contacts'));
    $record = named_report_get("Preliminary Estimates Summary");
    $id = $record["id"];
    _tournament_civix_insert_navigation_menu($menu, "{$path}/BillingOrganizations", array('label' => ts('Preliminary Estimates', array('domain' => $domain)), 'name' => 'PreliminaryEstimates', 'url' => "civicrm/report/instance/{$id}?reset=1", 'permission' => 'view all contacts'));
    $record = named_group_get("Billing Contacts");
    $id = $record["id"];
    _tournament_civix_insert_navigation_menu($menu, $path, array('label' => ts('Billing Individuals', array('domain' => $domain)), 'name' => 'BillingContacts', 'url' => "civicrm/group/search?context=smog&gid={$id}&reset=1&force=1", 'permission' => 'view all contacts'));
    _tournament_civix_navigationMenu($menu);
}
Esempio n. 2
0
/**
 * get HREF to profile listing
 *
 * @param $profile array
 * @param $contact array
 * @return string
 */
function profileEditHREF($profile, $contact)
{
    $HREF = contact_profile_HREF_data($contact, $profile);
    //$cid = $contact['id'];
    $text = $HREF['text'];
    //$contact['display_name'];
    $title = $HREF['title'];
    //"Use this link to edit $text";
    $token = $HREF['relativeURL'];
    //"civicrm/profile/edit&reset=1&=1&id={$cid}&gid=";
    return tokenIDHREF($token, $title, $text);
}