/** * @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'), userUrl($this->User, '', 'removepicture') . '?tk=' . $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 { if (hasEditProfile($this->User->UserID)) { $Module->addLink('Options', sprite('SpEdit') . ' ' . t('Edit Profile'), '/profile/edit', false, array('class' => 'Popup EditAccountLink')); } // 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') { // 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->Photo != '' && $AllowImages) { $Module->addLink('Options', sprite('SpDelete') . ' ' . t('Remove Picture'), userUrl($this->User, '', 'removepicture') . '?tk=' . $Session->transientKey(), array('Garden.Profiles.Edit', 'Garden.ProfilePicture.Edit'), array('class' => 'RemovePictureLink')); } } 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', array('class' => 'link-social')); } } }