About CleverReach®

CleverReach® was founded in 2007 and is one of the leading providers for email marketing, with more than 190,000 customers in 152 countries. A big plus of the German company based in Rastede, apart from the user-friendly menu navigation of the software, is the competent customer service and the very fair price-performance ratio. CleverReach® also meets the highest data protection standards, exceeding legal requirements.

https://www.drupal.org/cleverreach%C2%AE

About Project

The project connects CleverReach® email marketing tool directly with Drupal system. Thanks to our legally compliant registration forms, users are always on the safe side when generating addresses and save valuable time. At the same time, you avoid errors that often occur during a manual import or export.

The following Drupal data will be synchronized:
* Newsletter subscriptions and unsubscribes.
* All data collected during the registration process: first and last name, gender, age, date of birth, address details, interests…
* Your website content, so that you can fill your newsletter with current news or offers without manual effort.

Project link

https://www.drupal.org/project/clever_reach

Git instructions

git clone --branch 7.x-1.x https://git.drupal.org/project/clever_reach.git

Comments

CleverReach created an issue. See original summary.

avpaderno’s picture

Status: Needs review » Needs work

We just review a single project, and a single branch.
Please choose the project/branch you want reviewed, and edit the OP to reflect your choice.

avpaderno’s picture

When editing the OP, remember to add [D7] or [D8] at the beginning of the title, basing on which branch you want to be reviewed.

sagar_cis’s picture

Issue summary: View changes
cleverreach’s picture

Title: CleverReach® - Newsletter Marketing » [D7] CleverReach® - Newsletter Marketing
Issue summary: View changes
cleverreach’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
cleverreach’s picture

Hi, we updated the code according to your instructions.

cleverreach’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
function clever_reach_is_event_fire_allowed() {
  $queueService = ServiceRegister::getService(Queue::CLASS_NAME);

  if (!$queueService->findLatestByType('InitialSyncTask')) {
    return FALSE;
  }

  return module_exists('clever_reach');
}

If the module is not enabled, clever_reach_is_event_fire_allowed() cannot be called; if the module is enabled, module_exists('clever_reach') will return TRUE. This means the last line can simply be replaced by the following one.

  return TRUE;

Better, the full function can be changed as follows.

function clever_reach_is_event_fire_allowed() {
  $queueService = ServiceRegister::getService(Queue::CLASS_NAME);

  return (bool) $queueService->findLatestByType('InitialSyncTask');
}
  public function getAttributeByName($attributeName) {
    $attribute = new ShopAttribute();
    $mappedAttribute = $this->getMappedAttribute($attributeName);

    if ($mappedAttribute !== NULL) {
      $attribute->setDescription(t($mappedAttribute));
    }

    return $attribute;
  }

The first argument of t() needs to be a literal string, not a variable.

  /**
   * Create and send request asynchronously.
   *
   * @param string $method
   *   Request method.
   * @param string $url
   *   Request url.
   * @param mixed $headers
   *   Request headers.
   * @param string $body
   *   In JSON format.
   *
   * @return \CleverReach\Infrastructure\Utility\HttpResponse
   *   Http response object that contains response information such
   *   as headers, body and status.
   */
  public function sendHttpRequestAsync($method, $url, $headers = array(), $body = '') {
    $this->setCurlSessionAndCommonRequestParts($method, $url, $headers, $body);
    $this->setCurlSessionOptionsForAsynchronousRequest();
    return curl_exec($this->curlSession);
  }

  /**
   * Sets curl session parts.
   *
   * @param string $method
   *   Request method.
   * @param string $url
   *   Request url.
   * @param array $headers
   *   Request headers.
   * @param string $body
   *   In JSON format.
   */
  private function setCurlSessionAndCommonRequestParts($method, $url, array $headers, $body) {
    $this->initializeCurlSession();
    $this->setCurlSessionOptionsBasedOnMethod($method);
    $this->setCurlSessionUrlHeadersAndBody($method, $url, $headers, $body);
    $this->setCommonOptionsForCurlSession();
  }

  /**
   * Initializes curl session.
   */
  private function initializeCurlSession() {
    $this->curlSession = curl_init();
  }

Is there any reason not to use drupal_http_request()?

  private function isEmail($input) {
    return strpos($input, '@') !== FALSE;
  }

filter_var() can validate a string containing an email address.

cleverreach’s picture

Hi, thanks for your tips, we have updated our code according to your comments.

Regarding HTTP client, since PHP cURL library is Drupal installation requirement, we chose this way because of maintainability and easier debug from our side. If it is necessary to use drupal_http_request method, we will update our code to meet this requirement too.

cleverreach’s picture

Status: Needs work » Needs review
avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Needs review » Reviewed & tested by the community

It's not a requirement: I just wanted to see if you were aware that Drupal has drupal_http_request().

I will approve the application later.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.