/** * @param SideMenuModule $Module * @param string $CurrentUrl */ public function BuildEditMenu(&$Module, $CurrentUrl = '') { if (!$this->User) { return; } $Module->HtmlId = 'UserOptions'; $Module->AutoLinkGroups = FALSE; $Session = Gdn::Session(); $ViewingUserID = $Session->UserID; $Module->AddItem('Options', '', FALSE, array('class' => 'SideMenu')); // Check that we have the necessary tools to allow image uploading $AllowImages = C('Garden.Profile.EditPhotos', TRUE) && Gdn_UploadImage::CanUploadImages(); // Is the photo hosted remotely? $RemotePhoto = IsUrl($this->User->Photo); if ($this->User->UserID != $ViewingUserID) { // Include user js files for people with edit users permissions if (CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Profiles.Edit')) { // $this->AddJsFile('jquery.gardenmorepager.js'); $this->AddJsFile('user.js'); } $Module->AddLink('Options', Sprite('SpProfile') . ' ' . T('Edit Profile'), UserUrl($this->User, '', 'edit'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'Popup EditAccountLink')); $Module->AddLink('Options', Sprite('SpProfile') . ' ' . T('Edit Account'), '/user/edit/' . $this->User->UserID, 'Garden.Users.Edit', array('class' => 'Popup EditAccountLink')); $Module->AddLink('Options', Sprite('SpDelete') . ' ' . T('Delete Account'), '/user/delete/' . $this->User->UserID, 'Garden.Users.Delete', array('class' => 'Popup DeleteAccountLink')); if ($this->User->Photo != '' && $AllowImages) { $Module->AddLink('Options', Sprite('SpDelete') . ' ' . T('Remove Picture'), CombinePaths(array(UserUrl($this->User, '', 'removepicture'), $Session->TransientKey())), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'RemovePictureLink')); } $Module->AddLink('Options', Sprite('SpPreferences') . ' ' . T('Edit Preferences'), UserUrl($this->User, '', 'preferences'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'Popup PreferencesLink')); // Add profile options for everyone $Module->AddLink('Options', Sprite('SpPicture') . ' ' . T('Change Picture'), UserUrl($this->User, '', 'picture'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'PictureLink')); if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) { $Module->AddLink('Options', Sprite('SpThumbnail') . ' ' . T('Edit Thumbnail'), UserUrl($this->User, '', 'thumbnail'), array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), array('class' => 'ThumbnailLink')); } } else { // Add profile options for the profile owner // Don't allow account editing if it has been turned off. // Don't allow password editing if using SSO Connect ONLY. // This is for security. We encountered the case where a customer charges // for membership using their external application and use SSO to let // their customers into Vanilla. If you allow those people to change their // password in Vanilla, they will then be able to log into Vanilla using // Vanilla's login form regardless of the state of their membership in the // external app. if (C('Garden.UserAccount.AllowEdit') && C('Garden.Registration.Method') != 'Connect') { $Module->AddLink('Options', Sprite('SpEdit') . ' ' . T('Edit Profile'), '/profile/edit', FALSE, array('class' => 'Popup EditAccountLink')); // No password may have been set if they have only signed in with a connect plugin $PasswordLabel = T('Change My Password'); if ($this->User->HashMethod && $this->User->HashMethod != "Vanilla") { $PasswordLabel = T('Set A Password'); } $Module->AddLink('Options', Sprite('SpPassword') . ' ' . $PasswordLabel, '/profile/password', FALSE, array('class' => 'Popup PasswordLink')); } $Module->AddLink('Options', Sprite('SpPreferences') . ' ' . T('Notification Preferences'), UserUrl($this->User, '', 'preferences'), FALSE, array('class' => 'Popup PreferencesLink')); if ($AllowImages) { $Module->AddLink('Options', Sprite('SpPicture') . ' ' . T('Change My Picture'), '/profile/picture', array('Garden.Profiles.Edit', 'Garden.ProfilePicture.Edit'), array('class' => 'PictureLink')); } if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) { $Module->AddLink('Options', Sprite('SpThumbnail') . ' ' . T('Edit My Thumbnail'), '/profile/thumbnail', array('Garden.Profiles.Edit', 'Garden.ProfilePicture.Edit'), array('class' => 'ThumbnailLink')); } } if ($this->User->UserID == $ViewingUserID || $Session->CheckPermission('Garden.Users.Edit')) { $this->SetData('Connections', array()); $this->EventArguments['User'] = $this->User; $this->FireEvent('GetConnections'); if (count($this->Data('Connections')) > 0) { $Module->AddLink('Options', Sprite('SpConnection') . ' ' . T('Social'), '/profile/connections', 'Garden.SignIn.Allow'); } } }
/** * Adds the option menu to the panel asset. */ public function AddSideMenu($CurrentUrl = '') { if ($this->User !== FALSE) { $SideMenu = new SideMenuModule($this); $SideMenu->HtmlId = 'UserOptions'; $SideMenu->AutoLinkGroups = FALSE; $Session = Gdn::Session(); $ViewingUserID = $Session->UserID; $SideMenu->AddItem('Options', ''); // Check that we have the necessary tools to allow image uploading $AllowImages = Gdn_UploadImage::CanUploadImages(); if ($this->User->UserID != $ViewingUserID) { // Include user js files for people with edit users permissions if ($Session->CheckPermission('Garden.Users.Edit')) { $this->AddJsFile('jquery.gardenmorepager.js'); $this->AddJsFile('user.js'); } // Add profile options for everyone //$SideMenu->AddLink('Options', T('Change Picture'), '/profile/picture/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'PictureLink')); /*if ($this->User->Photo != '' && $AllowImages) { $SideMenu->AddLink('Options', T('Edit Thumbnail'), '/profile/thumbnail/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'ThumbnailLink')); $SideMenu->AddLink('Options', T('Remove Picture'), '/profile/removepicture/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name).'/'.$Session->TransientKey(), 'Garden.Users.Edit', array('class' => 'RemovePictureLink')); }*/ //$SideMenu->AddLink('Options', T('Edit Account'), '/user/edit/'.$this->User->UserID, 'Garden.Users.Edit', array('class' => 'Popup')); //$SideMenu->AddLink('Options', T('Delete Account'), '/user/delete/'.$this->User->UserID, 'Garden.Users.Delete'); //if ($this->User->Photo != '' && $AllowImages) //$SideMenu->AddLink('Options', T('Remove Picture'), '/profile/removepicture/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name).'/'.$Session->TransientKey(), 'Garden.Users.Edit', array('class' => 'RemovePictureLink')); //$SideMenu->AddLink('Options', T('Edit Preferences'), '/profile/preferences/'.$this->User->UserID.'/'.Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'Popup')); } else { // Add profile options for the profile owner //if ($AllowImages) //$SideMenu->AddLink('Options', T('Change My Picture'), '/profile/picture', FALSE, array('class' => 'PictureLink')); if ($this->User->Photo != '' && $AllowImages) { //$SideMenu->AddLink('Options', T('Edit My Thumbnail'), '/profile/thumbnail', FALSE, array('class' => 'ThumbnailLink')); //$SideMenu->AddLink('Options', T('Remove My Picture'), '/profile/removepicture/'.$Session->UserID.'/'.Gdn_Format::Url($Session->User->Name).'/'.$Session->TransientKey(), FALSE, array('class' => 'RemovePictureLink')); } // Don't allow account editing if it has been turned off. if (Gdn::Config('Garden.UserAccount.AllowEdit')) { //$SideMenu->AddLink('Options', T('Edit My Account'), '/profile/edit', FALSE, array('class' => 'Popup')); //$SideMenu->AddLink('Options', T('Change My Password'), '/profile/password', FALSE, array('class' => 'Popup')); } //if (Gdn::Config('Garden.Registration.Method') == 'Invitation') //$SideMenu->AddLink('Options', T('My Invitations'), '/profile/invitations', FALSE, array('class' => 'Popup')); $SideMenu->AddLink('Options', T('My Preferences'), '/profile/preferences/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), FALSE, array('class' => 'Popup')); } $this->EventArguments['SideMenu'] =& $SideMenu; $this->FireEvent('AfterAddSideMenu'); $this->AddModule($SideMenu, 'Panel'); } }
/** * Adds the option menu to the panel asset. * * @since 2.0.0 * @access public * @param string $CurrentUrl Path to highlight. */ public function AddSideMenu($CurrentUrl = '') { if ($this->User !== FALSE) { $SideMenu = new SideMenuModule($this); $SideMenu->HtmlId = 'UserOptions'; $SideMenu->AutoLinkGroups = FALSE; $Session = Gdn::Session(); $ViewingUserID = $Session->UserID; $SideMenu->AddItem('Options', ''); // Check that we have the necessary tools to allow image uploading $AllowImages = Gdn_UploadImage::CanUploadImages(); // Is the photo hosted remotely? $RemotePhoto = in_array(substr($this->User->Photo, 0, 7), array('http://', 'https:/')); if ($this->User->UserID != $ViewingUserID) { // Include user js files for people with edit users permissions if ($Session->CheckPermission('Garden.Users.Edit')) { // $this->AddJsFile('jquery.gardenmorepager.js'); $this->AddJsFile('user.js'); } // Add profile options for everyone $SideMenu->AddLink('Options', T('Change Picture'), '/profile/picture/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'PictureLink')); if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) { $SideMenu->AddLink('Options', T('Edit Thumbnail'), '/profile/thumbnail/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'ThumbnailLink')); $SideMenu->AddLink('Options', T('Remove Picture'), '/profile/removepicture/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name) . '/' . $Session->TransientKey(), 'Garden.Users.Edit', array('class' => 'RemovePictureLink')); } $SideMenu->AddLink('Options', T('Edit Account'), '/user/edit/' . $this->User->UserID, 'Garden.Users.Edit', array('class' => 'Popup EditAccountLink')); $SideMenu->AddLink('Options', T('Delete Account'), '/user/delete/' . $this->User->UserID, 'Garden.Users.Delete', array('class' => 'Popup DeleteAccountLink')); if ($this->User->Photo != '' && $AllowImages) { $SideMenu->AddLink('Options', T('Remove Picture'), '/profile/removepicture/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name) . '/' . $Session->TransientKey(), 'Garden.Users.Edit', array('class' => 'RemovePictureLink')); } $SideMenu->AddLink('Options', T('Edit Preferences'), '/profile/preferences/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), 'Garden.Users.Edit', array('class' => 'Popup PreferencesLink')); } else { // Add profile options for the profile owner if ($AllowImages) { $SideMenu->AddLink('Options', T('Change My Picture'), '/profile/picture', 'Garden.Profiles.Edit', array('class' => 'PictureLink')); } if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) { $SideMenu->AddLink('Options', T('Edit My Thumbnail'), '/profile/thumbnail', 'Garden.Profiles.Edit', array('class' => 'ThumbnailLink')); $SideMenu->AddLink('Options', T('Remove My Picture'), '/profile/removepicture/' . $Session->UserID . '/' . Gdn_Format::Url($Session->User->Name) . '/' . $Session->TransientKey(), 'Garden.Profiles.Edit', array('class' => 'RemovePictureLink')); } // Don't allow account editing if it has been turned off. if (Gdn::Config('Garden.UserAccount.AllowEdit')) { $SideMenu->AddLink('Options', T('Edit My Account'), '/profile/edit', FALSE, array('class' => 'Popup EditAccountLink')); // No password may have been set if they have only signed in with a connect plugin $passwordLabel = T('Change My Password'); if ($this->User->HashMethod && $this->User->HashMethod != "Vanilla") { $passwordLabel = T('Set A Password'); } $SideMenu->AddLink('Options', $passwordLabel, '/profile/password', FALSE, array('class' => 'Popup PasswordLink')); } if (Gdn::Config('Garden.Registration.Method') == 'Invitation') { $SideMenu->AddLink('Options', T('My Invitations'), '/profile/invitations', FALSE, array('class' => 'Popup InvitationsLink')); } $SideMenu->AddLink('Options', T('My Preferences'), '/profile/preferences/' . $this->User->UserID . '/' . Gdn_Format::Url($this->User->Name), FALSE, array('class' => 'Popup PreferencesLink')); } $this->EventArguments['SideMenu'] =& $SideMenu; $this->FireEvent('AfterAddSideMenu'); $this->AddModule($SideMenu, 'Panel'); } }