You are here

function context_condition_user_page::execute in Context 7.3

Same name and namespace in other branches
  1. 6.3 plugins/context_condition_user_page.inc \context_condition_user_page::execute()
  2. 6 plugins/context_condition_user_page.inc \context_condition_user_page::execute()

File

plugins/context_condition_user_page.inc, line 31

Class

context_condition_user_page
Expose user pages as a context condition.

Code

function execute($account, $op) {
  global $user;
  foreach ($this
    ->get_contexts($op) as $context) {
    if ($op === 'register') {
      $this
        ->condition_met($context);
    }
    else {
      $options = $this
        ->fetch_from_context($context, 'options');
      $mode = !empty($options['mode']) ? $options['mode'] : 'all';
      switch ($options['mode']) {
        case 'current':
          if ($account->uid == $user->uid) {
            $this
              ->condition_met($context);
          }
          break;
        case 'other':
          if ($account->uid != $user->uid) {
            $this
              ->condition_met($context);
          }
          break;
        case 'all':
        default:
          $this
            ->condition_met($context);
          break;
      }
    }
  }
}