package weaver.docs;

import java.util.ArrayList;
import java.util.Hashtable;

import weaver.hrm.orggroup.HrmOrgGroupComInfo;
import weaver.conn.RecordSet;
import weaver.crm.Maint.CustomerInfoComInfo;
import weaver.crm.Maint.CustomerTypeComInfo;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.general.KnowledgeTransMethod;
import weaver.hrm.companyvirtual.CompanyVirtualComInfo;
import weaver.hrm.companyvirtual.ResourceVirtualComInfo;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.hrm.roles.RolesComInfo;
import weaver.share.ShareManager;
import weaver.systeminfo.SystemEnv;
import weaver.hrm.job.JobTitlesComInfo;
public class DocShare extends BaseBean {
	public ResourceComInfo rcc;

	public SubCompanyComInfo scci;

	public DepartmentComInfo dci;

	public RolesComInfo rci;

	public CustomerTypeComInfo ctci;

	public CustomerInfoComInfo cici;
	public HrmOrgGroupComInfo hogci;
	private ShareManager ShareManager;
	private KnowledgeTransMethod knotm;
	private CompanyVirtualComInfo cvc;
	private ResourceVirtualComInfo rvc;
	private JobTitlesComInfo jbcom;

	public DocShare() {
		super();
		try {
			jbcom=new JobTitlesComInfo();
			cvc=new CompanyVirtualComInfo();
			rvc= new ResourceVirtualComInfo();
			rcc = new ResourceComInfo();
			knotm = new KnowledgeTransMethod();
			scci = new SubCompanyComInfo();
			dci = new DepartmentComInfo();
			rci = new RolesComInfo();
			ctci = new CustomerTypeComInfo();
			cici = new CustomerInfoComInfo();
			hogci = new HrmOrgGroupComInfo();
			ShareManager = new ShareManager();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 得到相关的共享字符串
	 * @param stringType
	 *            1:与创建人相关的默认共享 2:与创建人无关的默认共享 3:与客户相关的默认共享 4:与创建人相关的默认共享(外部用户创建)
	 *            5:非默认共享
	 * @param docId
	 *            文档的ID
	 * @return 相关的共享字符串
	 */
	public String getShareTRString(int stringType, int docId,
			String needCheckbox, int userLanguage) {
		return this.getShareTRString(stringType,docId,needCheckbox,userLanguage,true);
	}
	
	/**
	 * 得到相关的共享字符串
	 * @param stringType
	 *            1:与创建人相关的默认共享 2:与创建人无关的默认共享 3:与客户相关的默认共享 4:与创建人相关的默认共享(外部用户创建)
	 *            5:非默认共享
	 * @param docId
	 *            文档的ID
	 * @return 相关的共享字符串
	 */
	public String getShareTRString(int stringType, int docId,
			String needCheckbox, int userLanguage,boolean canShare) {
		String shareTRString = "";
		String sqlStr = "";
		String createrName = "";
		String isAllowModiMShare = "0";
		String isAllowModiNMShare = "0";
		RecordSet rs = new RecordSet();

		rs
				.executeSql("select d2.allownModiMshareL,d2.allownModiMshareW,d2.shareable from docdetail d1,DocSecCategory d2 where d1.seccategory=d2.id and d1.id="
						+ docId);
		if (rs.next()) {
			// if (stringType==4){
			// isAllowModiMShare =
			// Util.null2String(rs.getString("allownModiMshareW"));
			// } else {
			// 修改了一下用 allownModiMshareL代替了所有的默认共享
			isAllowModiMShare = Util.null2String(rs
					.getString("allownModiMshareL"));
			// }
			isAllowModiNMShare = Util.null2String(rs.getString("shareable"));
		}

		if (stringType == 1) { // 与创建人相关的默认共享 (内部)
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype between 80 and 85 and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if ((!"1".equals(isAllowModiMShare)||!canShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case 80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					createrName = shareRealName;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(15763, userLanguage);
					break;
				case 81: // 与创建人直接上级相关
					shareName = SystemEnv.getHtmlLabelName(18583, userLanguage);
					shareRealName = rcc.getLastname(rcc.getManagerID(""
							+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = rcc.getLastname("" + shareUserId)
							+ SystemEnv.getHtmlLabelName(18940, userLanguage);
					break;

				case 84: // 与创建人分部相关
					shareName = SystemEnv.getHtmlLabelName(18937, userLanguage);
					String departmentId = rcc.getDepartmentID("" + shareUserId);
					String subCompanyName = scci.getSubCompanyname(dci
							.getSubcompanyid1(departmentId));
					shareRealName = subCompanyName;
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = subCompanyName + "&nbsp;"
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ ">=" + secLevel
							+ SystemEnv.getHtmlLabelName(18941, userLanguage);
					break;
				case 85: // 与创建人部门相关
					shareName = SystemEnv.getHtmlLabelName(18938, userLanguage);
					departmentId = rcc.getDepartmentID("" + shareUserId);
					String departmentName = dci.getDepartmentname(departmentId);
					String subcompanyid = rcc.getSubCompanyID("" + shareUserId);
					String subcompanyname = scci.getSubcompanyname(subcompanyid);

					shareRealName = departmentName+"["+subcompanyname+"]";
					if ("".equals(departmentName))
						continue;
					shareRealLevel = departmentName + "&nbsp;"
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ "" + ">=" + secLevel
							+ SystemEnv.getHtmlLabelName(18942, userLanguage);
					break;
				}
				if (shareLevel == 1) {
					shareRealType = SystemEnv.getHtmlLabelName(18932,
							userLanguage);
					//TD12005 START
					int downloadLevel = Util.getIntValue(rs.getString("downloadlevel"),0);
					if (downloadLevel == 1) {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23733, userLanguage) + ")"; 
					} else {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23734, userLanguage) + ")";
					}//TD12005 END
				}
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(18933,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(18934,
							userLanguage);

				shareTRString += "<TR>\n";
				if ("true".equalsIgnoreCase(needCheckbox))
					shareTRString += "	<TD><INPUT TYPE='CHECKBOX' "
							+ isDisabled + " CLASS='INPUTSTYLE' VALUE="
							+ shareId + " NAME='" + chkShareId + "'></TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareName + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealLevel + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealName + "</TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareRealType + "</TD>\n";
				shareTRString += "</TR>\n";
				shareTRString += "<TR><TD CLASS=LINE COLSPAN=5></TD></TR>\n";
			}
		} else if (stringType == 2) { // 与创建人本人无关的默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype between 1 and 79  and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareCrmId = rs.getInt("crmid");
				int shareLevel = rs.getInt("sharelevel");

				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if ((!"1".equals(isAllowModiMShare)||!canShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case 1: // 人力资源
					shareName = SystemEnv.getHtmlLabelName(179, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					break;
				case 2: // 分部
					int subcompanyId = rs.getInt("subcompanyid");
					shareName = SystemEnv.getHtmlLabelName(141, userLanguage);
					shareRealName = scci.getSubCompanyname("" + subcompanyId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18941, userLanguage);
					break;
				case 3: // 部门
					int departmentId = rs.getInt("departmentid");
					shareName = SystemEnv.getHtmlLabelName(18939, userLanguage);
					shareRealName = dci.getDepartmentname("" + departmentId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18942, userLanguage);
					break;
				case 4: // 角色成员
					int roleId = rs.getInt("roleId");
					int rolelevel = rs.getInt("rolelevel");
					String roleLevelName = "";
					switch (rolelevel) {
					case 0:
						roleLevelName = SystemEnv.getHtmlLabelName(18939,
								userLanguage);
						break;
					case 1:
						roleLevelName = SystemEnv.getHtmlLabelName(141,
								userLanguage);
						break;
					case 2:
						roleLevelName = SystemEnv.getHtmlLabelName(140,
								userLanguage);
						break;
					}

					shareName = SystemEnv.getHtmlLabelName(18936, userLanguage);
					shareRealName = rci.getRolesRemark("" + roleId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(3005,
							userLanguage)
							+ "="
							+ roleLevelName
							+ "  "
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18945, userLanguage);
					break;
				case 6: // 群组
					int orgGroupId = rs.getInt("orgGroupId");
					shareName = SystemEnv.getHtmlLabelName(24002, userLanguage);
					shareRealName = hogci.getOrgGroupName("" + orgGroupId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(431, userLanguage);
					break;
				case 5: // 所有人
					shareName = SystemEnv.getHtmlLabelName(1340, userLanguage);
					shareRealName = SystemEnv.getHtmlLabelName(1340,
							userLanguage);
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18943, userLanguage);
					break;
				case 9: // 具体客户
					shareName = SystemEnv.getHtmlLabelName(18935, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareCrmId);
					if ("".equals(shareRealName))
						continue;
					// shareRealLevel=createrName+"的经理的所有上级";
					break;
				}
				if (shareLevel == 1) {
					shareRealType = SystemEnv.getHtmlLabelName(18932,
							userLanguage);
					//TD12005 START
					int downloadLevel = Util.getIntValue(rs.getString("downloadlevel"),0);
					if (downloadLevel == 1) {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23733, userLanguage) + ")"; 
					} else {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23734, userLanguage) + ")";
					}//TD12005 END
				}
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(18933,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(18934,
							userLanguage);

				shareTRString += "<TR>\n";
				if ("true".equalsIgnoreCase(needCheckbox))
					shareTRString += "	<TD><INPUT TYPE='CHECKBOX' "
							+ isDisabled + " CLASS='INPUTSTYLE' VALUE="
							+ shareId + " NAME='" + chkShareId + "'></TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareName + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealLevel + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealName + "</TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareRealType + "</TD>\n";
				shareTRString += "</TR>\n";
				shareTRString += "<TR><TD CLASS=LINE COLSPAN=5></TD></TR>\n";
			}
		} else if (stringType == 3) { // 与客户相关的默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype<0 and sharetype>-80 and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if ((!"1".equals(isAllowModiMShare)||!canShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}

				String crmtype = "" + ((-1) * shareType);
				shareName = ctci.getCustomerTypename(crmtype);
				shareRealLevel = SystemEnv.getHtmlLabelName(683, userLanguage)
						+ ">= " + secLevel
						+ SystemEnv.getHtmlLabelName(18946, userLanguage)
						+ shareName;
				shareRealName = shareName;
				if ("".equals(shareRealName))
					continue;				
				if (shareLevel == 1) {
					shareRealType = SystemEnv.getHtmlLabelName(18932,
							userLanguage);
					//TD12005 START
					int downloadLevel = Util.getIntValue(rs.getString("downloadlevel"),0);
					if (downloadLevel == 1) {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23733, userLanguage) + ")"; 
					} else {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23734, userLanguage) + ")";
					}//TD12005 END
				}
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(18933,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(18934,
							userLanguage);

				shareTRString += "<TR>\n";
				if ("true".equalsIgnoreCase(needCheckbox))
					shareTRString += "	<TD><INPUT TYPE='CHECKBOX' "
							+ isDisabled + " CLASS='INPUTSTYLE' VALUE="
							+ shareId + " NAME='" + chkShareId + "'></TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareName + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealLevel + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealName + "</TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareRealType + "</TD>\n";
				shareTRString += "</TR>\n";
				shareTRString += "<TR><TD CLASS=LINE COLSPAN=5></TD></TR>\n";
			}
		} else if (stringType == 4) { // 与创建人相关的默认共享(外部用户创建)
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype between -82 and -80 and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if ((!"1".equals(isAllowModiMShare)||!canShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case -80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					createrName = shareRealName;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(15763, userLanguage);
					break;
				case -81: // 与创建人经理相关
					shareName = SystemEnv.getHtmlLabelName(15080, userLanguage);
					shareRealName = rcc.getLastname(cici
							.getCustomerInfomanager("" + shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = cici.getCustomerInfoname("" + shareUserId)
							+ SystemEnv.getHtmlLabelName(18944, userLanguage);
					break;

				}
				if (shareLevel == 1) {
					shareRealType = SystemEnv.getHtmlLabelName(18932,
							userLanguage);
					//TD12005 START
					int downloadLevel = Util.getIntValue(rs.getString("downloadlevel"),0);
					if (downloadLevel == 1) {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23733, userLanguage) + ")"; 
					} else {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23734, userLanguage) + ")";
					}//TD12005 END
				}
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(18933,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(18934,
							userLanguage);

				shareTRString += "<TR>\n";
				if ("true".equalsIgnoreCase(needCheckbox))
					shareTRString += "	<TD><INPUT TYPE='CHECKBOX' "
							+ isDisabled + " CLASS='INPUTSTYLE' VALUE="
							+ shareId + " NAME='" + chkShareId + "'></TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareName + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealLevel + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealName + "</TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareRealType + "</TD>\n";
				shareTRString += "</TR>\n";
				shareTRString += "<TR><TD CLASS=LINE COLSPAN=5></TD></TR>\n";
			}
		} else if (stringType == 5) { // 非默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and (isSecDefaultShare !='1'  or isSecDefaultShare is null) order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareCrmId = rs.getInt("crmid");
				int shareLevel = rs.getInt("sharelevel");
				String secLevel = Util.null2String(rs.getString("seclevel"));

				if (!"1".equals(isAllowModiNMShare)||!canShare) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case 1: // 人力资源
					shareName = SystemEnv.getHtmlLabelName(179, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					break;
				case 2: // 分部
					int subcompanyId = rs.getInt("subcompanyid");
					shareName = SystemEnv.getHtmlLabelName(141, userLanguage);
					shareRealName = scci.getSubCompanyname("" + subcompanyId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18941, userLanguage);
					break;
				case 3: // 部门
					int departmentId = rs.getInt("departmentid");
					shareName = SystemEnv.getHtmlLabelName(18939, userLanguage);
					shareRealName = dci.getDepartmentname("" + departmentId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18942, userLanguage);
					break;
				case 4: // 角色成员
					int roleId = rs.getInt("roleId");
					shareName = SystemEnv.getHtmlLabelName(18936, userLanguage);
					int rolelevel = rs.getInt("rolelevel");
					String roleLevelName = "";
					switch (rolelevel) {
					case 0:
						roleLevelName = SystemEnv.getHtmlLabelName(18939,
								userLanguage);
						break;
					case 1:
						roleLevelName = SystemEnv.getHtmlLabelName(141,
								userLanguage);
						break;
					case 2:
						roleLevelName = SystemEnv.getHtmlLabelName(140,
								userLanguage);
						break;
					}
					shareRealName = rci.getRolesRemark("" + roleId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(3005,
							userLanguage)
							+ "="
							+ roleLevelName
							+ "  "
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18945, userLanguage);
					break;
				case 6: // 群组
					int orgGroupId = rs.getInt("orgGroupId");
					shareName = SystemEnv.getHtmlLabelName(24002, userLanguage);
					shareRealName = hogci.getOrgGroupName("" + orgGroupId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(431, userLanguage);
					break;
				case 5: // 所有人
					shareName = SystemEnv.getHtmlLabelName(1340, userLanguage);
					shareRealName = SystemEnv.getHtmlLabelName(1340,
							userLanguage);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18943, userLanguage);
					break;
				case -80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					createrName = shareRealName;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(15763, userLanguage);
					break;
				case 80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					createrName = shareRealName;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(15763, userLanguage);
					break;
				case 81: // 与创建人直接上级相关
					shareName = SystemEnv.getHtmlLabelName(18583, userLanguage);
					shareRealName = rcc.getLastname(rcc.getManagerID(""
							+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(18940, userLanguage);
					break;
				case 84: // 与创建人分部相关
					shareName = SystemEnv.getHtmlLabelName(18937, userLanguage);
					departmentId = Util.getIntValue(rcc.getDepartmentID(""
							+ shareUserId));
					String subCompanyName = scci.getSubCompanyname(dci
							.getSubcompanyid1("" + departmentId));
					shareRealName = subCompanyName;
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = subCompanyName + "&nbsp;"
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ ">=" + secLevel
							+ SystemEnv.getHtmlLabelName(18941, userLanguage);
					break;
				case 85: // 与创建人部门相关
					shareName = SystemEnv.getHtmlLabelName(18938, userLanguage);
					departmentId = Util.getIntValue(rcc.getDepartmentID(""
							+ shareUserId));
					String departmentName = dci.getDepartmentname(""
							+ departmentId);

					String subcompanyid = rcc.getSubCompanyID("" + shareUserId);
					String subcompanyname = scci.getSubcompanyname(subcompanyid);

					shareRealName = departmentName+"["+subcompanyname+"]";
					if ("".equals(departmentName))
						continue;
					shareRealLevel = departmentName + "&nbsp;"
							+ SystemEnv.getHtmlLabelName(683, userLanguage)
							+ ">=" + secLevel
							+ SystemEnv.getHtmlLabelName(18942, userLanguage);
					break;
				case -81: // 与创建人经理相关
					shareName = SystemEnv.getHtmlLabelName(15080, userLanguage);
					shareRealName = rcc.getLastname(rcc.getManagerID(""
							+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealLevel = createrName
							+ SystemEnv.getHtmlLabelName(18944, userLanguage);
					break;
				case 9: // 具体客户
					shareName = SystemEnv.getHtmlLabelName(18935, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareCrmId);
					if ("".equals(shareRealName))
						continue;
					// shareRealLevel=createrName+"的经理的所有上级";
					break;
				default: // 客户
					String crmtype = "" + ((-1) * shareType);
					shareName = ctci.getCustomerTypename(crmtype);
					shareRealLevel = SystemEnv.getHtmlLabelName(683,
							userLanguage)
							+ ">= "
							+ secLevel
							+ SystemEnv.getHtmlLabelName(18946, userLanguage)
							+ shareName;
					shareRealName = shareName;
					if ("".equals(shareRealName))
						continue;					

				}
				if (shareLevel == 1) {
					shareRealType = SystemEnv.getHtmlLabelName(18932,
							userLanguage);
					//TD12005 START
					int downloadLevel = Util.getIntValue(rs.getString("downloadlevel"),0);
					if (downloadLevel == 1) {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23733, userLanguage) + ")"; 
					} else {
						shareRealType += "(" + SystemEnv.getHtmlLabelName(23734, userLanguage) + ")";
					}//TD12005 END
				}
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(18933,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(18934,
							userLanguage);

				shareTRString += "<TR>\n";
				if ("true".equalsIgnoreCase(needCheckbox))
					shareTRString += "	<TD><INPUT TYPE='CHECKBOX' "
							+ isDisabled + " CLASS='INPUTSTYLE' VALUE="
							+ shareId + " NAME='" + chkShareId + "'></TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareName + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealLevel + "</TD>\n";
				shareTRString += "	<TD>&nbsp;" + shareRealName + "</TD>\n";
				shareTRString += "	<TD >&nbsp;" + shareRealType + "</TD>\n";
				shareTRString += "</TR>\n";
				shareTRString += "<TR><TD CLASS=LINE COLSPAN=5></TD></TR>\n";
			}
		}

		return shareTRString;
	}

	public ArrayList getShareList(int stringType, int docId,
			String needCheckbox, int userLanguage) {
		ArrayList returnList=new ArrayList();
		//String shareTRString = "";
		String sqlStr = "";
		String createrName = "";
		String isAllowModiMShare = "0";
		String isAllowModiNMShare = "0";

		int hasVirtualCom = 0 ;
       if(cvc.getCompanyNum()>0){
          hasVirtualCom=1;
         }
		RecordSet rs = new RecordSet();
		RecordSet rs2 = new RecordSet();

		rs.executeSql("select d2.allownModiMshareL,d2.allownModiMshareW,d2.shareable from docdetail d1,DocSecCategory d2 where d1.seccategory=d2.id and d1.id="
						+ docId);
		if (rs.next()) {
			// if (stringType==4){
			// isAllowModiMShare =
			// Util.null2String(rs.getString("allownModiMshareW"));
			// } else {
			// 修改了一下用 allownModiMshareL代替了所有的默认共享
			isAllowModiMShare = Util.null2String(rs
					.getString("allownModiMshareL"));
			// }
			isAllowModiNMShare = Util.null2String(rs.getString("shareable"));
		}

		if (stringType == 1) { // 与创建人相关的默认共享 (内部)
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and ( (sharetype between 80 and 85 and isSecDefaultShare='1' and sharetype!=89 )or( sharetype=11 and isSecDefaultShare='1' and  isSecDefaultShare='1' and sharetype!=89 ))order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				
				int orgid = Util.getIntValue(rs.getString("orgid"),0);
				int seclevelmax = Util.getIntValue(rs.getString("seclevelmax"),255);
				String includesub = Util.null2String(rs.getString("includesub"));
				String custype = Util.null2String(rs.getString("custype"));
				String allmanagers=Util.null2String(rs.getString("allmanagers"));

				String operategrouppar = userLanguage+"+1+"+orgid+"+"+hasVirtualCom;
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if (!"1".equals(isAllowModiMShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				
				String joblevel=Util.null2String(rs.getString("joblevel"));
				String jobdepartment=Util.null2String(rs.getString("jobdepartment"));
				String jobsubcompany=Util.null2String(rs.getString("jobsubcompany"));
				String jobids=Util.null2String(rs.getString("jobids"));
				
				switch (shareType) {
				case 80: // 与创建人本人相关
					shareName = knotm.getShareTypeNew("1",operategrouppar);
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+shareUserId+"' target='_blank'>"+rcc.getLastname("" + shareUserId)+"</a>";
					createrName = rcc.getLastname("" + shareUserId);
					shareRealLevel = "";
					break;
				case 81: // 与创建人直接上级相关
					
				if(orgid==0){
				if(allmanagers.equals("1")){
				    shareName =  knotm.getShareTypeNew("3",operategrouppar);
                    shareRealName=rcc.getMulResourcename2(rcc.getManagersIDs(""+shareUserId));					
					if ("".equals(rcc.getManagersIDs(""+shareUserId)+"")||"0".equals(rcc.getManagersIDs(""+shareUserId)+""))
						continue;
				}else{
					shareName =  knotm.getShareTypeNew("2",operategrouppar);
					shareRealName = rcc.getLastname(rcc.getManagerID(""+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+rcc.getManagerID(""
							+ shareUserId)+"' target='_blank'>"+shareRealName+"</a>";
					
				   }	
			   }else if(orgid<0){
				   String allmtem="";
					if(allmanagers.equals("1")){
					  shareName =  knotm.getShareTypeNew("3",operategrouppar);
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName=rcc.getMulResourcename2(rs2.getString("managerstr"));
					 allmtem=rs2.getString("managerstr");
					
					}
				 }else{
					 shareName =  knotm.getShareTypeNew("2",operategrouppar);
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName = rcc.getLastname(rs2.getString("managerid"));
					 allmtem=rs2.getString("managerid");
					
					 shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id='"+rs2.getString("manageid")+"' target='_blank'>"+shareRealName+"</a>";
					 }
				    }

					 if ("".equals(allmtem))
						continue;
					
			      }	
				   if ("".equals(shareRealName))
						continue;
					shareRealLevel = "";

					break;

				case 84: // 与创建人分部相关
					shareName =  knotm.getShareTypeNew("4",operategrouppar);
					String departmentId = rcc.getDepartmentID("" + shareUserId);
					String subCompanyName = scci.getSubCompanyname(dci.getSubcompanyid1(departmentId));
					if(orgid==0){
					shareRealName = subCompanyName;
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+dci.getSubcompanyid1(departmentId)+"' target='_blank'>"+shareRealName+"</a>";

					}else if(orgid<0){
					
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName = scci.getSubCompanyname(rs2.getString("subcompanyid"));
					 if ("".equals(shareRealName))
						continue;
					 shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+rs2.getString("subcompanyid")+"' target='_blank'>"+shareRealName+"</a>";
					 }
					 
					
					}
					  if ("".equals(shareRealName))
						continue;
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 85: // 与创建人部门相关
					shareName =  knotm.getShareTypeNew("5",operategrouppar);
					departmentId = rcc.getDepartmentID("" + shareUserId);
					String subcompanyid = rcc.getSubCompanyID("" + shareUserId);
					String subcompanyname = scci.getSubcompanyname(subcompanyid);
					String departmentName = dci.getDepartmentname(departmentId);

					if(orgid==0){
						shareRealName = departmentName+"["+subcompanyname+"]";
						if ("".equals(departmentName)) continue;
						shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+departmentId+"' target='_blank'>"+shareRealName+"</a>";

					}else if(orgid<0){
					
					 	rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 	if(rs2.next()){
					 		shareRealName = dci.getDepartmentname(rs2.getString("departmentid"));
					 		if ("".equals(shareRealName)) continue;
					 		shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+rs2.getString("departmentid")+"' target='_blank'>"+shareRealName+"</a>";
						 }
					}
					if ("".equals(shareRealName)) continue;
					shareRealLevel = shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
					 
				  case 11: // 与创建人岗位相关
					shareName =  SystemEnv.getHtmlLabelName(126610,userLanguage);					
  		        shareRealName = jbcom.getJobTitlesname(jobids)+"/";
					if ("".equals(jbcom.getJobTitlesname(jobids))){
						continue;
					}
			       if(joblevel.equals("1")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(140,userLanguage);
	 			   }
			
	 			   if(joblevel.equals("2")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(21837,userLanguage);
				   }			
	 			   if(joblevel.equals("3")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(126607,userLanguage);
				   }
				   if(joblevel.equals("4")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(126608,userLanguage);
				   }
				   if(joblevel.equals("5")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(30792,userLanguage);
				   }
				   if(joblevel.equals("6")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(19436,userLanguage);
				   }
				   if(joblevel.equals("7")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(27189,userLanguage);
				   }

  	
				    if ("".equals(shareRealName))
						continue;
					shareRealLevel ="";
					break;


                

				}
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);
				
				
				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				/** td12005 end */
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				
				ht.put("type",SystemEnv.getHtmlLabelName(15059, userLanguage));
				
				
				
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				
				returnList.add(ht);
			}
			
		} else if (stringType == 2) { // 与创建人本人无关的默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype between 1 and 79  and isSecDefaultShare='1' and  sharetype !=11  order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
                int orgid = Util.getIntValue(rs.getString("orgid"),0);
				int seclevelmax = Util.getIntValue(rs.getString("seclevelmax"),255);
				int includesub = Util.getIntValue(rs.getString("includesub"),0);
				String custype = Util.null2String(rs.getString("custype"));
				String allmanagers=Util.null2String(rs.getString("allmanagers"));

				String joblevel=Util.null2String(rs.getString("joblevel"));
				String jobdepartment=Util.null2String(rs.getString("jobdepartment"));
				String jobsubcompany=Util.null2String(rs.getString("jobsubcompany"));
				String jobids=Util.null2String(rs.getString("jobids"));

				String includesubDes=SystemEnv.getHtmlLabelName(10000010,userLanguage);
		        if(includesub==1){
			        includesubDes=SystemEnv.getHtmlLabelName(125963,userLanguage);
			     }

				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareCrmId = rs.getInt("crmid");
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				
				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if (!"1".equals(isAllowModiMShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case 1: // 人力资源
					shareName = SystemEnv.getHtmlLabelName(179, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+shareUserId+"' target='_blank'>"+shareRealName+"</a>";
					break;
				case 2: // 分部
					int subcompanyId = rs.getInt("subcompanyid");
					shareName = SystemEnv.getHtmlLabelName(141, userLanguage);									
					shareRealName = scci.getSubCompanyname("" + subcompanyId)+"("+includesubDes+")";
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+subcompanyId+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 3: // 部门
					int departmentId = rs.getInt("departmentid");
					shareName = SystemEnv.getHtmlLabelName(18939, userLanguage);
					shareRealName = dci.getDepartmentname("" + departmentId)+"("+includesubDes+")";
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+departmentId+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 4: // 角色成员
					int roleId = rs.getInt("roleId");
					int rolelevel = rs.getInt("rolelevel");
					String roleLevelName = "";
					switch (rolelevel) {
					case 0:
						roleLevelName = SystemEnv.getHtmlLabelName(18939,
								userLanguage);
						break;
					case 1:
						roleLevelName = SystemEnv.getHtmlLabelName(141,
								userLanguage);
						break;
					case 2:
						roleLevelName = SystemEnv.getHtmlLabelName(140,
								userLanguage);
						break;
					}

					shareName = SystemEnv.getHtmlLabelName(18936, userLanguage);
					shareRealName = rci.getRolesRemark("" + roleId)+"/"+roleLevelName;
					if ("".equals(shareRealName))
						continue;					
					shareRealName = shareRealName;
					
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 6: // 群组
					int orgGroupId = rs.getInt("orgGroupId");
					shareName = SystemEnv.getHtmlLabelName(24002, userLanguage);
					shareRealName = hogci.getOrgGroupName("" + orgGroupId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 5: // 所有人
					shareName = SystemEnv.getHtmlLabelName(1340, userLanguage);
					shareRealName = "";
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 9: // 具体客户
					shareName = SystemEnv.getHtmlLabelName(18935, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareCrmId);
					if ("".equals(shareRealName))
						continue;
					// shareRealLevel=createrName+"的经理的所有上级";
					break;
				case 10: // 与创建人无关的岗位
					shareName =  SystemEnv.getHtmlLabelName(6086,userLanguage);					
    		        shareRealName = jbcom.getJobTitlesname(jobids)+"/";
				  if ("".equals(jbcom.getJobTitlesname(jobids))){
						continue;
					}
			      if(joblevel.equals("1")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(140,userLanguage);
	 			  } 			
	 			  if(joblevel.equals("2")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(19437,userLanguage)+"(<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+jobsubcompany+"' target='_blank'>"+Util.toScreen(scci.getSubCompanyname(jobsubcompany),userLanguage)+"</a>)";
	 			  }			
	 			  if(joblevel.equals("3")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(19438,userLanguage)+"(<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+jobdepartment+"' target='_blank'>"+Util.toScreen(dci.getDepartmentname(jobdepartment),userLanguage)+"</a>)";
	 			  }
				    	
				  if ("".equals(shareRealName))
						continue;
					shareRealLevel ="";
					break;	
				

				}
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);
				
				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				/** td12005 end */
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				
				ht.put("type",SystemEnv.getHtmlLabelName(15059, userLanguage));
				
				
				
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				
				returnList.add(ht);
			}
		} else if (stringType == 3) { // 与客户相关的默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype<0 and sharetype>-80 and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
                int seclevelmax = Util.getIntValue(rs.getString("seclevelmax"),255);
				String operategrouppar = userLanguage+"+3+0+"+hasVirtualCom;

				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				
				String secLevel = Util.null2String(rs.getString("seclevel"));
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if (!"1".equals(isAllowModiMShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}

				String crmtype = "" + ((-1) * shareType);
				shareName = knotm.getShareTypeNew("8",operategrouppar);
			
                shareRealName = ctci.getCustomerTypename(crmtype);
				shareRealLevel =secLevel+"-"+seclevelmax ;
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);
				
				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				/** td12005 end */
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				
				ht.put("type",SystemEnv.getHtmlLabelName(15059, userLanguage));
				
				
				
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				
				returnList.add(ht);
			}
		} else if (stringType == 4) { // 与创建人相关的默认共享(外部用户创建)
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and sharetype between -82 and -80 and isSecDefaultShare='1' order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if (!"1".equals(isAllowModiMShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case -80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					createrName = shareRealName;
					shareRealLevel = "";
					break;
				case -81: // 与创建人经理相关
					shareName = SystemEnv.getHtmlLabelName(15080, userLanguage);
					shareRealName = rcc.getLastname(cici.getCustomerInfomanager("" + shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+cici.getCustomerInfomanager("" + shareUserId)+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel = "";
					break;

				}
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);
				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				/** td12005 end */
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				ht.put("type",SystemEnv.getHtmlLabelName(15059, userLanguage));
				
				
				
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				
				returnList.add(ht);
			}
		} else if (stringType == 5) { // 非默认共享
			sqlStr = "select * from docshare where docid="
					+ docId
					+ " and (isSecDefaultShare !='1'  or isSecDefaultShare is null) and sharetype!=89 order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			while (rs.next()) {
                int orgid = Util.getIntValue(rs.getString("orgid"),0);
				int seclevelmax = Util.getIntValue(rs.getString("seclevelmax"),255);
				
				int includesub = Util.getIntValue(rs.getString("includesub"),0);

				String joblevel=Util.null2String(rs.getString("joblevel"));
				String jobdepartment=Util.null2String(rs.getString("jobdepartment"));
				String jobsubcompany=Util.null2String(rs.getString("jobsubcompany"));
				String jobids=Util.null2String(rs.getString("jobids"));

				String custype = Util.null2String(rs.getString("custype"));
				String allmanagers=Util.null2String(rs.getString("allmanagers"));
				String includesubDes=SystemEnv.getHtmlLabelName(10000010,userLanguage);
		        if(includesub==1){
			        includesubDes=SystemEnv.getHtmlLabelName(125963,userLanguage);
			     }

				String operategrouppar = userLanguage+"+1+"+orgid+"+"+hasVirtualCom;

				String shareName = "";
				String shareRealName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				String chkShareId = "chkShareId";

				int shareId = rs.getInt("id");
				int shareType = rs.getInt("sharetype");
				int shareUserId = rs.getInt("userid");
				int shareCrmId = rs.getInt("crmid");
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				String secLevel = Util.null2String(rs.getString("seclevel"));

				if (!"1".equals(isAllowModiNMShare)) {
					isDisabled = " disabled ";
					chkShareId = "_chkShareId";
				}
				switch (shareType) {
				case 1: // 人力资源
					shareName = SystemEnv.getHtmlLabelName(179, userLanguage);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+shareUserId+"' target='_blank'>"+shareRealName+"</a>";
					break;
				case 2: // 分部
					int subcompanyId = rs.getInt("subcompanyid");
					shareName = SystemEnv.getHtmlLabelName(141, userLanguage);
					shareRealName = scci.getSubCompanyname("" + subcompanyId)+"("+includesubDes+")";
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+subcompanyId+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 3: // 部门
					int departmentId = rs.getInt("departmentid");
					shareName = SystemEnv.getHtmlLabelName(18939, userLanguage);
					shareRealName = dci.getDepartmentname("" + departmentId)+"("+includesubDes+")";
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+departmentId+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 4: // 角色成员
					int roleId = rs.getInt("roleId");
					shareName = SystemEnv.getHtmlLabelName(18936, userLanguage);
					int rolelevel = rs.getInt("rolelevel");
					String roleLevelName = "";
					switch (rolelevel) {
					case 0:
						roleLevelName = SystemEnv.getHtmlLabelName(18939,
								userLanguage);
						break;
					case 1:
						roleLevelName = SystemEnv.getHtmlLabelName(141,
								userLanguage);
						break;
					case 2:
						roleLevelName = SystemEnv.getHtmlLabelName(140,
								userLanguage);
						break;
					}
					shareRealName = rci.getRolesRemark("" + roleId)+"/"+roleLevelName;
					if ("".equals(shareRealName))
						continue;					
					shareRealName = shareRealName;
						shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 5: // 所有人
					shareName = SystemEnv.getHtmlLabelName(1340, userLanguage);
					shareRealName = "";			
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;
				case 6: // 群组
					int orgGroupId = rs.getInt("orgGroupId");
					shareName = SystemEnv.getHtmlLabelName(24002, userLanguage);
					shareRealName = hogci.getOrgGroupName("" + orgGroupId);
					if ("".equals(shareRealName))
						continue;					
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;

				case 10: // 与创建人无关的岗位
					shareName =  SystemEnv.getHtmlLabelName(6086,userLanguage);					
    		        shareRealName = jbcom.getJobTitlesname(jobids)+"/";
				  if ("".equals(jbcom.getJobTitlesname(jobids))){
						continue;
					}
			      if(joblevel.equals("1")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(140,userLanguage);
	 			  } 			
	 			  if(joblevel.equals("2")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(19437,userLanguage)+"(<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+jobsubcompany+"' target='_blank'>"+Util.toScreen(scci.getSubCompanyname(jobsubcompany),userLanguage)+"</a>)";
	 			  }			
	 			  if(joblevel.equals("3")){
	 				shareRealName = shareRealName + SystemEnv.getHtmlLabelName(19438,userLanguage)+"(<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+jobdepartment+"' target='_blank'>"+Util.toScreen(dci.getDepartmentname(jobdepartment),userLanguage)+"</a>)";
	 			  }
				    	
				  if ("".equals(shareRealName))
						continue;
					shareRealLevel ="";
					break;	
				 

				case -80: // 与创建人本人相关
					shareName = SystemEnv.getHtmlLabelName(15079, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					createrName = shareRealName;
					shareRealLevel = "";
					break;
				case 80: // 与创建人本人相关
					shareName = knotm.getShareTypeNew("1",operategrouppar);
					shareRealName = rcc.getLastname("" + shareUserId);
					if ("".equals(shareRealName))
						continue;					
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+shareUserId+"' target='_blank'>"+shareRealName+"</a>";
					createrName = shareRealName;
					shareRealLevel = "";
					break;
				case 81: // 与创建人直接上级相关
				if(orgid==0){
				if(allmanagers.equals("1")){
				    shareName =  knotm.getShareTypeNew("3",operategrouppar);
                    shareRealName=rcc.getMulResourcename2(rcc.getManagersIDs(""+shareUserId));					
					if ("".equals(rcc.getManagersIDs(""+shareUserId)+"")||"0".equals(rcc.getManagersIDs(""+shareUserId)+""))
						continue;
				}else{
					shareName =  knotm.getShareTypeNew("2",operategrouppar);
					shareRealName = rcc.getLastname(rcc.getManagerID(""+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+rcc.getManagerID(""
							+ shareUserId)+"' target='_blank'>"+shareRealName+"</a>";
					
				   }	
			   }else if(orgid<0){
				   String allmtem="";
					if(allmanagers.equals("1")){
					  shareName =  knotm.getShareTypeNew("3",operategrouppar);
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName=rcc.getMulResourcename2(rs2.getString("managerstr"));
					 allmtem=rs2.getString("managerstr");


					
					}
				 }else{
					 shareName =  knotm.getShareTypeNew("2",operategrouppar);



					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName = rcc.getLastname(rs2.getString("managerid"));
					 allmtem=rs2.getString("managerid");
					
					 shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id='"+rs2.getString("manageid")+"' target='_blank'>"+shareRealName+"</a>";
					 }
				    }





					 if ("".equals(allmtem))
						continue;
					
			      }	
				   if ("".equals(shareRealName))
						continue;

					shareRealLevel = "";

					break;

				case 84: // 与创建人分部相关

                       shareName =  knotm.getShareTypeNew("4",operategrouppar);
					 departmentId =Util.getIntValue(rcc.getDepartmentID("" + shareUserId));
					String subCompanyName = scci.getSubCompanyname(dci.getSubcompanyid1(departmentId+""));
					if(orgid==0){
					shareRealName = subCompanyName;
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+dci.getSubcompanyid1(departmentId+"")+"' target='_blank'>"+shareRealName+"</a>";

					}else if(orgid<0){
					
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName = scci.getSubCompanyname(rs2.getString("subcompanyid"));
					 if ("".equals(shareRealName))
						continue;
					 shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmSubCompanyDsp.jsp?id="+rs2.getString("subcompanyid")+"' target='_blank'>"+shareRealName+"</a>";
					 }
					 
					
					}
					  if ("".equals(shareRealName))
						continue;
					shareRealLevel =secLevel+"-"+seclevelmax ;
					break;

					
				case 85: // 与创建人部门相关


				    shareName =  knotm.getShareTypeNew("5",operategrouppar);
					departmentId =  Util.getIntValue(rcc.getDepartmentID(""
							+ shareUserId));
					String departmentName = dci.getDepartmentname(departmentId+"");
					String subcompanyid = rcc.getSubCompanyID("" + shareUserId);
					String subcompanyname = scci.getSubcompanyname(subcompanyid);

					if(orgid==0){
					shareRealName = departmentName+"["+subcompanyname+"]";
					if ("".equals(departmentName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+departmentId+"' target='_blank'>"+shareRealName+"</a>";

					}else if(orgid<0){
					
					 rs2.executeSql("select * from HrmResourceVirtual where virtualtype= "+orgid+" and resourceid="+shareUserId);
					 if(rs2.next()){
					 shareRealName = dci.getDepartmentname(rs2.getString("departmentid"));
					 if ("".equals(shareRealName))
						continue;
					 shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/company/HrmDepartmentDsp.jsp?id="+rs2.getString("departmentid")+"' target='_blank'>"+shareRealName+"</a>";
					 }
					 
					
					}
					  if ("".equals(shareRealName))
						continue;
					shareRealLevel = shareRealLevel =secLevel+"-"+seclevelmax ;
					break;


				case -81: // 与创建人经理相关
					shareName = SystemEnv.getHtmlLabelName(15080, userLanguage);
					shareRealName = rcc.getLastname(rcc.getManagerID(""+ shareUserId));
					if ("".equals(shareRealName))
						continue;
					shareRealName = "<a href='"+weaver.general.GCONST.getContextPath()+"/hrm/resource/HrmResource.jsp?id="+rcc.getManagerID(""+ shareUserId)+"' target='_blank'>"+shareRealName+"</a>";
					shareRealLevel = "";
					break;
				case 9: // 具体客户
					shareName = SystemEnv.getHtmlLabelName(18935, userLanguage);
					shareRealName = cici.getCustomerInfoname("" + shareCrmId);
					if ("".equals(shareRealName))
						continue;
					// shareRealLevel=createrName+"的经理的所有上级";
					break;
				default: // 客户
					String crmtype = "" + ((-1) * shareType);
					shareName = SystemEnv.getHtmlLabelName(1282, userLanguage);
					shareRealLevel =secLevel+"-"+seclevelmax ;
					shareRealName = ctci.getCustomerTypename(crmtype);
					if ("".equals(shareRealName))
						continue;					

				}
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);

				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				/** td12005 end */
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				
				ht.put("type",SystemEnv.getHtmlLabelName(18574, userLanguage));
				 
				
				
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				
				returnList.add(ht);
			}
			
			//所有上级权限 展现 89
			sqlStr = "select * from docshare where docid=" + docId + " and (isSecDefaultShare!='1' or isSecDefaultShare is null) and  sharetype=89 order by  issecdefaultshare desc,sharetype";
			rs.executeSql(sqlStr);
			int count = rs.getCounts();
			int i =0 ;
			String shareRealName = "";
			while (rs.next()) {
				i ++;
				String shareName = "";
				String shareRealLevel = "";
				String shareRealType = "";
				String isDisabled = "";
				int shareUserId = rs.getInt("userid");
				shareRealName += rcc.getLastname(""+ shareUserId);
				if ("".equals(shareRealName))
					continue;

				if(i<count){
					shareRealName+="，";
					continue;
				}
				int shareId = rs.getInt("id");
				
				int shareLevel = rs.getInt("sharelevel");
				int downloadlevel = Util.getIntValue(rs.getString("downloadlevel"), 0);//TD12005
				String isSecDefaultShare = Util.null2String(rs
						.getString("isSecDefaultShare"));
				if (!"1".equals(isAllowModiMShare)
						&& "1".equals(isSecDefaultShare)) {
					isDisabled = " disabled ";
				}
				shareName = SystemEnv.getHtmlLabelName(385205,userLanguage);
				RecordSet urs = new RecordSet();
				urs.execute("select doccreaterid from DocDetail where id="+docId);
				if(urs.next()){
					shareRealLevel = rcc.getLastname(urs.getString(1)) + SystemEnv.getHtmlLabelName(10000011,userLanguage);
				}
				if (shareLevel == 1)
					shareRealType = SystemEnv.getHtmlLabelName(367,
							userLanguage);
				else if (shareLevel == 2)
					shareRealType = SystemEnv.getHtmlLabelName(93,
							userLanguage);
				else if (shareLevel == 3)
					shareRealType = SystemEnv.getHtmlLabelName(17874,
							userLanguage);
				
				Hashtable ht=new Hashtable();
				ht.put("shareId", ""+shareId);
				ht.put("shareName", shareName);
				ht.put("shareRealLevel", shareRealLevel);
				ht.put("shareRealName", shareRealName);
				ht.put("shareRealType", shareRealType);
				/** td12005 start */
				String downloadlevelName = "";
				if(shareLevel==1){
				downloadlevelName = downloadlevel == 1 ? SystemEnv.getHtmlLabelName(23733, userLanguage) :SystemEnv.getHtmlLabelName(23734, userLanguage);
				}
				ht.put("downloadlevelName", downloadlevelName);
				ht.put("downloadlevel", ""+downloadlevel);
				/** td12005 end */
				ht.put("type",SystemEnv.getHtmlLabelName(18574, userLanguage));
				if ("true".equalsIgnoreCase(needCheckbox))
					ht.put("chk", ""+isDisabled);
				returnList.add(ht);
			}
		}

		return returnList;
	}

	/**
	 *  得到用户的所有下级
	 * @param userId
	 *            用户的ID
	 * @param secLevel
	 *            用户的安全级别
	 * @return 得到用户的所有下级
	 */
	public String getDownOwnerStrs(int userId, String secLevel) {
		String downOwnerStr = "";
		String downOwnerStr1 = "";
		String downOwnerStr2 = "";
		RecordSet rs = new RecordSet();
		rs
				.executeSql("select lastname from HrmResource  where managerstr like '%,"
						+ userId + ",%' and seclevel>=" + secLevel);
		int i = 0;
		while (rs.next()) {
			if (i <= 9) {
				downOwnerStr1 += Util.null2String(rs.getString(1)) + " ";
			}
			downOwnerStr2 += Util.null2String(rs.getString(1)) + " ";
			i++;
		}
		if ("".equals(downOwnerStr1))
			downOwnerStr = "";
		else
			downOwnerStr = "<div style='cursor:hand' title='" + downOwnerStr2
					+ "'>" + downOwnerStr1 + "......" + "</div>";

		return downOwnerStr;
	}

	/**
	 * 得到是否此目录下的文档允许修改其默认共享
	 * @param docid
	 *            文档的ID
	 * @return 是否此目录下的文档允许修改其默认共享
	 */
	public boolean getIsAllowModiMShare(String docid) {
		boolean allowModiMShare = false;
		RecordSet rs = new RecordSet();
		rs
				.executeSql("select d2.allownModiMshareL,d2.allownModiMshareW,d2.shareable from docdetail d1,DocSecCategory d2 where d1.seccategory=d2.id and d1.id="
						+ docid);
		if (rs.next()) {
			// 修改了一下用 allownModiMshareL代替了所有的默认共享
			String isAllowModiMShare = Util.null2String(rs
					.getString("allownModiMshareL")); // 默认共享
			allowModiMShare = "1".equals(isAllowModiMShare);
		}
		return allowModiMShare;
	}

	/**
	 *  得到 是否此目录下的文档允许修改其非默认共享
	 * @param docid
	 *            文档的ID
	 * @return 是否此目录下的文档允许修改其非默认共享
	 */
	public boolean getIsAllowModiNMShare(String docid) {
		boolean allowModiNMShare = false;
		RecordSet rs = new RecordSet();
		rs
				.executeSql("select d2.allownModiMshareL,d2.allownModiMshareW,d2.shareable from docdetail d1,DocSecCategory d2 where d1.seccategory=d2.id and d1.id="
						+ docid);
		if (rs.next()) {
			String isAllowModiNMShare = Util.null2String(rs
					.getString("shareable")); // 非默认共享
			allowModiNMShare = "1".equals(isAllowModiNMShare);

		}
		return allowModiNMShare;
	}
	
	/**
	 *  得到 是否此目录下的文档禁止文档下载(TD12005)
	 * @param docid
	 *            文档的ID
	 * @return 是否此目录下的文档禁止文档下载
	 */
	public boolean getIsAllowDownload(String docid) {
		boolean allowDownload = false;
		RecordSet rs = new RecordSet();
		rs
				.executeSql("select d2.nodownload from docdetail d1,DocSecCategory d2 where d1.seccategory=d2.id and d1.id="
						+ docid);
		if (rs.next()) {
			String noDownload = Util.null2String(rs
					.getString("nodownload")); // 禁止文档下载
			allowDownload = "0".equals(noDownload);

		}
		return allowDownload;
	}
}
