Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop_member

This commit is contained in:
Regis Houssin 2017-11-22 09:51:57 +01:00
commit 848a27283b
309 changed files with 36923 additions and 4266 deletions

View File

@ -37,6 +37,7 @@ php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
#- hhvm only with dist: trusty
- nightly
@ -71,6 +72,8 @@ matrix:
env: DB=postgresql
- php: '7.0'
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- php: hhvm
env: DB=postgresql
- php: nightly
@ -123,7 +126,10 @@ install:
if [ "$TRAVIS_PHP_VERSION" = '5.3' ] || [ "$TRAVIS_PHP_VERSION" = '5.4' ] || [ "$TRAVIS_PHP_VERSION" = '5.5' ]; then
composer -n require phpunit/phpunit ^4
fi
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ]; then
composer -n require phpunit/phpunit ^5
fi
if [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require phpunit/phpunit ^5
fi
echo
@ -163,7 +169,7 @@ before_script:
#echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
echo
echo "Enabling Memcached for PHP <= 5.4"
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1 and nightly!
# Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly!
echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini
fi
phpenv rehash
@ -237,7 +243,7 @@ before_script:
echo "Setting up Apache + FPM"
# enable php-fpm
cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
# Copy the included pool
cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf
fi
@ -332,6 +338,7 @@ script:
- |
echo "Unit testing"
phpunit --version
# Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
set -e
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php

View File

@ -15,22 +15,24 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The methode "cloture" on contract were renamed into "closeAll".
* The substitution key for reference of object is now __REF__ whatever is the object (it replaces __ORDERREF__,
* The substitution key for reference of objects is now __REF__ whatever is the object (it replaces __ORDERREF__,
__PROPALREF__, ...)
* The substition key __SIGNATURE__ was renamed into __USER_SIGNATURE__ to follow naming conventions.
* Substitution keys with syntax %XXX% were renamed into __XXX__ to match others.
* Removed old deprecated REST API (APIs found into '/root' section of the REST API explorer in Dolibarr v6).
* Some REST API to access setup features, like dictionaries (country, town, extrafields, ...) were moved into a
common API "/setup".
* The REST API /documents were renamed into /documents/download and /documents/upload.
* Page bank/index.php, bank/bankentries.php and comm/actions/listactions.php were renamed into
bank/list.php, bank/bankentries_list.php and comm/actions/list.php to follow page naming
conventions (so default filter/sort order features can also work).
conventions (so default filter/sort order features can also work for this pages).
* The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed into ORDER_SUPPLIER_STATUS_ORDERED.
* The trigger ORDER_SUPPLIER_STATUS_RECEIVED_ALL was renamed into ORDER_SUPPLIER_STATUS_RECEIVED_COMPLETELY.
* The parameter note into method cloture() is added at end of private note (previously in v6, it replaced).
* The parameter $user is now mandatory for method createFromOrder and createFromPropal.
* Removed js library 'fileupload' that was not used by core code.
* IE8 and earlier and Firefox 12 and earlier (2012) are no more supported.
* IE8 and earlier and Firefox 12 and earlier (< 2012) are no more supported.
***** ChangeLog for 6.0.3 compared to 6.0.2 *****
FIX: #7211 Update qty dispatched on qty change

View File

@ -116,4 +116,15 @@ to get
if ($className == 'Luracast\Restler\string') return;
if ($className == 'Luracast\Restler\mixed') return;
...
Change also file Luracast/Restler/explorer/index.html
+With swagger 2:
* Add line into Util.php to complete function
public static function getShortName($className)
{
// @CHANGE LDR
if (! is_string($className)) return;
//var_dump($className);

View File

@ -46,13 +46,20 @@ then
then
aaupper="GR"
fi
if [ $bb = "EG" ]
then
aaupper="SA"
fi
bblower=`echo $dirshort | nawk -F"_" '{ print tolower($2) }'`
echo "***** Process language "$aa"_"$bb
if [ "$aa" != "$bblower" -a "$dirshort" != "en_US" ]
then
reflang="htdocs/langs/"$aa"_"$aaupper
if [ -d $reflang -a $aa"_"$bb != $aa"_"$aaupper ]
then
echo "***** Process language "$aa"_"$bb" - Search original into "$reflang
echo "***** Search original into "$reflang
echo $dirshort is an alternative language of $reflang
echo ./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2
./dev/translation/strip_language_file.php $aa"_"$aaupper $aa"_"$bb $2

View File

@ -258,9 +258,10 @@ class Subscription extends CommonObject
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0)
function getNomUrl($withpicto=0, $notooltip=0)
{
global $langs;

View File

@ -708,8 +708,8 @@ if ($resql)
{
if (! empty($tabhelp[$id][$value]))
{
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value); // Tooltip on hover
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value); // Tooltip on click
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', 1); // Tooltip on hover
}
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
}

View File

@ -34,8 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
$langs->load("errors");
$langs->load("admin");
$langs->loadLangs(array("errors","admin","modulebuilder"));
$mode=GETPOST('mode', 'alpha');
if (empty($mode)) $mode='common';
@ -1009,9 +1008,21 @@ if ($mode == 'develop')
print '<td>'.$langs->trans("URL").'</td>';
print '</tr>';
print "<tr class=\"oddeven\">\n";
print '<tr class="oddeven" height="80">'."\n";
print '<td align="left">';
//span class="fa fa-bug"></span>
//print '<img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png">';
print '<div class="imgmaxheight50 logo_setup"></div>';
print '</td>';
print '<td>'.$langs->trans("TryToUseTheModuleBuilder").'</td>';
print '<td>'.$langs->trans("SeeTopRightMenu").'</td>';
print '</tr>';
print '<tr class="oddeven" height="80">'."\n";
$url='https://partners.dolibarr.org';
print '<td align="left"><a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png"></a></td>';
print '<td align="left">';
print'<a href="'.$url.'" target="_blank" rel="external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolibarr_preferred_partner_int.png"></a>';
print '</td>';
print '<td>'.$langs->trans("DoliPartnersDesc").'</td>';
print '<td><a href="'.$url.'" target="_blank" rel="external">'.$url.'</a></td>';
print '</tr>';

View File

@ -23,8 +23,6 @@ use Luracast\Restler\Format\UploadFormat;
require_once DOL_DOCUMENT_ROOT.'/main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
/**
* API class for receive files
@ -177,6 +175,8 @@ class Documents extends DolibarrApi
if ($modulepart == 'societe' || $modulepart == 'thirdparty')
{
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
if (!DolibarrApiAccess::$user->rights->societe->lire) {
throw new RestException(401);
}
@ -239,7 +239,7 @@ class Documents extends DolibarrApi
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
*
* @param string $filename Name of file to create ('FA1705-0123')
* @param string $filename Name of file to create ('FA1705-0123.txt')
* @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...)
* @param string $ref Reference of object (This will define subdir automatically and store submited file into it)
* @param string $subdir Subdirectory (Only if ref not provided)
@ -285,15 +285,20 @@ class Documents extends DolibarrApi
if ($modulepart == 'facture' || $modulepart == 'invoice')
{
$modulepart='facture';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db);
}
elseif ($modulepart == 'project')
{
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$object = new Project($this->db);
}
elseif ($modulepart == 'task' || $modulepart == 'project_task')
{
$modulepart = 'project_task';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$object = new Task($this->db);
$task_result = $object->fetch('', $ref);

View File

@ -96,7 +96,7 @@ preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg);
// Set the flag to say to refresh (when we reload the explorer, production must be for API call only)
$refreshcache=false;
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
{
$refreshcache=true;
}
@ -109,7 +109,7 @@ $api = new DolibarrApi($db, '', $refreshcache);
// See https://github.com/Luracast/Restler-API-Explorer for more info.
$api->r->addAPIClass('Luracast\\Restler\\Explorer');
$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat');
$api->r->setSupportedFormats('JsonFormat', 'XmlFormat', 'UploadFormat'); // 'YamlFormat'
$api->r->addAuthenticationClass('DolibarrApiAccess','');
// Define accepted mime types
@ -118,7 +118,7 @@ UploadFormat::$allowedMimeTypes = array('image/jpeg', 'image/png', 'text/plain',
// Call Explorer file for all APIs definitions
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $reg[2] == '/swagger.json/root' || $reg[2] == '/resources.json' || $reg[2] == '/resources.json/root'))
{
// Scan all API files to load them
@ -164,7 +164,7 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
if ($file_searched == 'api_access.class.php') continue;
// Support of the deprecated API.
if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$regapi))
/*if (is_readable($dir_part.$file_searched) && preg_match("/^api_deprecated_(.*)\.class\.php$/i",$file_searched,$regapi))
{
$classname = ucwords($regapi[1]).'Api';
require_once $dir_part.$file_searched;
@ -178,7 +178,8 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING);
}
}
elseif (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi))
else*/
if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi))
{
$classname = ucwords($regapi[1]);
$classname = str_replace('_', '', $classname);
@ -213,15 +214,16 @@ if (! empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/resources.json' |
{
$api->r->addAPIClass($classname, $apiname);
}
//var_dump($api->r);
}
// Call one APIs or one definition of an API
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' && preg_match('/^\/resources.json\/(.+)$/', $reg[2], $regbis) && $regbis[1] != 'root')))
if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root')))
{
$module = $reg[1];
if ($module == 'explorer') // If we call page to explore details of a service
{
$module = $regbis[1];
$module = $regbis[2];
}
$module=strtolower($module);

View File

@ -503,16 +503,16 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (! empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.id']['checked'])) print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['owner']['checked'])) print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['c.libelle']['checked'])) print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.label']['checked'])) print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"],"a.fk_element",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.datep']['checked'])) print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['a.datep2']['checked'])) print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.fk_contact']['checked'])) print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"],"a.fk_contact",$param,"","",$sortfield,$sortorder);
if (! empty($arrayfields['a.fk_element']['checked'])) print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"],"a.fk_element",$param,"","",$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))

View File

@ -153,7 +153,7 @@ if (empty($reshook))
// On choisit les mails non deja envoyes pour ce mailing (statut=0)
// ou envoyes en erreur (statut=-1)
$sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
$sql = "SELECT mc.rowid, mc.fk_mailing, mc.lastname, mc.firstname, mc.email, mc.other, mc.source_url, mc.source_id, mc.source_type, mc.tag";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.statut < 1 AND mc.fk_mailing = ".$object->id;
@ -283,7 +283,7 @@ if (empty($reshook))
}
// Fabrication du mail
$trackid='emailing-'.$obj2->source_type.$obj2->source_id;
$trackid='emailing-'.$obj->fk_mailing.'-'.$obj->rowid;
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing');
if ($mail->error)

View File

@ -2984,7 +2984,7 @@ class Propal extends CommonObject
/**
* Return label of status of proposal (draft, validated, ...)
*
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label
*/
function getLibStatut($mode=0)

View File

@ -3296,13 +3296,13 @@ class Commande extends CommonOrder
/**
* Return status label of Order
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
function getLibStatut($mode)
{
if ($this->facturee && empty($this->billed)) $this->billed=$this->facturee; // For backward compatibility
return $this->LibStatut($this->statut,$this->billed,$mode);
return $this->LibStatut($this->statut, $this->billed, $mode);
}
/**
@ -3310,7 +3310,7 @@ class Commande extends CommonOrder
*
* @param int $statut Id statut
* @param int $billed If invoiced
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
* @param int $donotshowbilled Do not show billed status after order status
* @return string Label of status
*/
@ -3382,6 +3382,17 @@ class Commande extends CommonOrder
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessedShort').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDeliveredShort').' </span>'.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
}
elseif ($mode == 6)
{
if ($statut==self::STATUS_CANCELED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderCanceled').' </span>'.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($statut==self::STATUS_DRAFT) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDraft').' </span>'.img_picto($langs->trans('StatusOrderDraft'),'statut0');
if ($statut==self::STATUS_VALIDATED) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderValidated').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
if ($statut==self::STATUS_SHIPMENTONPROCESS) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderSent').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderToBill').' </span>'.img_picto($langs->trans('StatusOrderToBill'),'statut4');
if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderProcessed').$billedtext.' </span>'.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return '<span class="hideonsmartphone">'.$langs->trans('StatusOrderDelivered').' </span>'.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
}
}

View File

@ -344,7 +344,7 @@ class BankAccounts extends DolibarrApi
/**
* Add a link to an account line
*
* @param int $account_id ID of account
* @param int $id ID of account
* @param int $line_id ID of account line
* @param int $url_id ID to set in the URL {@from body}
* @param string $url URL of the link {@from body}
@ -352,16 +352,16 @@ class BankAccounts extends DolibarrApi
* @param string $type Type of link ('payment', 'company', 'member', ...) {@from body}
* @return int ID of link
*
* @url POST {account_id}/lines/{line_id}/links
* @url POST {id}/lines/{line_id}/links
*/
function addLink($account_id, $line_id, $url_id, $url, $label, $type)
function addLink($id, $line_id, $url_id, $url, $label, $type)
{
if (! DolibarrApiAccess::$user->rights->banque->modifier) {
throw new RestException(401);
}
$account = new Account($this->db);
$result = $account->fetch($account_id);
$result = $account->fetch($id);
if (! $result) {
throw new RestException(404, 'account not found');
}

View File

@ -528,14 +528,14 @@ class PaymentVarious extends CommonObject
$result='';
$label=$langs->trans("ShowVariousPayment").': '.$this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkstart = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$picto='payment';
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref);
$result .= $linkend;
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$this->ref.$linkend;
return $result;
}

View File

@ -138,7 +138,8 @@ if ($result)
if ($typeid) $param.='&amp;typeid='.$typeid;
if ($optioncss != '') $param.='&amp;optioncss='.$optioncss;
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -168,11 +169,11 @@ if ($result)
// Ref
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="3" name="search_ref" value="'.$search_ref.'">';
print '<input class="flat" type="text" size="3" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
// Label
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.$search_label.'"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
// Date
print '<td class="liste_titre">&nbsp;</td>';
@ -286,12 +287,12 @@ if ($result)
$colspan=5;
if (! empty($conf->banque->enabled)) $colspan++;
print '<tr class="liste_total">';
print '<td colspan="'.$colspan.'" class="liste_total">'.$langs->trans("Total").'</td>';
print '<td class="liste_total" align="right">'.price($totalarray['totaldeb'])."</td>";
print '<td class="liste_total" align="right">'.price($totalarray['totalcred'])."</td>";
print '<td></td>';
print '<td></td>';
print '</tr>';
print "</table>";

View File

@ -677,7 +677,7 @@ if (empty($reshook))
$result=$discountcheck->fetch(0,$object->id);
$canconvert=0;
if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed completely and not already converted (see real condition into condition used to show button converttoreduc)
if ($object->type == Facture::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert=1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc)
if (($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert=1; // we can convert credit note into discount if credit note is not payed back and not already converted and amount of payment is 0 (see real condition into condition used to show button converttoreduc)
if ($canconvert)
{
@ -763,17 +763,21 @@ if (empty($reshook))
if (empty($error))
{
// Classe facture
$result = $object->set_paid($user);
if ($result >= 0)
{
if($object->type != Facture::TYPE_DEPOSIT) {
// Classe facture
$result = $object->set_paid($user);
if ($result >= 0)
{
$db->commit();
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
} else {
$db->commit();
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
$db->rollback();
}
}
else
{
@ -4262,7 +4266,7 @@ else if ($id > 0 || ! empty($ref))
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
}
// For deposit invoice
if ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 1 && $resteapayer == 0 && $user->rights->facture->creer && empty($discount->id))
if ($object->type == Facture::TYPE_DEPOSIT && $user->rights->facture->creer && empty($discount->id))
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
}

View File

@ -109,7 +109,7 @@ class FactureRec extends CommonInvoice
$this->nb_gen_max=empty($this->nb_gen_max)?0:$this->nb_gen_max;
$this->auto_validate=empty($this->auto_validate)?0:$this->auto_validate;
$this->generate_pdf = empty($this->generate_pdf)?0:$this->generate_pdf;
$this->db->begin();
// Charge facture modele
@ -356,7 +356,7 @@ class FactureRec extends CommonInvoice
$this->usenewprice = $obj->usenewprice;
$this->auto_validate = $obj->auto_validate;
$this->generate_pdf = $obj->generate_pdf;
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
// Retreive all extrafield for thirdparty
@ -902,6 +902,7 @@ class FactureRec extends CommonInvoice
$sql.= ' WHERE frequency > 0'; // A recurring invoice is an invoice with a frequency
$sql.= " AND (date_when IS NULL OR date_when <= '".$db->idate($today)."')";
$sql.= ' AND (nb_gen_done < nb_gen_max OR nb_gen_max = 0)';
$sql.= ' AND suspended = 0';
$sql.= $db->order('entity', 'ASC');
//print $sql;exit;
@ -940,7 +941,6 @@ class FactureRec extends CommonInvoice
$facture->brouillon = 1;
$facture->date = $facturerec->date_when; // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later.
$facture->socid = $facturerec->socid;
$facture->suspended = 0;
$invoiceidgenerated = $facture->create($user);
if ($invoiceidgenerated <= 0)
@ -1032,12 +1032,11 @@ class FactureRec extends CommonInvoice
* Return label of object status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
* @param integer $alreadypaid Not used
* @return string Label
*/
function getLibStatut($mode=0,$alreadypaid=-1)
function getLibStatut($mode=0)
{
return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, $this->type);
return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, empty($this->type)?0:$this->type);
}
/**
@ -1046,22 +1045,21 @@ class FactureRec extends CommonInvoice
* @param int $recur Is it a recurring invoice ?
* @param int $status Id status (suspended or not)
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto
* @param int $alreadypaid Not used
* @param int $type Type invoice
* @return string Libelle du statut
*/
function LibStatut($recur,$status,$mode=0,$alreadypaid=-1,$type=0)
function LibStatut($recur, $status, $mode=0, $type=0)
{
global $langs;
$langs->load('bills');
//print "$recur,$status,$mode,$alreadypaid,$type";
//print "$recur,$status,$mode,$type";
if ($mode == 0)
{
$prefix='';
if ($recur)
{
if ($status == 1) return $langs->trans('Suspended'); // credit note
if ($status == 1) return $langs->trans('Disabled'); // credit note
else return $langs->trans('Active');
}
else return $langs->trans("Draft");
@ -1071,7 +1069,7 @@ class FactureRec extends CommonInvoice
$prefix='Short';
if ($recur)
{
if ($status == 1) return $langs->trans('Suspended');
if ($status == 1) return $langs->trans('Disabled');
else return $langs->trans('Active');
}
else return $langs->trans("Draft");
@ -1080,7 +1078,7 @@ class FactureRec extends CommonInvoice
{
if ($recur)
{
if ($status == 1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
@ -1090,7 +1088,7 @@ class FactureRec extends CommonInvoice
if ($recur)
{
$prefix='Short';
if ($status == 1) return img_picto($langs->trans('Suspended'),'statut6');
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6');
else return img_picto($langs->trans('Active'),'statut4');
}
else return img_picto($langs->trans('Draft'),'statut0');
@ -1100,7 +1098,7 @@ class FactureRec extends CommonInvoice
$prefix='';
if ($recur)
{
if ($type == 1) return img_picto($langs->trans('Suspended'),'statut6').' '.$langs->trans('Suspended');
if ($status == 1) return img_picto($langs->trans('Disabled'),'statut6').' '.$langs->trans('Disabled');
else return img_picto($langs->trans('Active'),'statut4').' '.$langs->trans('Active');
}
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
@ -1111,7 +1109,7 @@ class FactureRec extends CommonInvoice
if ($mode == 5) $prefix='Short';
if ($recur)
{
if ($status == 1) return '<span class="xhideonsmartphone">'.$langs->trans('Suspended').' </span>'.img_picto($langs->trans('Suspended'),'statut6');
if ($status == 1) return '<span class="xhideonsmartphone">'.$langs->trans('Disabled').' </span>'.img_picto($langs->trans('Disabled'),'statut6');
else return '<span class="xhideonsmartphone">'.$langs->trans('Active').' </span>'.img_picto($langs->trans('Active'),'statut4');
}
else return $langs->trans('Draft').' '.img_picto($langs->trans('Active'),'statut0');

View File

@ -359,6 +359,54 @@ if (empty($reshook))
$object->setModelpdf(GETPOST('modelpdf', 'alpha'));
}
// Set status disabled
elseif ($action == 'disable' && $user->rights->facture->creer)
{
$db->begin();
$object->fetch($id);
$res = $object->setValueFrom('suspended', 1);
if ($res <= 0)
{
$error++;
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Set status enabled
elseif ($action == 'enable' && $user->rights->facture->creer)
{
$db->begin();
$object->fetch($id);
$res = $object->setValueFrom('suspended', 0);
if ($res <= 0)
{
$error++;
}
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
}
// Delete line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
@ -831,30 +879,30 @@ if (empty($reshook))
// Update line
if (! $error)
{
$result = $object->updateline(
GETPOST('lineid'),
$description,
$pu_ht,
$qty,
$vat_rate,
$localtax1_rate,
$localtax1_rate,
GETPOST('productid'),
GETPOST('remise_percent'),
'HT',
$info_bits,
0,
0,
$type,
0,
$special_code,
$label,
GETPOST('units')
);
if ($result >= 0)
{
$result = $object->updateline(
GETPOST('lineid'),
$description,
$pu_ht,
$qty,
$vat_rate,
$localtax1_rate,
$localtax1_rate,
GETPOST('productid'),
GETPOST('remise_percent'),
'HT',
$info_bits,
0,
0,
$type,
0,
$special_code,
$label,
GETPOST('units')
);
if ($result >= 0)
{
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
@ -1098,10 +1146,17 @@ if ($action == 'create')
print "</td></tr>";
// Auto generate document
print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
$select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc'));
print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
print "</td></tr>";
if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
{
print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
$select = array('0'=>$langs->trans('DoNotGenerateDoc'),'1'=>$langs->trans('AutoGenerateDoc'));
print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
print "</td></tr>";
}
else
{
print '<input type="hidden" name="generate_pdf" value="1">';
}
print "</table>";
@ -1325,8 +1380,8 @@ else
$substitutionarray['__INVOICE_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample,'%Y').')';
$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'),'%Y').')';
// Only on template invoices
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency),'dayhour').')';
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when?$object->date_when:dol_now()), 'dayhour').')';
$substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when?$object->date_when:dol_now()), $object->frequency, $object->unit_frequency),'dayhour').')';
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($substitutionarray as $key => $val)
@ -1512,19 +1567,28 @@ else
}
print '</td>';
// Auto generate documents
print '<tr><td>';
if ($action == 'generate_pdf' || $object->frequency > 0)
print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
else
print $langs->trans("StatusOfGeneratedDocuments");
print '</td><td>';
$select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
if ($action == 'generate_pdf' || $object->frequency > 0)
if (! empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION))
{
print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
print '<tr>';
print '<td>';
if ($action == 'generate_pdf' || $object->frequency > 0)
print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
else
print $langs->trans("StatusOfGeneratedDocuments");
print '</td>';
print '<td>';
$select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
if ($action == 'generate_pdf' || $object->frequency > 0)
{
print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
}
print '</td>';
print '</tr>';
}
else
{
print '<input type="hidden" name="generate_pdf" value="1">';
}
print '</td>';
print '</tr>';
print '</table>';
@ -1616,10 +1680,10 @@ else
*/
print '<div class="tabsAction">';
//if ($object->statut == Facture::STATUS_DRAFT) // there is no draft status on templates.
//{
if ($user->rights->facture->creer)
if (empty($object->suspended))
{
if ($user->rights->facture->creer)
{
if (! empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max))
{
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>';
@ -1628,19 +1692,31 @@ else
{
if (empty($object->frequency) || $object->date_when <= $today)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;socid='.$object->thirdparty->id.'&amp;fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>';
}
}
}
}
else
{
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("CreateBill").'</a></div>';
}
//}
}
}
if ($user->rights->facture->creer)
{
if (empty($object->suspended))
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?action=disable&id='.$object->id.'">'.$langs->trans("Disable").'</a></div>';
}
else
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/fiche-rec.php?action=enable&id='.$object->id.'">'.$langs->trans("Enable").'</a></div>';
}
}
//if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
if ($user->rights->facture->supprimer)

View File

@ -215,7 +215,7 @@ $today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year'
* List mode
*/
$sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,";
$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,";
$sql.= " f.datec, f.tms,";
$sql.= " f.fk_cond_reglement, f.fk_mode_reglement";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
@ -500,7 +500,7 @@ if ($resql)
if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.datec","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.tms","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER['PHP_SELF'],"f.suspended,f.frequency","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'nomaxwidthsearch ')."\n";
print "</tr>\n";
@ -518,7 +518,7 @@ if ($resql)
$invoicerectmp->id=$objp->id;
$invoicerectmp->frequency=$objp->frequency;
$invoicerectmp->suspend=$objp->suspend;
$invoicerectmp->suspended=$objp->suspended;
$invoicerectmp->unit_frequency=$objp->unit_frequency;
$invoicerectmp->nb_gen_max=$objp->nb_gen_max;
$invoicerectmp->nb_gen_done=$objp->nb_gen_done;
@ -632,7 +632,7 @@ if ($resql)
}
// Action column
print '<td align="center">';
if ($user->rights->facture->creer)
if ($user->rights->facture->creer && empty($invoicerectmp->suspended))
{
if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today)
{

View File

@ -500,14 +500,16 @@ class PaymentSalary extends CommonObject
$result='';
$label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
$link = '<a href="'.DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkstart = '<a href="'.DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend='</a>';
$picto='payment';
if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$link.$this->ref.$linkend;
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend;
return $result;
}

View File

@ -1090,6 +1090,10 @@ if ($action == 'create')
$objectsrc->fetch(GETPOST('originid'));
if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines();
$objectsrc->fetch_thirdparty();
// Replicate extrafields
$objectsrc->fetch_optionals($originid);
$object->array_options = $objectsrc->array_options;
$projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');

View File

@ -450,7 +450,6 @@ class Contracts extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
$updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
if ($updateRes > 0) {
return $this->get($id);

View File

@ -33,7 +33,7 @@ $var=true;
foreach($linkedObjectBlock as $key => $objectlink)
{
$ilink++;
$trclass=($var?'pair':'impair');
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total';
?>
@ -42,7 +42,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td>
<td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td>
<td align="right">&nbsp;</td>
<td align="right"><?php // var_dump($objectlink->total_ttc); ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
</tr>

View File

@ -18,35 +18,58 @@
* or see http://www.gnu.org/
*/
// Variable $upload_dir must be defined when entering here
// Variable $upload_dir must be defined when entering here.
// Variable $upload_dirold may also exists.
// Variable $confirm must be defined.
//var_dump($upload_dir);
//var_dump($upload_dirold);
// Submit file/link
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
if (GETPOST('sendit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id)
{
if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
else
$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
}
if (! empty($_FILES))
{
if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
else $userfiles=array($_FILES['userfile']['tmp_name']);
foreach($userfiles as $key => $userfile)
{
if (empty($_FILES['userfile']['tmp_name'][$key]))
{
$error++;
if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
}
else {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
}
}
}
if (! $error)
{
if (! empty($upload_dirold) && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
$result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
}
elseif (! empty($upload_dir))
{
$result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'));
}
}
}
}
elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
elseif (GETPOST('linkit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if ($object->id)
$link = GETPOST('link', 'alpha');
if ($link)
{
$link = GETPOST('link', 'alpha');
if ($link)
{
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
$link = 'http://' . $link;
}
dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link);
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
$link = 'http://' . $link;
}
dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link);
}
}
@ -54,8 +77,6 @@ elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($object->id)
{
$urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
if (GETPOST('section', 'alpha')) $file = $upload_dir . "/" . $urlfile; // For a delete of GED module urlfile contains full path from upload_dir
else // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
@ -71,8 +92,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
$ret = dol_delete_file($file, 0, 0, 0, $object);
if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, $object); // Delete file using old path
$ret = dol_delete_file($file, 0, 0, 0, (is_object($object)?$object:null));
if (! empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object)?$object:null)); // Delete file using old path
// Si elle existe, on efface la vignette
if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i',$file,$regs))
@ -112,9 +133,20 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
}
}
}
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.(!empty($withproject)?'&withproject=1':''));
exit;
}
if (is_object($object) && $object->id > 0)
{
if ($backtopage)
{
header('Location: ' . $backtopage);
exit;
}
else
{
header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.(!empty($withproject)?'&withproject=1':''));
exit;
}
}
}
elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('link', 'alpha'))
{
@ -142,45 +174,44 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l
//error fetching
}
}
elseif ($action == 'renamefile' && GETPOST('renamefilesave'))
elseif ($action == 'renamefile' && GETPOST('renamefilesave','alpha'))
{
if ($object->id)
// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
if (! empty($upload_dir))
{
// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
//var_dump($upload_dir);exit;
if (! empty($upload_dir))
$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'));
$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'));
// Security:
// Disallow file with some extensions. We rename them.
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
{
$filenamefrom=dol_sanitizeFileName(GETPOST('renamefilefrom','alpha'));
$filenameto=dol_sanitizeFileName(GETPOST('renamefileto','alpha'));
$filenameto.= '.noexe';
}
// Security:
// Disallow file with some extensions. We rename them.
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
if (preg_match('/\.htm|\.html|\.php|\.pl|\.cgi$/i',$filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
if ($filenamefrom && $filenameto)
{
$srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto;
$result = dol_move($srcpath, $destpath);
if ($result)
{
$filenameto.= '.noexe';
if ($object->id)
{
$object->addThumbs($destpath);
}
// TODO Add revert function of addThumbs to remove for old name
//$object->delThumbs($srcpath);
setEventMessages($langs->trans("FileRenamed"), null);
}
if ($filenamefrom && $filenameto)
else
{
$srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto;
$result = dol_move($srcpath, $destpath);
if ($result)
{
$object->addThumbs($destpath);
// TODO Add revert function of addThumbs
//$object->delThumbs($srcpath);
setEventMessages($langs->trans("FileRenamed"), null);
}
else
{
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFailToRenameFile", $filenamefrom, $filenameto), null, 'errors');
}
}
}

View File

@ -229,11 +229,12 @@ if ($type == 'directory')
$relativepath=GETPOST('file','alpha');
if ($relativepath && $relativepath!= '/') $relativepath.='/';
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
if (GETPOSTISSET('website'))
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
{
$param.='&file_manager=1';
if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid);
}
}
else
@ -289,40 +290,70 @@ if ($type == 'directory')
}
//if ($section)
//{
$useajax=1;
if (! empty($conf->dol_use_jmobile)) $useajax=0;
if (empty($conf->use_javascript_ajax)) $useajax=0;
if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
// Bottom of page
$useajax=1;
if (! empty($conf->dol_use_jmobile)) $useajax=0;
if (empty($conf->use_javascript_ajax)) $useajax=0;
if (! empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax=0;
if ($useajax || $action == 'delete')
//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
if ($useajax || $action == 'delete')
{
$urlfile='';
if ($action == 'delete') $urlfile=GETPOST('urlfile','alpha');
if (empty($section_dir)) $section_dir=GETPOST("file","alpha");
$section_id=$section;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$useglobalvars=1;
$form = new Form($db);
$formquestion['urlfile']=array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later
$formquestion['section']=array('type'=>'hidden','value'=>$section,'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later
$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later
$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later
if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
if (! empty($website)) $formquestion['website']=array('type'=>'hidden','value'=>$website,'name'=>'website');
if (! empty($pageid) && $pageid > 0) $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
}
if ($useajax)
{
print '<script type="text/javascript">';
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
// Wrapper to manage document_preview
if ($conf->browser->layout != 'phone')
{
$urlfile='';
if ($action == 'delete') $urlfile=GETPOST('urlfile');
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$useglobalvars=1;
$form = new Form($db);
$formquestion=array(
'urlfile'=>array('type'=>'hidden','value'=>$urlfile,'name'=>'urlfile'),
'section'=>array('type'=>'hidden','value'=>$section,'name'=>'section')
);
print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
print "\n/* JS CODE TO ENABLE document_preview */\n";
print '
jQuery(document).ready(function () {
jQuery(".documentpreview").click(function () {
console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\'));
document_preview($(this).attr(\'href\'), $(this).attr(\'mime\'), \''.dol_escape_js($langs->transnoentities("Preview")).'\');
return false;
});
});
' . "\n";
}
if ($useajax)
{
// Enable jquery handlers button to delete files
print '<script type="text/javascript">'."\n";
print 'jQuery(document).ready(function() {'."\n";
print 'jQuery(".deletefilelink").click(function(e) { console.log("We click on button with class deletefilelink"); jQuery("#urlfile").val(jQuery(this).attr("rel")); jQuery("#dialog-confirm-deletefile").dialog("open"); return false; });'."\n";
print '});'."\n";
print '</script>'."\n";
}
//}
// Enable jquery handlers button to delete files
print 'jQuery(document).ready(function() {'."\n";
print ' jQuery(".deletefilelink").click(function(e) { '."\n";
print ' console.log("We click on button with class deletefilelink, param='.$param.', we set urlfile to "+jQuery(this).attr("rel"));'."\n";
print ' jQuery("#urlfile").val(jQuery(this).attr("rel"));'."\n";
//print ' jQuery("#section_dir").val(\'aaa\');'."\n";
print ' jQuery("#dialog-confirm-deletefile").dialog("open");'."\n";
print ' return false;'."\n";
print ' });'."\n";
print '});'."\n";
print '</script>'."\n";
}
// Close db if mode is not noajax
if ((! isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();

View File

@ -198,10 +198,13 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
print '</td>';
// Edit link
print '<td align="right" width="18"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']).'">'.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').'</a></td>';
print '<td align="right" width="18"><a href="';
print DOL_URL_ROOT.'/ecm/dir_card.php?module='.urlencode($modulepart).'&section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']);
print '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid);
print '">'.img_view($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle"').'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';
//print '<td align="right" width="14">&nbsp;</td>';
// Info
@ -230,7 +233,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
}
}
// Enable jquery handlers on new generated HTML objects
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip (reload into ajaxdirtree) -->\n";
print '<script type="text/javascript">

View File

@ -957,6 +957,7 @@ class CMailFile
$out.= 'Message-ID: <' . time() . '.phpmail@' . $host . ">" . $this->eol2;
}
if (! empty($_SERVER['REMOTE_ADDR'])) $out.= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. $this->eol2;
$out.= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol2;
$out.= "Mime-Version: 1.0".$this->eol2;

View File

@ -612,15 +612,16 @@ abstract class CommonObject
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$forcedownload=1;
$rellink='/document.php?modulepart='.$modulepart;
if ($forcedownload) $rellink.='&attachment=1';
if (! empty($ecmfile->entity)) $rellink.='&entity='.$ecmfile->entity;
//$rellink.='&file='.urlencode($filepath); // No need of name of file for public link, we will use the hash
$fulllink=$urlwithroot.$rellink;
//if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path
//elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content
if (! empty($ecmfile->share)) $fulllink.='&hashp='.$ecmfile->share; // Hash for public share
$forcedownload=0;
$paramlink='';
//if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required.
//if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; // For sharing with hash (so public files), entity is not required.
//$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash
if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share
if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
$fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
// Here $ecmfile->share is defined
return $fulllink;
@ -4212,8 +4213,9 @@ abstract class CommonObject
/*$this->result['fullname']=$destfull;
$this->result['filepath']=$ecmfile->filepath;
$this->result['filename']=$ecmfile->filename;*/
//var_dump($obj->update_main_doc_field);exit;
// Update the last_main_doc field into main object
// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
$update_main_doc_field=0;
if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
if ($update_main_doc_field && ! empty($this->table_element))

View File

@ -817,6 +817,8 @@ class ExtraFields
$form=new Form($this->db);
}
$out='';
$keyprefix = $keyprefix.'options_'; // Because we work on extrafields
$label=$this->attribute_label[$key];

View File

@ -410,12 +410,13 @@ class Form
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
* @param string $incbefore Include code before the text
* @param int $noencodehtmltext Do not encode into html entity the htmltext
* @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
* @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
* @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only)
* @return string Code html du tooltip (texte+picto)
* @see Use function textwithpicto if you can.
* TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip
*/
function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger='')
function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger='', $forcenowrap=0)
{
global $conf;
@ -462,7 +463,7 @@ class Form
}
else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag
if (empty($notabs)) $s.='<table class="nobordernopadding" summary=""><tr style="height: auto;">';
elseif ($notabs == 2) $s.='<div class="inline-block">';
elseif ($notabs == 2) $s.='<div class="inline-block'.($forcenowrap?' nowrap':'').'">';
// Define value if value is before
if ($direction < 0) {
$s.='<'.$tag.$paramfortooltipimg;
@ -497,9 +498,10 @@ class Form
* @param int $noencodehtmltext Do not encode into html entity the htmltext
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
* @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
* @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only)
* @return string HTML code of text, picto, tooltip
*/
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='')
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='', $forcenowrap=0)
{
global $conf, $langs;
@ -534,7 +536,7 @@ class Form
elseif ($type == 'warning') $img = img_warning($alt);
else $img = img_picto($alt, $type);
return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger);
return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
}
/**
@ -3542,7 +3544,7 @@ class Form
* print '});'."\n";
* print '</script>'."\n";
*
* @param string $page Url of page to call if confirmation is OK
* @param string $page Url of page to call if confirmation is OK. Can contains paramaters (param 'action' and 'confirm' will be reformated)
* @param string $title Title
* @param string $question Question
* @param string $action Action

View File

@ -55,24 +55,25 @@ class FormFile
/**
* Show form to upload a new file
* Show form to upload a new file.
*
* @param string $url Url
* @param string $title Title zone (Title or '' or 'none')
* @param int $addcancel 1=Add 'Cancel' button
* @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. Deprecated.
* @param int $addcancel 1=Add 'Cancel' button
* @param int $sectionid If upload must be done inside a particular ECM section (is sectionid defined, sectiondir must not be)
* @param int $perm Value of permission to allow upload
* @param int $size Length of input file area. Deprecated.
* @param Object $object Object to use (when attachment is done on an element)
* @param string $options Add an option column
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). 2 should never be used.
* @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). @deprecated 2 should never be used and if 1 is used, option should no be enabled.
* @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
* @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files
* @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
* @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*')
* @return int <0 if KO, >0 if OK
* @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be)
* @return int <0 if KO, >0 if OK
*/
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='')
function form_attach_new_file($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='', $sectiondir='')
{
global $conf,$langs, $hookmanager;
$hookmanager->initHooks(array('formfile'));
@ -103,7 +104,7 @@ class FormFile
if ($title != 'none') $out.=load_fiche_titre($title, null, null);
$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="">';
$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
$out .= '<input type="hidden" id="'.$htmlname.'_section_id" name="section_id" value="'.$sectionid.'">';
$out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -1067,7 +1068,7 @@ class FormFile
$nboffiles=count($filearray);
if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$var=true; $i=0; $nboflines = 0; $lastrowid=0;
$i=0; $nboflines = 0; $lastrowid=0;
foreach($filearray as $key => $file) // filearray must be only files here
{
if ($file['name'] != '.'
@ -1082,7 +1083,9 @@ class FormFile
print '<!-- Line list_of_documents '.$key.' relativepath = '.$relativepath.' -->'."\n";
// Do we have entry into database ?
print '<!-- In database: position='.$filearray[$key]['position'].' -->'."\n";
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'" '.$bcdd[$var].'>';
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'">';
// File name
print '<td class="tdoverflowmax300">';
// Show file name with link to download
@ -1095,9 +1098,11 @@ class FormFile
print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'],0,0).')', 'inline-block valignbottom paddingright');
if ($showrelpart == 1) print $relativepath;
//print dol_trunc($file['name'],$maxlength,'middle');
if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile')))
if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile','alpha')))
{
print '</a>';
$section_dir=dirname(GETPOST('urlfile','alpha'));
print '<input type="hidden" name="section_dir" value="'.$section_dir.'">';
print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file['name']).'">';
print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file['name']).'">';
$editline=1;
@ -1107,12 +1112,17 @@ class FormFile
print $file['name'];
print '</a>';
}
// Preview link
if (! $editline) print $this->showPreview($file, $modulepart, $filepath);
// Public share link
if (! $editline && ! empty($filearray[$key]['hashp'])) print 'ee';
print "</td>\n";
// Size
print '<td align="right" width="80px">'.dol_print_size($file['size'],1,1).'</td>';
// Date
print '<td align="center" width="130px">'.dol_print_date($file['date'],"dayhour","tzuser").'</td>';
// Preview
@ -1142,7 +1152,7 @@ class FormFile
print '<td class="valignmiddle right actionbuttons"><!-- action on files -->';
if ($useinecm == 1)
{
print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view('default', 0, 'class="paddingrightonly"').'</a>';
print '<a href="'.DOL_URL_ROOT.'/ecm/file_card.php?urlfile='.urlencode($file['name']).$param.'" class="editfilelink" rel="'.urlencode($file['name']).'">'.img_view('default', 0, 'class="paddingrightonly"').'</a>';
}
if (! $useinecm || $useinecm == 2)
{
@ -1260,7 +1270,7 @@ class FormFile
* @param int $addfilterfields Add line with filters
* @return int <0 if KO, nb of files shown if OK
*/
function list_of_autoecmfiles($upload_dir,$filearray,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$url='',$addfilterfields=0)
function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload=0, $relativepath='', $permtodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0)
{
global $user, $conf, $langs, $form;
global $bc;
@ -1379,7 +1389,6 @@ class FormFile
$object_instance=new ExpenseReport($this->db);
}
$var=true;
foreach($filearray as $key => $file)
{
if (!is_dir($file['name'])
@ -1607,11 +1616,9 @@ class FormFile
$nboflinks = count($links);
if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$var = true;
foreach ($links as $link)
{
$var =! $var;
print '<tr ' . $bc[$var] . '>';
print '<tr class="oddeven">';
//edit mode
if ($action == 'update' && $selected === $link->id)
{
@ -1673,7 +1680,7 @@ class FormFile
* @param array $file File
* @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs
* @param string $ruleforpicto Rule for picto: 0=Preview picto, 1=Use picto of mime type of file)
* @param string $ruleforpicto Rule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file)
* @param string $param More param on http links
* @return string $out Output string with HTML
*/

View File

@ -1283,6 +1283,7 @@ class SMTPs
{
$_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
}
if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n";
if ( $this->getMoreInHeader() )
$_header .= $this->getMoreInHeader(); // Value must include the "\r\n";

View File

@ -98,12 +98,13 @@ class Translate
// We redefine $srclang
$langpart=explode("_",$codetouse);
//print "Short before _ : ".$langpart[0].'/ Short after _ : '.$langpart[1].'<br>';
//print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'<br>';
if (! empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
{
// Array force long code from first part, even if long code is defined
$longforshort=array('ar'=>'ar_SA');
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
$longforshortexcep=array('ar_EG');
if (isset($longforshort[strtolower($langpart[0])]) && ! in_array($codetouse, $longforshortexcep)) $srclang=$longforshort[strtolower($langpart[0])];
else if (! is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
$longforlong=array('no_nb'=>'nb_NO');
@ -339,7 +340,8 @@ class Translate
// This function MUST NOT contains call to syslog
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
$langofdir=strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not el_EL but el_GR
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
$this->load($domain,$alt+1,$stopafterdirection,$langofdir);
}

View File

@ -280,7 +280,7 @@ interface Database
/**
* Create a table into database
*
* @param string $table Nom de la table
* @param string $table Name of table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
@ -291,6 +291,14 @@ interface Database
*/
function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null);
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
function DDLDropTable($table);
/**
* Return list of available charset that can be used to store data in database
*

View File

@ -863,6 +863,22 @@ class DoliDBMssql extends DoliDB
return 1;
}
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
function DDLDropTable($table)
{
$sql = "DROP TABLE ".$table;
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* Return a pointer of line with description of a table or field
*

View File

@ -629,7 +629,7 @@ class DoliDBMysqli extends DoliDB
/**
* Create a table into database
*
* @param string $table Nom de la table
* @param string $table Name of table
* @param array $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
@ -702,13 +702,28 @@ class DoliDBMysqli extends DoliDB
$sql .= ",".implode(',',$sqlk);
$sql .=") engine=".$type;
dol_syslog($sql,LOG_DEBUG);
if(! $this -> query($sql))
if(! $this->query($sql))
return -1;
else
return 1;
}
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
function DDLDropTable($table)
{
$sql = "DROP TABLE ".$table;
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* Return a pointer of line with description of a table or field
*

View File

@ -999,6 +999,22 @@ class DoliDBPgsql extends DoliDB
return 1;
}
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
function DDLDropTable($table)
{
$sql = "DROP TABLE ".$table;
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* Create a user to connect to database
*

View File

@ -945,6 +945,22 @@ class DoliDBSqlite3 extends DoliDB
return 1;
}
/**
* Drop a table into database
*
* @param string $table Name of table
* @return int <0 if KO, >=0 if OK
*/
function DDLDropTable($table)
{
$sql = "DROP TABLE ".$table;
if (! $this->query($sql))
return -1;
else
return 1;
}
/**
* Return a pointer of line with description of a table or field
*

View File

@ -1,41 +0,0 @@
// Copyright (C) 2011 Regis Houssin <regis.houssin@capnetworks.com>
// Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// or see http://www.gnu.org/
//
//
// \file htdocs/core/js/jnotify.js
// \brief File that include javascript functions for jnotify default options
//
$(document).ready(function() {
$.jnotify.setup({
delay: 3000 // the default time to show each notification (in milliseconds)
, sticky: false // determines if the message should be considered "sticky" (user must manually close notification)
, closeLabel: "&times;" // the HTML to use for the "Close" link
, showClose: true // determines if the "Close" link should be shown if notification is also sticky
, fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
, slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
, classContainer: "jnotify-container"
, classNotification: "jnotify-notification"
, classBackground: "jnotify-background"
, classClose: "jnotify-close"
, classMessage: "jnotify-message"
, init: null // callback that occurs when the main jnotify container is created
, create: null // callback that occurs when when the note is created (occurs just before appearing in DOM)
, beforeRemove: null // callback that occurs when before the notification starts to fade away
});
});

View File

@ -44,6 +44,7 @@ else header('Cache-Control: no-cache');
//var_dump($conf);
// Wrapper to show tooltips (html or onclick popup)
if (empty($conf->dol_no_mouse_hover))
{
@ -107,7 +108,7 @@ if (! defined('JS_JQUERY_DISABLE_DROPDOWN'))
});
$(document).bind(\'click\', function (e) {
// TODO Use a bind on elements in dropdown only to avoid to bind/code all clicks
//console.log("We click outside of dropdown, so we close it.");
var $clicked = $(e.target);
if (!$clicked.parents().hasClass("dropdown")) $(".dropdown dd ul").hide();
});

View File

@ -919,8 +919,8 @@ function document_preview(file, type, title)
if (mode == 'image' && showOriginalSizeButton)
{
optionsbuttons = {
"<?php echo dol_escape_js($langs->trans("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); },
"<?php echo dol_escape_js($langs->trans("Close")); ?>": function() { $( this ).dialog( "close" ); }
"<?php echo dol_escape_js($langs->transnoentitiesnoconv("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); },
"<?php echo dol_escape_js($langs->transnoentitiesnoconv("Close")); ?>": function() { $( this ).dialog( "close" ); }
};
}
@ -1062,3 +1062,28 @@ function price2numjs(amount) {
}
<?php
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) {
?>
// Defined properties for JNotify
$(document).ready(function() {
$.jnotify.setup({
delay: 3000 // the default time to show each notification (in milliseconds)
, sticky: false // determines if the message should be considered "sticky" (user must manually close notification)
, closeLabel: "&times;" // the HTML to use for the "Close" link
, showClose: true // determines if the "Close" link should be shown if notification is also sticky
, fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
, slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
, classContainer: "jnotify-container"
, classNotification: "jnotify-notification"
, classBackground: "jnotify-background"
, classClose: "jnotify-close"
, classMessage: "jnotify-message"
, init: null // callback that occurs when the main jnotify container is created
, create: null // callback that occurs when when the note is created (occurs just before appearing in DOM)
, beforeRemove: null // callback that occurs when before the notification starts to fade away
});
});
<?php } ?>
// End of lib_head.js.php

View File

@ -68,18 +68,30 @@ function ecm_prepare_dasboard_head($object)
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @param string $module Module
* @param string $section Section
* @return array Array of tabs to show
*/
function ecm_prepare_head($object)
function ecm_prepare_head($object, $module='ecm', $section='')
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/ecm/docmine.php?section='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
if ($module == 'ecm')
{
$head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
}
else
{
$head[$h][0] = DOL_URL_ROOT.'/ecm/dir_card.php?section='.$section.'&module='.$module;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
}
return $head;
}
@ -96,7 +108,7 @@ function ecm_file_prepare_head($object)
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/ecm/docfile.php?section='.$object->section_id.'&urlfile='.urlencode($object->label);
$head[$h][0] = DOL_URL_ROOT.'/ecm/file_card.php?section='.$object->section_id.'&urlfile='.urlencode($object->label);
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;

View File

@ -46,7 +46,7 @@ function dol_basename($pathfile)
* @param int $recursive Determines whether subdirectories are searched
* @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function,
* but must not contains the start and end '/'. Filter is checked into basename only.
* @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath.
* @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx').
* @param string $sortcriteria Sort criteria ('','fullname','relativename','name','date','size')
* @param string $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
@ -107,6 +107,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
while (false !== ($file = readdir($dir))) // $file is always a basename (into directory $newpath)
{
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory
$fullpathfile=($newpath?$newpath.'/':'').$file;
$qualified=1;
@ -120,10 +121,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
// Check if file is qualified
foreach($excludefilterarray as $filt)
{
if (preg_match('/'.$filt.'/i',$file)) {
if (preg_match('/'.$filt.'/i', $file) || preg_match('/'.$filt.'/i', $fullpathfile)) {
$qualified=0; break;
}
}
//print $fullpathfile.' '.$file.' '.$qualified.'<br>';
if ($qualified)
{

View File

@ -1433,6 +1433,9 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
$morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
}
else {
$morehtmlstatus.=$object->getLibStatut(6);
}
}
elseif ($object->element == 'product')
{
@ -1458,13 +1461,13 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
elseif ($object->element == 'contrat' || $object->element == 'contract')
{
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
if ($object->statut == 0) $morehtmlstatus.=$object->getLibStatut(5);
else $morehtmlstatus.=$object->getLibStatut(4);
}
elseif ($object->element == 'facturerec')
{
if ($object->frequency==0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(4);
if ($object->frequency == 0) $morehtmlstatus.=$object->getLibStatut(2);
else $morehtmlstatus.=$object->getLibStatut(5);
}
else { // Generic case
$tmptxt=$object->getLibStatut(6);
@ -2560,7 +2563,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
var number=series.data[0][1];
return \'';
print '<div style="font-size:8pt;text-align:center;padding:2px;color:black;">';
if ($url) print '<a style="color: #FFFFFF;" border="0" href="'.$url.'=">';
if ($url) print '<a style="color: #FFFFFF;" border="0" href="'.$url.'">';
print '\'+'.($showlegend?'number':'label+\' \'+number');
if (! empty($showpercent)) print '+\'<br/>\'+percent+\'%\'';
print '+\'';
@ -4517,6 +4520,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
{
$product->get_buyprice($idprodfournprice,0,0,0);
$ret=$product->vatrate_supplier;
if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')';
}
else
{

View File

@ -1163,7 +1163,7 @@ function get_string_between($string, $start, $end){
*
* @param string $mask Mask to use
* @param string $value Value
* @return int <0 if KO, 0 if OK
* @return int|string <0 or error string if KO, 0 if OK
*/
function check_value($mask,$value)
{
@ -1249,6 +1249,7 @@ function check_value($mask,$value)
if (dol_strlen($value) != $len) $result=-1;
// Define $maskLike
/* seems not used
$maskLike = dol_string_nospecial($mask);
$maskLike = str_replace("%","_",$maskLike);
// Replace protected special codes with matching number of _ as wild card caracter
@ -1259,7 +1260,7 @@ function check_value($mask,$value)
$maskLike = str_replace(dol_string_nospecial('{dd}'),'__',$maskLike);
$maskLike = str_replace(dol_string_nospecial('{'.$masktri.'}'),str_pad("",dol_strlen($maskcounter),"_"),$maskLike);
if ($maskrefclient) $maskLike = str_replace(dol_string_nospecial('{'.$maskrefclient.'}'),str_pad("",strlen($maskrefclient),"_"),$maskLike);
*/
dol_syslog("functions2::check_value result=".$result,LOG_DEBUG);
return $result;

View File

@ -700,7 +700,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
{
print $formother->showColor($conf->global->THEME_ELDY_TEXTTITLENOTAB, $langs->trans("Default"));
}
print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #643c14">643c14</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';

View File

@ -267,14 +267,14 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
{
global $conf;
$res = 0;
$result = 0;
// Get Mask value
$mask = empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)?'':$conf->global->BARCODE_STANDARD_PRODUCT_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return '';
return -1;
}
dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest);
@ -292,6 +292,11 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
}
$result=check_value($mask,$newcodefortest);
if (is_string($result))
{
$this->error = $result;
return -1;
}
return $result;
}

View File

@ -139,6 +139,8 @@ class modOauth extends DolibarrModules
// Clean before activation
$this->remove($options);
return $this->_init($sql,$options);
$sql = array();
return $this->_init($sql, $options);
}
}

View File

@ -64,6 +64,7 @@ class modWebServices extends DolibarrModules
//-------------
$this->depends = array();
$this->requiredby = array();
//$this->phpmax = array(7,1); // Maximum version of PHP required by module
$this->langfiles = array("other");
// Constants

View File

@ -229,6 +229,7 @@ class mod_codeproduct_elephant extends ModeleProductCode
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
* -5 Other (see this->error)
*/
function verif($db, &$code, $product, $type)
{
@ -256,10 +257,15 @@ class mod_codeproduct_elephant extends ModeleProductCode
if (! $mask)
{
$this->error='NotConfigured';
return '';
return -5;
}
$result=check_value($mask,$code);
if (is_string($result))
{
$this->error = $result;
return -5;
}
}
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);

View File

@ -247,6 +247,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
* -2 ErrorCustomerCodeRequired
* -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired
* -5 Other (see this->error)
*/
function verif($db, &$code, $soc, $type)
{
@ -274,10 +275,15 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
if (! $mask)
{
$this->error='NotConfigured';
return '';
return -5;
}
$result=check_value($mask,$code);
if (is_string($result))
{
$this->error = $result;
return -5;
}
}
dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);

View File

@ -19,7 +19,7 @@
*/
?>
<!-- BEGIN PHP TEMPLATE ecm/tpl/filemanager.tpl.php -->
<!-- BEGIN PHP TEMPLATE core/tpl/filemanager.tpl.php -->
<!-- Doc of fileTree plugin at http://www.abeautifulsite.net/blog/2008/03/jquery-file-tree/ -->
<?php
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
if (empty($module)) $module='ecm';
$permtoadd = 0;
$permtoupload = 1;
$permtoupload = 0;
if ($module == 'ecm')
{
$permtoadd = $user->rights->ecm->setup;
@ -46,6 +46,7 @@ if ($module == 'medias')
// Confirm remove file (for non javascript users)
if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax))
{
// TODO Add website, pageid, filemanager if defined
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
}
@ -65,7 +66,7 @@ print '<div class="inline-block toolbarbutton centpercent">';
if ($permtoadd)
{
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&module='.urlencode($module).($website?'&website='.$website:'').($pageid?'&pageid='.$pageid:'').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid).'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create&module='.urlencode($module).($website?'&website='.$website:'').($pageid?'&pageid='.$pageid:'').'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid).'" class="inline-block valignmiddle toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
@ -103,9 +104,11 @@ if ((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABL
<?php
}
$sectiondir=GETPOST('file','alpha');
print '<!-- Start form to attach new file in filemanager.tpl.php sectionid='.$section.' sectiondir='.$sectiondir.' -->'."\n";
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile);
$formfile->form_attach_new_file($_SERVER["PHP_SELF"], 'none', 0, ($section?$section:-1), $permtoupload, 48, null, '', 0, '', 0, $nameforformuserfile, '', $sectiondir);
}
else print '&nbsp;';
@ -131,7 +134,7 @@ if ($action == 'delete_section')
// End confirm
if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
if (empty($action) || $action == 'editfile' || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete')
{
print '<table width="100%" class="liste noborderbottom">'."\n";
@ -211,4 +214,4 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
}
?>
<!-- END PHP TEMPLATE ecm/tpl/filemanager.tpl.php -->
<!-- END PHP TEMPLATE core/tpl/filemanager.tpl.php -->

View File

@ -1061,7 +1061,7 @@ class Cronjob extends CommonObject
// Execute a CLI
include_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
$utils = new Utils($db);
$utils = new Utils($this->db);
$arrayresult = $utils->executeCLI($this->command, $outputfile);
$retval = $arrayresult['result'];

View File

@ -73,7 +73,7 @@ $urlsource=GETPOST('urlsource','alpha');
$entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity;
// Security check
if (empty($modulepart)) accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1);
if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1);
if (empty($original_file) && empty($hashp)) accessforbidden('Bad link. Missing identification to find file (original_file or hashp)',0,0,1);
if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility
@ -119,15 +119,23 @@ if (! empty($hashp))
{
$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
$moduleparttocheck = $tmp[0];
if ($moduleparttocheck == $modulepart)
if ($modulepart) // Not required for link using public hashp
{
// We remove first level of directory
$original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir
//var_dump($original_file); exit;
if ($moduleparttocheck == $modulepart)
{
// We remove first level of directory
$original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir
//var_dump($original_file); exit;
}
else
{
accessforbidden('Bad link. File is from another module part.',0,0,1);
}
}
else
{
accessforbidden('Bad link. File is from another module part.',0,0,1);
$modulepart = $moduleparttocheck;
$original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir
}
}
else
@ -154,7 +162,8 @@ $fullpath_original_file = $check_access['original_file']; // $
if (! empty($hashp))
{
$accessallowed = 1; // When using hashp, link is public so we force $accessallowed
$accessallowed = 1; // When using hashp, link is public so we force $accessallowed
$sqlprotectagainstexternals = '';
}
else
{
@ -220,7 +229,7 @@ if (! file_exists($fullpath_original_file_osencoded))
top_httphead($type);
header('Content-Description: File Transfer');
if ($encoding) header('Content-Encoding: '.$encoding);
// Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, atachment=need user action to open)
// Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open)
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
header('Content-Length: ' . dol_filesize($fullpath_original_file));

View File

@ -842,9 +842,10 @@ class Don extends CommonObject
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $notooltip 1=Disable tooltip
* @return string Chaine avec URL
*/
function getNomUrl($withpicto=0)
function getNomUrl($withpicto=0, $notooltip=0)
{
global $langs;

View File

@ -39,19 +39,20 @@ class EcmDirectory // extends CommonObject
var $cachenbofdoc=-1; // By default cache initialized with value 'not calculated'
var $date_c;
var $date_m;
public $fk_user_m;
public $fk_user_c;
public $ref;
public $fk_user_m;
public $fk_user_c;
public $ref;
var $cats=array();
var $motherof=array();
var $forbiddenchars = array('<','>',':','/','\\','?','*','|','"');
var $forbiddenchars = array('<','>',':','/','\\','?','*','|','"');
var $forbiddencharsdir = array('<','>',':','?','*','|','"');
public $full_arbo_loaded;
public $full_arbo_loaded;
public $error;
public $errors;
public $error;
public $errors;
/**
@ -104,8 +105,8 @@ class EcmDirectory // extends CommonObject
$pathfound=0;
foreach ($cate_arbo as $key => $categ)
{
$path=str_replace($this->forbiddenchars,'_',$categ['fulllabel']);
//print $path.'<br>';
$path=str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']);
//print $relativepath.' - '.$path.'<br>';
if ($path == $relativepath)
{
$pathfound=1;
@ -424,7 +425,7 @@ class EcmDirectory // extends CommonObject
$label=$langs->trans("ShowECMSection").': '.$newref;
$linkclose='"'.($more?' '.$more:'').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$this->id.$linkclose;
$linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/dir_card.php?section='.$this->id.$linkclose;
if ($option == 'index') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;
if ($option == 'indexexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=false'.$linkclose;
if ($option == 'indexnotexpanded') $linkstart = '<a href="'.DOL_URL_ROOT.'/ecm/index.php?section='.$this->id.'&amp;sectionexpand=true'.$linkclose;

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,15 +17,13 @@
/**
* \file htdocs/ecm/class/htmlecm.form.class.php
* \brief Fichier de la classe des fonctions predefinie de composants html
* \brief File of class to manage HTML component for ECM and generic filemanager
*/
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
/**
* \class FormEcm
* \brief Classe permettant la generation de composants html
* \remarks Only common components must be here.
* Class to manage HTML component for ECM and generic filemanager
*/
class FormEcm
{
@ -52,13 +50,14 @@ class FormEcm
* @param string $module Module ('ecm', 'medias', ...)
* @return string String with HTML select
*/
function select_all_sections($selected=0, $select_name='', $module='ecm')
function selectAllSections($selected=0, $select_name='', $module='ecm')
{
global $conf, $langs;
$langs->load("ecm");
if ($select_name=='') $select_name="catParent";
$cate_arbo=null;
if ($module == 'ecm')
{
$cat = new EcmDirectory($this->db);
@ -80,7 +79,8 @@ class FormEcm
$output.= '<option value="-1">&nbsp;</option>';
foreach($cate_arbo as $key => $value)
{
if ($cate_arbo[$key]['id'] == $selected)
$valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id'];
if ($selected && $valueforoption == $selected)
{
$add = 'selected ';
}
@ -88,7 +88,7 @@ class FormEcm
{
$add = '';
}
$output.= '<option '.$add.'value="'.dol_escape_htmltag(empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
$output.= '<option '.$add.'value="'.dol_escape_htmltag($valueforoption).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
}
}
}

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
@ -29,15 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
$langs->load("users");
$langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("contracts");
$langs->load("categories");
$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts","categories"));
if (! $user->rights->ecm->setup) accessforbidden();
@ -46,11 +38,12 @@ $socid = GETPOST('socid','int');
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm=GETPOST('confirm','alpha');
$confirm = GETPOST('confirm','alpha');
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) $module='ecm';
// Security check
if ($user->societe_id > 0)
@ -66,7 +59,7 @@ if ($module == 'ecm')
{
$upload_dir = $conf->ecm->dir_output.'/'.$urlsection;
}
if ($module == 'medias')
else // For example $module == 'medias'
{
$upload_dir = $conf->medias->multidir_output[$conf->entity];
}
@ -109,39 +102,84 @@ if ($action == 'add' && $user->rights->ecm->setup)
}
else
{
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager');
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager'.($module?'&module='.$module:''));
exit;
}
}
$ecmdir->ref = trim($_POST["ref"]);
$ecmdir->label = trim($_POST["label"]);
$ecmdir->description = trim($_POST["desc"]);
$ecmdir->fk_parent = $_POST["catParent"];
$ref = trim(GETPOST("ref", 'alpha'));
$label = trim(GETPOST("label", 'alpha'));
$desc = trim(GETPOST("desc", 'alpha'));
$catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager)
$ok=true;
$error=0;
if (! $ecmdir->label)
if (empty($label))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
$action = 'create';
$ok=false;
$error++;
}
if ($ok)
if (! $error)
{
$id = $ecmdir->create($user);
if ($id > 0)
if ($module == 'ecm')
{
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager');
$ecmdir->ref = $ref;
$ecmdir->label = $label;
$ecmdir->description = $desc;
$ecmdir->fk_parent = (int) $catParent;
$id = $ecmdir->create($user);
if ($id <= 0)
{
$error++;
$langs->load("errors");
setEventMessages($ecmdir->error, $ecmdir->errors, 'errors');
$action = 'create';
}
}
else // For example $module == 'medias'
{
$dirfornewdir = '';
if ($module == 'medias')
{
$dirfornewdir = $conf->medias->multidir_output[$conf->entity];
}
if (empty($dirfornewdir))
{
$error++;
dol_print_error('', 'Bad value for module. Not supported.');
}
if (! $error)
{
$fullpathofdir = $dirfornewdir.'/'.($catParent? $catParent.'/' : '').$label;
$result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT);
if ($result < 0)
{
setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors');
$error++;
}
else
{
setEventMessages($langs->trans("ECMSectionWasCreated", $label), null, 'mesgs');
}
}
}
}
if (! $error)
{
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
}
else
{
$langs->load("errors");
setEventMessages($langs->trans($ecmdir->error), $ecmdir->errors, 'errors');
$action = 'create';
header("Location: ".DOL_URL_ROOT.'/ecm/index.php?action=file_manager');
exit;
}
}
}
@ -160,7 +198,7 @@ else if ($action == 'confirm_deletesection' && $confirm == 'yes')
* View
*/
llxHeader();
llxHeader('', $langs->trans("ECMNewSection"));
$form=new Form($db);
$formecm=new FormEcm($db);
@ -170,12 +208,13 @@ if ($action == 'create')
//***********************
// Create
//***********************
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
if ($website) print '<input type="hidden" name="website" value="'.$website.'">';
if ($pageid) print '<input type="hidden" name="pageid" value="'.$pageid.'">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($backtopage).'">';
if ($website) print '<input type="hidden" name="website" value="'.dol_escape_htmltag($website).'">';
if ($pageid) print '<input type="hidden" name="pageid" value="'.dol_escape_htmltag($pageid).'">';
$title=$langs->trans("ECMNewSection");
print load_fiche_titre($title);
@ -188,7 +227,7 @@ if ($action == 'create')
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth100" maxlength="32" value="'.$ecmdir->label.'"></td></tr>'."\n";
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $formecm->select_all_sections(! empty($_GET["catParent"]) ? $_GET["catParent"] : $ecmdir->fk_parent, 'catParent', $module);
print $formecm->selectAllSections((GETPOST("catParent",'alpha') ? GETPOST("catParent",'alpha') : $ecmdir->fk_parent), 'catParent', $module);
print '</td></tr>'."\n";
// Description
@ -207,7 +246,7 @@ if ($action == 'create')
print '<div class="center">';
print '<input type="submit" class="button" name="create" value="'.$langs->trans("Create").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print ' &nbsp; &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
@ -226,7 +265,7 @@ if (empty($action) || $action == 'delete_section')
$ecmdir->ref=$ecmdir->label;
print $langs->trans("ECMSection").': ';
print img_picto('','object_dir').' ';
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php">'.$langs->trans("ECMRoot").'</a>';
print '<a href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php">'.$langs->trans("ECMRoot").'</a>';
//print ' -> <b>'.$ecmdir->getNomUrl(1).'</b><br>';
print "<br><br>";
*/

View File

@ -17,7 +17,7 @@
/**
* \file htdocs/ecm/docmine.php
* \file htdocs/ecm/dir_card.php
* \ingroup ecm
* \brief Card of a directory for ECM module
* \author Laurent Destailleur
@ -34,8 +34,15 @@ $langs->load("ecm");
$langs->load("companies");
$langs->load("other");
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$confirm = GETPOST('confirm','alpha');
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) $module='ecm';
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
@ -48,24 +55,33 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$section=GETPOST("section");
$section=GETPOST("section", 'alpha')?GETPOST("section", 'alpha'):GETPOST("relativedir", 'alpha');
if (! $section)
{
dol_print_error('',"ErrorSectionParamNotDefined");
exit;
}
// Load ecm object
$ecmdir = new EcmDirectory($db);
$result=$ecmdir->fetch(GETPOST("section"));
if (! $result > 0)
if ($module == 'ecm')
{
dol_print_error($db,$ecmdir->error);
exit;
$result=$ecmdir->fetch($section);
if (! $result > 0)
{
dol_print_error($db, $ecmdir->error);
exit;
}
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
}
else // For example $module == 'medias'
{
$relativepath = $section;
$upload_dir = $conf->medias->multidir_output[$conf->entity].'/'.$relativepath;
}
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
@ -210,7 +226,7 @@ foreach($filearray as $key => $file)
}
$head = ecm_prepare_head($ecmdir);
$head = ecm_prepare_head($ecmdir, $module, $section);
dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir');
@ -219,75 +235,106 @@ if ($action == 'edit')
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="section" value="'.$section.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
print '<input type="hidden" name="action" value="update">';
}
$s='';
$result = 1;
$i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref=$tmpecmdir->label;
if ($i == 0 && $action == 'edit')
{
$s='<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
}
else $s=$tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
}
else
{
$tmpecmdir=0;
}
$i++;
}
$morehtml='';
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
$morehtmlref = '/'.$module.'/'.$relativepath;
if ($module == 'ecm')
{
$s='';
$result = 1;
$i=0;
$tmpecmdir=new EcmDirectory($db); // Need to create a new one
$tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0)
{
$tmpecmdir->ref=$tmpecmdir->label;
if ($i == 0 && $action == 'edit')
{
$s='<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
}
else $s=$tmpecmdir->getNomUrl(1).$s;
if ($tmpecmdir->fk_parent)
{
$s=' -> '.$s;
$result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
}
else
{
$tmpecmdir=0;
}
$i++;
}
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> '.$s;
}
dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border centpercent">';
/*print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$langs->trans("ECMRoot").'</a> -> ';
print $s;
print '</td></tr>';*/
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
if ($action == 'edit')
if ($module == 'ecm')
{
print '<textarea class="flat" name="description" cols="80">';
print $ecmdir->description;
print '</textarea>';
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
if ($action == 'edit')
{
print '<textarea class="flat quatrevingtpercent" name="description">';
print $ecmdir->description;
print '</textarea>';
}
else print dol_nl2br($ecmdir->description);
print '</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationUser").'</td><td>';
$userecm=new User($db);
$userecm->fetch($ecmdir->fk_user_c);
print $userecm->getNomUrl(1);
print '</td></tr>';
}
print '<tr><td class="titlefield">'.$langs->trans("ECMCreationDate").'</td><td>';
if ($module == 'ecm')
{
print dol_print_date($ecmdir->date_c,'dayhour');
}
else
{
//var_dump($upload_dir);
print dol_print_date(dol_filemtime($upload_dir), 'dayhour');
}
else print dol_nl2br($ecmdir->description);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationUser").'</td><td>';
$userecm=new User($db);
$userecm->fetch($ecmdir->fk_user_c);
print $userecm->getNomUrl(1);
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMCreationDate").'</td><td>';
print dol_print_date($ecmdir->date_c,'dayhour');
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMDirectoryForFiles").'</td><td>';
print '/ecm/'.$relativepath;
if ($module == 'ecm')
{
print '/ecm/'.$relativepath;
}
else
{
print '/'.$module.'/'.$relativepath;
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("ECMNbOfDocs").'</td><td>';
$nbofiles=count($filearray);
print $nbofiles;
// Test if nb is same than in cache
if ($nbofiles != $ecmdir->cachenbofdoc)
if ($ecmdir->id > 0)
{
$ecmdir->changeNbOfFiles((string) $nbofiles);
// Test if nb is same than in cache
if ($nbofiles != $ecmdir->cachenbofdoc)
{
$ecmdir->changeNbOfFiles((string) $nbofiles);
}
}
print '</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>';
@ -321,12 +368,12 @@ if ($action != 'edit' && $action != 'delete')
if ($user->rights->ecm->setup)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&section='.$section.'">'.$langs->trans('Edit').'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit'.($module?'&module='.$module:'').'&section='.$section.'">'.$langs->trans('Edit').'</a>';
}
if ($user->rights->ecm->setup)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/ecm/dir_add_card.php?action=create'.($module?'&module='.$module:'').'&catParent='.$section.'">'.$langs->trans('ECMAddSection').'</a>';
}
else
{
@ -337,7 +384,7 @@ if ($action != 'edit' && $action != 'delete')
{
if ($user->rights->ecm->setup)
{
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir&section='.$section.'">'.$langs->trans('Delete').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete_dir'.($module?'&module='.$module:'').'&section='.$section.'">'.$langs->trans('Delete').'</a>';
}
else
{
@ -354,25 +401,24 @@ if ($action != 'edit' && $action != 'delete')
// Confirm remove file
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"].'&amp;urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST("section",'alpha').'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
}
// Confirm remove file
if ($action == 'delete_dir')
{
$relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath);
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$_REQUEST["section"], $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1);
print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1);
}
$formfile=new FormFile($db);
/*
$formfile=new FormFile($db);
// Display upload form
if ($user->rights->ecm->upload)
{
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/docmine.php','',0,$section);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/ecm/dir_card.php','',0,$section);
}
// List of document

View File

@ -1,171 +0,0 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*/
/**
* \file htdocs/ecm/docother.php
* \ingroup ecm
* \brief Main ecm page
* \author Laurent Destailleur
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
// Get parameters
$socid = GETPOST("socid","int");
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$section=$_GET["section"];
if (! $section) $section='misc';
$upload_dir = $conf->ecm->dir_output.'/'.$section;
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
// Envoie fichier
if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
if (dol_mkdir($upload_dir) >= 0)
{
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
if (is_numeric($resupload) && $resupload > 0)
{
$result=$ecmdir->changeNbOfFiles('+');
}
else
{
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
}
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
{
setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors');
}
else // Known error
{
setEventMessages($langs->trans($resupload), null, 'errors');
}
}
}
else
{
// Echec transfert (fichier depassant la limite ?)
$langs->load("errors");
$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
}
}
// Suppression fichier
if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes')
{
$langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
}
/*******************************************************************
* PAGE
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
llxHeader();
$form=new Form($db);
print load_fiche_titre($langs->trans("ECMAutoOrg"));
//$head = societe_prepare_head($societe);
/*
* Confirmation of deleting a product line
*/
if ($_GET['action'] == 'delete_file')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?socid='.$socid.'&amp;urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile');
}
// Construct files list
clearstatcache();
$totalsize=0;
$filearray=array();
$errorlevel=error_reporting();
error_reporting(0);
$handle=opendir($upload_dir);
error_reporting($errorlevel);
if (is_resource($handle))
{
$i=0;
while (($file = readdir($handle))!==false)
{
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
{
$filearray[$i]->name=$file;
$filearray[$i]->size=dol_filesize($upload_dir."/".$file);
$filearray[$i]->date=dol_filemtime($upload_dir."/".$file);
$totalsize+=$filearray[$i]->size;
$i++;
}
}
closedir($handle);
}
else
{
// print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
}
/*
print '<table class="border"width="100%">';
// Nbre fichiers
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
//Total taille
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
*/
if ($mesg) { print $mesg."<br>"; }
print $langs->trans("FeatureNotYetAvailable");
// End of page
llxFooter();
$db->close();

View File

@ -16,7 +16,7 @@
*/
/**
* \file htdocs/ecm/docfile.php
* \file htdocs/ecm/file_card.php
* \ingroup ecm
* \brief Card of a file for ECM module
*/
@ -123,7 +123,7 @@ if ($cancel)
}
else
{
header("Location: ".DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section).($module?'&module='.urlencode($module):''));
exit;
}
}
@ -216,7 +216,7 @@ if ($action == 'update')
$db->commit();
$urlfile=$newlabel;
header("Location: ".DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
header('Location: '.$_SERVER["PHP_SELF"].'?urlfile='.urlencode($urlfile).'&section='.urlencode($section));
exit;
}
else
@ -242,7 +242,8 @@ if ($action == 'edit')
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="section" value="'.$section.'">';
print '<input type="hidden" name="urlfile" value="'.$urlfile.'">';
print '<input type="hidden" name="urlfile" value="'.$urlfile.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
}
@ -341,15 +342,19 @@ if (! empty($object->share))
if ($action != 'edit')
{
$modulepart='ecm';
$forcedownload=1;
$rellink='/document.php?modulepart='.$modulepart;
if ($forcedownload) $rellink.='&attachment=1';
if (! empty($object->entity)) $rellink.='&entity='.$object->entity;
//$rellink.='&file='.urlencode($filepath); // No need of name of file for public link, we will use the hash
$fulllink=$urlwithroot.$rellink;
//if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path
$forcedownload=0;
$paramlink='';
//if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart; // For sharing with hash (so public files), modulepart is not required.
//if (! empty($object->entity)) $paramlink.='&entity='.$object->entity; // For sharing with hash (so public files), entity is not required.
//$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath); // No need of name of file for public link, we will use the hash
if (! empty($object->share)) $paramlink.=($paramlink?'&':'').'hashp='.$object->share; // Hash for public share
if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
$fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
//if (! empty($object->ref)) $fulllink.='&hashn='.$object->ref; // Hash of file path
//elseif (! empty($object->label)) $fulllink.='&hashc='.$object->label; // Hash of file content
if (! empty($object->share)) $fulllink.='&hashp='.$object->share; // Hash for public share
print img_picto('','object_globe.png').' ';
if ($action != 'edit') print '<input type="text" class="quatrevingtpercent" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).'">';
else print $fulllink;

View File

@ -77,8 +77,8 @@ $error=0;
* Actions
*/
// Upload file
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
// Upload file (code similar but different than actions_linkedfiles.inc.php)
if (GETPOST("sendit",'none') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
// Define relativepath and upload_dir
$relativepath='';
@ -86,14 +86,20 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
else $relativepath=$section_dir;
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (empty($_FILES['userfile']['tmp_name']))
if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name'];
else $userfiles=array($_FILES['userfile']['tmp_name']);
foreach($userfiles as $key => $userfile)
{
$error++;
if($_FILES['userfile']['error'] == 1 || $_FILES['userfile']['error'] == 2){
setEventMessages($langs->trans('ErrorFileSizeTooLarge'),null, 'errors');
}
else {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
if (empty($_FILES['userfile']['tmp_name'][$key]))
{
$error++;
if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2){
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
}
else {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors');
}
}
}
@ -107,8 +113,6 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
}
}
// Add directory
if ($action == 'add' && $user->rights->ecm->setup)
{
@ -131,7 +135,7 @@ if ($action == 'add' && $user->rights->ecm->setup)
clearstatcache();
}
// Remove file
// Remove file (code similar but different than actions_linkedfiles.inc.php)
if ($action == 'confirm_deletefile')
{
if (GETPOST('confirm') == 'yes')
@ -141,7 +145,6 @@ if ($action == 'confirm_deletefile')
$upload_dir = $conf->ecm->dir_output.($relativepath?'/'.$relativepath:'');
$file = $upload_dir . "/" . GETPOST('urlfile','alpha'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
//var_dump($file);exit;
$ret=dol_delete_file($file); // This include also the delete from file index in database.
if ($ret)
@ -335,7 +338,7 @@ dol_fiche_head($head, 'index', $langs->trans("ECMArea").' - '.$langs->trans("ECM
// Add filemanager component
$module='ecm';
include DOL_DOCUMENT_ROOT.'/ecm/tpl/filemanager.tpl.php';
include DOL_DOCUMENT_ROOT.'/core/tpl/filemanager.tpl.php';
// End of page
dol_fiche_end();

View File

@ -30,14 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
$langs->load("users");
$langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("contracts");
$langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts"));
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@ -52,6 +45,11 @@ $action = GETPOST('action','alpha');
$section=GETPOST('section');
if (! $section) $section=0;
$module = GETPOST('module', 'alpha');
$website = GETPOST('website', 'alpha');
$pageid = GETPOST('pageid', 'int');
if (empty($module)) $module='ecm';
$upload_dir = $conf->ecm->dir_output.'/'.$section;
$sortfield = GETPOST("sortfield",'alpha');
@ -123,7 +121,7 @@ print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
// Tool bar
$head = ecm_prepare_head_fm($ecmdir);
$head = ecm_prepare_head_fm($ecmdir, $module, $section);
//dol_fiche_head($head, 'search_form', '', 1);

View File

@ -25,6 +25,7 @@
<?php
if (empty($module)) $module='ecm';
$paramwithoutsection=preg_replace('/&?section=(\d+)/', '', $param);
$openeddir='/';
?>
@ -34,21 +35,30 @@ $(document).ready(function() {
$('#filetree').fileTree({
root: '<?php print dol_escape_js($openeddir); ?>',
// Ajax called if we click to expand a dir (not a file). Parameter 'dir' is provided as a POST parameter by fileTree code to this following URL.
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir).(empty($param)?'':$param); ?>',
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart='.$module.'&openeddir='.urlencode($openeddir).(empty($paramwithoutsection)?'':$paramwithoutsection); ?>',
folderEvent: 'click', // 'dblclick'
multiFolder: false },
// Called if we click on a file (not a dir)
function(file) {
console.log("We click on a file");
$("#mesg").hide();
loadandshowpreview(file,0);
},
// Called if we click on a dir (not a file)
function(elem) {
id=elem.attr('id').substr(12); // We get id that is 'fmdirlia_id_xxx' (id we want is xxx)
jQuery("#<?php echo $nameforformuserfile ?>_section_dir").val(elem.attr('rel'));
rel=elem.attr('rel')
console.log("We click on a dir, we call the ajaxdirtree.php with modulepart=<?php echo $module; ?>, param=<?php echo $paramwithoutsection; ?>");
console.log("We also save dir name or id into <?php echo $nameforformuserfile ?>_section_... with name section_... id="+id+" rel="+rel);
jQuery("#<?php echo $nameforformuserfile ?>_section_dir").val(rel);
jQuery("#<?php echo $nameforformuserfile ?>_section_id").val(id);
jQuery("#section_dir").val(rel);
jQuery("#section_id").val(id);
jQuery("#section").val(id);
jQuery('#<?php echo $nameforformuserfile ?>').show();
console.log("We also execute the loadandshowpreview() that is on the onclick of each li defined by ajaxdirtree");
}
// The loadanshowpreview is also call by the 'onclick' set on each li return by ajaxdirtree
);
$('#refreshbutton').click( function() {
@ -73,7 +83,7 @@ function loadandshowpreview(filedirname,section)
$('#ecmfileview').empty();
var url = '<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php',1); ?>?action=preview&module=<?php echo $module; ?>&section='+section+'&file='+urlencode(filedirname)<?php echo (empty($param)?'':"+'".$param."'"); ?>;
var url = '<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php',1); ?>?action=preview&module=<?php echo $module; ?>&section='+section+'&file='+urlencode(filedirname)<?php echo (empty($paramwithoutsection)?'':"+'".$paramwithoutsection."'"); ?>;
$.get(url, function(data) {
//alert('Load of url '+url+' was performed : '+data);
pos=data.indexOf("TYPE=directory",0);

View File

@ -2391,47 +2391,39 @@ if (GETPOST('modelselected')) {
if ($action != 'presend')
{
print '<div class="fichehalfleft">';
/*
* Generate documents
*/
if($user->rights->expensereport->export && $action != 'create' && $action != 'edit')
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
if($user->rights->expensereport->creer && $action != 'create' && $action != 'edit')
{
$filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $user->rights->expensereport->export;
$delallowed = $user->rights->expensereport->export;
$genallowed = $user->rights->expensereport->creer;
$delallowed = $user->rights->expensereport->creer;
$var = true;
print $formfile->showdocuments('expensereport',$filename,$filedir,$urlsource,$genallowed,$delallowed);
print $formfile->showdocuments('expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed);
$somethingshown = $formfile->numoffiles;
}
print '</div>';
if ($action != 'create' && $action != 'edit' && ($id || $ref))
{
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
// Link invoice to intervention
if (GETPOST('LinkedFichinter')) {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->add_object_linked('fichinter', GETPOST('LinkedFichinter'));
}
// Show links to link elements
$linktoelements=array();
if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION))
{
$linktoelements[]='fichinter';
$linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
}
$linktoelem = $form->showLinkToObjectBlock($object, null, array('expensereport'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
$formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, 'expensereport', null);
print '</div></div></div>';
}
// Presend form

View File

@ -1520,13 +1520,13 @@ class ExpenseReport extends CommonObject
$this->error=$obj->error;
$this->errors=$obj->errors;
//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
return "";
return -1;
}
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_EXPENSEREPORT_ADDON_NotDefined");
return "";
$this->error = "Error_EXPENSEREPORT_ADDON_NotDefined";
return -2;
}
}

View File

@ -6374,7 +6374,9 @@ class wsdl extends nusoap_base {
$elements = $eElements;
}
if (count($attrs) > 0) {
// @CHANGE LDR FIX for PHP7.2
//if (count($attrs) > 0) {
if (is_array($attrs) && count($attrs) > 0) {
foreach($attrs as $n => $a){
// expand each attribute
foreach ($a as $k => $v) {

View File

@ -307,10 +307,10 @@ class AutoLoader
*/
private function alias($className, $currentClass)
{
// @CHANGE LDR
// @CHANGE LDR
if ($className == 'Luracast\Restler\string') return;
if ($className == 'Luracast\Restler\mixed') return;
if ($className != $currentClass
&& false !== strpos($className, $currentClass))
if (!class_exists($currentClass, false)

View File

@ -505,7 +505,7 @@ class CommentParser
$data = explode('|', $data);
$r['type'] = count($data) == 1 ? $data[0] : $data;
}
if (isset($r['type']) && is_string($r['type']) && Text::endsWith($r['type'], '[]')) {
if (isset($r['type']) && Text::endsWith($r['type'], '[]')) {
$r[static::$embeddedDataName]['type'] = substr($r['type'], 0, -2);
$r['type'] = 'array';
}

View File

@ -13,7 +13,7 @@ namespace Luracast\Restler\Data;
* @link http://luracast.com/products/restler/
* @version 3.0.0rc6
*/
class Object
class Obj
{
/**
* @var bool|string|callable

View File

@ -454,7 +454,10 @@ class Validator implements iValidate
}
if (isset ($info->choice)) {
if (is_array($input)) {
if (!$info->required && empty($input)) {
//since its optional, and empty let it pass.
$input = null;
} elseif (is_array($input)) {
foreach ($input as $i) {
if (!in_array($i, $info->choice)) {
$error .= ". Expected one of (" . implode(',', $info->choice) . ").";
@ -468,6 +471,11 @@ class Validator implements iValidate
}
if (method_exists($class = get_called_class(), $info->type) && $info->type != 'validate') {
if(!$info->required && empty($input))
{
//optional parameter with a empty value assume null
return null;
}
try {
return call_user_func("$class::$info->type", $input, $info);
} catch (Invalid $e) {
@ -669,4 +677,4 @@ class Validator implements iValidate
throw $e;
}
}
}
}

View File

@ -44,7 +44,7 @@ class EventDispatcher
public function __call($eventName, $params)
{
if (0 === strpos($eventName, 'on')) {
if (!@is_array($this->listeners[$eventName]))
if (!isset($this->listeners[$eventName]) || !is_array($this->listeners[$eventName]))
$this->listeners[$eventName] = array();
$this->listeners[$eventName][] = $params[0];
}

View File

@ -16,7 +16,12 @@ use Luracast\Restler\Scope;
*/
class Explorer implements iProvideMultiVersionApi
{
const SWAGGER_VERSION = '1.2';
const SWAGGER = '2.0';
/**
* @var array http schemes supported. http or https or both http and https
*/
public static $schemes = array();
/**
* @var bool should protected resources be shown to unauthenticated users?
*/
@ -70,17 +75,17 @@ class Explorer implements iProvideMultiVersionApi
*/
public static $dataTypeAlias = array(
//'string' => 'string',
'int' => 'integer',
'number' => 'number',
'float' => array('number', 'float'),
'bool' => 'boolean',
'int' => 'integer',
'number' => 'number',
'float' => array('number', 'float'),
'bool' => 'boolean',
//'boolean' => 'boolean',
//'NULL' => 'null',
'array' => 'array',
'array' => 'array',
//'object' => 'object',
'stdClass' => 'object',
'mixed' => 'string',
'date' => array('string', 'date'),
'mixed' => 'string',
'date' => array('string', 'date'),
'datetime' => array('string', 'date-time'),
);
@ -89,9 +94,9 @@ class Explorer implements iProvideMultiVersionApi
* protected api
*/
public static $apiDescriptionSuffixSymbols = array(
0 => '&nbsp; <i class="fa fa-lg fa-unlock-alt"></i>', //public api
1 => '&nbsp; <i class="fa fa-lg fa-adjust"></i>', //hybrid api
2 => '&nbsp; <i class="fa fa-lg fa-lock"></i>', //protected api
0 => ' 🔓', //'&nbsp; <i class="fa fa-lg fa-unlock-alt"></i>', //public api
1 => ' ◑', //'&nbsp; <i class="fa fa-lg fa-adjust"></i>', //hybrid api
2 => ' 🔐', //'&nbsp; <i class="fa fa-lg fa-lock"></i>', //protected api
);
protected $models = array();
@ -100,27 +105,23 @@ class Explorer implements iProvideMultiVersionApi
*/
protected $_fullDataRequested = false;
protected $crud = array(
'POST' => 'create',
'GET' => 'retrieve',
'PUT' => 'update',
'POST' => 'create',
'GET' => 'retrieve',
'PUT' => 'update',
'DELETE' => 'delete',
'PATCH' => 'partial update'
'PATCH' => 'partial update'
);
protected static $prefixes = array(
'get' => 'retrieve',
'index' => 'list',
'post' => 'create',
'put' => 'update',
'patch' => 'modify',
'get' => 'retrieve',
'index' => 'list',
'post' => 'create',
'put' => 'update',
'patch' => 'modify',
'delete' => 'remove',
);
protected $_authenticated = false;
protected $cacheName = '';
public function __construct()
{
}
/**
* Serve static files for exploring
@ -131,7 +132,7 @@ class Explorer implements iProvideMultiVersionApi
*/
public function get()
{
if (func_num_args() > 1 && func_get_arg(0) == 'resources') {
if (func_num_args() > 1 && func_get_arg(0) == 'swagger') {
/**
* BUGFIX:
* If we use common resourcePath (e.g. $r->addAPIClass([api-class], 'api/shop')), than we must determine resource-ID of e.g. 'api/shop'!
@ -141,6 +142,7 @@ class Explorer implements iProvideMultiVersionApi
array_shift($arguments);
// create ID
$id = implode('/', $arguments);
return $this->getResources($id);
}
$filename = implode('/', func_get_args());
@ -161,125 +163,75 @@ class Explorer implements iProvideMultiVersionApi
) {
$filename .= '.js';
}
PassThrough::file(__DIR__ . '/explorer/' . (empty($filename) ? 'index.html' : $filename), false, 0); //60 * 60 * 24);
PassThrough::file(__DIR__ . '/explorer/' . (empty($filename) ? 'index.html' : $filename), false,
0); //60 * 60 * 24);
}
public function resources()
/**
* @return stdClass
*/
public function swagger()
{
$r = new stdClass();
$r->apiVersion = (string)$this->restler->getRequestedApiVersion();
$r->swaggerVersion = static::SWAGGER_VERSION;
$r->apis = $this->apis($r->apiVersion);
$r->authorizations = $this->authorizations();
$r->info = array_filter(get_class_vars(static::$infoClass));
return $r;
}
$version = (string)$this->restler->getRequestedApiVersion();
$r->swagger = static::SWAGGER;
public function getResources($id)
{
$r = new stdClass();
$r->apiVersion = (string)$this->restler->getRequestedApiVersion();
$r->swaggerVersion = static::SWAGGER_VERSION;
$r->basePath = $this->restler->getBaseUrl();
$r->resourcePath = "/$id";
$r->apis = $this->apis($r->apiVersion, $id);
$r->models = (object)$this->models;
$info = parse_url($this->restler->getBaseUrl());
$r->host = $info['host'];
if (isset($info['port'])) {
$r->host .= ':' . $info['port'];
}
$r->basePath = isset($info['path']) ? $info['path'] : '';
if (!empty(static::$schemes)) {
$r->schemes = static::$schemes;
}
$r->produces = $this->restler->getWritableMimeTypes();
$r->consumes = $this->restler->getReadableMimeTypes();
$r->authorizations = $this->authorizations();
$r->paths = $this->paths($version);
$r->definitions = (object)$this->models;
$r->securityDefinitions = $this->securityDefinitions();
$r->info = compact('version') + array_filter(get_class_vars(static::$infoClass));
return $r;
}
private function apis($version = 1, $resource = false)
private function paths($version = 1)
{
$map = Routes::findAll(static::$excludedPaths + array($this->base()), static::$excludedHttpMethods, $version);
$r = array();
$a = array();
$paths = array();
foreach ($map as $path => $data) {
$route = $data[0]['route'];
$access = $data[0]['access'];
if ($access && !Text::contains($path, '{')) {
$r[] = array(
'path' => empty($path) ? '/root' : "/$path",
//'description' => ''
//TODO: Util::nestedValue($route, 'metadata', 'classDescription') ? : ''
);
}
if (static::$hideProtected && !$access)
if (static::$hideProtected && !$access) {
continue;
$grouper = array();
}
foreach ($data as $item) {
$route = $item['route'];
$access = $item['access'];
if (static::$hideProtected && !$access)
if (static::$hideProtected && !$access) {
continue;
}
$url = $route['url'];
if (isset($grouper[$url])) {
$grouper[$url]['operations'][] = $this->operation($route);
} else {
$api = array(
'path' => "/$url",
'description' =>
Util::nestedValue($route, 'metadata', 'classDescription') ? : '',
'operations' => array($this->operation($route))
);
static::$groupOperations
? $grouper[$url] = $api
: $a[$path][] = $api;
}
$paths["/$url"][strtolower($route['httpMethod'])] = $this->operation($route);
}
if (!empty($grouper)) {
$a[$path] = array_values($grouper);
// sort REST-endpoints by path
foreach ($a as & $b) {
usort(
$b,
function ($x, $y) {
return $x['path'] > $y['path'];
}
);
}
} else {
$order = array(
'GET' => 1,
'POST' => 2,
'PUT' => 3,
'PATCH' => 4,
'DELETE' => 5
);
foreach ($a as & $b) {
usort(
$b,
function ($x, $y) use ($order) {
return
$x['operations'][0]->method ==
$y['operations'][0]->method
? $x['path'] > $y['path']
: $order[$x['operations'][0]->method] >
$order[$y['operations'][0]->method];
}
}
);
}
}
}
if (false !== $resource) {
if ($resource == 'root') $resource = '';
if (isset($a[$resource])) return $a[$resource];
}
return $r;
return $paths;
}
private function operation($route)
{
$r = new stdClass();
$r->method = $route['httpMethod'];
$r->nickname = $this->nickname($route);
$m = $route['metadata'];
$r->operationId = $this->operationId($route);
$base = strtok($route['url'], '/');
if (empty($base)) {
$base = 'root';
}
$r->tags = array($base);
$r->parameters = $this->parameters($route);
$m = $route['metadata'];
$r->summary = isset($m['description'])
? $m['description']
@ -287,13 +239,18 @@ class Explorer implements iProvideMultiVersionApi
$r->summary .= $route['accessLevel'] > 2
? static::$apiDescriptionSuffixSymbols[2]
: static::$apiDescriptionSuffixSymbols[$route['accessLevel']];
$r->notes = isset($m['longDescription'])
$r->description = isset($m['longDescription'])
? $m['longDescription']
: '';
$r->responseMessages = $this->responseMessages($route);
$r->responses = $this->responses($route);
//TODO: avoid hard coding. Properly detect security
if ($route['accessLevel']) {
$r->security = array(array('api_key' => array()));
}
/*
$this->setType(
$r,
new ValidationInfo(Util::nestedValue($m, 'return') ? : array())
new ValidationInfo(Util::nestedValue($m, 'return') ?: array())
);
if (is_null($r->type) || 'mixed' == $r->type) {
$r->type = 'array';
@ -302,7 +259,7 @@ class Explorer implements iProvideMultiVersionApi
} elseif (Text::contains($r->type, '|')) {
$r->type = 'array';
}
*/
//TODO: add $r->authorizations
//A list of authorizations required to execute this operation. While not mandatory, if used, it overrides
//the value given at the API Declaration's authorizations. In order to completely remove API Declaration's
@ -324,8 +281,9 @@ class Explorer implements iProvideMultiVersionApi
$info = new ValidationInfo($param);
$description = isset($param['description']) ? $param['description'] : '';
if ('body' == $info->from) {
if ($info->required)
if ($info->required) {
$required = true;
}
$param['description'] = $description;
$children[] = $param;
} else {
@ -341,31 +299,31 @@ class Explorer implements iProvideMultiVersionApi
if (empty($firstChild['children'])) {
$description = $firstChild['description'];
} else {
$description = '<section class="body-param">';
$description = ''; //'<section class="body-param">';
foreach ($firstChild['children'] as $child) {
$description .= isset($child['required']) && $child['required']
? '<strong>' . $child['name'] . '</strong> (required)<br/>'
: $child['name'] . '<br/>';
? '**' . $child['name'] . '** (required) '.PHP_EOL
: $child['name'] . ' '.PHP_EOL;
}
$description .= '</section>';
//$description .= '</section>';
}
$r[] = $this->parameter(new ValidationInfo($firstChild), $description);
} else {
$description = '<section class="body-param">';
$description = ''; //'<section class="body-param">';
foreach ($children as $child) {
$description .= isset($child['required']) && $child['required']
? '<strong>' . $child['name'] . '</strong> (required)<br/>'
: $child['name'] . '<br/>';
$description .= isset($child['required']) && $child['required']
? '**' . $child['name'] . '** (required) '.PHP_EOL
: $child['name'] . ' '.PHP_EOL;
}
$description .= '</section>';
//$description .= '</section>';
//lets group all body parameters under a generated model name
$name = $this->nameModel($route);
$name = $this->modelName($route);
$r[] = $this->parameter(
new ValidationInfo(array(
'name' => $name,
'type' => $name,
'from' => 'body',
'name' => $name,
'type' => $name,
'from' => 'body',
'required' => $required,
'children' => $children
)),
@ -373,196 +331,224 @@ class Explorer implements iProvideMultiVersionApi
);
}
}
return $r;
}
private function parameter(ValidationInfo $info, $description = '')
{
$p = new stdClass();
if(isset($info->rules['model'])){
$info->type = $info->rules['model'];
if (isset($info->rules['model'])) {
//$info->type = $info->rules['model'];
}
$p->name = $info->name;
$this->setType($p, $info);
if (empty($info->children) || $info->type != 'array') {
//primitives
if ($info->default)
if ($info->default) {
$p->defaultValue = $info->default;
if ($info->choice)
}
if ($info->choice) {
$p->enum = $info->choice;
if ($info->min)
}
if ($info->min) {
$p->minimum = $info->min;
if ($info->max)
}
if ($info->max) {
$p->maximum = $info->max;
}
//TODO: $p->items and $p->uniqueItems boolean
}
$p->description = $description;
$p->paramType = $info->from; //$info->from == 'body' ? 'form' : $info->from;
$p->in = $info->from; //$info->from == 'body' ? 'form' : $info->from;
$p->required = $info->required;
$p->allowMultiple = false;
//$p->allowMultiple = false;
if (isset($p->{'$ref'})) {
$p->schema = (object)array('$ref' => ($p->{'$ref'}));
unset($p->{'$ref'});
}
return $p;
}
private function responseMessages(array $route)
private function responses(array $route)
{
$r = array();
$code = '200';
$r = array(
$code => (object)array(
'description' => 'Success',
'schema' => new stdClass()
)
);
$return = Util::nestedValue($route, 'metadata', 'return');
if (!empty($return)) {
$this->setType($r[$code]->schema, new ValidationInfo($return));
}
if (is_array($throws = Util::nestedValue($route, 'metadata', 'throws'))) {
foreach ($throws as $message) {
$m = (object)$message;
//TODO: add $m->responseModel from composer class
$r[] = $m;
$r[$message['code']] = array('description' => $message['message']);
}
}
return $r;
}
private function model($type, array $children)
{
/**
* Bugfix:
* If we use namespaces, than the model will not be correct, if we use a short name for the type!
*
* Example (phpDoc/annotations in API-class, which uses custom domain-model with namespace):
* @param Car $car {@from body} {@type Aoe\RestServices\Domain\Model\Car}
* @return Car {@type Aoe\RestServices\Domain\Model\Car}
* Than, the model (in swagger-spec) must also be 'Aoe\RestServices\Domain\Model\Car' and not 'Car'
*
* When we use namespaces, than we must use the @type-annotation, otherwise the automatic reconstitution
* from request-data (e.g. when it is a POST-request) to custom domain-model-object will not work!
*
* Summary:
* - When we use no namespaces, than the type would not be changed, if we would call 'Util::getShortName'
* - When we use namespaces, than the model will not be correct, if we would call 'Util::getShortName'
* ...so this method-call is either needless or will create a bug/error
*/
//$type = Util::getShortName($type);
if (isset($this->models[$type]))
if (isset($this->models[$type])) {
return $this->models[$type];
}
$r = new stdClass();
$r->id = $type;
$r->description = "$type Model"; //TODO: enhance this on Router
$r->required = array();
$r->properties = array();
$required = array();
foreach ($children as $child) {
$info = new ValidationInfo($child);
$p = new stdClass();
$this->setType($p, $info);
$p->description = isset($child['description']) ? $child['description'] : '';
if ($info->default)
if ($info->default) {
$p->defaultValue = $info->default;
if ($info->choice)
}
if ($info->choice) {
$p->enum = $info->choice;
if ($info->min)
}
if ($info->min) {
$p->minimum = $info->min;
if ($info->max)
}
if ($info->max) {
$p->maximum = $info->max;
if ($info->required)
$r->required[] = $info->name;
}
if ($info->required) {
$required[] = $info->name;
}
$r->properties[$info->name] = $p;
}
if (!empty($required)) {
$r->required = $required;
}
//TODO: add $r->subTypes https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#527-model-object
//TODO: add $r->discriminator https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#527-model-object
$this->models[$type] = $r;
return $r;
}
private function setType(&$object, ValidationInfo $info)
{
//TODO: proper type management
$type = Util::getShortName($info->type);
if ($info->type == 'array') {
$object->type = 'array';
if ($info->children) {
$this->model($info->contentType, $info->children);
$contentType = Util::getShortName($info->contentType);
$model = $this->model($contentType, $info->children);
$object->items = (object)array(
'$ref' => $info->contentType
'$ref' => "#/definitions/$contentType"
);
} elseif ($info->contentType && $info->contentType == 'associative') {
unset($info->contentType);
$this->model($info->type = 'Object', array(
array(
'name' => 'property',
'type' => 'string',
'default' => '',
'required' => false,
'name' => 'property',
'type' => 'string',
'default' => '',
'required' => false,
'description' => ''
)
));
} elseif ($info->contentType && $info->contentType != 'indexed') {
$object->items = (object)array(
'type' => $info->contentType
);
if (is_string($info->contentType) && $t = Util::nestedValue(static::$dataTypeAlias,
strtolower($info->contentType))) {
if (is_array($t)) {
$object->items = (object)array(
'type' => $t[0],
'format' => $t[1],
);
} else {
$object->items = (object)array(
'type' => $t,
);
}
} else {
$contentType = Util::getShortName($info->contentType);
$object->items = (object)array(
'$ref' => "#/definitions/$contentType"
);
}
} else {
$object->items = (object)array(
'type' => 'string'
);
}
} elseif ($info->children) {
$this->model($info->type, $info->children);
$this->model($type, $info->children);
$object->{'$ref'} = "#/definitions/$type";
} elseif (is_string($info->type) && $t = Util::nestedValue(static::$dataTypeAlias, strtolower($info->type))) {
if (is_array($t)) {
list($info->type, $object->format) = $t;
$object->type = $t[0];
$object->format = $t[1];
} else {
$info->type = $t;
$object->type = $t;
}
} else {
$info->type = 'string';
$object->type = 'string';
}
$object->type = $info->type;
$has64bit = PHP_INT_MAX > 2147483647;
if ($object->type == 'integer') {
$object->format = $has64bit
? 'int64'
: 'int32';
} elseif ($object->type == 'number') {
$object->format = $has64bit
? 'double'
: 'float';
if (isset($object->type)) {
if ($object->type == 'integer') {
$object->format = $has64bit
? 'int64'
: 'int32';
} elseif ($object->type == 'number') {
$object->format = $has64bit
? 'double'
: 'float';
}
}
}
private function nickname(array $route)
private function operationId(array $route)
{
static $hash = array();
$id = $route['httpMethod'] . ' ' . $route['url'];
if (isset($hash[$id])) {
return $hash[$id];
}
$class = Util::getShortName($route['className']);
$method = $route['methodName'];
if (isset(static::$prefixes[$method])) {
$method = static::$prefixes[$method];
$method = static::$prefixes[$method] . $class;
} else {
$method = str_replace(
array_keys(static::$prefixes),
array_values(static::$prefixes),
$method
);
$method = lcfirst($class) . ucfirst($method);
}
while (isset($hash[$method]) && $route['url'] != $hash[$method]) {
//create another one
$method .= '_';
}
$hash[$method] = $route['url'];
$hash[$id] = $method;
return $method;
}
private function nameModel(array $route)
private function modelName(array $route)
{
static $hash = array();
$count = 1;
//$name = str_replace('/', '-', $route['url']) . 'Model';
$name = $route['className'] . 'Model';
while (isset($hash[$name . $count])) {
//create another one
$count++;
}
$name .= $count;
$hash[$name] = $route['url'];
return $name;
return $this->operationId($route) . 'Model';
}
private function authorizations()
private function securityDefinitions()
{
$r = new stdClass();
$r->apiKey = (object)array(
$r->api_key = (object)array(
'type' => 'apiKey',
'passAs' => 'query',
'keyname' => 'api_key',
'name' => 'api_key',
'in' => 'query',
);
return $r;
}

View File

@ -2,16 +2,22 @@
/**
* Class ExplorerInfo
* @package Luracast\Restler
*
* @package Luracast\Restler
*
* @version 3.0.0rc6
*/
class ExplorerInfo
{
public static $title = 'Restler API Explorer';
public static $description = 'Live API Documentation';
public static $termsOfServiceUrl = null;
public static $contact = 'arul@luracast.com';
public static $license = 'LGPL-2.1';
public static $licenseUrl = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html';
public static $termsOfService = null;
public static $contact = array(
'name' => 'Restler Support',
'url' => 'luracast.com/products/restler',
'email' => 'arul@luracast.com',
);
public static $license = array(
'name' => 'LGPL-2.1',
'url' => 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html',
);
}

View File

@ -2,7 +2,7 @@
namespace Luracast\Restler\Format;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
use Luracast\Restler\RestException;
/**
@ -44,10 +44,10 @@ class CsvFormat extends Format implements iDecodeStream
*/
public function encode($data, $humanReadable = false)
{
$char = Object::$separatorChar;
Object::$separatorChar = false;
$data = Object::toArray($data);
Object::$separatorChar = $char;
$char = Obj::$separatorChar;
Obj::$separatorChar = false;
$data = Obj::toArray($data);
Obj::$separatorChar = $char;
if (is_array($data) && array_values($data) == $data) {
//if indexed array
$lines = array();
@ -109,10 +109,10 @@ class CsvFormat extends Format implements iDecodeStream
while (($row = static::getRow(array_shift($lines), $keys)) !== FALSE)
$decoded [] = $row;
$char = Object::$separatorChar;
Object::$separatorChar = false;
$decoded = Object::toArray($decoded);
Object::$separatorChar = $char;
$char = Obj::$separatorChar;
Obj::$separatorChar = false;
$decoded = Obj::toArray($decoded);
Obj::$separatorChar = $char;
return $decoded;
}
@ -172,10 +172,10 @@ class CsvFormat extends Format implements iDecodeStream
while (($row = static::getRow(stream_get_line($stream, 0, PHP_EOL), $keys)) !== FALSE)
$decoded [] = $row;
$char = Object::$separatorChar;
Object::$separatorChar = false;
$decoded = Object::toArray($decoded);
Object::$separatorChar = $char;
$char = Obj::$separatorChar;
Obj::$separatorChar = false;
$decoded = Obj::toArray($decoded);
Obj::$separatorChar = $char;
return $decoded;
}
}

View File

@ -11,7 +11,7 @@ use Illuminate\View\Engines\EngineResolver;
use Illuminate\View\Factory;
use Illuminate\View\FileViewFinder;
use Illuminate\View\View;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
use Luracast\Restler\Defaults;
use Luracast\Restler\RestException;
use Luracast\Restler\Restler;
@ -315,7 +315,7 @@ class HtmlFormat extends DependentFormat
$error = $success ? null : $exception->getMessage();
$data = array(
'response' => static::$convertResponseToArray
? Object::toArray($data)
? Obj::toArray($data)
: $data,
'stages' => $this->restler->getEvents(),
'success' => $success,

View File

@ -1,7 +1,7 @@
<?php
namespace Luracast\Restler\Format;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
use Luracast\Restler\RestException;
/**
@ -43,6 +43,13 @@ class JsonFormat extends Format
*/
public static $bigIntAsString = null;
/**
* @var boolean|null shim for json_decode JSON_NUMERIC_CHECK set it to
* null to
* use smart defaults
*/
public static $numbersAsNumbers = null;
const MIME = 'application/json';
const EXTENSION = 'json';
@ -80,13 +87,17 @@ class JsonFormat extends Format
$options |= JSON_UNESCAPED_UNICODE;
}
$result = json_encode(Object::toArray($data, true), $options);
if (self::$numbersAsNumbers) {
$options |= JSON_NUMERIC_CHECK;
}
$result = json_encode(Obj::toArray($data, true), $options);
$this->handleJsonError();
return $result;
}
$result = json_encode(Object::toArray($data, true));
$result = json_encode(Obj::toArray($data, true));
$this->handleJsonError();
if ($humanReadable) {
@ -116,6 +127,10 @@ class JsonFormat extends Format
public function decode($data)
{
if(empty($data)){
return null;
}
$options = 0;
if (self::$bigIntAsString) {
if ((PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4) // PHP >= 5.4
@ -142,7 +157,7 @@ class JsonFormat extends Format
throw new RestException(400, 'Error parsing JSON');
}
return Object::toArray($decoded);
return Obj::toArray($decoded);
}
/**
@ -259,4 +274,4 @@ class JsonFormat extends Format
throw new \RuntimeException('Error encoding/decoding JSON: '. $message);
}
}
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace Luracast\Restler\Format;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
use CFPropertyList\CFTypeDetector;
use CFPropertyList\CFPropertyList;
@ -61,7 +61,7 @@ class PlistFormat extends DependentMultiFormat
$plist = new CFPropertyList ();
$td = new CFTypeDetector ();
$guessedStructure = $td->toCFType(
Object::toArray($data)
Obj::toArray($data)
);
$plist->add($guessedStructure);

View File

@ -25,7 +25,9 @@ class UploadFormat extends Format
2 => "The uploaded file exceeds the maximum allowed size",
3 => "The uploaded file was only partially uploaded",
4 => "No file was uploaded",
6 => "Missing a temporary folder"
6 => "Missing a temporary folder",
7 => "Failed to write file to disk",
8 => "A PHP extension stopped the file upload"
);
/**
* use it if you need to restrict uploads based on file type

View File

@ -1,7 +1,7 @@
<?php
namespace Luracast\Restler\Format;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
use Luracast\Restler\RestException;
use SimpleXMLElement;
use XMLWriter;
@ -89,7 +89,7 @@ class XmlFormat extends Format
public function encode($data, $humanReadable = false)
{
$data = Object::toArray($data);
$data = Obj::toArray($data);
$xml = new XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', $this->charset);

View File

@ -2,7 +2,7 @@
namespace Luracast\Restler\Format;
use Symfony\Component\Yaml\Yaml;
use Luracast\Restler\Data\Object;
use Luracast\Restler\Data\Obj;
/**
* YAML Format for Restler Framework
@ -26,7 +26,7 @@ class YamlFormat extends DependentFormat
public function encode($data, $humanReadable = false)
{
return @Yaml::dump(Object::toArray($data), $humanReadable ? 10 : 4);
return @Yaml::dump(Obj::toArray($data), $humanReadable ? 10 : 4);
}
public function decode($data)

View File

@ -34,7 +34,6 @@ class PassThrough
* @param bool $isPublic cache control, is it public or private
*
* @throws RestException
* @internal param string $pragma
*
*/
public static function file($filename, $forceDownload = false, $expires = 0, $isPublic = true)

View File

@ -538,7 +538,7 @@ class Restler extends EventDispatcher
if ($version && $version <= $this->apiVersion) {
$this->requestedApiVersion = $version;
$path = explode('/', $path, 2);
$path = $path[1];
$path = count($path) == 2 ? $path[1] : '';
}
} else {
$this->requestedApiVersion = $this->apiMinimumVersion;
@ -718,7 +718,8 @@ class Restler extends EventDispatcher
. $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
header('Access-Control-Allow-Origin: ' .
(Defaults::$accessControlAllowOrigin == '*' ? $_SERVER['HTTP_ORIGIN'] : Defaults::$accessControlAllowOrigin));
((Defaults::$accessControlAllowOrigin == '*' && isset($_SERVER['HTTP_ORIGIN']))
? $_SERVER['HTTP_ORIGIN'] : Defaults::$accessControlAllowOrigin));
header('Access-Control-Allow-Credentials: true');
exit(0);
@ -1195,7 +1196,7 @@ class Restler extends EventDispatcher
foreach ($this->errorClasses as $className) {
if (method_exists($className, $method)) {
$obj = Scope::get($className);
if ($obj->$method())
if ($obj->$method($exception))
$handled = true;
}
}
@ -1397,6 +1398,135 @@ class Restler extends EventDispatcher
$this->errorClasses[] = $className;
}
/**
* protected methods will need at least one authentication class to be set
* in order to allow that method to be executed. When multiple authentication
* classes are in use, this function provides better performance by setting
* all auth classes through a single function call.
*
* @param array $classNames array of associative arrays containing
* the authentication class name & optional
* url prefix for mapping.
*/
public function setAuthClasses(array $classNames)
{
$this->authClasses = array_merge($this->authClasses, array_values($classNames));
}
/**
* Add multiple api classes through this method.
*
* This method provides better performance when large number
* of API classes are in use as it processes them all at once,
* as opposed to hundreds (or more) addAPIClass calls.
*
*
* All the public methods that do not start with _ (underscore)
* will be will be exposed as the public api by default.
*
* All the protected methods that do not start with _ (underscore)
* will exposed as protected api which will require authentication
*
* @param array $map array of associative arrays containing
* the class name & optional url prefix
* for mapping.
*
* @return null
*
* @throws Exception when supplied with invalid class name
*/
public function mapAPIClasses(array $map)
{
try {
if ($this->productionMode && is_null($this->cached)) {
$routes = $this->cache->get('routes');
if (isset($routes) && is_array($routes)) {
$this->apiVersionMap = $routes['apiVersionMap'];
unset($routes['apiVersionMap']);
Routes::fromArray($routes);
$this->cached = true;
} else {
$this->cached = false;
}
}
$maxVersionMethod = '__getMaximumSupportedVersion';
if (!$this->productionMode || !$this->cached) {
foreach ($map as $className => $resourcePath) {
if (is_numeric($className)) {
$className = $resourcePath;
$resourcePath = null;
}
if (isset(Scope::$classAliases[$className])) {
$className = Scope::$classAliases[$className];
}
if (class_exists($className)) {
if (method_exists($className, $maxVersionMethod)) {
$max = $className::$maxVersionMethod();
for ($i = 1; $i <= $max; $i++) {
$this->apiVersionMap[$className][$i] = $className;
}
} else {
$this->apiVersionMap[$className][1] = $className;
}
}
//versioned api
if (false !== ($index = strrpos($className, '\\'))) {
$name = substr($className, 0, $index)
. '\\v{$version}' . substr($className, $index);
} else {
if (false !== ($index = strrpos($className, '_'))) {
$name = substr($className, 0, $index)
. '_v{$version}' . substr($className, $index);
} else {
$name = 'v{$version}\\' . $className;
}
}
for ($version = $this->apiMinimumVersion;
$version <= $this->apiVersion;
$version++) {
$versionedClassName = str_replace('{$version}', $version,
$name);
if (class_exists($versionedClassName)) {
Routes::addAPIClass($versionedClassName,
Util::getResourcePath(
$className,
$resourcePath
),
$version
);
if (method_exists($versionedClassName, $maxVersionMethod)) {
$max = $versionedClassName::$maxVersionMethod();
for ($i = $version; $i <= $max; $i++) {
$this->apiVersionMap[$className][$i] = $versionedClassName;
}
} else {
$this->apiVersionMap[$className][$version] = $versionedClassName;
}
} elseif (isset($this->apiVersionMap[$className][$version])) {
Routes::addAPIClass($this->apiVersionMap[$className][$version],
Util::getResourcePath(
$className,
$resourcePath
),
$version
);
}
}
}
}
} catch (Exception $e) {
$e = new Exception(
"mapAPIClasses failed. " . $e->getMessage(),
$e->getCode(),
$e
);
$this->setSupportedFormats('JsonFormat');
$this->message($e);
}
}
/**
* Associated array that maps formats to their respective format class name
*
@ -1484,6 +1614,19 @@ class Restler extends EventDispatcher
public function __destruct()
{
if ($this->productionMode && !$this->cached) {
if (empty($this->url) && empty($this->requestMethod)) {
// url and requestMethod is NOT set:
// This can only happen, when an exception was thrown outside of restler, so that the method Restler::handle was NOT called.
// In this case, the routes can now be corrupt/incomplete, because we don't know, if all API-classes could be registered
// before the exception was thrown. So, don't cache the routes, because the routes can now be corrupt/incomplete!
return;
}
if ($this->exception instanceof RestException && $this->exception->getStage() === 'setup') {
// An exception has occured during configuration of restler. Maybe we could not add all API-classes correctly!
// So, don't cache the routes, because the routes can now be corrupt/incomplete!
return;
}
$this->cache->set(
'routes',
Routes::toArray() +

View File

@ -293,8 +293,6 @@ class Routes
}
$url = empty($methodUrl) ? rtrim($resourcePath, '/')
: $resourcePath . $methodUrl;
$lastPathParam = array_keys($pathParams);
$lastPathParam = end($lastPathParam);
for ($position = 0; $position < count($params); $position++) {
$from = $metadata['param'][$position][$dataName]['from'];
if ($from == 'body' && ($httpMethod == 'GET' ||
@ -307,6 +305,7 @@ class Routes
if (empty($pathParams) || $allowAmbiguity) {
static::addPath($url, $call, $httpMethod, $version);
}
$lastPathParam = end($pathParams);
foreach ($pathParams as $position) {
if (!empty($url))
$url .= '/';

View File

@ -52,7 +52,7 @@ class Scope
'MemcacheCache' => 'Luracast\Restler\MemcacheCache',
//Utility classes
'Object' => 'Luracast\Restler\Data\Object',
'Obj' => 'Luracast\Restler\Data\Obj',
'Text' => 'Luracast\Restler\Data\Text',
'Arr' => 'Luracast\Restler\Data\Arr',
@ -194,6 +194,11 @@ class Scope
{
if (empty($className) || !is_string($className))
return false;
if (self::isPrimitiveDataType($className)) {
return false;
}
$divider = '\\';
$qualified = false;
if ($className{0} == $divider) {
@ -212,4 +217,14 @@ class Scope
}
return false;
}
/**
* @param string $stringName
* @return boolean
*/
private static function isPrimitiveDataType($stringName)
{
$primitiveDataTypes = array('Array', 'array', 'bool', 'boolean', 'float', 'int', 'integer', 'string');
return in_array($stringName, $primitiveDataTypes);
}
}

View File

@ -226,6 +226,10 @@ class Util
public static function getShortName($className)
{
// @CHANGE LDR
if (! is_string($className)) return '';
//var_dump($className);
$className = explode('\\', $className);
return end($className);
}

File diff suppressed because it is too large Load Diff

View File

@ -126,6 +126,7 @@
max-width: 960px;
margin-left: auto;
margin-right: auto;
/* JSONEditor specific styling */
}
.swagger-section .swagger-ui-wrap b,
.swagger-section .swagger-ui-wrap strong {
@ -274,6 +275,9 @@
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
@ -294,7 +298,13 @@
.swagger-section .swagger-ui-wrap .message-fail {
color: #cc0000;
}
.swagger-section .swagger-ui-wrap .info_contact {
.swagger-section .swagger-ui-wrap .info_url {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_email {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_name {
padding-bottom: 5px;
}
.swagger-section .swagger-ui-wrap .info_description {
@ -350,7 +360,7 @@
font-size: .85em;
line-height: 1.2em;
overflow: auto;
max-height: 200px;
max-height: 400px;
cursor: pointer;
}
.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav {
@ -391,6 +401,43 @@
font-weight: bold;
color: #000;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper {
border-spacing: 0;
position: absolute;
background-color: #ffffff;
border: 1px solid #bbbbbb;
display: none;
font-size: 11px;
max-width: 400px;
line-height: 30px;
color: black;
padding: 5px;
margin-left: 10px;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper th {
text-align: center;
background-color: #eeeeee;
border: 1px solid #bbbbbb;
font-size: 11px;
color: #666666;
font-weight: bold;
padding: 5px;
line-height: 15px;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:first-child,
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:last-child {
display: inline;
}
.swagger-section .swagger-ui-wrap .model-signature .description .propDesc.markdown > p:not(:first-child):before {
display: block;
content: '';
}
.swagger-section .swagger-ui-wrap .model-signature .description span:last-of-type.propDesc.markdown > p:only-child {
margin-right: -3px;
}
.swagger-section .swagger-ui-wrap .model-signature .propName {
font-weight: bold;
}
@ -412,6 +459,17 @@
.swagger-section .swagger-ui-wrap .required {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap .editor_holder {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
font-size: 0.9em;
}
.swagger-section .swagger-ui-wrap .editor_holder label {
font-weight: normal!important;
/* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
}
.swagger-section .swagger-ui-wrap .editor_holder label.required {
font-weight: bold!important;
}
.swagger-section .swagger-ui-wrap input.parameter {
width: 300px;
border: 1px solid #aaa;
@ -761,6 +819,9 @@
outline: 2px solid black;
outline-color: #cc0000;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form select[name='parameterContentType'] {
max-width: 300px;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre {
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
padding: 10px;
@ -1034,6 +1095,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title {
font-style: bold;
}
@ -1072,14 +1136,14 @@
font-size: 24px;
padding: 10px 0;
}
.swagger-section .api-popup-dialog p.error-msg {
.swagger-section .api-popup-dialog .error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
.swagger-section .api-popup-dialog button.api-popup-authbtn {
.swagger-section .api-popup-dialog .api-popup-authbtn {
height: 30px;
}
.swagger-section .api-popup-dialog button.api-popup-cancel {
.swagger-section .api-popup-dialog .api-popup-cancel {
height: 30px;
}
.swagger-section .api-popup-scopes {
@ -1089,14 +1153,14 @@
padding: 5px 0;
line-height: 20px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-scopes li input {
position: relative;
top: 2px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-actions {
padding-top: 10px;
}
@ -1106,8 +1170,16 @@
.swagger-section .auth {
float: right;
}
.swagger-section #api_information_panel {
position: absolute;
.swagger-section .api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
}
.swagger-section .api-ic .api_information_panel {
position: relative;
margin-top: 20px;
margin-left: -5px;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
@ -1118,34 +1190,32 @@
color: black;
padding: 5px;
}
.swagger-section #api_information_panel p .api-msg-enabled {
.swagger-section .api-ic .api_information_panel p .api-msg-enabled {
color: green;
}
.swagger-section #api_information_panel p .api-msg-disabled {
.swagger-section .api-ic .api_information_panel p .api-msg-disabled {
color: red;
}
.swagger-section .api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
.swagger-section .api-ic:hover .api_information_panel {
position: absolute;
display: block;
}
.swagger-section .ic-info {
background-position: 0 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-warning {
background-position: -60px 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-error {
background-position: -30px 0;
width: 18px;
margin-top: -7px;
margin-top: -6px;
margin-left: 4px;
}
.swagger-section .ic-off {
@ -1161,42 +1231,39 @@
cursor: pointer;
}
.swagger-section #header {
background-color: #89bf04;
background-color: #646257;
padding: 14px;
}
.swagger-section #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
.swagger-section #input_baseUrl {
width: 400px;
}
.swagger-section #header form#api_selector {
.swagger-section #api_selector {
display: block;
clear: none;
float: right;
}
.swagger-section #header form#api_selector .input {
.swagger-section #api_selector .input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
}
.swagger-section #header form#api_selector .input input#input_apiKey {
.swagger-section #api_selector input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
.swagger-section #input_apiKey {
width: 200px;
}
.swagger-section #header form#api_selector .input input#input_baseUrl {
width: 400px;
}
.swagger-section #header form#api_selector .input a#explore {
.swagger-section #explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
background-color: #000000;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
@ -1204,13 +1271,16 @@
-khtml-border-radius: 4px;
border-radius: 4px;
}
.swagger-section #header form#api_selector .input a#explore:hover {
background-color: #547f00;
.swagger-section #explore:hover {
background-color: #a41e22;
}
.swagger-section #header form#api_selector .input input {
font-size: 0.9em;
padding: 3px;
margin: 0;
.swagger-section #header #logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
.swagger-section #content_message {
margin: 10px 15px;
@ -1222,3 +1292,13 @@
text-align: center;
padding-top: 10px;
}
.swagger-section .swagger-collapse:before {
content: "-";
}
.swagger-section .swagger-expand:before {
content: "+";
}
#input_baseUrl {
display: none;
}

View File

@ -0,0 +1,250 @@
.swagger-section #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo.png) no-repeat left center;
padding: 20px 0 20px 40px;
}
#text-head {
font-size: 80px;
font-family: 'Roboto', sans-serif;
color: #ffffff;
float: right;
margin-right: 20%;
}
.navbar-fixed-top .navbar-nav {
height: auto;
}
.navbar-fixed-top .navbar-brand {
height: auto;
}
.navbar-header {
height: auto;
}
.navbar-inverse {
background-color: #000;
border-color: #000;
}
#navbar-brand {
margin-left: 20%;
}
.navtext {
font-size: 10px;
}
.h1,
h1 {
font-size: 60px;
}
.navbar-default .navbar-header .navbar-brand {
color: #a2dfee;
}
/* tag titles */
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a {
color: #393939;
font-family: 'Arvo', serif;
font-size: 1.5em;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover {
color: black;
}
.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 {
color: #525252;
padding-left: 0px;
display: block;
clear: none;
float: left;
font-family: 'Arvo', serif;
font-weight: bold;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #0A0A0A;
}
.container1 {
width: 1500px;
margin: auto;
margin-top: 0;
background-image: url('../images/shield.png');
background-repeat: no-repeat;
background-position: -40px -20px;
margin-bottom: 210px;
}
.container-inner {
width: 1200px;
margin: auto;
background-color: rgba(223, 227, 228, 0.75);
padding-bottom: 40px;
padding-top: 40px;
border-radius: 15px;
}
.header-content {
padding: 0;
width: 1000px;
}
.title1 {
font-size: 80px;
font-family: 'Vollkorn', serif;
color: #404040;
text-align: center;
padding-top: 40px;
padding-bottom: 100px;
}
#icon {
margin-top: -18px;
}
.subtext {
font-size: 25px;
font-style: italic;
color: #08b;
text-align: right;
padding-right: 250px;
}
.bg-primary {
background-color: #00468b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus {
color: #08b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:hover {
color: #08b;
}
.navbar-default .nav > li > a,
.navbar-default .nav > li > a:focus:hover {
color: #08b;
}
.text-faded {
font-size: 25px;
font-family: 'Vollkorn', serif;
}
.section-heading {
font-family: 'Vollkorn', serif;
font-size: 45px;
padding-bottom: 10px;
}
hr {
border-color: #00468b;
padding-bottom: 10px;
}
.description {
margin-top: 20px;
padding-bottom: 200px;
}
.description li {
font-family: 'Vollkorn', serif;
font-size: 25px;
color: #525252;
margin-left: 28%;
padding-top: 5px;
}
.gap {
margin-top: 200px;
}
.troubleshootingtext {
color: rgba(255, 255, 255, 0.7);
padding-left: 30%;
}
.troubleshootingtext li {
list-style-type: circle;
font-size: 25px;
padding-bottom: 5px;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1000;
}
.block.response_body.json:hover {
cursor: pointer;
}
.backdrop {
color: blue;
}
#myModal {
height: 100%;
}
.modal-backdrop {
bottom: 0;
position: fixed;
}
.curl {
padding: 10px;
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
font-size: 0.9em;
max-height: 400px;
margin-top: 5px;
overflow-y: auto;
background-color: #fcf6db;
border: 1px solid #e5e0c6;
border-radius: 4px;
}
.curl_title {
font-size: 1.1em;
margin: 0;
padding: 15px 0 5px;
font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
font-weight: 500;
line-height: 1.1;
}
.footer {
display: none;
}
.swagger-section .swagger-ui-wrap h2 {
padding: 0;
}
h2 {
margin: 0;
margin-bottom: 5px;
}
.markdown p {
font-size: 15px;
font-family: 'Arvo', serif;
}
.swagger-section .swagger-ui-wrap .code {
font-size: 15px;
font-family: 'Arvo', serif;
}
.swagger-section .swagger-ui-wrap b {
font-family: 'Arvo', serif;
}
#signin:hover {
cursor: pointer;
}
.dropdown-menu {
padding: 15px;
}
.navbar-right .dropdown-menu {
left: 0;
right: auto;
}
#signinbutton {
width: 100%;
height: 32px;
font-size: 13px;
font-weight: bold;
color: #08b;
}
.navbar-default .nav > li .details {
color: #000000;
text-transform: none;
font-size: 15px;
font-weight: normal;
font-family: 'Open Sans', sans-serif;
font-style: italic;
line-height: 20px;
top: -2px;
}
.navbar-default .nav > li .details:hover {
color: black;
}
#signout {
width: 100%;
height: 32px;
font-size: 13px;
font-weight: bold;
color: #08b;
}

View File

@ -0,0 +1,14 @@
/* Google Font's Droid Sans */
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 400;
src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf') format('truetype');
}
/* Google Font's Droid Sans Bold */
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 700;
src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf') format('truetype');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 980 B

View File

@ -1,85 +1,126 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Api Explorer</title>
<!-- @CHANGE LDR Remove external links <link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>-->
<link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='css/screen.css' media='print' rel='stylesheet' type='text/css'/>
<script type="text/javascript" src="lib/shred.bundle.js"></script>
<link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
<!-- @CHANGE LDR Remove external links <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> -->
<script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
<script src='lib/handlebars-2.0.0.js' type='text/javascript'></script>
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
<script src='lib/marked.js' type='text/javascript'></script>
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<!-- Some basic translations -->
<!-- <script src='lang/translator.js' type='text/javascript'></script> -->
<!-- <script src='lang/ru.js' type='text/javascript'></script> -->
<!-- <script src='lang/en.js' type='text/javascript'></script> -->
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "resources.json",
validatorUrl: null,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded API Explorer");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
defaultModelRendering: 'model',
onFailure: function(data) {
log("Unable to Load API Explorer");
},
docExpansion: "none",
/*showRequestHeaders: true,
jsonEditor: true */
/*, sorter : "alpha"*/
});
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
/* @CHANGE LDR We set DOLAPIKEY into header */
log("added key " + key);
/* Disabled for security reason. We keep only param in header
window.authorizations.add("key", new ApiKeyAuthorization("DOLAPIKEY", key, "query"));
console.log("param api_key added with value "+key);
*/
window.authorizations.add("key2", new ApiKeyAuthorization("DOLAPIKEY", key, "header"));
console.log("header DOLAPIKEY added with value "+key);
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = "swagger.json";
}
// Pre load translate...
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: ",",
additionalQueryStringParams: {}
});
}
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate();
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
addApiKeyAuthorization();
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
jsonEditor: false,
apisSorter: "alpha",
defaultModelRendering: 'schema',
showRequestHeaders: false
});
function addApiKeyAuthorization(){
var key = encodeURIComponent($('#input_apiKey')[0].value);
if(key && key.trim() != "") {
/* @CHANGE LDR We set DOLAPIKEY into header */
/* log("added key " + key); */
log("added key");
/* Disabled for security reason. We keep only param in header
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query");
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
log("added key " + key);
*/
var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("DOLAPIKEY", key, "header");
window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
/* log("header DOLAPIKEY added with value "+key); */
log("header DOLAPIKEY added");
}
}
$('#input_apiKey').change(addApiKeyAuthorization);
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
*/
window.swaggerUi.load();
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
})
window.swaggerUi.load();
});
</script>
<style>
.info_title, .info_description, .info_contact, .info_license {
.info_title, .info_description, .info_contact, .info_name, .info_url, .info_email, .info_license {
display: none;
}
</style>
</style>
</head>
<body class="swagger-section">
@ -87,22 +128,14 @@
<div class="swagger-ui-wrap">
<a id="logo" href="#">API Explorer</a>
<form id='api_selector'>
<!-- @CHANGE LDR
<div class='input icon-btn'>
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
</div>
<div class='input icon-btn'>
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
</div>
-->
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="hidden" value="resources.json"/></div>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div class='input'><input placeholder="DOLAPIKEY" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
<div class='input'><a id="explore" href="#" data-sw-translate>Explore</a></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>

View File

@ -0,0 +1,55 @@
'use strict';
/* jshint quotmark: double */
window.SwaggerTranslator.learn({
"Warning: Deprecated":"Warning: Deprecated",
"Implementation Notes":"Implementation Notes",
"Response Class":"Response Class",
"Status":"Status",
"Parameters":"Parameters",
"Parameter":"Parameter",
"Value":"Value",
"Description":"Description",
"Parameter Type":"Parameter Type",
"Data Type":"Data Type",
"Response Messages":"Response Messages",
"HTTP Status Code":"HTTP Status Code",
"Reason":"Reason",
"Response Model":"Response Model",
"Request URL":"Request URL",
"Response Body":"Response Body",
"Response Code":"Response Code",
"Response Headers":"Response Headers",
"Hide Response":"Hide Response",
"Headers":"Headers",
"Try it out!":"Try it out!",
"Show/Hide":"Show/Hide",
"List Operations":"List Operations",
"Expand Operations":"Expand Operations",
"Raw":"Raw",
"can't parse JSON. Raw result":"can't parse JSON. Raw result",
"Model Schema":"Model Schema",
"Model":"Model",
"Click to set as parameter value":"Click to set as parameter value",
"apply":"apply",
"Username":"Username",
"Password":"Password",
"Terms of service":"Terms of service",
"Created by":"Created by",
"See more at":"See more at",
"Contact the developer":"Contact the developer",
"api version":"api version",
"Response Content Type":"Response Content Type",
"Parameter content type:":"Parameter content type:",
"fetching resource":"fetching resource",
"fetching resource list":"fetching resource list",
"Explore":"Explore",
"Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
"Please specify the protocol for":"Please specify the protocol for",
"Can't read swagger JSON from":"Can't read swagger JSON from",
"Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
"Unable to read api":"Unable to read api",
"from path":"from path",
"server returned":"server returned"
});

Some files were not shown because too many files have changed in this diff Show More