Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
menu_token
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
menu_token
Commits
fd16e977
Commit
fd16e977
authored
Apr 25, 2011
by
vadim
Browse files
Options
Downloads
Patches
Plain Diff
#1087212
by dealancer: changed way of performing update
parent
6a2fd673
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
menu_token.install
+39
-17
39 additions, 17 deletions
menu_token.install
with
39 additions
and
17 deletions
menu_token.install
+
39
−
17
View file @
fd16e977
...
...
@@ -52,25 +52,47 @@ function menu_token_uninstall() {
* Implementation of hook_update_N().
*/
function
menu_token_update_6000
()
{
$ret
=
drupal_install_schema
(
'menu_token'
);
drupal_get_schema
(
NULL
,
TRUE
);
return
$ret
;
}
/**
* Implementation of hook_update_N().
*/
function
menu_token_update_6001
()
{
$ret
=
array
();
$schema
[
'menu_token'
]
=
array
(
'description'
=>
t
(
'Menu token properties'
),
'fields'
=>
array
(
'mlid'
=>
array
(
'description'
=>
t
(
'The menu link {menu_links}.mlid'
),
'type'
=>
'int'
,
'unsigned'
=>
TRUE
,
'not null'
=>
TRUE
,
),
'link_path'
=>
array
(
'description'
=>
t
(
'The actual path with tokens'
),
'type'
=>
'varchar'
,
'length'
=>
255
,
'not null'
=>
TRUE
,
'default'
=>
''
,
),
),
'primary key'
=>
array
(
'mlid'
),
'indexes'
=>
array
(
'mlid'
=>
array
(
'mlid'
),
),
);
// create schema
db_create_table
(
$ret
,
'menu_token'
,
$schema
[
'menu_token'
]);
// ibsert records
foreach
(
variable_get
(
'menu_token_enabled'
,
array
())
as
$mlid
=>
$link_path
)
{
$item
=
(
object
)
array
(
'mlid'
=>
$mlid
,
'link_path'
=>
$link_path
);
$status
=
drupal_write_record
(
'menu_token'
,
$item
);
if
(
!
$status
)
{
$ret
[
'#abort'
]
=
array
(
'success'
=>
FALSE
,
'query'
=>
'Could not add records to databse'
);
return
$ret
;
$link_path
=
db_escape_string
(
$link_path
);
$ret
[]
=
update_sql
(
"INSERT INTO
{
menu_token
}
(mlid, link_path) VALUES (
$mlid
, '
$link_path
')"
);
}
unset
(
$item
);
// delete variable in case of all queries were successful
$success
=
true
;
foreach
(
$ret
as
$r
)
{
$success
=
$success
&&
$r
[
'success'
];
}
if
(
$success
)
{
variable_del
(
'menu_token_enabled'
);
}
return
$ret
;
}
\ No newline at end of file
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