Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New add possibility to move package files #390

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions class/actions_sellyoursaas.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1632,4 +1632,44 @@ public function restrictedArea($parameters, &$action, $hookmanager)

return 0;
}

/**
* Overloading the isLinkedDocumentObjectNotMovable function : check if we enable link document move
*
* @param array $parameters Hook metadatas (context, etc...)
* @param string $object Current object (if set)
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int =0 if OK but we want to process standard code,
* >0 if OK and we want to replace standard codeS.
*/
public function isLinkedDocumentObjectNotMovable($parameters, &$object, $hookmanager)
{
global $user;
if (in_array($object->element, array("packages"))) {
$this->results['disablemove'] = 0;
return 1;
}

return 0;
}

/**
* Overloading the checkRowPerms function : check permission on an object
*
* @param array $parameters Hook metadatas (context, etc...)
* @param string $object Current object (if set)
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int =0 if OK but we want to process standard code,
* >0 if OK and we want to replace standard codeS.
*/
public function checkRowPerms($parameters, &$object, $hookmanager)
{
global $user;
if (in_array($parameters["fk_element"], array("fk_packages"))) {
$this->results['perm'] = $user->hasRight('sellyoursaas', 'write');
return 1;
}

return 0;
}
}
2 changes: 1 addition & 1 deletion class/packages.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Packages extends CommonObject
public $module = 'sellyoursaas';

public $element_for_permission = 'sellyoursaas';

public $fk_element = 'fk_packages';
Hystepik marked this conversation as resolved.
Show resolved Hide resolved
/**
* @var array Does packages support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
Expand Down
1 change: 1 addition & 0 deletions class/sellyoursaasutils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4416,6 +4416,7 @@ public function sellyoursaasRemoteAction($remoteaction, $object, $appusername =
$commandurl.= '&'.str_replace(' ', '£', $domainnamewebsite); // Param 46 in .sh
$commandurl.= '&'.str_replace(' ', '£', $websitenamedeploy); // Param 47 in .sh
$commandurl.= '&'.str_replace(' ', '£', $tmppackage->srccliafterpaid); // Param 48 in .sh src for cli after paid
$commandurl.= '&'.str_replace(' ', '£', $tmppackage->id); // Param 49 in .sh src for dump files in deploy
//$outputfile = $conf->sellyoursaas->dir_temp.'/action-'.$remoteaction.'-'.dol_getmypid().'.out';

// Add a signature of message at end of message
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modSellYourSaas.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct($db)
'hooks' => array('thirdpartycard','thirdpartycomm','thirdpartysupplier','thirdpartycontact','contactthirdparty','thirdpartyticket','thirdpartynote','thirdpartydocument','thirdpartypartnership',
'projectthirdparty','consumptionthirdparty','thirdpartybancard','thirdpartymargins','ticketlist','thirdpartynotification','agendathirdparty',
'thirdpartydao','formmail','searchform','thirdpartylist','customerlist','prospectlist','contractcard','contractdao','contractlist',
'pdfgeneration','odtgeneration','customreport'));
'pdfgeneration','odtgeneration','customreport','rowinterface'));

// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, 'desc', visible, 'current' or 'allentities', deleteonunactive)
Expand Down
2 changes: 1 addition & 1 deletion packages_document.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
$sortorder="ASC";
}
if (! $sortfield) {
$sortfield="name";
$sortfield="position";
}

// Initialize technical objects
Expand Down
68 changes: 55 additions & 13 deletions scripts/action_deploy_undeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ if [ "x$INCLUDEFROMCONTRACT" == "x-" ]; then
fi

export CUSTOMDOMAIN=${46}
export packageID=${49}



Expand Down Expand Up @@ -1492,19 +1493,60 @@ if [[ "$mode" == "deploy" || "$mode" == "deployall" ]]; then

echo "You can test with mysql $dbname -h $dbserverhost -P $dbserverport -u $dbusername -p$dbpassword"

# Load dump file
echo `date +'%Y-%m-%d %H:%M:%S'`" Search dumpfile into $dirwithdumpfile"
for dumpfile in `ls $dirwithdumpfile/*.sql 2>/dev/null`
do
echo "$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -pXXXXXX -D $dbname < $dumpfile"
$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -p$dbadminpass -D $dbname < $dumpfile
result=$?
if [[ "x$result" != "x0" ]]; then
echo Failed to load dump file $dumpfile
echo "Failed to $mode instance $instancename.$domainname with: Failed to load dump file $dumpfile" | mail -aFrom:$EMAILFROM -s "[Alert] Pb in deploy/undeploy" $EMAILTO
exit 25
fi
done
echo `date +'%Y-%m-%d %H:%M:%S'`" Search dumpfile from master db"
Hystepik marked this conversation as resolved.
Show resolved Hide resolved
error=0
mastermysqliteration=0
masterdatabasehost=`grep '^databasehost=' /etc/sellyoursaas.conf | cut -d '=' -f 2`
masterdbport=`grep '^databaseport=' /etc/sellyoursaas.conf | cut -d '=' -f 2`
masterdbdatabase=`grep '^database=' /etc/sellyoursaas.conf | cut -d '=' -f 2`
masterdbuser=`grep '^databaseuser=' /etc/sellyoursaas.conf | cut -d '=' -f 2`
masterdbpass=`grep '^databasepass=' /etc/sellyoursaas.conf | cut -d '=' -f 2`

SQL2="SELECT CONCAT('$dirwithdumpfile/', filename) as full_path FROM llx_ecm_files WHERE src_object_type = 'packages' AND src_object_id = $packageID AND filename like '%.sql' ORDER BY position ASC"
echo "$MYSQL -ss -h $masterdatabasehost -D $masterdbdatabase -P $dbserverport -u$dbadminuser -pXXXXXX -e \"$SQL2\""

# Load dump file from master database
result=( $($MYSQL -ss -h $masterdatabasehost -D $masterdbdatabase -P $dbserverport -u$dbadminuser -p$masterdbpass -e "$SQL2") )
if [[ ${result[0]} == "" ]]; then
echo "Failed to get data from master databasebefore"
error=$(( $error + 1 ))
else
for dumpfile in ${result[@]};
do
if [[ -f $dumpfile ]]; then
echo "$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -pXXXXXX -D $dbname < $dumpfile"
$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -p$dbadminpass -D $dbname < $dumpfile
res=$?
if [[ "x$res" != "x0" ]]; then
echo Failed to load dump file $dumpfile
error=$(( $error + 1 ))
break
fi
echo "Dump $dumpfile successfully loaded"
mastermysqliteration=$(( $mastermysqliteration + 1 ))
else
echo "Error file $dumpfile does not exists"
error=$(( $error + 1 ))
break
fi
done
fi

# Load dump file if it didn't work with master db
if [[ $error -ne 0 ]] || [[ $mastermysqliteration -eq 0 ]]; then
echo `date +'%Y-%m-%d %H:%M:%S'`" Search dumpfile into $dirwithdumpfile"
for dumpfile in `ls $dirwithdumpfile/*.sql 2>/dev/null`
do
echo "$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -pXXXXXX -D $dbname < $dumpfile"
$MYSQL -A -h $dbserverhost -P $dbserverport -u$dbadminuser -p$dbadminpass -D $dbname < $dumpfile
result=$?
if [[ "x$result" != "x0" ]]; then
echo Failed to load dump file $dumpfile
echo "Failed to $mode instance $instancename.$domainname with: Failed to load dump file $dumpfile" | mail -aFrom:$EMAILFROM -s "[Alert] Pb in deploy/undeploy" $EMAILTO
exit 25
fi
done
fi

fi

Expand Down