cancel
Showing results for 
Search instead for 
Did you mean: 

how to modify datalists

icm76
Champ in-the-making
Champ in-the-making
Hi,

please help me identify the correct files for changing datalists behaviour for hiding certain lists for certain users (maybe similar to http://code.google.com/p/qbreng-alfresco-extensions/wiki/WorkflowGrants?)
- where datalists are populated and displayed in Share


Thank you,
Catalin
1 REPLY 1

icm76
Champ in-the-making
Champ in-the-making
I have added the following modifications to datalists.get.js (in tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\data-lists).

The file executed because I see the logs but the dataLists still remain the same ones in the browser - it seems that, somewhere between this file and the browser, there is another retrieval of dataLists but I do not know where… plese help me with this.


IN share-config-custom.xml
<config evaluator="string-compare" condition="DataLists">
      <!–
           A list of workflow definitions that are displayed in Share start-workflow page based on grant options
           - grant-type: "user" or "group"
           - grant-name: group name or user name (based on grant-type) allowed
         –>
      <grant-datalists>
         <datalist name="ruc:RegistruUnicCorespondenta" grant-type="user" grant-name="ureg" />
         <datalist name="dl:RegistruUnicCorespondenta" grant-type="user" grant-name="ureg" />
      </grant-datalists>
   </config>

**** and in ** datalists.get.js
function oc(a)
{
   var o = {};
   for(var i=0;i<a.length;i++)
   {
      o[a.itemName]='';
   }
   return o;
}

function getVisibleDataListsNames()
{
   var visibleDLNames = [],
       myconn = remote.connect("alfresco"),
      myres = myconn.get("/api/people/"+ user.name +"?groups=true");
  
   if (myres.status == 200)
   {
      var groups = eval('(' + myres + ')').groups,
            grantDL = config.scoped["DataLists"]["grant-datalists"].childrenMap["datalist"];
      if (grantDL)
      {
         for (var i = 0, il = grantDL.size(); i < il; i++)
         {
            if (grantDL.get(i).attributes["grant-type"] == "group")
            {
               if (grantDL.get(i).attributes["grant-name"] in oc(groups))
               {
                  // The user can start the workflow because he belongs to the group allowed
                  continue;
               }
            } else if (grantDL.get(i).attributes["grant-type"] == "user")
            {
               if (grantDL.get(i).attributes["grant-name"] == user.name)
               {
                  // The user can start the workflow because he is the allowed
                  continue;
               }
            }
            visibleDLNames.push(grantDL.get(i).attributes["name"]);
         }
      }
      return visibleDLNames;
   }
   return [];
}

function getListTypes()
{
   var types = [],
      result = remote.call("/api/classes/dl_dataListItem/subclasses");
  
   if (result.status == 200)
   {
      var classes = eval('(' + result + ')'),
         subclass,
         visibleDL = getVisibleDataListsNames();
        
         logger.log("*** datalists.get.js: visible" + visibleDL + ";user:" + user.name);
     
      for (var i = 0, ii = classes.length; i < ii; i++)
      {
         subclass = classes;
         if (subclass.name == "dl:dataListItem")
         {
            // Ignore abstract parent type
            continue;
         }
      
         if (visibleDL){
            logger.log("*** datalists.get.js 111 in if visibleDL:" + subclass.name + ";" + subclass.title);

            for each (el in visibleDL) {
               if (subclass.name == el)
               {
                  logger.log("*** datalists.get.js 111 in for + if. el:" + el);
                  types.push(
                  {
                     name: subclass.name,
                     title: subclass.title,
                     description: subclass.description
                  });
               }
            }
         }
         else {
            logger.log("*** datalists.get.js in else:" + subclass.name + ";" + subclass.title);
             types.push(
             {
                  name: subclass.name,
                  title: subclass.title,
                  description: subclass.description
             });
         }
      } //for i
   } //if
   
   logger.log("*** datalists.get.js types:" + types);

   return types;
}//function

model.listTypes = getListTypes();

function main()
{
   // Widget instantiation metadata…
   var dataLists = {
      id : "DataLists",
      name : "Alfresco.component.DataLists",
      options : {
         siteId : (page.url.templateArgs.site != null) ? page.url.templateArgs.site : "",
         containerId : template.properties.container != null ? template.properties.container : "dataLists",
         listId : (page.url.args.list != null) ? page.url.args.list : "",
         listTypes : model.listTypes
      }
   };
  
   model.widgets = [dataLists];
}

main();