This commit is contained in:
Laurent Destailleur 2012-01-08 00:52:07 +01:00
parent ad232fa38c
commit 2d67802938
19 changed files with 170 additions and 134 deletions

View File

@ -78,13 +78,13 @@
<!-- Tweaks to metrics -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="30" />
<property name="complexity" value="40" />
<property name="absoluteComplexity" value="100" />
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="6" />
<property name="nestingLevel" value="9" />
<property name="absoluteNestingLevel" value="50" />
</properties>
</rule>

View File

@ -78,13 +78,13 @@
<!-- Tweaks to metrics -->
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="30" />
<property name="complexity" value="40" />
<property name="absoluteComplexity" value="100" />
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="6" />
<property name="nestingLevel" value="9" />
<property name="absoluteNestingLevel" value="50" />
</properties>
</rule>

View File

@ -344,7 +344,7 @@ $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/admin/security_other.php',$langs->trans("FormToTestFileUploadForm"),0,0,1);
$db->close();
llxFooter();
$db->close();
?>

View File

@ -464,10 +464,11 @@ class ActionComm extends CommonObject
/**
* Load all objects with filters
*
* @param int $socid Filter by thirdparty
* @param int $fk_element Id of element action is linked to
* @param string $elementtype Type of element action is linked to
* @param filter Other filter
* @param int $socid Filter by thirdparty
* @param int $fk_element Id of element action is linked to
* @param string $elementtype Type of element action is linked to
* @param string $filter Other filter
* @return int <0 if KO, >0 if OK
*/
function getActions($socid=0, $fk_element=0, $elementtype='', $filter='')
{
@ -732,7 +733,7 @@ class ActionComm extends CommonObject
* @param string $type 'event' or 'journal'
* @param int $cachedelay Do not rebuild file if date older than cachedelay seconds
* @param string $filename Force filename
* @param filters Array of filters
* @param array $filters Array of filters
* @return int <0 if error, nb of events in new file if ok
*/
function build_exportfile($format,$type,$cachedelay,$filename,$filters)

View File

@ -47,7 +47,7 @@ class ical
function read_file($file)
{
$this->file = $file;
$file_text = join("", file ($file)); //load file
$file_text = join("", file($file)); //load file
$file_text = preg_replace("/[\r\n]{1,} ([:;])/","\\1",$file_text);
return $file_text; // return all text
@ -105,7 +105,7 @@ class ical
switch ($text) // search special string
{
case "BEGIN:VTODO":
$this->todo_count = $this->todo_count+1; // new todo begin
$this->todo_count = $this->todo_count+1; // new to do begin
$type = "VTODO";
break;
@ -157,9 +157,10 @@ class ical
/**
* Add to $this->ical array one value and key. Type is VTODO, VEVENT, VFREEBUSY, VCALENDAR ... .
*
* @param string $type Type
* @param string $key Key
* @param string $value Value
* @param string $type Type
* @param string $key Key
* @param string $value Value
* @return void
*/
function add_to_array($type, $key, $value)
{

View File

@ -798,12 +798,13 @@ llxFooter();
* @param int $year Year
* @param int $monthshown Current month shown in calendar view
* @param string $style Style to use for this day
* @param array $eventarray Array of events
* @param array &$eventarray Array of events
* @param int $maxPrint Nb of actions to show each day on month view (0 means non limit)
* @param int $maxnbofchar Nb of characters to show for event line
* @param string $newparam Parameters on current URL
* @param int $showinfo Add extended information (used by day view)
* @param int $minheight Minimum height for each event. 60px by default.
* @return void
*/
function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxPrint=0, $maxnbofchar=16, $newparam='', $showinfo=0, $minheight=60)
{

View File

@ -48,7 +48,8 @@ $element = GETPOST('element');
/**
*
* \file htdocs/core/ajax/fileupload.php
* \brief This class is used to manage file upload using ajax
*/
class UploadHandler
{
@ -56,6 +57,7 @@ class UploadHandler
private $fk_elment;
private $element;
/**
* Constructor
*
@ -107,7 +109,7 @@ class UploadHandler
/**
* Enter description here ...
*
* @param string $file_name
* @param string $file_name Filename
* @return stdClass|NULL
*/
private function get_file_object($file_name)
@ -136,18 +138,20 @@ class UploadHandler
/**
* Enter description here ...
*
* @return void
*/
private function get_file_objects()
{
return array_values(array_filter(array_map(
array($this, 'get_file_object'),
scandir($this->options['upload_dir'])
)));
return array_values(array_filter(array_map(array($this, 'get_file_object'), scandir($this->options['upload_dir']))));
}
/**
* Create thumbs
* options is array('max_width', 'max_height')
*
* @param string $file_name Filename
* @param string $options is array('max_width', 'max_height')
* @return void
*/
private function create_scaled_image($file_name, $options)
{
@ -177,9 +181,9 @@ class UploadHandler
/**
* Enter description here ...
*
* @param unknown_type $uploaded_file
* @param unknown_type $file
* @param unknown_type $error
* @param string $uploaded_file Uploade file
* @param string $file File
* @param string $error Error
* @return unknown|string
*/
private function has_error($uploaded_file, $file, $error)
@ -216,11 +220,11 @@ class UploadHandler
/**
* Enter description here ...
*
* @param unknown_type $uploaded_file
* @param unknown_type $name
* @param unknown_type $size
* @param unknown_type $type
* @param unknown_type $error
* @param string $uploaded_file Uploade file
* @param string $name Name
* @param int $size Size
* @param string $type Type
* @param string $error Error
* @return stdClass
*/
private function handle_file_upload($uploaded_file, $name, $size, $type, $error)
@ -284,7 +288,9 @@ class UploadHandler
}
/**
* Enter description here ...
* Output data
*
* @return void
*/
public function get()
{
@ -300,7 +306,9 @@ class UploadHandler
}
/**
* Enter description here ...
* Output data
*
* @return void
*/
public function post()
{
@ -317,24 +325,18 @@ class UploadHandler
foreach ($upload['tmp_name'] as $index => $value) {
$info[] = $this->handle_file_upload(
$upload['tmp_name'][$index],
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index],
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index],
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index],
isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'][$index],
isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'][$index],
isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'][$index],
$upload['error'][$index]
);
}
} else {
$info[] = $this->handle_file_upload(
$upload['tmp_name'],
isset($_SERVER['HTTP_X_FILE_NAME']) ?
$_SERVER['HTTP_X_FILE_NAME'] : $upload['name'],
isset($_SERVER['HTTP_X_FILE_SIZE']) ?
$_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'],
isset($_SERVER['HTTP_X_FILE_TYPE']) ?
$_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'],
isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : $upload['name'],
isset($_SERVER['HTTP_X_FILE_SIZE']) ? $_SERVER['HTTP_X_FILE_SIZE'] : $upload['size'],
isset($_SERVER['HTTP_X_FILE_TYPE']) ? $_SERVER['HTTP_X_FILE_TYPE'] : $upload['type'],
$upload['error']
);
}
@ -349,7 +351,9 @@ class UploadHandler
}
/**
* Enter description here ...
* Delete uploaded file
*
* @return void
*/
public function delete()
{

View File

@ -116,7 +116,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
$row_array['value'] = $row['town'];
$row_array['zipcode'] = $row['zip'];
}
$row_array['departement_id'] = $row['fk_county']; // TODO deprecated
$row_array['departement_id'] = $row['fk_county']; // deprecated
$row_array['selectcountry_id'] = $row['fk_country'];
$row_array['state_id'] = $row['fk_county'];

View File

@ -58,73 +58,81 @@ class FormFile
* @param int $sectionid If upload must be done inside a particular ECM section
* @param int $perm Value of permission to allow upload
* @param int $size Length of input file area
* @param Object $object Object to use (when attachment is done on an element)
* @return int <0 if KO, >0 if OK
*/
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50)
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='')
{
global $conf,$langs;
$maxlength=$size;
print "\n\n<!-- Start form attach new file -->\n";
if (empty($title)) $title=$langs->trans("AttachANewFile");
if ($title != 'none') print_titre($title);
print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
print '<input type="hidden" name="section" value="'.$sectionid.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td width="50%" valign="top">';
$max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp;
// Now $max and $maxphp are in Kb
if ($maxphp > 0) $max=min($max,$maxphp);
if ($max > 0)
if ($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)
{
print '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
print '<input class="flat" type="file" name="userfile" size="'.$maxlength.'"';
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
print '>';
print ' &nbsp; ';
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
print '>';
if ($addcancel)
{
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($perm)
{
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
print ')';
}
return $this->_form_ajaxfileupload($object);
}
else
{
print ' ('.$langs->trans("UploadDisabled").')';
$maxlength=$size;
print "\n\n<!-- Start form attach new file -->\n";
if (empty($title)) $title=$langs->trans("AttachANewFile");
if ($title != 'none') print_titre($title);
print '<form name="userfile" action="'.$url.'" enctype="multipart/form-data" method="POST">';
print '<input type="hidden" name="section" value="'.$sectionid.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table width="100%" class="nobordernopadding">';
print '<tr><td width="50%" valign="top">';
$max=$conf->global->MAIN_UPLOAD_DOC; // En Kb
$maxphp=@ini_get('upload_max_filesize'); // En inconnu
if (preg_match('/m$/i',$maxphp)) $maxphp=$maxphp*1024;
if (preg_match('/k$/i',$maxphp)) $maxphp=$maxphp;
// Now $max and $maxphp are in Kb
if ($maxphp > 0) $max=min($max,$maxphp);
if ($max > 0)
{
print '<input type="hidden" name="max_file_size" value="'.($max*1024).'">';
}
print '<input class="flat" type="file" name="userfile" size="'.$maxlength.'"';
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
print '>';
print ' &nbsp; ';
print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"';
print (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm)?' disabled="disabled"':'');
print '>';
if ($addcancel)
{
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
}
if (! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($perm)
{
print ' ('.$langs->trans("MaxSize").': '.$max.' '.$langs->trans("Kb");
print ' '.info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1);
print ')';
}
}
else
{
print ' ('.$langs->trans("UploadDisabled").')';
}
print "</td></tr>";
print "</table>";
print '</form>';
if (empty($sectionid)) print '<br>';
print "\n<!-- End form attach new file -->\n\n";
return 1;
}
print "</td></tr>";
print "</table>";
print '</form>';
if (empty($sectionid)) print '<br>';
print "\n<!-- End form attach new file -->\n\n";
return 1;
}
/**
@ -723,12 +731,13 @@ class FormFile
}
/**
* Show form to upload a new file with jquery fileupload
* Show form to upload a new file with jquery fileupload.
* This form use the fileupload.php file.
*
* @param Object $object Object to use
* @return void
*/
function form_ajaxfileupload($object)
private function _form_ajaxfileupload($object)
{
global $langs;

View File

@ -158,7 +158,7 @@ if ($_GET["action"] == 'create')
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="40" maxlength="32" value="'.$ecmdir->label.'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formecm->select_all_sections(! empty($_GET["catParent"])?$_GET["catParent"]:$ecmdir->fk_parent,'catParent');
print '</td></tr>'."\n";

View File

@ -51,7 +51,7 @@ class Expedition extends CommonObject
var $origin;
var $origin_id;
var $lines=array();
var $expedition_method_id; // TODO deprecated
var $expedition_method_id; // deprecated
var $shipping_method_id;
var $tracking_number;
var $tracking_url;

View File

@ -69,11 +69,12 @@ class Export
{
global $langs,$conf,$mysoc;
dol_syslog("Export::load_arrays user=".$user->id." filter=".$filter);
dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter);
$var=true;
$i=0;
// Define list of modules directories into modulesdir
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[] = $dirroot . "/core/modules/";
@ -188,7 +189,7 @@ class Export
$this->array_export_sql_end[$i]=$module->export_sql_end[$r];
//$this->array_export_sql[$i]=$module->export_sql[$r];
dol_syslog("Export loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".count($module->export_fields_code[$r]));
dol_syslog(get_class($this)."::load_arrays loaded for module ".$modulename." with index ".$i.", dataset=".$module->export_code[$r].", nb of fields=".count($module->export_fields_code[$r]));
$i++;
// }
}

View File

@ -800,8 +800,9 @@ llxFooter();
/**
* Return table name of an alias. For this, we look for the "tablename as alias" in sql string.
*
* @param code Alias.Fieldname
* @param sqlmaxforexport SQL request to parse
* @param string $code Alias.Fieldname
* @param string $sqlmaxforexport SQL request to parse
* @return string Table name of field
*/
function getablenamefromfield($code,$sqlmaxforexport)
{

View File

@ -207,9 +207,9 @@ class Fichinter extends CommonObject
/**
* Fetch a intervention
*
* @param int $id Id of intervention
* @param string $ref Ref of intervention
* @return int <0 if ko, >0 if ok
* @param int $rowid Id of intervention
* @param string $ref Ref of intervention
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid,$ref='')
{
@ -389,6 +389,7 @@ class Fichinter extends CommonObject
/**
* Returns the label status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
@ -445,8 +446,8 @@ class Fichinter extends CommonObject
/**
* Return clicable name (with picto eventually)
*
* @param int withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @return string String with URL
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @return string String with URL
*/
function getNomUrl($withpicto=0)
{
@ -520,7 +521,8 @@ class Fichinter extends CommonObject
/**
* Information sur l'objet fiche intervention
*
* @param int $id id de la fiche d'intervention
* @param int $id Id de la fiche d'intervention
* @return void
*/
function info($id)
{
@ -570,7 +572,8 @@ class Fichinter extends CommonObject
/**
* Delete intervetnion
*
* @param User $user Object user who deletes
* @param User $user Object user who delete
* @return int <0 if KO, >0 if OK
*/
function delete($user)
{
@ -875,8 +878,9 @@ class FichinterLigne
/**
* Constructeur d'objets ligne d'intervention
* @param DoliDB $DB handler d'acces base de donnee
* Constructor
*
* @param DoliDB $DB Database handler
*/
function FichinterLigne($DB)
{
@ -886,7 +890,8 @@ class FichinterLigne
/**
* Retrieve the line of intervention
*
* @param int $rowid line id
* @param int $rowid Line id
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{

View File

@ -85,7 +85,7 @@ if ($search_desc) $sql .= " AND (f.description like '%".$db->escape($search_d
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND s.rowid = " . $socid;
$sql.= " ORDER BY ".$sortfield." ".$sortorder;
$sql.= $db->plimit($limit + 1 ,$offset);
$sql.= $db->plimit($limit+1, $offset);
$result=$db->query($sql);
if ($result)

View File

@ -36,7 +36,17 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
// C'est un wrapper, donc header vierge
/**
* Header function
*
* @return void
*/
function llxHeaderVierge() { print '<html><title>Export agenda cal</title><body>'; }
/**
* Footer function
*
* @return void
*/
function llxFooterVierge() { print '</body></html>'; }
require("../../main.inc.php");

View File

@ -340,8 +340,8 @@ llxFooterVierge();
/**
* Show header for demo
*
* @param string $title
* @param string $head
* @param string $title Title
* @param string $head Head string
* @return void
*/
function llxHeaderVierge($title, $head = "")

View File

@ -25,7 +25,17 @@ define("NOLOGIN",1); // This means this output page does not require to be logg
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
// C'est un wrapper, donc header vierge
/**
* Header function
*
* @return void
*/
function llxHeaderVierge() { print '<html><title>Export agenda cal</title><body>'; }
/**
* Header function
*
* @return void
*/
function llxFooterVierge() { print '</body></html>'; }
require("../../main.inc.php");

View File

@ -211,14 +211,7 @@ if ($socid > 0)
$formfile=new FormFile($db);
// Show upload form
if ($conf->global->MAIN_USE_JQUERY_FILEUPLOAD)
{
$formfile->form_ajaxfileupload($object);
}
else
{
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer);
}
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?socid='.$socid,'',0,0,$user->rights->societe->creer,50,$object);
// List of document
$param='&socid='.$object->id;