Merge branch 'develop' of git://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
2d4957d415
@ -1,13 +1,16 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
# Script to purge and init a database with demo values.
|
# Script to purge and init a database with demo values.
|
||||||
# Note: "dialog" tool need to be available.
|
# Note: "dialog" tool need to be available if no parameter provided.
|
||||||
|
#
|
||||||
|
# WARNING: This script erase all data of database
|
||||||
|
# with data into dump file
|
||||||
#
|
#
|
||||||
# Regis Houssin - regis@dolibarr.fr
|
# Regis Houssin - regis@dolibarr.fr
|
||||||
# Laurent Destailleur - eldy@users.sourceforge.net
|
# Laurent Destailleur - eldy@users.sourceforge.net
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
# WARNING: This script erase all data of database
|
# Usage: initdemo.sh
|
||||||
# with data into dump file
|
# usage: initdemo.sh mysqldump_dolibarr_x.x.x.sql database port login pass
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@ -17,8 +20,6 @@ then
|
|||||||
export mydir="."
|
export mydir="."
|
||||||
fi
|
fi
|
||||||
export id=`id -u`;
|
export id=`id -u`;
|
||||||
export dumpfile=`ls $mydir/mysqldump_dolibarr_*.sql | sort | tail -n 1`
|
|
||||||
export dumpfile=`basename $dumpfile`
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------- check if root
|
# ----------------------------- check if root
|
||||||
@ -28,122 +29,140 @@ then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ----------------------------- input file
|
|
||||||
DIALOG=${DIALOG=dialog}
|
|
||||||
DIALOG="$DIALOG --ascii-lines"
|
|
||||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
|
||||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
--inputbox "Input dump file :" 16 55 $dumpfile 2> $fichtemp
|
|
||||||
valret=$?
|
|
||||||
case $valret in
|
|
||||||
0)
|
|
||||||
dumpfile=`cat $fichtemp`;;
|
|
||||||
1)
|
|
||||||
exit;;
|
|
||||||
255)
|
|
||||||
exit;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ----------------------------- database name
|
# ----------------------------- command line params
|
||||||
DIALOG=${DIALOG=dialog}
|
dumpfile=$1;
|
||||||
DIALOG="$DIALOG --ascii-lines"
|
base=$2;
|
||||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
port=$3;
|
||||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
admin=$4;
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
passwd=$5;
|
||||||
--inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp
|
|
||||||
valret=$?
|
|
||||||
case $valret in
|
|
||||||
0)
|
|
||||||
base=`cat $fichtemp`;;
|
|
||||||
1)
|
|
||||||
exit;;
|
|
||||||
255)
|
|
||||||
exit;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ---------------------------- database port
|
|
||||||
DIALOG=${DIALOG=dialog}
|
|
||||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
|
||||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
--inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp
|
|
||||||
|
|
||||||
valret=$?
|
# ----------------------------- if no params on command line
|
||||||
|
if [ "x$passwd" = "x" ]
|
||||||
|
then
|
||||||
|
export dumpfile=`ls $mydir/mysqldump_dolibarr_*.sql | sort | tail -n 1`
|
||||||
|
export dumpfile=`basename $dumpfile`
|
||||||
|
|
||||||
case $valret in
|
# ----------------------------- input file
|
||||||
0)
|
DIALOG=${DIALOG=dialog}
|
||||||
port=`cat $fichtemp`;;
|
DIALOG="$DIALOG --ascii-lines"
|
||||||
1)
|
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
exit;;
|
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
255)
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
exit;;
|
--inputbox "Input dump file :" 16 55 $dumpfile 2> $fichtemp
|
||||||
esac
|
valret=$?
|
||||||
|
case $valret in
|
||||||
|
0)
|
||||||
|
dumpfile=`cat $fichtemp`;;
|
||||||
|
1)
|
||||||
|
exit;;
|
||||||
|
255)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ----------------------------- database name
|
||||||
|
DIALOG=${DIALOG=dialog}
|
||||||
|
DIALOG="$DIALOG --ascii-lines"
|
||||||
|
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
|
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
--inputbox "Mysql database name :" 16 55 dolibarrdemo 2> $fichtemp
|
||||||
|
valret=$?
|
||||||
|
case $valret in
|
||||||
|
0)
|
||||||
|
base=`cat $fichtemp`;;
|
||||||
|
1)
|
||||||
|
exit;;
|
||||||
|
255)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ---------------------------- database port
|
||||||
|
DIALOG=${DIALOG=dialog}
|
||||||
|
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
|
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
--inputbox "Mysql port (ex: 3306):" 16 55 3306 2> $fichtemp
|
||||||
|
|
||||||
|
valret=$?
|
||||||
|
|
||||||
|
case $valret in
|
||||||
|
0)
|
||||||
|
port=`cat $fichtemp`;;
|
||||||
|
1)
|
||||||
|
exit;;
|
||||||
|
255)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ---------------------------- compte admin mysql
|
||||||
|
DIALOG=${DIALOG=dialog}
|
||||||
|
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
|
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
--inputbox "Mysql root login (ex: root):" 16 55 root 2> $fichtemp
|
||||||
|
|
||||||
|
valret=$?
|
||||||
|
|
||||||
|
case $valret in
|
||||||
|
0)
|
||||||
|
admin=`cat $fichtemp`;;
|
||||||
|
1)
|
||||||
|
exit;;
|
||||||
|
255)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ---------------------------- mot de passe admin mysql
|
||||||
|
DIALOG=${DIALOG=dialog}
|
||||||
|
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
|
trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
--inputbox "Password for Mysql root login :" 16 55 2> $fichtemp
|
||||||
|
|
||||||
|
valret=$?
|
||||||
|
|
||||||
|
case $valret in
|
||||||
|
0)
|
||||||
|
passwd=`cat $fichtemp`;;
|
||||||
|
1)
|
||||||
|
exit;;
|
||||||
|
255)
|
||||||
|
exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# ---------------------------- chemin d'acces du repertoire documents
|
||||||
|
#DIALOG=${DIALOG=dialog}
|
||||||
|
#fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
||||||
|
#trap "rm -f $fichtemp" 0 1 2 5 15
|
||||||
|
#$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
# --inputbox "Full path to documents directory (ex: /var/www/dolibarr/documents)- no / at end :" 16 55 2> $fichtemp
|
||||||
|
|
||||||
|
#valret=$?
|
||||||
|
|
||||||
|
#case $valret in
|
||||||
|
# 0)
|
||||||
|
#docs=`cat $fichtemp`;;
|
||||||
|
# 1)
|
||||||
|
#exit;;
|
||||||
|
# 255)
|
||||||
|
#exit;;
|
||||||
|
#esac
|
||||||
|
|
||||||
|
# ---------------------------- confirmation
|
||||||
|
DIALOG=${DIALOG=dialog}
|
||||||
|
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
||||||
|
--yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : '$passwd'" 15 55
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
0) echo "Ok, start process...";;
|
||||||
|
1) exit;;
|
||||||
|
255) exit;;
|
||||||
|
esac
|
||||||
|
|
||||||
# ---------------------------- compte admin mysql
|
fi
|
||||||
DIALOG=${DIALOG=dialog}
|
|
||||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
|
||||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
--inputbox "Mysql root login (ex: root):" 16 55 root 2> $fichtemp
|
|
||||||
|
|
||||||
valret=$?
|
|
||||||
|
|
||||||
case $valret in
|
|
||||||
0)
|
|
||||||
admin=`cat $fichtemp`;;
|
|
||||||
1)
|
|
||||||
exit;;
|
|
||||||
255)
|
|
||||||
exit;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ---------------------------- mot de passe admin mysql
|
|
||||||
DIALOG=${DIALOG=dialog}
|
|
||||||
fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
|
||||||
trap "rm -f $fichtemp" 0 1 2 5 15
|
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
--inputbox "Password for Mysql root login :" 16 55 2> $fichtemp
|
|
||||||
|
|
||||||
valret=$?
|
|
||||||
|
|
||||||
case $valret in
|
|
||||||
0)
|
|
||||||
passwd=`cat $fichtemp`;;
|
|
||||||
1)
|
|
||||||
exit;;
|
|
||||||
255)
|
|
||||||
exit;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ---------------------------- chemin d'acces du repertoire documents
|
|
||||||
#DIALOG=${DIALOG=dialog}
|
|
||||||
#fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$
|
|
||||||
#trap "rm -f $fichtemp" 0 1 2 5 15
|
|
||||||
#$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
# --inputbox "Full path to documents directory (ex: /var/www/dolibarr/documents)- no / at end :" 16 55 2> $fichtemp
|
|
||||||
|
|
||||||
#valret=$?
|
|
||||||
|
|
||||||
#case $valret in
|
|
||||||
# 0)
|
|
||||||
#docs=`cat $fichtemp`;;
|
|
||||||
# 1)
|
|
||||||
#exit;;
|
|
||||||
# 255)
|
|
||||||
#exit;;
|
|
||||||
#esac
|
|
||||||
|
|
||||||
# ---------------------------- confirmation
|
|
||||||
DIALOG=${DIALOG=dialog}
|
|
||||||
$DIALOG --title "Init Dolibarr with demo values" --clear \
|
|
||||||
--yesno "Do you confirm ? \n Dump file : '$dumpfile' \n Dump dir : '$mydir' \n Mysql database : '$base' \n Mysql port : '$port' \n Mysql login: '$admin' \n Mysql password : '$passwd'" 15 55
|
|
||||||
|
|
||||||
case $? in
|
|
||||||
0) echo "Ok, start process...";;
|
|
||||||
1) exit;;
|
|
||||||
255) exit;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ---------------------------- run sql file
|
# ---------------------------- run sql file
|
||||||
if [ "x$passwd" != "x" ]
|
if [ "x$passwd" != "x" ]
|
||||||
@ -154,6 +173,12 @@ fi
|
|||||||
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
|
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
|
||||||
echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile"
|
echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile"
|
||||||
mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
|
mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
|
||||||
|
export res=$?
|
||||||
|
|
||||||
echo "Dolibarr data demo has been loaded."
|
if [ "x$res" = "x0" ]
|
||||||
|
then
|
||||||
|
echo "Success, file successfully loaded."
|
||||||
|
else
|
||||||
|
echo "Error, load failed."
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2000-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2000-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -28,22 +28,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CSMSFile
|
* Class to send SMS
|
||||||
* \brief Class to send SMS
|
* Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to);
|
||||||
* \remarks Usage: $smsfile = new CSMSFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to);
|
* $smsfile->sendfile();
|
||||||
* \remarks $smsfile->sendfile();
|
|
||||||
*/
|
*/
|
||||||
class CSMSFile
|
class CSMSFile
|
||||||
{
|
{
|
||||||
var $error='';
|
var $error='';
|
||||||
|
|
||||||
var $message;
|
|
||||||
var $addr_from;
|
var $addr_from;
|
||||||
var $addr_to;
|
var $addr_to;
|
||||||
var $deliveryreceipt;
|
|
||||||
var $deferred;
|
var $deferred;
|
||||||
var $priority;
|
var $priority;
|
||||||
var $class;
|
var $class;
|
||||||
|
var $message;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,7 +50,7 @@ class CSMSFile
|
|||||||
* @param string $to Recipients SMS
|
* @param string $to Recipients SMS
|
||||||
* @param string $from Sender SMS
|
* @param string $from Sender SMS
|
||||||
* @param string $msg Message
|
* @param string $msg Message
|
||||||
* @param int $deliveryreceipt Ask a delivery receipt
|
* @param int $deliveryreceipt Not used
|
||||||
* @param int $deferred Deferred or not
|
* @param int $deferred Deferred or not
|
||||||
* @param int $priority Priority
|
* @param int $priority Priority
|
||||||
* @param int $class Class
|
* @param int $class Class
|
||||||
@ -75,16 +73,15 @@ class CSMSFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".count($msg), LOG_DEBUG);
|
dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".count($msg), LOG_DEBUG);
|
||||||
dol_syslog("CSMSFile::CSMSFile: deliveryreceipt=".$deliveryreceipt." deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG);
|
dol_syslog("CSMSFile::CSMSFile: deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG);
|
||||||
|
|
||||||
// Action according to choosed sending method
|
// Action according to choosed sending method
|
||||||
$this->addr_from=$from;
|
$this->addr_from=$from;
|
||||||
$this->addr_to=$to;
|
$this->addr_to=$to;
|
||||||
$this->message=$msg;
|
|
||||||
$this->deliveryreceipt=$deliveryreceipt;
|
|
||||||
$this->deferred=$deferred;
|
$this->deferred=$deferred;
|
||||||
$this->priority=$priority;
|
$this->priority=$priority;
|
||||||
$this->class=$class;
|
$this->class=$class;
|
||||||
|
$this->message=$msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,10 +144,10 @@ class CSMSFile
|
|||||||
$sms = new $classname($this->db);
|
$sms = new $classname($this->db);
|
||||||
$sms->expe=$this->addr_from;
|
$sms->expe=$this->addr_from;
|
||||||
$sms->dest=$this->addr_to;
|
$sms->dest=$this->addr_to;
|
||||||
$sms->message=$this->message;
|
|
||||||
$sms->deferred=$this->deferred;
|
$sms->deferred=$this->deferred;
|
||||||
$sms->priority=$this->priority;
|
$sms->priority=$this->priority;
|
||||||
$sms->class=$this->class;
|
$sms->class=$this->class;
|
||||||
|
$sms->message=$this->message;
|
||||||
|
|
||||||
$res=$sms->SmsSend();
|
$res=$sms->SmsSend();
|
||||||
if ($res <= 0)
|
if ($res <= 0)
|
||||||
@ -205,7 +202,12 @@ class CSMSFile
|
|||||||
$outputfile=$dolibarr_main_data_root."/dolibarr_sms.log";
|
$outputfile=$dolibarr_main_data_root."/dolibarr_sms.log";
|
||||||
$fp = fopen($outputfile,"w");
|
$fp = fopen($outputfile,"w");
|
||||||
|
|
||||||
fputs($fp, $this->message);
|
fputs($fp, "From: ".$this->addr_from."\n");
|
||||||
|
fputs($fp, "To: ".$this->addr_to."\n");
|
||||||
|
fputs($fp, "Priority: ".$this->priority."\n");
|
||||||
|
fputs($fp, "Class: ".$this->class."\n");
|
||||||
|
fputs($fp, "Deferred: ".$this->deferred."\n");
|
||||||
|
fputs($fp, "Message:\n".$this->message);
|
||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
if (! empty($conf->global->MAIN_UMASK))
|
if (! empty($conf->global->MAIN_UMASK))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user