standalone: fix naming of class preventing install
authorRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 2 Oct 2023 11:02:56 +0000 (12:02 +0100)
committerRich Lott / Artful Robot <code.commits@artfulrobot.uk>
Mon, 2 Oct 2023 11:02:56 +0000 (12:02 +0100)
ext/standaloneusers/CRM/Standaloneusers/Upgrader.php
ext/standaloneusers/CRM/Standaloneusers/WorkflowMessage/PasswordReset.php
ext/standaloneusers/Civi/Api4/Action/User/SendPasswordReset.php
ext/standaloneusers/Civi/Standalone/Security.php
ext/standaloneusers/tests/phpunit/Civi/Standalone/SecurityTest.php

index f867c7c6f4eff6e9308a36d135409577501f3573..d53b2721c0dd8f6e1e12428632d38898e163dc03 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 use CRM_Standaloneusers_ExtensionUtil as E;
+use Civi\Api4\MessageTemplate;
 
 /**
  * Collection of upgrade steps.
@@ -50,7 +51,7 @@ class CRM_Standaloneusers_Upgrader extends CRM_Extension_Upgrader_Base {
       ['pass']
     )));
 
-    // $this->createPasswordResetMessageTemplate();
+    $this->createPasswordResetMessageTemplate();
 
     // `standaloneusers` is installed as part of the overall install process for `Standalone`.
     // A subsequent step will configure some default users (*depending on local options*).
@@ -80,14 +81,14 @@ class CRM_Standaloneusers_Upgrader extends CRM_Extension_Upgrader_Base {
     ];
 
     // Create a "reserved" template. This is a pristine copy provided for reference.
-    civicrm_api4('MessageTemplate', 'create',
-      [
+    MessageTemplate::create(FALSE)
+      ->setValues([
         'values' => $baseTpl + ['is_reserved' => 1, 'is_default' => 0],
       ]);
 
     // Create a default template. This is live. The administrator may edit/customize.
-    civicrm_api4('MessageTemplate', 'create',
-      [
+    MessageTemplate::create(FALSE)
+      ->setValues([
         'values' => $baseTpl + ['is_reserved' => 0, 'is_default' => 1],
       ]);
 
index be625bca3ef5e3ac3272f6099ffd4150ca888492..3968694e39e0f1932be1f83fa9c17d7c3bd7a9a6 100644 (file)
@@ -9,7 +9,8 @@ use Civi\WorkflowMessage\GenericWorkflowMessage;
  * @method static setUsernameHtml(string $s)
  *
  */
-class CRM_Standalone_WorkflowMessage_PasswordReset extends GenericWorkflowMessage {
+class CRM_Standaloneusers_WorkflowMessage_PasswordReset extends GenericWorkflowMessage {
+
   public const WORKFLOW = 'password_reset';
 
   /**
index 73e89dc15518b731d8e570fa8daa915fb11fdd4e..101d21067587f620a32c65024ed35d7bf0434348 100644 (file)
@@ -71,7 +71,6 @@ class SendPasswordReset extends AbstractAction {
 
       $workflowMessage = Security::singleton()->preparePasswordResetWorkflow($user, $token);
       if ($workflowMessage) {
-        /** @var \CRM_Standalone_WorkflowMessage_PasswordReset $workflowMessage */
         // The template_params are used in the template like {$resetUrlHtml} and {$resetUrlHtml} {$usernamePlaintext} {$usernameHtml}
         try {
           [$sent, /*$subject, $text, $html*/] = $workflowMessage->sendTemplate();
index 88009190267bc8db8ade3d8572173a7f221fd2a0..587f1f504e14c18f469756737c52c4368444ea47 100644 (file)
@@ -5,7 +5,7 @@ use CRM_Core_Session;
 use Civi;
 use Civi\Api4\User;
 use Civi\Api4\MessageTemplate;
-use CRM_Standalone_WorkflowMessage_PasswordReset;
+use CRM_Standaloneusers_WorkflowMessage_PasswordReset;
 
 /**
  * This is a single home for security related functions for Civi Standalone.
@@ -422,9 +422,9 @@ class Security {
   /**
    * Prepare a password reset workflow email, if configured.
    *
-   * @return \CRM_Standalone_WorkflowMessage_PasswordReset|null
+   * @return \CRM_Standaloneusers_WorkflowMessage_PasswordReset|null
    */
-  public function preparePasswordResetWorkflow(array $user, string $token): ?CRM_Standalone_WorkflowMessage_PasswordReset {
+  public function preparePasswordResetWorkflow(array $user, string $token): ?CRM_Standaloneusers_WorkflowMessage_PasswordReset {
     // Find the message template
     $tplID = MessageTemplate::get(FALSE)
       ->setSelect(['id'])
@@ -445,7 +445,7 @@ class Security {
 
     // The template_params are used in the template like {$resetUrlHtml} and {$resetUrlHtml} {$usernamePlaintext} {$usernameHtml}
     list($domainFromName, $domainFromEmail) = \CRM_Core_BAO_Domain::getNameAndEmail(TRUE);
-    $workflowMessage = (new \CRM_Standalone_WorkflowMessage_PasswordReset())
+    $workflowMessage = (new \CRM_Standaloneusers_WorkflowMessage_PasswordReset())
       ->setDataFromUser($user, $token)
       ->setFrom("\"$domainFromName\" <$domainFromEmail>");
 
index c1e2fe972b7a344d315c7f70d6df49093d7d9505..7da17a2941e9f48870377cac4e3e65cb91fa7880 100644 (file)
@@ -417,7 +417,6 @@ class SecurityTest extends \PHPUnit\Framework\TestCase implements EndToEndInterf
 
     // Check the message template generation
     $token = \Civi\Api4\Action\User\SendPasswordReset::updateToken($userID);
-    /** @var \CRM_Standalone_WorkflowMessage_PasswordReset */
     $workflow = $security->preparePasswordResetWorkflow($user, $token);
     $result = $workflow->renderTemplate();