コード例 #1
0
 public function ToString()
 {
     $Session = Gdn::Session();
     $Controller = Gdn::Controller();
     $UserID = $Controller->User->UserID;
     $MemberOptions = array();
     $ProfileOptions = array();
     $Controller->EventArguments['UserID'] = $UserID;
     $Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
     $Controller->EventArguments['MemberOptions'] =& $MemberOptions;
     if ($Controller->EditMode) {
         return '<div class="ProfileOptions">' . Anchor(T('Back to Profile'), UserUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>';
         //         $ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile');
     } else {
         // Profile Editing
         if (hasEditProfile($Controller->User->UserID)) {
             $ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit'));
         }
         // Ban/Unban
         $MayBan = CheckPermission('Garden.Moderation.Manage') || CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Users.Ban');
         if ($MayBan && $UserID != $Session->UserID) {
             if ($Controller->User->Banned) {
                 $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
             } elseif (!$Controller->User->Admin) {
                 $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
             }
         }
         // Delete content.
         if (CheckPermission('Garden.Moderation.Manage')) {
             $ProfileOptions[] = array('Text' => Sprite('SpDelete') . ' ' . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
         }
     }
     return parent::ToString();
 }
コード例 #2
0
 public function toString()
 {
     $Session = Gdn::session();
     $Controller = Gdn::controller();
     $UserID = $Controller->User->UserID;
     $MemberOptions = array();
     $ProfileOptions = array();
     $Controller->EventArguments['UserID'] = $UserID;
     $Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
     $Controller->EventArguments['MemberOptions'] =& $MemberOptions;
     if ($Controller->EditMode) {
         return '<div class="ProfileOptions">' . anchor(t('Back to Profile'), userUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>';
         //         $ProfileOptions[] = array('Text' => t('Back to Profile'), 'Url' => userUrl($Controller->User), 'CssClass' => 'BackToProfile');
     } else {
         // Profile Editing
         if (hasEditProfile($Controller->User->UserID)) {
             $ProfileOptions[] = array('Text' => sprite('SpEditProfile') . ' ' . t('Edit Profile'), 'Url' => userUrl($Controller->User, '', 'edit'));
         } elseif ($Session->isValid() && $UserID == $Session->UserID) {
             $ProfileOptions[] = array('Text' => sprite('SpEditProfile') . ' ' . t('Preferences'), 'Url' => userUrl($Controller->User, '', 'preferences'));
         }
         // Ban/Unban
         $MayBan = checkPermission('Garden.Moderation.Manage') || checkPermission('Garden.Users.Edit') || checkPermission('Moderation.Users.Ban');
         if ($MayBan && $UserID != $Session->UserID) {
             if (BanModel::isBanned($Controller->User->Banned, BanModel::BAN_AUTOMATIC | BanModel::BAN_MANUAL)) {
                 $ProfileOptions[] = array('Text' => sprite('SpBan') . ' ' . t('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
             } elseif (!$Controller->User->Admin) {
                 $ProfileOptions[] = array('Text' => sprite('SpBan') . ' ' . t('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
             }
         }
         // Delete content.
         if (checkPermission('Garden.Moderation.Manage')) {
             $ProfileOptions[] = array('Text' => sprite('SpDelete') . ' ' . t('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
         }
     }
     return parent::ToString();
 }
コード例 #3
0
ファイル: me.php プロジェクト: caidongyun/vanilla
 if (Gdn::ApplicationManager()->CheckApplication('Vanilla')) {
     echo '<span class="ToggleFlyout" rel="/discussions/bookmarkedpopin">';
     echo anchor(sprite('SpBookmarks', 'Sprite Sprite16') . Wrap(t('Bookmarks'), 'em'), '/discussions/bookmarked', 'MeButton FlyoutButton', array('title' => t('Bookmarks')));
     echo sprite('SpFlyoutHandle', 'Arrow');
     echo '<div class="Flyout FlyoutMenu"></div></span>';
 }
 // Profile Settings & Logout
 echo '<span class="ToggleFlyout">';
 $CDashboard = $DashboardCount > 0 ? wrap($DashboardCount, 'span class="Alert"') : '';
 echo anchor(sprite('SpOptions', 'Sprite Sprite16') . Wrap(t('Account Options'), 'em') . $CDashboard, '/profile/edit', 'MeButton FlyoutButton', array('title' => t('Account Options')));
 echo sprite('SpFlyoutHandle', 'Arrow');
 echo '<div class="Flyout MenuItems">';
 echo '<ul>';
 // echo wrap(Wrap(t('My Account'), 'strong'), 'li');
 // echo wrap('<hr />', 'li');
 if (hasEditProfile(Gdn::session()->UserID)) {
     echo wrap(Anchor(sprite('SpEditProfile') . ' ' . t('Edit Profile'), 'profile/edit', 'EditProfileLink'), 'li', array('class' => 'EditProfileWrap link-editprofile'));
 } else {
     echo wrap(Anchor(sprite('SpEditProfile') . ' ' . t('Preferences'), 'profile/preferences', 'EditProfileLink'), 'li', array('class' => 'EditProfileWrap link-preferences'));
 }
 if ($Session->checkPermission(array('Garden.Settings.View', 'Garden.Settings.Manage', 'Garden.Moderation.Manage', 'Garden.Users.Approve', 'Moderation.Spam.Manage', 'Moderation.ModerationQueue.Manage'), false)) {
     echo wrap('<hr />', 'li');
     $CApplicant = $ApplicantCount > 0 ? ' ' . Wrap($ApplicantCount, 'span class="Alert"') : '';
     $CSpam = '';
     //$SpamCount > 0 ? ' '.Wrap($SpamCount, 'span class="Alert"') : '';
     $CModeration = $ModerationCount > 0 ? ' ' . Wrap($ModerationCount, 'span class="Alert"') : '';
     if ($Session->checkPermission('Garden.Users.Approve')) {
         echo wrap(Anchor(sprite('SpApplicants') . ' ' . t('Applicants') . $CApplicant, '/dashboard/user/applicants'), 'li', array('class' => 'link-applicants'));
     }
     if ($Session->checkPermission(array('Garden.Settings.Manage', 'Garden.Moderation.Manage', 'Moderation.ModerationQueue.Manage'), false)) {
         echo wrap(Anchor(sprite('SpSpam') . ' ' . t('Spam Queue') . $CSpam, '/dashboard/log/spam'), 'li', array('class' => 'link-spam'));
コード例 #4
0
ファイル: class.hooks.php プロジェクト: vanilla/vanilla
 /**
  *
  *
  * @param SiteNavModule $sender
  */
 public function siteNavModule_init_handler($sender)
 {
     // GLOBALS
     // Add a link to the community home.
     $sender->addLinkToGlobals(t('Community Home'), '/', 'main.home', '', -100, array('icon' => 'home'), false);
     $sender->addGroupToGlobals('', 'etc', '', 100);
     $sender->addLinkToGlobalsIf(Gdn::session()->isValid() && IsMobile(), t('Full Site'), '/profile/nomobile', 'etc.nomobile', '', 100, array('icon' => 'resize-full'));
     $sender->addLinkToGlobalsIf(Gdn::session()->isValid(), t('Sign Out'), SignOutUrl(), 'etc.signout', '', 100, array('icon' => 'signout'));
     $sender->addLinkToGlobalsIf(!Gdn::session()->isValid(), t('Sign In'), SigninUrl(), 'etc.signin', '', 100, array('icon' => 'signin'));
     // DEFAULTS
     if (!Gdn::session()->isValid()) {
         return;
     }
     $sender->addLinkIf(Gdn::session()->isValid(), t('Profile'), '/profile', 'main.profile', 'profile', 10, array('icon' => 'user'))->addLinkIf('Garden.Activity.View', t('Activity'), '/activity', 'main.activity', 'activity', 10, array('icon' => 'time'));
     // Add the moderation items.
     $sender->addGroup(t('Moderation'), 'moderation', 'moderation', 90);
     if (Gdn::session()->checkPermission('Garden.Users.Approve')) {
         $RoleModel = new RoleModel();
         $applicant_count = (int) $RoleModel->getApplicantCount();
         if ($applicant_count > 0 || true) {
             $sender->addLink(t('Applicants'), '/user/applicants', 'moderation.applicants', 'applicants', array(), array('icon' => 'user', 'badge' => $applicant_count));
         }
     }
     $sender->addLinkIf('Garden.Moderation.Manage', t('Spam Queue'), '/log/spam', 'moderation.spam', 'spam', array(), array('icon' => 'spam'))->addLinkIf('Garden.Settings.Manage', t('Dashboard'), '/settings', 'etc.dashboard', 'dashboard', array(), array('icon' => 'dashboard'));
     $user = Gdn::controller()->data('Profile');
     $user_id = val('UserID', $user);
     //EDIT PROFILE SECTION
     // Users can edit their own profiles and moderators can edit any profile.
     $sender->addLinkToSectionIf(hasEditProfile($user_id), 'EditProfile', t('Profile'), userUrl($user, '', 'edit'), 'main.editprofile', '', array(), array('icon' => 'edit'))->addLinkToSectionIf('Garden.Users.Edit', 'EditProfile', t('Edit Account'), '/user/edit/' . $user_id, 'main.editaccount', 'Popup', array(), array('icon' => 'cog'))->addLinkToSection('EditProfile', t('Back to Profile'), userUrl($user), 'main.profile', '', 100, array('icon' => 'arrow-left'));
     //PROFILE SECTION
     $sender->addLinkToSectionIf(c('Garden.Profile.ShowActivities', true), 'Profile', t('Activity'), userUrl($user, '', 'activity'), 'main.activity', '', array(), array('icon' => 'time'))->addLinkToSectionIf(Gdn::controller()->data('Profile.UserID') == Gdn::session()->UserID, 'Profile', t('Notifications'), userUrl($user, '', 'notifications'), 'main.notifications', '', array(), array('icon' => 'globe', 'badge' => Gdn::controller()->data('Profile.CountNotifications')))->addLinkToSectionIf(strcasecmp(c('Garden.Registration.Method'), 'invitation') === 0, 'Profile', t('Invitations'), userUrl($user, '', 'invitations'), 'main.invitations', '', array(), array('icon' => 'ticket'))->addLinkToSectionIf(hasEditProfile($user_id), 'Profile', t('Edit Profile'), userUrl($user, '', 'edit'), 'Profile', 'main.editprofile', '', array(), array('icon' => 'edit'));
 }
コード例 #5
0
 /**
  * @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'));
         }
     }
 }
コード例 #6
0
ファイル: class.hooks.php プロジェクト: R-J/vanilla
 /**
  *
  *
  * @param SiteNavModule $sender
  */
 public function siteNavModule_profile_handler($sender)
 {
     $user = Gdn::controller()->data('Profile');
     $user_id = val('UserID', $user);
     // Show the activity.
     if (c('Garden.Profile.ShowActivities', true)) {
         $sender->addLink('main.activity', array('text' => t('Activity'), 'url' => userUrl($user, '', 'activity'), 'icon' => icon('time')));
     }
     // Display the notifications for the current user.
     if (Gdn::controller()->data('Profile.UserID') == Gdn::session()->UserID) {
         $sender->addLink('main.notifications', array('text' => t('Notifications'), 'url' => userUrl($user, '', 'notifications'), 'icon' => icon('globe'), 'badge' => Gdn::controller()->data('Profile.CountNotifications')));
     }
     // Show the invitations if we're using the invite registration method.
     if (strcasecmp(c('Garden.Registration.Method'), 'invitation') === 0) {
         $sender->addLink('main.invitations', array('text' => t('Invitations'), 'url' => userUrl($user, '', 'invitations'), 'icon' => icon('ticket')));
     }
     // Users can edit their own profiles and moderators can edit any profile.
     if (hasEditProfile($user_id)) {
         $sender->addLink('main.editprofile', array('text' => t('Edit Profile'), 'url' => userUrl($user, '', 'edit'), 'icon' => icon('edit')));
     }
     // Add a stub group for moderation.
     $sender->addGroup('moderation', array('text' => t('Moderation'), 'sort' => 90));
 }