context_condition_book.inc 566 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * Expose book properties as a context condition.
  4. */
  5. class context_condition_book extends context_condition {
  6. function condition_values() {
  7. $values = array();
  8. foreach (book_get_books() as $book) {
  9. $values[$book['menu_name']] = check_plain($book['title']);
  10. }
  11. return $values;
  12. }
  13. function execute($node, $op) {
  14. if (isset($node->book, $node->book['menu_name'])) {
  15. foreach ($this->get_contexts($node->book['menu_name']) as $context) {
  16. $this->condition_met($context, $node->book['menu_name']);
  17. }
  18. }
  19. }
  20. }