예제 #1
0
 /**
  * @When /^I attach the file to the field banner$/
  */
 public function iAttachTheFileToTheField()
 {
     $query = new \entityFieldQuery();
     $query->entityCondition('entity_type', 'file')->propertyCondition('filename', 'banner6.jpg', 'LIKE')->range(0, 1);
     $result = $query->execute();
     if (!empty($result['file'])) {
         $fids = array_keys($result['file']);
     } else {
         throw new \Exception("File is not found");
     }
     $this->getSession()->executeScript("jQuery(\"input[name='c4m_banner[und][0][fid]']\").val(\"" . $fids[0] . "\");");
 }
예제 #2
0
 /**
  * @When I visit :arg1 node of type :arg2
  */
 public function iVisitNodeOfType($title, $type)
 {
     $query = new \entityFieldQuery();
     $result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', strtolower($type))->propertyCondition('title', $title)->propertyCondition('status', NODE_PUBLISHED)->range(0, 1)->execute();
     if (empty($result['node'])) {
         $params = array('@title' => $title, '@type' => $type);
         throw new \Exception(format_string("Node @title of @type not found.", $params));
     }
     $nid = key($result['node']);
     $params['@nid'] = $nid;
     $this->getSession()->visit($this->locatePath('node/' . $nid));
 }
예제 #3
0
 /**
  * Helper to get the group based on the title & type.
  *
  * @param string $title
  *   The group title.
  * @param string $type
  *   The group node type.
  *
  * @return stdClass
  *   The group (if any) or NULL.
  *
  * @throws Exception
  */
 private function loadGroupByTitleAndType($title, $type)
 {
     $query = new \entityFieldQuery();
     $result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', $type)->propertyCondition('title', $title)->propertyCondition('status', NODE_PUBLISHED)->range(0, 1)->execute();
     if (empty($result['node'])) {
         $params = array('@title' => $title, '@type' => $type);
         throw new \Exception(format_string("Group @title not found (type @type).", $params));
     }
     $gid = (int) key($result['node']);
     $group = node_load($gid);
     if (!$group) {
         $params = array('@title' => $title, '@type' => $type);
         throw new \Exception(format_string("Group @title not found (type @type).", $params));
     }
     return $group;
 }
예제 #4
0
 /**
  * @Given /^I update a "([^"]*)" with title "([^"]*)" with new title "([^"]*)" after "([^"]*)"$/
  */
 public function iUpdateAWithTitleInTheGroupWithNewTitleAfter($type, $title, $new_title, $time)
 {
     // Loading node of current content type and with current title.
     $query = new \entityFieldQuery();
     $result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', strtolower($type))->propertyCondition('title', $title)->propertyCondition('status', NODE_PUBLISHED)->range(0, 1)->execute();
     if (empty($result['node'])) {
         $params = array('@title' => $title, '@type' => $type);
         throw new \Exception(format_string("Node @title of @type not found.", $params));
     }
     $nid = key($result['node']);
     // Loading the previous message for the current node.
     $query = new \EntityFieldQuery();
     $result = $query->entityCondition('entity_type', 'message')->propertyCondition('type', 'c4m_insert__node__' . $type)->fieldCondition('field_node', 'target_id', $nid)->propertyOrderBy('timestamp', 'desc')->range(0, 1)->execute();
     if (empty($result['message'])) {
         throw new \Exception(format_string("Previous message not found."));
     }
     $id = key($result['message']);
     $message = message_load($id);
     // Changing timestamp of the previous message to earlier (minus current time).
     $message->timestamp = strtotime('now - ' . $time);
     $message->save();
     $node = node_load($nid);
     // Changing the current node title.
     $node->title = $new_title;
     node_save($node);
 }
예제 #5
0
 /**
  * Set the variable $name to $value for the site $vsite.
  */
 public static function VsiteSetVariable($vsite, $name, $value)
 {
     $query = new entityFieldQuery();
     $result = $query->entityCondition('entity_type', 'node')->propertyCondition('title', $vsite)->range(0, 1)->execute();
     if (empty($result['node'])) {
         return;
     }
     $nid = array_keys($result['node']);
     $vsite = vsite_get_vsite(reset($nid));
     $vsite->controllers->variable->set($name, $value);
 }
예제 #6
0
<?php

/**
 * @file
 * Drush script for converting private people pictures to public pictures.
 *
 *  Script parameters:
 *    --nid - List of people nodes IDs separated via Comma: 1,2
 *    --vsites - List of vsites IDs separated via Comma: 1,2
 */
$nids = drush_get_option('nids', 0);
$vsites = drush_get_option('vsites', 0);
$query = new entityFieldQuery();
$query->entityCondition('entity_type', 'node')->propertyCondition('type', 'person');
// Adding node IDs to the query.
if ($nids != 0) {
    $nids = explode(",", $nids);
    if (!empty($nids)) {
        $query->propertyCondition('nid', $nids, 'IN');
    }
}
// Adding sites to the query.
if ($vsites != 0) {
    $vsites = explode(",", $vsites);
    if (!empty($vsites)) {
        $query->fieldCondition(OG_AUDIENCE_FIELD, 'target_id', $vsites, 'IN');
    }
}
$result = $query->execute();
if (empty($result['node'])) {
    drush_log(dt('No records were found'), 'error');
<?php

/**
 * @file
 * Delete file reference to files which no longer exists.
 *
 * -- Arguments:
 *  - nid: The node ID you want to start from or you processed last.
 *  - batch: How much nodes to process every time, default is 250.
 */
// Get a list of fields that may contain files: files and image crop.
$file_fields = os_files_file_fields();
// Run through the nodes.
$nid = drush_get_option('nid', variable_get('os_files_last_nid', 0));
$batch = drush_get_option('batch', 250);
$query = new entityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')->propertyCondition('nid', $nid, '>=')->propertyOrderBy('nid')->range(0, $batch)->execute();
if (empty($result['node'])) {
    // All nodes were processed, delete the flag variable.
    variable_del('os_files_last_nid');
    return;
}
$nodes = node_load_multiple(array_keys($result['node']));
foreach ($nodes as $node) {
    $changed = FALSE;
    $deleted_files = 0;
    foreach ($file_fields as $file_field) {
        if (empty($node->{$file_field}[LANGUAGE_NONE])) {
            continue;
        }
        foreach ($node->{$file_field}[LANGUAGE_NONE] as $delta => $value) {