Skip to content

Commit fc7860c

Browse files
authored
Merge pull request #1 from ding2/master
Updating
2 parents 306139c + 6eeefa1 commit fc7860c

54 files changed

Lines changed: 758 additions & 456 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ jobs:
66
- image: circleci/php:7.0-cli
77
steps:
88
- checkout
9+
- run:
10+
name: Update composer
11+
command: |
12+
sudo composer self-update
913
- run:
1014
name: Install Drush
1115
command: |
@@ -66,6 +70,10 @@ jobs:
6670
- image: circleci/php:7.0-cli
6771
steps:
6872
- checkout
73+
- run:
74+
name: Update composer
75+
command: |
76+
sudo composer self-update
6977
- run:
7078
name: Install PHP linter
7179
command: |
@@ -81,6 +89,10 @@ jobs:
8189
- image: circleci/php:5.6-cli
8290
steps:
8391
- checkout
92+
- run:
93+
name: Update composer
94+
command: |
95+
sudo composer self-update
8496
- run:
8597
name: Install PHP linter
8698
command: |
@@ -99,6 +111,10 @@ jobs:
99111
steps:
100112
- attach_workspace:
101113
at: ~/
114+
- run:
115+
name: Update composer
116+
command: |
117+
sudo composer self-update
102118
- run:
103119
name: Configure PHP for Drupal
104120
command: |
@@ -123,7 +139,7 @@ jobs:
123139
--site-name=Ding2 --account-name=admin --account-pass=admin \
124140
install_configure_form.update_status_module='array(FALSE,FALSE)' \
125141
ding2_module_selection_form.providers_selection=connie \
126-
opensearch_admin_settings.opensearch_url=https://oss-services.dbc.dk/opensearch/5.2/ \
142+
opensearch_admin_settings.opensearch_url=https://opensearch.addi.dk/test_5.2/ \
127143
opensearch_admin_settings.ting_agency=100200 \
128144
opensearch_admin_settings.opensearch_search_profile=test \
129145
- run:
@@ -147,6 +163,10 @@ jobs:
147163
steps:
148164
- attach_workspace:
149165
at: ~/
166+
- run:
167+
name: Update composer
168+
command: |
169+
sudo composer self-update
150170
- run:
151171
name: Configure PHP for Drupal
152172
command: |
@@ -195,6 +215,10 @@ jobs:
195215
steps:
196216
- attach_workspace:
197217
at: ~/
218+
- run:
219+
name: Update composer
220+
command: |
221+
sudo composer self-update
198222
- run:
199223
name: Configure PHP for Drupal
200224
command: |

.platform.app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ hooks:
111111
set -e
112112
cd public
113113
drush -y updatedb
114+
drush secure-permissions-rebuild
114115
drush css-generate
115116
drush cc all
116117

ding2.install

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,3 +1072,10 @@ function ding2_update_7092() {
10721072
]);
10731073
}
10741074
}
1075+
1076+
/**
1077+
* Update translations.
1078+
*/
1079+
function ding2_update_7093() {
1080+
ding2_translation_update();
1081+
}

modules/bpi/bpi.module

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,33 @@ function bpi_menu() {
148148
'file' => 'bpi.admin.inc',
149149
);
150150

151+
$menu['bpi/edit/%'] = array(
152+
'title' => 'BPI content edit',
153+
'access callback' => 'bpi_edit_access',
154+
'access arguments' => [2],
155+
'page callback' => '_bpi_edit_callback',
156+
'page arguments' => array(2),
157+
'type' => MENU_CALLBACK,
158+
);
159+
151160
return $menu;
152161
}
153162

163+
/**
164+
* Redirects the user to BPI node edit form.
165+
*
166+
* @param string $bid
167+
* BPI id.
168+
*/
169+
function _bpi_edit_callback($bid) {
170+
if (!$node = bpi_load_node_by_bid($bid)) {
171+
drupal_not_found();
172+
}
173+
174+
$path = 'node/' . $node->nid . '/edit';
175+
drupal_goto($path);
176+
}
177+
154178
/**
155179
* Check if current user has access to the BPI Syndication menu.
156180
*
@@ -190,6 +214,21 @@ function bpi_access() {
190214
return $access;
191215
}
192216

217+
/**
218+
* Checks BPI node edit access.
219+
*
220+
* @param string $bid
221+
* BPI id.
222+
*
223+
* @return bool
224+
* Access result.
225+
*/
226+
function bpi_edit_access($bid) {
227+
$node = bpi_load_node_by_bid($bid);
228+
229+
return $node ? node_access('update', $node) : user_access('access content');
230+
}
231+
193232
/**
194233
* Implements hook_permission().
195234
*/
@@ -1138,3 +1177,25 @@ function bpi_preprocess_bpi_preview_item(&$variables) {
11381177
function bpi_material_is_sharable($material_id) {
11391178
return !preg_match('/katalog/', $material_id);
11401179
}
1180+
1181+
/**
1182+
* Attempts to load a node by BPI id.
1183+
*
1184+
* This is viable only in cases when the node held a certain BPI action,
1185+
* i.e. there is a record in the respective table.
1186+
* Obviously, only nodes that were pushed from this instance can be loaded
1187+
* this way.
1188+
*
1189+
* @param string $bid
1190+
* BPI id.
1191+
*
1192+
* @return mixed
1193+
* A node object, or FALSE when no match.
1194+
*/
1195+
function bpi_load_node_by_bid($bid) {
1196+
$result = db_query('SELECT nid FROM {bpi_syndicated} WHERE bid = :bid', [
1197+
':bid' => $bid,
1198+
])->fetchField();
1199+
1200+
return node_load($result);
1201+
}

modules/bpi/bpi.syndicate.inc

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -871,11 +871,6 @@ function bpi_build_search_facets(array &$form) {
871871
* @throws \Bpi\Sdk\Exception\SDKException
872872
*/
873873
function bpi_build_top_rank(&$form) {
874-
$heading = array(
875-
t('Title'),
876-
t('Amount')
877-
);
878-
879874
$form['bpi_top_rank'] = array(
880875
'#type' => 'fieldset',
881876
'#title' => t('Top ranking'),
@@ -889,52 +884,68 @@ function bpi_build_top_rank(&$form) {
889884
),
890885
);
891886

892-
$topNodesSyndicated = bpi_get_top_ranked('-1 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node');
893-
$rows = bpi_build_top_rank_rows($topNodesSyndicated, '/admin/bpi/syndicate');
887+
$bpi_rank_results = bpi_get_top_ranked('-1 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node');
888+
$rows = bpi_build_top_rank_rows($bpi_rank_results, '/admin/bpi/syndicate');
894889
$form['bpi_top_rank']['top_nodes_syndicated'] = array(
895890
'#theme' => 'table',
896-
'#caption' => t('Top syndicated (1 month)'),
897-
'#header' => $heading,
891+
'#caption' => t('Most shared articles (1 month)'),
892+
'#header' => array(
893+
t('Title'),
894+
t('Amount of articles'),
895+
),
898896
'#rows' => $rows,
899897
'#empty' => t('No data so far.'),
900898
);
901899

902-
$topNodesSyndicated = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node');
903-
$rows = bpi_build_top_rank_rows($topNodesSyndicated, '/admin/bpi/syndicate');
900+
$bpi_rank_results = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node');
901+
$rows = bpi_build_top_rank_rows($bpi_rank_results, '/admin/bpi/syndicate');
904902
$form['bpi_top_rank']['top_nodes_syndicated_three_months'] = array(
905903
'#theme' => 'table',
906-
'#caption' => t('Top syndicated (3 months)'),
907-
'#header' => $heading,
904+
'#caption' => t('Most shared articles (3 months)'),
905+
'#header' => array(
906+
t('Title'),
907+
t('Amount of articles'),
908+
),
908909
'#rows' => $rows,
909910
'#empty' => t('No data so far.'),
910911
);
911912

912-
$topAgenciesSyndicate = bpi_get_top_ranked('-3 months');
913-
$rows = bpi_build_top_rank_rows($topAgenciesSyndicate);
913+
$bpi_rank_results = bpi_get_top_ranked('-3 months');
914+
$rows = bpi_build_top_rank_rows($bpi_rank_results);
914915
$form['bpi_top_rank']['top_agency_syndications'] = array(
915916
'#theme' => 'table',
916-
'#caption' => t('Top syndications (3 months)'),
917-
'#header' => $heading,
917+
'#caption' => t('Top agency downloader (3 months)'),
918+
'#header' => array(
919+
t('Library'),
920+
t('Amount of articles'),
921+
),
918922
'#rows' => $rows,
919923
'#empty' => t('No data so far.'),
920924
);
921925

922-
$topAgenciesPush = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'push');
923-
$rows = bpi_build_top_rank_rows($topAgenciesPush);
926+
$bpi_rank_results = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'push');
927+
$rows = bpi_build_top_rank_rows($bpi_rank_results);
924928
$form['bpi_top_rank']['top_agency_pushes'] = array(
925929
'#theme' => 'table',
926-
'#caption' => t('Top pushes (3 months)'),
927-
'#header' => $heading,
930+
'#caption' => t('Top agency contributor (3 months)'),
931+
'#header' => array(
932+
t('Library'),
933+
t('Amount of articles'),
934+
),
928935
'#rows' => $rows,
929936
'#empty' => t('No data so far.'),
930937
);
931938

932-
$topNodesSyndicatedCreatedByMe = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node', ['999999']);
933-
$rows = bpi_build_top_rank_rows($topNodesSyndicatedCreatedByMe);
939+
$self_agency = variable_get('ting_agency', '');
940+
$bpi_rank_results = bpi_get_top_ranked('-3 months', BPI_TOP_RANK_AMOUNT, 'syndicate', 'node', [$self_agency]);
941+
$rows = bpi_build_top_rank_rows($bpi_rank_results, '/bpi/edit');
934942
$form['bpi_top_rank']['top_my_nodes_syndicated'] = array(
935943
'#theme' => 'table',
936-
'#caption' => t('Most syndications (3 months) authored by me'),
937-
'#header' => $heading,
944+
'#caption' => t('Most syndicated articles by my library'),
945+
'#header' => array(
946+
t('Title'),
947+
t('Amount of articles'),
948+
),
938949
'#rows' => $rows,
939950
'#empty' => t('No data so far.'),
940951
);

modules/ding_app_content_rss/ding_app_content_rss.rules_defaults.inc

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @file
4-
* Rules configuration.
4+
* ding_app_content_rss.rules_defaults.inc
55
*/
66

77
/**
@@ -43,12 +43,7 @@ function ding_app_content_rss_default_rules_configuration() {
4343
}
4444
],
4545
"DO" : [
46-
{ "cache_actions_action_clear_views_display_cache" : { "displays" : { "value" : {
47-
"ding_app_content_event_rss:feed" : "ding_app_content_event_rss:feed"
48-
}
49-
}
50-
}
51-
}
46+
{ "cache_actions_action_clear_views_display_cache" : { "displays" : { "value" : { "ding_app_content_event_rss:feed" : "ding_app_content_event_rss:feed" } } } }
5247
]
5348
}
5449
}');
@@ -86,12 +81,7 @@ function ding_app_content_rss_default_rules_configuration() {
8681
}
8782
],
8883
"DO" : [
89-
{ "cache_actions_action_clear_views_display_cache" : { "displays" : { "value" : {
90-
"ding_app_content_news_rss:feed" : "ding_app_content_news_rss:feed"
91-
}
92-
}
93-
}
94-
}
84+
{ "cache_actions_action_clear_views_display_cache" : { "displays" : { "value" : { "ding_app_content_news_rss:feed" : "ding_app_content_news_rss:feed" } } } }
9585
]
9686
}
9787
}');

0 commit comments

Comments
 (0)