Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
d3aee651
Commit
d3aee651
authored
12 years ago
by
matt2000
Committed by
Franz Glauber Vanderlinde
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #1454666: Add tool to reset locked feeds
parent
368a4a9a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
feeds.module
+25
-1
25 additions, 1 deletion
feeds.module
feeds.pages.inc
+59
-0
59 additions, 0 deletions
feeds.pages.inc
with
84 additions
and
1 deletion
feeds.module
+
25
−
1
View file @
d3aee651
...
...
@@ -235,6 +235,10 @@ function feeds_permission() {
$perms
[
"clear
$importer->id
feeds"
]
=
array
(
'title'
=>
t
(
'Delete items from @name feeds'
,
array
(
'@name'
=>
$importer
->
config
[
'name'
])),
);
$perms
[
"unlock
$importer->id
feeds"
]
=
array
(
'title'
=>
t
(
'Unlock imports from @name feeds'
,
array
(
'@name'
=>
$importer
->
config
[
'name'
])),
'description'
=>
t
(
'If a feed importation breaks for some reason, users with this permission can unlock them.'
)
);
}
return
$perms
;
}
...
...
@@ -288,6 +292,15 @@ function feeds_menu() {
'file'
=>
'feeds.pages.inc'
,
'type'
=>
MENU_LOCAL_TASK
,
);
$items
[
'import/%/unlock'
]
=
array
(
'title'
=>
'Unlock'
,
'page callback'
=>
'drupal_get_form'
,
'page arguments'
=>
array
(
'feeds_unlock_tab_form'
,
1
),
'access callback'
=>
'feeds_access'
,
'access arguments'
=>
array
(
'unlock'
,
1
),
'file'
=>
'feeds.pages.inc'
,
'type'
=>
MENU_LOCAL_TASK
,
);
$items
[
'import/%/template'
]
=
array
(
'page callback'
=>
'feeds_importer_template'
,
'page arguments'
=>
array
(
1
),
...
...
@@ -316,6 +329,16 @@ function feeds_menu() {
'type'
=>
MENU_LOCAL_TASK
,
'weight'
=>
11
,
);
$items
[
'node/%node/unlock'
]
=
array
(
'title'
=>
'Unlock'
,
'page callback'
=>
'drupal_get_form'
,
'page arguments'
=>
array
(
'feeds_unlock_tab_form'
,
NULL
,
1
),
'access callback'
=>
'feeds_access'
,
'access arguments'
=>
array
(
'unlock'
,
1
),
'file'
=>
'feeds.pages.inc'
,
'type'
=>
MENU_LOCAL_TASK
,
'weight'
=>
11
,
);
// @todo Eliminate this step and thus eliminate clearing menu cache when
// manipulating importers.
foreach
(
feeds_importer_load_all
()
as
$importer
)
{
...
...
@@ -367,11 +390,12 @@ function feeds_theme() {
* The action to be performed. Possible values are:
* - import
* - clear
* - unlock
* @param $param
* Node object or FeedsImporter id.
*/
function
feeds_access
(
$action
,
$param
)
{
if
(
!
in_array
(
$action
,
array
(
'import'
,
'clear'
)))
{
if
(
!
in_array
(
$action
,
array
(
'import'
,
'clear'
,
'unlock'
)))
{
// If $action is not one of the supported actions, we return access denied.
return
FALSE
;
}
...
...
This diff is collapsed.
Click to expand it.
feeds.pages.inc
+
59
−
0
View file @
d3aee651
...
...
@@ -193,6 +193,65 @@ function feeds_delete_tab_form_submit($form, &$form_state) {
feeds_source
(
$form
[
'#importer_id'
],
$feed_nid
)
->
startClear
();
}
/**
* Render a feeds unlock form.
*
* Used on both node pages and configuration pages.
* Therefore $node may be missing.
*/
function
feeds_unlock_tab_form
(
$form
,
&
$form_state
,
$importer_id
,
$node
=
NULL
)
{
if
(
empty
(
$node
))
{
$source
=
feeds_source
(
$importer_id
);
$form
[
'#redirect'
]
=
'import/'
.
$source
->
id
;
}
else
{
$importer_id
=
feeds_get_importer_id
(
$node
->
type
);
$source
=
feeds_source
(
$importer_id
,
$node
->
nid
);
$form
[
'#redirect'
]
=
'node/'
.
$source
->
feed_nid
;
}
// Form cannot pass on source object.
$form
[
'#importer_id'
]
=
$source
->
id
;
$form
[
'#feed_nid'
]
=
$source
->
feed_nid
;
$form
[
'source_status'
]
=
array
(
'#type'
=>
'fieldset'
,
'#title'
=>
t
(
'Status'
),
'#tree'
=>
TRUE
,
'#value'
=>
feeds_source_status
(
$source
),
);
$form
=
confirm_form
(
$form
,
t
(
'Unlock this importer?'
),
$form
[
'#redirect'
],
''
,
t
(
'Delete'
),
t
(
'Cancel'
),
'confirm feeds update'
);
$progress
=
$source
->
progressClearing
();
if
(
$progress
==
FEEDS_BATCH_COMPLETE
)
{
$form
[
'source_locked'
]
=
array
(
'#type'
=>
'markup'
,
'#title'
=>
t
(
'Not Locked'
),
'#tree'
=>
TRUE
,
'#markup'
=>
t
(
'This Importer is not locked, therefor it cannot be unlocked.'
),
);
$form
[
'actions'
][
'submit'
][
'#disabled'
]
=
TRUE
;
$form
[
'actions'
][
'submit'
][
'#value'
]
=
t
(
'Unlock (disabled)'
);
}
else
{
$form
[
'actions'
][
'submit'
][
'#value'
]
=
t
(
'Unlock'
);
}
return
$form
;
}
/**
* Form submit handler. Resets all feeds state.
*/
function
feeds_unlock_tab_form_submit
(
$form
,
&
$form_state
)
{
drupal_set_message
(
'Import Unlocked'
);
$form_state
[
'redirect'
]
=
$form
[
'#redirect'
];
$feed_nid
=
empty
(
$form
[
'#feed_nid'
])
?
0
:
$form
[
'#feed_nid'
];
$importer_id
=
$form
[
'#importer_id'
];
//Is there a more API-friendly way to set the state?
db_update
(
'feeds_source'
)
->
condition
(
'id'
,
$importer_id
)
->
condition
(
'feed_nid'
,
$feed_nid
)
->
fields
(
array
(
'state'
=>
FALSE
))
->
execute
();
}
/**
* Handle a fetcher callback.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment