public void CreateAppAndMenu(Group group, MvcContext ctx) { // 添加程序 IMemberApp forumApp = appService.Add((User)ctx.viewer.obj, group, lang.get("groupBoard"), 1, AccessStatus.Public); // 论坛 ForumApp app = forumService.GetById(forumApp.AppOid); ForumPermission.AddOwnerAdminPermission(app); // 添加一个论坛板块 ForumBoard board = new ForumBoard(); board.Name = lang.get("groupBoard"); board.ParentId = 0; board.AppId = forumApp.AppOid; board.Creator = (User)ctx.viewer.obj; board.CreatorUrl = ctx.viewer.obj.Url; board.OwnerId = group.Id; board.OwnerUrl = group.Url; board.OwnerType = typeof(Group).FullName; board.Ip = ctx.Ip; board.Security = app.Security; db.insert(board); // 添加menuUrl String forumUrl = UrlConverter.clearUrl(board, ctx); menuService.AddMenuByApp(forumApp, forumApp.Name, "default", forumUrl); }
private IMenu getMenu(User user, string name, string url) { IMenu menu = new UserMenu(); menu.Name = name; menu.RawUrl = UrlConverter.clearUrl(url, ctx, typeof(User).FullName, user.Url).TrimStart('/'); return(menu); }
private static IMenu getMenu(User user, string name, string url, MvcContext ctx) { IMenu menu = new UserMenu(); menu.Name = name; menu.RawUrl = UrlConverter.clearUrl(url, ctx, typeof(User).FullName, user.Url); return(menu); }
public virtual void Start(long id) { IMemberApp app = getApp(id); String appUrl = UrlConverter.clearUrl(app, ctx); userAppService.Start(app, appUrl); log(SiteLogString.StartApp(), app); echoRedirectPart(lang("opok"), to(Index), 0); }
public virtual void Delete(long id) { IMemberApp app = getApp(id); String appUrl = UrlConverter.clearUrl(app, ctx); userAppService.Delete(app, appUrl); log(SiteLogString.DeleteApp(), app); echoRedirect(lang("opok"), Index); }
protected void AddMenu(MvcContext ctx, String name, String url, String fUrl) { IMenu menu = new SiteMenu(); menu.Name = name; menu.Url = fUrl; menu.RawUrl = UrlConverter.clearUrl(url, ctx, typeof(Site).FullName, Site.Instance.Url); User creator = ctx.viewer.obj as User; menuService.Insert(menu, creator, Site.Instance); }
public virtual void Update(long id) { IMemberApp app = getApp(id); String appUrl = UrlConverter.clearUrl(app, ctx); String name = ctx.Post("Name"); userAppService.Update(app, name, appUrl); log(SiteLogString.UpdateApp(), app); echoToParentPart(lang("opok"), to(Index), 0); }
public virtual void Stop(long id) { IMemberApp app = getApp(id); String appUrl = UrlConverter.clearUrl(app, ctx); logger.Info("stoped app url : " + appUrl); userAppService.Stop(app, appUrl); log(SiteLogString.StopApp(), app); //redirect( Index ); //echoRedirect( lang( "opok" ), Index ); echoRedirectPart(lang("opok"), to(Index), 0); }
//--------------------------------- /// <summary> /// 安装app /// </summary> /// <returns></returns> protected IMemberApp createApp() { int installerId = 4; AppInstaller installer = installerService.GetById(installerId); IMember owner = this.owner; User creator = this.user; String name = appName; IMemberApp mapp = appService.Add(creator, owner, name, installer.Id, AccessStatus.Public); String appUrl = UrlConverter.clearUrl(mapp, ctx, this.owner); IMenu menu = menuService.AddMenuByApp(mapp, name, "", appUrl); ContentApp newApp = ContentApp.findById(mapp.AppOid); this.app = newApp; return(mapp); }
private IMemberApp createApp() { int appInfoId = 4; AppInstaller info = appinfoService.GetById(appInfoId); IMember owner = this.user; User creator = this.user; String name = lang.get("homepage"); IMemberApp myuserApp = appService.Add(creator, owner, name, info.Id, AccessStatus.Public); //String appUrl = UrlConverter.clearUrl( myuserApp, ctx ); String appUrl = UrlConverter.clearUrl(myuserApp, ctx, owner); IMenu menu = menuService.AddMenuByApp(myuserApp, name, "", appUrl); menu.Url = "default"; menu.OrderId = 99; menuService.Update(menu); this.app = ContentApp.findById(myuserApp.AppOid); return(myuserApp); }
public virtual void Create() { int appInfoId = cvt.ToInt(ctx.Post("appInfoId")); AppInstaller info = getAppInfo(appInfoId); if (info.IsClose(ctx.owner.obj.GetType())) { echo("app closed"); return; } if (!checkInstall(info)) { return; } String name = ctx.Post("Name"); AccessStatus accs = AccessStatus.Public; if (strUtil.IsNullOrEmpty(name)) { echoError("请填写名称"); return; } // 自定义安装 Type appType = ObjectContext.Instance.TypeList[info.TypeFullName]; if (rft.IsInterface(appType, typeof(IAppInstaller))) { // 主题ID String themeId = ctx.Post("themeId"); IAppInstaller customInstaller = ObjectContext.Create(appType) as IAppInstaller; IMemberApp capp = customInstaller.Install(ctx, ctx.owner.obj, name, accs, themeId, ""); intiAppPermission(capp); echoToParentPart(lang("opok"), to(Index), 1); return; } // 主题安装 if (strUtil.HasText(info.InstallerType)) { // 主题ID String themeId = ctx.Post("themeId"); Type installerType = ObjectContext.GetType(info.InstallerType); IAppInstaller customInstaller = ObjectContext.Create(installerType) as IAppInstaller; IMemberApp capp = customInstaller.Install(ctx, ctx.owner.obj, name, accs, themeId, ""); intiAppPermission(capp); echoToParentPart(lang("opok"), to(Index), 1); return; } // 默认安装 IMember owner = ctx.owner.obj; User creator = (User)ctx.viewer.obj; // 1、添加一条 IMemberApp IMemberApp app = userAppService.Add(creator, owner, name, info.Id, accs); if (app != null) { // 2、添加菜单 String appUrl = UrlConverter.clearUrl(app, ctx); menuService.AddMenuByApp(app, name, "", appUrl); // 3、初始化权限 intiAppPermission(app); log(SiteLogString.InsertApp(), app); echoToParentPart(lang("opok"), to(Index), 1); } else { errors.Add(lang("exop")); run(NewApp, info.Id); } }
private void addUserAppAndMenus(User user) { if (strUtil.IsNullOrEmpty(config.Instance.Site.UserInitApp)) { return; } List <String> menus = new List <string>(); String[] arr = config.Instance.Site.UserInitApp.Split(','); foreach (String app in arr) { if (strUtil.IsNullOrEmpty(app)) { continue; } menus.Add(app.Trim()); } if (menus.Contains("home")) { new UserHomeInstaller().Install(ctx, user, lang("homepage"), wojilu.Common.AppBase.AccessStatus.Public); } if (menus.Contains("blog")) { IMemberApp blogApp = appService.Add(user, "博客", 2); // 添加菜单:此处需要明确传入MemberType,否则将会使用ctx.Owner,也就是Site的值,导致bug String blogUrl = UrlConverter.clearUrl(alink.ToUserAppFull(blogApp), ctx, typeof(User).FullName, user.Url); menuService.AddMenuByApp(blogApp, blogApp.Name, "", blogUrl); } if (menus.Contains("photo")) { IMemberApp photoApp = appService.Add(user, "相册", 3); String photoUrl = UrlConverter.clearUrl(alink.ToUserAppFull(photoApp), ctx, typeof(User).FullName, user.Url); menuService.AddMenuByApp(photoApp, photoApp.Name, "", photoUrl); } if (menus.Contains("microblog")) { IMenu menu = getMenu(user, "微博", alink.ToUserMicroblog(user)); menuService.Insert(menu, user, user); } if (menus.Contains("share")) { IMenu menu = getMenu(user, "转帖", t2(new Users.ShareController().Index)); menuService.Insert(menu, user, user); } if (menus.Contains("friend")) { IMenu menu = getMenu(user, "好友", t2(new Users.FriendController().FriendList)); menuService.Insert(menu, user, user); } if (menus.Contains("visitor")) { IMenu menu = getMenu(user, "访客", t2(new Users.VisitorController().Index)); menuService.Insert(menu, user, user); } if (menus.Contains("forumpost")) { IMenu menu = getMenu(user, "论坛帖子", t2(new Users.ForumController().Topic)); menuService.Insert(menu, user, user); } if (menus.Contains("about")) { IMenu menu = getMenu(user, "关于我", t2(new Users.ProfileController().Main)); menuService.Insert(menu, user, user); } if (menus.Contains("feedback")) { IMenu menu = getMenu(user, "留言", t2(new Users.FeedbackController().List)); menuService.Insert(menu, user, user); } }
protected IMenu validateMenu(IMenu menu) { menu.Name = ctx.Post("Name"); menu.Url = ctx.Post("Url"); menu.Style = getMenuStyle(ctx); String rawUrl = ctx.Post("RawUrl"); if (strUtil.IsNullOrEmpty(menu.Name)) { errors.Add(lang("exName")); } if (strUtil.IsNullOrEmpty(rawUrl)) { errors.Add(lang("exUrl")); } Boolean isUrl = RegPattern.IsMatch(rawUrl, RegPattern.Url); if (!isUrl) { errors.Add(lang("exUrlFormat")); } if (ctx.HasErrors) { return(null); } Boolean isOutUrl = PathHelper.IsOutUrl(rawUrl); logger.Info("isOutUrl=" + isOutUrl); if (isOutUrl) { menu.RawUrl = rawUrl; menu.Url = ""; } else { IMember owner = ctx.owner.obj; String cleanedUrl = UrlConverter.clearUrl(rawUrl, ctx, owner.GetType().FullName, owner.Url); logger.Info("cleanedUrl=" + cleanedUrl); menu.RawUrl = cleanedUrl; } menu.OpenNewWindow = ctx.PostIsCheck("chkBlank"); if (strUtil.IsNullOrEmpty(menu.Name)) { errors.Add(lang("exName")); } if (strUtil.IsNullOrEmpty(menu.RawUrl)) { errors.Add(lang("exUrl")); } if (strUtil.HasText(menu.Url) && strUtil.IsUrlItem(menu.Url) == false) { errors.Add(lang("exFriendUrlFormat")); } return(menu); }
private static void addUserAppAndMenus(User user, MvcContext ctx) { if (strUtil.IsNullOrEmpty(config.Instance.Site.UserInitApp)) { return; } IMemberAppService appService = new UserAppService(); IMenuService menuService = new UserMenuService(); List <String> menus = new List <string>(); String[] arr = config.Instance.Site.UserInitApp.Split(','); foreach (String app in arr) { if (strUtil.IsNullOrEmpty(app)) { continue; } menus.Add(app.Trim()); } if (menus.Contains("home")) { addMenu(user, "主页", Link.ToMember(user), true); } if (menus.Contains("blog")) { IMemberApp blogApp = appService.Add(user, "博客", 2); // 添加菜单:此处需要明确传入MemberType,否则将会使用ctx.Owner,也就是Site的值,导致bug String blogUrl = UrlConverter.clearUrl(alink.ToUserAppFull(blogApp), ctx, typeof(User).FullName, user.Url); menuService.AddMenuByApp(blogApp, blogApp.Name, "", blogUrl); } if (menus.Contains("photo")) { IMemberApp photoApp = appService.Add(user, "相册", 3); String photoUrl = UrlConverter.clearUrl(alink.ToUserAppFull(photoApp), ctx, typeof(User).FullName, user.Url); menuService.AddMenuByApp(photoApp, photoApp.Name, "", photoUrl); } if (menus.Contains("microblog")) { IMenu menu = getMenu(user, "微博", alink.ToUserMicroblog(user), ctx); menuService.Insert(menu, user, user); } if (menus.Contains("friend")) { IMenu menu = getMenu(user, "好友", lnkToUser(user, new Users.FriendController().FriendList), ctx); menuService.Insert(menu, user, user); } if (menus.Contains("visitor")) { IMenu menu = getMenu(user, "访客", lnkToUser(user, new Users.VisitorController().Index), ctx); menuService.Insert(menu, user, user); } if (menus.Contains("forumpost")) { IMenu menu = getMenu(user, "论坛帖子", lnkToUser(user, new Users.ForumController().Topic), ctx); menuService.Insert(menu, user, user); } if (menus.Contains("about")) { IMenu menu = getMenu(user, "关于我", lnkToUser(user, new Users.ProfileController().Main), ctx); menuService.Insert(menu, user, user); } if (menus.Contains("feedback")) { IMenu menu = getMenu(user, "留言", lnkToUser(user, new Users.FeedbackController().List), ctx); menuService.Insert(menu, user, user); } }