/**
  * Check for existing groups with the same name
  *
  * @param string Name to check
  * @return string A group name which is unique for the current use
  */
 private function unique_groupname($name)
 {
     $checkname = $name;
     $num = 2;
     $hit = false;
     do {
         $sql_result = $this->db->query("SELECT 1 FROM " . $this->db->table_name($this->db_groups) . " WHERE del<>1" . " AND user_id=?" . " AND name=?", $this->user_id, $checkname);
         // append number to make name unique
         if ($hit = $this->db->fetch_array($sql_result)) {
             $checkname = $name . ' ' . $num++;
         }
     } while ($hit);
     return $checkname;
 }