public function run(&$params)
 {
     //
     //判断当前访问的url在不在这个数组中,如果在就直接访问
     $accessarr = array('Login/login', 'Login/logout');
     $requestURL = CONTROLLER_NAME . '/' . ACTION_NAME;
     if (in_array($requestURL, $accessarr)) {
         return;
     }
     //判断用户是否登录,如果未登录直接重定向到登录页面
     if (!islogin()) {
         $loginService = D('Login', 'Service');
         $loginService->autoLogin();
         redirect(U('Login/login'), 1, '请登陆!');
         exit;
     }
     //判断是否是超级管理员
     if (isSuperUser()) {
         return;
     }
     //最后在判断是否有访问某个控制器里方法的权限;
     $arr = userUrl();
     $arr = array_column($arr, 'url');
     if (!in_array($requestURL, $arr)) {
         echo "没有该权限";
         exit;
     }
 }
 /**
  * Build HTML.
  *
  * @return string HTML.
  */
 public function toString()
 {
     if ($this->_UserData->numRows() == 0) {
         return '';
     }
     $String = '';
     ob_start();
     ?>
     <div class="Box">
         <?php 
     echo panelHeading(t('In this Discussion'));
     ?>
         <ul class="PanelInfo">
             <?php 
     foreach ($this->_UserData->Result() as $User) {
         ?>
                 <li>
                     <?php 
         echo anchor(wrap(wrap(Gdn_Format::date($User->DateLastActive, 'html')), 'span', array('class' => 'Aside')) . ' ' . wrap(wrap(val('Name', $User), 'span', array('class' => 'Username')), 'span'), userUrl($User));
         ?>
                 </li>
             <?php 
     }
     ?>
         </ul>
     </div>
     <?php 
     $String = ob_get_contents();
     @ob_end_clean();
     return $String;
 }
 /**
  * @param $field
  * 得到用户权限对应的菜单项
  */
 private function getUserMenu()
 {
     $arr = userUrl();
     $arr = array_column($arr, 'id');
     $permission_id = implode(',', $arr);
     $sql = "select distinct m.id,m.name,m.url,m.level,m.parent_id from menu as m join menu_permission as mp on m.id=mp.menu_id where mp.permission_id in ({$permission_id})";
     return M()->query($sql);
 }
 /**
  *
  *
  * @param $Sender
  */
 public function profileController_afterAddSideMenu_handler($Sender)
 {
     if (!Gdn::session()->checkPermission('Garden.SignIn.Allow')) {
         return;
     }
     $SideMenu = $Sender->EventArguments['SideMenu'];
     $ViewingUserID = Gdn::session()->UserID;
     if ($Sender->User->UserID == $ViewingUserID) {
         $SideMenu->addLink('Options', sprite('SpQuote') . ' ' . t('Quote Settings'), '/profile/quotes', false, array('class' => 'Popup'));
     } else {
         $SideMenu->addLink('Options', sprite('SpQuote') . ' ' . t('Quote Settings'), userUrl($Sender->User, '', 'quotes'), 'Garden.Users.Edit', array('class' => 'Popup'));
     }
 }
 /**
  * 自动登录方法
  */
 public function autoLogin()
 {
     $arr = saveAutoLogin();
     if ($arr !== null) {
         $result = M('admin')->where($arr)->find();
         if ($result !== null) {
             $rows = $this->getUserPermissionUrls($result['id']);
             userUrl($rows);
             login($result);
             redirect(U(CONTROLLER_NAME . '/' . ACTION_NAME));
             exit;
         }
     }
 }
function connectButton($Row)
{
    $c = Gdn::controller();
    $Connected = val('Connected', $Row);
    $CssClass = $Connected ? 'Active' : 'InActive';
    $ConnectUrl = val('ConnectUrl', $Row);
    $DisconnectUrl = userUrl($c->User, '', 'Disconnect', array('provider' => $Row['ProviderKey']));
    $Result = '<span class="ActivateSlider ActivateSlider-' . $CssClass . '">';
    if ($Connected) {
        $Result .= anchor(t('Connected'), $DisconnectUrl, 'Button Primary Hijack ActivateSlider-Button');
    } else {
        $Result .= anchor(t('Connect'), $ConnectUrl, 'Button ActivateSlider-Button', array('target' => '_top'));
    }
    $Result .= '</span>';
    return $Result;
}
 /**
  * 显示登录页面和验证登录
  */
 public function login()
 {
     if (IS_POST) {
         $post = I("post.", '', false);
         //生成service文件夹中的工具类对象
         $loginService = D('Login', 'Service');
         $result = $loginService->verifyusr($post);
         if ($result !== false) {
             $rows = $loginService->getUserPermissionUrls($result['id']);
             //存储自动登录的信息
             if ($post['remember']) {
                 $loginService->saveAutoInfo($result['id']);
             }
             userUrl($rows);
             login($result);
             $this->success('登录成功', U('Index/index'), 1);
         } else {
             $this->error("登录失败");
         }
     } else {
         $this->display('login');
     }
 }
 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();
 }
        <h1><?php 
echo anchor(c('Garden.Title') . ' ' . Wrap(t('Visit Site')), '/');
?>
</h1>

        <div class="User">
            <?php 
$Session = Gdn::session();
if ($Session->isValid()) {
    $this->fireEvent('BeforeUserOptionsMenu');
    $Name = $Session->User->Name;
    $CountNotifications = $Session->User->CountNotifications;
    if (is_numeric($CountNotifications) && $CountNotifications > 0) {
        $Name .= wrap($CountNotifications);
    }
    echo anchor($Name, userUrl($Session->User), 'Profile');
    echo anchor(t('Sign Out'), SignOutUrl(), 'Leave');
}
?>
        </div>
    </div>
    <div id="Body">
        <div id="Panel">
            <?php 
$this->RenderAsset('Panel');
?>
        </div>
        <div id="Content"><?php 
$this->RenderAsset('Content');
?>
</div>
Exemple #10
0
    echo t('Thumbnail');
    ?>
</td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><?php 
    echo $Picture;
    if ($this->User->Photo != '' && $AllowImages && !$RemotePhoto) {
        echo wrap(Anchor(t('Remove Picture'), CombinePaths(array(userUrl($this->User, '', 'removepicture'), $Session->TransientKey())), 'Button Danger PopConfirm'), 'p');
        ?>
                        </td>
                        <td><?php 
        echo $Thumbnail;
        echo wrap(Anchor(t('Edit Thumbnail'), userUrl($this->User, '', 'thumbnail'), 'Button'), 'p');
    }
    ?>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </li>
        <?php 
}
?>
        <li>
            <p><?php 
echo t('Select an image on your computer (2mb max)');
?>
</p>
 /**
  *
  *
  * @param $WallPost
  */
 protected function notifyWallPost($WallPost)
 {
     $NotifyUser = Gdn::userModel()->getID($WallPost['ActivityUserID']);
     $Activity = array('ActivityType' => 'WallPost', 'ActivityUserID' => $WallPost['RegardingUserID'], 'Format' => $WallPost['Format'], 'NotifyUserID' => $WallPost['ActivityUserID'], 'RecordType' => 'Activity', 'RecordID' => $WallPost['ActivityID'], 'RegardingUserID' => $WallPost['ActivityUserID'], 'Route' => userUrl($NotifyUser, ''), 'Story' => $WallPost['Story'], 'HeadlineFormat' => t('HeadlineFormat.NotifyWallPost', '{ActivityUserID,User} posted on your <a href="{Url,url}">wall</a>.'));
     $this->save($Activity, 'WallComment');
 }
Exemple #12
0
 /**
  * Creates virtual 'Discussions' method in ProfileController.
  *
  * @since 2.0.0
  * @package Vanilla
  *
  * @param ProfileController $Sender ProfileController.
  */
 public function profileController_discussions_create($Sender, $UserReference = '', $Username = '', $Page = '', $UserID = '')
 {
     $Sender->editMode(false);
     // Tell the ProfileController what tab to load
     $Sender->getUserInfo($UserReference, $Username, $UserID);
     $Sender->_setBreadcrumbs(t('Discussions'), userUrl($Sender->User, '', 'discussions'));
     $Sender->setTabView('Discussions', 'Profile', 'Discussions', 'Vanilla');
     $Sender->CountCommentsPerPage = c('Vanilla.Comments.PerPage', 30);
     list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30));
     $DiscussionModel = new DiscussionModel();
     $Discussions = $DiscussionModel->getByUser($Sender->User->UserID, $Limit, $Offset, false, Gdn::session()->UserID);
     $CountDiscussions = $Offset + $DiscussionModel->LastDiscussionCount + 1;
     $Sender->DiscussionData = $Sender->setData('Discussions', $Discussions);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->getPager('MorePager', $Sender);
     $Sender->Pager->MoreCode = 'More Discussions';
     $Sender->Pager->LessCode = 'Newer Discussions';
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->configure($Offset, $Limit, $CountDiscussions, userUrl($Sender->User, '', 'discussions') . '?page={Page}');
     // Deliver JSON data if necessary
     if ($Sender->deliveryType() != DELIVERY_TYPE_ALL && $Offset > 0) {
         $Sender->setJson('LessRow', $Sender->Pager->toString('less'));
         $Sender->setJson('MoreRow', $Sender->Pager->toString('more'));
         $Sender->View = 'discussions';
     }
     // Set the HandlerType back to normal on the profilecontroller so that it fetches it's own views
     $Sender->HandlerType = HANDLER_TYPE_NORMAL;
     // Do not show discussion options
     $Sender->ShowOptions = false;
     if ($Sender->Head) {
         // These pages offer only duplicate content to search engines and are a bit slow.
         $Sender->Head->addTag('meta', array('name' => 'robots', 'content' => 'noindex,noarchive'));
     }
     // Render the ProfileController
     $Sender->render();
 }
Exemple #13
0
 /**
  * The ActivityType table has some special sprintf search/replace values in the
  * FullHeadline and ProfileHeadline fields. The ProfileHeadline field is to be
  * used on this page (the user profile page). The FullHeadline field is to be
  * used on the main activity page. The replacement definitions are as follows:
  *  %1$s = ActivityName
  *  %2$s = ActivityName Possessive
  *  %3$s = RegardingName
  *  %4$s = RegardingName Possessive
  *  %5$s = Link to RegardingName's Wall
  *  %6$s = his/her
  *  %7$s = he/she
  *  %8$s = route & routecode
  *  %9$s = gender suffix (some languages require this).
  *
  * @param object $Activity An object representation of the activity being formatted.
  * @param int $ProfileUserID If looking at a user profile, this is the UserID of the profile we are
  *  looking at.
  * @return string
  */
 public static function activityHeadline($Activity, $ProfileUserID = '', $ViewingUserID = '')
 {
     $Activity = (object) $Activity;
     if ($ViewingUserID == '') {
         $Session = Gdn::session();
         $ViewingUserID = $Session->isValid() ? $Session->UserID : -1;
     }
     $GenderSuffixCode = 'First';
     $GenderSuffixGender = $Activity->ActivityGender;
     if ($ViewingUserID == $Activity->ActivityUserID) {
         $ActivityName = $ActivityNameP = T('You');
     } else {
         $ActivityName = $Activity->ActivityName;
         $ActivityNameP = FormatPossessive($ActivityName);
         $GenderSuffixCode = 'Third';
     }
     if ($ProfileUserID != $Activity->ActivityUserID) {
         // If we're not looking at the activity user's profile, link the name
         $ActivityNameD = urlencode($Activity->ActivityName);
         $ActivityName = Anchor($ActivityName, UserUrl($Activity, 'Activity'));
         $ActivityNameP = Anchor($ActivityNameP, UserUrl($Activity, 'Activity'));
         $GenderSuffixCode = 'Third';
     }
     $Gender = t('their');
     //TODO: this isn't preferable but I don't know a better option
     $Gender2 = t('they');
     //TODO: this isn't preferable either
     if ($Activity->ActivityGender == 'm') {
         $Gender = t('his');
         $Gender2 = t('he');
     } elseif ($Activity->ActivityGender == 'f') {
         $Gender = t('her');
         $Gender2 = t('she');
     }
     if ($ViewingUserID == $Activity->RegardingUserID || $Activity->RegardingUserID == '' && $Activity->ActivityUserID == $ViewingUserID) {
         $Gender = $Gender2 = t('your');
     }
     $IsYou = false;
     if ($ViewingUserID == $Activity->RegardingUserID) {
         $IsYou = true;
         $RegardingName = t('you');
         $RegardingNameP = t('your');
         $GenderSuffixGender = $Activity->RegardingGender;
     } else {
         $RegardingName = $Activity->RegardingName == '' ? T('somebody') : $Activity->RegardingName;
         $RegardingNameP = formatPossessive($RegardingName);
         if ($Activity->ActivityUserID != $ViewingUserID) {
             $GenderSuffixCode = 'Third';
         }
     }
     $RegardingWall = '';
     $RegardingWallLink = '';
     if ($Activity->ActivityUserID == $Activity->RegardingUserID) {
         // If the activityuser and regardinguser are the same, use the $Gender Ref as the RegardingName
         $RegardingName = $RegardingProfile = $Gender;
         $RegardingNameP = $RegardingProfileP = $Gender;
     } elseif ($Activity->RegardingUserID > 0 && $ProfileUserID != $Activity->RegardingUserID) {
         // If there is a regarding user and we're not looking at his/her profile, link the name.
         $RegardingNameD = urlencode($Activity->RegardingName);
         if (!$IsYou) {
             $RegardingName = anchor($RegardingName, userUrl($Activity, 'Regarding'));
             $RegardingNameP = anchor($RegardingNameP, userUrl($Activity, 'Regarding'));
             $GenderSuffixCode = 'Third';
             $GenderSuffixGender = $Activity->RegardingGender;
         }
         $RegardingWallActivityPath = userUrl($Activity, 'Regarding');
         $RegardingWallLink = url($RegardingWallActivityPath);
         $RegardingWall = anchor(T('wall'), $RegardingWallActivityPath);
     }
     if ($RegardingWall == '') {
         $RegardingWall = t('wall');
     }
     if ($Activity->Route == '') {
         $ActivityRouteLink = '';
         if ($Activity->RouteCode) {
             $Route = t($Activity->RouteCode);
         } else {
             $Route = '';
         }
     } else {
         $ActivityRouteLink = url($Activity->Route);
         $Route = anchor(T($Activity->RouteCode), $Activity->Route);
     }
     // Translate the gender suffix.
     $GenderSuffixCode = "GenderSuffix.{$GenderSuffixCode}.{$GenderSuffixGender}";
     $GenderSuffix = t($GenderSuffixCode, '');
     if ($GenderSuffix == $GenderSuffixCode) {
         $GenderSuffix = '';
         // in case translate doesn't support empty strings.
     }
     /*
       Debug:
     return $ActivityName
     .'/'.$ActivityNameP
     .'/'.$RegardingName
     .'/'.$RegardingNameP
     .'/'.$RegardingWall
     .'/'.$Gender
     .'/'.$Gender2
     .'/'.$Route
     .'/'.$GenderSuffix.($GenderSuffixCode)
     */
     $FullHeadline = t("Activity.{$Activity->ActivityType}.FullHeadline", t($Activity->FullHeadline));
     $ProfileHeadline = t("Activity.{$Activity->ActivityType}.ProfileHeadline", t($Activity->ProfileHeadline));
     $MessageFormat = $ProfileUserID == $Activity->ActivityUserID || $ProfileUserID == '' || !$ProfileHeadline ? $FullHeadline : $ProfileHeadline;
     return sprintf($MessageFormat, $ActivityName, $ActivityNameP, $RegardingName, $RegardingNameP, $RegardingWall, $Gender, $Gender2, $Route, $GenderSuffix, $RegardingWallLink, $ActivityRouteLink);
 }
Exemple #14
0
 /**
  *
  *
  * @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));
 }
Exemple #15
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
$Alt = false;
$Session = Gdn::session();
$EditUser = $Session->checkPermission('Garden.Users.Edit');
$DeleteUser = $Session->checkPermission('Garden.Users.Delete');
$ViewPersonalInfo = $Session->checkPermission('Garden.PersonalInfo.View');
foreach ($this->UserData->result() as $User) {
    $Alt = !$Alt;
    $userBlock = new MediaItemModule(val('Name', $User), userUrl($User));
    $userBlock->setView('media-sm')->setImage(userPhotoUrl($User))->addMetaIf($ViewPersonalInfo, Gdn_Format::email($User->Email));
    ?>
    <tr id="<?php 
    echo "UserID_{$User->UserID}";
    ?>
"<?php 
    echo $Alt ? ' class="Alt"' : '';
    ?>
        data-userid="<?php 
    echo $User->UserID;
    ?>
">
        <!--      <td class="CheckboxCell"><input type="checkbox" name="LogID[]" value="<?php 
    echo $User->UserID;
    ?>
" /></td>-->
        <td>
            <?php 
Exemple #16
0
echo $this->Form->open(array('enctype' => 'multipart/form-data', 'class' => 'js-change-picture-form'));
echo $this->Form->errors();
if ($this->data('crop') && $allowImages) {
    echo $this->data('crop');
} else {
    ?>
    <div class="avatars">
        <div class="Padded current-avatar">
            <?php 
    echo img($this->data('avatar'), array('style' => 'width: ' . c('Garden.Thumbnail.Size') . 'px; height: ' . c('Garden.Thumbnail.Size') . 'px;'));
    ?>
        </div>
    </div>
<?php 
}
?>
<div class="DismissMessage WarningMessage"><?php 
echo t('By uploading a file you certify that you have the right to distribute this picture and that it does not violate the Terms of Service.');
?>
</div>
<div class="js-new-avatar Button change-picture-new" style="margin-bottom: 20px;"><?php 
echo t('Upload New Picture');
?>
</div>
<?php 
echo $this->Form->input('Avatar', 'file', array('class' => 'js-new-avatar-upload Hidden'));
if ($this->data('crop')) {
    echo anchor(t('Remove Picture'), userUrl($this->User, '', 'removepicture') . '?tk=' . Gdn::session()->TransientKey() . '&deliveryType=' . $this->deliveryType(), 'Button Danger PopConfirm change-picture-remove');
}
echo $this->Form->close();
echo '</div>';
 /**
  *
  *
  * @param $UserID
  * @throws Exception
  */
 public function deleteContent($UserID)
 {
     $this->permission('Garden.Moderation.Manage');
     $User = Gdn::userModel()->getID($UserID);
     if (!$User) {
         throw notFoundException('User');
     }
     if ($this->Form->authenticatedPostBack()) {
         Gdn::userModel()->deleteContent($UserID, array('Log' => true));
         if ($this->Request->get('Target')) {
             $this->RedirectUrl = url($this->Request->get('Target'));
         } else {
             $this->RedirectUrl = url(userUrl($User));
         }
     } else {
         $this->setData('Title', t('Are you sure you want to do this?'));
     }
     $this->setData('User', $User);
     $this->render();
 }
Exemple #18
0
 /**
  *
  *
  * @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'));
 }
 /**
  * Build the user profile.
  *
  * Set the page title, add data to page modules, add modules to assets,
  * add tabs to tab menu. $this->User must be defined, or this method will throw an exception.
  *
  * @since 2.0.0
  * @access public
  * @return bool Always true.
  */
 public function buildProfile()
 {
     if (!is_object($this->User)) {
         throw new Exception(t('Cannot build profile information if user is not defined.'));
     }
     $Session = Gdn::session();
     if (strpos($this->CssClass, 'Profile') === false) {
         $this->CssClass .= ' Profile';
     }
     $this->title(Gdn_Format::text($this->User->Name));
     if ($this->_DeliveryType != DELIVERY_TYPE_VIEW) {
         // Javascript needed
         // see note above about jcrop
         $this->addJsFile('jquery.jcrop.min.js');
         $this->addJsFile('profile.js');
         $this->addJsFile('jquery.gardenmorepager.js');
         $this->addJsFile('activity.js');
         // Build activity URL
         $ActivityUrl = 'profile/activity/';
         if ($this->User->UserID != $Session->UserID) {
             $ActivityUrl = userUrl($this->User, '', 'activity');
         }
         // Show activity?
         if (c('Garden.Profile.ShowActivities', true)) {
             $this->addProfileTab(t('Activity'), $ActivityUrl, 'Activity', sprite('SpActivity') . ' ' . t('Activity'));
         }
         // Show notifications?
         if ($this->User->UserID == $Session->UserID) {
             $Notifications = t('Notifications');
             $NotificationsHtml = sprite('SpNotifications') . ' ' . $Notifications;
             $CountNotifications = $Session->User->CountNotifications;
             if (is_numeric($CountNotifications) && $CountNotifications > 0) {
                 $NotificationsHtml .= ' <span class="Aside"><span class="Count">' . $CountNotifications . '</span></span>';
             }
             $this->addProfileTab($Notifications, 'profile/notifications', 'Notifications', $NotificationsHtml);
         }
         // Show invitations?
         if (c('Garden.Registration.Method') == 'Invitation') {
             $this->addProfileTab(t('Invitations'), 'profile/invitations', 'InvitationsLink', sprite('SpInvitations') . ' ' . t('Invitations'));
         }
         $this->fireEvent('AddProfileTabs');
     }
     return true;
 }
 /**
  * Pre-process content into a uniform format for output
  *
  * @param Array $content By reference
  */
 protected function processContent(&$content)
 {
     foreach ($content as &$item) {
         $contentType = val('RecordType', $item);
         $userID = val('InsertUserID', $item);
         $itemProperties = array();
         $itemFields = array('DiscussionID', 'DateInserted', 'DateUpdated', 'Body', 'Format', 'RecordType', 'Url', 'CategoryID', 'CategoryName', 'CategoryUrl');
         switch (strtolower($contentType)) {
             case 'comment':
                 $itemFields = array_merge($itemFields, array('CommentID'));
                 // Comment specific
                 $itemProperties['Name'] = sprintf(t('Re: %s'), valr('Discussion.Name', $item, val('Name', $item)));
                 $url = CommentUrl($item);
                 break;
             case 'discussion':
                 $itemFields = array_merge($itemFields, array('Name', 'Type'));
                 $url = DiscussionUrl($item);
                 break;
         }
         $item['Url'] = $url;
         if ($categoryId = val('CategoryID', $item)) {
             $category = CategoryModel::categories($categoryId);
             $item['CategoryName'] = val('Name', $category);
             $item['CategoryUrl'] = CategoryUrl($category);
         }
         $itemFields = array_fill_keys($itemFields, true);
         $filteredItem = array_intersect_key($item, $itemFields);
         $itemProperties = array_merge($itemProperties, $filteredItem);
         $item = $itemProperties;
         // Attach User
         $userFields = array('UserID', 'Name', 'Title', 'Location', 'PhotoUrl', 'RankName', 'Url', 'Roles', 'RoleNames');
         $user = Gdn::userModel()->getID($userID);
         $roleModel = new RoleModel();
         $roles = $roleModel->GetByUserID($userID)->resultArray();
         $roleNames = '';
         foreach ($roles as $role) {
             $roleNames[] = val('Name', $role);
         }
         // check
         $rankName = null;
         if (class_exists('RankModel')) {
             $rankName = val('Name', RankModel::Ranks(val('RankID', $user)), null);
         }
         $userProperties = array('Url' => url(userUrl($user), true), 'PhotoUrl' => UserPhotoUrl($user), 'RankName' => $rankName, 'RoleNames' => $roleNames, 'CssClass' => val('_CssClass', $user));
         $user = (array) $user;
         $userFields = array_fill_keys($userFields, true);
         $filteredUser = array_intersect_key($user, $userFields);
         $userProperties = array_merge($filteredUser, $userProperties);
         $item['Author'] = $userProperties;
     }
 }
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="Box InThisConversation">
    <?php 
echo panelHeading(t('In this Conversation'));
?>
    <ul class="PanelInfo">
        <?php 
foreach ($this->Data->result() as $User) {
    ?>
            <li>
                <?php 
    $Username = htmlspecialchars(val('Name', $User));
    $Photo = val('Photo', $User);
    if (val('Deleted', $User)) {
        echo anchor(wrap(($Photo ? img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall')) : '') . ' ' . wrap($Username, 'del', array('class' => 'Username')), 'span', array('class' => 'Conversation-User')), userUrl($User), array('title' => sprintf(t('%s has left this conversation.'), $Username)));
    } else {
        echo anchor(wrap(($Photo ? img($Photo, array('class' => 'ProfilePhoto ProfilePhotoSmall')) : '') . ' ' . wrap($Username, 'span', array('class' => 'Username')), 'span', array('class' => 'Conversation-User')), userUrl($User));
    }
    ?>
            </li>
        <?php 
}
?>
    </ul>
</div>
Exemple #22
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
echo '<div class="DataListWrap">';
echo '<h4 class="H discussions-label">' . t('New Activity') . '</h4>';
$Session = Gdn::session();
if ($Session->isValid() && checkPermission('Garden.Profiles.Edit')) {
    $this->fireEvent('BeforeStatusForm');
    $ButtonText = $Session->UserID == $this->User->UserID ? 'Share' : 'Add Comment';
    echo '<div class="FormWrapper FormWrapper-Condensed">';
    echo $this->Form->open(array('action' => url("/activity/post/{$this->User->UserID}?Target=" . urlencode(userUrl($this->User))), 'class' => 'Activity'));
    echo $this->Form->errors();
    echo $this->Form->bodyBox('Comment', array('Wrap' => TRUE));
    echo '<div class="Buttons">';
    echo $this->Form->button($ButtonText, array('class' => 'Button Primary'));
    echo '</div>';
    echo $this->Form->close();
    echo '</div>';
}
// Include the activities
include $this->fetchViewLocation('index', 'activity', 'dashboard');
echo '</div>';
Exemple #23
0
 /**
  * The callback helper for {@link formatString()}.
  *
  * @param array $Match Either the array of arguments or the regular expression match.
  * @param bool $SetArgs Whether this is a call to initialize the arguments or a matching callback.
  * @return mixed Returns the matching string or nothing when setting the arguments.
  * @access private
  */
 function _formatStringCallback($Match, $SetArgs = false)
 {
     static $Args = array(), $ContextUserID = null;
     if ($SetArgs) {
         $Args = $Match;
         if (isset($Args['_ContextUserID'])) {
             $ContextUserID = $Args['_ContextUserID'];
         } else {
             $ContextUserID = Gdn::session() && Gdn::session()->isValid() ? Gdn::session()->UserID : null;
         }
         return '';
     }
     $Match = $Match[1];
     if ($Match == '{') {
         return $Match;
     }
     // Parse out the field and format.
     $Parts = explode(',', $Match);
     $Field = trim($Parts[0]);
     $Format = trim(val(1, $Parts, ''));
     $SubFormat = strtolower(trim(val(2, $Parts, '')));
     $FormatArgs = val(3, $Parts, '');
     if (in_array($Format, array('currency', 'integer', 'percent'))) {
         $FormatArgs = $SubFormat;
         $SubFormat = $Format;
         $Format = 'number';
     } elseif (is_numeric($SubFormat)) {
         $FormatArgs = $SubFormat;
         $SubFormat = '';
     }
     $Value = valr($Field, $Args, null);
     if ($Value === null && !in_array($Format, array('url', 'exurl', 'number', 'plural'))) {
         $Result = '';
     } else {
         switch (strtolower($Format)) {
             case 'date':
                 switch ($SubFormat) {
                     case 'short':
                         $Result = Gdn_Format::date($Value, '%d/%m/%Y');
                         break;
                     case 'medium':
                         $Result = Gdn_Format::date($Value, '%e %b %Y');
                         break;
                     case 'long':
                         $Result = Gdn_Format::date($Value, '%e %B %Y');
                         break;
                     default:
                         $Result = Gdn_Format::date($Value);
                         break;
                 }
                 break;
             case 'html':
             case 'htmlspecialchars':
                 $Result = htmlspecialchars($Value);
                 break;
             case 'number':
                 if (!is_numeric($Value)) {
                     $Result = $Value;
                 } else {
                     switch ($SubFormat) {
                         case 'currency':
                             $Result = '$' . number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 2);
                             break;
                         case 'integer':
                             $Result = (string) round($Value);
                             if (is_numeric($FormatArgs) && strlen($Result) < $FormatArgs) {
                                 $Result = str_repeat('0', $FormatArgs - strlen($Result)) . $Result;
                             }
                             break;
                         case 'percent':
                             $Result = round($Value * 100, is_numeric($FormatArgs) ? $FormatArgs : 0);
                             break;
                         default:
                             $Result = number_format($Value, is_numeric($FormatArgs) ? $FormatArgs : 0);
                             break;
                     }
                 }
                 break;
             case 'plural':
                 if (is_array($Value)) {
                     $Value = count($Value);
                 } elseif (StringEndsWith($Field, 'UserID', true)) {
                     $Value = 1;
                 }
                 if (!is_numeric($Value)) {
                     $Result = $Value;
                 } else {
                     if (!$SubFormat) {
                         $SubFormat = rtrim("%s {$Field}", 's');
                     }
                     if (!$FormatArgs) {
                         $FormatArgs = $SubFormat . 's';
                     }
                     $Result = Plural($Value, $SubFormat, $FormatArgs);
                 }
                 break;
             case 'rawurlencode':
                 $Result = rawurlencode($Value);
                 break;
             case 'text':
                 $Result = Gdn_Format::text($Value, false);
                 break;
             case 'time':
                 $Result = Gdn_Format::date($Value, '%l:%M%p');
                 break;
             case 'url':
                 if (strpos($Field, '/') !== false) {
                     $Value = $Field;
                 }
                 $Result = Url($Value, $SubFormat == 'domain');
                 break;
             case 'exurl':
                 if (strpos($Field, '/') !== false) {
                     $Value = $Field;
                 }
                 $Result = externalUrl($Value);
                 break;
             case 'urlencode':
                 $Result = urlencode($Value);
                 break;
             case 'gender':
                 // Format in the form of FieldName,gender,male,female,unknown[,plural]
                 if (is_array($Value) && count($Value) == 1) {
                     $Value = array_shift($Value);
                 }
                 $Gender = 'u';
                 if (!is_array($Value)) {
                     $User = Gdn::userModel()->getID($Value);
                     if ($User) {
                         $Gender = $User->Gender;
                     }
                 } else {
                     $Gender = 'p';
                 }
                 switch ($Gender) {
                     case 'm':
                         $Result = $SubFormat;
                         break;
                     case 'f':
                         $Result = $FormatArgs;
                         break;
                     case 'p':
                         $Result = val(5, $Parts, val(4, $Parts));
                         break;
                     case 'u':
                     default:
                         $Result = val(4, $Parts);
                 }
                 break;
             case 'user':
             case 'you':
             case 'his':
             case 'her':
             case 'your':
                 //                    $Result = print_r($Value, true);
                 $ArgsBak = $Args;
                 if (is_array($Value) && count($Value) == 1) {
                     $Value = array_shift($Value);
                 }
                 if (is_array($Value)) {
                     if (isset($Value['UserID'])) {
                         $User = $Value;
                         $User['Name'] = formatUsername($User, $Format, $ContextUserID);
                         $Result = userAnchor($User);
                     } else {
                         $Max = c('Garden.FormatUsername.Max', 5);
                         // See if there is another count.
                         $ExtraCount = valr($Field . '_Count', $Args, 0);
                         $Count = count($Value);
                         $Result = '';
                         for ($i = 0; $i < $Count; $i++) {
                             if ($i >= $Max && $Count > $Max + 1) {
                                 $Others = $Count - $i + $ExtraCount;
                                 $Result .= ' ' . t('sep and', 'and') . ' ' . plural($Others, '%s other', '%s others');
                                 break;
                             }
                             $ID = $Value[$i];
                             if (is_array($ID)) {
                                 continue;
                             }
                             if ($i == $Count - 1) {
                                 $Result .= ' ' . T('sep and', 'and') . ' ';
                             } elseif ($i > 0) {
                                 $Result .= ', ';
                             }
                             $Special = array(-1 => T('everyone'), -2 => T('moderators'), -3 => T('administrators'));
                             if (isset($Special[$ID])) {
                                 $Result .= $Special[$ID];
                             } else {
                                 $User = Gdn::userModel()->getID($ID);
                                 if ($User) {
                                     $User->Name = formatUsername($User, $Format, $ContextUserID);
                                     $Result .= userAnchor($User);
                                 }
                             }
                         }
                     }
                 } else {
                     $User = Gdn::userModel()->getID($Value);
                     if ($User) {
                         // Store this name separately because of special 'You' case.
                         $Name = formatUsername($User, $Format, $ContextUserID);
                         // Manually build instead of using userAnchor() because of special 'You' case.
                         $Result = anchor(htmlspecialchars($Name), userUrl($User));
                     } else {
                         $Result = '';
                     }
                 }
                 $Args = $ArgsBak;
                 break;
             default:
                 $Result = $Value;
                 break;
         }
     }
     return $Result;
 }
 /**
  *
  *
  * @param EntryController $Sender
  * @param string $Code
  * @param string $State
  * @throws Gdn_UserException
  */
 public function entryController_googlePlus_create($Sender, $Code = false, $State = false)
 {
     if ($Error = $Sender->Request->get('error')) {
         throw new Gdn_UserException($Error);
     }
     // Get an access token.
     Gdn::session()->stash(self::ProviderKey);
     // remove any old google plus.
     $AccessToken = $this->getAccessToken($Code);
     $this->accessToken($AccessToken);
     // Get the user's information.
     $Profile = $this->api('/userinfo');
     if ($State) {
         parse_str($State, $State);
     } else {
         $State = array('r' => 'entry', 'uid' => null);
     }
     switch ($State['r']) {
         case 'profile':
             // This is a connect request from the user's profile.
             $User = Gdn::userModel()->getID($State['uid']);
             if (!$User) {
                 throw notFoundException('User');
             }
             // Save the authentication.
             Gdn::userModel()->saveAuthentication(array('UserID' => $User->UserID, 'Provider' => self::ProviderKey, 'UniqueID' => $Profile['id']));
             // Save the information as attributes.
             $Attributes = array('AccessToken' => $AccessToken, 'Profile' => $Profile);
             Gdn::userModel()->saveAttribute($User->UserID, self::ProviderKey, $Attributes);
             $this->EventArguments['Provider'] = self::ProviderKey;
             $this->EventArguments['User'] = $Sender->User;
             $this->fireEvent('AfterConnection');
             redirect(userUrl($User, '', 'connections'));
             break;
         case 'entry':
         default:
             // This is an sso request, we need to redispatch to /entry/connect/googleplus
             Gdn::session()->stash(self::ProviderKey, array('AccessToken' => $AccessToken, 'Profile' => $Profile));
             $url = '/entry/connect/googleplus';
             if ($target = val('target', $State)) {
                 $url .= '?Target=' . urlencode($target);
             }
             redirect($url);
             break;
     }
 }
</title>
        <link><?php 
    echo url(userUrl($Author, '', 'activity'), true);
    ?>
</link>
        <pubDate><?php 
    echo date('r', Gdn_Format::ToTimeStamp(val('DateUpdated', $Activity)));
    ?>
</pubDate>
        <dc:creator><?php 
    echo Gdn_Format::text($Author->Name);
    ?>
</dc:creator>
        <guid
            isPermaLink="false"><?php 
    echo val('ActivityID', $Activity) . '@' . Url(userUrl($Author, '', 'activity'));
    ?>
</guid>
        <?php 
    if ($Story = val('Story', $Activity)) {
        ?>
            <description><![CDATA[<?php 
        echo Gdn_Format::RssHtml($Story, val('Format', $Activity));
        ?>
]]>
            </description>
        <?php 
    }
    ?>
    </item>
<?php 
Exemple #26
0
 /**
  * Create a controller to handle entry request.
  *
  * @param Gdn_Controller $sender.
  * @param $code string Retrieved from the response of the authentication provider, used to fetch an authentication token.
  * @param $state string Values passed by us and returned in the response of the authentication provider.
  *
  * @throws Exception.
  * @throws Gdn_UserException.
  */
 public function entryEndpoint($sender, $code, $state)
 {
     if ($error = $sender->Request->get('error')) {
         throw new Gdn_UserException($error);
     }
     Gdn::session()->stash($this->getProviderKey());
     // remove any stashed provider data.
     $response = $this->requestAccessToken($code);
     if (!$response) {
         throw new Gdn_UserException('The OAuth server did not return a valid response.');
     }
     if (!empty($response['error'])) {
         throw new Gdn_UserException($response['error_description']);
     } elseif (empty($response['access_token'])) {
         throw new Gdn_UserException('The OAuth server did not return an access token.', 400);
     } else {
         $this->accessToken($response['access_token']);
     }
     $this->log('Getting Profile', []);
     $profile = $this->getProfile();
     $this->log('Profile', $profile);
     if ($state) {
         parse_str($state, $state);
     } else {
         $state = ['r' => 'entry', 'uid' => null, 'd' => 'none'];
     }
     switch ($state['r']) {
         case 'profile':
             // This is a connect request from the user's profile.
             $user = Gdn::userModel()->getID($state['uid']);
             if (!$user) {
                 throw notFoundException('User');
             }
             // Save the authentication.
             Gdn::userModel()->saveAuthentication(['UserID' => $user->UserID, 'Provider' => $this->getProviderKey(), 'UniqueID' => $profile['id']]);
             // Save the information as attributes.
             $attributes = ['AccessToken' => $response['access_token'], 'Profile' => $profile];
             Gdn::userModel()->saveAttribute($user->UserID, $this->getProviderKey(), $attributes);
             $sender->EventArguments['Provider'] = $this->getProviderKey();
             $sender->EventArguments['User'] = $sender->User;
             $sender->fireEvent('AfterConnection');
             redirect(userUrl($user, '', 'connections'));
             break;
         case 'entry':
         default:
             // This is an sso request, we need to redispatch to /entry/connect/[providerKey] which is Base_ConnectData_Handler() in this class.
             Gdn::session()->stash($this->getProviderKey(), ['AccessToken' => $response['access_token'], 'Profile' => $profile]);
             $url = '/entry/connect/' . $this->getProviderKey();
             //pass the target if there is one so that the user will be redirected to where the request originated.
             if ($target = val('target', $state)) {
                 $url .= '?Target=' . urlencode($target);
             }
             redirect($url);
             break;
     }
 }
 /**
  *
  *
  * @return string
  */
 public static function profileConnecUrl()
 {
     return url(userUrl(Gdn::session()->User, false, 'facebookconnect'), true);
 }
Exemple #28
0
} else {
    $ApplicantCount = null;
}
$this->EventArguments['DashboardCount'] =& $DashboardCount;
$this->fireEvent('BeforeFlyoutMenu');
if ($Session->isValid()) {
    echo '<div class="MeBox' . $CssClass . '">';
    echo userPhoto($User);
    echo '<div class="WhoIs">';
    echo userAnchor($User, 'Username');
    echo '<div class="MeMenu">';
    // Notifications
    $CountNotifications = $User->CountNotifications;
    $CNotifications = is_numeric($CountNotifications) && $CountNotifications > 0 ? '<span class="Alert NotificationsAlert">' . $CountNotifications . '</span>' : '';
    echo '<span class="ToggleFlyout" rel="/profile/notificationspopin">';
    echo anchor(sprite('SpNotifications', 'Sprite Sprite16') . Wrap(t('Notifications'), 'em') . $CNotifications, userUrl($User), 'MeButton FlyoutButton js-clear-notifications', array('title' => t('Notifications')));
    echo sprite('SpFlyoutHandle', 'Arrow');
    echo '<div class="Flyout FlyoutMenu"></div></span>';
    // Inbox
    if (Gdn::ApplicationManager()->CheckApplication('Conversations')) {
        $CountInbox = val('CountUnreadConversations', Gdn::session()->User);
        $CInbox = is_numeric($CountInbox) && $CountInbox > 0 ? ' <span class="Alert">' . $CountInbox . '</span>' : '';
        echo '<span class="ToggleFlyout" rel="/messages/popin">';
        echo anchor(sprite('SpInbox', 'Sprite Sprite16') . Wrap(t('Inbox'), 'em') . $CInbox, '/messages/all', 'MeButton FlyoutButton', array('title' => t('Inbox')));
        echo sprite('SpFlyoutHandle', 'Arrow');
        echo '<div class="Flyout FlyoutMenu"></div></span>';
    }
    // Bookmarks
    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')));
 /**
  * Takes a user object, and writes out an anchor of the user's icon to the user's profile.
  *
  * @param object|array $User A user object or array.
  * @param array $Options
  */
 function userPhoto($User, $Options = array())
 {
     if (is_string($Options)) {
         $Options = array('LinkClass' => $Options);
     }
     if ($Px = val('Px', $Options)) {
         $User = userBuilder($User, $Px);
     } else {
         $User = (object) $User;
     }
     $LinkClass = concatSep(' ', val('LinkClass', $Options, ''), 'PhotoWrap');
     $ImgClass = val('ImageClass', $Options, 'ProfilePhoto');
     $Size = val('Size', $Options);
     if ($Size) {
         $LinkClass .= " PhotoWrap{$Size}";
         $ImgClass .= " {$ImgClass}{$Size}";
     } else {
         $ImgClass .= " {$ImgClass}Medium";
         // backwards compat
     }
     $FullUser = Gdn::userModel()->getID(val('UserID', $User), DATASET_TYPE_ARRAY);
     $UserCssClass = val('_CssClass', $FullUser);
     if ($UserCssClass) {
         $LinkClass .= ' ' . $UserCssClass;
     }
     $LinkClass = $LinkClass == '' ? '' : ' class="' . $LinkClass . '"';
     $Photo = val('Photo', $User, val('PhotoUrl', $User));
     $Name = val('Name', $User);
     $Title = htmlspecialchars(val('Title', $Options, $Name));
     $Href = url(userUrl($User));
     if ($FullUser && $FullUser['Banned']) {
         $Photo = c('Garden.BannedPhoto', 'https://c3409409.ssl.cf0.rackcdn.com/images/banned_large.png');
         $Title .= ' (' . t('Banned') . ')';
     }
     if ($Photo) {
         if (!isUrl($Photo)) {
             $PhotoUrl = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
         } else {
             $PhotoUrl = $Photo;
         }
     } else {
         $PhotoUrl = UserModel::getDefaultAvatarUrl($User, 'thumbnail');
     }
     return '<a title="' . $Title . '" href="' . $Href . '"' . $LinkClass . '>' . img($PhotoUrl, array('alt' => $Name, 'class' => $ImgClass)) . '</a>';
 }
Exemple #30
0
// TODO: Pull this asset out elsewhere
Gdn_Theme::assetBegin('DashboardUserDropDown');
$user = Gdn::session()->User;
$rm = new RoleModel();
$roles = $rm->getByUserID(val('UserID', $user))->resultArray();
$roleTitlesArray = [];
foreach ($roles as $role) {
    $roleTitlesArray[] = val('Name', $role);
}
$roleTitles = implode(', ', $roleTitlesArray);
/** var UserController $user */
?>
<div class="card card-user">
    <?php 
$userBlock = new MediaItemModule(val('Name', $user), userUrl($user), $roleTitles, '', ['class' => 'card-block']);
$userBlock->setView('media-sm')->setImage(userPhotoUrl($user))->addButton(t('My Profile') . ' ' . dashboardSymbol('external-link', 'icon-11 icon-text'), userUrl($user), ['class' => 'btn btn-sm-rounded btn-secondary padded-top']);
echo $userBlock;
?>
    <div class="list-group list-group-flush">
        <?php 
foreach ($this->data('meList', []) as $meItem) {
    echo anchor(t($meItem['text']) . (val('isExternal', $meItem, true) ? ' ' . dashboardSymbol('external-link') : ''), $meItem['url'], 'list-group-item', ['target' => '_blank']);
}
?>
    </div>
    <div class="card-footer">
        <?php 
echo anchor(t('Sign Out'), signOutUrl(), 'btn btn-secondary Leave');
?>
    </div>
</div>