summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc49
1 files changed, 49 insertions, 0 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
new file mode 100644
index 0000000..2a7b610
--- /dev/null
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * @file
+ * Base sort handler for a ldap attributes
+ */
+class ldap_views_handler_sort_attribute extends ldap_views_handler_sort {
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['attribute_name'] = array('default' => '');
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+/*
+ $current_display = $this->view->display[$this->view->current_display];
+ $did = isset($current_display->display_options['query']['options']['did']) ? $current_display->display_options['query']['options']['did']
+ : $current_display->handler->default_display->display->display_options['query']['options']['did'];
+*/
+ $ldap_data = new LdapQuery(ldap_views_get_qid($this->view)); //ldap_data_load($did);
+ if (empty($ldap_data)) {
+ $form['attribute_name'] = array(
+ '#markup' => 'You must select a valid LDAP search (Advanced::Query settings)',
+ );
+ return;
+ }
+
+ parent::options_form($form, $form_state);
+ $options = array();
+ foreach ($ldap_data->attributes as $attribute) {
+ $options[$attribute] = $attribute;
+ }
+ $form['attribute_name'] = array(
+ '#type' => 'select',
+ '#title' => t('Attribute name'),
+ '#description' => t('The attribute name from LDAP response'),
+ '#options' => $options,
+ '#default_value' => $this->options['attribute_name'],
+ '#required' => TRUE,
+ );
+ }
+
+ /**
+ * Called to add the sort to a query.
+ */
+ function query() {
+ $this->query->add_orderby($this->table, $this->options['attribute_name'], $this->options['order']);
+ }
+}