View source
<?php
include_once 'commons_profile.features.inc';
function commons_profile_menu() {
$items = array();
$items['user/findfriends/autocomplete'] = array(
'title' => 'Find friends autocomplete',
'page callback' => 'commons_profile_find_friends_autocomplete',
'access callback' => 'user_access',
'access arguments' => array(
'access user profiles',
),
'type' => MENU_CALLBACK,
'file' => 'commons_profile.pages.inc',
);
return $items;
}
function commons_profile_menu_alter(&$items) {
foreach ($items as $key => $item) {
switch ($key) {
case 'user/%/badges':
case 'user/%user/messages':
case 'user/%user_category/edit':
case 'user/%user/messages':
case 'user/%user/notifications':
case 'user/%views_arg/bookmarks':
case 'user/%user/invites':
case 'user/%user/contact':
$items[$key]['type'] = MENU_CALLBACK;
break;
}
}
}
function commons_profile_block($op = 'list', $delta = 0, $edit = array()) {
module_load_include('inc', 'commons_profile', 'commons_profile.blocks');
return _commons_profile_block($op, $delta, $edit);
}
function commons_profile_theme() {
$registry = array(
'commons_profile_image_action_links_block' => array(
'arguments' => array(
'picture' => NULL,
'links' => NULL,
'account' => NULL,
),
),
'commons_profile_friend_autocomplete_item' => array(
'arguments' => array(
'name' => NULL,
'picture' => NULL,
),
),
);
foreach ($registry as $key => $item) {
$registry[$key]['file'] = 'commons_profile.theme.inc';
}
return $registry;
}
function commons_profile_init() {
if (arg(0) == 'profile' && !arg(1)) {
drupal_goto('users');
}
}
function commons_profile_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'view':
$account->content[t('Personal information')]['#access'] = FALSE;
$account->content['user_relationships_ui']['#access'] = FALSE;
$account->content['user_picture']['#access'] = FALSE;
$account->content['userpoints']['#access'] = FALSE;
$account->content['user_badges']['#access'] = FALSE;
break;
}
}
function commons_profile_views_pre_render(&$view) {
global $user;
if ($view->name == 'profile_about_page') {
if ($user->uid == arg(1)) {
context_set('context', 'profile-about-me', context_load('profile-about-me'));
}
else {
context_set('context', 'profile-about-other', context_load('profile-about-other'));
}
}
}
function commons_profile_views_pre_view(&$view) {
if ($view->name == 'profile_following') {
if ($account = _commons_profile_get_current_user()) {
$title = $view->display_handler
->get_option('title');
$friends = db_result(db_query('SELECT count(rid) FROM {user_relationships} ur WHERE ur.requester_id = %d AND ur.approved = 1 and ur.rtid = 1', array(
$account->uid,
)));
$title .= " ({$friends})";
$view->display_handler
->set_option('title', $title);
}
}
}
function _commons_profile_get_current_user() {
static $account = FALSE;
if (!$account) {
if (arg(0) == 'user' && is_numeric(arg(1))) {
$account = user_load(arg(1));
}
}
return $account;
}