public bool canEdit(map_views views, users user) { bool flag = false; switch (user.groups.name) { case "Admin": { // foreach (place_types item in place.place_types) // { //if (views.authors.Contains(user)) flag = true; break; // } } case "Editor": { //foreach (place_types item in place.place_types) // { //if (user.place_types.Contains(item)) flag = true; break; //} } } return(flag); }
public void clearLock(int id, bool ajax) { map_views view = ActiveRecordBase <map_views> .Find(id); view.editing = null; ActiveRecordMediator <map_views> .Save(view); CancelLayout(); RenderText("true"); }
public map_views[] getPublished() { map_views published = ActiveRecordBase <map_views> .Find(3); ICriterion expression = Expression.Eq("Status", published); map_views[] views = ActiveRecordBase <map_views> .FindAll(expression); return(views); }
public map_views[] getReview() { map_views review = ActiveRecordBase <map_views> .Find(2); ICriterion expression = Expression.Eq("Status", review); map_views[] views = ActiveRecordBase <map_views> .FindAll(expression); return(views); }
public map_views[] getDrafts() { map_views draft = ActiveRecordBase <map_views> .Find(1); ICriterion expression = Expression.Eq("Status", draft); map_views[] views = ActiveRecordBase <map_views> .FindAll(expression); return(views); }
public void delete(int id) { HelperService.writelog("Deleting view ", id); map_views view = ActiveRecordBase <map_views> .Find(id); Flash["message"] = "Article, <strong>Note:" + view.name + "</strong>, has been <strong>deleted</strong>."; ActiveRecordMediator <map_views> .Delete(view); CancelLayout(); RedirectToAction("list"); }
public void DeleteAuthor(int id, int viewId) { users author = ActiveRecordBase <users> .Find(id); map_views view = ActiveRecordBase <map_views> .Find(viewId); view.authors.Remove(author); ActiveRecordMediator <map_views> .Save(view); CancelLayout(); RenderText("true"); }
/*public bool canPublish(authors user) * { * bool flag = false; * switch (user.access_levels.title) * { * case "Admin": flag = true; break; * case "Editor": flag = true; break; * } * return flag; * }*/ public void setStatus(int id, int status, bool ajax) { map_views view = ActiveRecordBase <map_views> .Find(id); PropertyBag["view"] = view; status published = ActiveRecordBase <status> .Find(status); //view.Status = published; ActiveRecordMediator <map_views> .Save(view); //if(!ajax) //RedirectToReferrer(); string myTime = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss:ffff"); NameValueCollection myCol = new NameValueCollection(); myCol.Add("time", myTime); Redirect("view", "list", myCol); //} }
public void New() { map_views view = new map_views(); PropertyBag["loginUser"] = userService.getUserFull(); //String locationList = Getlocation(); //PropertyBag["locations"] = locationList; // string should be "location1","location2","location3" PropertyBag["view"] = Flash["view"] != null ? Flash["view"] : view; PropertyBag["tags"] = Flash["tags"] != null ? Flash["tags"] : ActiveRecordBase <tags> .FindAll(); PropertyBag["authors"] = Flash["authors"] != null ? Flash["authors"] : ActiveRecordBase <users> .FindAll(); PropertyBag["accesslevels"] = ActiveRecordBase <user_groups> .FindAll(); PropertyBag["statuslists"] = ActiveRecordBase <status> .FindAll(); PropertyBag["places"] = ActiveRecordBase <place> .FindAll(); RenderView("_editor"); }
public void Update( [ARDataBind("view", Validate = true, AutoLoad = AutoLoadBehavior.NewRootInstanceIfInvalidKey)] map_views view, [ARDataBind("tabs", Validate = true, AutoLoad = AutoLoadBehavior.NewRootInstanceIfInvalidKey)] infotabs[] tabs, int[] cats, String[] newtab, [ARDataBind("images", Validate = true, AutoLoad = AutoLoadBehavior.NewRootInstanceIfInvalidKey)] media_repo[] images, String[][] fields, int[] geolist, int[] placelist, bool ajaxed_update, bool forced_tmp, string LongLength, string Length, string apply, string cancel ) { //if (view.options.id == 0) ActiveRecordMediator<map_views_options>.Save(view.options); Flash["view"] = view; Flash["tags"] = view; Flash["authors"] = view; //ActiveRecordMediator<map_views>.Update(view); if (cancel != null) { HelperService.writelog("Canceled changes mapview", view.id); view.editing = null; ActiveRecordMediator <map_views> .Save(view); RedirectToAction("list"); return; } if (view.name == null || view.name.Length == 0) { //Flash["error"] = "You are missing the basic parts of a view"; //RedirectToReferrer(); //return; } if (forced_tmp && view.id == 0) { view.tmp = true; } else { view.tmp = false; string gemSql = "POINT (" + LongLength + " " + Length + ")"; string wkt = gemSql; SqlChars udtText = new SqlChars(wkt); SqlGeography sqlGeometry1 = SqlGeography.STGeomFromText(udtText, 4326); MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); byte[] WKB = sqlGeometry1.STAsBinary().Buffer; view.center = geometrics.AsByteArray(sqlGeometry1);//WKB;// } //view.tags.Clear(); //view.Images.Clear(); users user = userService.getUserFull(); view.authors.Clear(); if (apply != null) { } else { view.editing = null; } if (view.id == 0) { if (!userService.checkPrivilege("can_publish") || view.status == null) { status stat = ActiveRecordBase <status> .Find(1); view.status = stat; } view.creation_date = DateTime.Now; } else { view.updated_date = DateTime.Now; } /* foreach (authors author in authors){ * if (author.id > 0) * view.authors.Add(author); * }*/ view.authors.Add(user); if (HelperService.alias_exsits(view.alias, this.GetType().Name).Length > 1) { view.alias = view.alias + "1"; ActiveRecordMediator <map_views> .Save(view); Flash["error"] = "The url you choose is in use. Please choose a new one. We have saved it as '" + view.alias + "1" + "' currently."; if (apply != " Save ") { RedirectToUrl("~/view/_edit.castle?id=" + view.id); } else { RedirectToReferrer(); } return; } /* * //map_views_options tmp = view.options; * var jss = new JavaScriptSerializer(); * var json = jss.Serialize(tmp); * view.options_obj = json; */ Dictionary <string, string> urlparams = getPostParmasAsObj_obj("options"); var jss = new JavaScriptSerializer(); //jss.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() }); //var values = new Dictionary<string, object>(); MyJsonDictionary <String, Object> values = new MyJsonDictionary <String, Object>(); foreach (KeyValuePair <string, string> _urlparams in urlparams) { values.Add(_urlparams.Key, _urlparams.Value); } view.options_obj = Serialize(values);//jss.Serialize(usettings); if (view.geometrics != null) { view.geometrics.Clear(); foreach (int newItem in geolist) { view.geometrics.Add(ActiveRecordBase <geometrics> .Find(newItem)); } } if (view.places != null) { view.places.Clear(); foreach (int newItem in placelist) { view.places.Add(ActiveRecordBase <place> .Find(newItem)); } } ActiveRecordMediator <map_views> .Save(view); string appPath = getRootPath(); String cachePath = appPath + "cache/embeds/"; string file = HelperService.CalculateMD5Hash(view.alias) + ".ext"; String file_path = cachePath + file; if (File.Exists(file_path)) { File.Delete(file_path); } cleanUpview_media(view.id); Flash["view"] = null; Flash["tags"] = null; Flash["authors"] = null; if (apply != null) { HelperService.writelog("Applied changes mapview ", view.id); if (apply != " Save ") { RedirectToUrl("~/view/_edit.castle?applied=true&id=" + view.id); } else { RedirectToUrl("~/view/_edit.castle?applied=true"); //RedirectToReferrer(); } } else { view.editing = null; ActiveRecordMediator <map_views> .Save(view); HelperService.writelog("Saved mapview ", view.id); RedirectToAction("list"); } }
public void breakingNewsreadmore(int id) { map_views view = ActiveRecordBase <map_views> .Find(id); PropertyBag["BreakingNews"] = view; }
public void _edit(int id, int page, Boolean applied) { if (!applied) { HelperService.writelog("Editing map view", id); } PropertyBag["credits"] = ""; PropertyBag["imagetypes"] = ActiveRecordBase <media_types> .FindAll(); PropertyBag["images_inline"] = ActiveRecordBase <media_repo> .FindAll(); map_views view = ActiveRecordBase <map_views> .Find(id); users user = userService.getUserFull(); String username = user.nid; PropertyBag["loginUser"] = user; PropertyBag["authorname"] = user.name; view.editing = user; ActiveRecordMediator <map_views> .Save(view); //String locationList = Getlocation(); //PropertyBag["locations"] = locationList; // string should be "location1","location2","location3" PropertyBag["loginUser"] = user; PropertyBag["tags"] = ActiveRecordBase <tags> .FindAll(); if (Flash["view"] != null) { map_views flashview = Flash["view"] as map_views; ActiveRecordMediator <map_views> .Refresh(flashview); PropertyBag["view"] = flashview; } else { PropertyBag["view"] = view; } if (view.center != null) { PropertyBag["lat"] = view.getLat(); PropertyBag["long"] = view.getLong(); } PropertyBag["view"] = view; var values = new Dictionary <string, object>(); if (!String.IsNullOrWhiteSpace(view.options_obj) && view.options_obj != "{}") { var jss = new JavaScriptSerializer(); var options = jss.Deserialize <Dictionary <string, dynamic> >(view.options_obj); options.ToList <KeyValuePair <string, dynamic> >(); foreach (KeyValuePair <string, dynamic> option in options) { values.Add(option.Key, option.Value); } } PropertyBag["options"] = values; PropertyBag["options_json"] = view.options_obj == null ? "" : Regex.Replace(Regex.Replace(view.options_obj.Replace(@"""false""", "false").Replace(@"""true""", "true"), @"(""\w+"":\""\"",?)", "", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant).Replace(",}", "}"), @"""(\d+)""", "$1", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant).Replace(",}", "}"); PropertyBag["baseJson"] = view.options_obj == null ? "" : Regex.Replace(view.options_obj, @".*?(\""mapTypeId\"":""(\w+)"".*$)", "$2", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant); PropertyBag["shapes"] = new publicController().createPlaceJson(view.places.ToArray()); PropertyBag["map"] = view; //ImageType imgtype = ActiveRecordBase<ImageType>.Find(1); //PropertyBag["images"] = imgtype.Images; //Flash["images"] != null ? Flash["images"] : //PropertyBag["images"] = ActiveRecordBase<media_repo>.FindAll(); PropertyBag["authors"] = ActiveRecordBase <users> .FindAll();//Flash["authors"] != null ? Flash["authors"] : ActiveRecordBase<author>.FindAll(); PropertyBag["accesslevels"] = ActiveRecordBase <user_groups> .FindAll(); PropertyBag["statuslists"] = ActiveRecordBase <status> .FindAll(); PropertyBag["places"] = ActiveRecordBase <place> .FindAll(); PropertyBag["geometrics"] = ActiveRecordBase <geometrics> .FindAll(Order.Asc("name")); PropertyBag["campuses"] = ActiveRecordBase <campus> .FindAll(Order.Asc("name")); PropertyBag["listcats"] = ActiveRecordBase <categories> .FindAll(); foreach (geometrics_types types in ActiveRecordBase <geometrics_types> .FindAll()) { PropertyBag["styles_" + types.name] = ActiveRecordBase <styles> .FindAllByProperty("type", types); } //PropertyBag["styles_marker"] = ActiveRecordBase<styles>.FindAll().Where(obj => obj.type == ActiveRecordBase<geometrics_types>.Find(1)); if (page == 0) { page = 1; } int pagesize = 10; List <AbstractCriterion> baseEx = new List <AbstractCriterion>(); baseEx.Add(Expression.Eq("View", view)); /*IList<comments> items; * * items = ActiveRecordBase<comments>.FindAll(Order.Desc("CreateTime"), baseEx.ToArray()); * PropertyBag["comments"] = PaginationHelper.CreatePagination(items, pagesize, page);*/ String CreditList = GetCredits(); PropertyBag["credits"] = CreditList; List <users> authors = new List <users>(); if (!view.authors.Contains(user)) { authors.Add(user); } authors.AddRange(view.authors); PropertyBag["viewauthors"] = authors; RenderView("_editor"); }