Esempio n. 1
0
 /**
  * Read a record
  *
  * @param   mixed    $name
  * @return  boolean
  */
 public function read($name = null)
 {
     $this->clear();
     $db = \App::get('db');
     if (empty($db)) {
         return false;
     }
     if (!is_null($name)) {
         if (Validate::positiveInteger($name)) {
             $this->gidNumber = $name;
         } else {
             $this->cn = $name;
         }
     }
     $result = true;
     $lazyloading = false;
     if (is_numeric($this->gidNumber)) {
         $query = "SELECT * FROM `#__xgroups` WHERE gidNumber = " . $db->quote($this->gidNumber) . ";";
     } else {
         $query = "SELECT * FROM `#__xgroups` WHERE cn = " . $db->quote($this->cn) . ";";
     }
     $db->setQuery($query);
     $result = $db->loadAssoc();
     if (empty($result)) {
         $this->clear();
         return false;
     }
     foreach ($result as $key => $value) {
         if (property_exists(__CLASS__, $key) && $key[0] != '_') {
             $this->__set($key, $value);
         }
     }
     $this->__unset('members');
     // we unset the lists so we can detect whether they have been loaded or not
     $this->__unset('invitees');
     $this->__unset('applicants');
     $this->__unset('managers');
     if (!$lazyloading) {
         $this->__get('members');
         $this->__get('invitees');
         $this->__get('applicants');
         $this->__get('managers');
     }
     $this->_updatedkeys = array();
     return true;
 }