Answers.Body: <p>Per comments above, this bug was fixed by @herb in <a href="https://github.com/civicrm/civicrm-packages/pull/216" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-packages/pull/216</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-03T18:41:28.470Z
Answers.LastActivityDate: 2018-08-03T18:41:28.470Z
Answers.UserDisplayName: Laryn
Body: <p>I am using Backdrop CMS 1.10.1 with CiviCRM 5.2.2 and I am having trouble with the kcfinder, when uploading and inserting images, both into CiviMail and CiviContribute.</p>
  
  <p>The initial problem was a 500 error.  Based on this bit of the log,</p>
  
  <p><code>[Thu Jul 05 16:53:47.624995 2018] [fcgid:warn] [pid 6591] [client ] mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Function name must be a string in [site]/public_html/modules/civicrm/packages/kcfinder/integration/civicrm.php:67</code></p>
  
  <p>I traced it down to this switch statement in /kcfinder/integration/civicrm.php</p>
  
  <p><code>switch ($config-&gt;userFramework) {
      case 'Drupal':
      case 'Drupal6':
        $auth_function = 'authenticate_drupal';
        break;
      case 'Joomla':
        $auth_function = 'authenticate_joomla';
        break;
      case 'WordPress':
        $auth_function = 'authenticate_wordpress';
        break;
      }
  </code></p>
  
  <p>This is missing the case for Backdrop, so $authfunction never got assigned to a string.  I tried to add a case for Backdrop, as well as the authenticate_backdrop function, but I don't know how to make it work.  First, I tried making the authenticate_backdrop function the same as authenticate_drupal, but it gives me the error:</p>
  
  <p><code>You must be logged in with proper permissions to edit, add, or delete uploaded images.</code></p>
  
  <p>I removed everything except the permission check from the function, so that it just looks like this:</p>
  
  <p><code>function authenticate_backdrop($config) {
    // check if user has access permission...
    if (CRM_Core_Permission::check('access CiviCRM')) {
      error_log("There is permission.")
      return true;
    }
  }
  </code>
  It gives me permission, and allows me to upload an image and insert it. Here is the original file with the authenticate functions for drupal, joomla and wordpress.  <a href="https://github.com/civicrm/civicrm-packages/blob/master/kcfinder/integration/civicrm.php" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-packages/blob/master/kcfinder/integration/civicrm.php</a></p>
  
  <p>What is the correct way to implement <code>authenticate_backdrop</code>?  It is okay to just have the CRM_Core_Permission::check?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-07T05:11:11.353Z
Comments.Text: You might be right, but perhaps there's something we're missing. I don't really understand what's going on there. The drupal function is confusing and seems to have a whole lot of cruft that isn't being used. $base_url isn't being used. You might need to include the boostrap so we're sure to get the logged in user.
Comments.UserDisplayName: herb
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-07T14:16:35.887Z
Comments.Text: I checked and I think now that it has to bootstrap Backdrop otherwise it'll always return true.
Comments.UserDisplayName: herb
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-07T15:42:56.670Z
Comments.Text: Can you test this PR/patch? https://github.com/civicrm/civicrm-packages/pull/216
Comments.UserDisplayName: herb
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-12T16:20:59.187Z
Comments.Text: @herb The PR/patch works.  Thank you!
Comments.UserDisplayName: Tanya Bouman
Tags: <civicontribute><civimail><kcfinder><backdrop>
Title: Backdrop authentication function missing
ThreadText: # Backdrop authentication function missing
  
  (Asked by: username_0 on 2018-07-06)
  
  I am using Backdrop CMS 1.10.1 with CiviCRM 5.2.2 and I am having trouble with the kcfinder, when uploading and inserting images, both into CiviMail and CiviContribute.
  
  The initial problem was a 500 error. Based on this bit of the log,
  
  `[Thu Jul 05 16:53:47.624995 2018] [fcgid:warn] [pid 6591] [client ] mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Function name must be a string in [site]/public_html/modules/civicrm/packages/kcfinder/integration/civicrm.php:67`
  
  I traced it down to this switch statement in /kcfinder/integration/civicrm.php
  
  `switch ($config->userFramework) {
  case 'Drupal':
  case 'Drupal6':
  $auth_function = 'authenticate_drupal';
  break;
  case 'Joomla':
  $auth_function = 'authenticate_joomla';
  break;
  case 'WordPress':
  $auth_function = 'authenticate_wordpress';
  break;
  }`
  
  This is missing the case for Backdrop, so $authfunction never got assigned to a string. I tried to add a case for Backdrop, as well as the authenticate\_backdrop function, but I don't know how to make it work. First, I tried making the authenticate\_backdrop function the same as authenticate\_drupal, but it gives me the error:
  
  `You must be logged in with proper permissions to edit, add, or delete uploaded images.`
  
  I removed everything except the permission check from the function, so that it just looks like this:
  
  `function authenticate_backdrop($config) {
  // check if user has access permission...
  if (CRM_Core_Permission::check('access CiviCRM')) {
  error_log("There is permission.")
  return true;
  }
  }`
  It gives me permission, and allows me to upload an image and insert it. Here is the original file with the authenticate functions for drupal, joomla and wordpress. <https://github.com/civicrm/civicrm-packages/blob/master/kcfinder/integration/civicrm.php>
  
  What is the correct way to implement `authenticate_backdrop`? It is okay to just have the CRM\_Core\_Permission::check?
  
  **Tags:** civicontribute, civimail, kcfinder, backdrop
  
  > **Comments:**
  > **username_1**: You might be right, but perhaps there's something we're missing. I don't really understand what's going on there. The drupal function is confusing and seems to have a whole lot of cruft that isn't being used. $base_url isn't being used. You might need to include the boostrap so we're sure to get the logged in user.  
  > **username_1**: I checked and I think now that it has to bootstrap Backdrop otherwise it'll always return true.  
  > **username_1**: Can you test this PR/patch? https://github.com/civicrm/civicrm-packages/pull/216  
  > **username_0**: @username_1 The PR/patch works.  Thank you!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-08-03. Score: 1 | Accepted answer
  
  Per comments above, this bug was fixed by @username_1 in <https://github.com/civicrm/civicrm-packages/pull/216>
  
  
  ---
  
  