Prepare code for generic solution where all path are forged using

get_exdir.
This commit is contained in:
Laurent Destailleur
2015-05-18 22:25:51 +02:00
parent 4d6b25eb45
commit a258370f8a
32 changed files with 223 additions and 232 deletions

View File

@@ -3709,18 +3709,19 @@ function yn($yesno, $case=1, $color=0)
* @param int $level Level of subdirs to return (1, 2 or 3 levels)
* @param int $alpha Use alpha ref
* @param int $withoutslash 0=With slash at end, 1=without slash at end (except if '/', we return '')
* @param string $ref Not used yet. May be used to manage different option of directory path according to element.
* @param string $modulepart Not used yet. May be used to manage different option of directory path according to element.
* @param Object $object Object
* @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...')
* @return string Dir to use ending. Example '' or '1/' or '1/2/'
*/
function get_exdir($num,$level,$alpha=0,$withoutslash=0,$ref='',$modulepart='')
function get_exdir($num,$level,$alpha=0,$withoutslash=0,$object=null,$modulepart='')
{
global $conf;
$path = '';
if (in_array($modulepart, array('don','donation','supplier_invoice','invoice_supplier')))
if (! empty($level) && in_array($modulepart, array('shipment', 'member','don','donation','supplier_invoice','invoice_supplier')))
{
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
if (empty($alpha)) $num = preg_replace('/([^0-9])/i','',$num);
else $num = preg_replace('/^.*\-/i','',$num);
$num = substr("000".$num, -$level);