Révision 8c72e82a
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/webform/webform.module | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
$output = '<p>' . $output . '</p>'; |
38 | 38 |
break; |
39 |
|
|
39 | 40 |
case 'admin/content/webform': |
40 | 41 |
$output = '<p>' . t('This page lists all of the content on the site that may have a webform attached to it.') . '</p>'; |
41 | 42 |
break; |
43 |
|
|
42 | 44 |
case 'admin/help#webform': |
43 | 45 |
module_load_include('inc', 'webform', 'includes/webform.admin'); |
44 | 46 |
$types = webform_admin_type_list(); |
... | ... | |
67 | 69 |
<li>Your form is now ready for viewing. After receiving submissions, you can check the results users have submitted by visiting the <em>Results</em> tab on the piece of content.</li> |
68 | 70 |
</ul> |
69 | 71 |
<p>Help on adding and configuring the components will be shown after you add your first component.</p> |
70 |
", array('!webform-types-message' => $types_message, '!create-content' => url('node/add'), '!types' => $types)); |
|
72 |
", array( |
|
73 |
'!webform-types-message' => $types_message, |
|
74 |
'!create-content' => url('node/add'), |
|
75 |
'!types' => $types, |
|
76 |
) |
|
77 |
); |
|
71 | 78 |
break; |
79 |
|
|
72 | 80 |
case 'node/%/webform/conditionals': |
73 | 81 |
$output .= '<p>' . t('Conditionals may be used to hide or show certain components (or entire pages!) based on the value of other components.') . '</p>'; |
74 | 82 |
break; |
83 |
|
|
75 | 84 |
case 'node/%/submission/%/resend': |
76 | 85 |
$output .= '<p>' . t('This form may be used to resend e-mails configured for this webform. Check the e-mails that need to be sent and click <em>Resend e-mails</em> to send these e-mails again.') . '</p>'; |
77 | 86 |
break; |
... | ... | |
455 | 464 |
* @param string $arg |
456 | 465 |
* The argument supplied by the caller. |
457 | 466 |
* @param array $map |
458 |
* Array of path fragments (e.g. e.g. array('node','123','edit') for
|
|
467 |
* Array of path fragments (for example, array('node','123','edit') for
|
|
459 | 468 |
* 'node/123/edit'). |
460 |
* @param integer $index
|
|
469 |
* @param int $index |
|
461 | 470 |
* Which element of $map corresponds to $arg. |
471 |
* |
|
462 | 472 |
* @return string |
463 | 473 |
* The $arg, modified as desired. |
464 | 474 |
*/ |
... | ... | |
484 | 494 |
module_load_include('inc', 'webform', 'includes/webform.components'); |
485 | 495 |
if ($cid == 'new') { |
486 | 496 |
$components = webform_components(); |
487 |
$component = in_array($type, array_keys($components)) ? array('type' => $type, 'nid' => $nid, 'name' => $_GET['name'], 'required' => $_GET['required'], 'pid' => $_GET['pid'], 'weight' => $_GET['weight']) : FALSE; |
|
497 |
$component = in_array($type, array_keys($components)) ? array( |
|
498 |
'type' => $type, |
|
499 |
'nid' => $nid, |
|
500 |
'name' => $_GET['name'], |
|
501 |
'required' => $_GET['required'], |
|
502 |
'pid' => $_GET['pid'], |
|
503 |
'weight' => $_GET['weight'], |
|
504 |
) : FALSE; |
|
488 | 505 |
} |
489 | 506 |
else { |
490 | 507 |
$node = node_load($nid); |
... | ... | |
496 | 513 |
return $component; |
497 | 514 |
} |
498 | 515 |
|
499 |
|
|
500 | 516 |
/** |
501 | 517 |
* Menu loader callback. Load a webform e-mail if the given eid is a valid. |
502 | 518 |
*/ |
... | ... | |
538 | 554 |
/** |
539 | 555 |
* Access function for confirmation pages. |
540 | 556 |
* |
541 |
* @param $node |
|
557 |
* @param stdClass $node
|
|
542 | 558 |
* The webform node object. |
543 | 559 |
* |
544 |
* @return |
|
545 |
* Boolean whether the user has access to the confirmation page. |
|
560 |
* @return bool
|
|
561 |
* Boolean whether the user has access to the confirmation page.
|
|
546 | 562 |
*/ |
547 | 563 |
function webform_confirmation_page_access($node) { |
548 | 564 |
global $user; |
... | ... | |
582 | 598 |
} |
583 | 599 |
else { |
584 | 600 |
// No submission exists (such as auto-deleted by another module, such as |
585 |
// webform_clear), just ensure that the user has access to view the node page. |
|
601 |
// webform_clear), just ensure that the user has access to view the node |
|
602 |
// page. |
|
586 | 603 |
if (node_access('view', $node)) { |
587 | 604 |
return TRUE; |
588 | 605 |
} |
... | ... | |
594 | 611 |
/** |
595 | 612 |
* Access function for Webform submissions. |
596 | 613 |
* |
597 |
* @param $node |
|
614 |
* @param stdClass $node
|
|
598 | 615 |
* The webform node object. |
599 |
* @param $submission |
|
616 |
* @param stdClass $submission
|
|
600 | 617 |
* The webform submission object. |
601 |
* @param $op |
|
618 |
* @param stdClass $op
|
|
602 | 619 |
* The operation to perform. Must be one of view, edit, delete, list. |
603 |
* @param $account |
|
620 |
* @param array $account
|
|
604 | 621 |
* Optional. A user object or NULL to use the currently logged-in user. |
605 | 622 |
* |
606 |
* @return |
|
623 |
* @return bool
|
|
607 | 624 |
* Boolean whether the user has access to a webform submission. |
608 | 625 |
*/ |
609 | 626 |
function webform_submission_access($node, $submission, $op = 'view', $account = NULL) { |
... | ... | |
635 | 652 |
switch ($op) { |
636 | 653 |
case 'view': |
637 | 654 |
return $module_access || $general_access; |
655 |
|
|
638 | 656 |
case 'edit': |
639 | 657 |
return $module_access || ($general_access && (user_access('edit all webform submissions', $account) || (user_access('edit own webform submissions', $account) && $account->uid == $submission->uid))); |
658 |
|
|
640 | 659 |
case 'delete': |
641 | 660 |
return $module_access || ($general_access && (user_access('delete all webform submissions', $account) || (user_access('delete own webform submissions', $account) && $account->uid == $submission->uid))); |
661 |
|
|
642 | 662 |
case 'list': |
643 | 663 |
return $module_access || user_access('access all webform results', $account) || (user_access('access own webform submissions', $account) && ($account->uid || isset($_SESSION['webform_submission']))) || (user_access('access own webform results', $account) && $account->uid == $node->uid); |
644 | 664 |
} |
... | ... | |
685 | 705 |
* be granted, FALSE if it should absolutely be denied, or NULL if node_access |
686 | 706 |
* and 'edit webform components' permission should determine access. |
687 | 707 |
* |
688 |
* @see hook_webform_update_access().
|
|
708 |
* @see hook_webform_update_access() |
|
689 | 709 |
*/ |
690 | 710 |
function webform_node_update_access($node, $account = NULL) { |
691 | 711 |
global $user; |
... | ... | |
758 | 778 |
'render element' => 'webform', |
759 | 779 |
), |
760 | 780 |
'webform_view_messages' => array( |
761 |
'variables' => array('node' => NULL, 'page' => NULL, 'submission_count' => NULL, 'user_limit_exceeded' => NULL, 'total_limit_exceeded' => NULL, 'allowed_roles' => NULL, 'closed' => NULL, 'cached' => NULL), |
|
781 |
'variables' => array( |
|
782 |
'node' => NULL, |
|
783 |
'page' => NULL, |
|
784 |
'submission_count' => NULL, |
|
785 |
'user_limit_exceeded' => NULL, |
|
786 |
'total_limit_exceeded' => NULL, |
|
787 |
'allowed_roles' => NULL, |
|
788 |
'closed' => NULL, |
|
789 |
'cached' => NULL, |
|
790 |
), |
|
762 | 791 |
), |
763 | 792 |
'webform_form' => array( |
764 | 793 |
'render element' => 'form', |
... | ... | |
783 | 812 |
'render element' => 'element', |
784 | 813 |
), |
785 | 814 |
'webform_progressbar' => array( |
786 |
'variables' => array('node' => NULL, 'page_num' => NULL, 'page_count' => NULL, 'page_labels' => array()), |
|
815 |
'variables' => array( |
|
816 |
'node' => NULL, |
|
817 |
'page_num' => NULL, |
|
818 |
'page_count' => NULL, |
|
819 |
'page_labels' => array(), |
|
820 |
), |
|
787 | 821 |
'template' => 'templates/webform-progressbar', |
788 | 822 |
), |
789 | 823 |
'webform_mail_message' => array( |
790 |
'variables' => array('node' => NULL, 'submission' => NULL, 'email' => NULL), |
|
824 |
'variables' => array( |
|
825 |
'node' => NULL, |
|
826 |
'submission' => NULL, |
|
827 |
'email' => NULL, |
|
828 |
), |
|
791 | 829 |
'template' => 'templates/webform-mail', |
792 | 830 |
'pattern' => 'webform_mail(_[0-9]+)?', |
793 | 831 |
), |
794 | 832 |
'webform_mail_headers' => array( |
795 |
'variables' => array('node' => NULL, 'submission' => NULL, 'email' => NULL), |
|
833 |
'variables' => array( |
|
834 |
'node' => NULL, |
|
835 |
'submission' => NULL, |
|
836 |
'email' => NULL, |
|
837 |
), |
|
796 | 838 |
'pattern' => 'webform_mail_headers_[0-9]+', |
797 | 839 |
), |
798 | 840 |
'webform_token_help' => array( |
... | ... | |
882 | 924 |
'file' => 'includes/webform.report.inc', |
883 | 925 |
), |
884 | 926 |
'webform_results_table' => array( |
885 |
'variables' => array('node' => NULL, 'components' => NULL, 'submissions' => NULL, 'total_count' => NULL, 'pager_count' => NULL), |
|
927 |
'variables' => array( |
|
928 |
'node' => NULL, |
|
929 |
'components' => NULL, |
|
930 |
'submissions' => NULL, |
|
931 |
'total_count' => NULL, |
|
932 |
'pager_count' => NULL, |
|
933 |
), |
|
886 | 934 |
'file' => 'includes/webform.report.inc', |
887 | 935 |
), |
888 | 936 |
'webform_results_download_range' => array( |
... | ... | |
907 | 955 |
'variables' => array('component' => NULL, 'data' => NULL), |
908 | 956 |
'file' => 'includes/webform.report.inc', |
909 | 957 |
), |
910 |
// webform.submissions.inc |
|
958 |
// webform.submissions.inc.
|
|
911 | 959 |
'webform_submission' => array( |
912 | 960 |
'render element' => 'renderable', |
913 | 961 |
'template' => 'templates/webform-submission', |
... | ... | |
915 | 963 |
'file' => 'includes/webform.submissions.inc', |
916 | 964 |
), |
917 | 965 |
'webform_submission_page' => array( |
918 |
'variables' => array('node' => NULL, 'submission' => NULL, 'submission_content' => NULL, 'submission_navigation' => NULL, 'submission_information' => NULL, 'submission_actions' => NULL, 'mode' => NULL), |
|
966 |
'variables' => array( |
|
967 |
'node' => NULL, |
|
968 |
'submission' => NULL, |
|
969 |
'submission_content' => NULL, |
|
970 |
'submission_navigation' => NULL, |
|
971 |
'submission_information' => NULL, |
|
972 |
'submission_actions' => NULL, |
|
973 |
'mode' => NULL, |
|
974 |
), |
|
919 | 975 |
'template' => 'templates/webform-submission-page', |
920 | 976 |
'file' => 'includes/webform.submissions.inc', |
921 | 977 |
), |
922 | 978 |
'webform_submission_information' => array( |
923 |
'variables' => array('node' => NULL, 'submission' => NULL, 'mode' => 'display'), |
|
979 |
'variables' => array( |
|
980 |
'node' => NULL, |
|
981 |
'submission' => NULL, |
|
982 |
'mode' => 'display', |
|
983 |
), |
|
924 | 984 |
'template' => 'templates/webform-submission-information', |
925 | 985 |
'file' => 'includes/webform.submissions.inc', |
926 | 986 |
), |
... | ... | |
1187 | 1247 |
/** |
1188 | 1248 |
* Implements hook_forms(). |
1189 | 1249 |
* |
1190 |
* All webform_client_form forms share the same form handler |
|
1250 |
* All webform_client_form forms share the same form handler.
|
|
1191 | 1251 |
*/ |
1192 | 1252 |
function webform_forms($form_id) { |
1193 | 1253 |
$forms = array(); |
... | ... | |
1285 | 1345 |
} |
1286 | 1346 |
} |
1287 | 1347 |
|
1288 |
// Only rename files if this is the first time the submission is being saved as finished. |
|
1348 |
// Only rename files if this is the first time the submission is being saved |
|
1349 |
// as finished. |
|
1289 | 1350 |
if ($submission->is_draft || (isset($old_submission) && !$old_submission->is_draft)) { |
1290 | 1351 |
$renameable = array(); |
1291 | 1352 |
} |
... | ... | |
1460 | 1521 |
// Insert the components into the database. Used with clone.module. |
1461 | 1522 |
if (isset($node->webform['components']) && !empty($node->webform['components'])) { |
1462 | 1523 |
foreach ($node->webform['components'] as $cid => $component) { |
1463 |
$component['nid'] = $node->nid; // Required for clone.module. |
|
1524 |
// Required for clone.module. |
|
1525 |
$component['nid'] = $node->nid; |
|
1464 | 1526 |
webform_component_insert($component); |
1465 | 1527 |
} |
1466 | 1528 |
} |
... | ... | |
1571 | 1633 |
$conditional['nid'] = $node->nid; |
1572 | 1634 |
$conditional['rgid'] = $rgid; |
1573 | 1635 |
if (!isset($original->webform['conditionals'][$rgid]) || $original->webform['conditionals'][$rgid] != $conditional) { |
1574 |
webform_conditional_insert($conditional); |
|
1636 |
webform_conditional_insert($conditional);
|
|
1575 | 1637 |
} |
1576 | 1638 |
} |
1577 | 1639 |
} |
... | ... | |
1696 | 1758 |
} |
1697 | 1759 |
} |
1698 | 1760 |
|
1699 |
|
|
1700 | 1761 |
/** |
1701 | 1762 |
* Implements hook_node_load(). |
1702 | 1763 |
*/ |
... | ... | |
1811 | 1872 |
} |
1812 | 1873 |
} |
1813 | 1874 |
} |
1814 |
|
|
1815 | 1875 |
} |
1816 | 1876 |
|
1817 | 1877 |
/** |
1818 |
* Implements hook_user_role_delete(). |
|
1819 |
* |
|
1820 |
* Removes references to deleted role from existing webforms. |
|
1821 |
*/ |
|
1878 |
* Implements hook_user_role_delete().
|
|
1879 |
*
|
|
1880 |
* Removes references to deleted role from existing webforms.
|
|
1881 |
*/
|
|
1822 | 1882 |
function webform_user_role_delete($role) { |
1823 | 1883 |
db_delete('webform_roles')->condition('rid', $role->rid)->execute(); |
1824 | 1884 |
} |
... | ... | |
1934 | 1994 |
$allowed_roles = array(); |
1935 | 1995 |
} |
1936 | 1996 |
else { |
1937 |
$allowed_roles = _webform_allowed_roles($node, $enabled); // $enabled set by reference. |
|
1997 |
// $enabled set by reference. |
|
1998 |
$allowed_roles = _webform_allowed_roles($node, $enabled); |
|
1938 | 1999 |
} |
1939 | 2000 |
|
1940 | 2001 |
// Get a count of previous submissions by this user. Note that the |
... | ... | |
1948 | 2009 |
// Check if this page is cached or not. |
1949 | 2010 |
$cached = drupal_page_is_cacheable(); |
1950 | 2011 |
|
1951 |
// Check if the user can add another submission based on the individual submission limit. |
|
1952 |
if ($node->webform['submit_limit'] != -1) { // -1: Submissions are never throttled. |
|
2012 |
// Check if the user can add another submission based on the individual |
|
2013 |
// submission limit. |
|
2014 |
// -1: Submissions are never throttled. |
|
2015 |
if ($node->webform['submit_limit'] != -1) { |
|
1953 | 2016 |
module_load_include('inc', 'webform', 'includes/webform.submissions'); |
1954 | 2017 |
|
1955 |
// Disable the form if the limit is exceeded and page cache is not active. This prevent |
|
1956 |
// One anonymous user from generated a disabled webform page for the cache, which would |
|
1957 |
// be shown to other anonymous users who have not exceeded the limit. |
|
2018 |
// Disable the form if the limit is exceeded and page cache is not active. |
|
2019 |
// This prevents one anonymous user from generated a disabled webform page |
|
2020 |
// for the cache, which would be shown to other anonymous users who have not |
|
2021 |
// exceeded the limit. |
|
1958 | 2022 |
if (($user_limit_exceeded = webform_submission_user_limit_check($node)) && !$cached) { |
1959 | 2023 |
$enabled = FALSE; |
1960 | 2024 |
} |
... | ... | |
1962 | 2026 |
|
1963 | 2027 |
// Check if the user can add another submission if there is a limit on total |
1964 | 2028 |
// submissions. |
1965 |
if ($node->webform['total_submit_limit'] != -1) { // -1: Submissions are never throttled. |
|
2029 |
// -1: Submissions are never throttled. |
|
2030 |
if ($node->webform['total_submit_limit'] != -1) { |
|
1966 | 2031 |
module_load_include('inc', 'webform', 'includes/webform.submissions'); |
1967 | 2032 |
|
1968 |
// Disable the form if the limit is exceeded. The cache is irrelevant for the total
|
|
1969 |
// submission limit; when it is exceeded for one user, it is exceeded for any other
|
|
1970 |
// user. |
|
2033 |
// Disable the form if the limit is exceeded. The cache is irrelevant for |
|
2034 |
// the total submission limit; when it is exceeded for one user, it is
|
|
2035 |
// exceeded for any other user.
|
|
1971 | 2036 |
if (($total_limit_exceeded = webform_submission_total_limit_check($node))) { |
1972 | 2037 |
$enabled = FALSE; |
1973 | 2038 |
} |
... | ... | |
2005 | 2070 |
|
2006 | 2071 |
// Print out messages for the webform. |
2007 | 2072 |
if (empty($node->in_preview) && !isset($node->webform_block) && !$logging_in) { |
2008 |
theme('webform_view_messages', array('node' => $node, 'page' => $page, 'submission_count' => $submission_count, 'user_limit_exceeded' => $user_limit_exceeded, 'total_limit_exceeded' => $total_limit_exceeded, 'allowed_roles' => $allowed_roles, 'closed' => $closed, 'cached' => $cached)); |
|
2073 |
theme('webform_view_messages', array( |
|
2074 |
'node' => $node, |
|
2075 |
'page' => $page, |
|
2076 |
'submission_count' => $submission_count, |
|
2077 |
'user_limit_exceeded' => $user_limit_exceeded, |
|
2078 |
'total_limit_exceeded' => $total_limit_exceeded, |
|
2079 |
'allowed_roles' => $allowed_roles, |
|
2080 |
'closed' => $closed, |
|
2081 |
'cached' => $cached, |
|
2082 |
) |
|
2083 |
); |
|
2009 | 2084 |
} |
2010 | 2085 |
|
2011 | 2086 |
// Add the output to the node. |
... | ... | |
2023 | 2098 |
/** |
2024 | 2099 |
* Helper. Generates an array of allowed roles. |
2025 | 2100 |
* |
2026 |
* @param object $node
|
|
2101 |
* @param stdClass $node
|
|
2027 | 2102 |
* The loaded node object containing a webform. |
2028 |
* @param boolean $user_is_allowed
|
|
2103 |
* @param bool $user_is_allowed |
|
2029 | 2104 |
* Reference to boolean to be set to whether the current user is allowed. |
2105 |
* |
|
2030 | 2106 |
* @return array |
2031 | 2107 |
* Associative array of allowed roles indexed by the role id with a boolean |
2032 | 2108 |
* value indicating if the current user has this role. |
... | ... | |
2057 | 2133 |
/** |
2058 | 2134 |
* Output the Webform into the node content. |
2059 | 2135 |
* |
2060 |
* @param $node |
|
2136 |
* @param stdClass $node
|
|
2061 | 2137 |
* The webform node object. |
2062 |
* @param $page |
|
2138 |
* @param stdClass $page
|
|
2063 | 2139 |
* If this webform node is being viewed as the main content of the page. |
2064 |
* @param $form |
|
2140 |
* @param array $form
|
|
2065 | 2141 |
* The rendered form. |
2066 | 2142 |
* @param $enabled |
2067 | 2143 |
* If the form allowed to be completed by the current user. |
2144 |
* |
|
2145 |
* @return string |
|
2068 | 2146 |
*/ |
2069 | 2147 |
function theme_webform_view($variables) { |
2070 | 2148 |
// Only show the form if this user is allowed access. |
... | ... | |
2076 | 2154 |
/** |
2077 | 2155 |
* Display a message to a user if they are not allowed to fill out a form. |
2078 | 2156 |
* |
2079 |
* @param $node |
|
2157 |
* @param stdClass $node
|
|
2080 | 2158 |
* The webform node object. |
2081 | 2159 |
* @param $page |
2082 | 2160 |
* If this webform node is being viewed as the main content of the page. |
... | ... | |
2110 | 2188 |
$message = t('Submissions for this form are closed.'); |
2111 | 2189 |
} |
2112 | 2190 |
elseif ($node->webform['confidential'] && user_is_logged_in()) { |
2113 |
$message = t('This form is confidential. You must <a href="!url">Log out</a> to submit it.', |
|
2114 |
array('!url' => url('/user/logout', array('query' => array('destination' => request_uri()))))); |
|
2191 |
$message = t('This form is confidential. You must <a href="!url">Log out</a> to submit it.', array('!url' => url('/user/logout', array('query' => array('destination' => request_uri()))))); |
|
2115 | 2192 |
} |
2116 | 2193 |
// If open and not allowed to submit the form, give an explanation. |
2117 | 2194 |
elseif (array_search(TRUE, $allowed_roles) === FALSE && $user->uid != 1) { |
... | ... | |
2276 | 2353 |
'#node' => $node, |
2277 | 2354 |
'#sid' => $_SESSION['webform_confirmation'][$nid]['sid'], |
2278 | 2355 |
); |
2279 |
}
|
|
2356 |
} |
|
2280 | 2357 |
elseif (strlen(trim(strip_tags($node->webform['confirmation'])))) { |
2281 | 2358 |
// Display confirmation link drupal status messages, but in the block. |
2282 | 2359 |
$message = webform_replace_tokens($node->webform['confirmation'], |
... | ... | |
2287 | 2364 |
$content = array( |
2288 | 2365 |
'confirmation_message' => array( |
2289 | 2366 |
'#markup' => "<div class=\"messages status webform-confirmation\">\n" . |
2290 |
'<h2 class="element-invisible">' . t('Status message') . "</h2>\n" .
|
|
2291 |
$message .
|
|
2292 |
"</div>\n",
|
|
2367 |
'<h2 class="element-invisible">' . t('Status message') . "</h2>\n" . |
|
2368 |
$message . |
|
2369 |
"</div>\n", |
|
2293 | 2370 |
'#weight' => -1, |
2294 | 2371 |
), |
2295 | 2372 |
'webform_view' => $content, |
2296 | 2373 |
); |
2297 |
|
|
2298 | 2374 |
} |
2299 | 2375 |
unset($_SESSION['webform_confirmation'][$nid]); |
2300 | 2376 |
if (empty($_SESSION['webform_confirmation'])) { |
... | ... | |
2401 | 2477 |
* The current form array (always empty). |
2402 | 2478 |
* @param $form_state |
2403 | 2479 |
* The current form values of a submission, used in multipage webforms. |
2404 |
* @param $node |
|
2480 |
* @param stdClass $node
|
|
2405 | 2481 |
* The current webform node. |
2406 | 2482 |
* @param $submission |
2407 | 2483 |
* An object containing information about the form submission if we're |
... | ... | |
2463 | 2539 |
|
2464 | 2540 |
$form['#submit'] = array('webform_client_form_pages', 'webform_client_form_submit'); |
2465 | 2541 |
$form['#validate'] = array('webform_client_form_validate'); |
2466 |
// Add includes for used component types and pre/post validation handlers |
|
2542 |
// Add includes for used component types and pre/post validation handlers.
|
|
2467 | 2543 |
$form['#process'] = array('webform_client_form_process'); |
2468 | 2544 |
|
2469 | 2545 |
if (is_array($node->webform['components']) && !empty($node->webform['components'])) { |
2470 | 2546 |
// Prepare a new form array. |
2471 | 2547 |
$form['submitted'] = array( |
2472 |
'#tree' => TRUE |
|
2548 |
'#tree' => TRUE,
|
|
2473 | 2549 |
); |
2474 | 2550 |
$form['details'] = array( |
2475 | 2551 |
'#tree' => TRUE, |
... | ... | |
2528 | 2604 |
$sorter = webform_get_conditional_sorter($node); |
2529 | 2605 |
$sorter->reportErrors(); |
2530 | 2606 |
|
2531 |
// Excecute the condtionals on the current input values |
|
2607 |
// Excecute the condtionals on the current input values.
|
|
2532 | 2608 |
$input_values = $sorter->executeConditionals($input_values); |
2533 | 2609 |
|
2534 | 2610 |
// Allow values from other pages to be sent to browser for conditionals. |
... | ... | |
2544 | 2620 |
// 1) previous/next non-empty page, or |
2545 | 2621 |
// 2) the preview page, or |
2546 | 2622 |
// 3) the preview page, forcing its display if the form would unexpectedly submit, or |
2547 |
// 4) page 1 even if empty, if no other previous page would be shown |
|
2623 |
// 4) page 1 even if empty, if no other previous page would be shown.
|
|
2548 | 2624 |
$form_state['webform']['page_num'] = $submission->highest_valid_page; |
2549 | 2625 |
do { |
2550 | 2626 |
$form_state['webform']['page_num']++; |
2551 | 2627 |
} while (!webform_get_conditional_sorter($node)->pageVisibility($form_state['webform']['page_num'])); |
2552 |
if (!$form_state['webform']['preview'] && $form_state['webform']['page_num'] == $form_state['webform']['page_count'] + (int)!$form_state['webform']['preview']) { |
|
2628 |
if (!$form_state['webform']['preview'] && $form_state['webform']['page_num'] == $form_state['webform']['page_count'] + (int) !$form_state['webform']['preview']) {
|
|
2553 | 2629 |
// Force a preview to avert an unintended submission via Next. |
2554 | 2630 |
$form_state['webform']['preview'] = TRUE; |
2555 | 2631 |
$form_state['webform']['page_count']++; |
... | ... | |
2575 | 2651 |
'#page_num' => $page_num, |
2576 | 2652 |
'#page_count' => count($page_labels), |
2577 | 2653 |
'#page_labels' => $page_labels, |
2578 |
'#weight' => -100 |
|
2654 |
'#weight' => -100,
|
|
2579 | 2655 |
); |
2580 | 2656 |
} |
2581 | 2657 |
|
... | ... | |
2631 | 2707 |
'#value' => isset($submission->uid) ? $submission->uid : $user->uid, |
2632 | 2708 |
); |
2633 | 2709 |
$form['details']['page_num'] = array( |
2634 |
'#type' => 'hidden',
|
|
2710 |
'#type' => 'hidden', |
|
2635 | 2711 |
'#value' => $page_num, |
2636 | 2712 |
); |
2637 | 2713 |
$form['details']['page_count'] = array( |
2638 |
'#type' => 'hidden',
|
|
2714 |
'#type' => 'hidden', |
|
2639 | 2715 |
'#value' => $page_count, |
2640 | 2716 |
); |
2641 | 2717 |
$form['details']['finished'] = array( |
... | ... | |
2660 | 2736 |
'#type' => 'submit', |
2661 | 2737 |
'#value' => t('Save Draft'), |
2662 | 2738 |
'#weight' => -2, |
2663 |
'#validate' => array('webform_client_form_prevalidate'), // Prevalidation only; no element validation for Save Draft |
|
2739 |
// Prevalidation only; no element validation for Save Draft. |
|
2740 |
'#validate' => array('webform_client_form_prevalidate'), |
|
2664 | 2741 |
'#attributes' => array( |
2665 | 2742 |
'formnovalidate' => 'formnovalidate', |
2666 | 2743 |
'class' => array('webform-draft'), |
... | ... | |
2726 | 2803 |
// Add the post validation to end of validators. Do this first on the off |
2727 | 2804 |
// chance that an _alter function has unset form['#validate']. |
2728 | 2805 |
$form['#validate'][] = 'webform_client_form_postvalidate'; |
2729 |
// Add the pre-validator to the front of the list to run first |
|
2806 |
// Add the pre-validator to the front of the list to run first.
|
|
2730 | 2807 |
array_unshift($form['#validate'], 'webform_client_form_prevalidate'); |
2731 | 2808 |
|
2732 | 2809 |
return $form; |
2733 | 2810 |
} |
2734 | 2811 |
|
2735 |
|
|
2736 | 2812 |
/** |
2737 | 2813 |
* Add a component to a renderable array. Called recursively for fieldsets. |
2738 | 2814 |
* |
2739 | 2815 |
* This function assists in the building of the client form, as well as the |
2740 | 2816 |
* display of results, and the text of e-mails. |
2741 | 2817 |
* |
2742 |
* @param $node |
|
2818 |
* @param stdClass $node
|
|
2743 | 2819 |
* The current webform node. |
2744 | 2820 |
* @param $component |
2745 | 2821 |
* The component to be added to the form. |
... | ... | |
2808 | 2884 |
// Show the component only on its form page, or if building an unfiltered |
2809 | 2885 |
// version of the form (such as for Form Builder). |
2810 | 2886 |
elseif ($component['page_num'] == $page_num || $filter == FALSE) { |
2811 |
// Add this user-defined field to the form (with all the values that are always available). |
|
2887 |
// Add this user-defined field to the form (with all the values that are |
|
2888 |
// always available). |
|
2812 | 2889 |
if ($element = webform_component_invoke($component['type'], 'render', $component, $component_value, $filter, $form['#submission'])) { |
2813 | 2890 |
// Set access based on the private property. |
2814 | 2891 |
$element += array('#access' => TRUE); |
... | ... | |
2832 | 2909 |
// Add custom CSS classes to the field and wrapper. |
2833 | 2910 |
_webform_component_classes($element, $component); |
2834 | 2911 |
|
2835 |
// Allow modules to modify a webform component that is going to be render in a form. |
|
2912 |
// Allow modules to modify a webform component that is going to be render |
|
2913 |
// in a form. |
|
2836 | 2914 |
drupal_alter('webform_component_render', $element, $component); |
2837 | 2915 |
|
2838 | 2916 |
// Add the element into the proper parent in the form. |
... | ... | |
2854 | 2932 |
$sorter = webform_get_conditional_sorter($node); |
2855 | 2933 |
foreach ($component['children'] as $scid => $subcomponent) { |
2856 | 2934 |
$subcomponent_value = isset($input_values[$scid]) ? $input_values[$scid] : NULL; |
2857 |
// Include if always shown, or for forms, also if currently hidden but might be shown due to conditionals. |
|
2935 |
// Include if always shown, or for forms, also if currently hidden but |
|
2936 |
// might be shown due to conditionals. |
|
2858 | 2937 |
$visibility = $sorter->componentVisibility($scid, $subcomponent['page_num']); |
2859 | 2938 |
if ($visibility == WebformConditionals::componentShown || ($format == 'form' && $visibility) || !$filter) { |
2860 | 2939 |
_webform_client_form_add_component($node, $subcomponent, $subcomponent_value, $parent_fieldset[$component['form_key']], $form, $input_values, $format, $page_num, $filter); |
... | ... | |
2880 | 2959 |
// Check if the user is allowed to submit based on role. This check is |
2881 | 2960 |
// repeated here to ensure the user is still logged in at the time of |
2882 | 2961 |
// submission, otherwise a stale form in another window may be allowed. |
2883 |
$allowed_roles = _webform_allowed_roles($node, $allowed_role); // $allowed_role set by reference. |
|
2962 |
// $allowed_role set by reference. |
|
2963 |
$allowed_roles = _webform_allowed_roles($node, $allowed_role); |
|
2884 | 2964 |
|
2885 | 2965 |
// Check that the submissions have not exceeded the total submission limit. |
2886 | 2966 |
$total_limit_exceeded = FALSE; |
... | ... | |
2902 | 2982 |
// is no submission yet (hence isn't being edited) or the user isn't an admin. |
2903 | 2983 |
// Another way to consider this is that the form is open when its status is |
2904 | 2984 |
// open OR there is a submission and the user is an admin. |
2905 |
$closed = empty($node->webform['status']) && |
|
2906 |
(empty($form['#submission']) || !user_access('edit all webform submissions')); |
|
2985 |
$closed = empty($node->webform['status']) && (empty($form['#submission']) || !user_access('edit all webform submissions')); |
|
2907 | 2986 |
|
2908 | 2987 |
// Prevent submission by throwing an error. |
2909 | 2988 |
if ((!$allowed_role || $total_limit_exceeded || $user_limit_exceeded || $closed)) { |
... | ... | |
2916 | 2995 |
* Form API #validate handler for the webform_client_form() form. |
2917 | 2996 |
*/ |
2918 | 2997 |
function webform_client_form_validate($form, &$form_state) { |
2919 |
if (($errors = form_get_errors()) && key_exists('', $errors)) { |
|
2920 |
// Prevalidation failed. The form cannot be submitted. Do not attemp futher validation. |
|
2998 |
if (($errors = form_get_errors()) && array_key_exists('', $errors)) { |
|
2999 |
// Prevalidation failed. The form cannot be submitted. Do not attemp futher |
|
3000 |
// validation. |
|
2921 | 3001 |
return; |
2922 | 3002 |
} |
2923 | 3003 |
if ($form_state['webform']['preview'] && $form_state['webform']['page_count'] === $form_state['webform']['page_num']) { |
... | ... | |
2943 | 3023 |
$input_values = NULL; |
2944 | 3024 |
} |
2945 | 3025 |
|
2946 |
|
|
2947 | 3026 |
// Run all #element_validate and #required checks. These are skipped initially |
2948 | 3027 |
// by setting #validated = TRUE on all components when they are added. |
2949 | 3028 |
_webform_client_form_validate($form, $form_state, 'webform_client_form', $input_values); |
... | ... | |
2982 | 3061 |
$component = $elements['#webform_component']; |
2983 | 3062 |
$value = $input_values[$cid]; |
2984 | 3063 |
$value = is_array($value) ? $value[0] : $value; |
2985 |
// webform_component_invoke cannot be called with reference arguments. Call directly. |
|
2986 |
// webform_component_invoke($component['type'], 'action_set', $component, $elements, $form_state, $value); |
|
3064 |
// webform_component_invoke cannot be called with reference arguments. |
|
3065 |
// Call directly. |
|
3066 |
// webform_component_invoke($component['type'], 'action_set', $component, |
|
3067 |
// $elements, $form_state, $value);. |
|
2987 | 3068 |
$function = '_webform_action_set_' . $component['type']; |
2988 | 3069 |
$function($component, $elements, $form_state, $value); |
2989 | 3070 |
} |
... | ... | |
2993 | 3074 |
if (isset($required)) { |
2994 | 3075 |
$elements['#required'] = $required; |
2995 | 3076 |
|
2996 |
// Some components, e.g. grids, have nested sub-elements. Extend required
|
|
2997 |
// to any sub-components. |
|
3077 |
// Some components, for example, grids, have nested sub-elements. Extend
|
|
3078 |
// required to any sub-components.
|
|
2998 | 3079 |
foreach (element_children($elements) as $key) { |
2999 | 3080 |
if (isset($elements[$key]) && $elements[$key] && !isset($elements[$key]['#webform_component'])) { |
3000 | 3081 |
// Child is *not* a component. |
... | ... | |
3027 | 3108 |
form_error($elements, t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value'])))); |
3028 | 3109 |
} |
3029 | 3110 |
|
3111 |
// Verify that the value is not shorter than #minlength. The value may |
|
3112 |
// still be empty (required is a separate validation option). |
|
3113 |
if (isset($elements['#minlength'])) { |
|
3114 |
$length = drupal_strlen($elements['#value']); |
|
3115 |
if ($length > 0 && $length < $elements['#minlength']) { |
|
3116 |
form_error($elements, t('!name cannot be shorter than %min characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%min' => $elements['#minlength'], '%length' => drupal_strlen($elements['#value'])))); |
|
3117 |
} |
|
3118 |
} |
|
3119 |
|
|
3030 | 3120 |
if (isset($elements['#options']) && isset($elements['#value'])) { |
3031 | 3121 |
if ($elements['#type'] == 'select') { |
3032 | 3122 |
$options = form_options_flatten($elements['#options']); |
... | ... | |
3058 | 3148 |
// #value data. |
3059 | 3149 |
elseif (isset($elements['#element_validate'])) { |
3060 | 3150 |
foreach ($elements['#element_validate'] as $function) { |
3061 |
if (is_callable($function)) {
|
|
3151 |
if (is_callable($function)) { |
|
3062 | 3152 |
$function($elements, $form_state, $form_state['complete form']); |
3063 | 3153 |
} |
3064 | 3154 |
} |
... | ... | |
3113 | 3203 |
$node->webform['auto_save'] && |
3114 | 3204 |
!$form_state['values']['details']['finished'] && |
3115 | 3205 |
!empty($form_state['values']['op'])) { |
3116 |
// Validation errors are present, prevalidation succeeded (e.g. submission
|
|
3117 |
// limits are ok), auto-save is enabled, this form isn't finished (i.e. is
|
|
3118 |
// or soon will be a draft) and a button was pushed (not ajax). |
|
3119 |
|
|
3206 |
// Validation errors are present, prevalidation succeeded (for example
|
|
3207 |
// submission limits are ok), auto-save is enabled, this form isn't finished
|
|
3208 |
// (this is, is or soon will be a draft) and a button was pushed (not ajax).
|
|
3209 |
// |
|
3120 | 3210 |
// Process submission on a copy of the form and form_state to prevent the |
3121 | 3211 |
// submission handlers from making unintended changes. Use a button that |
3122 | 3212 |
// isn't Save Draft, Next Page, Submit, etc to avoid triggering any |
... | ... | |
3208 | 3298 |
// 1) previous/next non-empty page, or |
3209 | 3299 |
// 2) the preview page, or |
3210 | 3300 |
// 3) the preview page, forcing its display if the form would unexpectedly submit, or |
3211 |
// 4) page 1 even if empty, if no other previous page would be shown |
|
3212 |
$preview_page_num = $form_state['storage']['page_count'] + (int)!$form_state['webform']['preview']; |
|
3301 |
// 4) page 1 even if empty, if no other previous page would be shown.
|
|
3302 |
$preview_page_num = $form_state['storage']['page_count'] + (int) !$form_state['webform']['preview'];
|
|
3213 | 3303 |
$page_num = $current_page; |
3214 | 3304 |
do { |
3215 | 3305 |
$page_num += $forward; |
... | ... | |
3228 | 3318 |
} |
3229 | 3319 |
|
3230 | 3320 |
// Inform the submit handlers that a draft will be saved. |
3231 |
$form_state['save_draft'] = in_array($form_state['values']['op'], array($draft_op, '__AUTOSAVE__')) || |
|
3232 |
($node->webform['auto_save'] && !$form_state['values']['details']['finished'] && !$form_state['webform_completed'] && user_is_logged_in()); |
|
3321 |
$form_state['save_draft'] = in_array($form_state['values']['op'], array($draft_op, '__AUTOSAVE__')) || ($node->webform['auto_save'] && !$form_state['values']['details']['finished'] && !$form_state['webform_completed'] && user_is_logged_in()); |
|
3233 | 3322 |
|
3234 | 3323 |
// Determine what we need to do on the next page. |
3235 | 3324 |
if (!empty($form_state['save_draft']) || !$form_state['webform_completed']) { |
... | ... | |
3271 | 3360 |
|
3272 | 3361 |
// Merge with new submission data. The + operator maintains numeric keys. |
3273 | 3362 |
// This maintains existing data with just-submitted data when a user resumes |
3274 |
// a submission previously saved as a draft. |
|
3275 |
// Remove any existing data on this and previous pages. If components are hidden, they may
|
|
3276 |
// be in the $submission->data but absent entirely from $new_data;
|
|
3363 |
// a submission previously saved as a draft. Remove any existing data on
|
|
3364 |
// this and previous pages. If components are hidden, they may be in the
|
|
3365 |
// $submission->data but absent entirely from $new_data.
|
|
3277 | 3366 |
$page_map = webform_get_conditional_sorter($node)->getPageMap(); |
3278 | 3367 |
for ($page_nr = 1; $page_nr <= $form_state['webform']['page_num']; $page_nr++) { |
3279 | 3368 |
$submission->data = array_diff_key($submission->data, $page_map[$page_nr]); |
... | ... | |
3292 | 3381 |
$submission->is_draft = $is_draft; |
3293 | 3382 |
$submission->highest_valid_page = 0; |
3294 | 3383 |
if ($is_draft) { |
3295 |
$submission->highest_valid_page = end($form_state['clicked_button']['#parents']) == 'next' && $form_state['values']['op'] != '__AUTOSAVE__'
|
|
3296 |
? $form_state['webform']['page_num']
|
|
3297 |
: $form_state['webform']['page_num'] - 1;
|
|
3384 |
$submission->highest_valid_page = end($form_state['clicked_button']['#parents']) == 'next' && $form_state['values']['op'] != '__AUTOSAVE__' |
|
3385 |
? $form_state['webform']['page_num'] |
|
3386 |
: $form_state['webform']['page_num'] - 1; |
|
3298 | 3387 |
} |
3299 | 3388 |
|
3300 | 3389 |
// If there is no data to be saved (such as on a multipage form with no fields |
... | ... | |
3409 | 3498 |
/** |
3410 | 3499 |
* Post processes the submission tree with any updates from components. |
3411 | 3500 |
* |
3412 |
* @param $node |
|
3501 |
* @param stdClass $node
|
|
3413 | 3502 |
* The full webform node. |
3414 | 3503 |
* @param $form_values |
3415 | 3504 |
* The form values for the form. |
... | ... | |
3481 | 3570 |
module_load_include('inc', 'webform', 'includes/webform.conditionals'); |
3482 | 3571 |
$submission_data = isset($vars['form']['#conditional_values']) ? $vars['form']['#conditional_values'] : array(); |
3483 | 3572 |
$settings = webform_conditional_prepare_javascript($vars['form']['#node'], |
3484 |
$submission_data,
|
|
3485 |
$vars['form']['details']['page_num']['#value']);
|
|
3573 |
$submission_data, |
|
3574 |
$vars['form']['details']['page_num']['#value']); |
|
3486 | 3575 |
drupal_add_js(array('webform' => array('conditionals' => array('webform-client-form-' . $vars['nid'] => $settings))), 'setting'); |
3487 | 3576 |
} |
3488 |
|
|
3489 | 3577 |
} |
3490 | 3578 |
|
3491 | 3579 |
/** |
... | ... | |
3654 | 3742 |
TRUE => !empty($element['#description']) ? ' <div class="description">' . $element['#description'] . "</div>\n" : '', |
3655 | 3743 |
); |
3656 | 3744 |
|
3745 |
// If #children does not contain an element with a matching @id, do not |
|
3746 |
// include @for in the label. |
|
3747 |
if (strpos($element['#children'], ' id="' . $variables['element']['#id'] . '"') === FALSE) { |
|
3748 |
$variables['element']['#id'] = NULL; |
|
3749 |
} |
|
3750 |
|
|
3657 | 3751 |
switch ($element['#title_display']) { |
3658 | 3752 |
case 'inline': |
3659 | 3753 |
$output .= $description[$above]; |
... | ... | |
3813 | 3907 |
$attributes['class'][] = 'element-invisible'; |
3814 | 3908 |
} |
3815 | 3909 |
|
3816 |
$attributes['class'][] = 'webform-inline-radio';
|
|
3817 |
if (!empty($element['#id'])) {
|
|
3818 |
$attributes['for'] = $element['#id'];
|
|
3819 |
}
|
|
3910 |
$attributes['class'][] = 'webform-inline-radio'; |
|
3911 |
if (!empty($element['#id'])) { |
|
3912 |
$attributes['for'] = $element['#id']; |
|
3913 |
} |
|
3820 | 3914 |
|
3821 | 3915 |
// The leading whitespace helps visually separate fields from inline labels. |
3822 | 3916 |
return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n"; |
... | ... | |
3825 | 3919 |
/** |
3826 | 3920 |
* Theme the headers when sending an email from webform. |
3827 | 3921 |
* |
3828 |
* @param $node |
|
3922 |
* @param stdClass $node
|
|
3829 | 3923 |
* The complete node object for the webform. |
3830 | 3924 |
* @param $submission |
3831 | 3925 |
* The webform submission of the user. |
... | ... | |
3834 | 3928 |
* you can check the $email['email'] property to output different content. |
3835 | 3929 |
* This will be the ID of the component that is a conditional e-mail |
3836 | 3930 |
* recipient. For the normal e-mails, it will have the value of 'default'. |
3931 |
* |
|
3837 | 3932 |
* @return |
3838 | 3933 |
* An array of headers to be used when sending a webform email. If headers |
3839 | 3934 |
* for "From", "To", or "Subject" are set, they will take precedence over |
... | ... | |
3854 | 3949 |
// should be returned. |
3855 | 3950 |
if (isset($_POST['form_id']) && stripos($_POST['form_id'], 'webform_client_form_') === 0 && |
3856 | 3951 |
!empty($_POST['details']['sid']) && empty($_POST['details']['finished'])) { |
3857 |
// A draft is already being edited |
|
3952 |
// A draft is already being edited.
|
|
3858 | 3953 |
$sid = $_POST['details']['sid']; |
3859 | 3954 |
} |
3860 | 3955 |
else { |
... | ... | |
3881 | 3976 |
/** |
3882 | 3977 |
* Returns a new or cached WebformConditionals object for the specified node. |
3883 | 3978 |
* |
3884 |
* @param object $node
|
|
3979 |
* @param stdClass $node
|
|
3885 | 3980 |
* The loaded webform node. |
3981 |
* |
|
3886 | 3982 |
* @returns object |
3887 | 3983 |
* Object of type WebformConditionals, possibly with the conditionals already |
3888 | 3984 |
* analyzed for dependencies. |
... | ... | |
3901 | 3997 |
return $strict ? webform_filter_xss($output) : $output; |
3902 | 3998 |
} |
3903 | 3999 |
|
3904 |
/* |
|
4000 |
/**
|
|
3905 | 4001 |
* Replace tokens with Webform contexts populated. |
3906 | 4002 |
* |
3907 | 4003 |
* @param $string |
3908 | 4004 |
* The string to have its tokens replaced. |
3909 |
* @param $node |
|
4005 |
* @param stdClass $node
|
|
3910 | 4006 |
* If replacing node-level tokens, the node for which tokens will be created. |
3911 | 4007 |
* @param $submission |
3912 | 4008 |
* If replacing submission-level tokens, the submission for which tokens will |
... | ... | |
3957 | 4053 |
* to be called with the option 'clear' => FALSE, to not remove input filters. |
3958 | 4054 |
* For security reasons webform_replace_tokens() is called before |
3959 | 4055 |
* check_markup(), where input filters get replaced. Tokens won't be replaced if |
3960 |
* there is no value provided. These tokens i.e. [current-page:query:*] needs to
|
|
3961 |
* be removed to not show up in the output. |
|
4056 |
* there is no value provided. These tokens, that is, [current-page:query:*]
|
|
4057 |
* needs to be removed to not show up in the output.
|
|
3962 | 4058 |
* |
3963 | 4059 |
* Note: This function was previously named webform_clear_tokens, which |
3964 | 4060 |
* conflicted with the webform_clear module, being called as hook_tokens. |
3965 | 4061 |
* |
3966 | 4062 |
* @param string $text |
3967 | 4063 |
* The text to have its tokens removed. |
4064 |
* |
|
4065 |
* @return mixed|string |
|
4066 |
* Replace tokens with actual value. |
|
4067 |
* |
|
3968 | 4068 |
* @see token_replace() |
3969 | 4069 |
*/ |
3970 | 4070 |
function webform_replace_tokens_clear($text) { |
... | ... | |
3993 | 4093 |
* |
3994 | 4094 |
* @param string $redirect_url |
3995 | 4095 |
* The redirect URL, with everything other than tokens already URL encoded. |
3996 |
* @param $node |
|
4096 |
* @param stdClass $node
|
|
3997 | 4097 |
* If replacing node-level tokens, the node for which tokens will be created. |
3998 | 4098 |
* @param $submission |
3999 | 4099 |
* If replacing submission-level tokens, the submission for which tokens will |
4000 | 4100 |
* be created. |
4101 |
* |
|
4001 | 4102 |
* @return array |
4002 | 4103 |
* An array of path and url() options, suitable for a redirect or drupal_goto. |
4003 | 4104 |
*/ |
... | ... | |
4061 | 4162 |
/** |
4062 | 4163 |
* Utility function to ensure that a webform record exists in the database. |
4063 | 4164 |
* |
4064 |
* @param $node |
|
4165 |
* @param stdClass $node
|
|
4065 | 4166 |
* The node object to check if a database entry exists. |
4167 |
* |
|
4066 | 4168 |
* @return |
4067 | 4169 |
* This function should always return TRUE if no errors were encountered, |
4068 | 4170 |
* ensuring that a webform table row has been created. Will return FALSE if |
... | ... | |
4086 | 4188 |
* delete rows from the webform table if the node-type is exclusively used for |
4087 | 4189 |
* webforms (per the "webform_node_types_primary" variable). |
4088 | 4190 |
* |
4089 |
* @param $node |
|
4191 |
* @param stdClass $node
|
|
4090 | 4192 |
* The node object to check if a database entry is still required. |
4193 |
* |
|
4091 | 4194 |
* @return |
4092 | 4195 |
* Returns TRUE if the webform still has a record in the database. Returns |
4093 | 4196 |
* FALSE if the webform does not have a record or if the previously existing |
... | ... | |
4110 | 4213 |
} |
4111 | 4214 |
|
4112 | 4215 |
/** |
4113 |
* Given a form_key and a list of form_key parents, determine the cid.
|
|
4216 |
* Given a component's form_key and optionally its parent's cid, get its cid(s).
|
|
4114 | 4217 |
* |
4115 |
* @param $node |
|
4116 |
* A fully loaded node object. |
|
4117 |
* @param $form_key |
|
4118 |
* The form key for which we're finding a cid.
|
|
4119 |
* @param $parent
|
|
4218 |
* @param stdClass $node
|
|
4219 |
* A fully loaded webform node object.
|
|
4220 |
* @param string $form_key
|
|
4221 |
* The form key for which to find the cid(s).
|
|
4222 |
* @param int|null $pid
|
|
4120 | 4223 |
* The cid of the parent component. |
4224 |
* |
|
4225 |
* @return int|int[] |
|
4226 |
* The cid of the component or an array of component ids. |
|
4121 | 4227 |
*/ |
4122 |
function webform_get_cid(&$node, $form_key, $pid) { |
|
4123 |
foreach ($node->webform['components'] as $cid => $component) { |
|
4124 |
if ($component['form_key'] == $form_key && $component['pid'] == $pid) { |
|
4125 |
return $cid; |
|
4228 |
function webform_get_cid(&$node, $form_key, $pid = NULL) { |
|
4229 |
if ($pid === NULL) { |
|
4230 |
$cids = array(); |
|
4231 |
foreach ($node->webform['components'] as $cid => $component) { |
|
4232 |
if ((string) $component['form_key'] === (string) $form_key) { |
|
4233 |
$cids[] = $cid; |
|
4234 |
} |
|
4235 |
} |
|
4236 |
return $cids; |
|
4237 |
} |
|
4238 |
else { |
|
4239 |
foreach ($node->webform['components'] as $cid => $component) { |
|
4240 |
if ((string) $component['form_key'] === (string) $form_key && $component['pid'] == $pid) { |
|
4241 |
return $cid; |
|
4242 |
} |
|
4126 | 4243 |
} |
4127 | 4244 |
} |
4128 | 4245 |
} |
... | ... | |
4130 | 4247 |
/** |
4131 | 4248 |
* Find the label of a given page based on page breaks. |
4132 | 4249 |
* |
4133 |
* @param $node |
|
4250 |
* @param stdClass $node
|
|
4134 | 4251 |
* The webform node. |
4135 | 4252 |
* @param $form_state |
4136 | 4253 |
* The form's state, if available |
4254 |
* |
|
4137 | 4255 |
* @return array |
4138 | 4256 |
* An array of all page labels, indexed by page number. |
4139 | 4257 |
*/ |
... | ... | |
4164 | 4282 |
case 'webform_blocks': |
4165 | 4283 |
$result = variable_get('webform_blocks', array()); |
4166 | 4284 |
break; |
4285 |
|
|
4167 | 4286 |
case 'webform_tracking_mode': |
4168 | 4287 |
$result = variable_get('webform_tracking_mode', 'cookie'); |
4169 | 4288 |
break; |
4289 |
|
|
4170 | 4290 |
case 'webform_allowed_tags': |
4171 | 4291 |
$result = variable_get('webform_allowed_tags', array('a', 'em', 'strong', 'code', 'img')); |
4172 | 4292 |
break; |
4293 |
|
|
4173 | 4294 |
case 'webform_email_address_format': |
4174 | 4295 |
$result = variable_get('webform_email_address_format', 'long'); |
4175 | 4296 |
break; |
4297 |
|
|
4176 | 4298 |
case 'webform_email_address_individual': |
4177 | 4299 |
$result = variable_get('webform_email_address_individual', 0); |
4178 | 4300 |
break; |
4301 |
|
|
4179 | 4302 |
case 'webform_default_from_name': |
4180 | 4303 |
$result = variable_get('webform_default_from_name', variable_get('site_name', '')); |
4181 | 4304 |
break; |
4305 |
|
|
4182 | 4306 |
case 'webform_default_from_address': |
4183 | 4307 |
$result = variable_get('webform_default_from_address', variable_get('site_mail', ini_get('sendmail_from'))); |
4184 | 4308 |
break; |
4309 |
|
|
4185 | 4310 |
case 'webform_default_subject': |
4186 | 4311 |
$result = variable_get('webform_default_subject', t('Form submission from: [node:title]')); |
4187 | 4312 |
break; |
4313 |
|
|
4188 | 4314 |
case 'webform_email_replyto': |
4189 | 4315 |
$result = variable_get('webform_email_replyto', TRUE); |
4190 | 4316 |
break; |
4317 |
|
|
4191 | 4318 |
case 'webform_email_html_capable': |
4192 | 4319 |
$result = variable_get('webform_email_html_capable', FALSE); |
4193 | 4320 |
break; |
4321 |
|
|
4194 | 4322 |
case 'webform_default_format': |
4195 | 4323 |
$result = variable_get('webform_default_format', 0); |
4196 | 4324 |
break; |
4325 |
|
|
4197 | 4326 |
case 'webform_format_override': |
4198 | 4327 |
$result = variable_get('webform_format_override', 0); |
4199 | 4328 |
break; |
4329 |
|
|
4200 | 4330 |
case 'webform_email_select_max': |
4201 | 4331 |
$result = variable_get('webform_email_select_max', 50); |
4202 | 4332 |
break; |
4333 |
|
|
4203 | 4334 |
case 'webform_node_types': |
4204 | 4335 |
$result = webform_node_types(); |
4205 | 4336 |
break; |
4337 |
|
|
4206 | 4338 |
case 'webform_node_types_primary': |
4207 | 4339 |
$result = variable_get('webform_node_types_primary', array('webform')); |
4208 | 4340 |
break; |
4341 |
|
|
4209 | 4342 |
case 'webform_date_type': |
4210 | 4343 |
$result = variable_get('webform_date_type', 'medium'); |
4211 | 4344 |
break; |
4345 |
|
|
4212 | 4346 |
case 'webform_export_format': |
4213 | 4347 |
module_load_include('inc', 'webform', 'includes/webform.export'); |
4214 | 4348 |
$options = webform_export_list(); |
4215 | 4349 |
$result = variable_get('webform_export_format', 'excel'); |
4216 | 4350 |
$result = isset($options[$result]) ? $result : key($options); |
4217 | 4351 |
break; |
4352 |
|
|
4218 | 4353 |
case 'webform_csv_delimiter': |
4219 | 4354 |
$result = variable_get('webform_csv_delimiter', '\t'); |
4220 | 4355 |
break; |
4356 |
|
|
4221 | 4357 |
case 'webform_csv_line_ending': |
4222 | 4358 |
$result = variable_get('webform_csv_line_ending', "\n"); |
4223 | 4359 |
break; |
4360 |
|
|
4224 | 4361 |
case 'webform_export_wordwrap': |
4225 | 4362 |
$result = variable_get('webform_export_wordwrap', 0); |
4226 | 4363 |
break; |
4364 |
|
|
4227 | 4365 |
case 'webform_excel_legacy_exporter': |
4228 | 4366 |
$result = variable_get('webform_excel_legacy_exporter', 0); |
4229 | 4367 |
break; |
4368 |
|
|
4230 | 4369 |
case 'webform_progressbar_style': |
4231 | 4370 |
$result = variable_get('webform_progressbar_style', array('progressbar_bar', 'progressbar_pagebreak_labels', 'progressbar_include_confirmation')); |
4232 | 4371 |
break; |
4372 |
|
|
4233 | 4373 |
case 'webform_progressbar_label_first': |
4234 | 4374 |
$result = variable_get('webform_progressbar_label_first', t('Start')); |
4235 | 4375 |
break; |
4376 |
|
|
4236 | 4377 |
case 'webform_progressbar_label_confirmation': |
4237 | 4378 |
$result = variable_get('webform_progressbar_label_confirmation', t('Complete')); |
4238 | 4379 |
break; |
4380 |
|
|
4239 | 4381 |
case 'webform_table': |
4240 | 4382 |
$result = variable_get('webform_table', FALSE); |
4241 | 4383 |
break; |
4384 |
|
|
4242 | 4385 |
case 'webform_submission_access_control': |
4243 | 4386 |
$result = variable_get('webform_submission_access_control', 1); |
4244 | 4387 |
break; |
4388 |
|
|
4245 | 4389 |
case 'webform_token_access': |
4246 | 4390 |
$result = variable_get('webform_token_access', 1); |
4247 | 4391 |
break; |
4392 |
|
|
4248 | 4393 |
case 'webform_update_batch_size': |
4249 | 4394 |
$result = variable_get('webform_update_batch_size', 100); |
4250 | 4395 |
break; |
4396 |
|
|
4251 | 4397 |
case 'webform_disabled_components': |
4252 | 4398 |
$result = variable_get('webform_disabled_components', array()); |
4253 | 4399 |
break; |
... | ... | |
4340 | 4486 |
* @param $name |
4341 | 4487 |
* The name to be used in the formatted address. If the address contains a |
4342 | 4488 |
* name in 'Some Name <somename@example.com>' format, $name is ignored. |
4343 |
* @param $node |
|
4489 |
* @param stdClass $node
|
|
4344 | 4490 |
* The webform node if replacements will be done. |
4345 | 4491 |
* @param $submission |
4346 | 4492 |
* The webform submission values if replacements will be done. |
... | ... | |
4355 | 4501 |
* "long", or NULL for the system default. |
4356 | 4502 |
* @param $mapping |
4357 | 4503 |
* A mapping array to be applied to the address values. |
4504 |
* |
|
4358 | 4505 |
* @return string|array |
4359 | 4506 |
* The formatted e-mail address -- or addresses (if not $single) |
4360 | 4507 |
*/ |
... | ... | |
4377 | 4524 |
foreach ($name as &$one_name) { |
4378 | 4525 |
$one_name = isset($options[$one_name]) ? $options[$one_name] : $one_name; |
4379 | 4526 |
} |
4380 |
unset($one_name); // Drop PHP reference. |
|
4527 |
// Drop PHP reference. |
|
4528 |
unset($one_name); |
|
4381 | 4529 |
} |
4382 | 4530 |
} |
4383 | 4531 |
else { |
... | ... | |
4431 | 4579 |
} |
4432 | 4580 |
|
4433 | 4581 |
return $single ? reset($address) : $address; |
4434 |
|
|
4435 | 4582 |
} |
4436 | 4583 |
|
4437 | 4584 |
/** |
... | ... | |
4443 | 4590 |
* with a comma and space. |
4444 | 4591 |
* @param string $form_name |
4445 | 4592 |
* The name of the form element to receive an error, in form_set_error format. |
4446 |
* @param boolean $allow_empty
|
|
4593 |
* @param bool $allow_empty |
|
4447 | 4594 |
* TRUE if optional. FALSE if required. |
4448 |
* @param boolean $allow_multiple
|
|
4595 |
* @param bool $allow_multiple |
|
4449 | 4596 |
* TRUE if a list of emails is allowed. FALSE if only one. |
4450 |
* @param boolean $allow_tokens
|
|
4597 |
* @param bool $allow_tokens |
|
4451 | 4598 |
* TRUE if any token should be assumed to contain a valid e-mail address. |
4452 | 4599 |
* @param string $format |
4453 | 4600 |
* 'short', 'long', or NULL (for default) format. Long format has a name and |
4454 | 4601 |
* the address in angle brackets. |
4455 |
* @return integer|boolean |
|
4602 |
* |
|
4603 |
* @return int|bool |
|
4456 | 4604 |
* The number of valid addresses found, or FALSE for an invalid email found. |
4457 | 4605 |
*/ |
4458 | 4606 |
function webform_email_validate(&$emails, $form_name, $allow_empty, $allow_multiple, $allow_tokens, $format = NULL) { |
... | ... | |
4476 | 4624 |
* An email address, a list of comma-separated email addresses. If all the |
4477 | 4625 |
* addresses are valid, the list of trimmed, non-empty emails is returned by |
4478 | 4626 |
* reference. |
4479 |
* @param boolean $allow_tokens
|
|
4627 |
* @param bool $allow_tokens |
|
4480 | 4628 |
* TRUE if any token should be assumed to contain a valid e-mail address. |
4481 | 4629 |
* @param string $format |
4482 | 4630 |
* 'short', 'long', or NULL (for default) format. Long format has a name and |
4483 | 4631 |
* the address in angle brackets. |
4484 |
* @return boolean|integer |
|
4632 |
* |
|
4633 |
* @return bool|int |
|
4485 | 4634 |
* Returns FALSE if an invalid e-mail address was found, 0 if no email |
4486 | 4635 |
* address(es) were found, or the number of valid e-mail addresses found. |
4487 | 4636 |
*/ |
... | ... | |
4514 | 4663 |
* @param string $format |
4515 | 4664 |
* 'short', 'long', or NULL (for default) format. Long format has a name and |
4516 | 4665 |
* the address in angle brackets. |
4666 |
* |
|
4517 | 4667 |
* @return array |
4518 | 4668 |
* Associative array indexed by 'name' and 'address'. |
4519 | 4669 |
*/ |
... | ... | |
4522 | 4672 |
$format = webform_variable_get('webform_email_address_format'); |
4523 | 4673 |
} |
4524 | 4674 |
if ($format == 'long') { |
4525 |
// Match e-mails of the form 'My Name <email@domain.com>' as follows: |
|
4526 |
// ^ = beginning of string |
|
4527 |
// "? = optional quote |
|
4528 |
// ([^<]*?) = match optional characters that aren't a < (non-greedy) |
|
4529 |
// "? = optional quote |
|
4530 |
// SPACE* = optional spaces |
|
4531 |
// (?:<(.*)>) = < matching stuff > (without the angle brakets) |
|
4532 |
// $ = end of string |
|
4675 |
// Match e-mails of the form 'My Name <email@domain.com>'. |
|
4533 | 4676 |
preg_match('/^"?([^<]*?)"? *(?:<(.*)>)?$/', $email, $matches); |
4534 | 4677 |
if (isset($matches[2]) && strlen($matches[2])) { |
4535 | 4678 |
return array( |
... | ... | |
4582 | 4725 |
} |
4583 | 4726 |
|
4584 | 4727 |
/** |
4585 |
* Convert an array of components into a tree |
|
4728 |
* Convert an array of components into a tree.
|
|
4586 | 4729 |
*/ |
4587 | 4730 |
function _webform_components_tree_build($src, &$tree, $parent, &$page_count) { |
4588 | 4731 |
foreach ($src as $cid => $component) { |
... | ... | |
4631 | 4774 |
} |
4632 | 4775 |
|
4633 | 4776 |
/** |
4634 |
* Sort each level of a component tree by weight and name |
|
4777 |
* Sort each level of a component tree by weight and name.
|
|
4635 | 4778 |
*/ |
4636 | 4779 |
function _webform_components_tree_sort($tree) { |
4637 | 4780 |
if (isset($tree['children']) && is_array($tree['children'])) { |
... | ... | |
4663 | 4806 |
$components += $module_components; |
4664 | 4807 |
} |
4665 | 4808 |
drupal_alter('webform_component_info', $components); |
4666 |
uasort($components, function($a, $b) { |
|
4809 |
uasort($components, function ($a, $b) {
|
|
4667 | 4810 |
return strnatcasecmp($a['label'], $b['label']); |
4668 | 4811 |
}); |
4669 | 4812 |
$enabled = array_diff_key($components, $disabled); |
... | ... | |
4716 | 4859 |
* The callback to execute. |
4717 | 4860 |
* @param ... |
4718 | 4861 |
* Any additional parameters required by the $callback. |
4862 |
* |
|
4863 |
* @return mixed |
|
4864 |
* Return value of the callback on success and FALSE on failure. |
|
4719 | 4865 |
*/ |
4720 | 4866 |
function webform_component_invoke($type, $callback) { |
4721 | 4867 |
$args = func_get_args(); |
... | ... | |
4735 | 4881 |
* The component type as a string. |
4736 | 4882 |
* @param $callback |
4737 | 4883 |
* The callback to check. |
4884 |
* |
|
4885 |
* @return bool |
|
4738 | 4886 |
*/ |
4739 | 4887 |
function webform_component_implements($type, $callback) { |
4740 | 4888 |
$function = '_webform_' . $callback . '_' . $type; |
... | ... | |
4756 | 4904 |
function _webform_component_classes(&$element, $component) { |
4757 | 4905 |
if (isset($component['extra']['css_classes']) && drupal_strlen($component['extra']['css_classes'])) { |
4758 | 4906 |
$element['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] : array(); |
4759 |
$element['#attributes']['class'] = array_merge($element['#attributes']['class'], explode(' ' , $component['extra']['css_classes']));
|
|
4907 |
$element['#attributes']['class'] = array_merge($element['#attributes']['class'], explode(' ', $component['extra']['css_classes'])); |
|
4760 | 4908 |
} |
4761 | 4909 |
if (isset($component['extra']['wrapper_classes']) && drupal_strlen($component['extra']['wrapper_classes'])) { |
4762 | 4910 |
$element['#wrapper_attributes']['class'] = isset($element['#wrapper_attributes']['class']) ? $element['#wrapper_attributes']['class'] : array(); |
4763 |
$element['#wrapper_attributes']['class'] = array_merge($element['#wrapper_attributes']['class'], explode(' ' , $component['extra']['wrapper_classes']));
|
|
4911 |
$element['#wrapper_attributes']['class'] = array_merge($element['#wrapper_attributes']['class'], explode(' ', $component['extra']['wrapper_classes'])); |
|
4764 | 4912 |
} |
4765 | 4913 |
} |
4766 | 4914 |
|
... | ... | |
4774 | 4922 |
/** |
4775 | 4923 |
* Set the necessary breadcrumb for the page we are on. |
4776 | 4924 |
* |
4777 |
* @param object $node
|
|
4925 |
* @param stdClass $node
|
|
4778 | 4926 |
* The loaded webform node. |
4779 |
* @param boolean|object $submission
|
|
4927 |
* @param bool|object $submission |
|
4780 | 4928 |
* The submission if the current page is viewing or dealing with a submission, |
4781 | 4929 |
* or TRUE to just include the webform node in the breadcrumbs (used for |
4782 | 4930 |
* the submission completion confirmation page), or NULL for no extra |
4783 |
* processing |
|
4931 |
* processing.
|
|
4784 | 4932 |
*/ |
4785 | 4933 |
function webform_set_breadcrumb($node, $submission = NULL) { |
4786 | 4934 |
$node_path = "node/{$node->nid}"; |
... | ... | |
4807 | 4955 |
// Setting the current menu href will cause the submission title and current |
4808 | 4956 |
// tab (if not the default tab) to be added to the active path when the |
4809 | 4957 |
// webform is in the default location in the menu (node/NID). The title |
4810 |
// is desirable, but the tab name (e.g. Edit or Delete) isn't.
|
|
4958 |
// is desirable, but the tab name (for example Edit or Delete) isn't.
|
|
4811 | 4959 |
if (preg_match('/href=".*"/', end($breadcrumb), $matches)) { |
4812 | 4960 |
foreach ($breadcrumb as $index => $link) { |
4813 | 4961 |
if (stripos($link, $matches[0]) !== FALSE) { |
... | ... | |
4815 | 4963 |
break; |
4816 | 4964 |
} |
4817 | 4965 |
} |
4818 |
} |
|
4966 |
}
|
|
4819 | 4967 |
|
4820 | 4968 |
// If the user is dealing with a submission, then the breadcrumb should |
4821 | 4969 |
// be fudged to allow them to return to a likely list of webforms. |
... | ... | |
4858 | 5006 |
* - hour (in 24hr notation) |
4859 | 5007 |
* - minute |
4860 | 5008 |
* - second |
5009 |
* |
|
5010 |
* @return array |
|
5011 |
* Date in array formate. |
|
4861 | 5012 |
*/ |
4862 | 5013 |
function webform_date_array($string, $type = NULL) { |
4863 | 5014 |
$pattern = '/((\d{4}?)-(\d{2}?)-(\d{2}?))?(T?(\d{2}?):(\d{2}?):(\d{2}?))?/'; |
... | ... | |
4892 | 5043 |
* @param $type |
4893 | 5044 |
* If wanting a specific string format back specify either "date" or "time". |
4894 | 5045 |
* Otherwise a full ISO 8601 date and time string will be returned. |
5046 |
* |
|
5047 |
* @return string |
|
5048 |
* Date in string format |
|
4895 | 5049 |
*/ |
4896 | 5050 |
function webform_date_string($array, $type = NULL) { |
4897 | 5051 |
$string = ''; |
... | ... | |
4909 | 5063 |
} |
4910 | 5064 |
|
4911 | 5065 |
if ($type == 'time' || !isset($type)) { |
4912 |
$string .= empty($array['hour']) ? '00' : sprintf('%02d', $array['hour']);
|
|
5066 |
$string .= empty($array['hour']) ? '00' : sprintf('%02d', $array['hour']); |
|
4913 | 5067 |
$string .= ':'; |
4914 |
$string .= empty($array['minute']) ? '00' : sprintf('%02d', $array['minute']);
|
|
5068 |
$string .= empty($array['minute']) ? '00' : sprintf('%02d', $array['minute']); |
|
4915 | 5069 |
$string .= ':'; |
4916 |
$string .= empty($array['second']) ? '00' : sprintf('%02d', $array['second']);
|
|
5070 |
$string .= empty($array['second']) ? '00' : sprintf('%02d', $array['second']); |
|
4917 | 5071 |
} |
4918 | 5072 |
|
4919 | 5073 |
return $string; |
... | ... | |
4929 | 5083 |
* @param array $exclude |
4930 | 5084 |
* An array containing 'day', 'month', and/or 'year' if they should be |
4931 | 5085 |
* removed from the format. |
5086 |
* |
|
4932 | 5087 |
* @return string |
4933 | 5088 |
* A date/time format string. |
4934 | 5089 |
*/ |
... | ... | |
4953 | 5108 |
// -------------------------------------------------------------------------- |
4954 | 5109 |
// Time aABgGhHisueIOPTZ |
4955 | 5110 |
// Special /.,-: <space> |
4956 |
|
|
5111 |
// |
|
4957 | 5112 |
// Strip Time and Special characters from the beginning and end of format. |
4958 | 5113 |
$date_format = trim($format, 'aABgGhHisueIOPTZ/.,-: '); |
4959 | 5114 |
|
... | ... | |
5013 | 5168 |
// 3) Set the time to midnight because when a non-referenced relative |
5014 | 5169 |
// date is created without a time, it is created at midnight (0:00). |
5015 | 5170 |
// 4) Adjust to the specified relative (or absolute) time. |
5016 |
|
|
5017 | 5171 |
@$datetime = new DateTime('@' . $reference_timestamp); |
5018 | 5172 |
@$datetime->setTimezone($timezone) |
5019 |
->setTime(0, 0, 0)
|
|
5020 |
->modify($string);
|
|
5173 |
->setTime(0, 0, 0) |
|
5174 |
->modify($string); |
|
5021 | 5175 |
} |
5022 | 5176 |
else { |
5023 | 5177 |
@$datetime = new DateTime($string, $timezone); |
... | ... | |
5084 | 5238 |
$path = './' . drupal_get_path('module', 'webform') . '/views/default_views/*.inc'; |
5085 | 5239 |
$views = array(); |
5086 | 5240 |
foreach (glob($path) as $views_filename) { |
5087 |
require_once($views_filename);
|
|
5241 |
require_once $views_filename;
|
|
5088 | 5242 |
} |
5089 | 5243 |
return $views; |
5090 | 5244 |
} |
... | ... | |
5248 | 5402 |
* @param int $nid |
5249 | 5403 |
* The Node ID of the Webform. |
5250 | 5404 |
* |
5251 |
* $return int
|
|
5405 |
* @return int
|
|
5252 | 5406 |
* The largest serial number used by a submission plus 1 for the specified |
5253 | 5407 |
* node or 1 when there are no submissions. |
5254 | 5408 |
*/ |
... | ... | |
5266 | 5420 |
/** |
5267 | 5421 |
* Alter the node before saving a clone. |
5268 | 5422 |
* |
5269 |
* @param $node |
|
5423 |
* @param stdClass $node
|
|
5270 | 5424 |
* Reference to the fully loaded node object being saved (the clone) that |
5271 | 5425 |
* can be altered as needed. |
5272 | 5426 |
* @param array $context |
... | ... | |
5310 | 5464 |
// is that the POST was truncated because PHP exceeded its max_input_vars limit. |
5311 | 5465 |
$subs = array( |
5312 | 5466 |
'@count' => webform_count_terminals($_POST), |
5313 |
'@limit' => (int)ini_get('max_input_vars'), |
|
5467 |
'@limit' => (int) ini_get('max_input_vars'),
|
|
5314 | 5468 |
); |
5315 | 5469 |
drupal_set_message(user_access('administer site configuration') |
5316 | 5470 |
? t('This form could not be submitted because $_POST was truncated to @count input vars. PHP max_input_vars is @limit and needs to be increased.', $subs) |
5317 | 5471 |
: t('This form could not be submitted because it exceeds the server configuration. Contact the administrator.'), |
5318 | 5472 |
'error'); |
5319 | 5473 |
watchdog('webform', |
5320 |
'POST truncated to @count input vars. PHP max_input_vars is @limit. Increase max_input_vars.',
|
|
5321 |
$subs,
|
|
5322 |
WATCHDOG_ERROR);
|
|
5474 |
'POST truncated to @count input vars. PHP max_input_vars is @limit. Increase max_input_vars.', |
|
5475 |
$subs, |
|
5476 |
WATCHDOG_ERROR); |
|
5323 | 5477 |
} |
5324 | 5478 |
} |
5325 | 5479 |
|
... | ... | |
5334 | 5488 |
$limit = ini_get('max_input_vars'); |
5335 | 5489 |
if ($limit) { |
5336 | 5490 |
// Estimate the number of input vars needed to see if the PHP limit has been exceeded. |
5337 |
$count = 1 + webform_count_input_vars($element); // Additional input_vars: op |
|
5491 |
// Additional input_vars: op. |
|
5492 |
$count = 1 + webform_count_input_vars($element); |
|
5338 | 5493 |
if ($count > $limit * 0.95) { |
5339 | 5494 |
$subs = array( |
5340 | 5495 |
'@count' => $count, |
... | ... | |
5342 | 5497 |
); |
5343 | 5498 |
$warning = array( |
5344 | 5499 |
'#markup' => '<div class="messages warning">' . |
5345 |
(user_access('administer site configuration')
|
|
5346 |
? t('This form contains @count input elements. PHP max_input_vars is @limit and should be increased.', $subs)
|
|
5347 |
: t('This form may be too long to work properly. Contact the administrator.'))
|
|
5348 |
. '</div>',
|
|
5500 |
(user_access('administer site configuration') |
|
5501 |
? t('This form contains @count input elements. PHP max_input_vars is @limit and should be increased.', $subs) |
|
5502 |
: t('This form may be too long to work properly. Contact the administrator.')) |
|
5503 |
. '</div>', |
|
5349 | 5504 |
'#weight' => -1, |
5350 | 5505 |
); |
5351 | 5506 |
if ($element['#input_var_waring_parent']) { |
... | ... | |
5355 | 5510 |
$element['input_vars_warning'] = $warning; |
5356 | 5511 |
} |
5357 | 5512 |
watchdog('webform', |
5358 |
'Page contains @count input elements but PHP max_input_vars is only @limit. Increase max_input_vars.',
|
|
5359 |
$subs,
|
|
5360 |
WATCHDOG_ERROR);
|
|
5513 |
'Page contains @count input elements but PHP max_input_vars is only @limit. Increase max_input_vars.', |
|
5514 |
$subs, |
|
5515 |
WATCHDOG_ERROR); |
|
5361 | 5516 |
} |
5362 | 5517 |
} |
5363 | 5518 |
return $element; |
... | ... | |
5378 | 5533 |
* |
5379 | 5534 |
* @param array $element |
5380 | 5535 |
* The form whose elements should be counted. |
5381 |
* @return integer |
|
5536 |
* |
|
5537 |
* @return int |
|
5382 | 5538 |
* The number of elements in the form that will result in $_POST entries. |
5383 | 5539 |
*/ |
5384 | 5540 |
function webform_count_input_vars($element) { |
... | ... | |
5412 | 5568 |
* |
5413 | 5569 |
* @param $a |
5414 | 5570 |
* Array or array element to be counted |
5415 |
* @return integer |
|
5571 |
* |
|
5572 |
* @return int |
|
5416 | 5573 |
* Number of non-array elements within $a. |
5417 | 5574 |
*/ |
5418 | 5575 |
function webform_count_terminals($a) { |
Formats disponibles : Unified diff
Weekly update of contrib modules