roundcubemail/program/lib/Roundcube/rcube_contacts.php
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, true).
                " 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;
    }
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, true).
                " 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;
    }
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 , true ) . " 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 ; }
Check for existing groups with the same name

@param string $name Name to check

@return string A group name which is unique for the current use
Check for existing groups with the same name