Skip to content
Snippets Groups Projects
Select Git revision
  • 58b63c23176f276e471fa0c5cf618d571994f160
  • master default
  • labcomm2014_tc31
  • labcomm2014
  • js
  • java_dyn_msg_dec
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.1
  • v2014.0
  • v2013.0
14 results

labcomm_pthread_scheduler.h

Blame
  • Forked from Anders Blomdell / LabComm
    Source project has a limited visibility.
    class.Group.php 2.25 KiB
    <?php
    
    class Group {
    
      private static $queryList = <<<EOS
        select ID, Gruppnamn from Grupper order by Gruppnamn
    EOS;
    
      private static $queryMembership = <<<EOS
        select Grupper.ID, Gruppnamn from Grupper,GruppAdress where 
        GruppID = Grupper.ID and Adressid = ? order by Gruppnamn
    EOS;
    
      private static $querySetGroup = <<<EOS
        replace into GruppAdress set AdressID = ?, GruppID = ?
    EOS;
    
      private static $queryUnsetGroup = <<<EOS
        delete from GruppAdress where AdressID = ? and GruppID = ?
    EOS;
    
      private static $instance;
    
      private $list;
    
      private function __construct() {
        global $gCms;
        if (!isset($gCms)) exit;
        $ADB = AddressDB::getDB();
        $result = $ADB->Execute(self::$queryList,array());
        while ($row = $result->FetchRow()) {
          $this->list[$row['Gruppnamn']] = $row['ID'];
        }
      }
      
      public static function getMembers($GruppID) {
        global $gCms; if (!isset($gCms)) exit;
        $db = AddressDB::getDB();
        $result = $db->Execute(self::$queryMembership,array($GruppID));
        if ($result === false) { die("Database error!<br>" . $db->ErrorMsg()); }
        $list = array();
        while ($row = $result->FetchRow()) {
          $list[$row['Gruppnamn']] = $row['ID'];
        }
        return $list;
      }
    
      public static function getNonMembers($GruppID) {
        $members = self::getMembers($GruppID);
        $nonmembers = array_diff_assoc(self::getGroup(),$members);
        return $nonmembers;
      }
        
      public static function setMember($ID,$GroupID) {
        global $gCms; if (!isset($gCms)) exit;
        $db = AddressDB::getDB();
        $values = array($ID, $GroupID);
        $result = $db->Execute(self::$querySetGroup,$values);
        if ($result === false) {die("Database error!<br>" . $db->ErrorMsg()); }
      }  
    
      public static function unsetMember($ID,$GroupID) {
        global $gCms; if (!isset($gCms)) exit;
        $db = AddressDB::getDB();
        $values = array($ID, $GroupID);
        //   echo '<pre>'; print_r($queryUnsetGroup); print_r($values); echo '</pre>';exit;
        
        $result = $db->Execute(self::$queryUnsetGroup,$values);
        if ($result === false) {die("Database error!<br>" . $db->ErrorMsg()); }
      }  
    
      public static function getGroup() {
        if (!isset(self::$instance)) {
          $c = __CLASS__;
          self::$instance = new $c;
        }
        return self::$instance->list;
      }
    
    
    }
    ?>