Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marwenblel/8ea9c50a7db6bd4991e6 to your computer and use it in GitHub Desktop.
Save marwenblel/8ea9c50a7db6bd4991e6 to your computer and use it in GitHub Desktop.
<?php
/**
* Expose the myfield field value as a context condition.
*/
class basedoc_droits_has_corporate_option extends context_condition {
/**
* condition_values
*/
function condition_values() {
return array(
'no' => t('No'),
'yes' => t('Yes'),
);
}
/**
* Condition form.
*/
function condition_form($context) {
$form = parent::condition_form($context);
if (variable_get('VXP_institutionnel', TRUE)) {
$default = array('no');
} else {
$default = array('yes');
}
$form['#default_value'] = $default;
$form['#disabled'] = TRUE;
return $form;
}
/**
* function execute
*/
function execute($value) {
if (is_array(context_condition_map()['basedoc_droits_has_corporate_option'])) {
foreach ($this->get_contexts($value) as $context) {
$this->condition_met($context, $value);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment