Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
wcms-openscholar
uw_virtual_site_homepage
Commits
93774ccd
Commit
93774ccd
authored
Jan 13, 2017
by
Lily Yan
Browse files
FDSU-1805 Convert old faculty field value to new faculty field and remove old faculty field.
parent
4221b3f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
43 deletions
+46
-43
uw_virtual_site_homepage.install
uw_virtual_site_homepage.install
+46
-43
No files found.
uw_virtual_site_homepage.install
View file @
93774ccd
...
...
@@ -208,47 +208,50 @@ function uw_virtual_site_homepage_update_7101() {
if
(
db_table_exists
(
'field_data_field_uw_faculty'
)
&&
db_table_exists
(
'field_data_field_uw_faculty_list'
))
{
$result
=
db_select
(
'field_data_field_uw_faculty'
,
'f'
)
->
fields
(
'f'
)
->
condition
(
'bundle'
,
'uw_virtual_site_homepage'
,
'='
)
->
execute
()
->
fetchA
ssoc
();
$faculty
=
$result
[
'field_uw_faculty_value'
];
$faculty_value
=
_get_faculty_list_value
(
$faculty
);
$data
=
array
(
'entity_type'
=>
'nod
e'
,
'bundle'
=>
'uw_virtual_site_homepage'
,
'deleted'
=>
0
,
'entity_id'
=>
$result
[
'entity
_id
'
]
,
'revision_id'
=>
$result
[
'revision_i
d'
]
,
'language'
=>
'und'
,
'delta'
=>
0
,
'field_uw_faculty_list_value'
=>
$faculty_value
,
);
drupal_write_record
(
'field_data_field_uw_faculty_list'
,
$data
);
->
fetchA
ll
();
foreach
(
$result
as
$item
)
{
$faculty_value
=
_get_faculty_list_value
(
$
item
->
field_uw_
faculty
_value
);
$data
=
array
(
'entity_type'
=>
'node'
,
'bundle'
=>
'uw_virtual_site_homepag
e'
,
'deleted'
=>
0
,
'entity_id'
=>
$item
->
entity_id
,
'revision_id'
=>
$item
->
revision
_id
,
'language'
=>
'un
d'
,
'delta'
=>
0
,
'field_uw_faculty_list_value'
=>
$faculty_value
,
);
drupal_write_record
(
'field_data_field_uw_faculty_list'
,
$data
);
}
}
// Convert the value from field_revision_field_uw_faculty to field_revision_field_uw_faculty_list.
if
(
db_table_exists
(
'field_revision_field_uw_faculty'
)
&&
db_table_exists
(
'field_revision_field_uw_faculty_list'
))
{
$result2
=
db_select
(
'field_revision_field_uw_faculty'
,
'f'
)
->
fields
(
'f'
)
->
condition
(
'bundle'
,
'uw_virtual_site_homepage'
,
'='
)
->
execute
()
->
fetchA
ssoc
();
$faculty2
=
$result2
[
'field_uw_faculty_value'
];
$faculty_value2
=
_get_faculty_list_value
(
$faculty
2
);
$data
=
array
(
'entity_type'
=>
'nod
e'
,
'bundle'
=>
'uw_virtual_site_homepage'
,
'deleted'
=>
0
,
'entity_id'
=>
$result
[
'entity
_id
'
]
,
'revision_id'
=>
$result
[
'revision_i
d'
]
,
'language'
=>
'und'
,
'delta'
=>
0
,
'field_uw_faculty_list_value'
=>
$faculty_value2
,
);
drupal_write_record
(
'field_revision_field_uw_faculty_list'
,
$data
);
->
fetchA
ll
();
foreach
(
$result2
as
$item2
)
{
$faculty_value2
=
_get_faculty_list_value
(
$
item2
->
field_uw_
faculty
_value
);
$data2
=
array
(
'entity_type'
=>
'node'
,
'bundle'
=>
'uw_virtual_site_homepag
e'
,
'deleted'
=>
0
,
'entity_id'
=>
$item2
->
entity_id
,
'revision_id'
=>
$item2
->
revision
_id
,
'language'
=>
'un
d'
,
'delta'
=>
0
,
'field_uw_faculty_list_value'
=>
$faculty_value2
,
);
drupal_write_record
(
'field_revision_field_uw_faculty_list'
,
$data2
);
}
}
drupal_set_message
(
t
(
"Converted the value from the old faculty field to the new faculty field for the existing hompage setting node."
));
// Delete or remove field_uw_faculty field from uw_virtual_site_homepage content type.
...
...
@@ -264,47 +267,47 @@ function uw_virtual_site_homepage_update_7101() {
*/
function
_get_faculty_list_value
(
$field_uw_faculty
)
{
$faculty_name
=
strtolower
(
$field_uw_faculty
);
if
(
strpos
(
$faculty_name
,
'waterloo'
)
!==
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
university of
waterloo'
)
!==
FALSE
)
{
$faculty_list_value
=
'default'
;
}
if
(
strpos
(
$faculty_name
,
'
applied
'
)
!==
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
faculty of applied health sciences
'
)
!==
FALSE
)
{
$faculty_list_value
=
'ahs'
;
}
if
(
strpos
(
$faculty_name
,
'arts'
)
!==
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'faculty of arts'
)
!==
FALSE
||
strpos
(
$faculty_name
,
'arts'
)
!==
FALSE
)
{
$faculty_list_value
=
'arts'
;
}
if
(
strpos
(
$faculty_name
,
'engineering'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
faculty of
engineering'
)
!=
=
FALSE
||
strpos
(
$faculty_name
,
'engineering'
)
!==
FALSE
)
{
$faculty_list_value
=
'engineering'
;
}
if
(
strpos
(
$faculty_name
,
'environment'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
faculty of
environment'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'environment'
;
}
if
(
strpos
(
$faculty_name
,
'
math
'
)
!=
FALSE
||
strpos
(
$faculty_name
,
'maths'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
faculty of mathematics
'
)
!=
=
FALSE
||
strpos
(
$faculty_name
,
'math
ematic
s'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'math'
;
}
if
(
strpos
(
$faculty_name
,
'science'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
faculty of
science'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'science'
;
}
if
(
strpos
(
$faculty_name
,
'conrad
'
)
!=
FALSE
||
strpos
(
$faculty_name
,
'grebel
'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'conrad
grebel university college
'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'cgc'
;
}
if
(
strpos
(
$faculty_name
,
'renison'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'renison
university college
'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'ren'
;
}
if
(
strpos
(
$faculty_name
,
'jerome'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
st.
jerome'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'stj'
;
}
if
(
strpos
(
$faculty_name
,
'paul'
)
!=
FALSE
)
{
if
(
strpos
(
$faculty_name
,
'
st.
paul'
)
!=
=
FALSE
)
{
$faculty_list_value
=
'stp'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment