Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: preg_match() when user doesn't have edit access #948

Open
wants to merge 1 commit into
base: 7.x-5.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions webform_civicrm.module
Original file line number Diff line number Diff line change
Expand Up @@ -581,17 +581,28 @@ function webform_civicrm_preprocess_webform_results_submissions(&$vars) {
foreach ($vars['table']['#rows'] as &$row) {
$name = '';
// Get submission id from url
preg_match('#/submission/(\d+)#', $row[4], $preg);
$sid = $preg[1];
if (!empty($vars['submissions'][$sid]->civicrm['contact'][1])) {
$data = $vars['submissions'][$sid]->civicrm;
$name = $data['contact'][1]['display_name'];
if ($name !== '' && $access) {
$name = l($name, 'civicrm/contact/view', [
'query' => ['reset' => 1, 'cid' => $data['contact'][1]['id']],
'attributes' => ['title' => t('View CiviCRM contact')],
'alias' => TRUE,
]);
// Where a user doesn't have edit or delete access, we might need to get
// it from an array.
$linkURL = '';
if (is_array($row[4]) && !empty($row[4]['data'])) {
$linkURL = $row[4]['data'];
}
elseif (is_string($row[4])) {
$linkURL = $row[4];
}
if (!empty($linkURL)) {
preg_match('#/submission/(\d+)#', $linkURL, $preg);
$sid = $preg[1];
if (!empty($vars['submissions'][$sid]->civicrm['contact'][1])) {
$data = $vars['submissions'][$sid]->civicrm;
$name = $data['contact'][1]['display_name'];
if ($name !== '' && $access) {
$name = l($name, 'civicrm/contact/view', [
'query' => ['reset' => 1, 'cid' => $data['contact'][1]['id']],
'attributes' => ['title' => t('View CiviCRM contact')],
'alias' => TRUE,
]);
}
}
}
$temp = $row;
Expand Down