Snippets

missing_leg_session.diff

missing_leg_session.diff
diff --git a/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module b/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
index 394d474..503a3e9 100644
--- a/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
+++ b/docroot/sites/all/modules/custom/cga_legislators/cga_legislators.module
@@ -41,6 +41,7 @@ function cga_legislators_block_view($delta = '') {
       $committees = array();
       $committees['role'] = array();
       $committees['no_role'] = array();
+      $current_sess = cga_entity_queries_get_current_or_most_recent_session();
       foreach ($relations as $relation) {
         $wrapper = entity_metadata_wrapper('relation', $relation);
         $endpoints = $wrapper->endpoints->value();
@@ -53,6 +54,11 @@ function cga_legislators_block_view($delta = '') {
         foreach ($endpoints as $node) {
           if ($node->type->value() != 'legislator') {
             $w = entity_metadata_wrapper('node', $node);
+            // Check if committee is in the current session, if not, do not show on the legislator page.
+            $committee_sess = $w->field_session->value();
+            if($current_sess->tid != $committee_sess->tid) {
+              continue;
+            }
             // Add to committees array only if this committee is toggled for display
             if($w->field_display_on_member_page->value() == 1) {
               if (!empty($role)) {

Disable Search API index running on Dev and Stage servers on Acquia

disable_search_indexing_on_non_prod.php
<?php
/**
 * ENV AH_NON_PRODUCTION is set on dev and test on 
 *   acquia servers but not local servers.
 */
function cga_utility_search_api_index_load($indexes) {
  if( isset($_ENV['AH_NON_PRODUCTION']) ) {
    foreach ($indexes as &$index) {
      $index->read_only = "1";
    }
  }
}

Create Calendar PDF Queue Item.

create_cal_pdf.php
<?php

class NodeHouseCommitteeScheduleItemQueue extends ImportQueue {

  public function request($reset = FALSE, $pdf_request = FALSE) {
    parent::request($reset);

    if (!$pdf_request) {
      if (!empty($this->data->events)) {
        $this->data = $this->data->events;
      }
    } else {
      $this->data = $this->data->calendar_pdf;
    }
  }

  public function executeCronQueue() {
     // [deleted unnecessary code... ]
  
      //Need to pull across the schedule item PDF.
      $this->request(FALSE, TRUE);
      $url = $this->data;
      $cal_bean = bean_load(36);
      $bean_wrapper = entity_metadata_wrapper('bean', $cal_bean);
      $file_info = system_retrieve_file($url, 'public://', TRUE, FILE_EXISTS_REPLACE);
      if (!empty($file_info)) {
        $bean_wrapper->field_house_calendar->file->set($file_info);
        $bean_wrapper->save();
      }
      return parent::executeCronQueue(); // TODO: Change the autogenerated stub
  }
}

Apache 2.4 configuration example

apache-2_4.conf
<VirtualHost *:80>
  ServerAlias www.majorursa.net
  ServerName majorursa.net
  DocumentRoot /var/www/mu_dev/drupal-7.12/
  <Directory /var/www/mu_dev/drupal-7.12/>
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>

Hello Bigwig Markdown example

hello_bigwig.md

Hello to the Baron von Bigwig

NameColor
Bigwigblack/white
SuzyBlack
SeamusGray
ShermanWhite/Tortoiseshell
cat = "bigwig"
puts "hello, #{cat}!"

Let’s see a blockquote

To sleep is to experience Par*nashallah

—That guy who makes up words.

Bonnie is the junk lady

Mass update nodes in drupal

mass_update_nodes_devel.php
<?php
module_load_include('inc', 'node', 'node.admin');
$nids = db_query("SELECT nid FROM {node} where type = 'bill' ")->fetchCol();

// Update in batches
$start = 0;
$batch_size = 10;
$nids = array_slice($nids, $start, $batch_size);
node_mass_update($nids, array());