Skip to content

Commit

Permalink
Added setting for sorting and group / also move the admin pages to a …
Browse files Browse the repository at this point in the history
…new group
  • Loading branch information
zuuperman committed Sep 19, 2013
1 parent ff80ff0 commit 1574ddc
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 59 deletions.
6 changes: 3 additions & 3 deletions culturefeed.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ function culturefeed_admin_settings() {
$form['culturefeed_api_application_key'] = array(
'#type' => 'textfield',
'#title' => t('Application key'),
'#description' => t('Your Culture Feed Application key.'),
'#description' => t('Your CultureFeed Application key.'),
'#default_value' => variable_get('culturefeed_api_application_key', ''),
'#size' => 40,
'#maxlength' => 40,
);
$form['culturefeed_api_shared_secret'] = array(
'#type' => 'textfield',
'#title' => t('Shared secret'),
'#description' => t('Your Culture Feed Shared Secret.'),
'#description' => t('Your CultureFeed Shared Secret.'),
'#default_value' => variable_get('culturefeed_api_shared_secret', ''),
'#size' => 40,
'#maxlength' => 40,
);
$form['culturefeed_entry_api_path'] = array(
'#type' => 'textfield',
'#title' => t('Entry API path'),
'#description' => t('The path where the Culture Feed Entry API resides. End with a slash. Example: entry/test.rest.uitdatabank.be/api/v1/'),
'#description' => t('The path where the CultureFeed Entry API resides. End with a slash. Example: entry/test.rest.uitdatabank.be/api/v1/'),
'#default_value' => variable_get('culturefeed_entry_api_path', CULTUREFEED_ENTRY_API_PATH),
);

Expand Down
20 changes: 10 additions & 10 deletions culturefeed.helpers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function culturefeed_is_culturefeed_user($uid = NULL) {
}

/**
* Fetch a unique username for the given Culture Feed user id.
* Fetch a unique username for the given CultureFeed user id.
*/
function culturefeed_unique_username($cf_uid, $nick) {
$name = db_query("SELECT DISTINCT name FROM {culturefeed_user} cfu INNER JOIN {users} u ON u.uid = cfu.uid WHERE cfu.cf_uid = :cf_uid", array(':cf_uid' => $cf_uid))->fetchField();
Expand Down Expand Up @@ -52,17 +52,17 @@ function culturefeed_create_user($cf_account) {

// Use a database transaction, as we need to handle what follows as a unit of work.
$txn = db_transaction();

try {

// If no CultureFeed user was passed, we can't create the user.
if (!$cf_account || empty($cf_account->nick)) {
return FALSE;
}

// Find a unique nick based on the given nick. In case the nick is not used yet, the passed nick will be used. Else the nick will be suffixed with an underscore and counter (example nick_12).
$unique_nick = culturefeed_unique_username($cf_account->id, $cf_account->nick);

// Create the user account.
$url = parse_url($GLOBALS['base_url']);
$account = user_save(
Expand All @@ -78,25 +78,25 @@ function culturefeed_create_user($cf_account) {
'mail' => '',
)
);
// Save the mapping between Culture Feed User ID and Drupal user id.

// Save the mapping between CultureFeed User ID and Drupal user id.
db_insert('culturefeed_user')
->fields(array(
'uid' => $account->uid,
'cf_uid' => $cf_account->id,
))
->execute();

// Save the fact that this is an external account for culturefeed.
user_set_authmaps($account, array('authname_culturefeed' => $account->name));
}
catch (Exception $e) {
$txn->rollback();
throw $e;
}

return $account;

}

function culturefeed_get_uid_for_cf_uid($cf_uid, $nick) {
Expand Down
2 changes: 1 addition & 1 deletion culturefeed.info
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ files[] = lib/CultureFeed/CultureFeed/Messages/Message.php
files[] = lib/CultureFeed/CultureFeed/Log/RequestLog.php
files[] = lib/CultureFeed/CultureFeed/Log/Request.php

configure = admin/config/services/culturefeed
configure = admin/config/culturefeed/culturefeed

6 changes: 3 additions & 3 deletions culturefeed.install
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function culturefeed_requirements($phase) {
// Raise warning if CultureFeed key has not been set yet.
$requirements['culturefeed_api_application_key']['title'] = $t('CultureFeed Application Key');
if (trim(variable_get('culturefeed_api_application_key', '')) == '') {
$requirements['culturefeed_api_application_key']['description'] = $t('Your CultureFeed Application key has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/services/culturefeed')));
$requirements['culturefeed_api_application_key']['description'] = $t('Your CultureFeed Application key has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_application_key']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_application_key']['value'] = $t('Not configured');
}
Expand All @@ -124,7 +124,7 @@ function culturefeed_requirements($phase) {
// Raise warning if CultureFeed shared secret has not been set yet.
$requirements['culturefeed_api_shared_secret']['title'] = $t('CultureFeed Shared Secret');
if (trim(variable_get('culturefeed_api_shared_secret', '')) == '') {
$requirements['culturefeed_api_shared_secret']['description'] = $t('Your CultureFeed Shared Secret has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/services/culturefeed')));
$requirements['culturefeed_api_shared_secret']['description'] = $t('Your CultureFeed Shared Secret has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_shared_secret']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_shared_secret']['value'] = $t('Not configured');
}
Expand All @@ -135,7 +135,7 @@ function culturefeed_requirements($phase) {
// Raise warning if CultureFeed location has not been set yet.
$requirements['culturefeed_api_location']['title'] = $t('CultureFeed location');
if (trim(variable_get('culturefeed_api_location')) == '') {
$requirements['culturefeed_api_location']['description'] = $t('The location of the CultureFeed has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/services/culturefeed')));
$requirements['culturefeed_api_location']['description'] = $t('The location of the CultureFeed has not been set yet. Please configure its settings from the <a href="@url">CultureFeed settings page</a>.', array('@url' => url('admin/config/culturefeed/culturefeed')));
$requirements['culturefeed_api_location']['severity'] = REQUIREMENT_ERROR;
$requirements['culturefeed_api_location']['value'] = $t('Not configured');
}
Expand Down
16 changes: 13 additions & 3 deletions culturefeed.module
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ function culturefeed_init() {
* Implements hook_menu().
*/
function culturefeed_menu() {
$items['admin/config/services/culturefeed'] = array(
'title' => 'Culture Feed',
'description' => 'Change Culture Feed API setting like API Appliction key, location, ...',
$items['admin/config/culturefeed'] = array(
'title' => 'CultureFeed',
'description' => 'Settings related to CultureFeed.',
'position' => 'right',
'weight' => 0,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('access administration pages'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/culturefeed/api-settings'] = array(
'title' => 'CultureFeed',
'description' => 'Change CultureFeed API setting like API Appliction key, location, ...',
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_admin_settings'),
'access arguments' => array('administer site configuration'),
Expand Down
11 changes: 10 additions & 1 deletion culturefeed_agenda/culturefeed_agenda.module
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ function culturefeed_agenda_menu() {
'file' => 'includes/pages.inc',
);

$items['admin/config/culturefeed/agenda'] = array(
'title' => 'CultureFeed Agenda',
'description' => t('Change CultureFeed agenda settings'),
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_agenda_admin_settings_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.inc',
);

return $items;

}
Expand All @@ -136,7 +145,7 @@ function culturefeed_agenda_culturefeed_search_page_info() {
'path' => 'agenda/search',
'page_title' => t('Agenda'),
'search_title' => t('Activities'),
'sort_default' => 'date',
'sort_default' => variable_get('culturefeed-agenda-default-sort', 'date'),
'sort_options' => array(
'relevancy' => t('Relevance'),
'date' => t('Date'),
Expand Down
25 changes: 25 additions & 0 deletions culturefeed_agenda/includes/admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @file
* Admin settings for culturefeed_agenda.
*/

/**
* General settings for agenda.
*/
function culturefeed_agenda_admin_settings_form() {

$page_info = culturefeed_agenda_culturefeed_search_page_info();
$agenda_page = current($page_info);

$form = array();
$form['culturefeed-agenda-default-sort'] = array(
'#title' => t('Default sorting for agenda'),
'#type' => 'select',
'#options' => $agenda_page['sort_options'],
'#default_value' => $agenda_page['sort_default'],
);

return system_settings_form($form);
}

2 changes: 1 addition & 1 deletion culturefeed_devel/culturefeed_devel.module
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function culturefeed_devel_menu() {

$items = array();
$items['admin/config/development/culturefeed'] = array(
'title' => 'Culture Feed Devel',
'title' => 'CultureFeed Devel',
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_devel_admin_settings_form'),
'access arguments' => array('administer site configuration'),
Expand Down
2 changes: 1 addition & 1 deletion culturefeed_mailing/culturefeed_mailing.module
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function culturefeed_mailing_menu() {
);

// Configuration pages.
$items['admin/config/services/culturefeed-mailing'] = array(
$items['admin/config/culturefeed/mailing'] = array(
'title' => 'CultureFeed Mailing',
'description' => 'CultureFeed Mailing settings',
'page callback' => 'drupal_get_form',
Expand Down
4 changes: 2 additions & 2 deletions culturefeed_pages/lib/Drupal/PagesSearchPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ protected function execute($params) {
// Add items / page.
$this->parameters[] = new Parameter\Rows($this->resultsPerPage);

// Add grouping so returned events are not duplicate.
$this->parameters[] = new Parameter\Group();
// Add grouping so returned data is not duplicate.
$this->parameters[] = new Parameter\Group($this->group);

// Always add spellcheck.
$this->parameters[] = new Parameter\Parameter('spellcheck', 'true');
Expand Down
6 changes: 3 additions & 3 deletions culturefeed_search/culturefeed_search.module
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ module_load_include('inc', 'culturefeed_search', 'includes/helpers');
*/
function culturefeed_search_menu() {

$items['admin/config/services/culturefeed_search'] = array(
'title' => 'Culture Feed Search',
'description' => 'Change Culture Feed Search API setting like API Appliction key, location, ...',
$items['admin/config/culturefeed/search'] = array(
'title' => 'CultureFeed Search',
'description' => 'Change CultureFeed Search API setting like API Appliction key, location, ...',
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_search_admin_settings'),
'access arguments' => array('administer site configuration'),
Expand Down
4 changes: 2 additions & 2 deletions culturefeed_search/includes/admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function culturefeed_search_admin_settings() {
$form['culturefeed_search_api_application_key'] = array(
'#type' => 'textfield',
'#title' => t('Application key'),
'#description' => t('Your Culture Feed Search Application key.'),
'#description' => t('Your CultureFeed Search Application key.'),
'#default_value' => variable_get('culturefeed_search_api_application_key', ''),
'#size' => 40,
'#maxlength' => 40,
Expand All @@ -29,7 +29,7 @@ function culturefeed_search_admin_settings() {
$form['culturefeed_search_api_shared_secret'] = array(
'#type' => 'textfield',
'#title' => t('Shared secret'),
'#description' => t('Your Culture Feed Search Shared Secret.'),
'#description' => t('Your CultureFeed Search Shared Secret.'),
'#default_value' => variable_get('culturefeed_search_api_shared_secret', ''),
'#size' => 40,
'#maxlength' => 40,
Expand Down
7 changes: 4 additions & 3 deletions culturefeed_search_ui/culturefeed_search_ui.module
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ function culturefeed_search_ui_menu() {

}

$items['admin/config/services/culturefeed_search_ui'] = array(
'title' => 'Culture Feed Search UI',
'description' => t('Change Culture Feed Search UI settings like display, filters, …'),
$items['admin/config/culturefeed/search-ui'] = array(
'title' => 'CultureFeed Search UI',
'description' => t('Change CultureFeed Search UI settings like display, filters, …'),
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_search_ui_admin_settings'),
'access arguments' => array('administer site configuration'),
Expand Down Expand Up @@ -523,6 +523,7 @@ function culturefeed_get_search_page($search_type) {
$pages[$class_name] = new $search_type['class_name']();
$pages[$class_name]->setResultsPerPage(variable_get('culturefeed_search_ui_pager_items_per_page', CULTUREFEED_SEARCH_UI_PAGER_ITEMS_PER_PAGE));
$pages[$class_name]->setDefaultSort($search_type['sort_default']);
$pages[$class_name]->setGroup(variable_get('culturefeed_search_group', TRUE));
$pages[$class_name]->initialize();
}
return $pages[$class_name];
Expand Down
7 changes: 7 additions & 0 deletions culturefeed_search_ui/includes/admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ function culturefeed_search_ui_admin_settings() {
'#default_value' => variable_get('culturefeed_search_redirect_old_search', FALSE),
);

$form['culturefeed_search_group'] = array(
'#type' => 'textfield',
'#title' => t('Group'),
'#description' => t('Group description'),
'#default_value' => variable_get('culturefeed_search_group', TRUE),
);

return system_settings_form($form);

}
26 changes: 24 additions & 2 deletions culturefeed_search_ui/lib/Drupal/CultureFeedSearchPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ class CultureFeedSearchPage {
*/
protected $parameters = array();

/**
* The group value to send to the service.
* @var string|boolean
*/
protected $group = TRUE;

/**
* Query to search on.
* @var array
Expand Down Expand Up @@ -302,6 +308,22 @@ public function unsetParameter($key) {
return $this->parameters;
}

/**
* Get the group value.
* @return mixed boolean|string
*/
public function getGroup() {
return $this->group;
}

/**
* Group value to set.
* @param boolean|string $group
*/
public function setGroup($group) {
$this->group = $group;
}

/**
* Initializes the search with data from the URL query parameters.
*/
Expand Down Expand Up @@ -470,8 +492,8 @@ protected function execute($params) {
// Add items / page.
$this->parameters[] = new Parameter\Rows($this->resultsPerPage);

// Add grouping so returned events are not duplicate.
$this->parameters[] = new Parameter\Group();
// Add grouping so returned data is not duplicate.
$this->parameters[] = new Parameter\Group($this->group);

// Always add spellcheck.
$this->parameters[] = new Parameter\Parameter('spellcheck', 'true');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ msgstr ""
"X-Generator: Poedit 1.5.7\n"

#: culturefeed_search_ui.module:98
msgid "Change Culture Feed Search UI settings like display, filters, …"
msgid "Change CultureFeed Search UI settings like display, filters, …"
msgstr ""
"Verander de instellingen van de CultureFeed Search UI zoals weergave, "
"filters,..."
Expand Down Expand Up @@ -68,7 +68,7 @@ msgid "Culturefeed search"
msgstr ""

#: culturefeed_search_ui.module:97
msgid "Culture Feed Search UI"
msgid "CultureFeed Search UI"
msgstr ""

#: culturefeed_search_ui.info:0
Expand Down
2 changes: 1 addition & 1 deletion culturefeed_social/culturefeed_social.module
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function culturefeed_social_menu() {
'file' => 'includes/pages.inc',
);

$items['admin/config/services/culturefeed_social'] = array(
$items['admin/config/culturefeed/social'] = array(
'title' => 'CultureFeed Social',
'description' => 'Change CultureFeed Social settings',
'page callback' => 'drupal_get_form',
Expand Down
6 changes: 3 additions & 3 deletions culturefeed_ui/culturefeed_ui.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ define('CULTUREFEED_UI_PAGE_USERS_FOR_CONTENT_ACTIVITY', 20);
* Implements hook_menu().
*/
function culturefeed_ui_menu() {
$items['admin/config/services/culturefeed_ui'] = array(
'title' => 'Culture Feed User Interface',
'description' => 'Change Culture Feed User Interface settings.',
$items['admin/config/culturefeed/culturefeed_ui'] = array(
'title' => 'CultureFeed User Interface',
'description' => 'Change CultureFeed User Interface settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_ui_admin_settings'),
'access arguments' => array('administer site configuration'),
Expand Down
4 changes: 2 additions & 2 deletions culturefeed_ui/translations/culturefeed_ui.nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,11 @@ msgstr ""
"cache is geleegd en opnieuw gecreeërd."

#: culturefeed_ui.module:16
msgid "Culture Feed User Interface"
msgid "CultureFeed User Interface"
msgstr "CultureFeed User Interface"

#: culturefeed_ui.module:17
msgid "Change Culture Feed User Interface settings."
msgid "Change CultureFeed User Interface settings."
msgstr "Verander instellingen van de CultureFeed User Interface. "

#: culturefeed_ui.info:0
Expand Down
Loading

0 comments on commit 1574ddc

Please sign in to comment.