cvs: pearweb /include/Damblan Karma.php
| From: | Martin Jansen | Date: | Sat, 27 Sep 2003 13:39:44 +0000 |
| Subject: | cvs: pearweb /include/Damblan Karma.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13132@lists.php.net to get a copy of this message | ||
mj Sat Sep 27 09:39:44 2003 EDT
Modified files:
/pearweb/include/Damblan Karma.php
Log:
* Only require global.karma.manager karma when running write operations on
the database.
Index: pearweb/include/Damblan/Karma.php
diff -u pearweb/include/Damblan/Karma.php:1.3 pearweb/include/Damblan/Karma.php:1.4
--- pearweb/include/Damblan/Karma.php:1.3 Fri Sep 26 15:50:13 2003
+++ pearweb/include/Damblan/Karma.php Sat Sep 27 09:39:44 2003
@@ -15,7 +15,7 @@
+----------------------------------------------------------------------+
| Author: Martin Jansen <mj@php.net> |
+----------------------------------------------------------------------+
- $Id: Karma.php,v 1.3 2003/09/26 19:50:13 mj Exp $
+ $Id: Karma.php,v 1.4 2003/09/27 13:39:44 mj Exp $
*/
/**
@@ -26,7 +26,7 @@
* single-sign-on system some time in the future.
*
* @author Martin Jansen <mj@php.net>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
class Damblan_Karma {
@@ -42,10 +42,6 @@
global $auth_user;
$this->_dbh = $dbh;
-
- if ($this->has($auth_user->handle, "global.karma.manager") == false) {
- return PEAR::raiseError("Insufficient privileges");
- }
}
/**
@@ -106,6 +102,8 @@
function grant($user, $level) {
global $auth_user;
+ $this->_requireKarma();
+
$id = $this->_dbh->nextId("karma");
$query = "INSERT INTO karma VALUES (?, ?, ?, ?, NOW())";
@@ -123,6 +121,8 @@
* @return boolean
*/
function remove($user, $level) {
+ $this->_requireKarma();
+
$query = "DELETE FROM karma WHERE user = ? AND level = ?";
return $this->_dbh->query($query, array($user, $level));
}
@@ -149,6 +149,19 @@
function getUsers($level) {
$query = "SELECT * FROM karma WHERE level = ?";
return $this->_dbh->getAll($query, array($handle), DB_FETCHMODE_ASSOC);
+ }
+
+ /**
+ * Require global.karma.manager level for write operations
+ *
+ * @access private
+ */
+ function _requireKarma() {
+ global $auth_user;
+
+ if ($this->has($auth_user->handle, "global.karma.manager") == false) {
+ return PEAR::raiseError("Insufficient privileges");
+ }
}
}
?>