本文整理汇总了PHP中ctools_export_load_object函数的典型用法代码示例。如果您正苦于以下问题:PHP ctools_export_load_object函数的具体用法?PHP ctools_export_load_object怎么用?PHP ctools_export_load_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ctools_export_load_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFromDb
protected function loadFromDb()
{
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_authorization', 'names', array($this->consumerType));
// @todo, this is technically wrong, but I don't quite grok what we're doing in the non-ctools case - justintime
$server_record = array_pop($result);
// There's no ctools api call to get the reserved properties, so instead of hardcoding a list of them
// here, we just grab everything. Basically, we sacrifice a few bytes of RAM for forward-compatibility.
} else {
$select = db_select('ldap_authorization', 'ldap_authorization');
$select->fields('ldap_authorization');
$select->condition('ldap_authorization.consumer_type', $this->consumerType);
$server_record = $select->execute()->fetchObject();
}
if (!$server_record) {
$this->inDatabase = FALSE;
return FALSE;
}
foreach ($this->field_to_properties_map() as $db_field_name => $property_name) {
if (isset($server_record->{$db_field_name})) {
if (in_array($db_field_name, $this->field_to_properties_serialized())) {
$this->{$property_name} = unserialize($server_record->{$db_field_name});
} else {
$this->{$property_name} = $server_record->{$db_field_name};
}
}
}
$this->numericConsumerConfId = isset($server_record->numeric_consumer_conf_id) ? $server_record->numeric_consumer_conf_id : NULL;
$this->server = ldap_servers_get_servers($this->sid, NULL, TRUE);
return TRUE;
}
示例2: loadFromDb
protected function loadFromDb()
{
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_authorization', 'names', array($this->consumerType));
// @todo, this is technically wrong, but I don't quite grok what we're doing in the non-ctools case - justintime
$consumer_conf = array_pop($result);
// There's no ctools api call to get the reserved properties, so instead of hardcoding a list of them
// here, we just grab everything. Basically, we sacrifice a few bytes of RAM for forward-compatibility.
} else {
$select = db_select('ldap_authorization', 'ldap_authorization');
$select->fields('ldap_authorization');
$select->condition('ldap_authorization.consumer_type', $this->consumerType);
$consumer_conf = $select->execute()->fetchObject();
}
if (!$consumer_conf) {
$this->inDatabase = FALSE;
return;
}
$this->sid = $consumer_conf->sid;
$this->consumerType = $consumer_conf->consumer_type;
$this->numericConsumerConfId = isset($consumer_conf->numeric_consumer_conf_id) ? $consumer_conf->numeric_consumer_conf_id : NULL;
$this->status = $consumer_conf->status ? 1 : 0;
$this->onlyApplyToLdapAuthenticated = (bool) @$consumer_conf->only_ldap_authenticated;
$this->useFirstAttrAsGroupId = (bool) @$consumer_conf->useFirstAttrAsGroupId;
$this->searchAll = (bool) @$consumer_conf->searchAll;
$this->mappings = $this->pipeListToArray($consumer_conf->mappings, FALSE);
$this->useMappingsAsFilter = (bool) @$consumer_conf->use_filter;
$this->synchToLdap = (bool) @$consumer_conf->synch_to_ldap;
$this->synchOnLogon = (bool) @$consumer_conf->synch_on_logon;
$this->regrantLdapProvisioned = (bool) @$consumer_conf->regrant_ldap_provisioned;
$this->revokeLdapProvisioned = (bool) @$consumer_conf->revoke_ldap_provisioned;
$this->createConsumers = (bool) @$consumer_conf->create_consumers;
$this->server = ldap_servers_get_servers($this->sid, NULL, TRUE);
}
示例3: getLdapServerObjects
/**
* @param $type = 'all', 'enabled'
*/
public static function getLdapServerObjects($sid = NULL, $type = NULL, $class = 'LdapServer')
{
$servers = array();
if (module_exists('ctools')) {
ctools_include('export');
$select = ctools_export_load_object('ldap_servers', 'all');
} else {
try {
$select = db_select('ldap_servers', 'ldap_servers')->fields('ldap_servers')->execute();
} catch (Exception $e) {
drupal_set_message(t('server index query failed. Message = %message, query= %query', array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error');
return array();
}
}
foreach ($select as $result) {
$servers[$result->sid] = $class == 'LdapServer' ? new LdapServer($result->sid) : new LdapServerAdmin($result->sid);
}
return $servers;
}
示例4: getLdapQueryObjects
/**
* @param string $sid either 'all' or the ldap server sid
* @param $type = 'all', 'enabled'
*/
public static function getLdapQueryObjects($sid = 'all', $type = 'enabled', $class = 'LdapQuery')
{
$queries = array();
if (module_exists('ctools')) {
ctools_include('export');
$select = ctools_export_load_object('ldap_query', 'all');
} else {
try {
$select = db_select('ldap_query', 'ldap_query')->fields('ldap_query')->execute();
} catch (Exception $e) {
drupal_set_message(t('query index query failed. Message = %message, query= %query', array('%message' => $e->getMessage(), '%query' => $e->query_string)), 'error');
return array();
}
}
foreach ($select as $result) {
$query = $class == 'LdapQuery' ? new LdapQuery($result->qid) : new LdapQueryAdmin($result->qid);
if (($sid == 'all' || $query->sid == $sid) && (!$type || $type == 'all' || ($query->status = 1 && $type == 'enabled'))) {
$queries[$result->qid] = $query;
}
}
return $queries;
}
示例5: __construct
/**
* Constructor Method
*/
function __construct($qid)
{
if (!is_scalar($qid)) {
return;
}
$query_records = array();
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_query', 'names', array($qid));
if (isset($result[$qid])) {
$query_record = $result[$qid];
foreach ($query_record as $property_name => $value) {
$this->{$property_name} = $value;
}
}
} else {
$select = db_select('ldap_query')->fields('ldap_query')->condition('ldap_query.qid', $qid)->execute();
foreach ($select as $record) {
$query_records[$record->qid] = $record;
}
if (!isset($query_records[$qid])) {
$this->inDatabase = FALSE;
return;
}
$query_record = $query_records[$qid];
foreach ($this->fields() as $field_id => $field) {
if (isset($query_record->{$field_id})) {
$this->{$field['property_name']} = @$query_record->{$field_id};
}
}
}
// special properties that don't map directly from storage and defaults
$this->inDatabase = TRUE;
$this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
$this->baseDn = $this->linesToArray($this->base_dn_str);
$this->attributes = $this->attributes_str ? $this->csvToArray($this->attributes_str, TRUE) : array();
}
示例6: _edit_form
/**
* Helper function with element for the settings editing form.
*/
function _edit_form(&$form, &$form_state)
{
$heartbeatStreamConfig = $form_state['item'];
_heartbeat_stream_config_unpack($heartbeatStreamConfig);
$cloning = $form_state['form type'] == 'clone';
$form['path'] = array('#type' => 'hidden', '#title' => t('Path'), '#default_value' => $heartbeatStreamConfig->path);
$form['module'] = array('#type' => 'hidden', '#title' => t('Module'), '#default_value' => $heartbeatStreamConfig->module);
$heartbeatStreamConfig->real_class = empty($heartbeatStreamConfig->real_class) ? $heartbeatStreamConfig->class : $heartbeatStreamConfig->real_class;
if ($cloning) {
$heartbeatStreamConfig->real_class = preg_replace("/clone_of_/", "", $heartbeatStreamConfig->class);
}
$form['real_class'] = array('#type' => 'hidden', '#title' => t('Real class'), '#default_value' => $heartbeatStreamConfig->real_class, '#description' => t('Real class to load for clones'));
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => isset($heartbeatStreamConfig->title) ? $heartbeatStreamConfig->title : '', '#description' => t('Used in page titles'));
if ($cloning) {
$form['title']['#default_value'] = t('Clone of @title', array('@title' => $heartbeatStreamConfig->title));
}
$form['settings'] = array('#type' => 'vertical_tabs', '#tree' => TRUE, '#weight' => 50);
// Permissions, allow/deny message templates.
$form['settings']['fs_perms'] = array('#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => FALSE, '#title' => t('Permissions'));
// Fetch message objects.
ctools_include('export');
$options = array();
foreach (ctools_export_load_object('heartbeat_messages', 'all') as $template) {
$options[$template->message_id] = $template->description;
}
$form['settings']['fs_perms']['messages_denied'] = array('#type' => 'checkboxes', '#title' => t('Choose message types you want to deny from display'), '#multiple' => TRUE, '#default_value' => $heartbeatStreamConfig->messages_denied, '#options' => $options);
// Stream settings.
$form['settings']['fs_settings'] = array('#type' => 'fieldset', '#title' => t('Settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
// Configuration can be simple for some heartbeat requirements and thus exceptions.
if (in_array($heartbeatStreamConfig->class, array('singleactivity', 'viewsactivity'))) {
$form['settings']['fs_settings']['stream_path'] = array('#type' => 'textfield', '#default_value' => '', '#title' => t('Path to the page stream'), '#disabled' => TRUE);
$form['settings']['fs_settings']['stream_profile_path'] = array('#type' => 'textfield', '#default_value' => '', '#title' => t('Path to the user stream'), '#disabled' => TRUE);
} else {
$form['settings']['fs_settings']['skip_active_user'] = array('#title' => t('Skip the active user'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->skip_active_user);
$form['settings']['fs_settings']['show_message_times'] = array('#title' => t('Show the time of action in message displays'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->show_message_times);
$form['settings']['fs_settings']['show_message_times_grouped'] = array('#title' => t('Show the time of action with messages are grouped together'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->show_message_times_grouped);
$form['settings']['fs_settings']['poll_messages'] = array('#type' => 'select', '#options' => array(0 => t('No'), 10 => t('Every 10 seconds'), 20 => t('Every 20 seconds'), 30 => t('Every 30 seconds'), 45 => t('Every 45 seconds'), 60 => t('Every minute')), '#title' => t('Poll every x seconds for newer messages to prepend the stream.'), '#default_value' => $heartbeatStreamConfig->poll_messages);
$form['settings']['fs_settings']['poll_messages_type'] = array('#type' => 'select', '#options' => array(0 => t('Automatically prepend the new messages to the stream'), 1 => t('Prepend new messages to the stream after clicking "X new messages"')), '#title' => t('New messages notification type'), '#default_value' => $heartbeatStreamConfig->poll_messages_type);
$form['settings']['fs_settings']['num_load_max'] = array('#title' => t('Fetch a maximum of logged messages '), '#type' => 'textfield', '#size' => 20, '#description' => t('Heartbeat loads a maximum number of activity messages to keep a final number.
This number has to be bigger than the number of max items in blocks and pages. This is needed because
streams can have messages that are denied, grouped or inhibited by permission. In
order to make sure we have enough messages for display and to keep the performance to a high level, this
odd way is needed.'), '#default_value' => $heartbeatStreamConfig->num_load_max);
if (!empty($form_state['values']['settings']['grouping_seconds'])) {
$value = $form_state['values']['settings']['grouping_seconds'];
} elseif (isset($heartbeatStreamConfig->grouping_seconds)) {
$value = $heartbeatStreamConfig->grouping_seconds;
} else {
$value = variable_get('heartbeat_activity_grouping_seconds', 7200);
}
$form['settings']['fs_settings']['grouping_seconds'] = array('#title' => t('Maximum gap (in seconds)'), '#type' => 'select', '#options' => array(300 => t('5 minutes'), 600 => t('10 minutes'), 1200 => t('20 minutes'), 1800 => t('30 minutes'), 3600 => t('1 hour'), 7200 => t('2 hours'), 14400 => t('4 hours'), 86400 => t('24 hours')), '#default_value' => $value, '#description' => t('Maximum gap for the same activity to be grouped together and before an identical activity can be logged again'));
// Blocks settings.
$form['settings']['fs_blocks'] = array('#type' => 'fieldset', '#title' => t('Blocks'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['settings']['fs_blocks']['has_block'] = array('#title' => t('Enable block'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->has_block, '#attributes' => array());
if ($heartbeatStreamConfig->class == 'singleactivity') {
$form['settings']['fs_blocks']['has_block']['#attributes'] = array('readlonly' => 'readonly');
}
$form['settings']['fs_blocks']['block_items_max'] = array('#title' => t('Maximum items in the @name blocks', array('@name' => $heartbeatStreamConfig->name)), '#type' => 'textfield', '#size' => 20, '#default_value' => $heartbeatStreamConfig->block_items_max);
$options = array(0 => t('No more link'), 1 => t('Display "full list" link in block display'), 2 => t('Display an ajax-driven older messages link'));
$form['settings']['fs_blocks']['block_show_pager'] = array('#title' => t('Show "older messages" link in block display'), '#type' => 'radios', '#options' => $options, '#default_value' => $heartbeatStreamConfig->block_show_pager);
// Get the view modes.
$entity_info = entity_get_info('heartbeat_activity');
$view_modes = array('default' => t('Default'));
foreach ($entity_info['view modes'] as $key => $view_mode) {
$view_modes[$key] = $view_mode['label'];
}
$form['settings']['fs_blocks']['block_view_mode'] = array('#type' => 'select', '#title' => t('View mode'), '#options' => $view_modes, '#default_value' => isset($heartbeatStreamConfig->block_view_mode) ? $heartbeatStreamConfig->block_view_mode : 'default');
// Page settings.
$form['settings']['fs_pages'] = array('#type' => 'fieldset', '#title' => t('Pages'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['settings']['fs_pages']['stream_path'] = array('#title' => t('Path to the stream page'), '#type' => 'textfield', '#default_value' => $cloning ? '' : $heartbeatStreamConfig->stream_path, '#description' => t('Leave empty to disable the page.'));
$form['settings']['fs_pages']['stream_profile_path'] = array('#title' => t('Path to the user profile stream page'), '#type' => 'textfield', '#default_value' => $cloning ? '' : $heartbeatStreamConfig->stream_profile_path, '#description' => t('Leave empty to disable the user page at user/%user/PATH.'));
$form['settings']['fs_pages']['page_items_max'] = array('#title' => t('Maximum items in the @name pages', array('@name' => $heartbeatStreamConfig->name)), '#type' => 'textfield', '#size' => 20, '#default_value' => $heartbeatStreamConfig->page_items_max);
$form['settings']['fs_pages']['page_show_pager'] = array('#title' => t('Display "older messages" link in page displays'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->page_show_pager);
$form['settings']['fs_pages']['page_pager_ajax'] = array('#title' => t('Display "older messages" link in page displays with Ajax'), '#type' => 'checkbox', '#default_value' => $heartbeatStreamConfig->page_pager_ajax);
$form['settings']['fs_pages']['page_view_mode'] = array('#type' => 'select', '#title' => t('View mode'), '#options' => $view_modes, '#default_value' => isset($heartbeatStreamConfig->page_view_mode) ? $heartbeatStreamConfig->page_view_mode : 'default');
$form['settings']['fs_pages']['exclude_og'] = array('#type' => 'checkbox', '#title' => t('Exclude messages within Organic Group context.'), '#description' => t('The same setting exists for blocks and content panes but at instance level.'), '#default_value' => isset($heartbeatStreamConfig->exclude_og) ? $heartbeatStreamConfig->exclude_og : 0);
}
// Let other contribs save in the variables data.
$form['variables'] = array('#tree' => TRUE);
}
示例7: get_default_panelizer_objects
/**
* Get the default panelizers for the given bundle.
*/
public function get_default_panelizer_objects($bundle)
{
if (strpos($bundle, '.') !== FALSE) {
list($bundle, $view_mode) = explode('.', $bundle);
}
$conditions = array('panelizer_type' => $this->entity_type, 'panelizer_key' => $bundle);
if (!empty($view_mode)) {
$conditions['view_mode'] = $view_mode;
}
ctools_include('export');
return ctools_export_load_object('panelizer_defaults', 'conditions', $conditions);
}
示例8: getAllIdentifiers
/**
* Overrides Drupal\configuration\Config\Configuration::getAllIdentifiers().
*/
public static function getAllIdentifiers($component)
{
ctools_include('export');
$objects = ctools_export_load_object($component, 'all');
return drupal_map_assoc(array_keys($objects));
}
示例9: get_default_panelizer_objects
/**
* Get the default panelizers for the given bundle.
*/
public function get_default_panelizer_objects($bundle)
{
if (strpos($bundle, '.') !== FALSE) {
list($bundle, $view_mode) = explode('.', $bundle);
}
$conditions = array('panelizer_type' => $this->entity_type, 'panelizer_key' => $bundle);
// If the entity bundle is not panelized, nothing to do here.
if (!$this->is_panelized($bundle)) {
return array();
}
if (!empty($view_mode)) {
// If this view mode is not panelized, nothing to do here.
if (!$this->is_panelized($bundle . '.' . $view_mode)) {
return array();
}
$conditions['view_mode'] = $view_mode;
}
ctools_include('export');
return ctools_export_load_object('panelizer_defaults', 'conditions', $conditions);
}
示例10: loadFromDb
protected function loadFromDb()
{
if (module_exists('ctools')) {
ctools_include('export');
if ($this->consumerType) {
$result = ctools_export_load_object('ldap_authorization', 'names', array($this->consumerType));
} else {
$result = ctools_export_load_object('ldap_authorization', 'all');
}
// @todo, this is technically wrong, but I don't quite grok what we're doing in the non-ctools case - justintime
$consumer_conf = array_pop($result);
// There's no ctools api call to get the reserved properties, so instead of hardcoding a list of them
// here, we just grab everything. Basically, we sacrifice a few bytes of RAM for forward-compatibility.
if ($consumer_conf) {
foreach ($consumer_conf as $property => $value) {
$this->{$property} = $value;
}
}
} else {
$select = db_select('ldap_authorization', 'ldap_authorization');
$select->fields('ldap_authorization');
if ($this->consumerType) {
$select->condition('ldap_authorization.consumer_type', $this->consumerType);
}
$consumer_conf = $select->execute()->fetchObject();
}
if (!$consumer_conf) {
$this->inDatabase = FALSE;
return;
}
$this->sid = $consumer_conf->sid;
$this->consumerType = $consumer_conf->consumer_type;
$this->status = $consumer_conf->status ? 1 : 0;
$this->onlyApplyToLdapAuthenticated = (bool) @$consumer_conf->only_ldap_authenticated;
$this->deriveFromDn = (bool) @$consumer_conf->derive_from_dn;
$this->deriveFromDnAttr = $consumer_conf->derive_from_dn_attr;
$this->deriveFromAttr = (bool) $consumer_conf->derive_from_attr;
$this->deriveFromAttrAttr = $this->linesToArray($consumer_conf->derive_from_attr_attr);
$this->deriveFromAttrUseFirstAttr = (bool) $consumer_conf->derive_from_attr_use_first_attr;
$this->deriveFromAttrNested = (bool) $consumer_conf->derive_from_attr_nested;
$this->deriveFromEntry = (bool) @$consumer_conf->derive_from_entry;
$this->deriveFromEntryEntries = $this->linesToArray($consumer_conf->derive_from_entry_entries);
$this->deriveFromEntryEntriesAttr = $consumer_conf->derive_from_entry_entries_attr;
$this->deriveFromEntryMembershipAttr = $consumer_conf->derive_from_entry_attr;
$this->deriveFromEntryAttrMatchingUserAttr = $consumer_conf->derive_from_entry_user_ldap_attr;
$this->deriveFromEntrySearchAll = (bool) $consumer_conf->derive_from_entry_search_all;
$this->deriveFromEntryUseFirstAttr = (bool) $consumer_conf->derive_from_entry_use_first_attr;
$this->deriveFromEntryNested = $consumer_conf->derive_from_entry_nested;
$this->mappings = $this->pipeListToArray($consumer_conf->mappings, TRUE);
$this->useMappingsAsFilter = (bool) @$consumer_conf->use_filter;
$this->synchToLdap = (bool) @$consumer_conf->synch_to_ldap;
$this->synchOnLogon = (bool) @$consumer_conf->synch_on_logon;
$this->regrantLdapProvisioned = (bool) @$consumer_conf->regrant_ldap_provisioned;
$this->revokeLdapProvisioned = (bool) @$consumer_conf->revoke_ldap_provisioned;
$this->createConsumers = (bool) @$consumer_conf->create_consumers;
}
示例11: __construct
/**
* Constructor Method
*/
function __construct($sid)
{
if (!is_scalar($sid)) {
return;
}
$this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
$server_record = array();
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_servers', 'names', array($sid));
if (isset($result[$sid])) {
$server_record[$sid] = $result[$sid];
foreach ($server_record[$sid] as $property => $value) {
$this->{$property} = $value;
}
}
} else {
$select = db_select('ldap_servers')->fields('ldap_servers')->condition('ldap_servers.sid', $sid)->execute();
foreach ($select as $record) {
$server_record[$record->sid] = $record;
}
}
if (!isset($server_record[$sid])) {
$this->inDatabase = FALSE;
return;
}
$server_record = $server_record[$sid];
if ($server_record) {
$this->inDatabase = TRUE;
$this->sid = $sid;
$this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
} else {
// @todo throw error
}
$this->groupFunctionalityUnused = isset($server_record->groupFunctionalityUnused) && $server_record->groupFunctionalityUnused;
foreach ($this->field_to_properties_map() as $db_field_name => $property_name) {
$db_field_name = drupal_strtolower($db_field_name);
if (isset($server_record->{$db_field_name})) {
if ($this->groupFunctionalityUnused && in_array($db_field_name, $this->group_properties)) {
// leave group properties as default if groups are set as unused
} else {
$this->{$property_name} = $server_record->{$db_field_name};
}
}
}
$this->initDerivedProperties($server_record->bindpw);
}
示例12: __construct
/**
* Constructor Method
*/
function __construct($sid)
{
if (!is_scalar($sid)) {
return;
}
$this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
$server_record = array();
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_servers', 'names', array($sid));
if (isset($result[$sid])) {
$server_record[$sid] = $result[$sid];
foreach ($server_record[$sid] as $property => $value) {
$this->{$property} = $value;
}
}
} else {
$select = db_select('ldap_servers')->fields('ldap_servers')->condition('ldap_servers.sid', $sid)->execute();
foreach ($select as $record) {
$server_record[$record->sid] = $record;
}
}
if (!isset($server_record[$sid])) {
$this->inDatabase = FALSE;
return;
}
$server_record = $server_record[$sid];
if ($server_record) {
$this->inDatabase = TRUE;
$this->sid = $sid;
$this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
} else {
// @todo throw error
}
foreach ($this->field_to_properties_map() as $db_field_name => $property_name) {
if (isset($server_record->{$db_field_name})) {
$this->{$property_name} = $server_record->{$db_field_name};
}
}
if (is_scalar($this->basedn)) {
$this->basedn = unserialize($this->basedn);
}
if (isset($server_record->bindpw) && $server_record->bindpw != '') {
$this->bindpw = $server_record->bindpw;
$this->bindpw = ldap_servers_decrypt($this->bindpw);
}
$this->paginationEnabled = (bool) (ldap_servers_php_supports_pagination() && $this->searchPagination);
$this->queriableWithoutUserCredentials = (bool) ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT || $this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER);
$this->editPath = 'admin/config/people/ldap/servers/edit/' . $this->sid;
}
示例13: migrateType
/**
* Migrates the given type to a Feeds importer
*
* @param $type
* Content-type machine name
*/
public function migrateType($type)
{
// First attempt to retrieve an existing importer for this content type.
// If it can be retrieved, assume that it is configured correctly.
$importers = feeds_importer_load_all();
foreach ($importers as $potential_importer) {
if (!empty($potential_importer->config['content_type']) && $potential_importer->config['content_type'] === $type) {
$importer = $potential_importer;
if ($class = get_class($importer->processor)) {
$processor = array_search($class, $this->dictionary);
}
break;
}
}
// Otherwise, create a new importer from the legacy FeedAPI configuration.
if (!isset($importer)) {
if (!function_exists('feedapi_get_settings')) {
module_load_include('inc', 'feedapi2feeds', 'feedapi2feeds.legacy');
}
$settings = feedapi_get_settings($type);
// 1) Create new importer and configure it
// Generate a name for importer
$importer_name = $type;
$collision = TRUE;
$i = 0;
do {
$importer = feeds_importer($importer_name);
if (!ctools_export_load_object('feeds_importer', 'conditions', array('id' => $importer_name))) {
$collision = FALSE;
} else {
$importer_name = $type . '_' . $i++;
}
} while ($collision);
// Enable given parsers, processors w/ configuration, Feeds do not support multi parser, processor
if (!empty($settings)) {
$parser = $this->getActive($settings, 'parsers');
$processor = $this->getActive($settings, 'processors');
}
if (empty($parser) || empty($processor)) {
throw new Exception($type . ' content-type cannot migrated because there is no enabled parser or processor for it.');
break;
}
if (!isset($this->dictionary[$parser])) {
throw new Exception($parser . ' parser is not supported by this migration script, skipping ' . $type);
break;
}
if (!isset($this->dictionary[$processor])) {
throw new Exception($parser . ' processor is not supported by this migration script, skipping ' . $type);
break;
}
// Create the new importer
$this->createImporter($importer_name, $type);
$importer = feeds_importer_load($importer_name);
$importer->setPlugin($this->dictionary[$parser]);
$importer->setPlugin($this->dictionary[$processor]);
if ($settings['upload_method'] == 'upload') {
$importer->setPlugin('FeedsFileFetcher');
}
// Apply per-submodule settings
foreach (array($parser, $processor) as $module) {
$config_func = 'feedapi2feeds_configure_' . $module;
if (method_exists($this, $config_func)) {
$ret = $this->{$config_func}($settings, $importer);
if (is_array($ret) && !empty($ret)) {
$this->default_mapping = $ret;
}
} else {
$this->messages[] = t('The settings at @type for @submodule were not migrated.', array('@type' => $type, '@submodule' => $module));
}
}
// Supporting FeedAPI Mapper 1.x style mappings, only per-content-type
$custom_mapping = variable_get('feedapi_mapper_mapping_' . $type, array());
if (!empty($custom_mapping) && is_array($custom_mapping)) {
$sources = $importer->parser->getMappingSources();
$targets = $importer->processor->getMappingTargets();
foreach ($custom_mapping as $source => $target) {
$matched_source = $this->match($source, $sources);
$matched_target = $this->match($target, $targets);
if (!empty($matched_source) && !empty($matched_target)) {
$importer->processor->addMapping($matched_source, $matched_target, FALSE);
} else {
$this->messages[] = t('Failed to migrate this mapping (@type): @source - @target', array('@type' => $type, '@source' => $source, '@target' => $target));
}
}
}
// See what's abandoned
$count = db_result(db_query("SELECT COUNT(*) FROM {feedapi_mapper} m LEFT JOIN {node} n on m.nid = n.nid WHERE n.type = '%s'", $type));
if ($count > 0) {
$this->messages[] = t('@num feed nodes were detected with custom mapping (@type), these mappings were skipped, you need to manually migrate them!', array('@type' => $type, '@num' => $count));
}
// We have default mapping for these processors
if ($processor == 'feedapi_node' || $processor == 'feedapi_fast') {
foreach ($this->default_mapping as $mapping) {
$importer->processor->addMapping($mapping['source'], $mapping['target'], $mapping['unique']);
//.........这里部分代码省略.........
示例14: __construct
/**
* Constructor Method
*/
function __construct($sid)
{
if (!is_scalar($sid)) {
return;
}
$this->detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
$server_record = FALSE;
if (module_exists('ctools')) {
ctools_include('export');
$result = ctools_export_load_object('ldap_servers', 'names', array($sid));
if (isset($result[$sid])) {
$server_record = new stdClass();
foreach ($result[$sid] as $db_field_name => $value) {
$server_record->{$db_field_name} = $value;
}
}
//debug('ctools record'); debug($server_record);
} else {
$select = db_select('ldap_servers')->fields('ldap_servers')->condition('ldap_servers.sid', $sid)->execute();
foreach ($select as $record) {
if ($record->sid == $sid) {
$server_record = $record;
}
}
}
$server_record_bindpw = NULL;
if (!$server_record) {
$this->inDatabase = FALSE;
} else {
$this->inDatabase = TRUE;
$this->sid = $sid;
$this->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
foreach ($this->field_to_properties_map() as $db_field_name => $property_name) {
if (isset($server_record->{$db_field_name})) {
$this->{$property_name} = $server_record->{$db_field_name};
}
}
$server_record_bindpw = property_exists($server_record, 'bindpw') ? $server_record->bindpw : '';
}
$this->initDerivedProperties($server_record_bindpw);
}
示例15: get_default_panelizer_object
/**
* Load the named default display for the bundle.
*/
public function get_default_panelizer_object($bundle, $name)
{
if (strpos($bundle, '.') !== FALSE) {
list($bundle, $view_mode) = explode('.', $bundle);
} else {
$view_mode = 'page_manager';
}
// If the name is not in the format of entitytype:bundle:name which is
// the machine name used, split that out automatically.
if (strpos($name, ':') === FALSE) {
$name = implode(':', array($this->entity_type, $bundle, 'default'));
// This is the default view mode and older defaults won't have this,
// so we don't enforce it.
if ($view_mode != 'page_manager') {
$name .= ':' . $view_mode;
}
}
ctools_include('export');
$panelizer = ctools_export_load_object('panelizer_defaults', 'names', array($name));
return reset($panelizer);
}