*/
class Group {
/**#@+
- * @access private
+ * @private
*/
/** string $name Group name */
var $name;
/** string $rights Contain rights values : "foo,bar,bla" */
var $rights;
/**#@-*/
-
+
/** Constructor */
function Group() {
$this->clear();
// be sure it's an integer
$this->id = intval($this->id);
-
+
if($this->id) {
// By ID
$dbr =& wfGetDB( DB_SLAVE );
$this->description = $row->gr_description;
$this->rights = $row->gr_rights;
$this->dataLoaded = true;
- }
-
+ }
+
/** Initialise a new row in the database */
function addToDatabase() {
if ( Group::getStaticGroups() ) {
- wfDebugDieBacktrace( "Can't modify groups in static mode" );
+ throw new MWException( "Can't modify groups in static mode" );
}
$fname = 'Group::addToDatabase';
global $wgMemc;
if ( Group::getStaticGroups() ) {
- wfDebugDieBacktrace( "Can't modify groups in static mode" );
+ throw new MWException( "Can't modify groups in static mode" );
}
if($this->id == 0) { return; }
-
+
$fname = 'Group::save';
$dbw =& wfGetDB( DB_MASTER );
-
+
$dbw->update( 'groups',
array( /* SET */
'gr_name' => $this->name,
'gr_id' => $this->id
), $fname
);
-
+
$wgMemc->set( Group::getCacheKey( $this->id ), $this, 3600 );
}
global $wgMemc;
if ( Group::getStaticGroups() ) {
- wfDebugDieBacktrace( "Can't modify groups in static mode" );
+ throw new MWException( "Can't modify groups in static mode" );
}
if($this->id == 0) { return; }
-
+
$fname = 'Group::delete';
$dbw =& wfGetDB( DB_MASTER );
$wgMemc->delete( Group::getCacheKey( $this->id ) );
}
-
+
/**
* Get memcached key
* @static
// Factories
/**
* Uses Memcached if available.
- * @param integer $id Group database id
+ * @param $id Integer: group database id
*/
function newFromId($id) {
- global $wgMemc, $wgDBname;
+ global $wgMemc;
$fname = 'Group::newFromId';
-
+
$staticGroups =& Group::getStaticGroups();
if ( $staticGroups ) {
if ( array_key_exists( $id, $staticGroups ) ) {
wfDebug( "$fname loaded group $id from cache\n" );
return $group;
}
-
+
$group = new Group();
$group->id = $id;
$group->loadFromDatabase();
}
- /** @param string $name Group database name */
+ /** @param $name String: group database name */
function newFromName($name) {
$fname = 'Group::newFromName';
-
+
$staticGroups =& Group::getStaticGroups();
if ( $staticGroups ) {
$id = Group::idFromName( $name );
return null;
}
}
-
+
$g = new Group();
$g->name = $name;
$g->loadFromDatabase();
// Converters
/**
- * @param integer $id Group database id
+ * @param $id Integer: group database id
* @return string Group database name
*/
function nameFromId($id) {
}
/**
- * @param string $name Group database name
+ * @param $name String: group database name
* @return integer Group database id
*/
function idFromName($name) {
$this->loadFromDatabase();
return $this->getMessage( $this->name );
}
-
+
function getNameForContent() {
$this->loadFromDatabase();
return $this->getMessageForContent( $this->name );
$this->loadFromDatabase();
$this->name = $name;
}
-
+
function getId() { return $this->id; }
function setId($id) {
$this->id = intval($id);
$this->dataLoaded = false;
}
-
+
function getDescription() {
return $this->description;
}