Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Actions          = new AllowedActions(ProfileHelper.UserInfo);
            MyStaff          = ProfileHelper.UserInfo.IsMe();
            UserHasAvatar    = !UserPhotoManager.GetPhotoAbsoluteWebPath(ProfileHelper.UserInfo.ID).Contains("default/images/");
            HasActions       = Actions.AllowEdit || Actions.AllowAddOrDelete;
            IsAdmin          = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin();
            SubscribeBtnText =
                StudioNotifyService.Instance.IsSubscribeToPeriodicNotify(SecurityContext.CurrentAccount.ID)
                    ? ResourceJS.TipsAndTricksUnsubscribeBtn
                    : ResourceJS.TipsAndTricksSubscribeBtn;

            if (HasActions && Actions.AllowAddOrDelete)
            {
                _phConfirmationDeleteUser.Controls.Add(LoadControl(ConfirmationDeleteUser.Location));
            }

            ProfileEditLink =
                Page is MyStaff
                    ? "/my.aspx?action=edit"
                    : "profileaction.aspx?action=edit&user="******"reassigns.aspx?user="******"email_change"] == "success")
            {
                Page.RegisterInlineScript(string.Format("toastr.success(\"{0}\");", Resource.ChangeEmailSuccess));
            }
        }
Exemplo n.º 2
0
        protected UserInfoEx LoadUserInfoEx(Guid userID)
        {
            var dep = GetDepartmentForUser(userID);

            var ui = new UserInfoEx
            {
                Info         = CoreContext.UserManager.GetUsers(userID),
                PhotoPath    = UserPhotoManager.GetPhotoAbsoluteWebPath(userID),
                DepartmentID = (dep != null) ? dep.ID : Guid.Empty,
                Department   = (dep != null) ? dep.Name.HtmlEncode() : "",
            };
            var nodes = SocialContactsManager.xmlSocialContacts.GetElementsByTagName("contact");

            if (nodes == null)
            {
                return(ui);
            }

            for (Int32 i = 0, n = nodes.Count; i < n; i++)
            {
                ui.Contacts.Add(GetSocialContact((XmlElement)nodes[i]));
            }

            return(ui);
        }
Exemplo n.º 3
0
 public ThumbnailsDataWrapper(Guid userId, UserPhotoManager userPhotoManager)
 {
     Original = userPhotoManager.GetPhotoAbsoluteWebPath(userId);
     Retina   = userPhotoManager.GetRetinaPhotoURL(userId);
     Max      = userPhotoManager.GetMaxPhotoURL(userId);
     Big      = userPhotoManager.GetBigPhotoURL(userId);
     Medium   = userPhotoManager.GetMediumPhotoURL(userId);
     Small    = userPhotoManager.GetSmallPhotoURL(userId);
 }
 public ThumbnailsDataWrapper(Tenant tenant, Guid userId)
 {
     Original = UserPhotoManager.GetPhotoAbsoluteWebPath(tenant, userId);
     Retina   = UserPhotoManager.GetRetinaPhotoURL(tenant.TenantId, userId);
     Max      = UserPhotoManager.GetMaxPhotoURL(tenant.TenantId, userId);
     Big      = UserPhotoManager.GetBigPhotoURL(tenant.TenantId, userId);
     Medium   = UserPhotoManager.GetMediumPhotoURL(tenant.TenantId, userId);
     Small    = UserPhotoManager.GetSmallPhotoURL(tenant.TenantId, userId);
 }
Exemplo n.º 5
0
        public EmployeeWraperFull UpdateMemberPhoto(string userid, string files)
        {
            var user = GetUserInfo(userid);

            if (files != UserPhotoManager.GetPhotoAbsoluteWebPath(user.ID))
            {
                UpdatePhotoUrl(files, user);
            }
            CoreContext.UserManager.SaveUserInfo(user);
            return(new EmployeeWraperFull(user));
        }
Exemplo n.º 6
0
        public EmployeeWraperFull UpdateMemberPhoto(string userid, string files)
        {
            var user = GetUserInfo(userid);

            if (files != UserPhotoManager.GetPhotoAbsoluteWebPath(user.ID))
            {
                UpdatePhotoUrl(files, user);
            }

            CoreContext.UserManager.SaveUserInfo(user);
            MessageService.Send(_context, MessageAction.UserAddedAvatar, user.DisplayUserName(false));

            return(new EmployeeWraperFull(user));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Actions       = new AllowedActions(ProfileHelper.UserInfo);
            MyStaff       = ProfileHelper.UserInfo.IsMe();
            UserHasAvatar = !UserPhotoManager.GetPhotoAbsoluteWebPath(ProfileHelper.UserInfo.ID).Contains("default/images/");
            HasActions    = Actions.AllowEdit || Actions.AllowAddOrDelete;
            IsAdmin       = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin();

            if (HasActions && Actions.AllowAddOrDelete)
            {
                _phConfirmationDeleteUser.Controls.Add(LoadControl(ConfirmationDeleteUser.Location));
            }

            ProfileEditLink =
                Page is MyStaff
                    ? "/my.aspx?action=edit"
                    : "profileaction.aspx?action=edit&user=" + HttpUtility.UrlEncode(ProfileHelper.UserInfo.UserName);
        }
Exemplo n.º 8
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            var defuaultPhoto = UserPhotoManager.GetDefaultPhotoAbsoluteWebPath();

            if (User == null)
            {
                MainImgUrl        = defuaultPhoto;
                ThumbnailSettings = UserPhotoThumbnailSettings.LoadForDefaultTenant();
            }
            else
            {
                IsLdap            = User.IsLDAP();
                HasAvatar         = User.HasAvatar();
                MainImgUrl        = UserPhotoManager.GetPhotoAbsoluteWebPath(User.ID);
                ThumbnailSettings = UserPhotoThumbnailSettings.LoadForUser(User.ID);
            }

            Page.RegisterStyle("~/usercontrols/users/userprofile/css/loadphoto_style.less",
                               "~/usercontrols/users/userprofile/css/jquery.jcrop.less")
            .RegisterBodyScripts("~/js/uploader/ajaxupload.js",
                                 "~/usercontrols/users/userprofile/js/loadphoto.js",
                                 "~/usercontrols/users/userprofile/js/jquery.jcrop.js");

            var script =
                string.Format(
                    "window.ASC.Controls.LoadPhotoImage.init('{0}',[{1},{2}],{{point:{{x:{3},y:{4}}},size:{{width:{5},height:{6}}}}},'{7}', '{8}');",
                    User == null ? "" : User.ID.ToString(),
                    UserPhotoManager.SmallFotoSize.Width,
                    UserPhotoManager.SmallFotoSize.Height,
                    ThumbnailSettings.Point.X,
                    ThumbnailSettings.Point.Y,
                    ThumbnailSettings.Size.Width,
                    ThumbnailSettings.Size.Height,
                    HasAvatar ? MainImgUrl : "",
                    defuaultPhoto);

            Page.RegisterInlineScript(script);
        }
 public static string GetPhotoURL(this UserInfo userInfo)
 {
     return(UserPhotoManager.GetPhotoAbsoluteWebPath(userInfo.ID));
 }
Exemplo n.º 10
0
        public EmployeeWraperFull UpdateMember(bool isVisitor, string userid, string email, string firstname, string lastname, string comment, Guid[] department, string title, string location, string sex, ApiDateTime birthday, ApiDateTime worksfrom, IEnumerable <Contact> contacts, string files, bool?disable)
        {
            SecurityContext.DemandPermissions(new UserSecurityProvider(new Guid(userid)), Core.Users.Constants.Action_EditUser);

            var user = GetUserInfo(userid);

            if (CoreContext.UserManager.IsSystemUser(user.ID))
            {
                throw new SecurityException();
            }

            var self      = SecurityContext.CurrentAccount.ID.Equals(user.ID);
            var resetDate = new DateTime(1900, 01, 01);

            //Update it

            //Validate email
            if (!string.IsNullOrEmpty(email))
            {
                var address = new MailAddress(email);
                user.Email = address.Address;
            }

            //Set common fields
            user.FirstName = firstname ?? user.FirstName;
            user.LastName  = lastname ?? user.LastName;
            user.Title     = title ?? user.Title;
            user.Location  = location ?? user.Location;
            user.Notes     = comment ?? user.Notes;
            user.Sex       = ("male".Equals(sex, StringComparison.OrdinalIgnoreCase)
                            ? true
                            : ("female".Equals(sex, StringComparison.OrdinalIgnoreCase) ? (bool?)false : null)) ?? user.Sex;

            user.BirthDate = birthday != null?TenantUtil.DateTimeFromUtc(Convert.ToDateTime(birthday)) : user.BirthDate;

            if (user.BirthDate == resetDate)
            {
                user.BirthDate = null;
            }

            user.WorkFromDate = worksfrom != null?TenantUtil.DateTimeFromUtc(Convert.ToDateTime(worksfrom)) : user.WorkFromDate;

            if (user.WorkFromDate == resetDate)
            {
                user.WorkFromDate = null;
            }

            //Update contacts
            UpdateContacts(contacts, user);
            UpdateDepartments(department, user);

            if (files != UserPhotoManager.GetPhotoAbsoluteWebPath(user.ID))
            {
                UpdatePhotoUrl(files, user);
            }
            if (disable.HasValue)
            {
                user.Status         = disable.Value ? EmployeeStatus.Terminated : EmployeeStatus.Active;
                user.TerminatedDate = disable.Value ? DateTime.UtcNow : (DateTime?)null;
            }

            if (self && !CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Core.Users.Constants.GroupAdmin.ID))
            {
                StudioNotifyService.Instance.SendMsgToAdminAboutProfileUpdated();
            }

            // change user type
            var canBeGuestFlag = !user.IsOwner() && !user.IsAdmin() && !user.GetListAdminModules().Any() && !user.IsMe();

            if (isVisitor && !user.IsVisitor() && canBeGuestFlag)
            {
                CoreContext.UserManager.AddUserIntoGroup(user.ID, Core.Users.Constants.GroupVisitor.ID);
                WebItemSecurity.ClearCache();
            }

            if (!self && !isVisitor && user.IsVisitor())
            {
                var usersQuota = TenantExtra.GetTenantQuota().ActiveUsers;
                if (TenantStatisticsProvider.GetUsersCount() < usersQuota)
                {
                    CoreContext.UserManager.RemoveUserFromGroup(user.ID, Core.Users.Constants.GroupVisitor.ID);
                    WebItemSecurity.ClearCache();
                }
                else
                {
                    throw new TenantQuotaException(string.Format("Exceeds the maximum active users ({0})", usersQuota));
                }
            }

            CoreContext.UserManager.SaveUserInfo(user, isVisitor);
            MessageService.Send(Request, MessageAction.UserUpdated, user.DisplayUserName(false));

            return(new EmployeeWraperFull(user));
        }
 public string GetPhotoPath()
 {
     return(IsPageEditProfileFlag ? UserPhotoManager.GetPhotoAbsoluteWebPath(UserProfile.Id) : UserPhotoManager.GetDefaultPhotoAbsoluteWebPath());
 }
Exemplo n.º 12
0
 public static string GetPhotoURL(this UserInfo userInfo, Guid moduleID)
 {
     return(UserPhotoManager.GetPhotoAbsoluteWebPath(moduleID, userInfo.ID));
 }
Exemplo n.º 13
0
        public override void HandleMessage(XmppStream stream, Message message, XmppHandlerContext context)
        {
            if (!message.HasTo || message.To.IsServer)
            {
                context.Sender.SendTo(stream, XmppStanzaError.ToServiceUnavailable(message));
                return;
            }

            var sessions = context.SessionManager.GetBareJidSessions(message.To);

            if (0 < sessions.Count)
            {
                foreach (var s in sessions)
                {
                    try
                    {
                        context.Sender.SendTo(s, message);
                    }
                    catch
                    {
                        context.Sender.SendToAndClose(s.Stream, message);
                    }
                }
            }
            else
            {
                pushStore = new DbPushStore();
                var properties = new Dictionary <string, string>(1);
                properties.Add("connectionStringName", "default");
                pushStore.Configure(properties);

                if (message.HasTag("active"))
                {
                    var fromFullName = message.HasAttribute("username") ?
                                       message.GetAttribute("username") : message.From.ToString();

                    var tenantId        = -1;
                    var messageToDomain = message.To.ToString().Split(new char[] { '@' })[1];

                    foreach (
                        var tenant in CoreContext.TenantManager.GetTenants().Where(t => t.Status == TenantStatus.Active)
                        )
                    {
                        if (tenant.TenantDomain == messageToDomain)
                        {
                            tenantId = tenant.TenantId;
                            break;
                        }
                    }
                    var userPushList = new List <UserPushInfo>();
                    userPushList = pushStore.GetUserEndpoint(message.To.ToString().Split(new char[] { '@' })[0]);

                    var firebaseAuthorization = "";
                    try
                    {
                        CallContext.SetData(TenantManager.CURRENT_TENANT, new Tenant(tenantId, ""));
                        firebaseAuthorization = KeyStorage.Get("firebase_authorization");
                    }
                    catch (Exception exp)
                    {
                        log.DebugFormat("firebaseAuthorizationERROR: {0}", exp);
                    }
                    foreach (var user in userPushList)
                    {
                        try
                        {
                            var           from = message.From.ToString().Split(new char[] { '@' })[0];
                            List <string> userId;
                            string        photoPath = "";
                            using (var db = new DbManager("core"))
                                using (var command = db.Connection.CreateCommand())
                                {
                                    var q = new SqlQuery("core_user").Select("id").Where(Exp.Like("username", from));

                                    userId = command.ExecuteList(q, DbRegistry.GetSqlDialect(db.DatabaseId))
                                             .ConvertAll(r => Convert.ToString(r[0]))
                                             .ToList();
                                }
                            if (userId.Count != 0)
                            {
                                var guid = new Guid(userId[0]);
                                photoPath = UserPhotoManager.GetPhotoAbsoluteWebPath(guid);
                            }

                            var tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
                            tRequest.Method      = "post";
                            tRequest.ContentType = "application/json";
                            var data = new
                            {
                                to   = user.endpoint,
                                data = new
                                {
                                    msg          = message.Body,
                                    fromFullName = fromFullName,
                                    photoPath    = photoPath
                                }
                            };
                            var serializer = new JavaScriptSerializer();
                            var json       = serializer.Serialize(data);
                            var byteArray  = Encoding.UTF8.GetBytes(json);
                            tRequest.Headers.Add(string.Format("Authorization: key={0}", firebaseAuthorization));
                            tRequest.ContentLength = byteArray.Length;
                            using (var dataStream = tRequest.GetRequestStream())
                            {
                                dataStream.Write(byteArray, 0, byteArray.Length);
                                using (var tResponse = tRequest.GetResponse())
                                {
                                    using (var dataStreamResponse = tResponse.GetResponseStream())
                                    {
                                        using (var tReader = new StreamReader(dataStreamResponse))
                                        {
                                            var sResponseFromServer = tReader.ReadToEnd();
                                            var str = sResponseFromServer;
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            var str = ex.Message;
                            log.DebugFormat("PushRequestERROR: {0}", str);
                        }
                    }
                }
                StoreOffline(message, context.StorageManager.OfflineStorage);
            }
        }