function library_update_6202 in Library 6.2
File
- ./
library.install, line 226 - @author Jess Straatmann library.install Install and uninstall all required databases. Also do incremental database updates.
Code
function library_update_6202() {
$ret = array();
if (module_exists('patron')) {
//Transfer patron info associated with users to profile fields
$patrons = db_query("SELECT * FROM {library_patrons} p, {users} u WHERE p.patron_uid = u.uid AND p.patron_uid IS NOT NULL");
if (module_exists('profile')) {
while ($patron = db_fetch_object($patrons)) {
$patron_user = user_load(array(
'uid' => $patron->patron_uid,
));
$data = array(
'profile_patron_name_last' => $patron->name_last,
'profile_patron_name_first' => $patron->name_first,
'profile_patron_barcode' => $patron->barcode,
);
$successful = user_save($patron_user, $data, 'Library');
if (!$successful) {
watchdog('Library', 'Patron conversion of @name failed', array(
'@name' => $patron->name_first . ' ' . $patron->name_last,
));
}
else {
watchdog('Library', 'Patron @name converted to profile fields.', array(
'@name' => $patron->name_first . ' ' . $patron->name_last,
));
}
}
}
}
return $ret;
}