[ Index ]
 

Code source de CMS made simple 1.0.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/classes/ -> class.groupoperations.inc.php (source)

   1  <?php
   2  #CMS - CMS Made Simple
   3  #(c)2004-6 by Ted Kulp (ted@cmsmadesimple.org)
   4  #This project's homepage is: http://cmsmadesimple.org
   5  #
   6  #This program is free software; you can redistribute it and/or modify
   7  #it under the terms of the GNU General Public License as published by
   8  #the Free Software Foundation; either version 2 of the License, or
   9  #(at your option) any later version.
  10  #
  11  #This program is distributed in the hope that it will be useful,
  12  #BUT withOUT ANY WARRANTY; without even the implied warranty of
  13  #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  #GNU General Public License for more details.
  15  #You should have received a copy of the GNU General Public License
  16  #along with this program; if not, write to the Free Software
  17  #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18  #
  19  #$Id$
  20  
  21  /**
  22   * Class for doing group related functions.  Maybe of the Group object functions are just wrappers around these.
  23   *
  24   * @since        0.6
  25   * @package        CMS
  26   */
  27  
  28  include_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.group.inc.php');
  29  
  30  class GroupOperations
  31  {
  32  	function LoadGroups()
  33      {
  34          global $gCms;
  35          $db = &$gCms->GetDb();
  36  
  37          $result = array();
  38  
  39          $query = "SELECT group_id, group_name, active FROM ".cms_db_prefix()."groups ORDER BY group_id";
  40          $dbresult = $db->Execute($query);
  41  
  42          while ($dbresult && $row = $dbresult->FetchRow())
  43          {
  44              $onegroup = new Group();
  45              $onegroup->id = $row['group_id'];
  46              $onegroup->name = $row['group_name'];
  47              $onegroup->active = $row['active'];
  48              $result[] = $onegroup;
  49          }
  50  
  51          return $result;
  52      }
  53  
  54      function & LoadGroupByID($id)
  55      {
  56  
  57          $result = false;
  58  
  59          global $gCms;
  60          $db = &$gCms->GetDb();
  61  
  62          $query = "SELECT group_id, group_name, active FROM ".cms_db_prefix()."groups WHERE group_id = ? ORDER BY group_id";
  63          $dbresult = $db->Execute($query, array($id));
  64  
  65          while ($dbresult && $row = $dbresult->FetchRow())
  66          {
  67              $onegroup = new Group();
  68              $onegroup->id = $row['group_id'];
  69              $onegroup->name = $row['group_name'];
  70              $onegroup->active = $row['active'];
  71              $result = $onegroup;
  72          }
  73  
  74          return $result;
  75      }
  76  
  77  	function InsertGroup($group)
  78      {
  79          $result = -1; 
  80  
  81          global $gCms;
  82          $db = &$gCms->GetDb();
  83  
  84          $new_group_id = $db->GenID(cms_db_prefix()."groups_seq");
  85          $time = $db->DBTimeStamp(time());
  86          $query = "INSERT INTO ".cms_db_prefix()."groups (group_id, group_name, active, create_date, modified_date) VALUES (?,?,?,".$time.", ".$time.")";
  87          $dbresult = $db->Execute($query, array($new_group_id, $group->name, $group->active));
  88          if ($dbresult !== false)
  89          {
  90              $result = $new_group_id;
  91          }
  92  
  93          return $result;
  94      }
  95  
  96  	function UpdateGroup($group)
  97      {
  98          $result = false; 
  99  
 100          global $gCms;
 101          $db = &$gCms->GetDb();
 102  
 103          $time = $db->DBTimeStamp(time());
 104          $query = "UPDATE ".cms_db_prefix()."groups SET group_name = ?, active = ?, modified_date = ".$time." WHERE group_id = ?";
 105          $dbresult = $db->Execute($query, array($group->name, $group->active, $group->id));
 106          if ($dbresult !== false)
 107          {
 108              $result = true;
 109          }
 110  
 111          return $result;
 112      }
 113  
 114  	function DeleteGroupByID($id)
 115      {
 116          $result = false;
 117  
 118          global $gCms;
 119          $db = &$gCms->GetDb();
 120  
 121          $query = "DELETE FROM ".cms_db_prefix()."group_perms where group_id = ?";
 122          $dbresult = $db->Execute($query, array($id));
 123  
 124          $query = "DELETE FROM ".cms_db_prefix()."groups where group_id = ?";
 125          $dbresult = $db->Execute($query, array($id));
 126  
 127          if ($dbresult !== false)
 128          {
 129              $result = true;
 130          }
 131  
 132          return $result;
 133      }
 134  }
 135  
 136  ?>


Généré le : Tue Apr 3 18:50:37 2007 par Balluche grâce à PHPXref 0.7