Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: None
-
Fix Version/s: 1.4
-
Component/s: None
-
Labels:None
Description
From an email by Michael Knight to crm-dev
I'm making a custom form for the public utilising the CiviCRM API. I had everything working nicely until I added a 'note' field to the form.
Here's a simplified overview:
$user = array(
'primary_location_id' => 1,
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'custom_2' => $_POST['custom_2'],
'prefix' => $_POST['individual_prefix'],
'job_title' => $_POST['job_title'],
'home_URL' => $_POST['home_URL'],
'note' => $_POST['note']
);
$contact =& crm_create_contact($user);
Removing the 'note' line causes the form to work without a hitch. If it is included, the browser seems to try and redirect to a null URL. After a bit of debugging, I tracked down the null redirection to CRM/Utils/System.php in the function statusBounce().
Since the function is short, I'll use it to illustrate the problem in my case:
// $status = "We could not find your logged in user ID"
function statusBounce($status) {
$session =& CRM_Core_Session::singleton();
$redirect = $session->readUserContext(); // $redirect is now NULL
$session->setStatus($status);
CRM_Utils_System::redirect($redirect);
}
So I guess my queries are:
- Is the ID check in CRM_Core_BAO_Note::add too strict? With my custom form I am essentially trying to allow anonymous users to add themselves into the CiviCRM DB.
- Since readUserContext() can legitimately return null, is it worthwhile putting some kind of safeguard in CRM_Utils_System::redirect()?
I'm using the 1.3 release for Mambo (PHP4).