Browse Source

fixe contact ops materiaux access, fixe #21

Bachir Soussi Chiadmi 7 years ago
parent
commit
8d0f110c50

+ 13 - 4
sites/all/modules/gui/materiobasemod/materio_search_api.pages.inc

@@ -412,8 +412,17 @@ function msa_solrquery_breves($typed, $language, $user, $offset, $limit){
 function materio_search_api_actuality(){
   global $user;
 
-  if(isset($user->roles[1])){
-    $date_limit = strtotime('-6 month');
+  $useraccess = !isset($user->roles[10]) // student
+    && !isset($user->roles[11]) // alphatesteur
+    && !isset($user->roles[6]) // adherent
+    && !isset($user->roles[8]) // premium
+    && !isset($user->roles[12]) // translator
+    && !isset($user->roles[13]) // admin showroom
+    && !isset($user->roles[3]) // admin
+    && !isset($user->roles[4]); // root
+
+  if($useraccess){
+    $date_limit = strtotime('-4 month');
     // dsm(date('d m y', $date_limit));
   }
 
@@ -436,7 +445,7 @@ function materio_search_api_actuality(){
     ->propertyOrderBy('created', 'DESC')
     ->range($offset,$limit);
 
-  if(isset($user->roles[1])){
+  if($useraccess){
     $query->propertyCondition('created', $date_limit, '>');
   }
 
@@ -449,7 +458,7 @@ function materio_search_api_actuality(){
     ->propertyCondition('status', 1)
     ->entityCondition('bundle', array('breve'));
   // dsm($count, 'count');
-  if(isset($user->roles[1])){
+  if($useraccess){
     $count_query->propertyCondition('created', $date_limit, '>');
   }
   $count = $count_query->count()->execute();

+ 9 - 1
sites/all/themes/gui/materiobasetheme/inc/template.theme-overrides.inc

@@ -261,7 +261,15 @@ function materiobasetheme_image_style($variables) {
 
   # hide title and alt for non adherent users
   global $user;
-  if(isset($user->roles[1]) || isset($user->roles[7])){
+  if(!isset($user->roles[10]) // student
+      && !isset($user->roles[11]) // alphatesteur
+      && !isset($user->roles[6]) // adherent
+      && !isset($user->roles[8]) // premium
+      && !isset($user->roles[12]) // translator
+      && !isset($user->roles[13]) // admin showroom
+      && !isset($user->roles[3]) // admin
+      && !isset($user->roles[4]) // root
+    ){
     unset($variables['title']);
     unset($variables['alt']);
   }

+ 9 - 1
sites/all/themes/gui/materiobasetheme/preprocess/field.pre.php

@@ -10,7 +10,15 @@ $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name']
 if($vars['element']['#field_name'] == 'field_materiau_image'){
 	global $user;
 	// dsm($vars);
-	if(isset($user->roles[1])){
+	if( !isset($user->roles[10]) // student
+    && !isset($user->roles[11]) // alphatesteur
+    && !isset($user->roles[6]) // adherent
+    && !isset($user->roles[8]) // premium
+    && !isset($user->roles[12]) // translator
+    && !isset($user->roles[13]) // admin showroom
+    && !isset($user->roles[3]) // admin
+    && !isset($user->roles[4]) // root
+    && in_array($view_mode, $vm)){
 		$items = $vars['items'];
 		$vars['items'] = array($items[0]);
 	}

+ 11 - 1
sites/all/themes/gui/materiobasetheme/templates/node--materiau.tpl.php

@@ -13,8 +13,18 @@
 
   <?php
   global $user;
+  // dsm($user);
   $vm = array('cardmedium', 'cardbig'); //, upgrade with 'cardfull' needs more design works, postponed
-  if( isset($user->roles[1]) && in_array($view_mode, $vm)):
+  // if( isset($user->roles[1]) && in_array($view_mode, $vm)):
+  if( !isset($user->roles[10]) // student
+    && !isset($user->roles[11]) // alphatesteur
+    && !isset($user->roles[6]) // adherent
+    && !isset($user->roles[8]) // premium
+    && !isset($user->roles[12]) // translator
+    && !isset($user->roles[13]) // admin showroom
+    && !isset($user->roles[3]) // admin
+    && !isset($user->roles[4]) // root
+    && in_array($view_mode, $vm)):
   ?>
   <div class="side oops">
     <p>