Commit e0d2ff27 authored by Denis's avatar Denis
Browse files

Issue #3307624 by dench0: consent_manager 7.x-2.0 release

parent a4a9e7aa
Loading
Loading
Loading
Loading
+59 −13
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
function consent_manager_settings($form, &$form_state) {
  $config = variable_get('consent_manager');
  $path = '/' . drupal_get_path('module', 'consent_manager');

  $form['consent_manager'] = array(
    '#type' => 'fieldset',
@@ -22,6 +23,7 @@ function consent_manager_settings($form, &$form_state) {
    '#collapsible' => FALSE,
    '#tree' => TRUE,
  );
  
  $form['consent_manager']['blocking_mode'] = array(
    '#type' => 'select',
    '#title' => t('Blocking mode'),
@@ -32,15 +34,59 @@ function consent_manager_settings($form, &$form_state) {
    '#default_value' => isset($config['blocking_mode']) ? $config['blocking_mode'] : 'semi_automatic',
    '#required' => TRUE,
  );
  $form['consent_manager']['cmp_id'] = array(
  
  $form['consent_manager']['cdid'] = array(
    '#type' => 'textfield',
    '#title' => t('Id'),
    '#description' => t('If you don\'t yet have an ID, please get in on <a href="@url" target="_blank">www.consentmanager.net</a>', array('@url' => 'https://www.consentmanager.net/client/codes.php')),
    '#default_value' => isset($config['cmp_id']) ? $config['cmp_id'] : '',
    '#min' => 1,
    '#step' => 1,
    '#title' => t('Code-ID'),
    '#description' => t('If you don\'t yet have an Code-ID, please get in on <a href="@url" target="_blank">www.consentmanager.net</a>', array('@url' => 'https://www.consentmanager.net/client/codes.php')),
    '#default_value' => isset($config['cdid']) ? $config['cdid'] : '',
    '#required' => TRUE,
  );

  $form['consent_manager']['cdid_image'] = array(
    '#type' => 'html_tag',
    '#tag' => 'img',
    '#attributes' => array(
      'src' => $path . '/images/cmpcodeid.png',
      'width' => '500',
      'height' => 'auto',
    ),
  );

  $form['consent_manager']['host'] = array(
    '#type' => 'textfield',
    '#title' => t('Host'),
    '#description' => t('Leave blank to use the default value: %default_value. You need to specify the host name value only (without the protocol https://).', array('%default_value' => CONSENT_MANAGER_DEFAULT_HOST)),
    '#default_value' => isset($config['host']) ? $config['host'] : '',
  );

  $form['consent_manager']['host_image'] = array(
    '#type' => 'html_tag',
    '#tag' => 'img',
    '#attributes' => array(
      'src' => $path . '/images/cmphost.png',
      'width' => '500',
      'height' => 'auto',
    ),
  );

  $form['consent_manager']['cdn'] = array(
    '#type' => 'textfield',
    '#title' => t('CDN'),
    '#description' =>t('Leave blank to use the default value: %default_value. You need to specify the host name value only (without the protocol https://).', array('%default_value' => CONSENT_MANAGER_DEFAULT_CDN)),
    '#default_value' => isset($config['cdn']) ? $config['cdn'] : '',
  );

  $form['consent_manager']['cdn_image'] = array(
    '#type' => 'html_tag',
    '#tag' => 'img',
    '#attributes' => array(
      'src' => $path . '/images/cmpcdn.png',
      'width' => '500',
      'height' => 'auto',
    ),
  );
  
  $form['consent_manager']['custom_code'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom HTML code'),
@@ -58,13 +104,13 @@ function consent_manager_settings($form, &$form_state) {
 * @param $form_state
 */
function consent_manager_settings_validate($form, &$form_state) {
  if (empty($form_state['values']['consent_manager']['cmp_id'])) {
    form_set_error('consent_manager][cmp_id', t('You need to fill the <em>Id</em> value.'));
  }
  else {
    $cmp_id = $form_state['values']['consent_manager']['cmp_id'];
    if ($cmp_id < 1 || $cmp_id != (int) $cmp_id) {
      form_set_error('consent_manager][cmp_id', t('<em>Id</em> value should be positive integer.'));
  $host = $form_state['values']['consent_manager']['host'];
  if ($host && !filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
    form_set_error('consent_manager][host', t('Wrong host value.'));
  }

  $cdn = $form_state['values']['consent_manager']['cdn'];
  if ($cdn && !filter_var($cdn, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
    form_set_error('consent_manager][cdn', t('Wrong CDN value.'));
  }
}
+16 −51
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@
 * Provides the Consent Manager helper functions.
 */

define('CONSENT_MANAGER_AUTOMATIC_CODE', '<script type="text/javascript" data-cmp-ab="1" src="https://cdn.consentmanager.mgr.consensu.org/delivery/automatic.min.js" data-cmp-id="!cmp_id" data-cmp-host="consentmanager.mgr.consensu.org" data-cmp-cdn="cdn.consentmanager.mgr.consensu.org"></script>');
define('CONSENT_MANAGER_SEMI_AUTOMATIC_CODE', '<link rel="stylesheet" href="https://cdn.consentmanager.mgr.consensu.org/delivery/cmp.min.css" /><script>window.gdprAppliesGlobally=true;if(!("cmp_id" in window)){window.cmp_id=!cmp_id}if(!("cmp_params" in window)){window.cmp_params=""}if(!("cmp_host" in window)){window.cmp_host="consentmanager.mgr.consensu.org"}if(!("cmp_cdn" in window)){window.cmp_cdn="cdn.consentmanager.mgr.consensu.org"}window.cmp_getsupportedLangs=function(){var b=["DE","EN","FR","IT","NO","DA","FI","ES","PT","RO","BG","ET","EL","GA","HR","LV","LT","MT","NL","PL","SV","SK","SL","CS","HU","RU","SR","ZH","TR","UK","AR","BS"];if("cmp_customlanguages" in window){for(var a=0;a<window.cmp_customlanguages.length;a++){b.push(window.cmp_customlanguages[a].l.toUpperCase())}}return b};window.cmp_getRTLLangs=function(){return["AR"]};window.cmp_getlang=function(j){if(typeof(j)!="boolean"){j=true}if(j&&typeof(cmp_getlang.usedlang)=="string"&&cmp_getlang.usedlang!==""){return cmp_getlang.usedlang}var g=window.cmp_getsupportedLangs();var c=[];var f=location.hash;var e=location.search;var a="languages" in navigator?navigator.languages:[];if(f.indexOf("cmplang=")!=-1){c.push(f.substr(f.indexOf("cmplang=")+8,2))}else{if(e.indexOf("cmplang=")!=-1){c.push(e.substr(e.indexOf("cmplang=")+8,2))}else{if("cmp_setlang" in window&&window.cmp_setlang!=""){c.push(window.cmp_setlang.toUpperCase())}else{if(a.length>0){for(var d=0;d<a.length;d++){c.push(a[d])}}}}}if("language" in navigator){c.push(navigator.language)}if("userLanguage" in navigator){c.push(navigator.userLanguage)}var h="";for(var d=0;d<c.length;d++){var b=c[d].toUpperCase();if(g.indexOf(b)!=-1){h=b;break}if(b.indexOf("-")!=-1){b=b.substr(0,2)}if(g.indexOf(b)!=-1){h=b;break}}if(h==""&&typeof(cmp_getlang.defaultlang)=="string"&&cmp_getlang.defaultlang!==""){return cmp_getlang.defaultlang}else{if(h==""){h="EN"}}h=h.toUpperCase();return h};(function(){var a="";var f="_en";if("cmp_getlang" in window){a=window.cmp_getlang().toLowerCase();if("cmp_customlanguages" in window){for(var b=0;b<window.cmp_customlanguages.length;b++){if(window.cmp_customlanguages[b].l.toUpperCase()==a.toUpperCase()){a="en";break}}}f="_"+a}var d=("cmp_proto" in window)?window.cmp_proto:"https:";var h=("cmp_ref" in window)?window.cmp_ref:location.href;var c=document.createElement("script");c.setAttribute("data-cmp-ab","1");c.src=d+"//"+window.cmp_host+"/delivery/cmp.php?id="+window.cmp_id+"&h="+encodeURIComponent(h)+"&"+window.cmp_params+(document.cookie.length>0?"&__cmpfcc=1":"")+"&l="+a.toLowerCase()+"&o="+(new Date()).getTime();c.type="text/javascript";c.async=true;if(document.currentScript&&document.currentScript!==null){document.currentScript.parentElement.appendChild(c)}else{if(document.body&&document.body!==null){document.body.appendChild(c)}else{var g=document.getElementsByTagName("body");if(g.length==0){g=document.getElementsByTagName("div")}if(g.length==0){g=document.getElementsByTagName("span")}if(g.length==0){g=document.getElementsByTagName("ins")}if(g.length==0){g=document.getElementsByTagName("script")}if(g.length==0){g=document.getElementsByTagName("head")}if(g.length>0){g[0].appendChild(c)}}}var c=document.createElement("script");c.src=d+"//"+window.cmp_cdn+"/delivery/cmp"+f+".min.js";c.type="text/javascript";c.setAttribute("data-cmp-ab","1");c.async=true;if(document.currentScript&&document.currentScript!==null){document.currentScript.parentElement.appendChild(c)}else{if(document.body&&document.body!==null){document.body.appendChild(c)}else{var g=document.getElementsByTagName("body");if(g.length==0){g=document.getElementsByTagName("div")}if(g.length==0){g=document.getElementsByTagName("span")}if(g.length==0){g=document.getElementsByTagName("ins")}if(g.length==0){g=document.getElementsByTagName("script")}if(g.length==0){g=document.getElementsByTagName("head")}if(g.length>0){g[0].appendChild(c)}}}})();window.cmp_addFrame=function(b){if(!window.frames[b]){if(document.body&&document.body!==null){var a=document.createElement("iframe");a.style.cssText="display:none";a.name=b;document.body.appendChild(a)}else{window.setTimeout(\'window.cmp_addFrame("\'+b+\'")\',10)}}};window.cmp_rc=function(h){var b=document.cookie;var f="";var d=0;while(b!=""&&d<100){d++;while(b.substr(0,1)==" "){b=b.substr(1,b.length)}var g=b.substring(0,b.indexOf("="));if(b.indexOf(";")!=-1){var c=b.substring(b.indexOf("=")+1,b.indexOf(";"))}else{var c=b.substr(b.indexOf("=")+1,b.length)}if(h==g){f=c}var e=b.indexOf(";")+1;if(e==0){e=b.length}b=b.substring(e,b.length)}return(f)};window.cmp_stub=function(){var a=arguments;__cmapi.a=__cmapi.a||[];if(!a.length){return __cmapi.a}else{if(a[0]==="ping"){if(a[1]===2){a[2]({gdprApplies:gdprAppliesGlobally,cmpLoaded:false,cmpStatus:"stub",displayStatus:"hidden",apiVersion:"2.0",cmpId:31},true)}else{a[2]({gdprAppliesGlobally:gdprAppliesGlobally,cmpLoaded:false},true)}}else{if(a[0]==="getUSPData"){a[2]({version:1,uspString:window.cmp_rc("")},true)}else{if(a[0]==="getTCData"){__cmapi.a.push([].slice.apply(a))}else{if(a[0]==="addEventListener"||a[0]==="removeEventListener"){__cmapi.a.push([].slice.apply(a))}else{if(a.length==4&&a[3]===false){a[2]({},false)}else{__cmapi.a.push([].slice.apply(a))}}}}}}};window.cmp_msghandler=function(d){var a=typeof d.data==="string";try{var c=a?JSON.parse(d.data):d.data}catch(f){var c=null}if(typeof(c)==="object"&&c!==null&&"__cmpCall" in c){var b=c.__cmpCall;window.__cmp(b.command,b.parameter,function(h,g){var e={__cmpReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")})}if(typeof(c)==="object"&&c!==null&&"__cmapiCall" in c){var b=c.__cmapiCall;window.__cmapi(b.command,b.parameter,function(h,g){var e={__cmapiReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")})}if(typeof(c)==="object"&&c!==null&&"__uspapiCall" in c){var b=c.__uspapiCall;window.__uspapi(b.command,b.version,function(h,g){var e={__uspapiReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")})}if(typeof(c)==="object"&&c!==null&&"__tcfapiCall" in c){var b=c.__tcfapiCall;window.__tcfapi(b.command,b.version,function(h,g){var e={__tcfapiReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")},b.parameter)}};window.cmp_setStub=function(a){if(!(a in window)||(typeof(window[a])!=="function"&&typeof(window[a])!=="object"&&(typeof(window[a])==="undefined"||window[a]!==null))){window[a]=window.cmp_stub;window[a].msgHandler=window.cmp_msghandler;if(window.addEventListener){window.addEventListener("message",window.cmp_msghandler,false)}else{window.attachEvent("onmessage",window.cmp_msghandler)}}};window.cmp_addFrame("__cmapiLocator");window.cmp_addFrame("__cmpLocator");window.cmp_addFrame("__uspapiLocator");window.cmp_addFrame("__tcfapiLocator");window.cmp_setStub("__cmapi");window.cmp_setStub("__cmp");window.cmp_setStub("__tcfapi");window.cmp_setStub("__uspapi");</script>');
define('CONSENT_MANAGER_AUTOMATIC_CODE', '<script type="text/javascript" data-cmp-ab="1" src="https://@cdn/delivery/autoblocking/@cdid.js" data-cmp-host="@host" data-cmp-cdn="@cdn" data-cmp-codesrc="26"></script>');
define('CONSENT_MANAGER_SEMI_AUTOMATIC_CODE', '<script>window.gdprAppliesGlobally=true;if(!("cmp_id" in window)||window.cmp_id<1){window.cmp_id=0}if(!("cmp_cdid" in window)){window.cmp_cdid="@cdid"}if(!("cmp_params" in window)){window.cmp_params=""}if(!("cmp_host" in window)){window.cmp_host="@host"}if(!("cmp_cdn" in window)){window.cmp_cdn="@cdn"}if(!("cmp_proto" in window)){window.cmp_proto="https:"}if(!("cmp_codesrc" in window)){window.cmp_codesrc="1"}window.cmp_getsupportedLangs=function(){var b=["DE","EN","FR","IT","NO","DA","FI","ES","PT","RO","BG","ET","EL","GA","HR","LV","LT","MT","NL","PL","SV","SK","SL","CS","HU","RU","SR","ZH","TR","UK","AR","BS"];if("cmp_customlanguages" in window){for(var a=0;a<window.cmp_customlanguages.length;a++){b.push(window.cmp_customlanguages[a].l.toUpperCase())}}return b};window.cmp_getRTLLangs=function(){var a=["AR"];if("cmp_customlanguages" in window){for(var b=0;b<window.cmp_customlanguages.length;b++){if("r" in window.cmp_customlanguages[b]&&window.cmp_customlanguages[b].r){a.push(window.cmp_customlanguages[b].l)}}}return a};window.cmp_getlang=function(j){if(typeof(j)!="boolean"){j=true}if(j&&typeof(cmp_getlang.usedlang)=="string"&&cmp_getlang.usedlang!==""){return cmp_getlang.usedlang}var g=window.cmp_getsupportedLangs();var c=[];var f=location.hash;var e=location.search;var a="languages" in navigator?navigator.languages:[];if(f.indexOf("cmplang=")!=-1){c.push(f.substr(f.indexOf("cmplang=")+8,2).toUpperCase())}else{if(e.indexOf("cmplang=")!=-1){c.push(e.substr(e.indexOf("cmplang=")+8,2).toUpperCase())}else{if("cmp_setlang" in window&&window.cmp_setlang!=""){c.push(window.cmp_setlang.toUpperCase())}else{if(a.length>0){for(var d=0;d<a.length;d++){c.push(a[d])}}}}}if("language" in navigator){c.push(navigator.language)}if("userLanguage" in navigator){c.push(navigator.userLanguage)}var h="";for(var d=0;d<c.length;d++){var b=c[d].toUpperCase();if(g.indexOf(b)!=-1){h=b;break}if(b.indexOf("-")!=-1){b=b.substr(0,2)}if(g.indexOf(b)!=-1){h=b;break}}if(h==""&&typeof(cmp_getlang.defaultlang)=="string"&&cmp_getlang.defaultlang!==""){return cmp_getlang.defaultlang}else{if(h==""){h="EN"}}h=h.toUpperCase();return h};(function(){var n=document;var p=window;var f="";var b="_en";if("cmp_getlang" in p){f=p.cmp_getlang().toLowerCase();if("cmp_customlanguages" in p){for(var h=0;h<p.cmp_customlanguages.length;h++){if(p.cmp_customlanguages[h].l.toUpperCase()==f.toUpperCase()){f="en";break}}}b="_"+f}function g(e,d){var l="";e+="=";var i=e.length;if(location.hash.indexOf(e)!=-1){l=location.hash.substr(location.hash.indexOf(e)+i,9999)}else{if(location.search.indexOf(e)!=-1){l=location.search.substr(location.search.indexOf(e)+i,9999)}else{return d}}if(l.indexOf("&")!=-1){l=l.substr(0,l.indexOf("&"))}return l}var j=("cmp_proto" in p)?p.cmp_proto:"https:";if(j!="http:"&&j!="https:"){j="https:"}var k=("cmp_ref" in p)?p.cmp_ref:location.href;var q=n.createElement("script");q.setAttribute("data-cmp-ab","1");var c=g("cmpdesign","");var a=g("cmpregulationkey","");var o=g("cmpatt","");q.src=j+"//"+p.cmp_host+"/delivery/cmp.php?"+("cmp_id" in p&&p.cmp_id>0?"id="+p.cmp_id:"")+("cmp_cdid" in p?"cdid="+p.cmp_cdid:"")+"&h="+encodeURIComponent(k)+(c!=""?"&cmpdesign="+encodeURIComponent(c):"")+(a!=""?"&cmpregulationkey="+encodeURIComponent(a):"")+(o!=""?"&cmatt="+encodeURIComponent(o):"")+("cmp_params" in p?"&"+p.cmp_params:"")+(n.cookie.length>0?"&__cmpfcc=1":"")+"&l="+f.toLowerCase()+"&o="+(new Date()).getTime();q.type="text/javascript";q.async=true;if(n.currentScript&&n.currentScript.parentElement){n.currentScript.parentElement.appendChild(q)}else{if(n.body){n.body.appendChild(q)}else{var m=n.getElementsByTagName("body");if(m.length==0){m=n.getElementsByTagName("div")}if(m.length==0){m=n.getElementsByTagName("span")}if(m.length==0){m=n.getElementsByTagName("ins")}if(m.length==0){m=n.getElementsByTagName("script")}if(m.length==0){m=n.getElementsByTagName("head")}if(m.length>0){m[0].appendChild(q)}}}var q=n.createElement("script");q.src=j+"//"+p.cmp_cdn+"/delivery/js/cmp"+b+".min.js";q.type="text/javascript";q.setAttribute("data-cmp-ab","1");q.async=true;if(n.currentScript&&n.currentScript.parentElement){n.currentScript.parentElement.appendChild(q)}else{if(n.body){n.body.appendChild(q)}else{var m=n.getElementsByTagName("body");if(m.length==0){m=n.getElementsByTagName("div")}if(m.length==0){m=n.getElementsByTagName("span")}if(m.length==0){m=n.getElementsByTagName("ins")}if(m.length==0){m=n.getElementsByTagName("script")}if(m.length==0){m=n.getElementsByTagName("head")}if(m.length>0){m[0].appendChild(q)}}}})();window.cmp_addFrame=function(b){if(!window.frames[b]){if(document.body){var a=document.createElement("iframe");a.style.cssText="display:none";if("cmp_cdn" in window&&"cmp_ultrablocking" in window&&window.cmp_ultrablocking>0){a.src="//"+window.cmp_cdn+"/delivery/empty.html"}a.name=b;document.body.appendChild(a)}else{window.setTimeout(window.cmp_addFrame,10,b)}}};window.cmp_rc=function(h){var b=document.cookie;var f="";var d=0;while(b!=""&&d<100){d++;while(b.substr(0,1)==" "){b=b.substr(1,b.length)}var g=b.substring(0,b.indexOf("="));if(b.indexOf(";")!=-1){var c=b.substring(b.indexOf("=")+1,b.indexOf(";"))}else{var c=b.substr(b.indexOf("=")+1,b.length)}if(h==g){f=c}var e=b.indexOf(";")+1;if(e==0){e=b.length}b=b.substring(e,b.length)}return(f)};window.cmp_stub=function(){var a=arguments;__cmp.a=__cmp.a||[];if(!a.length){return __cmp.a}else{if(a[0]==="ping"){if(a[1]===2){a[2]({gdprApplies:gdprAppliesGlobally,cmpLoaded:false,cmpStatus:"stub",displayStatus:"hidden",apiVersion:"2.0",cmpId:31},true)}else{a[2](false,true)}}else{if(a[0]==="getUSPData"){a[2]({version:1,uspString:window.cmp_rc("")},true)}else{if(a[0]==="getTCData"){__cmp.a.push([].slice.apply(a))}else{if(a[0]==="addEventListener"||a[0]==="removeEventListener"){__cmp.a.push([].slice.apply(a))}else{if(a.length==4&&a[3]===false){a[2]({},false)}else{__cmp.a.push([].slice.apply(a))}}}}}}};window.cmp_msghandler=function(d){var a=typeof d.data==="string";try{var c=a?JSON.parse(d.data):d.data}catch(f){var c=null}if(typeof(c)==="object"&&c!==null&&"__cmpCall" in c){var b=c.__cmpCall;window.__cmp(b.command,b.parameter,function(h,g){var e={__cmpReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")})}if(typeof(c)==="object"&&c!==null&&"__uspapiCall" in c){var b=c.__uspapiCall;window.__uspapi(b.command,b.version,function(h,g){var e={__uspapiReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")})}if(typeof(c)==="object"&&c!==null&&"__tcfapiCall" in c){var b=c.__tcfapiCall;window.__tcfapi(b.command,b.version,function(h,g){var e={__tcfapiReturn:{returnValue:h,success:g,callId:b.callId}};d.source.postMessage(a?JSON.stringify(e):e,"*")},b.parameter)}};window.cmp_setStub=function(a){if(!(a in window)||(typeof(window[a])!=="function"&&typeof(window[a])!=="object"&&(typeof(window[a])==="undefined"||window[a]!==null))){window[a]=window.cmp_stub;window[a].msgHandler=window.cmp_msghandler;window.addEventListener("message",window.cmp_msghandler,false)}};window.cmp_addFrame("__cmpLocator");if(!("cmp_disableusp" in window)||!window.cmp_disableusp){window.cmp_addFrame("__uspapiLocator")}if(!("cmp_disabletcf" in window)||!window.cmp_disabletcf){window.cmp_addFrame("__tcfapiLocator")}window.cmp_setStub("__cmp");if(!("cmp_disabletcf" in window)||!window.cmp_disabletcf){window.cmp_setStub("__tcfapi")}if(!("cmp_disableusp" in window)||!window.cmp_disableusp){window.cmp_setStub("__uspapi")};</script>');

/**
 * Get Consent Manger code.
@@ -14,55 +14,20 @@ define('CONSENT_MANAGER_SEMI_AUTOMATIC_CODE', '<link rel="stylesheet" href="http
 */
function consent_manager_get_code() {
  $config = variable_get('consent_manager');
  $code = FALSE;
  $code_id = isset($config['cdid']) ? $config['cdid'] : NULL;

  $blocking_mode = isset($config['blocking_mode']) ? $config['blocking_mode'] : NULL;
  if ($code_id) {
    $custom_code = isset($config['custom_code']) ? $config['custom_code'] : '';
  $cmp_id = isset($config['cmp_id']) ? (int) $config['cmp_id'] : NULL;

  switch ($blocking_mode) {
    case 'automatic':
      $code = _consent_manager_get_automatic_code($cmp_id, $custom_code);
      break;

    case 'semi_automatic':
      $code = _consent_manager_get_semi_automatic_code($cmp_id, $custom_code);
      break;

    default:
      $code = FALSE;
    $blocking_mode = isset($config['blocking_mode']) ? $config['blocking_mode'] : 'automatic';
    $default_code = $blocking_mode === 'automatic' ? CONSENT_MANAGER_AUTOMATIC_CODE : CONSENT_MANAGER_SEMI_AUTOMATIC_CODE;

    $code = format_string($custom_code . $default_code, array(
      '@cdid' => $code_id,
      '@host' => !empty($config['host']) ? $config['host'] : CONSENT_MANAGER_DEFAULT_HOST,
      '@cdn' => !empty($config['cdn']) ? $config['cdn'] : CONSENT_MANAGER_DEFAULT_CDN,
    ));
  }

  return $code;
}
 No newline at end of file

/**
 * Get Consent Manger automatic code.
 *
 * @param int $cmp_id
 * @param string $custom_code
 *
 * @return false|string
 */
function _consent_manager_get_automatic_code($cmp_id, $custom_code) {
  if (!empty($cmp_id)) {
    $code = trim($custom_code) . CONSENT_MANAGER_AUTOMATIC_CODE;
    return format_string($code, array('!cmp_id' => $cmp_id));
  }
  return FALSE;
}

/**
 * Get Consent Manger semi-automatic code.
 *
 * @param int $cmp_id
 * @param string $custom_code
 *
 * @return false|string
 */
function _consent_manager_get_semi_automatic_code($cmp_id, $custom_code) {
  if (!empty($cmp_id)) {
    $code = trim($custom_code) . CONSENT_MANAGER_SEMI_AUTOMATIC_CODE;
    return format_string($code, array('!cmp_id' => $cmp_id));
  }
  return FALSE;
}
+28 −0
Original line number Diff line number Diff line
@@ -14,3 +14,31 @@ function consent_manager_uninstall() {
    ->condition('name', 'consent_manager')
    ->execute();
}

/**
 * Implements hook_requirements().
 */
function consent_manager_requirements($phase) {
  $requirements = array();

  if ($phase === 'runtime') {
    $config = variable_get('consent_manager');
    if (!empty($config['cdid'])) {
      $requirements['consent_manager'] = array(
        'title' => 'Consent manager',
        'value' => t('Consent manager Code-ID exists.'),
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $requirements['consent_manager'] = array(
        'title' => 'Consent manager',
        'value' => t('Consent manager Code-ID doesn\'t exists.'),
        'description' => t('You need to set the Code-ID value on this <a href="@link" target="_blank">page</a>.', array('@link' => '/admin/config/services/consent-manager')),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }

  return $requirements;
}
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@
 * Contains consent_manager.module.
 */

define('CONSENT_MANAGER_DEFAULT_HOST', 'delivery.consentmanager.net');
define('CONSENT_MANAGER_DEFAULT_CDN', 'cdn.consentmanager.net');

/**
 * Implements hook_help().
 */

images/cmpcdn.png

0 → 100644
+36 KiB
Loading image diff...
Loading