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

Variable Substitution - Project Variables Not Working #19953

Closed
playcock opened this issue Jan 27, 2022 · 4 comments
Closed

Variable Substitution - Project Variables Not Working #19953

playcock opened this issue Jan 27, 2022 · 4 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@playcock
Copy link

playcock commented Jan 27, 2022

Bug

The following variables do not work in email templates.

__PROJECT_ID__
__PROJECT_REF__
__PROJECT_NAME__

Environment Version

13.0.1

Environment OS

Ubuntu 18.04.5 LTS

Environment Web server

Apache/2.4.29 (Ubuntu)

Environment PHP

PHP 7.2.24

Environment Database

MariaDB

Environment URL(s)

/admin/mails_templates.php

Expected and actual behavior

The following Variable Substitutions are not populating the Project Emails as expected:

__PROJECT_ID__
__PROJECT_REF__
__PROJECT_NAME__

When using any of the above variables, the email message body just prints their key.
Example of variable in an email message:
image

The expected behavior would be:
Print out the Project id for __PROJECT_ID__
Print out the Project ref for __PROJECT_REF__
Print out the Project title for __PROJECT_NAME__

I am pretty confident that the following lines in htdocs/core/lib/functions.lib.php never get hit:

if (is_object($object->project))
{
	$substitutionarray['__PROJECT_ID__'] = (is_object($object->project) ? $object->project->id : '');
	$substitutionarray['__PROJECT_REF__'] = (is_object($object->project) ? $object->project->ref : '');
	$substitutionarray['__PROJECT_NAME__'] = (is_object($object->project) ? $object->project->title : '');
}
if (is_object($object->projet))	// Deprecated, for backward compatibility
{
	$substitutionarray['__PROJECT_ID__'] = (is_object($object->projet) ? $object->projet->id : '');
	$substitutionarray['__PROJECT_REF__'] = (is_object($object->projet) ? $object->projet->ref : '');
	$substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet) ? $object->projet->title : '');
}

I will note that even though the following code does not exist in htdocs/core/lib/functions.lib.php, it will print out the expected values in Project emails when they are added outside of the conditional blocks for if (is_object($object->project)) and if (is_object($object->projet)):

$substitutionarray['__PROJECT_ID__'] = $object->id;
$substitutionarray['__PROJECT_REF__'] = $object->ref;
$substitutionarray['__PROJECT_NAME__'] = $object->title;

Steps to reproduce the behavior

Create a project email template with any of these variables:

__PROJECT_ID__
__PROJECT_REF__
__PROJECT_NAME__

Send a Project email using the email template.

Attached files

No response

@playcock playcock added the Bug This is a bug (something does not work as expected) label Jan 27, 2022
@playcock
Copy link
Author

playcock commented Jan 27, 2022

Bug description updated.

@carmelchas
Copy link
Contributor

From what I can see in the report the problem is that the PROJECT substitutions are only provided when $object "Has-A Project". There is not logical code-block to provide substitutions when $object "Is-A Project".

For example:

if (is_object($object) && get_class($object) === 'Project')
{
$substitutionarray['PROJECT_ID'] = $object->id ;
$substitutionarray['PROJECT_REF'] = $object->ref ;
$substitutionarray['PROJECT_NAME'] = $object->title;
}

@github-actions
Copy link

This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 10 days (you should still be able to re-open it if required).

@github-actions github-actions bot added the Issue Stale (automatic label) This issue is stale because it has been open 1 year with no activity. Remove this label to keep open label Jan 28, 2023
@github-actions github-actions bot closed this as completed Feb 7, 2023
@mikeemike7
Copy link

this is still a bug on dolibarr 18.0.1
:-(

@github-actions github-actions bot removed the Issue Stale (automatic label) This issue is stale because it has been open 1 year with no activity. Remove this label to keep open label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

3 participants