updated uc_termsofservice, session_limit

This commit is contained in:
Bachir Soussi Chiadmi 2016-11-05 17:26:29 +01:00
parent 08127672d6
commit 86c993f638
8 changed files with 103 additions and 60 deletions

View File

@ -1,13 +1,15 @@
-- Ubercart Terms of Service -- Ubercart Terms of Service
This module allows the administrator of a Ubercart Shop to add a check of =========================
Terms of Service (ToS) in the Checkout pane or in the Cart pane. This module allows the administrator of a Ubercart Shop to display
Terms of Service (ToS) in the Checkout pane or in the Cart pane, and require
the customer to agree to these terms before purchase.
-- Installation -- Installation
Just enable the module, cart module and checkout module of ubercart are ============
required. Just enable the module. Ubercart Cart and Checkout modules are required.
The configuration of this module is merged into the Ubercart pane settings. The configuration of this module is merged into the Ubercart pane settings.
You can configure the options for checkout in panes' checkout configuration You can configure the options for checkout in panes' checkout configuration
page (admin/store/settings/checkout/edit/panes) and for cart in panes' cart page (admin/store/settings/checkout/edit/panes) and for cart in pane's cart
configuration page (admin/store/settings/cart/edit/panes). configuration page (admin/store/settings/cart/edit/panes).
Options available for configuration: Options available for configuration:
@ -17,33 +19,37 @@ Options available for configuration:
- In case of checkout, if the ToS is required or not. - In case of checkout, if the ToS is required or not.
- Cart pane can't be required. - Cart pane can't be required.
- If ModalFrame API is present, you can also select if the ToS is displayed in - If ModalFrame API is present, you can also select if the ToS is displayed in
a popup window and its size. a popup window and its size.
- You can configure conditional actions so the checkout pane is only displayed - You can configure Rules so the checkout pane is only displayed when there is
when there is one product from a given class. one product from a given class.
Multilanguage is supported through the Translation module. You can translate the Multilanguage is supported through the Translation module. You can translate
ToS node and the correct translation will be displayed depending of the language. the ToS node and the correct translation will be displayed depending of the
language.
-- ToS in js popup -- ToS in JavaScript popup
=======================
You can enable the ModalFrame API (http://drupal.org/project/modalframe) module You can enable the ModalFrame API (http://drupal.org/project/modalframe) module
in order to have the Terms of Service opened in a js popup window, you can in order to have the Terms of Service opened in a js popup window, you can
accept the ToS from this window. accept the ToS from this window. You can disable the popup option in the
You can disable the popup option in the settings of the module. settings of the module.
-- Theming & ToS text -- Theming & ToS text
==================
You can theme both form and ToS text from two tpl files included with this You can theme both form and ToS text from two tpl files included with this
module and a css file, just copy those tpl files in your theme and modify the module and a css file, just copy those tpl files in your theme and modify the
text, structure or css. text, structure or css. By default, the node body will be displayed.
By default, the node body will be displayed.
-- Conditional Actions -- Rules
You can configure conditional actions to display the Terms of Service in the =====
You can configure the Rules module to display the Terms of Service in the
checkout only if a product from a given product class or content type is checkout only if a product from a given product class or content type is
present. The admin url for this is present. The admin url for this is :
admin/store/ca/uc_termsofservice_display_pane/edit/conditions admin/store/ca/uc_termsofservice_display_pane/edit/conditions
You can also add extra conditions and actions. You can also add extra conditions and actions.
-- Know Issues -- Know Issues
===========
The ToS can be placed as a cart pane, but then it won't be required. The ToS can be placed as a cart pane, but then it won't be required.
If you are using Secure Pages for a version of the checkout in SSL, you should If you are using Secure Pages for a version of the checkout in SSL, you should
add uc_termsofservice/* to the Secure Pages settings. add uc_termsofservice/* to the Secure Pages settings.
@ -51,5 +57,3 @@ add uc_termsofservice/* to the Secure Pages settings.
If you need a previous agreement checkbox, i.e. in the registration of the If you need a previous agreement checkbox, i.e. in the registration of the
users, please take a look to the Legal (http://drupal.org/project/legal) or users, please take a look to the Legal (http://drupal.org/project/legal) or
Terms of Service (http://drupal.org/project/terms_of_use) module. Terms of Service (http://drupal.org/project/terms_of_use) module.
Module supported by Neurotic (http://www.neurotic.es)

View File

@ -5,9 +5,9 @@ dependencies[] = uc_cart
package = Ubercart - extra package = Ubercart - extra
core = 7.x core = 7.x
; Information added by drupal.org packaging script on 2013-10-19 ; Information added by Drupal.org packaging script on 2016-04-03
version = "7.x-1.0-beta1+1-dev" version = "7.x-1.0-beta1+3-dev"
core = "7.x" core = "7.x"
project = "uc_termsofservice" project = "uc_termsofservice"
datestamp = "1382149680" datestamp = "1459648442"

View File

@ -17,8 +17,7 @@ function uc_termsofservice_uninstall() {
} }
/** /**
* Renames uc_termsofservice_checkout_ca to uc_termsofservice_checkout_rules * Renames uc_termsofservice_checkout_ca to uc_termsofservice_checkout_rules.
* for D7.
*/ */
function uc_termsofservice_update_7100() { function uc_termsofservice_update_7100() {
variable_set('uc_termsofservice_checkout_rules', variable_set('uc_termsofservice_checkout_rules',

View File

@ -296,25 +296,17 @@ function uc_termsofservice_admin_form($type = NULL) {
'#default_value' => variable_get('uc_termsofservice_' . $type . '_display', 'teaser'), '#default_value' => variable_get('uc_termsofservice_' . $type . '_display', 'teaser'),
); );
// Container for advanced settings.
$form['uc_termsofservice_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#weight' => 2,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// Checkbox to enable Rules.
$form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_rules'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Rules'),
'#description' => t('You can set the conditions under which the pane will be displayed with <a href="@url">Rules</a>', array('@url' => url('admin/workflow/rules/uc_termsofservice_display_pane/edit/conditions'))),
'#default_value' => variable_get('uc_termsofservice_' . $type . '_rules', 0),
);
// Handle ToS in a popup window. // Handle ToS in a popup window.
if (module_exists('modalframe')) { if (module_exists('modalframe')) {
// Container for advanced settings.
$form['uc_termsofservice_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#weight' => 2,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_popup'] = array( $form['uc_termsofservice_advanced_settings']['uc_termsofservice_' . $type . '_popup'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t('Open ToS in a popup modal window.'), '#title' => t('Open ToS in a popup modal window.'),
@ -383,7 +375,6 @@ function uc_termsofservice_checkout_form_validate($form, &$form_state) {
if (!$agreed) { if (!$agreed) {
$node = uc_termsofservice_get_node('checkout'); $node = uc_termsofservice_get_node('checkout');
// Issue #1818992 : the ID used in form_set_error is not a typo
form_set_error('panes][uc_termsofservice_agreement_checkout][tos_agree', t("In order to continue with the checkout process you must first accept the !tos", array('!tos' => $node->title))); form_set_error('panes][uc_termsofservice_agreement_checkout][tos_agree', t("In order to continue with the checkout process you must first accept the !tos", array('!tos' => $node->title)));
} }
} }

View File

@ -1,14 +1,16 @@
name = Session Limit name = Session Limit
description = "Limit simultaneous user sessions." description = "Limit simultaneous user sessions."
core = 7.x core = 7.x
configure = admin/config/people/session_limit
files[] = session_limit.install files[] = session_limit.install
files[] = session_limit.module files[] = session_limit.module
files[] = session_limit.tokens.inc files[] = session_limit.tokens.inc
files[] = tests/session_limit.test files[] = tests/session_limit.test
; Information added by Drupal.org packaging script on 2014-03-04 ; Information added by Drupal.org packaging script on 2016-02-24
version = "7.x-2.0" version = "7.x-2.2"
core = "7.x" core = "7.x"
project = "session_limit" project = "session_limit"
datestamp = "1393949919" datestamp = "1456312454"

View File

@ -83,7 +83,7 @@ function session_limit_menu() {
'access callback' => 'user_is_logged_in', 'access callback' => 'user_is_logged_in',
'type' => MENU_SUGGESTED_ITEM, 'type' => MENU_SUGGESTED_ITEM,
); );
$items['admin/config/people/session_limit'] = array( $items['admin/config/people/session-limit'] = array(
'title' => 'Session limit', 'title' => 'Session limit',
'description' => 'Configure session limits.', 'description' => 'Configure session limits.',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
@ -98,7 +98,7 @@ function session_limit_menu() {
'access arguments' => array('administer site configuration'), 'access arguments' => array('administer site configuration'),
'type' => MENU_DEFAULT_LOCAL_TASK, 'type' => MENU_DEFAULT_LOCAL_TASK,
); );
$items['admin/config/people/session_limit/roles'] = array( $items['admin/config/people/session-limit/roles'] = array(
'title' => 'Role limits', 'title' => 'Role limits',
'description' => 'Configure session limits by role.', 'description' => 'Configure session limits by role.',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
@ -106,7 +106,7 @@ function session_limit_menu() {
'access arguments' => array('administer session limits by role'), 'access arguments' => array('administer session limits by role'),
'type' => MENU_LOCAL_TASK, 'type' => MENU_LOCAL_TASK,
); );
$items['user/%user/session_limit'] = array( $items['user/%user/session-limit'] = array(
'title' => 'Session limit', 'title' => 'Session limit',
'description' => 'Configure session limit for one user.', 'description' => 'Configure session limit for one user.',
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
@ -304,6 +304,21 @@ function session_limit_action_info_alter(&$info) {
} }
} }
/**
* Implements hook_field_extra_fields().
*/
function session_limit_field_extra_fields() {
$extra['user']['user']['display'] = array(
'session_limit' => array(
'label' => t('Session limit'),
'description' => t('Session limit.'),
'weight' => 10,
),
);
return $extra;
}
/** /**
* Implements hook_user_view(). * Implements hook_user_view().
*/ */
@ -312,7 +327,9 @@ function session_limit_user_view($account, $view_mode) {
$account->content['session_limit'] = array( $account->content['session_limit'] = array(
'#title' => t('Session limit'), '#title' => t('Session limit'),
'#type' => 'user_profile_category', '#type' => 'user_profile_category',
'session_limit' => array('#value' => empty($account->data['session_limit']) ? t('Default') : $account->data['session_limit']) 'session_limit' => array(
'#markup' => empty($account->data['session_limit']) ? t('Default') : $account->data['session_limit'],
)
); );
} }
} }
@ -487,12 +504,14 @@ function session_limit_user_max_sessions_byrole($account) {
$limits = array(); $limits = array();
foreach ($account->roles as $rid => $name) { foreach ($account->roles as $rid => $name) {
$limits[] = variable_get("session_limit_rid_$rid", 0); $role_limit = variable_get("session_limit_rid_$rid", FALSE);
if (!empty($role_limit)) {
$limits[] = (int) $role_limit;
}
} }
rsort($limits); return empty($limits) ? 0 : max($limits);
return (int) $limits[0];
} }
/** /**
@ -554,7 +573,7 @@ function session_limit_invoke_session_limit($session, $op) {
if ($limit > 0) { if ($limit > 0) {
// Secure session ids are seperate rows in the database, but we don't want to kick // Secure session ids are seperate rows in the database, but we don't want to kick
// the user off there http session and not there https session or vice versa. This // the user off there http session and not there https session or vice versa. This
// is why this query is DISTINCT. // is why this query is DISTINCT.
$result = db_select('sessions', 's') $result = db_select('sessions', 's')
->distinct() ->distinct()
->fields('s', array('sid')) ->fields('s', array('sid'))
@ -599,7 +618,7 @@ function session_limit_session_limit($sid, $op) {
} }
$fields['uid'] = 0; $fields['uid'] = 0;
$query = db_update('sessions') db_update('sessions')
->fields($fields) ->fields($fields)
->condition('sid', $sid) ->condition('sid', $sid)
->execute(); ->execute();
@ -665,3 +684,31 @@ function _session_limit_bypass() {
return FALSE; return FALSE;
} }
/**
* Implements hook_variable_group_info().
*/
function session_limit_variable_group_info() {
$groups['session_limit'] = array(
'title' => t('Session limit'),
'access' => 'administer site configuration',
'path' => array('admin/config/people/session_limit/defaults'),
);
return $groups;
}
/**
* Implements hook_variable_info().
*/
function session_limit_variable_info($options) {
$variables['session_limit_logged_out_message'] = array(
'title' => t('Logged out message', array(), $options),
'description' => t('The message that is displayed to a user if the workstation has been logged out.<br />
@number is replaced with the maximum number of simultaneous sessions.', array(), $options),
'type' => 'string',
'localize' => TRUE,
'group' => 'session_limit',
);
return $variables;
}