FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
name = Profile2 translation
|
||||
description = Translate profile2 types.
|
||||
dependencies[] = profile2
|
||||
dependencies[] = i18n_string
|
||||
package = Multilingual - Internationalization
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-12-26
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1356482021"
|
||||
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Profile2 i18n integration module via entity API i18n support.
|
||||
*
|
||||
* @see EntityDefaultI18nController
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info_alter().
|
||||
*/
|
||||
function profile2_i18n_entity_info_alter(&$info) {
|
||||
// Enable i18n support via the entity API.
|
||||
$info['profile2_type']['i18n controller class'] = 'EntityDefaultI18nStringController';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_property_info_alter().
|
||||
*/
|
||||
function profile2_i18n_entity_property_info_alter(&$info) {
|
||||
// Mark some properties as translatable, but also denote that translation
|
||||
// works with i18n_string.
|
||||
foreach (array('label') as $name) {
|
||||
$info['profile2_type']['properties'][$name]['translatable'] = TRUE;
|
||||
$info['profile2_type']['properties'][$name]['i18n string'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_insert().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_insert($profile_type) {
|
||||
i18n_string_object_update('profile2_type', $profile_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_update().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_update($profile_type) {
|
||||
// Account for name changes.
|
||||
if ($profile_type->original->type != $profile_type->type) {
|
||||
i18n_string_update_context("profile2:profile2_type:{$profile_type->original->type}:*", "profile2:profile2_type:{$profile_type->type}:*");
|
||||
}
|
||||
i18n_string_object_update('profile2_type', $profile_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_delete().
|
||||
*/
|
||||
function profile2_i18n_profile2_type_delete($profile_type) {
|
||||
i18n_string_object_remove('profile2_type', $profile_type);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
name = Profile2 group access
|
||||
description = Adds Organic groups permissions to control profile access on the group level.
|
||||
core = 7.x
|
||||
dependencies[] = profile2
|
||||
dependencies[] = og
|
||||
package = "Organic groups"
|
||||
; Information added by drupal.org packaging script on 2012-12-26
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1356482021"
|
||||
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Profile2 og access integration module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_og_permission().
|
||||
*/
|
||||
function profile2_og_access_og_permission() {
|
||||
$permissions = array();
|
||||
// Generate per profile type permissions.
|
||||
foreach (profile2_get_types() as $type) {
|
||||
$type_name = check_plain($type->type);
|
||||
$permissions += array(
|
||||
"edit any $type_name profile" => array(
|
||||
'title' => t('%type_name: Edit any profile', array('%type_name' => $type->label)),
|
||||
),
|
||||
"view any $type_name profile" => array(
|
||||
'title' => t('%type_name: View any profile', array('%type_name' => $type->label)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_access().
|
||||
*
|
||||
* @see profile2_profile2_access()
|
||||
*/
|
||||
function profile2_og_access_profile2_access($op, $profile = NULL, $account = NULL) {
|
||||
if (isset($profile) && ($type_name = $profile->type) && $profile->identifier() && $op != 'delete') {
|
||||
// Only return TRUE if og grants access. So other modules may still grant
|
||||
// access in case og does not.
|
||||
if (og_user_access_entity("$op any $type_name profile", 'profile2', $profile, $account)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Adds separate pages for viewing and editing profiles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shows the profile page for the current user.
|
||||
*
|
||||
* @see user_page()
|
||||
*/
|
||||
function profile2_page_own($base_path) {
|
||||
global $user;
|
||||
if ($user->uid) {
|
||||
menu_set_active_item($base_path . '/' . $user->uid);
|
||||
return menu_execute_active_handler(NULL, FALSE);
|
||||
}
|
||||
else {
|
||||
return drupal_get_form('user_login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile view page.
|
||||
*/
|
||||
function profile2_page_view($profile) {
|
||||
return $profile->view('page');
|
||||
}
|
||||
|
||||
/**
|
||||
* The profile edit form.
|
||||
*/
|
||||
function profile2_form($form, &$form_state, $profile) {
|
||||
if (empty($form_state['profiles'])) {
|
||||
$form_state['profiles'][$profile->type] = $profile;
|
||||
}
|
||||
// Prevent invoking the same hooks twice, so tell profile2_attach_form() to
|
||||
// skip invoking the hooks.
|
||||
$form_state['profile2_skip_hook'] = TRUE;
|
||||
profile2_attach_form($form, $form_state);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#weight' => 40,
|
||||
);
|
||||
if (empty($profile->is_new) && user_access('administer profiles')) {
|
||||
$form['actions']['delete'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Delete profile'),
|
||||
'#weight' => 45,
|
||||
'#limit_validation_errors' => array(),
|
||||
'#submit' => array('profile2_form_submit_delete')
|
||||
);
|
||||
}
|
||||
$form['#submit'][] = 'profile2_form_submit';
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile form submit handler.
|
||||
*/
|
||||
function profile2_form_submit($form, &$form_state) {
|
||||
// The profile is being saved by profile2_form_submit_handler().
|
||||
drupal_set_message(t('The changes have been saved.'));
|
||||
$form_state['redirect'] = $form_state['profile2']->path();
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile form submit handler for the delete button.
|
||||
*/
|
||||
function profile2_form_submit_delete($form, &$form_state) {
|
||||
$form_state['redirect'] = $form_state['profile2']->path() . '/delete';
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm form for deleting a profile.
|
||||
*/
|
||||
function profile2_page_delete_confirm_form($form, &$form_state, $profile) {
|
||||
$form_state += array('profile2' => $profile);
|
||||
$confirm_question = t('Are you sure you want to delete profile %label?', array('%label' => $profile->label()));
|
||||
return confirm_form($form, $confirm_question, $profile->path());
|
||||
}
|
||||
|
||||
function profile2_page_delete_confirm_form_submit($form, &$form_state) {
|
||||
$profile = $form_state['profile2'];
|
||||
$profile->delete();
|
||||
drupal_set_message(t('Deleted %label.', array('%label' => $profile->label)));
|
||||
$form_state['redirect'] = 'user/' . $profile->uid;
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
name = Profile2 pages
|
||||
description = Adds separate pages for viewing and editing profiles.
|
||||
core = 7.x
|
||||
dependencies[] = profile2
|
||||
; Information added by drupal.org packaging script on 2012-12-26
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "profile2"
|
||||
datestamp = "1356482021"
|
||||
|
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Adds separate pages for viewing and editing profiles.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function profile2_page_menu() {
|
||||
$items = array();
|
||||
|
||||
// Bugfix for uninstalling the module, see http://drupal.org/node/1008346.
|
||||
if (!module_exists('profile2')) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (profile2_get_types() as $type_name => $type) {
|
||||
if (!empty($type->data['use_page'])) {
|
||||
$path = profile2_page_get_base_path($type);
|
||||
$count = count(explode('/', $path));
|
||||
|
||||
$items[$path] = array(
|
||||
'title callback' => 'profile2_page_title',
|
||||
'title arguments' => array($type_name),
|
||||
'page callback' => 'profile2_page_own',
|
||||
'page arguments' => array($path),
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array("edit own $type_name profile"),
|
||||
'file' => 'profile2_page.inc',
|
||||
'menu_name' => 'user-menu',
|
||||
);
|
||||
|
||||
$items[$path . '/%profile2_by_uid'] = array(
|
||||
'title callback' => 'profile2_page_title',
|
||||
'title arguments' => array($type_name, $count),
|
||||
'page callback' => 'profile2_page_view',
|
||||
'page arguments' => array($count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('view', $count),
|
||||
'file' => 'profile2_page.inc',
|
||||
// Copied over the following hack from user_menu() to avoid $path
|
||||
// appearing in the breadcrumb:
|
||||
//
|
||||
// By assigning a different menu name, this item (and all registered
|
||||
// child paths) are no longer considered as children of 'user'. When
|
||||
// accessing the user account pages, the preferred menu link that is
|
||||
// used to build the active trail (breadcrumb) will be found in this
|
||||
// menu (unless there is more specific link), so the link to 'user' will
|
||||
// not be in the breadcrumb.
|
||||
'menu_name' => 'navigation',
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/view'] = array(
|
||||
'title' => 'View',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'load arguments' => array($type_name),
|
||||
'weight' => -10,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/edit'] = array(
|
||||
'page callback' => 'entity_ui_get_form',
|
||||
'page arguments' => array('profile2', $count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('edit', $count),
|
||||
'title' => 'Edit',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
|
||||
'file' => 'profile2_page.inc',
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/delete'] = array(
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('profile2_page_delete_confirm_form', $count),
|
||||
'load arguments' => array($type_name),
|
||||
'access callback' => 'profile2_access',
|
||||
'access arguments' => array('delete', $count),
|
||||
'title' => 'Delete',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'context' => MENU_CONTEXT_INLINE,
|
||||
'file' => 'profile2_page.inc',
|
||||
);
|
||||
// Devel integration.
|
||||
if (module_exists('devel')) {
|
||||
$devel_path = drupal_get_path('module', 'devel');
|
||||
$items[$path . '/%profile2_by_uid/devel'] = array(
|
||||
'title' => 'Devel',
|
||||
'page callback' => 'devel_load_object',
|
||||
'file' => 'devel.pages.inc',
|
||||
'file path' => $devel_path,
|
||||
'page arguments' => array('profile2', $count),
|
||||
'access arguments' => array('access devel information'),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 100,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/devel/load'] = array(
|
||||
'title' => 'Load',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
);
|
||||
$items[$path . '/%profile2_by_uid/devel/render'] = array(
|
||||
'title' => 'Render',
|
||||
'page callback' => 'devel_render_object',
|
||||
'page arguments' => array('profile2', $count),
|
||||
'access arguments' => array('access devel information'),
|
||||
'file' => 'devel.pages.inc',
|
||||
'file path' => $devel_path,
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 100,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu load callback.
|
||||
*
|
||||
* Returns the profile object for the given user. If there is none yet, a new
|
||||
* object is created.
|
||||
*/
|
||||
function profile2_by_uid_load($uid, $type_name) {
|
||||
if ($uid && is_numeric($uid) && ($account = user_load($uid))) {
|
||||
$profile = profile2_load_by_user($account, $type_name);
|
||||
if (!$profile) {
|
||||
$profile = profile2_create(array('type' => $type_name));
|
||||
$profile->setUser($account);
|
||||
$profile->is_new = TRUE;
|
||||
}
|
||||
return $profile;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base path to use as profile page.
|
||||
*/
|
||||
function profile2_page_get_base_path($profile_type) {
|
||||
// Allow for an easy customization of the page's base path.
|
||||
if (!empty($profile_type->data['page_path'])) {
|
||||
return $profile_type->data['page_path'];
|
||||
}
|
||||
return 'profile-' . $profile_type->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_forms().
|
||||
*/
|
||||
function profile2_page_forms($form_id, $args) {
|
||||
// For efficiency, only act if the third argument is 'profile2'.
|
||||
if (isset($args[2]) && is_string($args[2]) && $args[2] == 'profile2') {
|
||||
$info = entity_get_info('profile2');
|
||||
// Translate bundle form ids to the base form id 'profile2_form'.
|
||||
foreach ($info['bundles'] as $bundle => $bundle_info) {
|
||||
$forms['profile2_edit_' . $bundle . '_form']['callback'] = 'profile2_form';
|
||||
$forms['profile2_edit_' . $bundle . '_form']['wrapper callback'] = 'entity_ui_form_defaults';
|
||||
}
|
||||
return $forms;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_load().
|
||||
*/
|
||||
function profile2_page_profile2_type_load($types) {
|
||||
foreach ($types as $type) {
|
||||
if (!empty($type->data['use_page'])) {
|
||||
// Disable user categories and the user account view.
|
||||
$type->userCategory = FALSE;
|
||||
$type->userView = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info_alter().
|
||||
*/
|
||||
function profile2_page_entity_info_alter(&$entity_info) {
|
||||
// Add new view modes for the page.
|
||||
$entity_info['profile2']['view modes']['page'] = array(
|
||||
'label' => t('Profile page'),
|
||||
'custom settings' => FALSE,
|
||||
);
|
||||
$entity_info['profile2']['view modes']['teaser'] = array(
|
||||
'label' => t('Teaser'),
|
||||
'custom settings' => FALSE,
|
||||
);
|
||||
$entity_info['profile2']['uri callback'] = 'profile2_page_uri_callback';
|
||||
$entity_info['profile2']['form callback'] = 'profile2_page_form_callback';
|
||||
}
|
||||
|
||||
/**
|
||||
* URI callback pointing to the profile page.
|
||||
*
|
||||
* @see profile2_pages_entity_info_alter()
|
||||
*/
|
||||
function profile2_page_uri_callback($profile) {
|
||||
$type = $profile->type();
|
||||
if (!empty($type->data['use_page'])) {
|
||||
return array('path' => profile2_page_get_base_path($type) . '/' . $profile->uid);
|
||||
}
|
||||
// Fall back to the default callback.
|
||||
return $profile->defaultUri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form callback for entity_form().
|
||||
*/
|
||||
function profile2_page_form_callback($profile) {
|
||||
// Pre-populate the form-state with the right form include.
|
||||
$form_state = form_state_defaults();
|
||||
form_load_include($form_state, 'inc', 'profile2_page');
|
||||
return entity_ui_get_form('profile2', $profile, 'edit', $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu title callback.
|
||||
*/
|
||||
function profile2_page_title($type_name, $profile2 = NULL) {
|
||||
$type = profile2_get_types($type_name);
|
||||
// If no profile is given, we are at the general path pointing to the own
|
||||
// profile.
|
||||
if (!isset($profile2)) {
|
||||
return t('My @profile-label', array('@profile-label' => drupal_strtolower($type->getTranslation('label'))));
|
||||
}
|
||||
return drupal_ucfirst($profile2->label());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for the profile2 type form..
|
||||
*/
|
||||
function profile2_page_form_profile2_type_form_alter(&$form, &$form_state) {
|
||||
$type = $form_state['profile2_type'];
|
||||
$form['data']['use_page'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Provide a separate page for editing profiles.'),
|
||||
'#description' => t('If enabled, a separate menu item for editing the profile is generated and the profile is hidden from the user account page.'),
|
||||
'#default_value' => !empty($type->is_new) || !empty($type->data['use_page']),
|
||||
);
|
||||
$form['data']['#tree'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_insert().
|
||||
*/
|
||||
function profile2_page_profile2_type_insert(ProfileType $type) {
|
||||
// Do not directly issue menu rebuilds here to avoid potentially multiple
|
||||
// rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
|
||||
if (!empty($type->data['use_page'])) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_update().
|
||||
*/
|
||||
function profile2_page_profile2_type_update(ProfileType $type) {
|
||||
// Rebuild the menu if use_page or the type name has been changed.
|
||||
// @see profile2_page_profile2_type_insert()
|
||||
if (empty($type->data['use_page']) != empty($type->original->data['use_page']) || ($type->data['use_page'] && $type->type != $type->original->type)) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_profile2_type_delete()
|
||||
*/
|
||||
function profile2_page_profile2_type_delete($type) {
|
||||
// Do not directly issue menu rebuilds here to avoid potentially multiple
|
||||
// rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
|
||||
if (!empty($type->data['use_page'])) {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user