- renamed class Group to LetoDMS_Group

- moved all static functions into class but kept old functions for
  backward compatibility
This commit is contained in:
steinm 2010-11-03 10:18:26 +00:00
parent 12ca95bb40
commit a26a34162e
4 changed files with 95 additions and 79 deletions

View File

@ -1455,7 +1455,7 @@ class LetoDMS_Document
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (!is_bool($resArr)) { if (!is_bool($resArr)) {
foreach ($resArr as $row) { foreach ($resArr as $row) {
$this->_approversList["groups"][] = new Group($row["id"], $row["name"], $row["comment"]); $this->_approversList["groups"][] = new LetoDMS_Group($row["id"], $row["name"], $row["comment"]);
} }
} }
} }

View File

@ -1165,7 +1165,7 @@ class LetoDMS_Folder
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (!is_bool($resArr)) { if (!is_bool($resArr)) {
foreach ($resArr as $row) { foreach ($resArr as $row) {
$this->_approversList["groups"][] = new Group($row["id"], $row["name"], $row["comment"]); $this->_approversList["groups"][] = new LetoDMS_Group($row["id"], $row["name"], $row["comment"]);
} }
} }
} }

View File

@ -16,99 +16,115 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
/**********************************************************************\ /**********************************************************************\
| statische, Group-bezogene Funktionen | | statische, Group-bezogene Funktionen |
\**********************************************************************/ \**********************************************************************/
function getGroup($id) function getGroup($id) {
{ return LetoDMS_Group::getGroup($id);
global $db; }
if (!is_numeric($id)) function getGroupByName($name) {
die ("invalid groupid"); return LetoDMS_Group::getGroupByName($name);
}
$queryStr = "SELECT * FROM tblGroups WHERE id = " . $id;
$resArr = $db->getResultArray($queryStr); function getAllGroups() {
return LetoDMS_Group::getAllGroups();
if (is_bool($resArr) && $resArr == false) }
return false;
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-) function addGroup($name, $comment) {
return false; return LetoDMS_Group::addGroup($name, $comment);
}
$resArr = $resArr[0];
return new Group($resArr["id"], $resArr["name"], $resArr["comment"]);
}
function getGroupByName($name) {
global $db;
$queryStr = "SELECT `tblGroups`.* FROM `tblGroups` WHERE `tblGroups`.`name` = '".$name."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
return false;
$resArr = $resArr[0];
return new Group($resArr["id"], $resArr["name"], $resArr["comment"]);
}
function getAllGroups()
{
global $db;
$queryStr = "SELECT * FROM tblGroups ORDER BY name";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
$groups = array();
for ($i = 0; $i < count($resArr); $i++)
$groups[$i] = new Group($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
return $groups;
}
function addGroup($name, $comment)
{
global $db;
if (is_object(getGroupByName($name))) {
return false;
}
$queryStr = "INSERT INTO tblGroups (name, comment) VALUES ('".$name."', '" . $comment . "')";
if (!$db->getResult($queryStr))
return false;
return getGroup($db->getInsertID());
}
/**********************************************************************\ /**********************************************************************\
| Group-Klasse | | Group-Klasse |
\**********************************************************************/ \**********************************************************************/
class Group class LetoDMS_Group
{ {
var $_id; var $_id;
var $_name; var $_name;
function Group($id, $name, $comment) function LetoDMS_Group($id, $name, $comment)
{ {
$this->_id = $id; $this->_id = $id;
$this->_name = $name; $this->_name = $name;
$this->_comment = $comment; $this->_comment = $comment;
} }
function getGroup($id)
{
global $db;
if (!is_numeric($id))
die ("invalid groupid");
$queryStr = "SELECT * FROM tblGroups WHERE id = " . $id;
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
return false;
$resArr = $resArr[0];
return new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
}
function getGroupByName($name) {
global $db;
$queryStr = "SELECT `tblGroups`.* FROM `tblGroups` WHERE `tblGroups`.`name` = '".$name."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
else if (count($resArr) != 1) //wenn, dann wohl eher 0 als > 1 ;-)
return false;
$resArr = $resArr[0];
return new LetoDMS_Group($resArr["id"], $resArr["name"], $resArr["comment"]);
}
function getAllGroups()
{
global $db;
$queryStr = "SELECT * FROM tblGroups ORDER BY name";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
$groups = array();
for ($i = 0; $i < count($resArr); $i++)
$groups[$i] = new LetoDMS_Group($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
return $groups;
}
function addGroup($name, $comment)
{
global $db;
if (is_object(getGroupByName($name))) {
return false;
}
$queryStr = "INSERT INTO tblGroups (name, comment) VALUES ('".$name."', '" . $comment . "')";
if (!$db->getResult($queryStr))
return false;
return self::getGroup($db->getInsertID());
}
function getID() { return $this->_id; } function getID() { return $this->_id; }
function getName() { return $this->_name; } function getName() { return $this->_name; }

View File

@ -428,7 +428,7 @@ class LetoDMS_User
$this->_groups = array(); $this->_groups = array();
foreach ($resArr as $row) { foreach ($resArr as $row) {
$group = new Group($row["id"], $row["name"], $row["comment"]); $group = new LetoDMS_Group($row["id"], $row["name"], $row["comment"]);
array_push($this->_groups, $group); array_push($this->_groups, $group);
} }
} }