added rights for simplenews subscriptions by roles
This commit is contained in:
		@@ -173,6 +173,16 @@ function materio_administration_user_default_permissions() {
 | 
			
		||||
    'module' => 'workflow',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'send newsletter'.
 | 
			
		||||
  $permissions['send newsletter'] = array(
 | 
			
		||||
    'name' => 'send newsletter',
 | 
			
		||||
    'roles' => array(
 | 
			
		||||
      'administrator' => 'administrator',
 | 
			
		||||
      'root' => 'root',
 | 
			
		||||
    ),
 | 
			
		||||
    'module' => 'simplenews',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'show workflow state form'.
 | 
			
		||||
  $permissions['show workflow state form'] = array(
 | 
			
		||||
    'name' => 'show workflow state form',
 | 
			
		||||
@@ -180,5 +190,54 @@ function materio_administration_user_default_permissions() {
 | 
			
		||||
    'module' => 'workflow',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'subscribe to newsletters'.
 | 
			
		||||
  $permissions['subscribe to newsletters'] = array(
 | 
			
		||||
    'name' => 'subscribe to newsletters',
 | 
			
		||||
    'roles' => array(
 | 
			
		||||
      'Adhérent' => 'Adhérent',
 | 
			
		||||
      'Contact opérationnel' => 'Contact opérationnel',
 | 
			
		||||
      'Premium' => 'Premium',
 | 
			
		||||
      'Student' => 'Student',
 | 
			
		||||
      'Utilisateur' => 'Utilisateur',
 | 
			
		||||
      'administrator' => 'administrator',
 | 
			
		||||
      'anonymous user' => 'anonymous user',
 | 
			
		||||
      'root' => 'root',
 | 
			
		||||
    ),
 | 
			
		||||
    'module' => 'simplenews',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'subscribe to simplenews category 6274'.
 | 
			
		||||
  $permissions['subscribe to simplenews category 6274'] = array(
 | 
			
		||||
    'name' => 'subscribe to simplenews category 6274',
 | 
			
		||||
    'roles' => array(
 | 
			
		||||
      'anonymous user' => 'anonymous user',
 | 
			
		||||
      'authenticated user' => 'authenticated user',
 | 
			
		||||
    ),
 | 
			
		||||
    'module' => 'materio_user',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'subscribe to simplenews category 6374'.
 | 
			
		||||
  $permissions['subscribe to simplenews category 6374'] = array(
 | 
			
		||||
    'name' => 'subscribe to simplenews category 6374',
 | 
			
		||||
    'roles' => array(
 | 
			
		||||
      'Adhérent' => 'Adhérent',
 | 
			
		||||
      'Utilisateur Alpha Tester' => 'Utilisateur Alpha Tester',
 | 
			
		||||
      'administrator' => 'administrator',
 | 
			
		||||
      'root' => 'root',
 | 
			
		||||
    ),
 | 
			
		||||
    'module' => 'materio_user',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  // Exported permission: 'subscribe to simplenews category 6585'.
 | 
			
		||||
  $permissions['subscribe to simplenews category 6585'] = array(
 | 
			
		||||
    'name' => 'subscribe to simplenews category 6585',
 | 
			
		||||
    'roles' => array(
 | 
			
		||||
      'Utilisateur Alpha Tester' => 'Utilisateur Alpha Tester',
 | 
			
		||||
      'administrator' => 'administrator',
 | 
			
		||||
      'root' => 'root',
 | 
			
		||||
    ),
 | 
			
		||||
    'module' => 'materio_user',
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  return $permissions;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,8 +8,10 @@ dependencies[] = admin_menu_toolbar
 | 
			
		||||
dependencies[] = ctools
 | 
			
		||||
dependencies[] = elysia_cron
 | 
			
		||||
dependencies[] = features
 | 
			
		||||
dependencies[] = materio_user
 | 
			
		||||
dependencies[] = menu
 | 
			
		||||
dependencies[] = role_delegation
 | 
			
		||||
dependencies[] = simplenews
 | 
			
		||||
dependencies[] = strongarm
 | 
			
		||||
dependencies[] = title
 | 
			
		||||
dependencies[] = views
 | 
			
		||||
@@ -65,7 +67,12 @@ features[user_permission][] = display drupal links
 | 
			
		||||
features[user_permission][] = flush caches
 | 
			
		||||
features[user_permission][] = participate in workflow
 | 
			
		||||
features[user_permission][] = schedule workflow transitions
 | 
			
		||||
features[user_permission][] = send newsletter
 | 
			
		||||
features[user_permission][] = show workflow state form
 | 
			
		||||
features[user_permission][] = subscribe to newsletters
 | 
			
		||||
features[user_permission][] = subscribe to simplenews category 6274
 | 
			
		||||
features[user_permission][] = subscribe to simplenews category 6374
 | 
			
		||||
features[user_permission][] = subscribe to simplenews category 6585
 | 
			
		||||
features[variable][] = admin_menu_cache_client
 | 
			
		||||
features[variable][] = admin_menu_devel_modules_enabled
 | 
			
		||||
features[variable][] = admin_menu_devel_modules_skip
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ function materio_user_init() {
 | 
			
		||||
 * Implements hook_permission().
 | 
			
		||||
 */
 | 
			
		||||
function materio_user_permission() {
 | 
			
		||||
  return array(
 | 
			
		||||
  $perms =  array(
 | 
			
		||||
    'view own user profile' =>  array(
 | 
			
		||||
      'title' => t('view own user profile'),
 | 
			
		||||
      'description' => t('view own user profile'),
 | 
			
		||||
@@ -23,6 +23,18 @@ function materio_user_permission() {
 | 
			
		||||
      'description' => t('Access to online payment'),
 | 
			
		||||
    ),
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  $simplenews_cats = simplenews_category_list();
 | 
			
		||||
  // dsm($simplenews_cats);
 | 
			
		||||
 | 
			
		||||
  foreach ($simplenews_cats as $tid => $name) {
 | 
			
		||||
    $perms["subscribe to simplenews category $tid"] =  array(
 | 
			
		||||
      'title' => t("subscribe to simplenews category $name"),
 | 
			
		||||
      // 'description' => t('Access to online payment'),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return $perms;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function materio_user_menu(){
 | 
			
		||||
@@ -199,6 +211,17 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
 | 
			
		||||
  //   //dsm($form, '$form');
 | 
			
		||||
  //   $form['account']['pass']['#type'] = "new_password_confirm";
 | 
			
		||||
  // }
 | 
			
		||||
 | 
			
		||||
  if ( $form_id == "simplenews_subscriptions_multi_block_form"){
 | 
			
		||||
    dsm($form);
 | 
			
		||||
    $options = array();
 | 
			
		||||
    foreach ($form['newsletters']['#options'] as $tid => $name) {
 | 
			
		||||
      if(user_access("subscribe to simplenews category $tid")){
 | 
			
		||||
        $options[$tid] = $name;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    $form['newsletters']['#options'] = $options;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// function materio_user_user_register_form_submit($form, &$form_state){
 | 
			
		||||
@@ -684,3 +707,12 @@ function materio_user_mandrill_mailsend_result($result) {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function materio_user_simplenews_subscriptions_multi_block_form_form_alter(&$form, &$form_state, $form_id){
 | 
			
		||||
  dsm($form_id, 'form_id');
 | 
			
		||||
  dsm($form, "form");
 | 
			
		||||
  dsm($form_state, "form_state");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user