894 else |
894 else |
895 { |
895 { |
896 echo '<div class="error-box">' . $lang->get('usercp_avatar_move_failed') . '</div>'; |
896 echo '<div class="error-box">' . $lang->get('usercp_avatar_move_failed') . '</div>'; |
897 } |
897 } |
898 break; |
898 break; |
|
899 case 'set_gravatar': |
|
900 // set avatar to use Gravatar |
|
901 // make sure we're allowed to do this |
|
902 if ( getConfig('avatar_upload_gravatar') != '1' ) |
|
903 { |
|
904 // access denied |
|
905 break; |
|
906 } |
|
907 // first, remove old image |
|
908 if ( $has_avi ) |
|
909 { |
|
910 // First switch the avatar off |
|
911 $q = $db->sql_query('UPDATE ' . table_prefix . 'users SET user_has_avatar = 0 WHERE user_id = ' . $session->user_id . ';'); |
|
912 if ( !$q ) |
|
913 $db->_die('Avatar CP switching user avatar off'); |
|
914 |
|
915 @unlink($avi_path); |
|
916 } |
|
917 // set to gravatar mode |
|
918 $q = $db->sql_query('UPDATE ' . table_prefix . 'users SET user_has_avatar = 1, avatar_type = \'grv\' WHERE user_id = ' . $session->user_id . ';'); |
|
919 if ( !$q ) |
|
920 $db->_die('Avatar CP switching user avatar off'); |
|
921 |
|
922 $has_avi = 1; |
|
923 echo '<div class="info-box">' . $lang->get('usercp_avatar_gravatar_success') . '</div>'; |
|
924 break; |
899 } |
925 } |
900 } |
926 } |
901 |
927 |
902 ?> |
928 ?> |
903 <script type="text/javascript"> |
929 <script type="text/javascript"> |
908 { |
934 { |
909 case 'keep': |
935 case 'keep': |
910 case 'remove': |
936 case 'remove': |
911 $('avatar_upload_http').object.style.display = 'none'; |
937 $('avatar_upload_http').object.style.display = 'none'; |
912 $('avatar_upload_file').object.style.display = 'none'; |
938 $('avatar_upload_file').object.style.display = 'none'; |
|
939 $('avatar_upload_gravatar').object.style.display = 'none'; |
913 break; |
940 break; |
914 case 'set_http': |
941 case 'set_http': |
915 $('avatar_upload_http').object.style.display = 'block'; |
942 $('avatar_upload_http').object.style.display = 'block'; |
916 $('avatar_upload_file').object.style.display = 'none'; |
943 $('avatar_upload_file').object.style.display = 'none'; |
|
944 $('avatar_upload_gravatar').object.style.display = 'none'; |
917 break; |
945 break; |
918 case 'set_file': |
946 case 'set_file': |
919 $('avatar_upload_http').object.style.display = 'none'; |
947 $('avatar_upload_http').object.style.display = 'none'; |
920 $('avatar_upload_file').object.style.display = 'block'; |
948 $('avatar_upload_file').object.style.display = 'block'; |
|
949 $('avatar_upload_gravatar').object.style.display = 'none'; |
|
950 break; |
|
951 case 'set_gravatar': |
|
952 $('avatar_upload_gravatar').object.style.display = 'block'; |
|
953 $('avatar_upload_http').object.style.display = 'none'; |
|
954 $('avatar_upload_file').object.style.display = 'none'; |
921 break; |
955 break; |
922 } |
956 } |
923 } |
957 } |
924 |
958 |
925 </script> |
959 </script> |
940 </td> |
974 </td> |
941 <td class="row1" style="text-align: center;">'; |
975 <td class="row1" style="text-align: center;">'; |
942 |
976 |
943 if ( $has_avi == 1 ) |
977 if ( $has_avi == 1 ) |
944 { |
978 { |
945 echo '<img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $session->username)) . '" src="' . make_avatar_url($session->user_id, $avi_type) . '" />'; |
979 echo '<img alt="' . $lang->get('usercp_avatar_image_alt', array('username' => $session->username)) . '" src="' . make_avatar_url($session->user_id, $avi_type, $session->email) . '" />'; |
946 } |
980 } |
947 else |
981 else |
948 { |
982 { |
949 echo $lang->get('usercp_avatar_image_none'); |
983 echo $lang->get('usercp_avatar_image_none'); |
950 } |
984 } |
971 { |
1005 { |
972 echo ' <div id="avatar_upload_http" style="display: none;"></div>'; |
1006 echo ' <div id="avatar_upload_http" style="display: none;"></div>'; |
973 } |
1007 } |
974 if ( getConfig('avatar_upload_file') == '1' ) |
1008 if ( getConfig('avatar_upload_file') == '1' ) |
975 { |
1009 { |
976 echo ' <label><input type="radio" name="avatar_action" value="set_file" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_set_file') . '</label> |
1010 echo ' <label><input type="radio" name="avatar_action" value="set_file" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_set_file') . '</label><br /> |
977 <div id="avatar_upload_file" style="display: none; margin: 10px 0 0 2.2em;"> |
1011 <div id="avatar_upload_file" style="display: none; margin: 10px 0 0 2.2em;"> |
978 ' . $lang->get('usercp_avatar_lbl_file') . ' <input type="file" name="avatar_file" size="40" /><br /> |
1012 ' . $lang->get('usercp_avatar_lbl_file') . ' <input type="file" name="avatar_file" size="40" /><br /> |
979 <small>' . $lang->get('usercp_avatar_lbl_file_desc') . ' ' . $lang->get('usercp_avatar_limits') . '</small> |
1013 <small>' . $lang->get('usercp_avatar_lbl_file_desc') . ' ' . $lang->get('usercp_avatar_limits') . '</small> |
980 </div>'; |
1014 </div>'; |
981 } |
1015 } |
982 else |
1016 else |
983 { |
1017 { |
984 echo ' <div id="avatar_upload_file" style="display: none;"></div>'; |
1018 echo ' <div id="avatar_upload_file" style="display: none;"></div>'; |
|
1019 } |
|
1020 if ( getConfig('avatar_upload_gravatar') == '1' ) |
|
1021 { |
|
1022 $rating_images = array('g' => '0', 'pg' => '1', 'r' => '2', 'x' => '3'); |
|
1023 $rating_id = $rating_images[ getConfig('gravatar_rating', 'g') ]; |
|
1024 $rating_image = "http://s.gravatar.com/images/gravatars/ratings/$rating_id.gif"; |
|
1025 $max_rating = getConfig('gravatar_rating', 'g'); |
|
1026 echo ' <label><input type="radio" name="avatar_action" value="set_gravatar" onclick="avatar_select_field(this);" /> ' . $lang->get('usercp_avatar_lbl_set_gravatar') . ' <img alt=" " src="' . make_gravatar_url($session->email, 16) . '" /></label> (<a href="http://www.gravatar.com/" onclick="window.open(this); return false;">' . $lang->get('usercp_avatar_link_gravatar_info') . '</a>) |
|
1027 <div id="avatar_upload_gravatar" style="display: none; margin: 10px 0 0 2.2em;"> |
|
1028 <div style="float: left; margin-right: 5px; margin-bottom: 20px;"> |
|
1029 <img alt=" " src="' . $rating_image . '" /> |
|
1030 </div> |
|
1031 ' . $lang->get("usercp_avatar_gravatar_rating_$max_rating") . ' |
|
1032 </div>'; |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 echo ' <div id="avatar_upload_gravatar" style="display: none;"></div>'; |
985 } |
1037 } |
986 echo ' </td> |
1038 echo ' </td> |
987 </tr>'; |
1039 </tr>'; |
988 |
1040 |
989 echo ' <tr> |
1041 echo ' <tr> |