summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-05 01:22:27 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-05 01:22:27 -0400
commit570901ba4e526be37afd0cbbe018cb0500a7cda1 (patch)
tree81f13e66cfd795141cac216fd2af610e877a1a31
parentad4a7ff9159c2c64cea98d7189f46fa7d6174fc2 (diff)
Refactor a bit
* move a lot of stuff out of MessageManager * move models from lib to models
-rw-r--r--conf-contacts.php (renamed from plugin-conf.php)0
-rw-r--r--index.php4
-rw-r--r--src/controllers/AuthPage.class.php1
-rw-r--r--src/controllers/Messages.class.php9
-rw-r--r--src/controllers/Plugins.class.php6
-rw-r--r--src/controllers/Users.class.php82
-rw-r--r--src/lib/Database.class.php4
-rw-r--r--src/lib/Login.class.php2
-rw-r--r--src/lib/MessageHandler.class.php49
-rw-r--r--src/lib/MessageManager.class.php14
-rw-r--r--src/lib/Model.class.php3
-rw-r--r--src/lib/PluginManager.class.php16
-rw-r--r--src/lib/SenderBroadcast.class.php7
-rw-r--r--src/lib/SenderPrivate.class.php7
-rw-r--r--src/models/Auth.class.php (renamed from src/lib/Auth.class.php)52
-rw-r--r--src/models/ContactMethod.class.php (renamed from src/lib/ContactMethod.class.php)0
-rw-r--r--src/models/Group.class.php (renamed from src/lib/Group.class.php)4
-rw-r--r--src/models/User.class.php (renamed from src/lib/User.class.php)2
-rw-r--r--src/plugins/InformationPlugin.class.php2
-rw-r--r--src/plugins/SenderGVSMS.class.php5
-rw-r--r--src/plugins/SenderIdentica.class.php5
-rw-r--r--src/views/Template.class.php12
-rw-r--r--src/views/pages/plugins/index.html.php2
-rw-r--r--src/views/pages/users/500.html.php3
24 files changed, 122 insertions, 169 deletions
diff --git a/plugin-conf.php b/conf-contacts.php
index 7b397cc..7b397cc 100644
--- a/plugin-conf.php
+++ b/conf-contacts.php
diff --git a/index.php b/index.php
index ceab3f3..1148b1d 100644
--- a/index.php
+++ b/index.php
@@ -37,12 +37,12 @@ define('PAGE', $PAGE); unset($PAGE);
define('PAGE_EXT', $EXT); unset($EXT);
// Get ready
-require_once('Model.class.php');
+//require_once('Model.class.php');
require_once('Controller.class.php');
require_once('Router.class.php');
require_once('ContactMethod.class.php');
-require('plugin-conf.php');
+require('conf-contacts.php');
global $mm;
require_once('MessageManager.class.php');
diff --git a/src/controllers/AuthPage.class.php b/src/controllers/AuthPage.class.php
index 127bc1f..b31d938 100644
--- a/src/controllers/AuthPage.class.php
+++ b/src/controllers/AuthPage.class.php
@@ -1,4 +1,5 @@
<?php
+require_once('Login.class.php');
Router::register('auth', 'AuthPage');
diff --git a/src/controllers/Messages.class.php b/src/controllers/Messages.class.php
index 86403ae..d28d968 100644
--- a/src/controllers/Messages.class.php
+++ b/src/controllers/Messages.class.php
@@ -1,4 +1,5 @@
<?php
+require_once('Login.class.php');
Router::register('messages', 'Messages', 'index');
Router::register('messages/index', 'Messages', 'index');
@@ -39,9 +40,8 @@ class Messages extends Controller {
}
public function message($routed, $remainder) {
- global $mm;
- $uid = $mm->isLoggedIn();
- if ($uid===false || !$mm->getAuthObj($uid)->isUser()) {
+ $uid = Login::isLoggedIn();
+ if ($uid===false || !Auth::getObj($uid)->isUser()) {
$this->http401($routed, $remainder);
return;
}
@@ -94,7 +94,6 @@ class Messages extends Controller {
}
public function http401($routed, $remainder) {
- global $mm;
- $this->showView('messages/401', array('uid'=>$mm->isLoggedIn()));
+ $this->showView('messages/401', array('uid'=>Login::isLoggedIn()));
}
} \ No newline at end of file
diff --git a/src/controllers/Plugins.class.php b/src/controllers/Plugins.class.php
index 597cd19..40d3fc0 100644
--- a/src/controllers/Plugins.class.php
+++ b/src/controllers/Plugins.class.php
@@ -1,12 +1,12 @@
<?php
+require_once('Login.class.php');
Router::register('plugins', 'Plugins');
class Plugins extends Controller {
public function index($routed, $remainder) {
- global $mm;
- $uid = $mm->isLoggedIn();
- if ($uid===false || !$m->getAuthObj($uid)->isAdim()) {
+ $uid = Login::isLoggedIn();
+ if ($uid===false || !Auth::getObj($uid)->isAdmin()) {
$this->http401($routed, $remainder);
return;
}
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index 9781ab0..9674907 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -1,4 +1,6 @@
<?php
+require_once('Login.class.php');
+require_once('Auth.class.php');
Router::register('users/new' , 'Users', 'new_user');
Router::register('users/index', 'Users', 'index_file');
@@ -7,18 +9,9 @@ Router::register('users/*' , 'Users', 'individual');
class Users extends Controller {
public static $illegal_names = array('', 'new', 'index');
-
- /**
- * Handle GETing the new user form.
- *
- * I would have named this `new', but that's a keyword.
- */
- public function new_user($routed, $vars) {
- // since there will never be a remainder to `users/new', we can
- // use that parameter to pass in some data.
- $this->showView('users/new', $vars);
- }
-
+
+ // Index Views ///////////////////////////////////////////////
+
public function index($routed, $remainder) {
return $this->index_dir($routed, $remainder);
}
@@ -56,18 +49,32 @@ class Users extends Controller {
$this->show_index($routed, $remainder);
}
+ // Other Views ///////////////////////////////////////////////
+ /**
+ * Handle GETing the new user form.
+ *
+ * I would have named this `new', but that's a keyword.
+ */
+ public function new_user($routed, $vars) {
+ // since there will never be a remainder to `users/new', we can
+ // use that parameter to pass in some data.
+ $this->showView('users/new', $vars);
+ }
+
public function individual($routed, $remainder) {
$username = implode('/', $remainder);
- global $mm;
- $uid = $mm->getUID($username);
- if ($mm->getStatus($uid)===3) $uid = false; // ignore groups.
+ global $mm; // also used for pluginmanager
+ $db = $mm->database();
+ $uid = $db->getUID($username);
+ $user = Auth::getObj($uid);
+
+ if ($user->isGroup()) $uid = false; // ignore groups.
if ($uid===false) {
$this->http404($routed, $remainder);
} else {
- $user = $mm->getAuthObj($uid);
if (!$user->canRead()) {
$this->http401($routed, $remainder);
exit();
@@ -75,6 +82,7 @@ class Users extends Controller {
$vars = array();
$method = $_SERVER['REQUEST_METHOD'];
+
switch ($method) {
case 'PUT': $_POST = $_PUT;
case 'POST':
@@ -82,31 +90,32 @@ class Users extends Controller {
if ($user->canEdit()) {
$vars = $this->update_user($user);
}
- break;
+ break;
}
-
+
$config_options = array();
$mm->pluginManager()->callHook('userConfig', &$config_options);
$vars['config_options'] = $config_options;
$vars['user'] = $user;
- $vars['groups'] = $mm->listGroupNames();
+ $vars['groups'] = $db->listGroupNames();
require_once('ContactMethod.class.php');
$this->showView('users/individual', $vars);
}
}
- public function http404($routed, $remainder) {
+ public function http404($routed, $rnemainder) {
$username = implode('/', $remainder);
$this->showView('users/404',
array('username'=>$username));
}
-
+
public function http401($routed, $remainder) {
- global $mm;
- $this->showView('users/401', array('uid'=>$mm->isLoggedIn()));
+ $this->showView('users/401', array('uid'=>Login::isLoggedIn()));
}
-
+
+ // Other Functions ///////////////////////////////////////////
+
/**
* This will parse POST data to create a new user.
* If successfull it will show a message saying so.
@@ -119,9 +128,10 @@ class Users extends Controller {
@$vars['password1'] = $_POST['auth_password' ];
@$vars['password2'] = $_POST['auth_password_verify'];
- global $mm;
+ global $mm; $db = $mm->database();
+
$vars['errors'] = array();
- if ($mm->getUID($vars['username'])!==false)
+ if ($db->getUID($vars['username'])!==false)
$vars['errors'][] = 'user exists';
if (in_array($vars['username'], $this->illegal_names))
$vars['errors'] = 'illegal name';
@@ -136,11 +146,11 @@ class Users extends Controller {
} else {
$username = $vars['username'];
$passowrd = $vars['password1'];
- $uid = $mm->addUser($username, $password);
+ $uid = $db->addUser($username, $password);
if ($uid===false) {
$this->showView('users/500');
} else {
- $mm->login($username, $password);
+ Login::login($username, $password);
$this->showView('users/created',
array('username'=>$username));
}
@@ -185,8 +195,8 @@ class Users extends Controller {
}
// Change information //////////////////////////////////////////
- global $mm;
$config_options = array();
+ global $mm;
$mm->pluginManager()->callHook('userConfig', &$config_options);
foreach ($config_options as $group=>$options) {
@@ -244,9 +254,9 @@ class Users extends Controller {
* This will show the user index.
*/
private function show_index($routed, $remainder) {
- global $mm;
+ global $mm; $db = $mm->database();
- $logged_in_user = $mm->getAuthObj($mm->isLoggedIn());
+ $logged_in_user = Auth::getObj(Login::isLoggedIn());
if (!$logged_in_user->isUser()) {
$this->http401($routed, $remainder);
exit();
@@ -255,9 +265,9 @@ class Users extends Controller {
$vars = array();
$vars['attribs'] = $this->getIndexAttribs();
$vars['users'] = array();
- $uids = $mm->listUsers();
+ $uids = $db->listUsers();
foreach ($uids as $uid) {
- $user = $mm->getAuthObj($uid);
+ $user = Auth::getObj($uid);
$vars['users'][$uid] = array();
foreach ($vars['attribs'] as $attrib) {
$key = $attrib['key'];
@@ -269,8 +279,7 @@ class Users extends Controller {
}
private function getConf($user, $key) {
- global $mm;
- $logged_in_user = $mm->getAuthObj($mm->isLoggedIn());
+ $logged_in_user = Auth::getObj(Login::isLoggedIn());
$uid = $user->getUID();
$post_key = $key."[$uid]";
@$value = $_POST[$post_key];
@@ -301,8 +310,7 @@ class Users extends Controller {
private function setConf($uid, $key, $value) {
// So, this rocks because we don't have to check permissions,
// the User object does that.
- global $mm;
- $user = $mm->getAuthObj($uid);
+ $user = Auth::getObj($uid);
switch ($key) {
case 'auth_name':
diff --git a/src/lib/Database.class.php b/src/lib/Database.class.php
index 03c227f..b7e5bcd 100644
--- a/src/lib/Database.class.php
+++ b/src/lib/Database.class.php
@@ -381,7 +381,7 @@ class Database {
* key-value store in the database.
*/
public static function arrayToValue($list) {
- $out_list = $this->sanitizeArray($list);
+ $out_list = self::sanitizeArray($list);
return ','.implode(',', $out_list).',';
}
/**
@@ -389,7 +389,7 @@ class Database {
*/
public static function valueToArray($value) {
$raw_list = explode(',', $value);
- $out_list = $this->sanitizeArray($raw_list);
+ $out_list = self::sanitizeArray($raw_list);
return $out_list;
}
diff --git a/src/lib/Login.class.php b/src/lib/Login.class.php
index 26d11dd..14e3ecb 100644
--- a/src/lib/Login.class.php
+++ b/src/lib/Login.class.php
@@ -1,6 +1,8 @@
<?php
class Login {
+ public function __construct() {}
+
public static function login($username, $password) {
global $mm;
$uid = $mm->database()->getUID($username);
diff --git a/src/lib/MessageHandler.class.php b/src/lib/MessageHandler.class.php
deleted file mode 100644
index 1fa9faf..0000000
--- a/src/lib/MessageHandler.class.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class MessageHandler {
- public function __constructor() {
-
- }
- public function loadPlugin($plugin_name) {
- global $m;
-
- require_once("$plugin.class.php");
- $obj = new $plugin;
- $params = call_user_func("$plugin::configList");
- foreach ($params as $param => $type) {
- $value = $m->getPluginConf($plugin, $param);
- if ($value!==false) {
- switch ($type) {
- case 'text':
- case 'password':
- $value = "$value";
- break;
- case 'int':
- $value = (int)$value;
- break;
- }
- $obj->configSet($param, $value);
- }
- }
- return $obj;
- }
- public function main() {
- global $BASE;
-
- $private_senders = array();
- $broadcast_senders = array();
-
- $plugin_list = $m->getSysConf('plugins');
- $plugins = explode(',', $plugin_list);
- foreach ($plugins as $plugin) {
- require_once("$plugin.class.php");
- if (is_subclass_of($plugin, 'SenderPrivate')) {
- $private_senders[] = $this->loadPlugin($plugin);
- }
- if (is_subclass_of($plugin, 'SenderBroadcast')) {
- $broadcast_senders[] = $this->loadPlugin($plugin);
- }
- }
- //foreach ($private_senders)
- }
-} \ No newline at end of file
diff --git a/src/lib/MessageManager.class.php b/src/lib/MessageManager.class.php
index 645643e..d327eb7 100644
--- a/src/lib/MessageManager.class.php
+++ b/src/lib/MessageManager.class.php
@@ -82,18 +82,4 @@ class MessageManager {
}
return $this->base;
}
-
- public function getAuthObj($uid) {
- if (!isset($this->users[$uid])) {
- $is_group = ($this->database()->getStatus($uid)===3);
- if ($is_group) {
- require_once('Group.class.php');
- $this->users[$uid] = new Group($uid);
- } else {
- require_once('User.class.php');
- $this->users[$uid] = new User($uid);
- }
- }
- return $this->users[$uid];
- }
}
diff --git a/src/lib/Model.class.php b/src/lib/Model.class.php
deleted file mode 100644
index 523976e..0000000
--- a/src/lib/Model.class.php
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-
-class Model {}
diff --git a/src/lib/PluginManager.class.php b/src/lib/PluginManager.class.php
index 22d7b0c..417eecc 100644
--- a/src/lib/PluginManager.class.php
+++ b/src/lib/PluginManager.class.php
@@ -7,13 +7,13 @@ class PluginManager {
* Return an instance of the plugin with $plugin_name
*/
public function loadPlugin($plugin_name) {
- global $mm;
+ global $mm; $db = $mm->database();
require_once("$plugin_name.class.php");
$obj = new $plugin_name;
$params = call_user_func("$plugin_name::configList");
foreach ($params as $param => $type) {
- $value = $mm->getPluginConf($plugin_name, $param);
+ $value = $db->getPluginConf($plugin_name, $param);
if ($value!==false) {
switch ($type) {
case 'text':
@@ -52,18 +52,18 @@ class PluginManager {
* Return an array of enabled plugin names.
*/
public function getActivePlugins() {
- global $mm;
- $string = $mm->getSysConf('plugins');
- return $mm->valueToArray($string);
+ global $mm; $db = $mm->database();
+ $string = $db->getSysConf('plugins');
+ return $db->valueToArray($string);
}
/**
* Set the enabled plugins.
*/
public function setActivePlugins($plugins) {
- global $mm;
- $string = $mm->arrayToValue($plugins);
- return $mm->setSysConf('plugins', $string);
+ global $mm; $db = $mm->database();
+ $string = $db->arrayToValue($plugins);
+ return $db->setSysConf('plugins', $string);
}
/**
diff --git a/src/lib/SenderBroadcast.class.php b/src/lib/SenderBroadcast.class.php
deleted file mode 100644
index 7510ff2..0000000
--- a/src/lib/SenderBroadcast.class.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-require_once('Plugin.class.php');
-
-abstract class SenderBroadcast extends Plugin {
- public abstract function send($id, $subject, $body);
-}
diff --git a/src/lib/SenderPrivate.class.php b/src/lib/SenderPrivate.class.php
deleted file mode 100644
index e6f2807..0000000
--- a/src/lib/SenderPrivate.class.php
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-require_once('Plugin.class.php');
-
-abstract class SenderPrivate extends Plugin {
- public abstract function send($to, $id, $subject, $body);
-}
diff --git a/src/lib/Auth.class.php b/src/models/Auth.class.php
index e49ebf7..3aba0f3 100644
--- a/src/lib/Auth.class.php
+++ b/src/models/Auth.class.php
@@ -1,12 +1,32 @@
<?php
require_once('MessageManager.class.php');
+require_once('Login.class.php');
+require_once('Group.class.php');
+require_once('User.class.php');
class Auth {
- protected $mm = null;
+ static $users = array();
+ public static function getObj($uid) {
+ if (!isset(self::$users[$uid])) {
+ global $mm;
+ $is_group = ($mm->database()->getStatus($uid)===3);
+ if ($is_group) {
+ require_once('Group.class.php');
+ $obj = new Group($uid);
+ } else {
+ require_once('User.class.php');
+ $obj = new User($uid);
+ }
+ self::$users[$uid] = $obj;
+ }
+ return self::$users[$uid];
+ }
+
+ protected $db = null;
protected $uid = false;
public function __construct($uid) {
global $mm;
- $this->mm = $mm;
+ $this->db = $mm->database();
$this->uid = $uid;
}
public function getUID() {
@@ -22,16 +42,16 @@ class Auth {
* @return 0=unverified 1=user 2=admin 3=group
*/
protected function getType() {
- $type = $this->mm->getStatus($this->uid);
+ $type = $this->db->getStatus($this->uid);
return $type;
}
protected function setType($type) {
- $logged_in_uid = $this->mm->isLoggedIn();
- $logged_in_obj = $this->mm->getAuthObj($logged_in_uid);
+ $logged_in_uid = $this->db->isLoggedIn();
+ $logged_in_obj = Auth::getObj($logged_in_uid);
$is_admin = $logged_in_obj->isAdmin();
if (!$is_admin) return false;
- return $this->mm->setStatus($this->uid, $type);
+ return $this->db->setStatus($this->uid, $type);
}
public function isUser() {
$type = $this->getType();
@@ -59,19 +79,19 @@ class Auth {
// Permissions /////////////////////////////////////////////////////////
public function canRead() {
- $logged_in_uid = $this->mm->isLoggedIn();
+ $logged_in_uid = Login::isLoggedIn();
$is_me = ($logged_in_uid === $this->uid);
- $logged_in_obj = $this->mm->getAuthObj($logged_in_uid);
+ $logged_in_obj = Auth::getObj($logged_in_uid);
$is_user = $logged_in_obj->isUser();
return ($is_me || $is_user);
}
public function canEdit() {
- $logged_in_uid = $this->mm->isLoggedIn();
+ $logged_in_uid = Login::isLoggedIn();
$is_me = ($logged_in_uid === $this->uid);
- $logged_in_obj = $this->mm->getAuthObj($logged_in_uid);
+ $logged_in_obj = Auth::getObj($logged_in_uid);
$is_admin = $logged_in_obj->isAdmin();
return ($is_me || $is_admin);
@@ -80,11 +100,11 @@ class Auth {
// [user|group]name ////////////////////////////////////////////////////
public function getName() {
if (!$this->canRead()) return false;
- return $this->mm->getUsername($this->uid);
+ return $this->db->getUsername($this->uid);
}
public function setName($new_name) {
if (!$this->canEdit()) return false;
- return $this->mm->setUsername($this->uid, $new_name);
+ return $this->db->setUsername($this->uid, $new_name);
}
/**********************************************************************\
@@ -93,18 +113,18 @@ class Auth {
public function getConf($setting) {
if (!$this->canRead()) return false;
- return $this->mm->getUserConf($this->uid, $setting);
+ return $this->db->getUserConf($this->uid, $setting);
}
public function setConf($setting, $value) {
if (!$this->canEdit()) return false;
- return $this->mm->setUserConf($this->uid, $setting, $value);
+ return $this->db->setUserConf($this->uid, $setting, $value);
}
public function getConfArray($setting) {
$string = $this->getConf($setting);
- return $this->mm->valueToArray($string);
+ return $this->db->valueToArray($string);
}
public function setConfArray($setting, $list) {
- $string = $this->mm->arrayToValue($list);
+ $string = $this->db->arrayToValue($list);
return $this->setConf($setting, $string);
}
}
diff --git a/src/lib/ContactMethod.class.php b/src/models/ContactMethod.class.php
index b01e7d3..b01e7d3 100644
--- a/src/lib/ContactMethod.class.php
+++ b/src/models/ContactMethod.class.php
diff --git a/src/lib/Group.class.php b/src/models/Group.class.php
index 96c5e2c..f981a4f 100644
--- a/src/lib/Group.class.php
+++ b/src/models/Group.class.php
@@ -1,7 +1,7 @@
<?php
require_once('Auth.class.php');
-class User extends Auth {
+class Group extends Auth {
public function __construct($uid) {
parent::__construct($uid);
}
@@ -18,6 +18,6 @@ class User extends Auth {
\**********************************************************************/
public function getMembers() {
- return $this->mm->getUsersInGroup($this->getName());
+ return $this->db->getUsersInGroup($this->getName());
}
}
diff --git a/src/lib/User.class.php b/src/models/User.class.php
index c1888b5..b6dbede 100644
--- a/src/lib/User.class.php
+++ b/src/models/User.class.php
@@ -15,7 +15,7 @@ class User extends Auth {
public function setPassword($password) {
if (!$this->canEdit()) return false;
- return $this->mm->setPassword($this->uid, $password);
+ return $this->db->setPassword($this->uid, $password);
}
/**********************************************************************\
diff --git a/src/plugins/InformationPlugin.class.php b/src/plugins/InformationPlugin.class.php
index 6a37370..0267ccf 100644
--- a/src/plugins/InformationPlugin.class.php
+++ b/src/plugins/InformationPlugin.class.php
@@ -22,4 +22,6 @@ class InformationPlugin extends Plugin {
'Why you want to be on the team',
'textarea');
}
+ public function sendPrivate($to, $id, $subject, $body) {}
+ public function sendBroadcast($id, $subject, $body) {}
}
diff --git a/src/plugins/SenderGVSMS.class.php b/src/plugins/SenderGVSMS.class.php
index 90f9e69..7919007 100644
--- a/src/plugins/SenderGVSMS.class.php
+++ b/src/plugins/SenderGVSMS.class.php
@@ -1,9 +1,8 @@
<?php
-require_once('SenderPrivate.class.php');
require_once('GoogleVoice.class.php');
-class SenderGVSMS extends SenderPrivate {
+class SenderGVSMS extends Plugin {
protected $config = array('username'=>'',
'password'=>'',
'length'=>160);
@@ -23,7 +22,7 @@ class SenderGVSMS extends SenderPrivate {
$this->config['password']);
}
- public function send($phoneNum, $id, $subject, $body) {
+ public function sendPrivate($phoneNum, $id, $subject, $body) {
global $shorturl, $messenger;
$url = $shorturl->get($messenger->id2url($id));
$maxlen = $this->config['length']-(strlen($url)+1);
diff --git a/src/plugins/SenderIdentica.class.php b/src/plugins/SenderIdentica.class.php
index ac62dc3..1e778f6 100644
--- a/src/plugins/SenderIdentica.class.php
+++ b/src/plugins/SenderIdentica.class.php
@@ -1,9 +1,8 @@
<?php
-require_once('SenderBroadcast.class.php');
require_once('Identica.class.php');
-class SenderIdentica extends SenderBroadcast {
+class SenderIdentica extends Plugin {
protected $config = array('username'=>'',
'password'=>'',
'length'=>140);
@@ -24,7 +23,7 @@ class SenderIdentica extends SenderBroadcast {
$this->config['password']);
}
- public function send($id, $subject, $body) {
+ public function sendBroadcast($id, $subject, $body) {
global $shorturl, $messenger;
$url = $shorturl->get($messenger->id2url($id));
$maxlen = $this->config['length']-(strlen($url)+1);
diff --git a/src/views/Template.class.php b/src/views/Template.class.php
index 540e4fc..f57d5dc 100644
--- a/src/views/Template.class.php
+++ b/src/views/Template.class.php
@@ -1,10 +1,12 @@
<?php
+require_once('Login.class.php');
+
class Template {
private $indent = 0;
private $ret = false;
private $base = '/';
- private $mm = null;
+ private $db = null;
public function status($status) {
header($_SERVER["SERVER_PROTOCOL"]." $status");
@@ -13,7 +15,7 @@ class Template {
public function __construct($base_url, $mm=null) {
$this->base = $base_url;
- $this->mm = $mm;
+ $this->db = $mm->database();
}
public function setRet($ret) {
@@ -109,11 +111,11 @@ class Template {
echo $str;
}
public function header($title) {
- $mm = $this->mm;
- if ($mm==null) {
+ $db = $this->db;
+ if ($db==null) {
$username = false;
} else {
- $username = $mm->getUsername($mm->isLoggedIn());
+ $username = $db->getUsername(Login::isLoggedIn());
}
$ret = $this->ret;
diff --git a/src/views/pages/plugins/index.html.php b/src/views/pages/plugins/index.html.php
index 0e14161..d62b555 100644
--- a/src/views/pages/plugins/index.html.php
+++ b/src/views/pages/plugins/index.html.php
@@ -2,4 +2,4 @@
$t = $VARS['template'];
$t->header('Administrator Plugin Management');
-$t->openTag('form',array('method'=>'post','action'=>$m->baseUrl().plugins));
+$t->openTag('form',array('method'=>'post','action'=>$t->url('plugins')));
diff --git a/src/views/pages/users/500.html.php b/src/views/pages/users/500.html.php
index 27038a4..f4f1c42 100644
--- a/src/views/pages/users/500.html.php
+++ b/src/views/pages/users/500.html.php
@@ -1,5 +1,6 @@
<?php global $VARS, $mm;
$t = $VARS['template'];
+$db = $mm->database();
$t->status('500 Internal Server Error');
$t->header('Unknown error');
@@ -9,5 +10,5 @@ $t->paragraph("An unknown error was encountered when creating ".
"error is on our end. Sorry.");
$t->paragraph("Here's a dump of the SQL error stack, it may ".
"help us find the issue:");
-$t->tag('pre', array(), htmlentities($mm->mysql_error()));
+$t->tag('pre', array(), htmlentities($db->mysql_error()));
$t->footer();