|
From: <sv...@de...> - 2005-05-27 17:34:07
|
Author: pcamacho
Date: 2005-05-27 13:34:05 -0400 (Fri, 27 May 2005)
New Revision: 1169
Modified:
humano2/trunk/components/webTools/Adapter.cs
humano2/trunk/web/builder/site/foldermanagement.aspx.cs
Log:
FIX: #134.
Modified: humano2/trunk/components/webTools/Adapter.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/components/webTools/Adapter.cs 2005-05-27 16:46:50 UTC =
(rev 1168)
+++ humano2/trunk/components/webTools/Adapter.cs 2005-05-27 17:34:05 UTC =
(rev 1169)
@@ -1880,6 +1880,103 @@
return dt1;
}
=20
-
+ ///<summary>
+ /// Returns the list of all descendants of a folder (all levels
+ ///</summary>
+ public int [] GetAllDescendantsOfFolder(int folderId)
+ {
+ int [] directChilds =3D complex.GetChildsOfFolder(folderId);
+ int sizeDirectChilds =3D directChilds.Length;
+ =20
+ if(sizeDirectChilds =3D=3D 0) //we're done
+ {
+ Logger.Log("GetAllDescendantsIoFolder: " + folderId + " =
has no child",LogLevel.Trace);
+ return directChilds; =20
+ }
+ else //Follow recursivity and build tab
+ {
+ Logger.Log("GetAllDescendantsIoFolder: " + folderId + " h=
as " + sizeDirectChilds + " childs.",LogLevel.Trace);
+ int [] aux =3D null;
+ for(int i=3D0;i<sizeDirectChilds;i++)
+ {
+ aux =3D ConcatInt32Array(GetAllDescendantsOfFolder(d=
irectChilds[i]),aux);
+ }
+ int [] res =3D ConcatInt32Array(aux,directChilds);
+ return res;
+ }
+ } =20
+ =20
+ private int [] ConcatInt32Array(int [] arr1, int [] arr2)
+ {
+ =20
+ int sizeArr1;
+ int sizeArr2;
+ =20
+ if(arr1!=3Dnull)
+ {
+ sizeArr1 =3D arr1.Length; =20
+ }
+ else
+ {
+ sizeArr1 =3D 0; =20
+ }
+ =20
+ if(arr2!=3Dnull)
+ {
+ sizeArr2 =3D arr2.Length; =20
+ }
+ else
+ {
+ sizeArr2 =3D 0; =20
+ }
+ =20
+ int size =3D sizeArr1 + sizeArr2;
+ Logger.Log("ConcatInt32Array. size=3D " + size, LogLevel.Tra=
ce);
+ int [] res =3D new int[size];
+ =20
+ //copy first array
+ if(arr1 !=3D null)
+ {
+ for(int i=3D0;i<arr1.Length;i++)
+ {
+ res[i] =3D arr1[i];
+ }
+ }
+ //copy second array
+ if(arr2 !=3D null)
+ {
+ for(int i=3D0;i<arr2.Length;i++)
+ {
+ res[i+sizeArr1] =3D arr2[i]; =20
+ }
+ }
+ =20
+ Logger.Log("Adapter Concat",LogLevel.Trace);
+ for(int i=3D0;i<size;i++)
+ {
+ Logger.Log("res[" + i + "]=3D " +res[i] + " ",LogLevel.T=
race);
+ }
+ =20
+ return res;
+ }
+ =20
+ public bool IsDescendantOfFolder(int folderId, int folderIsDesce=
ndantId)
+ {
+ int [] allDescendants =3D GetAllDescendantsOfFolder(folderId=
);
+ bool res =3D false;=20
+ =20
+ //Look for the folderIsDescendantId in the descendant list
+ int size =3D allDescendants.Length;
+ for(int i=3D0; i< size; i++)
+ {
+ if(folderIsDescendantId =3D=3D allDescendants[i])
+ {
+ res =3D true;
+ break;
+ }
+ }
+ =20
+ return res;
+ }
}
}
Modified: humano2/trunk/web/builder/site/foldermanagement.aspx.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/builder/site/foldermanagement.aspx.cs 2005-05-27 16=
:46:50 UTC (rev 1168)
+++ humano2/trunk/web/builder/site/foldermanagement.aspx.cs 2005-05-27 17=
:34:05 UTC (rev 1169)
@@ -244,6 +244,12 @@
}
}
=09
+ =20
+ ///<summary>
+ ///Get the list of all folders (id,name) from a specific domain
+ ///</summary>
+ ///<param name=3D"domainId">id of domain</param>
+ ///<returns>list of folders with id and name</returns>
private DataTable getListFolder(int domainId)
{
string filtro =3D String.Format("34|4|'{0}'|0|0",domainId);
@@ -496,56 +502,20 @@
return;
}
=20
- arrFolder =3D getListFolderChilds(domainId);
foreach(DataRow row in dtResult.Rows)
{
- strHtml +=3D getNextOptionFolder(row,arrFolder,folderId);
+ //Don't allow a folder to be a child of one of its desce=
ndants and himself
+ adapter dbAdapter =3D userCred.CoreAdapter;
+ if(!dbAdapter.IsDescendantOfFolder(folderId, Convert.ToInt32(row["id=
_entity"]))
+ && folderId !=3D Convert.ToInt32(row["id_entity"]) )=
=20
+ {
+ strHtml +=3D String.Format("<option value=3D\"{0}\" =
selected>{1}</option>",row["id_entity"],row["folderName"]);
+ }
}
Response.Write(strHtml);
}
=20
- private string getNextOptionFolder(DataRow row, ArrayList arrFolder, i=
nt folderId)
- {
- string strHtml =3D "";
- int flag =3D 0;
=09
- int id_entity =3D Convert.ToInt32(row["id_entity"]);
- =09
- if(folderId =3D=3D id_entity)
- {
- return strHtml;
- }
- if (arrFolder !=3D null)
- {
- for(int pos =3D 0;pos < arrFolder.Count;pos++)
- {
- if (((strct_folderNode)arrFolder[pos]).idParent =3D=3D folderId)
- {
- if(((strct_folderNode)arrFolder[pos]).idNode =3D=3D id_entity)
- {
- flag =3D 1;
- }
- }
- }
- }
- if(folderParentId !=3D null && folderParentId.Length > 0)
- {
- if(Convert.ToInt32(folderParentId) =3D=3D id_entity)
- {
- if(flag =3D=3D 0)
- {
- strHtml =3D String.Format("<option value=3D\"{0}\" selected>{1}</o=
ption>",row["id_entity"],row[1]);
- return strHtml;
- }
- }
- }
- if(flag =3D=3D 0)
- {
- strHtml +=3D String.Format("<option value=3D\"{0}\">{1}</option>",ro=
w["id_entity"],row[1]);
- }
- return strHtml;
- }
-
public void html_getFolderParentId()
{
Response.Write("0");
|