Skip to content

Commit 732f238

Browse files
committed
Add buttons to profile viewer
1 parent 28cf4f6 commit 732f238

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/controllers/User/View.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */
22
namespace BNETDocs\Controllers\User;
33

4+
use \BNETDocs\Libraries\Authentication;
45
use \BNETDocs\Libraries\Credits;
56
use \BNETDocs\Libraries\Document;
67
use \BNETDocs\Libraries\Exceptions\UserNotFoundException;
@@ -20,6 +21,7 @@ class View extends Controller
2021
public function &run(Router &$router, ViewLib &$view, array &$args)
2122
{
2223
$model = new UserViewModel();
24+
$model->active_user = Authentication::$user;
2325
$model->user_id = array_shift($args);
2426

2527
$this->getUserInfo($model);

src/models/ActiveUser.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
<?php
2-
namespace BNETDocs\Models;
3-
use \CarlBennett\MVC\Libraries\Model;
4-
class ActiveUser extends Model
1+
<?php namespace BNETDocs\Models;
2+
class ActiveUser extends \CarlBennett\MVC\Libraries\Model
53
{
64
public $active_user;
75
}

src/models/User/View.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php namespace BNETDocs\Models\User;
2-
class View extends \CarlBennett\MVC\Libraries\Model
2+
class View extends \BNETDocs\Models\ActiveUser
33
{
44
public $contributions;
55
public $documents;

src/templates/User/View.phtml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace BNETDocs\Templates\User;
33
use \BNETDocs\Libraries\Document;
44
use \CarlBennett\MVC\Libraries\Common;
55
use \CarlBennett\MVC\Libraries\Pair;
6+
$active_user = $this->getContext()->active_user;
67
$contributions = $this->getContext()->contributions;
78
$documents = $this->getContext()->documents;
89
$news_posts = $this->getContext()->news_posts;
@@ -60,8 +61,12 @@ $this->opengraph->attach(new Pair('url', $url));
6061
require('./header.inc.phtml'); ?>
6162
<div class="container mb-3">
6263
<span class="float-right">
63-
<a class="btn btn-sm btn-primary" href="https://twitter.com/share?text=<?=urlencode($title)?>&amp;url=<?=urlencode($url)?>" rel="external" data-popup="1"><img class="img-fluid" src="<?=Common::relativeUrlToAbsolute('/a/social-twitter-24px.png')?>"/></a>
64+
<? if ($active_user && $user && $active_user->getId() == $user->getId()) { ?>
65+
<a class="btn btn-sm btn-secondary" href="<?=Common::relativeUrlToAbsolute('/user/update')?>" title="Update Profile">📝 Update Profile</a>
66+
<a class="btn btn-sm btn-secondary" href="<?=Common::relativeUrlToAbsolute('/user/changepassword')?>" title="Change Password">🔑 Change Password</a>
67+
<? } ?>
6468
<a class="btn btn-sm btn-primary" href="https://facebook.com/sharer/sharer.php?u=<?=urlencode($url)?>" rel="external" data-popup="1"><img class="img-fluid" src="<?=Common::relativeUrlToAbsolute('/a/social-facebook-24px.png')?>"/></a>
69+
<a class="btn btn-sm btn-primary" href="https://twitter.com/share?text=<?=urlencode($title)?>&amp;url=<?=urlencode($url)?>" rel="external" data-popup="1"><img class="img-fluid" src="<?=Common::relativeUrlToAbsolute('/a/social-twitter-24px.png')?>"/></a>
6570
</span>
6671
<? if ($user) { ?>
6772
<h1>User Profile</h1>

0 commit comments

Comments
 (0)