/** * Create an avatar picture (and checks all necessary things too) * TODO decouple * TODO total rebuild */ public static function createAvatar() { // check avatar folder writing rights, check if upload fits all rules if (AvatarModel::isAvatarFolderWritable() and AvatarModel::validateImageFile()) { // create a jpg file in the avatar folder, write marker to database $target_file_path = Config::get('PATH_AVATARS') . Session::get('user_id'); AvatarModel::resizeAvatarImage($_FILES['avatar_file']['tmp_name'], $target_file_path, Config::get('AVATAR_SIZE'), Config::get('AVATAR_SIZE'), Config::get('AVATAR_JPEG_QUALITY')); AvatarModel::writeAvatarToDatabase(Session::get('user_id')); Session::set('user_avatar_file', AvatarModel::getPublicUserAvatarFilePathByUserId(Session::get('user_id'))); Session::add('feedback_positive', Text::get('FEEDBACK_AVATAR_UPLOAD_SUCCESSFUL')); } }