I can give you the important parts of a and c.
Get users:
<%!
// getgroups: generates HTML-formatted string containing all users and groups
// below the selected group ID
// Calls itself to recurse through all child groups
public String getgroups(Integer si_id,IInfoStore oInfoStore,int iLevel)
{
String strHTML = "";
Date sendDate;
// Increment iLevel; abort if we get beyond 12 levels (to ensure we don't get stuck in a loop)
iLevel += 1;
if(iLevel > 12)
{
strHTML += "<tr><td colspan=3>Returning for: " + si_id + "</tr>";
return strHTML;
}
// First part of string -- level number of current group
strHTML = "<tr><td>&nbsp;</td></tr>";
strHTML += "<tr><td>Level: " + iLevel + "</td>";
try {
// This call gets the first (only) item in the list -- note that it is getting the PARENT
// group, not the subgroups
IInfoObject myUserGroup = getIoBySQL(oInfoStore," SELECT SI_SUBGROUPS,SI_ID,SI_GROUP_MEMBERS FROM CI_SYSTEMOBJECTS WHERE SI_ID = " + si_id);
// Display the parent group name
strHTML += "<td>" + myUserGroup.getTitle();
// Now we create an array (subUsers) containing the users of the parent group
// ..and add user into into the HTML string
Object[] subUsers = ((IUserGroup)myUserGroup).getUsers().toArray();
strHTML += "<td>" + (subUsers.length) + " Users" + "</tr>";
for (int x = 0; x < subUsers.length; x++)
{
IInfoObject oISUser = getIoBySQL(oInfoStore," SELECT si_name,SI_USERFULLNAME,SI_CREATION_TIME FROM CI_SYSTEMOBJECTS WHERE si_id = " + subUsers[x]);
String strFullName;
sendDate = (Date)oISUser.properties().getProperty("SI_CREATION_TIME").getValue();
String newdate = new SimpleDateFormat("MM/dd/yy hh:mm:ss a").format(sendDate);
if (!(oISUser.properties().getProperty("SI_USERFULLNAME") == null))
strFullName = (String)oISUser.properties().getProperty("SI_USERFULLNAME").getValue();
else
strFullName = " ";
strHTML += "<tr><td>" + (oISUser.getTitle() + "</td><td>" + newdate + "</td><td>" + strFullName + "</td><td>" + "</tr>");
}
// Create another array to contain the group's subgroups
Object[] subgroups = ((IUserGroup)myUserGroup).getSubGroups().toArray();
for (int x = 0; x < subgroups.length; x++)
{
//strHTML += (subgroups[x] + "<BR>");
int myval = ((Integer)subgroups[x]).intValue();
Integer myInt = new Integer(myval);
// Recursively call getgroups for each member of the parent group
strHTML += getgroups(myInt,oInfoStore,iLevel);
}
}
catch (SDKException e) {
}
return (strHTML);
}
%>
and for c. This presents the percentage of the parent folder, and of all content (not considering disk space)
out.print ("<table border=1 style='font-size: small;font-family: courier;'>");
IInfoObjects myoInfoObjects;
DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
//Execute the query
myoInfoObjects = oInfoStore.query("select top 10000 si_id,si_name from ci_infoobjects where si_parentid in (" + strIt + ") and si_id != 23 order by si_name");
ArrayList aList = new ArrayList();
aList.add("Top");
aList.add(new Long(0)); // file space
aList.add(new Long(1)); // file count
for (int x = 0; x < myoInfoObjects.size(); x++)
{
IInfoObject oInfoObject = (IInfoObject)myoInfoObjects.get(x);
if (!oInfoObject.getTitle().equals ("Categories") && !oInfoObject.getTitle().equals ("Personal Categories")) {
Integer duh = new Integer(oInfoObject.getID());
aList.add(getgroups(duh,oInfoStore,0,oInfoObject.getTitle()));
}
}
aList.set(1,setSizeAndSort(aList,0));
setCount(aList,0);
out.print (getTheArray(aList,0,"",((Long)aList.get(1)).longValue(),((Long)aList.get(1)).longValue()));
out.print ("</table>");
%>
<%!
ArrayList getgroups(Integer si_id,IInfoStore oInfoStore,int iLevel,String fullFolder)
{
ArrayList aList = new ArrayList();
// Add the name to the array
aList.add(fullFolder);
// Increment iLevel; abort if we get beyond 12 levels (to ensure we don't get stuck in a loop)
iLevel += 1;
if(iLevel > 100)
return aList;
try {
IInfoObjects ioInnerFiles = null;
IInfoObjects ioInnerFolders = null;
// Get this folder's deski/webi files
ioInnerFiles = oInfoStore.query(" SELECT top 10000 si_files,si_id,si_name,si_kind from ci_infoobjects where si_kind in ('fullclient','webi') and si_parentid = " + si_id + " and si_name != 'User Folders' order by si_name");
long lSize = 0;
for (int x = 0; x < ioInnerFiles.size(); x++)
{
IInfoObject oISFile = (IInfoObject)ioInnerFiles.get(x);
try
{
IFiles files = oISFile.getFiles();
for (int county = 0; county < files.size(); county++) {
IFile file = (IFile)files.get(county);
lSize += file.getSize();
}
}
catch (Exception wtf) {}; // ignore errors when getting Files
}
aList.add(new Long(lSize));
aList.add(new Long(ioInnerFiles.size()));
// Get the children of this group
ioInnerFolders = oInfoStore.query(" SELECT top 10000 si_files,si_id,si_name,si_kind from ci_infoobjects where si_children > 0 and si_parentid = " + si_id + " order by si_name");
for (int x = 0; x < ioInnerFolders.size(); x++)
{
IInfoObject oISFolder = (IInfoObject)ioInnerFolders.get(x);
ArrayList aTemp;
Integer theID = new Integer(oISFolder.getID());
aTemp = getgroups(theID,oInfoStore,iLevel,fullFolder + " / " + oISFolder.getTitle());
aList.add(aTemp);
}
}
catch (SDKException e) {
System.out.print (e);
}
return aList;
}
String formatPercent(float one,float two)
{
if(two == 0)
return "-";
NumberFormat f = NumberFormat.getPercentInstance();
f.setMinimumFractionDigits(1);
f.setMaximumFractionDigits(1);
return f.format(one / two);
}
String formatNumber(long inNum)
{
NumberFormat formatter = new DecimalFormat("###,###,###,###");
String s = formatter.format(inNum);
return s;
}
String formatNumber(Long inNum)
{
return formatNumber(inNum.longValue());
}
String getTheArray(ArrayList aList,int iLevel,String strSpace,long parentSize,long topSize)
{
if(aList.size() == 0)
{
return "";
}
String strString = "";
if( ((Long)aList.get(1)).longValue() > 0)
{
strString = "<tr><td>" + formatNumber(iLevel) +
"</td><td>" + strSpace + aList.get(0) +
"</td><td align=right>" + formatNumber((Long)aList.get(1)) +
"</td><td align=right>" + formatPercent( ((Long)aList.get(1)).longValue(),parentSize) +
"</td><td align=right>" + formatPercent( ((Long)aList.get(1)).longValue(),topSize) +
"</td><td align=right>" + formatNumber((Long)aList.get(2)) + "</td></tr>";
for(int i = 3;i < aList.size();i++)
{
strString += getTheArray((ArrayList)aList.get(i),iLevel+1,strSpace + "&nbsp;&nbsp;",((Long)aList.get(1)).longValue(),topSize);
}
}
return strString;
}
Long setSizeAndSort(ArrayList aList,int iLevel)
{
Long mySize;
mySize = (Long)aList.get(1);
// First, recurse - this makes sure the Total Size is set at the lower levels
for(int i = 3;i < aList.size();i++)
mySize = new Long ( mySize.longValue() + setSizeAndSort((ArrayList)aList.get(i),iLevel+1).longValue());
// Now sort
for(int i = 3;i < aList.size();i++)
for(int j = i+1;j < aList.size();j++)
{
if( ((Long)((ArrayList)aList.get(j)).get(1)).longValue() > ((Long)((ArrayList)aList.get(i)).get(1)).longValue())
{
ArrayList aTemp = (ArrayList)aList.get(i);
aList.set(i, aList.get(j));
aList.set(j,aTemp);
}
}
aList.set(1,mySize);
return mySize;
}
long setCount(ArrayList aList,int iLevel)
{
long myCount;
myCount = ((Long)aList.get(2)).longValue();
// First, recurse - this makes sure the Total Count is set at the lower levels
for(int i = 3;i < aList.size();i++)
myCount += setCount((ArrayList)aList.get(i),iLevel+1);
aList.set(2,new Long(myCount));
return myCount;
}
joepeters
(BOB member since 2002-08-29)