Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Added simplistic public profile functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdkleijn committed Nov 20, 2010
1 parent 62fa23a commit ff17ccd
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
13 changes: 13 additions & 0 deletions AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ public function index() {
));
}

public function profile($username) {
// Get profile information from other plugins.
foreach(Observer::getObserverList('account_display_profile') as $callback) {
self::$profile = array_merge(self::$profile, call_user_func_array($callback, array()));
}

$this->display(ACCOUNT_VIEWS.'/profile', array('settings' => Plugin::getAllSettings('account'),
'user' => User::findOneFrom('User', 'username=?', array($username)),
'profile' => self::$profile,
'actions' => self::$actions
));
}

public function password() {
$this->_checkLoggedIn();

Expand Down
16 changes: 15 additions & 1 deletion enable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,18 @@
);

Plugin::setAllSettings($settings, 'account');
}
}

$PDO = Record::getConnection();
$driver = strtolower($PDO->getAttribute(Record::ATTR_DRIVER_NAME));

// Setup table structure
if ($driver == 'mysql') {
$PDO->exec("CREATE TABLE ".TABLE_PREFIX."account_setting (
id int(11) unsigned NOT NULL auto_increment,
user_id int(11) unsigned NOT NULL,
name varchar(40) NOT NULL,
value varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8");
}
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'/'.$uri.'/' => '/plugin/account/index',
'/'.$uri.'/edit' => '/plugin/account/edit',
'/'.$uri.'/password' => '/plugin/account/password',
//'/'.$uri.'/:any/' => '/plugin/account/$1',
'/'.$uri.'/:any' => '/plugin/account/profile/$1',
'/'.$uri.'/:any/' => '/plugin/account/profile/$1',
//'/users' => '/plugin/account/list',
));
44 changes: 44 additions & 0 deletions views/profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/*
* Account plugin for Wolf CMS. <http://www.wolfcms.org>
* Copyright (C) 2010 Martijn van der Kleijn <martijn.niji@gmail.com>
*
* This file is part of the Account plugin for Wolf CMS.
*
* The Account plugin for Wolf CMS is made available under the terms of the GNU GPLv3 license.
* Please see <http://www.gnu.org/licenses/gpl.html> for full details.
*/

/**
* The Account plugin allows end users to view and manipulate their accounts.
*
* @package wolf
* @subpackage plugin.account
*
* @author Martijn van der Kleijn <martijn.niji@gmail.com>
* @version 1.0.0
* @since Wolf version 0.7.0
* @license http://www.gnu.org/licenses/gpl.html GPLv3 License
* @copyright Martijn van der Kleijn, 2010
*/
?>

<div id="account">
<h1><?php echo __('Public profile for :username', array(':username' => $user->username)); ?></h1>
<table>
<tr>
<td><?php echo __('Username'); ?></td>
<td><?php echo $user->username; ?></td>
</tr>
<tr>
<td><?php echo __('Full name'); ?></td>
<td><?php echo $user->name; ?></td>
</tr>
<?php foreach($profile as $entryName => $entryValue) { ?>
<tr>
<td><?php echo $entryName; ?></td>
<td><?php echo $entryValue; ?></td>
</tr>
<?php } ?>
</table>
</div>

0 comments on commit ff17ccd

Please sign in to comment.