restrict access to materials descriptions for free users
This commit is contained in:
parent
e2183f0a0d
commit
9df43555ac
23
materio_display.info
Normal file
23
materio_display.info
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
name = Materio Display
|
||||||
|
description = "Materio display module (permissions, ...)"
|
||||||
|
|
||||||
|
; Core version (required)
|
||||||
|
core = 7.x
|
||||||
|
|
||||||
|
; Package name (see http://drupal.org/node/542202 for a list of names)
|
||||||
|
package = Materio
|
||||||
|
|
||||||
|
; PHP version requirement (optional)
|
||||||
|
; php = 5.2
|
||||||
|
|
||||||
|
; Loadable code files
|
||||||
|
; files[] = materio_ctools_automodal.module
|
||||||
|
|
||||||
|
; Module dependencies
|
||||||
|
; dependencies[] = user
|
||||||
|
|
||||||
|
; Configuration page
|
||||||
|
; configure = admin/config/materiobasemod
|
||||||
|
|
||||||
|
; For further information about configuration options, see
|
||||||
|
; - http://drupal.org/node/542202
|
58
materio_display.module
Normal file
58
materio_display.module
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_init().
|
||||||
|
*/
|
||||||
|
// function materio_user_init() {
|
||||||
|
// drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_permission().
|
||||||
|
*/
|
||||||
|
function materio_display_permission() {
|
||||||
|
return array(
|
||||||
|
'view full materiau description' => array(
|
||||||
|
'title' => t('view full materiau description'),
|
||||||
|
'description' => t('view full materiau description'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_preprocess().
|
||||||
|
*/
|
||||||
|
function materio_display_preprocess_field(&$vars, $hook) {
|
||||||
|
// dsm($vars);
|
||||||
|
$element = $vars['element'];
|
||||||
|
|
||||||
|
if($element['#field_name'] == 'field_description'){
|
||||||
|
dsm($vars);
|
||||||
|
if(!user_access('view full materiau description')){
|
||||||
|
$value = $element['#items'][0]['value'];
|
||||||
|
|
||||||
|
switch ($element['#view_mode']) {
|
||||||
|
case 'cardbig':
|
||||||
|
case 'cardfull':
|
||||||
|
$limit = 210;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$limit = 130;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$summary = truncate_utf8($value, $limit, TRUE, TRUE);
|
||||||
|
|
||||||
|
$summary .= '<div class="upgrade"><p>'
|
||||||
|
. t("In order to access full description, information about manufacturers and more, you need to upgrade your account.")
|
||||||
|
. l(t("Pricing"), 'node/11187')
|
||||||
|
. '</p></div>';
|
||||||
|
|
||||||
|
// dsm($summary);
|
||||||
|
$vars['items'][0]['#markup'] = $summary;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user