'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'
';
- else
+ else
{
if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
$nophoto='';
@@ -1003,14 +1003,14 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.='';
- if ($object->element == 'action')
+ if ($object->element == 'action')
{
$cssclass='photorefcenter';
$nophoto=img_picto('', 'title_agenda', '', false, 1);
@@ -1042,7 +1042,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($showbarcode) $morehtmlleft.='
'.$form->showbarcode($object).'
';
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
$morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
- }
+ }
elseif ($object->element == 'product')
{
//$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
@@ -1062,7 +1062,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
elseif ($object->element == 'facture' || $object->element == 'invoice' || $object->element == 'invoice_supplier')
{
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
- if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
+ if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt;
}
elseif ($object->element == 'chargesociales')
@@ -1084,7 +1084,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
else { // Generic case
$tmptxt=$object->getLibStatut(6);
- if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
+ if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
$morehtmlstatus.=$tmptxt;
}
if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; // For thirdparty
@@ -1278,9 +1278,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
$reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0;
$formatwithoutreduce = preg_replace('/reduceformat/','',$format);
if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day
-
+
// Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
- // TODO Add format daysmallyear and dayhoursmallyear
+ // TODO Add format daysmallyear and dayhoursmallyear
if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short);
else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short);
else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration);
@@ -1782,7 +1782,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
$newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4);
}
}
-
+
if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
{
if (! empty($conf->browser->phone) || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone
@@ -1912,7 +1912,7 @@ function dol_user_country()
* @param int $mode thirdparty|contact|member|other
* @param int $id Id of object
* @param int $noprint No output. Result is the function return
- * @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
+ * @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
* @return string|void Nothing if noprint is 0, formatted address if noprint is 1
* @see dol_format_address
*/
@@ -1933,7 +1933,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0, $charfornl
{
if (empty($charfornl)) $out.=nl2br($address);
else $out.=preg_replace('/[\r\n]+/', $charfornl, $address);
-
+
$showgmap=$showomap=0;
// TODO Add a hook here
@@ -2061,7 +2061,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
print '
'.$langs->trans("NotEnoughDataYet").'
';
return;
}
-
+
if (empty($conf->use_javascript_ajax)) return;
$jsgraphlib='flot';
$datacolor=array();
@@ -2230,7 +2230,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
global $conf;
if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
-
+
if (empty($stringencoding)) $stringencoding='UTF-8';
// reduce for small screen
if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
@@ -3196,11 +3196,11 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
function load_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=-1, $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0)
{
global $conf,$langs;
-
+
$savlimit = $limit;
$savtotalnboflines = $totalnboflines;
$totalnboflines=abs($totalnboflines);
-
+
if ($picto == 'setup') $picto='title_setup.png';
if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif';
if ($limit < 0) $limit = $conf->liste_limit;
@@ -3433,7 +3433,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
{
$morelabel='';
-
+
if (preg_match('/%/',$rate))
{
$rate=str_replace('%','',$rate);
@@ -3636,7 +3636,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
/**
* Output a dimension with best unit
- *
+ *
* @param float $dimension Dimension
* @param int $unit Unit of dimension (0, -3, ...)
* @param string $type 'weight', 'volume', ...
@@ -3648,16 +3648,16 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
-
- if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
+
+ if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
{
$dimension = $dimension * 1000000;
- $unit = $unit - 6;
+ $unit = $unit - 6;
}
elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
{
$dimension = $dimension * 1000;
- $unit = $unit - 3;
+ $unit = $unit - 3;
}
elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
{
@@ -3669,9 +3669,9 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=
$dimension = $dimension / 1000;
$unit = $unit + 3;
}
-
+
$ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
-
+
return $ret;
}
@@ -3702,12 +3702,12 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
$vatratecleaned = trim($reg[1]);
$vatratecode = $reg[2];
}
-
+
/*if ($thirdparty_buyer->country_code != $thirdparty_seller->country_code)
{
return 0;
}*/
-
+
// Some test to guess with no need to make database access
if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe
{
@@ -3805,7 +3805,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
if ($local==1) return $obj->localtax1;
elseif ($local==2) return $obj->localtax2;
}
-
+
return 0;
}
@@ -3865,7 +3865,7 @@ function get_localtax_by_third($local)
/**
* Get vat rate and npr from id.
- * You can call getLocalTaxesFromRate after to get other fields
+ * You can call getLocalTaxesFromRate after to get other fields
*
* @param int $vatrowid Line ID into vat rate table.
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
@@ -3919,7 +3919,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
$vatratecleaned = $reg[1];
$vatratecode = $reg[2];
}
-
+
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
@@ -3932,7 +3932,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
$sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
}
-
+
$resql=$db->query($sql);
if ($resql)
{
@@ -4339,7 +4339,7 @@ function yn($yesno, $case=1, $color=0)
/**
* Return a path to have a directory according to object.
* New usage: $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart')
- * Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
+ * Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
*
* @param string $num Id of object (deprecated, $object will be used in future)
* @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future)
@@ -4356,7 +4356,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
$path = '';
$arrayforoldpath=array('cheque','user','category','holiday','shipment','supplier_invoice','invoice_supplier','mailing');
- if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
+ if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
if (! empty($level) && in_array($modulepart, $arrayforoldpath))
{
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
@@ -4509,7 +4509,7 @@ function dolGetFirstLineOfText($text)
{
$firstline=preg_replace('/
]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/
]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
-
+
}
else
{
@@ -5415,7 +5415,7 @@ function picto_from_langcode($codelang)
}
/**
- * Complete or removed entries into a head array (used to build tabs).
+ * Complete or removed entries into a head array (used to build tabs).
* For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab'].
* Or by change using hook completeTabsHead
*
@@ -5445,7 +5445,7 @@ function picto_from_langcode($codelang)
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
{
global $hookmanager;
-
+
if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type]))
{
foreach ($conf->modules_parts['tabs'][$type] as $value)
@@ -5511,7 +5511,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
}
}
}
-
+
// No need to make a return $head. Var is modified as a reference
if (! empty($hookmanager))
{
@@ -5549,11 +5549,11 @@ function printCommonFooter($zone='private')
{
print ''."\n";
print ''."\n";
}
-
+
// Google Analytics (need Google module)
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
{
@@ -5717,7 +5717,7 @@ function dol_getmypid()
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
* If param $mode is 2, can contains a list of id separated by comma like "1,3,4"
* @param integer $mode 0=value is list of keywords, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4')
- * @param integer $nofirstand 1=Do now output the first 'AND'
+ * @param integer $nofirstand 1=Do not output the first 'AND'
* @return string $res The statement to append to the SQL query
*/
function natural_search($fields, $value, $mode=0, $nofirstand=0)
@@ -5732,6 +5732,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
{
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
}
+
+ $value = preg_replace('/\s*\|\s*/','|', $value);
+
$crits = explode(' ', $value);
$res = '';
if (! is_array($fields)) $fields = array($fields);
@@ -5786,15 +5789,15 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
$tmpcrit=trim($tmpcrit);
$tmpcrit2=$tmpcrit;
$tmpbefore='%'; $tmpafter='%';
- if (preg_match('/^[\^\$]/', $tmpcrit))
- {
+ if (preg_match('/^[\^\$]/', $tmpcrit))
+ {
$tmpbefore='';
- $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
+ $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
}
- if (preg_match('/[\^\$]$/', $tmpcrit))
- {
+ if (preg_match('/[\^\$]$/', $tmpcrit))
+ {
$tmpafter='';
- $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
+ $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
}
$newres .= $tmpbefore;
$newres .= $db->escape($tmpcrit2);
@@ -5859,7 +5862,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
function getAdvancedPreviewUrl($modulepart, $relativepath)
{
global $conf;
-
+
if (empty($conf->use_javascript_ajax)) return '';
$mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css');
diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php
index 9cf745a0da0..00153a7849d 100644
--- a/htdocs/core/lib/images.lib.php
+++ b/htdocs/core/lib/images.lib.php
@@ -37,8 +37,10 @@ $quality = 80;
*/
function image_format_supported($file)
{
+ $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm'; // See also into product.class.php
+
// Case filename is not a format image
- if (! preg_match('/(\.gif|\.jpg|\.jpeg|\.png|\.bmp)$/i',$file,$reg)) return -1;
+ if (! preg_match('/('.$regeximgext.')$/i',$file,$reg)) return -1;
// Case filename is a format image but not supported by this PHP
$imgfonction='';
@@ -47,6 +49,8 @@ function image_format_supported($file)
if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp';
+ if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm';
+ if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm';
if ($imgfonction)
{
if (! function_exists($imgfonction))
diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php
index 6f47ef6e62b..0149b581fa2 100644
--- a/htdocs/core/lib/oauth.lib.php
+++ b/htdocs/core/lib/oauth.lib.php
@@ -26,9 +26,13 @@
// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth)
$supportedoauth2array=array(
'OAUTH_GOOGLE_NAME'=>'google',
- 'OAUTH_GITHUB_NAME'=>'github'
);
+if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
+{
+ $supportedoauth2array['OAUTH_GITHUB_NAME']='github';
+}
+$supportedoauth2array['OAUTH_GITHUB_NAME']='github';
// API access parameters OAUTH
$list = array (
array(
@@ -264,7 +268,7 @@ function oauthadmin_prepare_head()
$h++;
$head[$h][0] = dol_buildpath('/admin/oauthlogintokens.php', 1);
- $head[$h][1] = $langs->trans("ManualTokenGeneration");
+ $head[$h][1] = $langs->trans("TokenManager");
$head[$h][2] = 'tokengeneration';
$h++;
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index a88e180b16a..8c6c7311f82 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -111,13 +111,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
$chaine="";
if (! empty($conf->product->enabled)) {
- $chaine.=$langs->trans("Products");
+ $chaine.=$langs->trans("TMenuProducts");
}
if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) {
- $chaine.="/";
+ $chaine.=" | ";
}
if (! empty($conf->service->enabled)) {
- $chaine.=$langs->trans("Services");
+ $chaine.=$langs->trans("TMenuServices");
}
if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
@@ -261,7 +261,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode
$idsel='tools';
if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
- if (empty($noout)) print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget);
+ if (empty($noout)) print_text_menu_entry($langs->trans("TMenuTools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget);
if (empty($noout)) print_end_menu_entry($showmode);
$menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '');
}
diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php
index a0c2a6e9de4..2ba37ad3cbd 100644
--- a/htdocs/core/modules/modAgenda.class.php
+++ b/htdocs/core/modules/modAgenda.class.php
@@ -189,7 +189,7 @@ class modAgenda extends DolibarrModules
// $r++;
$this->menu[$r]=array('fk_menu'=>0,
'type'=>'top',
- 'titre'=>'Agenda',
+ 'titre'=>'TMenuAgenda',
'mainmenu'=>'agenda',
'url'=>'/comm/action/index.php',
'langs'=>'agenda',
diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php
new file mode 100644
index 00000000000..83c3da66a47
--- /dev/null
+++ b/htdocs/core/modules/oauth/github_oauthcallback.php
@@ -0,0 +1,171 @@
+
+ *
+ * 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
.
+ */
+
+/**
+ * \file htdocs/core/modules/oauth/github_oauthcallback.php
+ * \ingroup oauth
+ * \brief Page to get oauth callback
+ */
+
+require '../../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+use OAuth\Common\Storage\DoliStorage;
+use OAuth\Common\Consumer\Credentials;
+use OAuth\OAuth2\Service\GitHub;
+
+// Define $urlwithroot
+$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+$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
+
+
+
+$action = GETPOST('action', 'alpha');
+$backtourl = GETPOST('backtourl', 'alpha');
+
+
+/**
+ * Create a new instance of the URI class with the current URI, stripping the query string
+ */
+$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
+//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
+//$currentUri->setQuery('');
+$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/github_oauthcallback.php');
+
+
+/**
+ * Load the credential for the service
+ */
+
+/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
+$serviceFactory = new \OAuth\ServiceFactory();
+$httpClient = new \OAuth\Common\Http\Client\CurlClient();
+// TODO Set options for proxy and timeout
+// $params=array('CURLXXX'=>value, ...)
+//$httpClient->setCurlParameters($params);
+$serviceFactory->setHttpClient($httpClient);
+
+// Dolibarr storage
+$storage = new DoliStorage($db, $conf);
+
+// Setup the credentials for the requests
+$credentials = new Credentials(
+ $conf->global->OAUTH_GITHUB_ID,
+ $conf->global->OAUTH_GITHUB_SECRET,
+ $currentUri->getAbsoluteUri()
+);
+
+$requestedpermissionsarray=array();
+if (GETPOST('state')) $requestedpermissionsarray=explode(',', GETPOST('state')); // Example: 'userinfo_email,userinfo_profile,cloud_print'. 'state' parameter is standard to retrieve some parameters back
+if ($action != 'delete' && empty($requestedpermissionsarray))
+{
+ print 'Error, parameter state is not defined';
+ exit;
+}
+//var_dump($requestedpermissionsarray);exit;
+
+// Instantiate the Api service using the credentials, http client and storage mechanism for the token
+/** @var $apiService Service */
+$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray);
+
+// access type needed to have oauth provider refreshing token
+//$apiService->setAccessType('offline');
+
+$langs->load("oauth");
+
+
+/*
+ * Actions
+ */
+
+
+if ($action == 'delete')
+{
+ $storage->clearToken('GitHub');
+
+ setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
+
+ header('Location: ' . $backtourl);
+ exit();
+}
+
+if (! empty($_GET['code'])) // We are coming from oauth provider page
+{
+ //llxHeader('',$langs->trans("OAuthSetup"));
+
+ //$linkback='
'.$langs->trans("BackToModuleList").' ';
+ //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
+
+ //dol_fiche_head();
+ // retrieve the CSRF state parameter
+ $state = isset($_GET['state']) ? $_GET['state'] : null;
+ //print '
';
+
+ // This was a callback request from service, get the token
+ try {
+ //var_dump($_GET['code']);
+ //var_dump($state);
+ //var_dump($apiService); // OAuth\OAuth2\Service\GitHub
+
+ //$token = $apiService->requestAccessToken($_GET['code'], $state);
+ $token = $apiService->requestAccessToken($_GET['code']);
+ // Github is a service that does not need state yo be stored.
+ // Into constructor of GitHub, the call
+ // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
+ // has not the ending parameter to true like the Google class constructor.
+
+ setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
+ } catch (Exception $e) {
+ print $e->getMessage();
+ }
+
+ $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
+ unset($_SESSION["backtourlsavedbeforeoauthjump"]);
+
+ header('Location: ' . $backtourl);
+ exit();
+}
+else // If entry on page with no parameter, we arrive here
+{
+ $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
+
+ // This may create record into oauth_state before the header redirect.
+ // Creation of record with state in this tables depend on the Provider used (see its constructor).
+ if (GETPOST('state'))
+ {
+ $url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
+ }
+ else
+ {
+ $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
+ }
+
+ // we go on oauth provider authorization page
+ header('Location: ' . $url);
+ exit();
+}
+
+
+/*
+ * View
+ */
+
+// No view at all, just actions
+
+$db->close();
+
diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php
index 3068a29098c..c69493ed9a5 100644
--- a/htdocs/core/modules/oauth/google_oauthcallback.php
+++ b/htdocs/core/modules/oauth/google_oauthcallback.php
@@ -17,7 +17,7 @@
*/
/**
- * \file htdocs/core/modules/oauth/getoauthcallback.php
+ * \file htdocs/core/modules/oauth/google_oauthcallback.php
* \ingroup oauth
* \brief Page to get oauth callback
*/
@@ -83,7 +83,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray))
/** @var $apiService Service */
$apiService = $serviceFactory->createService('Google', $credentials, $storage, $requestedpermissionsarray);
-// access type needed for google refresh token
+// access type needed to have oauth provider refreshing token
$apiService->setAccessType('offline');
$langs->load("oauth");
@@ -104,7 +104,7 @@ if ($action == 'delete')
exit();
}
-if (! empty($_GET['code'])) // We are coming from Google oauth page
+if (! empty($_GET['code'])) // We are coming from oauth provider page
{
//llxHeader('',$langs->trans("OAuthSetup"));
@@ -121,6 +121,7 @@ if (! empty($_GET['code'])) // We are coming from Google oauth page
//var_dump($_GET['code']);
//var_dump($state);
//var_dump($apiService); // OAuth\OAuth2\Service\Google
+
$token = $apiService->requestAccessToken($_GET['code'], $state);
setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
@@ -138,6 +139,8 @@ else // If entry on page with no parameter, we arrive here
{
$_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl;
+ // This may create record into oauth_state before the header redirect.
+ // Creation of record with state in this tables depend on the Provider used (see its constructor).
if (GETPOST('state'))
{
$url = $apiService->getAuthorizationUri(array('state'=>GETPOST('state')));
@@ -146,7 +149,8 @@ else // If entry on page with no parameter, we arrive here
{
$url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
}
- // we go on google authorization page
+
+ // we go on oauth provider authorization page
header('Location: ' . $url);
exit();
}
diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php
index 3d086466c87..baa5106ae93 100644
--- a/htdocs/core/modules/printing/printgcp.modules.php
+++ b/htdocs/core/modules/printing/printgcp.modules.php
@@ -66,6 +66,7 @@ class printing_printgcp extends PrintingDriver
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$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
+
$this->db = $db;
if (!$conf->oauth->enabled) {
@@ -117,10 +118,28 @@ class printing_printgcp extends PrintingDriver
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):''));
if ($token_ok) {
+ $expiredat='';
+
$refreshtoken = $token->getRefreshToken();
+
+ $endoflife=$token->getEndOfLife();
+
+ if ($endoflife == $token::EOL_NEVER_EXPIRES)
+ {
+ $expiredat = $langs->trans("Never");
+ }
+ elseif ($endoflife == $token::EOL_UNKNOWN)
+ {
+ $expiredat = $langs->trans("Unknown");
+ }
+ else
+ {
+ $expiredat=dol_print_date($endoflife, "dayhour");
+ }
+
$this->conf[] = array('varname'=>'TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
- $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info');
+ $this->conf[] = array('varname'=>'TOKEN_EXPIRE_AT', 'info'=>($expiredat), 'type'=>'info');
}
/*
if ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)) {
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 778c37f686a..8fcd0d2b930 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -134,11 +134,50 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
{
$fullpath=$dir."/".$original_file;
$result=dol_imageResizeOrCrop($fullpath,0,$_POST['sizex'],$_POST['sizey']);
-
+
if ($result == $fullpath)
{
$object->addThumbs($fullpath);
+ // Update/create database for file $fullpath
+ $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
+ $rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
+
+ include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
+ $ecmfile=new EcmFiles($db);
+ $result = $ecmfile->fetch(0, '', $rel_filename);
+ if ($result > 0) // If found
+ {
+ $filename = basename($rel_filename);
+ $rel_dir = dirname($rel_filename);
+ $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
+ $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
+
+ $ecmfile->label = md5_file(dol_osencode($fullpath));
+ $result = $ecmfile->update($user);
+ }
+ elseif ($result == 0) // If not found
+ {
+ $filename = basename($rel_filename);
+ $rel_dir = dirname($rel_filename);
+ $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
+ $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
+
+ $ecmfile->filepath = $rel_dir;
+ $ecmfile->filename = $filename;
+ $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
+ $ecmfile->fullpath_orig = $fullpath;
+ $ecmfile->gen_or_uploaded = 'unknown';
+ $ecmfile->description = ''; // indexed content
+ $ecmfile->keyword = ''; // keyword content
+ $result = $ecmfile->create($user);
+ if ($result < 0)
+ {
+ setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
+ }
+ $result = $ecmfile->create($user);
+ }
+
if ($backtourl)
{
header("Location: ".$backtourl);
@@ -168,6 +207,45 @@ if ($action == 'confirm_crop')
{
$object->addThumbs($fullpath);
+ // Update/create database for file $fullpath
+ $rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $fullpath);
+ $rel_filename = preg_replace('/^[\\/]/','',$rel_filename);
+
+ include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
+ $ecmfile=new EcmFiles($db);
+ $result = $ecmfile->fetch(0, '', $rel_filename);
+ if ($result > 0) // If found
+ {
+ $filename = basename($rel_filename);
+ $rel_dir = dirname($rel_filename);
+ $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
+ $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
+
+ $ecmfile->label = md5_file(dol_osencode($fullpath));
+ $result = $ecmfile->update($user);
+ }
+ elseif ($result == 0) // If not found
+ {
+ $filename = basename($rel_filename);
+ $rel_dir = dirname($rel_filename);
+ $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
+ $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
+
+ $ecmfile->filepath = $rel_dir;
+ $ecmfile->filename = $filename;
+ $ecmfile->label = md5_file(dol_osencode($fullpath)); // $fullpath is a full path to file
+ $ecmfile->fullpath_orig = $fullpath;
+ $ecmfile->gen_or_uploaded = 'unknown';
+ $ecmfile->description = ''; // indexed content
+ $ecmfile->keyword = ''; // keyword content
+ $result = $ecmfile->create($user);
+ if ($result < 0)
+ {
+ setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
+ }
+ $result = $ecmfile->create($user);
+ }
+
if ($backtourl)
{
header("Location: ".$backtourl);
@@ -218,10 +296,11 @@ print ''.$langs->trans("Resize").' ';
print $langs->trans("ResizeDesc").' ';
print $langs->trans("NewLength").': px '.$langs->trans("or").' ';
print $langs->trans("NewHeight").': px ';
+
print ' ';
print ' ';
print ' ';
-print ' ';
+print ' ';
print ' ';
print ' ';
print ' ';
diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php
index 123fcef662c..d0a7b45efea 100644
--- a/htdocs/core/tpl/ajaxrow.tpl.php
+++ b/htdocs/core/tpl/ajaxrow.tpl.php
@@ -17,18 +17,19 @@
*
* Javascript code to activate drag and drop on lines
* You can use this if you want to be abale to drag and drop rows of a table.
- * You must add id="tablelines" on table level tag and have count($object->lines) or count($taskarray) > 0
+ * You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0)
*/
?>
-
+
id;
$fk_element=$object->fk_element;
-$table_element_line=$object->table_element_line;
-$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):0));
+$table_element_line=(empty($table_element_line)?$object->table_element_line:$table_element_line);
+$nboflines=(isset($object->lines)?count($object->lines):(isset($tasksarray)?count($tasksarray):(empty($nboflines)?0:$nboflines)));
$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
+$filepath=(empty($filepath)?'':$filepath);
if (GETPOST('action') != 'editline' && $nboflines > 1) { ?>