static function makeAttachFilename($subfolder, $filename, $date = null, $ticket = null, $userid = null) { $base = JPATH_SITE . DS . FSS_Settings::get('attach_location') . DS . $subfolder . DS; $path = ''; $path_info = pathinfo($filename); $file_template = $path_info['filename'] . "-{UID}." . $path_info['extension']; if ($date == null) { $date = date("Y-m-d"); } $time = strtotime($date); if ($userid == null) { $userid = $ticket->user_id; } if ($ticket != null) { switch (FSS_Settings::get('attach_storage_filename')) { case 1: $path .= $ticket->id . DS; break; case 2: $path .= date("Y", $time) . DS . date("Y-m", $time) . DS; break; case 3: $path .= date("Y", $time) . DS . date("Y-m", $time) . DS . date("Y-m-d", $time) . DS; break; case 4: $user = JFactory::getUser($userid); if ($user->id > 0) { $path .= $user->username . DS; } else { $path .= '_unregistered' . DS; } } } if (!file_exists($base . $path)) { mkdir($base . $path, 0755, true); } $filename = str_replace("{UID}", FSS_File_Helper::shortUID($file_template), $file_template); while (JFile::exists($path . $filename)) { $filename = str_replace("{UID}", FSS_File_Helper::shortUID($file_template), $file_template); } return $path . $filename; }