04-27-2011 08:46 AM
<!– Viewing Content Models in the Advanced Search –>
<config replace="true" evaluator="string-compare" condition="AdvancedSearch">
<advanced-search>
<!– Forms for the advanced search type list –>
<forms>
<!–
The 'form' config element contains the name of the model type
of the form to display.
The element supports the following optional attributes:
id = form id, the id of "search" will be assumed if not set
label = label text to display - defaults to model type if
not set
labelId = I18N message id of label text to display
description = description text to display
descriptionId = I18N message id of description text to
display
–>
<form labelId="search.form.label.cm_content"
descriptionId="search.form.desc.cm_content">cm:content</form>
<form labelId="search.form.label.cm_folder"
descriptionId="search.form.desc.cm_folder">cm:folder</form>
<!– Definition of new Content Type: MyContentType –>
<form id="search.form.id.myModel_myContentType"
labelId="search.form.label.myModel_myContentType"
descriptionId="search.form.desc.myModel_myContentType">
myModel:myContentType
</form>
</forms>
</advanced-search>
</config>
<!– –>
<!– Definition of new Content Type: MyContentType –>
<config evaluator="model-type" condition="myModel:myContentType">
<forms>
<!– Search form –>
<form id="MY_GROUP_FORM">
<field-visibility>
<show id="cm:name" />
<show id="cm:title" force="true" />
<show id="cm:description" force="true" />
<show id="mimetype" />
</field-visibility>
<appearance>
<field id="mimetype">
<control
template="/org/alfresco/components/form/controls/
mimetype.ftl" />
</field>
</appearance>
</form>
</forms>
</config>
<!– End of Definition of new Content Type: MyContentType –>
NOTA: por la precondición es muy importante que el atributo "id" del objeto "form" coincida con el nombre del grupo creado en Alfresco Share.
# Definition of new Content Type: MyContentType
search.form.id.myModel_myContentType=MY_GROUP_FORM
search.form.label.myModel_myContentType=My search form
search.form.desc.myModel_myContentType=Description of my search form.
# End of Definition of new Content Type: MyContentType
NOTA: por la precondición es muy importante que el atributo "search.form.id.myModel_myContentType" coincida con el nombre del grupo creado en Alfresco Share.
// Declaracion de variables.
var groups = new Array();
var groupsNames = new Array();
var groupName;
var length;
var status = false;
var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "?groups=true");
// Se obtienen los grupos del usuario y se guarda el nombre de los mismos en
// otro array. No entran aquellos nombres que comiencen por "sites_", ya que
// estos hacen referencia a permisos de Share y no a grupos concretos.
if (result.status == 200 && result != "{}") {
status = true;
var users = eval('(' + result + ')');
groups = users.groups;
length = groups.length;
var j = 0;
for (var i = 0; i < length; i++) {
groupName = groups[i].displayName;
if (groupName.lastIndexOf("site_") < 0) {
groupsNames[j] = groups[i];
j++;
}
}
length = groupsNames.length;
for (var i = 0; i < length; i++) {
groupName = groupsNames[i].displayName;
j = groupName.lastIndexOf("_");
var nameLength = groupName.length;
var groupNameMin = groupName.substr(j, nameLength);
groupNameMin = groupNameMin.toUpperCase();
if (groupNameMin.indexOf("ADMIN") > 0 ||
groupNameMin.indexOf("COLAB") > 0 ||
groupNameMin.indexOf("CONTR") > 0 ||
groupNameMin.indexOf("CONSU") > 0) {
groupsNames[i].displayName = groupName.substr(0, j);
}
}
}
A continuación se incluye dentro del segundo bucle "for" la casuística que permite valorar qué tipo de formulario se está tratando, si concuerda o no con el grupo del usuario y si debe presentarse aún no habiendo concordancia.
// fetch the request params required by the advanced search component template
var siteId = (page.url.templateArgs["site"] != null) ? page.url.templateArgs["site"] : "";
// get the search forms from the config
var formsElements = config.scoped["AdvancedSearch"]["advanced-search"].getChildren("forms");
var searchForms = [];
for (var x = 0, forms; x < formsElements.size(); x++) {
forms = formsElements.get(x).childrenMap["form"];
for (var i = 0, form, formId, label, desc; i < forms.size(); i++) {
form = forms.get(i);
// get optional attributes and resolve label/description text
formId = form.attributes["id"];
// Se anade esta casuistica para dar un valor desde el inicio a la variable
// "formId".
if (formId == null || formId == "") {
formId = "search";
} else {
formId = msg.get(formId);
}
// Se anaden las siguientes casuisticas para evitar que las variables
// "label" y "desc" queden vacias.
label = form.attributes["label"];
if (label == null || label =="") {
label = form.attributes["labelId"];
if (label != null && label != "") {
label = msg.get(label);
} else {
label = form.value;
}
}
desc = form.attributes["description"];
if (desc == null || desc == "") {
desc = form.attributes["descriptionId"];
if (desc != null && desc != "") {
desc = msg.get(desc);
} else {
desc = "No existe una descripcion para este aspecto.";
}
}
Y por último, continuando dentro del segundo bucle "for", se almacenan los formularios de búsqueda, teniendo en cuenta que sólo aquellos que coincidan con los grupos del usuario y los dos que vienen por defecto (para buscar contenidos y para buscar carpetas) serán los elegidos.
// Se anade el siguiente bloque para evitar que se almacenen los formularios de busquedas
// que no correspondan con los grupos a los que pertenece el usuario.
if (label == "Contenido" || label == "Carpetas") {
// create the model object to represent the form definition
searchForms.push(
{
id: formId,
type: form.value,
label: label,
description: desc
});
} else {
if (status) {
length = groupsNames.length;
for (var m = 0; m < length; m++) {
groupName = groupsNames[m].displayName;
if (groupName == formId) {
// create the model object to represent the form definition
searchForms.push(
{
id: formId,
type: form.value,
label: label,
description: desc
});
}
}
} else {
// create the model object to represent the form definition
searchForms.push(
{
id: formId,
type: form.value,
label: label,
description: desc
});
}
}
04-28-2011 06:09 AM
04-28-2011 10:45 AM
04-03-2012 07:16 PM
Siento haber colocado este hilo aquí, debería ir en el subforo "Comparte tu Código" ops:. Si algún moderador puede que lo mueva de sitio y elimine esta respuesta (si quiere).
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.