Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
node_authlink
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
node_authlink
Commits
ac92551d
Commit
ac92551d
authored
Oct 18, 2020
by
Joël Pittet
Browse files
Options
Downloads
Patches
Plain Diff
Coding standards cleanup
parent
fa74bd0b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
node_authlink.install
+57
-39
57 additions, 39 deletions
node_authlink.install
node_authlink.module
+126
-89
126 additions, 89 deletions
node_authlink.module
node_authlink.views.inc
+4
-4
4 additions, 4 deletions
node_authlink.views.inc
with
187 additions
and
132 deletions
node_authlink.install
+
57
−
39
View file @
ac92551d
<?php
<?php
// $Id$
/**
/**
* Implementation of hook_schema().
* @file
* Installation and update of the node_authlink module.
*/
/**
* Implements hook_schema().
*/
*/
function
node_authlink_schema
()
{
function
node_authlink_schema
()
{
$schema
[
'node_authlink_nodes'
]
=
array
(
$schema
[
'node_authlink_nodes'
]
=
array
(
'description'
=>
'Table for store authorization keys.'
,
'description'
=>
'Table for store authorization keys.'
,
'fields'
=>
array
(
'fields'
=>
array
(
'nid'
=>
array
(
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
),
'nid'
=>
array
(
'authkey'
=>
array
(
'type'
=>
'varchar'
,
'length'
=>
64
,
'not null'
=>
TRUE
),
'type'
=>
'int'
,
'created'
=>
array
(
'type'
=>
'int'
,
'not null'
=>
TRUE
,
'default'
=>
0
),
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
),
'authkey'
=>
array
(
'type'
=>
'varchar'
,
'length'
=>
64
,
'not null'
=>
TRUE
,
),
'created'
=>
array
(
'type'
=>
'int'
,
'not null'
=>
TRUE
,
'default'
=>
0
,
),
),
),
'primary key'
=>
array
(
'nid'
),
'primary key'
=>
array
(
'nid'
),
);
);
...
@@ -19,22 +35,35 @@ function node_authlink_schema() {
...
@@ -19,22 +35,35 @@ function node_authlink_schema() {
}
}
/**
/**
* I
n
plement
ation of
hook_install().
* I
m
plement
s
hook_install().
*/
*/
function
node_authlink_install
()
{
function
node_authlink_install
()
{
drupal_set_message
(
t
(
'To setup Node authorize link module go to Structure → Content types → edit → Node authorize link.'
));
drupal_set_message
(
t
(
'To setup Node authorize link module go to Structure → Content types → edit → Node authorize link.'
));
}
}
/**
/**
* Inplementation of hook_update_N().
* Implements hook_uninstall().
*/
function
node_authlink_uninstall
()
{
$node_types
=
node_type_get_types
();
foreach
(
$node_types
as
$node_type
)
{
variable_del
(
'node_authlink_enable_'
.
$node_type
->
type
);
variable_del
(
'node_authlink_grants_'
.
$node_type
->
type
);
variable_del
(
'node_authlink_expire_'
.
$node_type
->
type
);
}
}
/**
* Implements hook_update_N().
*/
*/
function
node_authlink_update_7100
(
&
$sandbox
)
{
function
node_authlink_update_7100
(
&
$sandbox
)
{
// Migrate data
// Migrate data
.
drupal_install_schema
(
'node_authlink'
);
drupal_install_schema
(
'node_authlink'
);
$keys
=
db_query
(
'SELECT f.field_node_authlink_authkey_value, f.entity_id, n.created
FROM
$keys
=
db_query
(
'SELECT f.field_node_authlink_authkey_value, f.entity_id, n.created
{field_data_field_node_authlink_authkey} AS f INNER JOIN {node} AS n ON f.entity_id =
FROM
{field_data_field_node_authlink_authkey} AS f INNER JOIN {node} AS n ON f.entity_id =
n.nid
n.nid
WHERE f.language = \'und\''
);
WHERE f.language = \'und\''
);
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
db_insert
(
'node_authlink_nodes'
)
db_insert
(
'node_authlink_nodes'
)
...
@@ -48,9 +77,12 @@ function node_authlink_update_7100(&$sandbox) {
...
@@ -48,9 +77,12 @@ function node_authlink_update_7100(&$sandbox) {
unset
(
$keys
);
unset
(
$keys
);
// Migrate settings
// Migrate settings
.
$field
=
field_info_field
(
'field_node_authlink_authkey'
);
$field
=
field_info_field
(
'field_node_authlink_authkey'
);
$instances
=
field_read_instances
(
array
(
'field_id'
=>
$field
[
'id'
],
'entity_type'
=>
'node'
));
$instances
=
field_read_instances
(
array
(
'field_id'
=>
$field
[
'id'
],
'entity_type'
=>
'node'
,
));
$node_types
=
array
();
$node_types
=
array
();
foreach
(
$instances
as
$instance
)
{
foreach
(
$instances
as
$instance
)
{
...
@@ -62,27 +94,13 @@ function node_authlink_update_7100(&$sandbox) {
...
@@ -62,27 +94,13 @@ function node_authlink_update_7100(&$sandbox) {
variable_set
(
'node_authlink_types'
,
$node_types
);
variable_set
(
'node_authlink_types'
,
$node_types
);
// Cleanup
// Cleanup
.
field_delete_field
(
'field_node_authlink_authkey'
);
field_delete_field
(
'field_node_authlink_authkey'
);
}
}
function
node_authlink_update_7101
(
&
$sandbox
)
{
variable_del
(
'node_authlink_types'
);
}
/**
/**
*
Inplementation of hook_uninstall()
.
*
Remove node_authlink_types variable
.
*/
*/
function
node_authlink_uninstall
()
{
function
node_authlink_update_7101
(
&
$sandbox
)
{
$node_types
=
node_type_get_types
();
variable_del
(
'node_authlink_types'
);
foreach
(
$node_types
as
$node_type
)
{
variable_del
(
'node_authlink_enable_'
.
$node_type
->
type
);
variable_del
(
'node_authlink_grants_'
.
$node_type
->
type
);
variable_del
(
'node_authlink_expire_'
.
$node_type
->
type
);
}
}
}
This diff is collapsed.
Click to expand it.
node_authlink.module
+
126
−
89
View file @
ac92551d
<?php
<?php
// $Id$
/**
/**
* Alter of node_type_form.
* @file
* Provides functionality for the node_authlink module.
*/
/**
* Implements hook_form_node_type_form_alter().
*/
*/
function
node_authlink_form_node_type_form_alter
(
&
$form
,
&
$form_state
)
{
function
node_authlink_form_node_type_form_alter
(
&
$form
,
&
$form_state
)
{
$form
[
'node_authlink'
]
=
array
(
$form
[
'node_authlink'
]
=
array
(
...
@@ -32,8 +36,16 @@ function node_authlink_form_node_type_form_alter(&$form, &$form_state) {
...
@@ -32,8 +36,16 @@ function node_authlink_form_node_type_form_alter(&$form, &$form_state) {
'#description'
=>
t
(
'What operations will be temporarily given to authorised user for the node. This not affect users who is authorised yet.'
),
'#description'
=>
t
(
'What operations will be temporarily given to authorised user for the node. This not affect users who is authorised yet.'
),
);
);
// Time periods: none, 1 day, 1 week, 4 weeks, 3 months, 6 months, 1 year
// Time periods: none, 1 day, 1 week, 4 weeks, 3 months, 6 months, 1 year.
$period
=
drupal_map_assoc
(
array
(
0
,
86400
,
604800
,
2419200
,
7776000
,
15552000
,
31536000
),
'format_interval'
);
$period
=
drupal_map_assoc
(
array
(
0
,
86400
,
604800
,
2419200
,
7776000
,
15552000
,
31536000
,
),
'format_interval'
);
$period
[
0
]
=
'<'
.
t
(
'disabled'
)
.
'>'
;
$period
[
0
]
=
'<'
.
t
(
'disabled'
)
.
'>'
;
$form
[
'node_authlink'
][
'node_authlink_expire'
]
=
array
(
$form
[
'node_authlink'
][
'node_authlink_expire'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
...
@@ -65,10 +77,10 @@ function node_authlink_form_node_type_form_alter(&$form, &$form_state) {
...
@@ -65,10 +77,10 @@ function node_authlink_form_node_type_form_alter(&$form, &$form_state) {
}
}
/**
/**
* Submit for node_type_form.
*
Callback:
Submit for node_type_form.
*/
*/
function
node_authlink_form_node_type_form_alter_submit
(
&
$form
,
&
$form_state
)
{
function
node_authlink_form_node_type_form_alter_submit
(
&
$form
,
&
$form_state
)
{
// Disabled
// Disabled
.
if
(
!
$form_state
[
'values'
][
'node_authlink_enable'
])
{
if
(
!
$form_state
[
'values'
][
'node_authlink_enable'
])
{
variable_del
(
'node_authlink_enable_'
.
$form_state
[
'values'
][
'type'
]);
variable_del
(
'node_authlink_enable_'
.
$form_state
[
'values'
][
'type'
]);
variable_del
(
'node_authlink_grants_'
.
$form_state
[
'values'
][
'type'
]);
variable_del
(
'node_authlink_grants_'
.
$form_state
[
'values'
][
'type'
]);
...
@@ -76,10 +88,10 @@ function node_authlink_form_node_type_form_alter_submit(&$form, &$form_state) {
...
@@ -76,10 +88,10 @@ function node_authlink_form_node_type_form_alter_submit(&$form, &$form_state) {
}
}
/**
/**
* Generate authkeys for all nodes in node type.
*
Callback:
Generate authkeys for all nodes in node type.
*/
*/
function
node_authlink_batch_generate
(
&
$form
,
&
$form_state
)
{
function
node_authlink_batch_generate
(
&
$form
,
&
$form_state
)
{
// Load NIDs that are not in the authkeys table
// Load NIDs that are not in the authkeys table
.
$query
=
db_select
(
'node'
,
'n'
);
$query
=
db_select
(
'node'
,
'n'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
fields
(
'n'
,
array
(
'nid'
))
$query
->
fields
(
'n'
,
array
(
'nid'
))
...
@@ -87,7 +99,7 @@ function node_authlink_batch_generate(&$form, &$form_state) {
...
@@ -87,7 +99,7 @@ function node_authlink_batch_generate(&$form, &$form_state) {
->
isNull
(
'authkey'
);
->
isNull
(
'authkey'
);
$nids
=
$query
->
execute
()
->
fetchCol
();
$nids
=
$query
->
execute
()
->
fetchCol
();
// Create keys
// Create keys
.
foreach
(
$nids
as
$nid
)
{
foreach
(
$nids
as
$nid
)
{
node_authlink_node_insert
(
$nid
);
node_authlink_node_insert
(
$nid
);
if
(
module_exists
(
'entitycache'
))
{
if
(
module_exists
(
'entitycache'
))
{
...
@@ -99,10 +111,10 @@ function node_authlink_batch_generate(&$form, &$form_state) {
...
@@ -99,10 +111,10 @@ function node_authlink_batch_generate(&$form, &$form_state) {
}
}
/**
/**
* Delete authkeys for all nodes in node type.
*
Callback:
Delete authkeys for all nodes in node type.
*/
*/
function
node_authlink_batch_delete
(
&
$form
,
&
$form_state
)
{
function
node_authlink_batch_delete
(
&
$form
,
&
$form_state
)
{
// NIDs of nodes that are in this node type
// NIDs of nodes that are in this node type
.
$query
=
db_select
(
'node'
,
'n'
);
$query
=
db_select
(
'node'
,
'n'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
fields
(
'n'
,
array
(
'nid'
))
$query
->
fields
(
'n'
,
array
(
'nid'
))
...
@@ -110,7 +122,7 @@ function node_authlink_batch_delete(&$form, &$form_state) {
...
@@ -110,7 +122,7 @@ function node_authlink_batch_delete(&$form, &$form_state) {
->
isNotNull
(
'authkey'
);
->
isNotNull
(
'authkey'
);
$nids
=
$query
->
execute
()
->
fetchCol
();
$nids
=
$query
->
execute
()
->
fetchCol
();
// Delete keys
// Delete keys
.
$count
=
db_delete
(
'node_authlink_nodes'
)
$count
=
db_delete
(
'node_authlink_nodes'
)
->
condition
(
'nid'
,
$nids
,
'IN'
)
->
condition
(
'nid'
,
$nids
,
'IN'
)
->
execute
();
->
execute
();
...
@@ -124,45 +136,60 @@ function node_authlink_batch_delete(&$form, &$form_state) {
...
@@ -124,45 +136,60 @@ function node_authlink_batch_delete(&$form, &$form_state) {
drupal_set_message
(
t
(
'%num authkeys has been deleted.'
,
array
(
'%num'
=>
$count
)));
drupal_set_message
(
t
(
'%num authkeys has been deleted.'
,
array
(
'%num'
=>
$count
)));
}
}
/**
/**
* Implement
ation of
hook_node_load().
* Implement
s
hook_node_load().
*
*
* Appends authke to loaded node object.
* Appends authke
y
to loaded node object.
*/
*/
function
node_authlink_node_load
(
$nodes
,
$types
)
{
function
node_authlink_node_load
(
$nodes
,
$types
)
{
foreach
(
$nodes
as
$nid
=>
$node
)
{
foreach
(
$nodes
as
$nid
=>
$node
)
{
// TODO: check node type (performance)
// TODO: check node type (performance)
if
(
$authkey
=
node_authlink_load_authkey
(
$nid
))
if
(
$authkey
=
node_authlink_load_authkey
(
$nid
))
{
$nodes
[
$nid
]
->
authkey
=
$authkey
;
$nodes
[
$nid
]
->
authkey
=
$authkey
;
}
}
}
}
}
/**
/**
* Loads key from NID.
* Loads key from NID.
*
* @param string $nid
* The node id.
*
* @return string
* The authkey.
*/
*/
function
node_authlink_load_authkey
(
$nid
)
{
function
node_authlink_load_authkey
(
$nid
)
{
$result
=
db_query
(
'SELECT authkey FROM {node_authlink_nodes} WHERE nid = :nid'
,
array
(
':nid'
=>
$nid
));
$result
=
db_query
(
'SELECT authkey FROM {node_authlink_nodes} WHERE nid = :nid'
,
array
(
':nid'
=>
$nid
));
return
$result
->
fetchField
();
return
$result
->
fetchField
();
}
}
/**
/**
* Get edit URL of specified node.
* Get edit URL of specified node.
* @param $node Node object or NID.
*
* @param $op Operation to do with node. view, edit (default) or delete.
* @param int|object $node
* Node object or NID.
* @param string $op
* Operation to do with node. view, edit (default) or delete.
*
* @return string
* The node operation's URL with authkey query appended.
*/
*/
function
node_authlink_get_url
(
$node
,
$op
=
'edit'
)
{
function
node_authlink_get_url
(
$node
,
$op
=
'edit'
)
{
if
(
is_numeric
(
$node
))
if
(
is_numeric
(
$node
))
{
$node
=
node_load
(
$node
);
$node
=
node_load
(
$node
);
}
if
(
!
isset
(
$node
->
authkey
))
if
(
!
isset
(
$node
->
authkey
))
{
return
FALSE
;
return
FALSE
;
}
if
(
$op
==
'view'
)
if
(
$op
==
'view'
)
{
$op
=
''
;
$op
=
''
;
else
}
else
{
$op
=
'/'
.
$op
;
$op
=
'/'
.
$op
;
}
return
url
(
"node/
$node->nid$op
"
,
array
(
return
url
(
"node/
$node->nid$op
"
,
array
(
'absolute'
=>
TRUE
,
'absolute'
=>
TRUE
,
...
@@ -171,74 +198,80 @@ function node_authlink_get_url($node, $op = 'edit') {
...
@@ -171,74 +198,80 @@ function node_authlink_get_url($node, $op = 'edit') {
}
}
/**
/**
* Implement
ation of
hook_node_access().
* Implement
s
hook_node_access().
*/
*/
function
node_authlink_node_access
(
$node
,
$op
,
$account
)
{
function
node_authlink_node_access
(
$node
,
$op
,
$account
)
{
// Ignore if just creating node
// Ignore if just creating node
.
if
(
$op
==
'create'
)
if
(
$op
==
'create'
)
{
return
NODE_ACCESS_IGNORE
;
return
NODE_ACCESS_IGNORE
;
}
// Ignore if node type is not enabled
// Ignore if node type is not enabled
.
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
{
return
NODE_ACCESS_IGNORE
;
return
NODE_ACCESS_IGNORE
;
}
// Check key if:
// Check key if:
if
(
isset
(
$_GET
[
'authkey'
])
&&
// authkey param is set
// authkey param is set
and in node is set.
isset
(
$node
->
authkey
))
{
// authkey in node is set
if
(
isset
(
$_GET
[
'authkey'
])
&&
isset
(
$node
->
authkey
))
{
if
(
$node
->
authkey
==
$_GET
[
'authkey'
])
{
if
(
$node
->
authkey
==
$_GET
[
'authkey'
])
{
// Start session
// Start session
.
if
(
!
isset
(
$_SESSION
))
if
(
!
isset
(
$_SESSION
))
{
drupal_session_initialize
();
drupal_session_initialize
();
}
// Save allowed grants to session
// Save allowed grants to session
.
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
]
=
variable_get
(
'node_authlink_grants_'
.
$node
->
type
,
array
());
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
]
=
variable_get
(
'node_authlink_grants_'
.
$node
->
type
,
array
());
}
}
}
}
// Permit if checked
// Permit if checked.
if
(
isset
(
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
])
&&
if
(
isset
(
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
])
&&
in_array
(
$op
,
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
]))
{
in_array
(
$op
,
$_SESSION
[
'node_authlink_nodes'
][
$node
->
nid
]))
return
NODE_ACCESS_ALLOW
;
return
NODE_ACCESS_ALLOW
;
}
}
}
/**
/**
* Implement
ation of
hook_node_presave().
* Implement
s
hook_node_presave().
*
*
* Pre-generate auth key for the new node (e.g. for use in Rules).
* Pre-generate auth key for the new node (e.g. for use in Rules).
*/
*/
function
node_authlink_node_presave
(
$node
)
{
function
node_authlink_node_presave
(
$node
)
{
// Ignore if node type is disabled
// Ignore if node type is disabled
.
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
{
return
;
return
;
}
// Generate key
// Generate key
.
if
(
!
isset
(
$node
->
authkey
))
{
if
(
!
isset
(
$node
->
authkey
))
{
$node
->
authkey
=
hash
(
'sha256'
,
drupal_random_bytes
(
64
));
$node
->
authkey
=
hash
(
'sha256'
,
drupal_random_bytes
(
64
));
}
}
}
}
/**
/**
* Implement
ation of
hook_node_insert().
* Implement
s
hook_node_insert().
*
*
* Generate and save auth key for the new node.
* Generate and save auth key for the new node.
*/
*/
function
node_authlink_node_insert
(
$node
)
{
function
node_authlink_node_insert
(
$node
)
{
// Allow key generate without load node object
// Allow key generate without load node object
.
if
(
is_numeric
(
$node
))
if
(
is_numeric
(
$node
))
{
$nid
=
$node
;
$nid
=
$node
;
}
else
{
else
{
$nid
=
$node
->
nid
;
$nid
=
$node
->
nid
;
// Ignore if node type is disabled
// Ignore if node type is disabled
.
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
if
(
!
variable_get
(
'node_authlink_enable_'
.
$node
->
type
,
FALSE
))
{
return
;
return
;
}
}
}
// Generate key if not yet
// Generate key if not yet
.
$authkey
=
isset
(
$node
->
authkey
)
?
$node
->
authkey
:
hash
(
'sha256'
,
drupal_random_bytes
(
64
));
$authkey
=
isset
(
$node
->
authkey
)
?
$node
->
authkey
:
hash
(
'sha256'
,
drupal_random_bytes
(
64
));
// Save to DB
// Save to DB
.
db_insert
(
'node_authlink_nodes'
)
db_insert
(
'node_authlink_nodes'
)
->
fields
(
array
(
->
fields
(
array
(
'nid'
=>
$nid
,
'nid'
=>
$nid
,
...
@@ -249,17 +282,18 @@ function node_authlink_node_insert($node) {
...
@@ -249,17 +282,18 @@ function node_authlink_node_insert($node) {
}
}
/**
/**
* Implement
ation of
hook_cron().
* Implement
s
hook_cron().
*/
*/
function
node_authlink_cron
()
{
function
node_authlink_cron
()
{
$node_types
=
node_type_get_types
();
$node_types
=
node_type_get_types
();
foreach
(
$node_types
as
$type
)
{
foreach
(
$node_types
as
$type
)
{
$expire
=
variable_get
(
'node_authlink_expire_'
.
$type
->
type
,
0
);
$expire
=
variable_get
(
'node_authlink_expire_'
.
$type
->
type
,
0
);
if
(
!
$expire
)
if
(
!
$expire
)
{
continue
;
continue
;
}
// NIDs of expired keys
// NIDs of expired keys
.
$query
=
db_select
(
'node'
,
'n'
);
$query
=
db_select
(
'node'
,
'n'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
leftJoin
(
'node_authlink_nodes'
,
'a'
,
'n.nid = a.nid'
);
$query
->
fields
(
'n'
,
array
(
'nid'
))
$query
->
fields
(
'n'
,
array
(
'nid'
))
...
@@ -267,7 +301,7 @@ function node_authlink_cron() {
...
@@ -267,7 +301,7 @@ function node_authlink_cron() {
->
condition
(
'a.created'
,
time
()
-
$expire
,
'<'
);
->
condition
(
'a.created'
,
time
()
-
$expire
,
'<'
);
$nids
=
$query
->
execute
()
->
fetchCol
();
$nids
=
$query
->
execute
()
->
fetchCol
();
// Regenerate keys
// Regenerate keys
.
foreach
(
$nids
as
$nid
)
{
foreach
(
$nids
as
$nid
)
{
db_delete
(
'node_authlink_nodes'
)
db_delete
(
'node_authlink_nodes'
)
->
condition
(
'nid'
,
$nid
)
->
condition
(
'nid'
,
$nid
)
...
@@ -281,7 +315,7 @@ function node_authlink_cron() {
...
@@ -281,7 +315,7 @@ function node_authlink_cron() {
}
}
/**
/**
* Implement
ation of
hook_token_info().
* Implement
s
hook_token_info().
*/
*/
function
node_authlink_token_info
()
{
function
node_authlink_token_info
()
{
$node
[
'authlink:authkey'
]
=
array
(
$node
[
'authlink:authkey'
]
=
array
(
...
@@ -307,7 +341,7 @@ function node_authlink_token_info() {
...
@@ -307,7 +341,7 @@ function node_authlink_token_info() {
}
}
/**
/**
* Implement
ation of
hook_tokens().
* Implement
s
hook_tokens().
*/
*/
function
node_authlink_tokens
(
$type
,
$tokens
,
array
$data
=
array
(),
array
$options
=
array
())
{
function
node_authlink_tokens
(
$type
,
$tokens
,
array
$data
=
array
(),
array
$options
=
array
())
{
$replacements
=
array
();
$replacements
=
array
();
...
@@ -320,12 +354,15 @@ function node_authlink_tokens($type, $tokens, array $data = array(), array $opti
...
@@ -320,12 +354,15 @@ function node_authlink_tokens($type, $tokens, array $data = array(), array $opti
case
'authlink:authkey'
:
case
'authlink:authkey'
:
$replacements
[
$original
]
=
$node
->
authkey
;
$replacements
[
$original
]
=
$node
->
authkey
;
break
;
break
;
case
'authlink:view-url'
:
case
'authlink:view-url'
:
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'view'
);
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'view'
);
break
;
break
;
case
'authlink:edit-url'
:
case
'authlink:edit-url'
:
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'edit'
);
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'edit'
);
break
;
break
;
case
'authlink:delete-url'
:
case
'authlink:delete-url'
:
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'delete'
);
$replacements
[
$original
]
=
node_authlink_get_url
(
$node
,
'delete'
);
break
;
break
;
...
...
This diff is collapsed.
Click to expand it.
node_authlink.views.inc
+
4
−
4
View file @
ac92551d
...
@@ -12,11 +12,11 @@
...
@@ -12,11 +12,11 @@
*/
*/
function
node_authlink_views_data
()
{
function
node_authlink_views_data
()
{
// Table properties
// Table properties
.
$data
[
'node_authlink_nodes'
][
'table'
][
'group'
]
=
t
(
'Node Auth link'
);
$data
[
'node_authlink_nodes'
][
'table'
][
'group'
]
=
t
(
'Node Auth link'
);
$data
[
'node_authlink_nodes'
][
'table'
][
'base'
]
=
array
(
$data
[
'node_authlink_nodes'
][
'table'
][
'base'
]
=
array
(
'field'
=>
'nid'
,
// This is the identifier field for the view.
'field'
=>
'nid'
,
'title'
=>
t
(
'Node auth link nodes table'
),
'title'
=>
t
(
'Node auth link nodes table'
),
'help'
=>
t
(
'Table for store authorization keys.'
),
'help'
=>
t
(
'Table for store authorization keys.'
),
'weight'
=>
-
10
,
'weight'
=>
-
10
,
...
@@ -29,7 +29,7 @@ function node_authlink_views_data() {
...
@@ -29,7 +29,7 @@ function node_authlink_views_data() {
),
),
);
);
// Table fields
// Table fields
.
$data
[
'node_authlink_nodes'
][
'nid'
]
=
array
(
$data
[
'node_authlink_nodes'
][
'nid'
]
=
array
(
'title'
=>
t
(
'Nid'
),
'title'
=>
t
(
'Nid'
),
'help'
=>
t
(
'The node ID.'
),
'help'
=>
t
(
'The node ID.'
),
...
@@ -76,7 +76,7 @@ function node_authlink_views_data() {
...
@@ -76,7 +76,7 @@ function node_authlink_views_data() {
),
),
);
);
// Node integration
// Node integration
.
$data
[
'node'
][
'node_authlink_nodes'
]
=
array
(
$data
[
'node'
][
'node_authlink_nodes'
]
=
array
(
'title'
=>
t
(
'Nid'
),
'title'
=>
t
(
'Nid'
),
'help'
=>
t
(
'The node ID.'
),
'help'
=>
t
(
'The node ID.'
),
...
...
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