Example #1
0
 public function bind($array, $ignore = '')
 {
     if (key_exists('params', $array) && is_array($array['params'])) {
         $registry = new MRegistry();
         $registry->loadArray($array['params']);
         $array['params'] = (string) $registry;
     }
     // Attempt to bind the data.
     $return = parent::bind($array, $ignore);
     // Load the real group data based on the bound ids.
     if ($return && !empty($this->groups)) {
         // Set the group ids.
         MArrayHelper::toInteger($this->groups);
         // Get the titles for the user groups.
         $query = $this->_db->getQuery(true);
         $query->select($this->_db->quoteName('id'));
         $query->select($this->_db->quoteName('title'));
         $query->from($this->_db->quoteName('#__usergroups'));
         $query->where($this->_db->quoteName('id') . ' = ' . implode(' OR ' . $this->_db->quoteName('id') . ' = ', $this->groups));
         $this->_db->setQuery($query);
         // Set the titles for the user groups.
         $this->groups = $this->_db->loadAssocList('id', 'id');
         // Check for a database error.
         if ($this->_db->getErrorNum()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     return $return;
 }