diff --git a/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificClient.php b/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificClient.php
index 9987c04ba2..0c2db86047 100644
--- a/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificClient.php
+++ b/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificClient.php
@@ -19,7 +19,7 @@ class GlificClient {
public function __construct() {
$this->client = new Client();
$this->token = GlificHelper::getToken();
- $this->url = rtrim(CIVICRM_GLIFIC_API_BASE_URL, '/') . '/api/';
+ $this->url = rtrim(\Civi::settings()->get('civiglific_api_base_url'), '/') . '/api/';
}
/**
diff --git a/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificHelper.php b/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificHelper.php
index 3a5807d965..346b96c862 100644
--- a/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificHelper.php
+++ b/wp-content/civi-extensions/civiglific/CRM/Civiglific/GlificHelper.php
@@ -8,53 +8,61 @@
*
*/
if (!class_exists('CRM\Civiglific\GlificHelper')) {
-class GlificHelper {
/**
- * Get the Glific API access token using phone and password.
*
- * @return string|false Access token or FALSE on failure.
*/
- public static function getToken() {
- $url = rtrim(CIVICRM_GLIFIC_API_BASE_URL, '/') . '/api/v1/session';
-
- $data = [
- 'user' => [
- 'phone' => CIVICRM_GLIFIC_PHONE,
- 'password' => CIVICRM_GLIFIC_PASSWORD,
- ],
- ];
-
- try {
- $client = new Client();
- $response = $client->post($url, [
- 'headers' => ['Content-Type' => 'application/json'],
- 'json' => $data,
- 'http_errors' => FALSE,
- ]);
-
- $json = json_decode($response->getBody(), TRUE);
-
- if (!empty($json['data']['access_token'])) {
- return $json['data']['access_token'];
+ class GlificHelper {
+
+ /**
+ * Get the Glific API access token using phone and password.
+ *
+ * @return string|false Access token or FALSE on failure.
+ */
+ public static function getToken() {
+ $apiBaseUrl = \Civi::settings()->get('civiglific_api_base_url');
+ $phone = \Civi::settings()->get('civiglific_phone');
+ $password = \Civi::settings()->get('civiglific_password');
+
+ $url = rtrim($apiBaseUrl, '/') . '/api/v1/session';
+
+ $data = [
+ 'user' => [
+ 'phone' => $phone,
+ 'password' => $password,
+ ],
+ ];
+
+ try {
+ $client = new Client();
+ $response = $client->post($url, [
+ 'headers' => ['Content-Type' => 'application/json'],
+ 'json' => $data,
+ 'http_errors' => FALSE,
+ ]);
+
+ $json = json_decode($response->getBody(), TRUE);
+
+ if (!empty($json['data']['access_token'])) {
+ return $json['data']['access_token'];
+ }
+ else {
+ \Civi::log()->error('Glific token error:', [
+ 'error' => 'Invalid response from Glific API',
+ 'response' => json_encode($json),
+ ]);
+ return FALSE;
+ }
}
- else {
- \Civi::log()->error('Glific token error:', [
- 'error' => 'Invalid response from Glific API',
- 'response' => json_encode($json),
+ catch (\Exception $e) {
+ \Civi::log()->error('Glific token exception:', [
+ 'error' => 'Glific token exception',
+ 'exception' => $e->getMessage(),
]);
return FALSE;
}
}
- catch (\Exception $e) {
- \Civi::log()->error('Glific token exception:', [
- 'error' => 'Glific token exception',
- 'exception' => $e->getMessage(),
- ]);
- return FALSE;
- }
- }
-}
+ }
}
diff --git a/wp-content/civi-extensions/civiglific/CRM/Civiglific/Page/GroupMapping.php b/wp-content/civi-extensions/civiglific/CRM/Civiglific/Page/GroupMapping.php
index 4d769bb464..4836fba516 100644
--- a/wp-content/civi-extensions/civiglific/CRM/Civiglific/Page/GroupMapping.php
+++ b/wp-content/civi-extensions/civiglific/CRM/Civiglific/Page/GroupMapping.php
@@ -50,7 +50,7 @@ public function run() {
*
*/
protected function fetchGlificGroups($token) {
- $url = rtrim(CIVICRM_GLIFIC_API_BASE_URL, '/') . '/api/';
+ $url = rtrim(\Civi::settings()->get('civiglific_api_base_url'), '/') . '/api/';
$client = new Client();
try {
diff --git a/wp-content/civi-extensions/civiglific/Civi/MonetaryReceiptService.php b/wp-content/civi-extensions/civiglific/Civi/MonetaryReceiptService.php
index 58cd592ee9..326747b779 100644
--- a/wp-content/civi-extensions/civiglific/Civi/MonetaryReceiptService.php
+++ b/wp-content/civi-extensions/civiglific/Civi/MonetaryReceiptService.php
@@ -88,10 +88,10 @@ public static function triggerMonetaryEmail($op, $entity, $id, $objectRef = NULL
$contributionPageName = $contributionData['contribution_page_id:name'] ?? '';
if ($contributionPageName === 'Team_5000') {
- $templateId = CIVICRM_GLIFIC_TEMPLATE_ID_TEAM5000;
+ $templateId = \Civi::settings()->get('civiglific_template_id_team5000');
}
else {
- $templateId = CIVICRM_GLIFIC_TEMPLATE_ID_DEFAULT;
+ $templateId = \Civi::settings()->get('civiglific_template_id_default');
}
$input = [
@@ -152,7 +152,7 @@ public static function triggerMonetaryEmail($op, $entity, $id, $objectRef = NULL
// Save PDF to persistent location.
$uploadBase = defined('WP_CONTENT_DIR') ? rtrim(WP_CONTENT_DIR, '/') : rtrim($_SERVER['DOCUMENT_ROOT'] ?? __DIR__, '/');
- $saveDir = $uploadBase . CIVICRM_PERSIST_PDF_PATH;
+ $saveDir = $uploadBase . \Civi::settings()->get('civiglific_persist_pdf_path');
if (!file_exists($saveDir)) {
mkdir($saveDir, 0755, TRUE);
@@ -164,7 +164,7 @@ public static function triggerMonetaryEmail($op, $entity, $id, $objectRef = NULL
}
$baseUrl = rtrim(\CRM_Core_Config::singleton()->userFrameworkBaseURL, '/');
- $pdfUrl = $baseUrl . CIVICRM_SAVED_PDF_PATH . $fileNameForPdf;
+ $pdfUrl = $baseUrl . \Civi::settings()->get('civiglific_saved_pdf_path') . $fileNameForPdf;
$contributionContactId = $contributionData['contact_id'];
diff --git a/wp-content/civi-extensions/civiglific/README.md b/wp-content/civi-extensions/civiglific/README.md
index ee4aac0808..dca28ad9bd 100644
--- a/wp-content/civi-extensions/civiglific/README.md
+++ b/wp-content/civi-extensions/civiglific/README.md
@@ -3,6 +3,7 @@
Integrates Glific with CiviCRM, enabling you to send messages to users directly from CiviCRM and sync your group contacts between CiviCRM and Glific.
Latest releases can be found in the [CiviCRM extensions directory](https://lab.civicrm.org/dashboard/projects/personal)
+
## Documentation
### Installation
@@ -11,7 +12,7 @@ Latest releases can be found in the [CiviCRM extensions directory](https://lab.c
2. Put it in your CiviCRM extension directory
3. Go to `CiviCRM > Administer > System Settings > Extensions`
4. Find `civiglific` in the extension list and enable it
-5. Optionally, you can also use `cv` command-line tool to perform step 3 and 4
+5. Optionally, you can also use the `cv` command-line tool to perform steps 3 and 4
## Setup
@@ -21,12 +22,20 @@ There are two main setup configurations you can perform with this extension:
### Setup 1: Migrate CiviCRM Group Contacts to Glific Groups
-1. **Add configuration details in your `settings.php` file** to connect Glific with CiviCRM:
- ```php
- define('CIVICRM_GLIFIC_PHONE', 'XXXXXXXXXX');
- define('CIVICRM_GLIFIC_PASSWORD', 'ABC');
- define('CIVICRM_GLIFIC_API_BASE_URL', 'https://api.abs.com');
+1. **Configure Glific credentials in CiviCRM Settings UI**
+
+ Go to:
+
```
+ Administer → System Settings → Civiglific Settings
+ ```
+
+ Add the following values:
+
+ * Glific Phone Number
+ * Glific Password
+ * Glific API Base URL
+
2. **Add a navigation menu entry** in CiviCRM to access the Group Mapping screen. You can use the following URL:
```
civicrm/group-mapping
@@ -40,16 +49,21 @@ Civiglific.civicrm_glific_contact_sync_cron
### Setup 2: Send Receipts or Messages to Monetary Contributors
-1. **Add the following configurations in your `settings.php` file:**
- ```php
- // Glific Template IDs
- define('CIVICRM_GLIFIC_TEMPLATE_ID_DEFAULT', 111111);
- define('CIVICRM_GLIFIC_TEMPLATE_ID_TEAM5000', 111111);
+1. **Configure Template IDs and PDF paths in CiviCRM Settings UI**
+
+ Go to:
- // Persistent PDF storage
- define('CIVICRM_PERSIST_PDF_PATH', '');
- define('CIVICRM_SAVED_PDF_PATH', '');
```
+ Administer → System Settings → Civiglific Settings
+ ```
+
+ Configure:
+
+ * Default Glific Template ID
+ * Team 5000 Template ID
+ * Persistent PDF Path (private storage path)
+ * Saved PDF Path (public access path)
+
2. **Create a custom field** (Alphanumeric, Radio Buttons type) for **Contributions** to identify which contributors should receive WhatsApp messages or receipts.
3. Create message template on glific end, fetch those id and added it to step 1.
4. **Send messages or receipts automatically:** When submitting a contribution form, simply select the configured field, the message or receipt will be automatically sent to the contributor’s WhatsApp number using the Glific integration.
@@ -68,13 +82,11 @@ Once the extension is installed and configured:
2. **Automated Message Sending**
- When a new contribution is recorded in CiviCRM and the configured custom field is selected, an automated WhatsApp message or receipt will be sent to the contributor using the linked Glific template.
-3. **Template Management**
- - Update your Glific template IDs in `settings.php` if you need to use different message templates for various campaigns or donor tiers.
- - The system will automatically pick the correct template ID during message sending.
-4. **PDF Receipts**
- - If you’ve configured persistent PDF paths in your `settings.php`, a copy of the sent receipt PDF will be saved for each transaction..
+### 4. PDF Receipts
+* If persistent PDF paths are configured in **Civiglific Settings**,
+ a copy of the sent receipt PDF will be stored for each transaction.
## Maintainers
diff --git a/wp-content/civi-extensions/civiglific/info.xml b/wp-content/civi-extensions/civiglific/info.xml
index 31aede8d08..f8f2da4252 100644
--- a/wp-content/civi-extensions/civiglific/info.xml
+++ b/wp-content/civi-extensions/civiglific/info.xml
@@ -39,10 +39,11 @@
mgd-php@1.0.0
- setting-php@1.0.0
smarty@1.0.3
scan-classes@1.0.0
entity-types-php@2.0.0
+ setting-php@1
+ setting-admin@1
CRM_Civiglific_Upgrader
diff --git a/wp-content/civi-extensions/civiglific/settings/civiglific.php b/wp-content/civi-extensions/civiglific/settings/civiglific.php
new file mode 100644
index 0000000000..79f29aa07c
--- /dev/null
+++ b/wp-content/civi-extensions/civiglific/settings/civiglific.php
@@ -0,0 +1,13 @@
+ [
+ 'title' => ts('Civiglific Settings'),
+ 'weight' => 10,
+ 'tab' => 'System',
+ ],
+];
diff --git a/wp-content/civi-extensions/civiglific/settings/civiglific.setting.php b/wp-content/civi-extensions/civiglific/settings/civiglific.setting.php
new file mode 100644
index 0000000000..60d4b5581d
--- /dev/null
+++ b/wp-content/civi-extensions/civiglific/settings/civiglific.setting.php
@@ -0,0 +1,86 @@
+ [
+ 'name' => 'civiglific_phone',
+ 'type' => 'String',
+ 'html_type' => 'text',
+ 'title' => ts('Glific Phone Number'),
+ 'description' => ts('Registered Glific WhatsApp phone number'),
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'settings_pages' => ['civiglific' => ['weight' => 10]],
+ ],
+
+ 'civiglific_password' => [
+ 'name' => 'civiglific_password',
+ 'type' => 'String',
+ 'html_type' => 'password',
+ 'title' => ts('Glific Password'),
+ 'description' => ts('Glific API password'),
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'settings_pages' => ['civiglific' => ['weight' => 20]],
+ ],
+
+ 'civiglific_api_base_url' => [
+ 'name' => 'civiglific_api_base_url',
+ 'type' => 'String',
+ 'html_type' => 'text',
+ 'title' => ts('Glific API Base URL'),
+ 'description' => ts('Base URL for Glific API'),
+ 'default' => 'https://api.goonj.glific.com',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'settings_pages' => ['civiglific' => ['weight' => 30]],
+ ],
+
+ 'civiglific_template_id_default' => [
+ 'name' => 'civiglific_template_id_default',
+ 'type' => 'Integer',
+ 'html_type' => 'text',
+ 'title' => ts('Default Template ID'),
+ 'is_domain' => 1,
+ 'settings_pages' => ['civiglific' => ['weight' => 40]],
+ ],
+
+ 'civiglific_template_id_team5000' => [
+ 'name' => 'civiglific_template_id_team5000',
+ 'type' => 'Integer',
+ 'html_type' => 'text',
+ 'title' => ts('Team 5000 Template ID'),
+ 'is_domain' => 1,
+ 'settings_pages' => ['civiglific' => ['weight' => 50]],
+ ],
+
+ 'civiglific_persist_pdf_path' => [
+ 'name' => 'civiglific_persist_pdf_path',
+ 'type' => 'String',
+ 'html_type' => 'text',
+ 'title' => ts('Persistent PDF Path (Private)'),
+ 'description' => ts('Server path where contribution PDFs are stored persistently (private path)'),
+ 'default' => '/uploads/civicrm/persist/contribute/contribution/',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'settings_pages' => ['civiglific' => ['weight' => 60]],
+ ],
+
+ 'civiglific_saved_pdf_path' => [
+ 'name' => 'civiglific_saved_pdf_path',
+ 'type' => 'String',
+ 'html_type' => 'text',
+ 'title' => ts('Saved PDF Path (Public)'),
+ 'description' => ts('Public path where contribution PDFs are accessible'),
+ 'default' => '/wp-content/uploads/civicrm/persist/contribute/contribution/',
+ 'is_domain' => 1,
+ 'is_contact' => 0,
+ 'settings_pages' => ['civiglific' => ['weight' => 70]],
+ ],
+
+];