diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-29 03:20:00 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-29 03:20:00 +0000 |
commit | db47bcb6c018fecae71b8b7120c70d7ef9c7bcf6 (patch) | |
tree | d017e40d77c0d580aa6091dceabec7fd919a83c2 /lib | |
parent | 20c3dc0fd1993b36a8ff3467fbc8c4f30c59588d (diff) | |
download | ampache-db47bcb6c018fecae71b8b7120c70d7ef9c7bcf6.tar.gz ampache-db47bcb6c018fecae71b8b7120c70d7ef9c7bcf6.tar.bz2 ampache-db47bcb6c018fecae71b8b7120c70d7ef9c7bcf6.zip |
fixed play all artist, play all artist random, and account updating from user preferences
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/user.class.php | 46 | ||||
-rw-r--r-- | lib/general.lib.php | 35 |
2 files changed, 70 insertions, 11 deletions
diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 26eb2c0f..5924eec1 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -388,6 +388,52 @@ class User { } // add_preference /** + * update + * This function is an all encompasing update function that + * calls the mini ones does all the error checking and all that + * good stuff + */ + public function update($data) { + + if (empty($data['username'])) { + Error::add('username',_('Error Username Required')); +echo "WOO"; + } + + if ($data['password1'] != $data['password2'] AND !empty($data['password1'])) { +echo "WOO"; + Error::add('password',_("Error Passwords don't match")); + } + + if (Error::$state) { + return false; + } + + foreach ($data as $name=>$value) { + switch ($name) { + case 'password1'; + $name = 'password'; + case 'access': + case 'email': + case 'username': + case 'fullname'; + if ($this->$name != $value) { + $function = 'update_' . $name; + $this->$function($value); + } + break; + default: + // Rien a faire + break; + } // end switch on field + + } // end foreach + + return true; + + } // update + + /** * update_username * updates their username */ diff --git a/lib/general.lib.php b/lib/general.lib.php index 56c75c28..65422c48 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -519,19 +519,32 @@ function get_file_extension( $filename ) { } } // get_file_extension -/** - * tbl_name - * This function takes a SQL table name and returns it with any prefix - * that might be needed to make it work, - * @package General - * @catagory Database +/** + * generate_password + * This generates a random password, of the specified + * length */ -function tbl_name($table) { - - /* For now we just return the table name */ - return $table; +function generate_password($length) { + + $vowels = 'aAeEuUyY12345'; + $consonants = 'bBdDgGhHjJmMnNpPqQrRsStTvVwWxXzZ6789'; + $password = ''; + + $alt = time() % 2; + + for ($i = 0; $i < $length; $i++) { + if ($alt == 1) { + $password .= $consonants[(rand() % 39)]; + $alt = 0; + } else { + $password .= $vowels[(rand() % 17)]; + $alt = 1; + } + } -} // tbl_name + return $password; + +} // generate_password /** * scrub_out |