/**
  * Returns the user's billing cycle with the provided start time.
  *
  * If an existing billing cycle matches the expected start and end, it will
  * be returned. Otherwise, a new one will be created.
  *
  * @param $uid
  *   The uid of the user.
  * @param $start
  *   The unix timestamp when the billing cycle needs to start.
  * @param $save
  *   Whether to save the created billing cycle entity.
  *   Passing FALSE allows an unsaved billing cycle entity to be returned
  *   for estimation purposes.
  *
  * @return
  *   A cl_billing_cycle entity.
  */
 public function getBillingCycle($uid, $start = REQUEST_TIME, $save = TRUE)
 {
     // Make the billing cycle exactly 30 days long, so that it can be divided
     // predictably for prorating.
     // The 1 is substracted to make sure that the billing cycle ends 1s before
     // the next one starts
     $end = $start + 2592000 - 1;
     // Try to find an existing billing cycle matching our parameters.
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'cl_billing_cycle')->entityCondition('bundle', $this->name)->propertyCondition('status', 1)->propertyCondition('uid', $uid);
     if ($start != REQUEST_TIME) {
         // In case of a custom start, make sure to match the exact billing cycle.
         // Ensures that new orders get the previous billing cycle created at the
         // start of testing, while getNextBillingCycle returns the expected result.
         $query->propertyCondition('start', $start);
     }
     $result = $query->execute();
     if ($result) {
         $billing_cycle_id = key($result['cl_billing_cycle']);
         $billing_cycle = entity_load_single('cl_billing_cycle', $billing_cycle_id);
     } else {
         // No existing billing cycle found. Create a new one.
         $billing_cycle = entity_create('cl_billing_cycle', array('type' => $this->name));
         $billing_cycle->uid = $uid;
         $billing_cycle->start = $start;
         $billing_cycle->end = $end;
         $billing_cycle->status = 1;
         if ($save) {
             $billing_cycle->save();
         }
     }
     return $billing_cycle;
 }
Exemplo n.º 2
0
function quatro_preprocess_page(&$vars)
{
    // Set the page title for the "Verein" Panels Page
    if (arg(0) == 'verein' && is_numeric(arg(1))) {
        //dpm($vars);
        $nid = arg(1);
        // Search for the "Mannschaft" Node matching the argument
        $query = new EntityFieldQuery();
        $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'mannschaft')->propertyCondition('status', NODE_PUBLISHED)->propertyCondition('nid', $nid, '=')->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        // Set the page title to the Node Title of the "Mannschaft" Node
        if (isset($result['node'])) {
            $node_ids = array_keys($result['node']);
            $node_id = $node_ids[0];
            $node = node_load($node_id);
            drupal_set_title($node->title);
        }
    }
    // Set the page title for the "Spieler" Panels Page
    if (arg(0) == 'spieler' && is_numeric(arg(1))) {
        //dpm($vars);
        $nid = arg(1);
        // Search for the ticket matching the Rabattcode
        $query = new EntityFieldQuery();
        $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'spieler')->propertyCondition('status', NODE_PUBLISHED)->propertyCondition('nid', $nid, '=')->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        // If a ticket was found, set the price field to the ticket price
        if (isset($result['node'])) {
            $node_ids = array_keys($result['node']);
            $node_id = $node_ids[0];
            $node = node_load($node_id);
            drupal_set_title($node->title);
        }
    }
}
Exemplo n.º 3
0
 private function loadConvenzioneFromTarga($ar_data)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'parkauto')->propertyCondition('status', 1)->fieldCondition('field_p_targa_auto_cliente', 'value', trim($ar_data['rc_targa_auto_cliente']), '=')->fieldCondition('field_p_sito_parking', 'nid', trim($ar_data['sito']))->range(0, 1)->addMetaData('account', user_load(1));
     $qryres = $query->execute();
     return $qryres;
 }
Exemplo n.º 4
0
 public function load_data($ar_data = null)
 {
     $result = array();
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'sito_parcheggio')->propertyCondition('status', 1)->addMetaData('account', user_load(1));
     $qryres = $query->execute();
     if (isset($qryres['node'])) {
         $items_nids = array_keys($qryres['node']);
         $items = entity_load('node', $items_nids);
         $first = true;
         foreach ($items as $nodo => $elem) {
             if ($first) {
                 $result[0]['codice'] = 0;
                 $result[0]['descrizione'] = 'Selezionare un parcheggio';
                 $first = false;
             }
             $result[$nodo]['codice'] = $elem->field_sp_codice[LANGUAGE_NONE][0]['value'];
             $result[$nodo]['descrizione'] = $elem->title;
             $result[$nodo]['indirizzo']['indirizzo'] = $elem->field_sp_indirizzo[LANGUAGE_NONE][0]['thoroughfare'];
             $result[$nodo]['indirizzo']['cap'] = $elem->field_sp_indirizzo[LANGUAGE_NONE][0]['postal_code'];
             $result[$nodo]['indirizzo']['localita'] = $elem->field_sp_indirizzo[LANGUAGE_NONE][0]['locality'];
             $result[$nodo]['indirizzo']['provincia'] = $elem->field_sp_indirizzo[LANGUAGE_NONE][0]['administrative_area'];
         }
     }
     $this->ar_lista = $result;
 }
 protected function queryLoad($ids)
 {
     $multifields = multifield_get_fields();
     foreach (array_keys($multifields) as $field_name) {
         $query = new EntityFieldQuery();
         if ($ids) {
             $query->fieldCondition($field_name, 'id', $ids, 'IN');
         } else {
             $query->fieldCondition($field_name, 'id', 0, '>');
         }
         if ($results = $query->execute()) {
             $pseudo_entities = array();
             $field = field_info_field($field_name);
             foreach ($results as $entity_type => $entities) {
                 // Simply doing an entity load on the entities with multifield values
                 // will cause the cacheSet() from multifield_field_load() to get
                 // invoked.
                 $entities = entity_load($entity_type, array_keys($entities));
                 foreach ($entities as $entity) {
                     if ($items = field_get_items($entity_type, $entity, $field_name)) {
                         foreach ($items as $item) {
                             $pseudo_entities[$item['id']] = _multifield_field_item_to_entity($field['type'], $item);
                         }
                     }
                 }
             }
             $this->cacheSet($pseudo_entities);
         }
     }
     return array_intersect_key($this->entityCache, drupal_map_assoc($ids, $ids));
 }
Exemplo n.º 6
0
/**
 * Allows overriding of the selected entity list for cloning.
 *
 * @param $ids
 *   An array of entity ids currently selected.
 * @return
 *   An array of entity ids after processing.
 */
function hook_get_group_content_ids_alter(&$ids)
{
    // array of content types to remove from cloning
    $content_types = array('cle_submission');
    // pull out nodes for testing as this could have other entities
    foreach ($ids as $key => $id) {
        if ($id['entity_type'] == 'node') {
            $id_key[$key] = $id['etid'];
        }
    }
    // Don't allow submissions to be cloned
    $query = new EntityFieldQuery();
    // select all nodes
    $query->entityCondition('entity_type', 'node')->entityCondition('bundle', $content_types, 'IN')->propertyCondition('nid', $id_key, 'IN')->addMetaData('account', user_load(1));
    $result = $query->execute();
    // verify that we have results
    if (isset($result['node'])) {
        // test the node array against the nodes in the clone array
        foreach ($result['node'] as $node) {
            // if the node selected is in the array, remove it from the ids
            if (in_array($node->nid, $id_key)) {
                unset($ids[array_search($node->nid, $id_key)]);
            }
        }
    }
}
function community_features_user_feed()
{
    $uid = $GLOBALS['user']->uid;
    $flags = flag_get_user_flags('user', null, $uid);
    //dpm($flags);
    //unset($flags['cf_follow_user']);
    if (isset($flags['cf_follow_user'])) {
        //dpm($flags['cf_follow_user']);
        foreach ($flags['cf_follow_user'] as $flag) {
            //dpm($flag);
            $author_uid = $flag->entity_id;
            $query = new EntityFieldQuery();
            $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'cm_show')->propertyCondition('status', 1)->propertyCondition('uid', $author_uid)->propertyOrderBy('created', 'DESC')->fieldCondition('field_show_vod', 'fid', 'NULL', '!=')->pager(5);
            //->range(0, 100);
            $result = $query->execute();
            if (isset($result['node'])) {
                $nids = array_keys($result['node']);
                $nodes = entity_load('node', $nids);
                foreach ($nodes as $node) {
                    $items[$node->nid] = array('node' => $node);
                }
            }
        }
        $build['pager'] = array('#theme' => 'pager', '#weight' => 5);
        //dpm($items);
        // Send data to TPL.
        return theme('cf_user_feed_all', array('content' => isset($items) ? $items : '', 'pager' => $build['pager']));
    } else {
        return '<br/> You are currently not following any users. Please follow some users and their videos will appear here.';
    }
}
Exemplo n.º 8
0
 /**
  * Get the entity ID.
  *
  * @param $entity_type
  *   'node', 'user', etc.
  * @param $title
  *   Title of the entity.
  * @param $bundle
  *   Optional; The bundle of the entity.
  *
  * @return mixed
  *   The entity ID (in case of $return).
  */
 public static function getEntityID($entity_type, $title, $bundle = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', $entity_type);
     if ($entity_type == 'node') {
         $query->propertyCondition('title', $title);
     } else {
         if ($entity_type == 'file') {
             $query->propertyCondition('filename', $title);
         }
     }
     if ($bundle) {
         $query->entityCondition('bundle', $bundle);
     }
     $result = $query->execute();
     // Currently only support file and node.
     if ($entity_type == 'node') {
         $identifier = 'nid';
     } else {
         if ($entity_type == 'file') {
             $identifier = 'fid';
         }
     }
     if (empty($result[$entity_type])) {
         return NULL;
     }
     return reset($result[$entity_type])->{$identifier};
 }
/**
 * Lets modules prevent the deletion of a particular product.
 *
 * Before a product can be deleted, other modules are given the chance to say
 * whether or not the action should be allowed. Modules implementing this hook
 * can check for reference data or any other reason to prevent a product from
 * being deleted and return FALSE to prevent the action.
 *
 * This is an API level hook, so implementations should not display any messages
 * to the user (although logging to the watchdog is fine).
 *
 * @param $product
 *   The product to be deleted.
 *
 * @return
 *   TRUE or FALSE indicating whether or not the given product can be deleted.
 *
 * @see commerce_product_reference_commerce_product_can_delete()
 */
function hook_commerce_product_can_delete($product)
{
    // Use EntityFieldQuery to look for line items referencing this product and do
    // not allow the delete to occur if one exists.
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'commerce_line_item', '=')->entityCondition('bundle', 'product', '=')->fieldCondition('product', 'product_id', $product->product_id, '=')->count();
    return $query->execute() > 0 ? FALSE : TRUE;
}
    private function scanReports () {
        $this->affected = array();

        $query = new \EntityFieldQuery();
        $query->entityCondition('entity_type', 'node');
        $query->propertyCondition('type', NODE_TYPE_REPORT);
        $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        $reportNids = isset($result['node']) ? array_keys($result['node']) : NULL;
        $reportNodes = node_load_multiple($reportNids);
        
        foreach ( $reportNodes as $node ) {
            $datasetName = get_node_field_value($node,'field_report_dataset_sysnames');
            if ( empty($datasetName) ) {
                $patient = array(
                    'info' => array(
                        'reportNodeId' => $node->nid,
                        'reportTitle' => $node->title,
                        'published' => $node->status,
                        'type' => $node->type,
                        'datasetName' => $datasetName
                    ),
                    'notes' => 'Dataset field is empty.'
                );

                $this->attachTreatment($patient);
                $this->affected[] = $patient;
                continue;
            }

            // lookup dataset
            $datasourceQuery = new \EntityFieldQuery();
            $datasourceQuery->entityCondition('entity_type', 'node');
            $datasourceQuery->propertyCondition('type', NODE_TYPE_DATASET);
            $datasourceQuery->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
            $datasourceQuery->fieldCondition('field_dataset_sysname', 'value', $datasetName);
            $datasourceQuery->fieldCondition('field_dataset_datasource', 'value', get_node_field_value($node,'field_report_datasource'));
            $datasourceEntities = $datasourceQuery->execute();
            $datasource_nids = isset($datasourceEntities['node']) ? array_keys($datasourceEntities['node']) : NULL;

            if (count($datasource_nids) != 1) {
                $patient = array(
                    'info' => array(
                        'reportNodeId' => $node->nid,
                        'reportTitle' => $node->title,
                        'published' => $node->status,
                        'type' => $node->type,
                        'datasetName' => $datasetName
                    ),
                    'notes' => 'Dataset does not exist.'
                );

                $this->attachTreatment($patient);
                $this->affected[] = $patient;
                continue;
            }
        }
    }
/**
 * @param string $calendarId
 * @return int
 */
function cob_calendar_node_id($calendarId)
{
    $query = new EntityFieldQuery();
    $query->fieldCondition('field_google_calendar_id', 'value', $calendarId, '=');
    $result = $query->execute();
    if (count($result)) {
        return array_keys($result['node'])[0];
    }
}
Exemplo n.º 12
0
 /**
  * @param scalar $puid is permanent unique id value and
  */
 public function drupalUserFromPuid($puid)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'user')->fieldCondition('ldap_user_puid_sid', 'value', $this->sid, '=')->fieldCondition('ldap_user_puid', 'value', $puid, '=')->fieldCondition('ldap_user_puid_property', 'value', $this->unique_persistent_attr, '=')->addMetaData('account', user_load(1));
     // run the query as user 1
     $result = $query->execute();
     if (isset($result['user'])) {
         $user = entity_load('user', array_keys($result['user']));
     }
 }
Exemplo n.º 13
0
function wyc_get_uid_by_wycnumber($no)
{
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'user')->fieldCondition('field_wyc_number', 'value', $no);
    $result = $query->execute();
    if (!empty($result['user'])) {
        return key($result['user']);
    }
    return 0;
}
Exemplo n.º 14
0
/**
 *
 */
function _query_products_nids()
{
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->entityCondition('bundle', array('card', 'software', 'chassis'))->propertyCondition('status', 1);
    $result = $query->execute();
    $nids = NULL;
    if (isset($result['node'])) {
        $nids = array_keys($result['node']);
    }
    return $nids;
}
Exemplo n.º 15
0
function get_nodes_by_reference($bundle, $field, $nid, $view_mode)
{
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->entityCondition('bundle', $bundle)->propertyCondition('status', NODE_PUBLISHED)->fieldCondition($field, 'target_id', $nid, '=')->addMetaData('account', user_load(1));
    $result = $query->execute();
    if (isset($result['node'])) {
        $nids = array_keys($result['node']);
        $nodes = entity_load('node', $nids);
        return node_view_multiple($nodes, $view_mode);
    }
    return FALSE;
}
Exemplo n.º 16
0
 public static function get_nid_from_data($id_label)
 {
     $result = array();
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'listino_base')->propertyCondition('status', 1)->fieldCondition('field_lb_classe_servizio', 'value', ucfirst($id_label))->addMetaData('account', user_load(1));
     $qryres = $query->execute();
     if (isset($qryres['node'])) {
         $items_nids = array_keys($qryres['node']);
         $result = $items_nids[0];
     }
     return $result;
 }
Exemplo n.º 17
0
/**
 * @return array,
 */
function _node_title_search($title = NULL, $brand_tid = NULL, $depend_chassis)
{
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->entityCondition('bundle', array('card', 'chassis', 'software'))->propertyCondition('title', $title)->propertyCondition('status', NODE_PUBLISHED);
    $result = $query->execute();
    $nid_array = NULL;
    if (isset($result['node'])) {
        if (count($result['node']) > 0) {
            $nid_array = array_keys($result['node']);
        }
    }
    return $nid_array;
}
Exemplo n.º 18
0
 /**
  * {@inheritdoc}
  *
  * @todo Update to new query API.
  */
 public function match(ContactInterface $contact, $property = 'value')
 {
     $results = array();
     $field_item = 'value';
     $field = field_get_items('crm_core_contact', $contact, $rule->field_name);
     $needle = isset($field[0]['value']) ? $field[0]['value'] : '';
     if (!empty($needle)) {
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'crm_core_contact')->entityCondition('bundle', $contact->type)->entityCondition('entity_id', $contact->contact_id, '<>')->fieldCondition($rule->field_name, $field_item, $needle, $rule->operator);
         $results = $query->execute();
     }
     return isset($results['crm_core_contact']) ? array_keys($results['crm_core_contact']) : $results;
 }
function entity_reference_users($nid)
{
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'user');
    $result = $query->execute();
    foreach ($result['user'] as $doctors) {
        $doctor = user_load($doctors->uid);
        if ($doctor->field_speciality['und'][0]['target_id'] == $nid) {
            $doctor_arr[$doctors->uid] = array('name' => $doctor->name, 'designation' => $doctor->field_designation['und'][0]['value'], 'profile_link' => $doctor->field_view_profile_link['und'][0]['value']);
        }
    }
    return $doctor_arr;
}
Exemplo n.º 20
0
 private function load_data()
 {
     $result = array();
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'tipo_cliente')->propertyCondition('status', 1)->addMetaData('account', user_load(1));
     $qryres = $query->execute();
     if (isset($qryres['node'])) {
         $items_nids = array_keys($qryres['node']);
         $items = entity_load('node', $items_nids);
         foreach ($items as $nodo => $elem) {
             $result[$nodo] = $elem->field_tpc_descrizione[LANGUAGE_NONE][0]['value'];
         }
     }
     return $result;
 }
 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'article')->propertyCondition('status', 1)->propertyOrderBy('created', 'DESC')->range(0, $bean->settings['records_shown']);
     $result = $query->execute();
     if (empty($result)) {
         $content['nodes'] = array();
     } else {
         foreach ($result['node'] as $node) {
             $node = node_load($node->nid, $node->vid);
             $content['nodes'][$node->nid] = node_view($node, $bean->settings['node_view_mode']);
         }
     }
     $content['more_link']['#markup'] = theme('article_listing_more_link', array('text' => $bean->more_link['text'], 'path' => $bean->more_link['path']));
     return $content;
 }
/**
 * Returns the initial usage for a license's usage group.
 *
 * Initial usage is registered when the license is first activated.
 * The first hook to provide initial usage wins. If no hooks are found,
 * the 'initial_quantity' key on group info.
 *
 * Right now initial usage is only registered for gauge usage groups.
 *
 * @param $license
 *   The license entity.
 * @param $group_name
 *   The name of the usage group, as defined in $license->usageGroups().
 *
 * @return
 *   The numeric quantity.
 */
function hook_commerce_license_billing_initial_usage($license, $group_name)
{
    if ($group_name == 'environments') {
        // In this example the initial usage is stored on the line item because
        // the customer selected the desired number of environments during checkout.
        $query = new EntityFieldQuery();
        $query->entityCondition('entity_type', 'commerce_line_item')->entityCondition('bundle', 'recurring', '<>')->fieldCondition('commerce_license', 'target_id', $license->license_id);
        $result = $query->execute();
        if ($result) {
            $line_item_id = key($result['commerce_line_item']);
            $line_item = commerce_line_item_load($line_item_id);
            $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
            return $line_item_wrapper->field_user_environments->value();
        }
    }
}
 /**
  * Displays the bean.
  */
 public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
 {
     // Retrieve the terms from the loaded entity.
     $active_entity = bean_tax_active_entity_array();
     // Check for cached content on this block.
     $cache_name = 'bean_tax:listing:' . $bean->delta . ':' . $active_entity['type'] . ':' . $active_entity['ids'][0];
     if ($cache = cache_get($cache_name)) {
         $content = $cache->data;
     } else {
         // We need to make sure that the bean is configured correctly.
         if ($active_entity['type'] != 'bean' && !empty($bean->filters['vocabulary']) && (isset($active_entity['terms']) && count($active_entity['terms']))) {
             // Reformat vocabulary list from machine names to vocabulary vids.
             $vids = array();
             foreach ($bean->filters['vocabulary'] as $vm) {
                 $query = new EntityFieldQuery();
                 $result = $query->entityCondition('entity_type', 'taxonomy_vocabulary');
                 $query->propertyCondition('machine_name', $vm);
                 global $language;
                 if ($language->language != NULL && db_field_exists('taxonomy_vocabulary', 'language')) {
                     $query->propertyCondition('language', $language->language);
                 }
                 $result = $query->execute();
                 foreach ($result['taxonomy_vocabulary'] as $vocabulary) {
                     $vids[$vocabulary->vid] = $vocabulary->vid;
                 }
             }
             $i = 0;
             $content['terms'] = array();
             // Parse terms from correct vocabularies, limit list to X results.
             foreach ($active_entity['terms'] as $term) {
                 $term = entity_load_single('taxonomy_term', $term->tid);
                 if (in_array($term->vid, $vids) && $i < $bean->settings['records_shown']) {
                     $content['terms'][$term->tid] = entity_view('taxonomy_term', array($term->tid => $term), $bean->settings['term_view_mode']);
                     $i++;
                 }
             }
             cache_set($cache_name, $content, 'cache', time() + 60 * $bean->settings['cache_duration']);
         } elseif (isset($active_entity['type']) && $active_entity['type'] == 'bean' && $bean->bid === $active_entity['object']->bid) {
             $content['#markup'] = '';
         } elseif ($bean->settings['hide_empty'] || !$active_entity['object']) {
             return;
         } else {
             $content['#markup'] = t('No terms.');
         }
     }
     return $content;
 }
 /**
  * Implements EntityReferenceHandler::getReferencableEntities().
  */
 public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
 {
     $gid = oa_core_get_space_context();
     $space = node_load($gid);
     $type = variable_get_value('oa_worktracker_assigned_to_users');
     if ($type === OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS && !module_exists('oa_subspaces')) {
         $type = OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS;
     }
     $uids = array();
     switch ($type) {
         case OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS:
             $uids = og_subgroups_get_users_group('node', $space);
             $uids = $uids['user'];
             $inherited = _og_subgroups_get_inherited_users('node', $gid);
             foreach ($inherited as $inherited_uid => $data) {
                 $uids[] = $inherited_uid;
             }
             break;
         case OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS:
             $query = new EntityFieldQuery();
             $query->entityCondition('entity_type', 'og_membership')->propertyCondition('group_type', 'node', '=')->propertyCondition('gid', $gid, '=')->propertyCondition('entity_type', 'user', '=')->propertyCondition('state', OG_STATE_ACTIVE, '=');
             $result = $query->execute();
             if (!empty($result['og_membership'])) {
                 $og_memberships = og_membership_load_multiple(array_keys($result['og_membership']));
                 foreach ($og_memberships as $og_membership) {
                     $uids[] = $og_membership->etid;
                 }
             }
             break;
         case OA_WORKTRACKER_ASSIGN_TO_ANY_USERS:
             $query = db_select('users', 'u')->fields('u', array('uid'))->condition('status', 1);
             $uids = $query->execute()->fetchCol();
             break;
     }
     $options = array('user' => array());
     if (!empty($uids)) {
         // Get the user label and make sure that the user can access the space.
         $users = user_load_multiple($uids);
         foreach ($users as $uid => $account) {
             if (node_access('view', $space, $account)) {
                 $options['user'][$uid] = check_plain($this->getLabel($account));
             }
         }
         asort($options['user']);
     }
     return $options;
 }
/**
 * Get team member from Drupal
 *
 * @param string $url
 * @return integer $id
 */
function _ten_thousand_feet_get_team_member($uid)
{
    $query = new EntityFieldQuery();
    try {
        # Select results for node, if they exist
        $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'team_member')->fieldCondition('field_team_member_id', 'value', $uid, '=')->propertyCondition('status', NODE_PUBLISHED);
        $result = $query->execute();
        # If the project is found
        if (!empty($result['node'])) {
            $node = node_load(array_shift(array_keys($result['node'])));
        }
        return $node;
    } catch (Exception $e) {
        # Log the exception to watchdog.
        watchdog_exception('database', $e);
    }
}
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  *
  * Specify files in file fields by their filename.
  */
 public function expand($values)
 {
     $return = array();
     foreach ($values as $value) {
         $query = new \EntityFieldQuery();
         $query->entityCondition('entity_type', 'file')->propertyCondition('filename', $value)->propertyOrderBy('timestamp', 'DESC')->range(0, 1);
         $result = $query->execute();
         if (!empty($result['file'])) {
             $files = entity_load('file', array_keys($result['file']));
             $file = current($files);
             $return[$this->language][] = array('filename' => $file->filename, 'uri' => $file->uri, 'fid' => $file->fid, 'display' => 1);
         } else {
             throw new \Exception(sprintf('File with filename "%s" not found.', $value));
         }
     }
     return $return;
 }
Exemplo n.º 27
0
 function findAgent($json)
 {
     $json_array = drupal_json_decode($json);
     if (!isset($json_array['mbox']) && !isset($json_array['mbox_sha1sum']) && !isset($json_array['openid']) && (!isset($json_array['account']) && !isset($json_array['account']['homePage']) && !isset($json_array['account']['name']))) {
         return 0;
     }
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'tincan_agent');
     if (isset($json_array['objectType'])) {
         switch ($json_array['objectType']) {
             case 'Agent':
                 $query->propertyCondition('object_type', 'Agent');
                 break;
             case 'Group':
                 $query->propertyCondition('object_type', 'Group');
                 break;
         }
     } else {
         $query->propertyCondition('object_type', 'Agent');
     }
     if (isset($json_array['mbox'])) {
         $query->propertyCondition('mbox', $json_array['mbox']);
     }
     if (isset($json_array['mbox_sha1sum'])) {
         $query->propertyCondition('mbox_sha1sum', $json_array['mbox_sha1sum']);
     }
     if (isset($json_array['openid'])) {
         $query->propertyCondition('openid', $json_array['openid']);
     }
     if (isset($json_array['account'])) {
         if (isset($json_array['account']['homePage'])) {
             $query->propertyCondition('account_home_page', $json_array['account']['homePage']);
         }
         if (isset($json_array['account']['name'])) {
             $query->propertyCondition('account_name', $json_array['account']['name']);
         }
     }
     $result = $query->execute();
     if (isset($result['tincan_agent'])) {
         foreach ($result['tincan_agent'] as $key => $agent) {
             return $key;
         }
     } else {
         return 0;
     }
 }
    private function scanReportConfigs () {
        $this->affected = array();

        $query = new \EntityFieldQuery();
        $query->entityCondition('entity_type', 'node');
        $query->propertyCondition('type', NODE_TYPE_REPORT);
        $query->propertyCondition('status', NODE_PUBLISHED);
        $query->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
        $result = $query->execute();
        $reportNids = isset($result['node']) ? array_keys($result['node']) : NULL;
        $reportNodes = node_load_multiple($reportNids);
        
        foreach ( $reportNodes as $node ) {

            \LogHelper::log_info(t('Inspecting report @nid', array('@nid' => $node->nid)));

            $reportConfigText = get_node_field_value($node, 'field_report_conf', 0, 'value', FALSE);
            $reportConfig = isset($reportConfigText) ? json_decode($reportConfigText) : NULL;
            if (!isset($reportConfig)) {
                \LogHelper::log_info('Report configuration is EMPTY');
                continue;
            }

            // loop through filters
            if (!empty($reportConfig->model->filters)) {
                foreach ($reportConfig->model->filters as $key => $value) {
                    $result = $this->detectInvalidFilter($value);
                    if ($result) {
                        $patient = array(
                            'info' => array(
                                'reportNodeId' => $node->nid,
                                'reportTitle' => $node->title,
                                'filter' => $value,
                                'published' => $node->status,
                                'configPath' => 'model/filters'
                            ),
                            'notes' => $result
                        );
                        $this->attachTreatment($patient);
                        $this->affected[] = $patient;
                    }
                }
            }
        }
    }
Exemplo n.º 29
0
 public function load_data($ar_data = null)
 {
     $result = array();
     $dt_rif = $ar_data['dt_riferimento'];
     if (!$dt_rif) {
         $dt_rif = new DateTime();
     }
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'tipo_automezzo')->propertyCondition('status', 1)->fieldCondition('field_tpa_data_validita_finale', 'value', $dt_rif->format("Y-m-d"), '>=')->addMetaData('account', user_load(1));
     $qryres = $query->execute();
     if (isset($qryres['node'])) {
         $items_nids = array_keys($qryres['node']);
         $items = entity_load('node', $items_nids);
         foreach ($items as $nodo => $elem) {
             $result[$nodo] = $elem->field_tpa_tipo[LANGUAGE_NONE][0]['value'];
         }
     }
     $this->ar_lista = $result;
 }
Exemplo n.º 30
0
 public function actionDeleteAll()
 {
     if (isset($_POST['date'])) {
         $date = $_POST['date'];
         $img_file = PC . '/epaper2/assets/article_img/' . $date;
         $result = "";
         if (!is_dir($img_file)) {
             header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
         } else {
             $dh = opendir($img_file);
             while ($file = readdir($dh)) {
                 if ($file != "." && $file != "..") {
                     $fullpath = $img_file . "/" . $file;
                     if (!is_dir($fullpath)) {
                         unlink($fullpath);
                     } else {
                         deldir($fullpath);
                     }
                 }
             }
             closedir($dh);
             //删除当前文件夹:
             if (rmdir($img_file)) {
                 // Article::model()->deleteAll('create_time=:create_time',array(':create_time'=>$date));
                 Coor::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 PageCount::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 Pname::model()->deleteAll('create_time=:create_time', array(':create_time' => $date));
                 $query = new EntityFieldQuery();
                 $query->entityCondition('entity_type', 'node')->entityCondition('bundle', '_xinwen')->fieldCondition('field_riq', 'value', $date);
                 $result = $query->execute();
                 if (isset($result['node'])) {
                     $news_items_nids = array_keys($result['node']);
                     node_delete_multiple($news_items_nids);
                 }
                 header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/5");
             } else {
                 header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
             }
         }
     } else {
         header("Location: " . Yii::app()->name . "tydaily2/?q=myresult/4");
     }
 }