Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mt_task
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
mt_task
Commits
5806709d
Commit
5806709d
authored
13 years ago
by
Daniel Zhou
Browse files
Options
Downloads
Patches
Plain Diff
added hook_user_view and changed access permission
parent
89724bd3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mt_task.module
+23
-13
23 additions, 13 deletions
mt_task.module
script.py
+1
-1
1 addition, 1 deletion
script.py
with
24 additions
and
14 deletions
mt_task.module
+
23
−
13
View file @
5806709d
...
...
@@ -109,29 +109,22 @@ function mt_task_form($node, $form_state) {
*/
function
mt_task_permission
()
{
$perms
=
array
(
'administer
own
mt_task'
=>
array
(
'title'
=>
t
(
'Administer
your own
Mechanical Turk tasks'
),
'description'
=>
t
(
'You need to have this permission in order to
create/admin
mt_task nodes'
),
'administer mt_task'
=>
array
(
'title'
=>
t
(
'Administer Mechanical Turk tasks'
),
'description'
=>
t
(
'You need to have this permission in order to
administer any
mt_task nodes'
),
),
);
return
$perms
;
}
function
mt_task_access
(
$task_id
)
{
if
(
user_access
(
'administer
own
mt_task'
)
!=
TRUE
)
{
if
(
user_access
(
'administer mt_task'
)
!=
TRUE
)
{
return
FALSE
;
}
$node
=
node_load
(
$task_id
);
if
(
$
node
->
type
!=
'mt_task'
)
{
if
(
!
node
_access
(
'create'
,
$node
)
&&
!
node_access
(
'edit'
,
$node
)
)
{
return
FALSE
;
}
global
$user
;
if
(
$user
->
uid
!=
$node
->
uid
)
{
return
FALSE
;
}
return
TRUE
;
}
...
...
@@ -141,7 +134,7 @@ function mt_task_access($task_id) {
/*function mt_task_node_view($node, $view_mode, $langcode) {
global $user;
# TODO: this seems redundant to node access permission. consider remove it.
if ($node->uid != $user->uid || !user_access('administer
own
mt_task')) {
if ($node->uid != $user->uid || !user_access('administer mt_task')) {
// if no permission, then do nothing.
return;
}
...
...
@@ -213,4 +206,21 @@ function mt_task_create_command($app, $task_id, $command) {
function
mt_task_cron
()
{
// by default, avoid duplicate
async_command_create_command
(
'mt_task'
,
'update_worker()'
,
array
(
'uid'
=>
0
));
}
/**
* Implements hook_user_view
*/
function
mt_task_user_view
(
$account
,
$view_mode
,
$langcode
)
{
$worker_id
=
encset_ini_get
(
$account
->
mt_properties_secure
,
'worker_id'
,
NULL
);
if
(
$view_mode
==
'full'
&&
$worker_id
!=
NULL
)
{
$account
->
content
[
'summary'
][
'mt_worker_id'
]
=
array
(
'#type'
=>
'user_profile_item'
,
'#title'
=>
t
(
'AMT Worker ID'
),
//'#description' => t('The worker ID from AMT. Only workers need to input this in the MT Properties box.'),
'#markup'
=>
$worker_id
,
//'#weight' => -1,
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
script.py
+
1
−
1
View file @
5806709d
...
...
@@ -219,7 +219,7 @@ class MTTaskApp(JythonDrupalApp):
ON u.uid=f.entity_id WHERE entity_type=
"
user
"
AND bundle=
"
user
"'
)
for
row
in
rows
:
mt_settings
=
self
.
readEncryptedSettingsField
(
row
[
'
mt_properties_secure_value
'
],
self
.
EncryptionMethod
.
MCRYPT
)
worker_id
=
mt_settings
[
'
worker_id
'
]
worker_id
=
mt_settings
[
'
worker_id
'
]
.
strip
()
if
worker_id
!=
None
:
# TODO: see #1148280 (http://drupal.org/node/1148280)
if
worker_id
in
mapping
:
...
...
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