LSselect : Added feature to filter object selection that can't be modified by user
authorBenjamin Renard <brenard@easter-eggs.com>
Wed, 11 Nov 2009 19:58:28 +0000 (19:58 +0000)
committerBenjamin Renard <brenard@easter-eggs.com>
Wed, 11 Nov 2009 19:58:28 +0000 (19:58 +0000)
trunk/includes/class/class.LSselect.php
trunk/select.php
trunk/templates/default/select_table.tpl

index 266b76f..0916a6b 100644 (file)
@@ -82,6 +82,10 @@ class LSselect {
       LSerror :: addErrorCode('LSsession_12');
     }
   }
       LSerror :: addErrorCode('LSsession_12');
     }
   }
+  
+  public static function selectablly($obj,$args) {
+    return (LSsession::canEdit($obj->type,$obj->dn,$args))?1:0;
+  }
 }
 
 ?>
 }
 
 ?>
index 7312706..ebbdbcf 100644 (file)
@@ -35,12 +35,27 @@ if(LSsession :: startLSsession()) {
         $LSsearch -> setParamsFormPostData();
         $LSsearch -> setParam('nbObjectsByPage',NB_LSOBJECT_LIST_SELECT);
         
         $LSsearch -> setParamsFormPostData();
         $LSsearch -> setParam('nbObjectsByPage',NB_LSOBJECT_LIST_SELECT);
         
+        $selectablly=((isset($_REQUEST['selectablly']))?$_REQUEST['selectablly']:0);
+        
+        if (is_string($_REQUEST['editableAttr'])) {
+          $LSsearch -> setParam(
+            'customInfos',
+            array (
+              'selectablly' => array (
+                'function' => array('LSselect','selectablly'),
+                'args' => $_REQUEST['editableAttr']
+              )
+            )
+          );
+          $selectablly=1;
+        }
         $multiple = ((isset($_REQUEST['multiple']))?1:0);
         
         $searchForm = array (
           'action' => $_SERVER['PHP_SELF'],
           'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ),
           'multiple' => $multiple,
         $multiple = ((isset($_REQUEST['multiple']))?1:0);
         
         $searchForm = array (
           'action' => $_SERVER['PHP_SELF'],
           'recursive' => (! LSsession :: isSubDnLSobject($LSobject) && LSsession :: subDnIsEnabled() ),
           'multiple' => $multiple,
+          'selectablly' => $selectablly,
           'labels' => array (
             'submit' => _('Search'),
             'approx' => _('Approximative search'),
           'labels' => array (
             'submit' => _('Search'),
             'approx' => _('Approximative search'),
@@ -60,6 +75,7 @@ if(LSsession :: startLSsession()) {
             $LSsearch -> getHiddenFieldForm(),
             array(
               'ajax' => 1,
             $LSsearch -> getHiddenFieldForm(),
             array(
               'ajax' => 1,
+              'selectablly' => $selectablly,
               'multiple' => $multiple
             )
           )
               'multiple' => $multiple
             )
           )
index 1e529d7..75d6539 100644 (file)
@@ -26,7 +26,7 @@
   </tr>
 {foreach from=$page.list item=object}
     <tr class='{cycle values="LSobject-list,LSobject-list LSobject-list-bis"}'>
   </tr>
 {foreach from=$page.list item=object}
     <tr class='{cycle values="LSobject-list,LSobject-list LSobject-list-bis"}'>
-        <td class='LSobject-list LSobject-select-check'><input type='{if $searchForm.multiple}checkbox{else}radio{/if}' name='LSobjects_selected[]' value='{$object->dn}' {if $object->LSselect}checked="true"{/if} class='LSobject-select' /></td>
+        <td class='LSobject-list LSobject-select-check'><input type='{if $searchForm.multiple}checkbox{else}radio{/if}' name='LSobjects_selected[]' value='{$object->dn}' {if $object->LSselect}checked="true"{/if}{if $searchForm.selectablly}{if !$object->selectablly} disabled{/if}{/if} class='LSobject-select' /></td>
         <td class='LSobject-list LSobject-select-names'>{$object->displayName}</td>
         {if $LSsearch->displaySubDn}
           <td class='LSobject-list LSobject-select-level'>{$object->subDn}</td>
         <td class='LSobject-list LSobject-select-names'>{$object->displayName}</td>
         {if $LSsearch->displaySubDn}
           <td class='LSobject-list LSobject-select-level'>{$object->subDn}</td>