| 96 |
* @return array $items An array of menu items |
* @return array $items An array of menu items |
| 97 |
*/ |
*/ |
| 98 |
function nf_handshake_perm() { |
function nf_handshake_perm() { |
| 99 |
return array('administer handshakes', 'intitiate handshake', 'accept handshake', 'view own handshakes', 'view handshakes'); |
return array('administer handshakes', 'intitiate handshake', 'accept handshake', 'view own handshakes', 'view handshakes', 'bypass handshakes'); |
| 100 |
} // function nf_handshake_perm() |
} // function nf_handshake_perm() |
| 101 |
|
|
| 102 |
/** |
/** |
| 601 |
} |
} |
| 602 |
} |
} |
| 603 |
|
|
| 604 |
|
/** |
| 605 |
|
* Implementation of hook_user. We need to respond to users being deleted and delete their entries from our tables |
| 606 |
|
* in order to prevent orphan handshakes. |
| 607 |
|
* |
| 608 |
|
* @param string $op What kind of action is being performed. |
| 609 |
|
* @param array $edit The array of form values submitted by the user. |
| 610 |
|
* @param array $account The user object on which the operation is being performed. |
| 611 |
|
* @param string $category The active category of user information being edited. |
| 612 |
|
*/ |
| 613 |
|
function nf_handshake_user($op, &$edit, &$account, $category = NULL) { |
| 614 |
|
switch($op) { |
| 615 |
|
case 'delete': |
| 616 |
|
$uid = $account->uid; |
| 617 |
|
$sql = "DELETE FROM {nf_handshake} WHERE auid = %d OR iuid = %d"; |
| 618 |
|
$sql2 = "DELETE FROM {nf_handshake_manage} WHERE auid = %d OR iuid = %d"; |
| 619 |
|
dq_query($sql, $uid); |
| 620 |
|
dq_query($sql2, $uid); |
| 621 |
|
break; |
| 622 |
|
} |
| 623 |
|
} |
| 624 |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
| 625 |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
| 626 |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
//-----------------------------------------Administrative Hooks and Functions----------------------------------------- |
| 647 |
$type = $split_value[0]; |
$type = $split_value[0]; |
| 648 |
$type_name = $all_nodeprofiles[$type]; |
$type_name = $all_nodeprofiles[$type]; |
| 649 |
$field_name = $split_value[1]; |
$field_name = $split_value[1]; |
| 650 |
$rows[] = array('<em>' .$type_name. '</em>', $field_name); |
if ($type == 'Users table') { |
| 651 |
unset($selected_cck_fields[$type][$field_name]); |
$rows[] = array('<strong><em>' .$type. '</em><strong>', $field_name); |
| 652 |
|
unset($selected_cck_fields['Users_table'][$field_name]); |
| 653 |
|
} |
| 654 |
|
else { |
| 655 |
|
$rows[] = array('<em>' .$type_name. '</em>', $field_name); |
| 656 |
|
unset($selected_cck_fields[$type][$field_name]); |
| 657 |
|
} |
| 658 |
if (empty($selected_cck_fields[$type])) { |
if (empty($selected_cck_fields[$type])) { |
| 659 |
unset($selected_cck_fields[$type]); |
unset($selected_cck_fields[$type]); |
| 660 |
} |
} |
| 673 |
if (!empty($selected_cck_fields)) { |
if (!empty($selected_cck_fields)) { |
| 674 |
$rows = array(); |
$rows = array(); |
| 675 |
foreach ($selected_cck_fields as $type => $set) { |
foreach ($selected_cck_fields as $type => $set) { |
| 676 |
$type_name = $all_nodeprofiles[$type]; |
if ($type == 'Users_table') { |
| 677 |
foreach ($set as $key => $value) { |
foreach ($set as $key => $value) { |
| 678 |
$rows[] = array('<em>' .$type_name. '</em>', $value); |
$rows[] = array('<strong><em>Users table</em></strong>', $value); |
| 679 |
|
} |
| 680 |
|
} |
| 681 |
|
else { |
| 682 |
|
$type_name = $all_nodeprofiles[$type]; |
| 683 |
|
foreach ($set as $key => $value) { |
| 684 |
|
$rows[] = array('<em>' .$type_name. '</em>', $value); |
| 685 |
|
} |
| 686 |
} |
} |
| 687 |
} |
} |
| 688 |
$output .= theme('table', $header, $rows); |
$output .= theme('table', $header, $rows); |
| 691 |
else { |
else { |
| 692 |
$rows = array(); |
$rows = array(); |
| 693 |
foreach ($selected_cck_fields as $type => $set) { |
foreach ($selected_cck_fields as $type => $set) { |
| 694 |
$type_name = $all_nodeprofiles[$type]; |
if ($type == 'Users_table') { |
| 695 |
foreach ($set as $key => $value) { |
foreach ($set as $key => $value) { |
| 696 |
$rows[] = array('<em>' .$type_name. '</em>', $value); |
$rows[] = array('<strong><em>Users table</em></strong>', $value); |
| 697 |
|
} |
| 698 |
|
} |
| 699 |
|
else { |
| 700 |
|
$type_name = $all_nodeprofiles[$type]; |
| 701 |
|
foreach ($set as $key => $value) { |
| 702 |
|
$rows[] = array('<em>' .$type_name. '</em>', $value); |
| 703 |
|
} |
| 704 |
} |
} |
| 705 |
} |
} |
| 706 |
$output .= theme('table', $header, $rows); |
$output .= theme('table', $header, $rows); |
| 731 |
} |
} |
| 732 |
} |
} |
| 733 |
} |
} |
| 734 |
|
//add user photo and email address from users table to $all_cck_fields |
| 735 |
|
if (!(key_exists('Users_table', $added_cck_fields) && key_exists('mail', $added_cck_fields['Users_table']))) { |
| 736 |
|
$all_cck_fields['Users_table']['mail'] = 'mail'; |
| 737 |
|
} |
| 738 |
|
if (!(key_exists('Users_table', $added_cck_fields) && key_exists('picture', $added_cck_fields['Users_table']))) { |
| 739 |
|
$all_cck_fields['Users_table']['picture'] = 'picture'; |
| 740 |
|
} |
| 741 |
$form['cck_fields'] = array( |
$form['cck_fields'] = array( |
| 742 |
'#type' => 'select', |
'#type' => 'select', |
| 743 |
'#title' => t('Add profile-related CCK fields'), |
'#title' => t('Add profile-related CCK fields'), |
| 769 |
if ($form_values['op'] == t('Add CCK field')) { |
if ($form_values['op'] == t('Add CCK field')) { |
| 770 |
$selection = explode('::', $form_values['cck_fields']); |
$selection = explode('::', $form_values['cck_fields']); |
| 771 |
$added_cck_fields = _nf_handshake_get_cckfieldnames(); |
$added_cck_fields = _nf_handshake_get_cckfieldnames(); |
| 772 |
$added_cck_fields[$selection[0]][$selection[1]] = $selection[1]; |
if (isset($selection[1])) { |
| 773 |
|
$added_cck_fields[$selection[0]][$selection[1]] = $selection[1]; |
| 774 |
|
} |
| 775 |
|
else { |
| 776 |
|
$added_cck_fields['Users_table'][$selection[0]] = $selection[0]; |
| 777 |
|
} |
| 778 |
variable_set('nf_handshake_cckfieldnames', $added_cck_fields); |
variable_set('nf_handshake_cckfieldnames', $added_cck_fields); |
| 779 |
drupal_set_message(t('The CCK field list has been updated.')); |
drupal_set_message(t('The CCK field list has been updated.')); |
| 780 |
} |
} |
| 795 |
$rows = array(); |
$rows = array(); |
| 796 |
if (!empty($selected_cck_fields)) { |
if (!empty($selected_cck_fields)) { |
| 797 |
foreach ($selected_cck_fields as $type => $set) { |
foreach ($selected_cck_fields as $type => $set) { |
| 798 |
$type_name = $all_nodeprofiles[$type]; |
if ($type == 'Users_table') { |
| 799 |
foreach ($set as $key => $value) { |
foreach ($set as $key => $value) { |
| 800 |
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_cck_fields/' .$type. '::' .$value); |
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_cck_fields/' .$type. '::' .$value); |
| 801 |
$rows[] = array('<em>' .$type_name. '</em>', $value, $delete); |
$rows[] = array('<strong><em>Users table</em></strong>', $value, $delete); |
| 802 |
|
} |
| 803 |
|
} |
| 804 |
|
else { |
| 805 |
|
$type_name = $all_nodeprofiles[$type]; |
| 806 |
|
foreach ($set as $key => $value) { |
| 807 |
|
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_cck_fields/' .$type. '::' .$value); |
| 808 |
|
$rows[] = array('<em>' .$type_name. '</em>', $value, $delete); |
| 809 |
|
} |
| 810 |
} |
} |
| 811 |
} |
} |
| 812 |
} |
} |
| 890 |
'#description' => t('This allows you to group logical fields together for exchange as a group. See the README for details.'), |
'#description' => t('This allows you to group logical fields together for exchange as a group. See the README for details.'), |
| 891 |
); |
); |
| 892 |
$not_field_options = array(); |
$not_field_options = array(); |
| 893 |
|
$field_options = array(); |
| 894 |
foreach ($all_groups as $group => $types) { |
foreach ($all_groups as $group => $types) { |
| 895 |
if (!empty($types)) { |
if (!empty($types)) { |
| 896 |
foreach ($types as $type => $field) { |
foreach ($types as $type => $field) { |
| 903 |
if (!empty($the_rest)) { |
if (!empty($the_rest)) { |
| 904 |
foreach ($the_rest as $field => $val) { |
foreach ($the_rest as $field => $val) { |
| 905 |
if (!key_exists($type. '::' .$val, $not_field_options)) { |
if (!key_exists($type. '::' .$val, $not_field_options)) { |
| 906 |
$field_options[$type. '::' .$val] = $all_nodeprofiles[$type]. '::' .$val; |
if ($type == 'Users_table') { |
| 907 |
|
$field_options[$type. '::' .$val] = 'Users table::' .$val; |
| 908 |
|
} |
| 909 |
|
else { |
| 910 |
|
$field_options[$type. '::' .$val] = $all_nodeprofiles[$type]. '::' .$val; |
| 911 |
|
} |
| 912 |
} |
} |
| 913 |
} |
} |
| 914 |
} |
} |
| 915 |
} |
} |
|
if (empty($field_options)) { |
|
|
$field_options = array(); |
|
|
} |
|
| 916 |
foreach ($all_groups as $group => $types) { |
foreach ($all_groups as $group => $types) { |
| 917 |
$form[$group] = array( |
$form[$group] = array( |
| 918 |
'#tree' => TRUE, |
'#tree' => TRUE, |
| 991 |
$exp_val = explode('::', $value); |
$exp_val = explode('::', $value); |
| 992 |
$type = $exp_val[0]; |
$type = $exp_val[0]; |
| 993 |
$val = $exp_val[1]; |
$val = $exp_val[1]; |
| 994 |
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_group/' .$group. '/' .$value); |
if ($exp_val[0] == 'Users table') { |
| 995 |
$rows[] = array($all_nodeprofiles[$type]. '::' .$val, $delete); |
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_group/' .$group. '/Users_table::' .$val); |
| 996 |
|
$rows[] = array('Users table::' .$val, $delete); |
| 997 |
|
} |
| 998 |
|
else { |
| 999 |
|
$delete = l(t('delete'), 'admin/user/nf_handshake/delete_group/' .$group. '/' .$value); |
| 1000 |
|
$rows[] = array($all_nodeprofiles[$type]. '::' .$val, $delete); |
| 1001 |
|
} |
| 1002 |
} |
} |
| 1003 |
} |
} |
| 1004 |
$edit = l(t('edit group'), 'admin/user/nf_handshake/edit_group/' .$group); |
$edit = l(t('edit group'), 'admin/user/nf_handshake/edit_group/' .$group); |
| 1236 |
$form['settings']['no_admin'] = array( |
$form['settings']['no_admin'] = array( |
| 1237 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 1238 |
'#title' => t('Exclude user 1 from handshakes'), |
'#title' => t('Exclude user 1 from handshakes'), |
| 1239 |
'#default_value' => 1, |
'#default_value' => isset($values['no_admin']) ? $values['no_admin'] : 1, |
| 1240 |
'#description' => t('This prevents users from making a handshake with the administrator. They may contact the admin via the site\'s contact form.') |
'#description' => t('This prevents users from making a handshake with the administrator. They may contact the admin via the site\'s contact form.') |
| 1241 |
); |
); |
| 1242 |
$form['settings']['no_admin_role'] = array( |
$form['settings']['no_admin_role'] = array( |
| 1243 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 1244 |
'#title' => t('Exclude users with the <em>administer handshakes</em> role from handshakes'), |
'#title' => t('Exclude users with the <em>administer handshakes</em> role from handshakes'), |
| 1245 |
'#default_value' => 1, |
'#default_value' => isset($values['no_admin_role']) ? $values['no_admin_role'] : 1, |
| 1246 |
'#description' => t('This prevents users from making a handshake with administrators that are not user 1. This would occur in the case where the site is |
'#description' => t('This prevents users from making a handshake with administrators that are not user 1. This would occur in the case where the site is |
| 1247 |
able to employ additional help and/or when the site is run by someone other than the person that sets things up. Users with this permission and this box checked |
able to employ additional help and/or when the site is run by someone other than the person that sets things up. Users with this permission and this box checked |
| 1248 |
are assumed to not interact with other users as a normal user. If that is not the case, you may want to create two accounts for that user - a regular, and an |
are assumed to not interact with other users as a normal user. If that is not the case, you may want to create two accounts for that user - a regular, and an |
| 1553 |
* Replace the standard call to user_view (see menu item above). |
* Replace the standard call to user_view (see menu item above). |
| 1554 |
* |
* |
| 1555 |
* If the user is an admin or is trying to view his own profile, call user_view so it's shown to him like normal. |
* If the user is an admin or is trying to view his own profile, call user_view so it's shown to him like normal. |
| 1556 |
|
* If admin 1 or a user with 'administer users' permission tries to view a profile, and admins aren't forbidden |
| 1557 |
|
* from shaking hands, append the handshake form/data to the top of the user profile depending on state of the |
| 1558 |
|
* handshake. |
| 1559 |
* Otherwise, check if the current user has previously shaken hands with the user whose profile he's trying to |
* Otherwise, check if the current user has previously shaken hands with the user whose profile he's trying to |
| 1560 |
* view. If so and it was accepted, present the exposed data. If so and if the request is pending or some other |
* view. If so and it was accepted, present the exposed data. If so and if the request is pending or some other |
| 1561 |
* intermediate condition exists, show what that condition is. If no handshake has been made, present the user |
* intermediate condition exists, show what that condition is. If no handshake has been made, present the user |
| 1567 |
*/ |
*/ |
| 1568 |
function nf_handshake_view_user($uid = 0) { |
function nf_handshake_view_user($uid = 0) { |
| 1569 |
global $user; |
global $user; |
| 1570 |
if ($user->uid == 1 || $user->uid == $uid || user_access('administer users')) { |
$values = variable_get('nf_handshake_settings', array()); |
| 1571 |
|
$no_admin = $values['no_admin']; |
| 1572 |
|
$no_admin_role = $values['no_admin_role']; |
| 1573 |
|
//users can't shake hands with themselves |
| 1574 |
|
if ($user->uid == $uid) { |
| 1575 |
return user_view($uid); |
return user_view($uid); |
| 1576 |
} |
} |
| 1577 |
|
//admins can shake hands if the box(es) are unchecked in the Misc Settings page of the Handshake settings. |
| 1578 |
|
elseif (($user->uid == 1 && $no_admin == 0) || (user_access('administer users') && $no_admin_role == 0)) { |
| 1579 |
|
$sql = "SELECT * FROM {nf_handshake} WHERE (auid = %d AND iuid = %d) OR (auid = %d AND iuid = %d)"; |
| 1580 |
|
$result = db_fetch_object(db_query($sql, $uid, $user->uid, $user->uid, $uid)); |
| 1581 |
|
//if we have shaken hands with this person, show exposed fields - make sure there isn't a rejection, pending, expired, reviewed, or flagged status |
| 1582 |
|
if ($result && (($result->hstatus == NFHANDSHAKE_ACCEPTED) || ($result->hstatus == NFHANDSHAKE_UPGRADE_REQUESTED) || (($result->hstatus == NFHANDSHAKE_EXTENSION_REQUESTED) && (time() < $result->duration)))) { |
| 1583 |
|
return nf_handshake_view_user_data($uid) . user_view($uid); |
| 1584 |
|
} |
| 1585 |
|
//if we get a hit, but it isn't accepted |
| 1586 |
|
elseif ($result && $result->hstatus != NFHANDSHAKE_ACCEPTED) { |
| 1587 |
|
if ($result->hstatus == NFHANDSHAKE_EXPIRED) { |
| 1588 |
|
//if handshake expired, both parties can try again |
| 1589 |
|
return drupal_get_form('nf_handshake_initiate_or_contact', $user->uid, $uid) . user_view($uid); |
| 1590 |
|
} |
| 1591 |
|
elseif ($result->hstatus == NFHANDSHAKE_REJECTED && $result->auid == $user->uid) { |
| 1592 |
|
//give auid a chance to change their mind in the case where they rejected a handshake |
| 1593 |
|
return drupal_goto('user/' .$user->uid. '/nf_handshake/view_hsr/' .$result->iuid) . user_view($uid); |
| 1594 |
|
} |
| 1595 |
|
else { |
| 1596 |
|
return nf_handshake_view_denied($result->hstatus, $uid) . user_view($uid); |
| 1597 |
|
} |
| 1598 |
|
} |
| 1599 |
|
//otherwise, show handshake request form |
| 1600 |
|
else { |
| 1601 |
|
return drupal_get_form('nf_handshake_initiate_or_contact', $user->uid, $uid) . user_view($uid); |
| 1602 |
|
} |
| 1603 |
|
} |
| 1604 |
|
//deal with regular users' handshakes |
| 1605 |
else { |
else { |
| 1606 |
$sql = "SELECT * FROM {nf_handshake} WHERE (auid = %d AND iuid = %d) OR (auid = %d AND iuid = %d)"; |
$sql = "SELECT * FROM {nf_handshake} WHERE (auid = %d AND iuid = %d) OR (auid = %d AND iuid = %d)"; |
| 1607 |
$result = db_fetch_object(db_query($sql, $uid, $user->uid, $user->uid, $uid)); |
$result = db_fetch_object(db_query($sql, $uid, $user->uid, $user->uid, $uid)); |
| 1790 |
foreach ($fields as $type => $the_rest) { |
foreach ($fields as $type => $the_rest) { |
| 1791 |
if (!empty($the_rest)) { |
if (!empty($the_rest)) { |
| 1792 |
foreach ($the_rest as $field => $val) { |
foreach ($the_rest as $field => $val) { |
| 1793 |
if (!key_exists($type. '::' .$val, $not_options)) { |
if ($type == 'Users_table') { |
| 1794 |
$val2 = substr($val, 6); |
if (!key_exists($type. '::' .$val, $not_options)) { |
| 1795 |
$val2 = ucfirst($val2); |
$val2 = ucfirst($val); |
| 1796 |
$options[$type. '::' .$val] = $val2; |
$options[$type. '::' .$val] = $val2; |
| 1797 |
|
} |
| 1798 |
|
} |
| 1799 |
|
else { |
| 1800 |
|
if (!key_exists($type. '::' .$val, $not_options)) { |
| 1801 |
|
$val2 = substr($val, 6); |
| 1802 |
|
$val2 = ucfirst($val2); |
| 1803 |
|
$options[$type. '::' .$val] = $val2; |
| 1804 |
|
} |
| 1805 |
} |
} |
| 1806 |
} |
} |
| 1807 |
} |
} |
| 2004 |
//determine which types the user has created nodes for; hold on to the node data for those types they've created. |
//determine which types the user has created nodes for; hold on to the node data for those types they've created. |
| 2005 |
$all_fields = _nf_handshake_get_cckfieldnames(); |
$all_fields = _nf_handshake_get_cckfieldnames(); |
| 2006 |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
| 2007 |
|
$sql7 = "SELECT u.mail, u.picture FROM {users} u WHERE u.uid = %d"; |
| 2008 |
foreach ($all_fields as $type => $field) { |
foreach ($all_fields as $type => $field) { |
| 2009 |
$results = db_query($sql, $form['handshake']['from']['#value'], $type); |
if ($type == 'Users_table') { |
| 2010 |
|
$results = db_query($sql7, $form['handshake']['from']['#value']); |
| 2011 |
|
} |
| 2012 |
|
else { |
| 2013 |
|
$results = db_query($sql, $form['handshake']['from']['#value'], $type); |
| 2014 |
|
} |
| 2015 |
if (db_num_rows($results) > 1) { |
if (db_num_rows($results) > 1) { |
| 2016 |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
| 2017 |
return ''; |
return ''; |
| 2032 |
//locate the user's data |
//locate the user's data |
| 2033 |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
| 2034 |
foreach ($all_fields as $type => $the_rest) { |
foreach ($all_fields as $type => $the_rest) { |
| 2035 |
$type_data = content_types($type); |
if ($type == 'Users_table') { |
| 2036 |
foreach ($the_rest as $key => $value) { |
$user_data_location[$type] = $user_types[$type]; |
| 2037 |
if ($user_types[$type] != NULL) { |
} |
| 2038 |
$result = db_fetch_object(db_query($sql2, $value)); |
else { |
| 2039 |
$field = $type_data['fields'][$value]; |
$type_data = content_types($type); |
| 2040 |
$storage = content_database_info($field); |
foreach ($the_rest as $key => $value) { |
| 2041 |
$user_data_location[$type][$key] = $storage; |
if ($user_types[$type] != NULL) { |
| 2042 |
|
$result = db_fetch_object(db_query($sql2, $value)); |
| 2043 |
|
$field = $type_data['fields'][$value]; |
| 2044 |
|
$storage = content_database_info($field); |
| 2045 |
|
$user_data_location[$type][$key] = $storage; |
| 2046 |
|
} |
| 2047 |
} |
} |
| 2048 |
} |
} |
| 2049 |
} |
} |
| 2050 |
//retrieve the user's data and place it in rows |
//retrieve the user's data and place it in rows |
| 2051 |
foreach ($user_data_location as $type => $field_name) { |
foreach ($user_data_location as $type => $field_name) { |
| 2052 |
foreach ($field_name as $key => $value) { |
foreach ($field_name as $key => $value) { |
| 2053 |
foreach ($value as $key2 => $value2) { |
if ($type == 'Users_table') { |
| 2054 |
$table = $value['table']; |
$user_data[$type][$key][$key] = $value; |
| 2055 |
if ($key2 == 'columns') { |
} |
| 2056 |
foreach ($value2 as $column_readable => $column_array) { |
else { |
| 2057 |
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
foreach ($value as $key2 => $value2) { |
| 2058 |
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
$table = $value['table']; |
| 2059 |
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
if ($key2 == 'columns') { |
| 2060 |
|
foreach ($value2 as $column_readable => $column_array) { |
| 2061 |
|
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
| 2062 |
|
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
| 2063 |
|
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
| 2064 |
|
} |
| 2065 |
} |
} |
| 2066 |
} |
} |
| 2067 |
} |
} |
| 2071 |
if (strstr($key4, '::')) { |
if (strstr($key4, '::')) { |
| 2072 |
$data_text = ''; |
$data_text = ''; |
| 2073 |
$exp_val = explode('::', $key4); |
$exp_val = explode('::', $key4); |
| 2074 |
if (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
if ($exp_val[0] == 'Users_table') { |
| 2075 |
|
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
| 2076 |
|
if (!empty($data)) { |
| 2077 |
|
if ($column == 'picture') { |
| 2078 |
|
$data_text .= theme('image', $data) .'<br />'; |
| 2079 |
|
} |
| 2080 |
|
else { |
| 2081 |
|
$data_text .= $data. '<br />'; |
| 2082 |
|
} |
| 2083 |
|
} |
| 2084 |
|
} |
| 2085 |
|
if ($data_text == '') { |
| 2086 |
|
$data_text .= t('<strong>No Value Entered</strong>'); |
| 2087 |
|
$form['handshake']['fields'][$key4]['#attributes'] = array('disabled' => 1); |
| 2088 |
|
$form['handshake']['fields'][$key4]['#return_value'] = 'NULL'; |
| 2089 |
|
} |
| 2090 |
|
} |
| 2091 |
|
elseif (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
| 2092 |
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
| 2093 |
if (!empty($data)) { |
if (!empty($data)) { |
| 2094 |
$data_text .= $data. '<br />'; |
$data_text .= $data. '<br />'; |
| 2162 |
|
|
| 2163 |
} |
} |
| 2164 |
$rows[] = array(array('data' => drupal_render($form['handshake']['fields'][$key4]), 'width' => '35%'), array('data' => $data_text, 'width' => '*')); |
$rows[] = array(array('data' => drupal_render($form['handshake']['fields'][$key4]), 'width' => '35%'), array('data' => $data_text, 'width' => '*')); |
|
|
|
| 2165 |
} |
} |
| 2166 |
} |
} |
| 2167 |
} |
} |
| 2183 |
* |
* |
| 2184 |
* @return array $form The form to be rendered. |
* @return array $form The form to be rendered. |
| 2185 |
*/ |
*/ |
| 2186 |
function nf_handshake_inbox() {//TODO after makning cron jobs for admin flag changes, also adjust the message that says "nothing to do at this time" to show decisions |
function nf_handshake_inbox() {//TODO after making cron jobs for admin flag changes, also adjust the message that says "nothing to do at this time" to show decisions |
| 2187 |
global $user; |
global $user; |
| 2188 |
//--------------------------Deal with all cases for which the user is the auid first and put them in an inbox-------------------------------- |
//--------------------------Deal with all cases for which the user is the auid first and put them in an inbox-------------------------------- |
| 2189 |
$new_num = nf_handshake_get_new_handshake_requests($user->uid); |
$new_num = nf_handshake_get_new_handshake_requests($user->uid); |
| 2306 |
*/ |
*/ |
| 2307 |
function theme_nf_handshake_inbox($form) { |
function theme_nf_handshake_inbox($form) { |
| 2308 |
global $user; |
global $user; |
| 2309 |
|
drupal_add_css(drupal_get_path('module', 'nf_handshake') .'/nf_handshake.css', 'module', 'all', FALSE); |
| 2310 |
$output = ''; |
$output = ''; |
| 2311 |
$output1 = ''; |
$output1 = ''; |
| 2312 |
$rows = array(); |
$rows = array(); |
| 2318 |
array('data' => t('Date Initiated'), 'field' => 'datestamp'), |
array('data' => t('Date Initiated'), 'field' => 'datestamp'), |
| 2319 |
array('data' => t('From Username'), 'field' => 'name'), |
array('data' => t('From Username'), 'field' => 'name'), |
| 2320 |
t('Stated Purpose'), t('Operation')); |
t('Stated Purpose'), t('Operation')); |
| 2321 |
$rows[] = array(array('data' => t('<em>These are the handshake requests you are currently working with or which need your attention.</em>'), 'colspan' => 5)); |
$rows[] = array(array('data' => t('<em>These are the handshake requests you are currently working with or which need your attention.</em>'), 'colspan' => 5, 'id' => 'handshake-attention')); |
| 2322 |
if (!empty($form['new'])) { |
if (!empty($form['new'])) { |
| 2323 |
foreach (element_children($form['new']) as $key) { |
foreach (element_children($form['new']) as $key) { |
| 2324 |
$obj = $form['new'][$key]['#value']; |
$obj = $form['new'][$key]['#value']; |
| 2333 |
} |
} |
| 2334 |
} |
} |
| 2335 |
else { |
else { |
| 2336 |
$rows[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 5)); |
$rows[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 5, 'id' => 'handshake-no-new')); |
| 2337 |
} |
} |
| 2338 |
if (!empty($form['unanswered'])) { |
if (!empty($form['unanswered'])) { |
| 2339 |
foreach (element_children($form['unanswered']) as $key) { |
foreach (element_children($form['unanswered']) as $key) { |
| 2349 |
} |
} |
| 2350 |
} |
} |
| 2351 |
else { |
else { |
| 2352 |
$rows[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 5)); |
$rows[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 5, 'id' => 'handshake-no-reviewed')); |
| 2353 |
} |
} |
| 2354 |
if (!empty($form['flagged'])) { |
if (!empty($form['flagged'])) { |
| 2355 |
foreach (element_children($form['flagged']) as $key) { |
foreach (element_children($form['flagged']) as $key) { |
| 2374 |
} |
} |
| 2375 |
} |
} |
| 2376 |
else { |
else { |
| 2377 |
$rows[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 5)); |
$rows[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 5, 'id' => 'handshake-no-flagged')); |
| 2378 |
} |
} |
| 2379 |
if (!empty($form['upgraded'])) { |
if (!empty($form['upgraded'])) { |
| 2380 |
foreach (element_children($form['upgraded']) as $key) { |
foreach (element_children($form['upgraded']) as $key) { |
| 2390 |
} |
} |
| 2391 |
} |
} |
| 2392 |
else { |
else { |
| 2393 |
$rows[] = array(array('data' => t('      No handshake upgrade request.'), 'colspan' => 5)); |
$rows[] = array(array('data' => t('      No handshake upgrade request.'), 'colspan' => 5, 'id' => 'handshake-no-upgrades')); |
| 2394 |
} |
} |
| 2395 |
$output .= '<br />You have <strong>' .$form['new_num']['#value']. '</strong> new, and <strong> ' .$form['unanswered_num']['#value']. '</strong> read but unanswered handshake requests.<br />'; |
$output .= '<br />You have <strong>' .$form['new_num']['#value']. '</strong> new, and <strong> ' .$form['unanswered_num']['#value']. '</strong> read but unanswered handshake requests.<br />'; |
| 2396 |
$output .= 'You have <strong>' .$form['flag_num']['#value']. '</strong> flagged handshakes that require a comment from you.<br /><br />'; |
$output .= 'You have <strong>' .$form['flag_num']['#value']. '</strong> flagged handshakes that require a comment from you.<br /><br />'; |
| 2399 |
array('data' => t('Expiration Date'), 'field' => 'duration'), |
array('data' => t('Expiration Date'), 'field' => 'duration'), |
| 2400 |
array('data' => t('From Username'), 'field' => 'name'), |
array('data' => t('From Username'), 'field' => 'name'), |
| 2401 |
t('Operation')); |
t('Operation')); |
| 2402 |
$rows2[] = array(array('data' => t('<em>The initiators of these handshakes have requested expiration extensions.</em>'), 'colspan' => 4)); |
$rows2[] = array(array('data' => t('<em>The initiators of these handshakes have requested expiration extensions.</em>'), 'colspan' => 4, 'id' => 'handshake-extensions')); |
| 2403 |
if (!empty($form['extension'])) { |
if (!empty($form['extension'])) { |
| 2404 |
foreach (element_children($form['extension']) as $key) { |
foreach (element_children($form['extension']) as $key) { |
| 2405 |
$obj = $form['extension'][$key]['#value']; |
$obj = $form['extension'][$key]['#value']; |
| 2413 |
} |
} |
| 2414 |
} |
} |
| 2415 |
else { |
else { |
| 2416 |
$rows2[] = array(array('data' => t('      No outstanding handshake extension requests.'), 'colspan' => 4)); |
$rows2[] = array(array('data' => t('      No outstanding handshake extension requests.'), 'colspan' => 4, 'id' => 'handshake-no-extensions')); |
| 2417 |
} |
} |
| 2418 |
$rows2[] = array(array('data' => t('<em>You may change your mind regarding handhshakes you have rejected until they expire.</em>'), 'colspan' => 4)); |
$rows2[] = array(array('data' => t('<em>You may change your mind regarding handhshakes you have rejected until they expire.</em>'), 'colspan' => 4, 'id' => 'handshake-change-mind')); |
| 2419 |
if (!empty($form['rejected'])) { |
if (!empty($form['rejected'])) { |
| 2420 |
foreach (element_children($form['rejected']) as $key) { |
foreach (element_children($form['rejected']) as $key) { |
| 2421 |
$obj = $form['rejected'][$key]['#value']; |
$obj = $form['rejected'][$key]['#value']; |
| 2429 |
} |
} |
| 2430 |
} |
} |
| 2431 |
else { |
else { |
| 2432 |
$rows2[] = array(array('data' => t('      No rejected handshakes.'), 'colspan' => 4)); |
$rows2[] = array(array('data' => t('      No rejected handshakes.'), 'colspan' => 4, 'id' => 'handshake-no-rejected')); |
| 2433 |
} |
} |
| 2434 |
$output1 .= '<br />'; |
$output1 .= '<br />'; |
| 2435 |
$output1 .= theme('table', $header2, $rows2, array('width' => '99%')); |
$output1 .= theme('table', $header2, $rows2, array('width' => '99%')); |
| 2450 |
t('Stated Purpose')); |
t('Stated Purpose')); |
| 2451 |
if ($form['flag_num'] > 0) { |
if ($form['flag_num'] > 0) { |
| 2452 |
$header3[] = t('Operations'); |
$header3[] = t('Operations'); |
| 2453 |
$rows3[] = array(array('data' => t('<em>These are the handshake requests you have submitted and which have not been answered yet.</em>'), 'colspan' => 5)); |
$rows3[] = array(array('data' => t('<em>These are the handshake requests you have submitted and which have not been answered yet.</em>'), 'colspan' => 5, 'id' => 'handshake-submitted')); |
| 2454 |
} |
} |
| 2455 |
else { |
else { |
| 2456 |
$rows3[] = array(array('data' => t('<em>These are the handshake requests you have submitted and which have not been answered yet.</em>'), 'colspan' => 4)); |
$rows3[] = array(array('data' => t('<em>These are the handshake requests you have submitted and which have not been answered yet.</em>'), 'colspan' => 4, 'id' => 'handshake-submitted')); |
| 2457 |
} |
} |
| 2458 |
if (!empty($form['new_out'])) { |
if (!empty($form['new_out'])) { |
| 2459 |
foreach (element_children($form['new_out']) as $key) { |
foreach (element_children($form['new_out']) as $key) { |
| 2470 |
} |
} |
| 2471 |
else { |
else { |
| 2472 |
if ($form['flag_num'] > 0) { |
if ($form['flag_num'] > 0) { |
| 2473 |
$rows3[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 5)); |
$rows3[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 5, 'id' => 'handshake-no-new')); |
| 2474 |
} |
} |
| 2475 |
else { |
else { |
| 2476 |
$rows3[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 4)); |
$rows3[] = array(array('data' => t('      No new handshake requests.'), 'colspan' => 4, 'id' => 'handshake-no-new')); |
| 2477 |
} |
} |
| 2478 |
} |
} |
| 2479 |
if (!empty($form['unanswered_out'])) { |
if (!empty($form['unanswered_out'])) { |
| 2491 |
} |
} |
| 2492 |
else { |
else { |
| 2493 |
if ($form['flag_num'] > 0) { |
if ($form['flag_num'] > 0) { |
| 2494 |
$rows3[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 5)); |
$rows3[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 5, 'id' => 'handshake-no-reviewed')); |
| 2495 |
} |
} |
| 2496 |
else { |
else { |
| 2497 |
$rows3[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 4)); |
$rows3[] = array(array('data' => t('      No reviewed handshake requests.'), 'colspan' => 4, 'id' => 'handshake-no-reviewed')); |
| 2498 |
} |
} |
| 2499 |
} |
} |
| 2500 |
if (!empty($form['flagged_out'])) { |
if (!empty($form['flagged_out'])) { |
| 2518 |
} |
} |
| 2519 |
else { |
else { |
| 2520 |
if ($form['flag_num'] > 0) { |
if ($form['flag_num'] > 0) { |
| 2521 |
$rows3[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 5)); |
$rows3[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 5, 'id' => 'handshake-no-flagged')); |
| 2522 |
} |
} |
| 2523 |
else { |
else { |
| 2524 |
$rows3[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 4)); |
$rows3[] = array(array('data' => t('      No flagged handshakes.'), 'colspan' => 4, 'id' => 'handshake-no-flagged')); |
| 2525 |
} |
} |
| 2526 |
} |
} |
| 2527 |
if (!empty($form['upgraded_out'])) { |
if (!empty($form['upgraded_out'])) { |
| 2538 |
} |
} |
| 2539 |
else { |
else { |
| 2540 |
if ($form['flag_num'] > 0) { |
if ($form['flag_num'] > 0) { |
| 2541 |
$rows3[] = array(array('data' => t('      No handshake upgrade requests.'), 'colspan' => 5)); |
$rows3[] = array(array('data' => t('      No handshake upgrade requests.'), 'colspan' => 5, 'id' => 'handshake-no-upgrades')); |
| 2542 |
} |
} |
| 2543 |
else { |
else { |
| 2544 |
$rows3[] = array(array('data' => t('      No handshake upgrade requests.'), 'colspan' => 4)); |
$rows3[] = array(array('data' => t('      No handshake upgrade requests.'), 'colspan' => 4, 'id' => 'handshake-no-upgrades')); |
| 2545 |
} |
} |
| 2546 |
} |
} |
| 2547 |
$output2 .= theme('table', $header3, $rows3, array('width' => '99%')); |
$output2 .= theme('table', $header3, $rows3, array('width' => '99%')); |
| 2548 |
$header4 = array(array('data' => t('Status'), 'field' => 'hstatus', 'sort' => 'asc'), |
$header4 = array(array('data' => t('Status'), 'field' => 'hstatus', 'sort' => 'asc'), |
| 2549 |
array('data' => t('Expiration Date'), 'field' => 'duration'), |
array('data' => t('Expiration Date'), 'field' => 'duration'), |
| 2550 |
array('data' => t('To Username'), 'field' => 'name')); |
array('data' => t('To Username'), 'field' => 'name')); |
| 2551 |
$rows4[] = array(array('data' => t('<em>You have requested expiration extensions for these handshakes.</em>'), 'colspan' => 3)); |
$rows4[] = array(array('data' => t('<em>You have requested expiration extensions for these handshakes.</em>'), 'colspan' => 3, 'id' => 'handshake-extensions')); |
| 2552 |
if (!empty($form['extension_out'])) { |
if (!empty($form['extension_out'])) { |
| 2553 |
foreach (element_children($form['extension_out']) as $key) { |
foreach (element_children($form['extension_out']) as $key) { |
| 2554 |
$obj = $form['extension_out'][$key]['#value']; |
$obj = $form['extension_out'][$key]['#value']; |
| 2561 |
} |
} |
| 2562 |
} |
} |
| 2563 |
else { |
else { |
| 2564 |
$rows4[] = array(array('data' => t('      No outstanding handshake extension requests.'), 'colspan' => 3)); |
$rows4[] = array(array('data' => t('      No outstanding handshake extension requests.'), 'colspan' => 3, 'id' => 'handshake-no-outstanding')); |
| 2565 |
} |
} |
| 2566 |
$rows4[] = array(array('data' => t('<em>These are handshakes you initiated that have been rejected.</em>'), 'colspan' => 3)); |
$rows4[] = array(array('data' => t('<em>These are handshakes you initiated that have been rejected.</em>'), 'colspan' => 3, 'id' => 'handshake-initiated')); |
| 2567 |
if (!empty($form['rejected_out'])) { |
if (!empty($form['rejected_out'])) { |
| 2568 |
foreach (element_children($form['rejected_out']) as $key) { |
foreach (element_children($form['rejected_out']) as $key) { |
| 2569 |
$obj = $form['rejected_out'][$key]['#value']; |
$obj = $form['rejected_out'][$key]['#value']; |
| 2576 |
} |
} |
| 2577 |
} |
} |
| 2578 |
else { |
else { |
| 2579 |
$rows4[] = array(array('data' => t('      No rejected handshakes.'), 'colspan' => 3)); |
$rows4[] = array(array('data' => t('      No rejected handshakes.'), 'colspan' => 3, 'id' => 'handshake-no-rejected')); |
| 2580 |
} |
} |
| 2581 |
$output2 .= '<br />'; |
$output2 .= '<br />'; |
| 2582 |
$output2 .= theme('table', $header4, $rows4, array('width' => '99%')); |
$output2 .= theme('table', $header4, $rows4, array('width' => '99%')); |
| 2654 |
if (!empty($the_rest)) { |
if (!empty($the_rest)) { |
| 2655 |
foreach ($the_rest as $field => $val) { |
foreach ($the_rest as $field => $val) { |
| 2656 |
if (key_exists($type. '::' .$val, $used_fields) && $used_fields[$type. '::' .$val] !== 0) { |
if (key_exists($type. '::' .$val, $used_fields) && $used_fields[$type. '::' .$val] !== 0) { |
| 2657 |
$val2 = substr($val, 6); |
if ($type == 'Users_table') { |
| 2658 |
$val2 = ucfirst($val2); |
$val2 = ucfirst($val); |
| 2659 |
$used_fields[$type. '::' .$val] = $val2; |
$used_fields[$type. '::' .$val] = $val2; |
| 2660 |
|
} |
| 2661 |
|
else { |
| 2662 |
|
$val2 = substr($val, 6); |
| 2663 |
|
$val2 = ucfirst($val2); |
| 2664 |
|
$used_fields[$type. '::' .$val] = $val2; |
| 2665 |
|
} |
| 2666 |
} |
} |
| 2667 |
} |
} |
| 2668 |
} |
} |
| 3005 |
$groups = _nf_handshake_get_groupnames(); |
$groups = _nf_handshake_get_groupnames(); |
| 3006 |
$all_fields = _nf_handshake_get_cckfieldnames(); |
$all_fields = _nf_handshake_get_cckfieldnames(); |
| 3007 |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
| 3008 |
|
$sql7 = "SELECT u.mail, u.picture FROM {users} u WHERE u.uid = %d"; |
| 3009 |
foreach ($all_fields as $type => $field) { |
foreach ($all_fields as $type => $field) { |
| 3010 |
$results = db_query($sql, $form['request']['to']['#value'], $type); |
if ($type == 'Users_table') { |
| 3011 |
|
$results = db_query($sql7, $form['request']['to']['#value']); |
| 3012 |
|
} |
| 3013 |
|
else { |
| 3014 |
|
$results = db_query($sql, $form['request']['to']['#value'], $type); |
| 3015 |
|
} |
| 3016 |
if (db_num_rows($results) > 1) { |
if (db_num_rows($results) > 1) { |
| 3017 |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
| 3018 |
return ''; |
return ''; |
| 3033 |
//locate the user's data |
//locate the user's data |
| 3034 |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
| 3035 |
foreach ($all_fields as $type => $the_rest) { |
foreach ($all_fields as $type => $the_rest) { |
| 3036 |
$type_data = content_types($type); |
if ($type == 'Users_table') { |
| 3037 |
foreach ($the_rest as $key => $value) { |
$user_data_location[$type] = $user_types[$type]; |
| 3038 |
if ($user_types[$type] != NULL) { |
} |
| 3039 |
$result = db_fetch_object(db_query($sql2, $value)); |
else { |
| 3040 |
$field = $type_data['fields'][$value]; |
$type_data = content_types($type); |
| 3041 |
$storage = content_database_info($field); |
foreach ($the_rest as $key => $value) { |
| 3042 |
$user_data_location[$type][$key] = $storage; |
if ($user_types[$type] != NULL) { |
| 3043 |
|
$result = db_fetch_object(db_query($sql2, $value)); |
| 3044 |
|
$field = $type_data['fields'][$value]; |
| 3045 |
|
$storage = content_database_info($field); |
| 3046 |
|
$user_data_location[$type][$key] = $storage; |
| 3047 |
|
} |
| 3048 |
} |
} |
| 3049 |
} |
} |
| 3050 |
} |
} |
| 3051 |
//retrieve the user's data and place it in rows |
//retrieve the user's data and place it in rows |
| 3052 |
foreach ($user_data_location as $type => $field_name) { |
foreach ($user_data_location as $type => $field_name) { |
| 3053 |
foreach ($field_name as $key => $value) { |
foreach ($field_name as $key => $value) { |
| 3054 |
foreach ($value as $key2 => $value2) { |
if ($type == 'Users_table') { |
| 3055 |
$table = $value['table']; |
$user_data[$type][$key][$key] = $value; |
| 3056 |
if ($key2 == 'columns') { |
} |
| 3057 |
foreach ($value2 as $column_readable => $column_array) { |
else { |
| 3058 |
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
foreach ($value as $key2 => $value2) { |
| 3059 |
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
$table = $value['table']; |
| 3060 |
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
if ($key2 == 'columns') { |
| 3061 |
|
foreach ($value2 as $column_readable => $column_array) { |
| 3062 |
|
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
| 3063 |
|
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
| 3064 |
|
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
| 3065 |
|
} |
| 3066 |
} |
} |
| 3067 |
} |
} |
| 3068 |
} |
} |
| 3075 |
if (strstr($key4, '::')) { |
if (strstr($key4, '::')) { |
| 3076 |
$data_text = ''; |
$data_text = ''; |
| 3077 |
$exp_val = explode('::', $key4); |
$exp_val = explode('::', $key4); |
| 3078 |
if (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
if ($exp_val[0] == 'Users_table') { |
| 3079 |
|
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
| 3080 |
|
if (!empty($data)) { |
| 3081 |
|
if ($column == 'picture') { |
| 3082 |
|
$data_text .= theme('image', $data) .'<br />'; |
| 3083 |
|
} |
| 3084 |
|
else { |
| 3085 |
|
$data_text .= $data. '<br />'; |
| 3086 |
|
} |
| 3087 |
|
} |
| 3088 |
|
} |
| 3089 |
|
if ($data_text == '') { |
| 3090 |
|
$data_text .= t('<strong>No Value Entered</strong>'); |
| 3091 |
|
$form['request']['fields'][$key4]['#attributes'] = array('disabled' => 1); |
| 3092 |
|
$form['request']['fields'][$key4]['#return_value'] = 'NULL'; |
| 3093 |
|
} |
| 3094 |
|
} |
| 3095 |
|
elseif (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
| 3096 |
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
| 3097 |
if (!empty($data)) { |
if (!empty($data)) { |
| 3098 |
$data_text .= $data. '<br />'; |
$data_text .= $data. '<br />'; |
| 3431 |
*/ |
*/ |
| 3432 |
function nf_handshake_view_user_data($uid = NULL) { |
function nf_handshake_view_user_data($uid = NULL) { |
| 3433 |
global $user; |
global $user; |
| 3434 |
|
drupal_add_css(drupal_get_path('module', 'nf_handshake') .'/nf_handshake.css', 'module', 'all', FALSE); |
| 3435 |
$other_user = user_load(array('uid' => $uid)); |
$other_user = user_load(array('uid' => $uid)); |
|
$output = ''; |
|
| 3436 |
$sql = "SELECT * FROM {nf_handshake} WHERE (auid = %d AND iuid = %d) OR (auid = %d AND iuid = %d)"; |
$sql = "SELECT * FROM {nf_handshake} WHERE (auid = %d AND iuid = %d) OR (auid = %d AND iuid = %d)"; |
| 3437 |
$request = db_fetch_object(db_query($sql, $user->uid, $uid, $uid, $user->uid)); |
$request = db_fetch_object(db_query($sql, $user->uid, $uid, $uid, $user->uid)); |
| 3438 |
$username = db_fetch_object(db_query("SELECT name FROM {users} WHERE uid = %d", $uid)); |
$username = $other_user->name; |
| 3439 |
$username = $username->name; |
$output = '<div id="view-handshake"><h2>'. $username .'\'s '. t('shared data') .'</h2>'; |
| 3440 |
$used_fields = unserialize($request->hfields); |
$used_fields = unserialize($request->hfields); |
| 3441 |
$header = array(t('Field'), t("<em>$username's</em> shared data")); |
$header = array(t('Field'), t("<em>$username's</em> shared data")); |
| 3442 |
$rows = array(); |
$rows = array(); |
| 3446 |
$groups = _nf_handshake_get_groupnames(); |
$groups = _nf_handshake_get_groupnames(); |
| 3447 |
$all_fields = _nf_handshake_get_cckfieldnames(); |
$all_fields = _nf_handshake_get_cckfieldnames(); |
| 3448 |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
$sql = "SELECT n.nid, n.vid, n.type, n.title FROM {node} n WHERE n.uid = %d AND n.type = '%s'"; |
| 3449 |
|
$sql7 = "SELECT u.mail, u.picture FROM {users} u WHERE u.uid = %d"; |
| 3450 |
foreach ($all_fields as $type => $field) { |
foreach ($all_fields as $type => $field) { |
| 3451 |
$results = db_query($sql, $uid, $type); |
if ($type == 'Users_table') { |
| 3452 |
|
$results = db_query($sql7, $uid); |
| 3453 |
|
} |
| 3454 |
|
else { |
| 3455 |
|
$results = db_query($sql, $uid, $type); |
| 3456 |
|
} |
| 3457 |
if (db_num_rows($results) > 1) { |
if (db_num_rows($results) > 1) { |
| 3458 |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
drupal_set_message('Error, you have more than one node of the content type ' .$type. '. Please contact the system administrator with this error message.', 'error'); |
| 3459 |
return ''; |
return ''; |
| 3474 |
//locate the user's data |
//locate the user's data |
| 3475 |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
$sql2 = "SELECT type FROM {node_field} WHERE field_name = '%s'"; |
| 3476 |
foreach ($all_fields as $type => $the_rest) { |
foreach ($all_fields as $type => $the_rest) { |
| 3477 |
|
if ($type == 'Users_table') { |
| 3478 |
|
$user_data_location[$type] = $user_types[$type]; |
| 3479 |
|
} |
| 3480 |
|
else { |
| 3481 |
$type_data = content_types($type); |
$type_data = content_types($type); |
| 3482 |
foreach ($the_rest as $key => $value) { |
foreach ($the_rest as $key => $value) { |
| 3483 |
if ($user_types[$type] != NULL) { |
if ($user_types[$type] != NULL) { |
| 3484 |
$result = db_fetch_object(db_query($sql2, $value)); |
$result = db_fetch_object(db_query($sql2, $value)); |
| 3485 |
$field = $type_data['fields'][$value]; |
$field = $type_data['fields'][$value]; |
| 3486 |
$storage = content_database_info($field); |
$storage = content_database_info($field); |
| 3487 |
$user_data_location[$type][$key] = $storage; |
$user_data_location[$type][$key] = $storage; |
| 3488 |
|
} |
| 3489 |
} |
} |
| 3490 |
} |
} |
| 3491 |
} |
} |
| 3492 |
//retrieve the user's data and place it in rows |
//retrieve the user's data and place it in rows |
| 3493 |
foreach ($user_data_location as $type => $field_name) { |
foreach ($user_data_location as $type => $field_name) { |
| 3494 |
foreach ($field_name as $key => $value) { |
foreach ($field_name as $key => $value) { |
| 3495 |
foreach ($value as $key2 => $value2) { |
if ($type == 'Users_table') { |
| 3496 |
$table = $value['table']; |
$user_data[$type][$key][$key] = $value; |
| 3497 |
if ($key2 == 'columns') { |
} |
| 3498 |
foreach ($value2 as $column_readable => $column_array) { |
else { |
| 3499 |
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
foreach ($value as $key2 => $value2) { |
| 3500 |
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
$table = $value['table']; |
| 3501 |
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
if ($key2 == 'columns') { |
| 3502 |
|
foreach ($value2 as $column_readable => $column_array) { |
| 3503 |
|
$sql3 = "SELECT %s FROM {%s} WHERE nid = %d"; |
| 3504 |
|
$result = db_fetch_object(db_query($sql3, $column_array['column'], $table, $user_types[$type]->nid)); |
| 3505 |
|
$user_data[$type][$key][$column_readable] = $result->$column_array['column']; |
| 3506 |
|
} |
| 3507 |
} |
} |
| 3508 |
} |
} |
| 3509 |
} |
} |
| 3516 |
if (strstr($key4, '::')) { |
if (strstr($key4, '::')) { |
| 3517 |
$data_text = ''; |
$data_text = ''; |
| 3518 |
$exp_val = explode('::', $key4); |
$exp_val = explode('::', $key4); |
| 3519 |
if (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
if ($exp_val[0] == 'Users_table') { |
| 3520 |
|
foreach ($user_data[$exp_val[0]][$exp_val[1]] as $column => $data) { |
| 3521 |
|
if (!empty($data)) { |
| 3522 |
|
if ($column == 'picture') { |
| 3523 |
|
$data_text .= theme('image', $data) .'<br />'; |
| 3524 |
|
} |
| 3525 |
|
else { |
| 3526 |
|
$data_text .= $data. '<br />'; |
| 3527 |
|
} |
| 3528 |
|
} |
| 3529 |
|
} |
| 3530 |
|
} |
| 3531 |
|
elseif (!empty($user_types[$exp_val[0]]) && $user_types[$exp_val[0]] != NULL) { |
| 3532 |
//start new stuff |
//start new stuff |
| 3533 |
$type_name = $exp_val[0]; |
$type_name = $exp_val[0]; |
| 3534 |
$type = content_types($type_name); |
$type = content_types($type_name); |
| 3552 |
} |
} |
| 3553 |
//end |
//end |
| 3554 |
} |
} |
| 3555 |
$rows[] = array(array('data' => t($field['widget']['label']), 'width' => '20%'), array('data' => $data_text, 'width' => '*')); |
if ($exp_val[0] == 'Users_table') { |
| 3556 |
|
$rows[] = array(array('data' => t(ucfirst($exp_val[1])), 'width' => '20%'), array('data' => $data_text, 'width' => '*')); |
| 3557 |
|
} |
| 3558 |
|
else { |
| 3559 |
|
$rows[] = array(array('data' => t($field['widget']['label']), 'width' => '20%'), array('data' => $data_text, 'width' => '*')); |
| 3560 |
|
} |
| 3561 |
} |
} |
| 3562 |
else { |
else { |
| 3563 |
foreach ($groups as $group => $the_rest) { |
foreach ($groups as $group => $the_rest) { |
| 3637 |
$output .= l(t('Downgrade handshake (hide fields)'), |
$output .= l(t('Downgrade handshake (hide fields)'), |
| 3638 |
'user/' .$user->uid. '/nf_handshake/view_hsr/' .$uid. '/1', |
'user/' .$user->uid. '/nf_handshake/view_hsr/' .$uid. '/1', |
| 3639 |
array('title' => t("You may revoke specific fields from the handshake at any time."))); |
array('title' => t("You may revoke specific fields from the handshake at any time."))); |
| 3640 |
return $output; |
return $output ."</div>"; |
| 3641 |
} // function nf_handshake_view_user_data() |
} // function nf_handshake_view_user_data() |
| 3642 |
|
|
| 3643 |
/** |
/** |