Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * Fixed by Fikri Fadzil - [email protected]
- * - As I couldn't contact the developer, this is the patch for time being.
- *
- * User Social 1.1
- *
- * Copyright 2014 CrazyCat
- *
- * This program is free software: you can redistribute it
- * and/or modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- *You should have received a copy of the GNU General Public License
- * along with this program.
- *If not, see <http://www.gnu.org/licenses/>.
- **/
- /**
- * Short changelog
- *
- * 1.2 : corrected usercp and member profil queries
- *
- * 1.1 : corrected package (pictures missing, language variables)
- * Upgrade: unactivate the plugin, upload the new version and re-activate
- *
- * 1.0 : Initial release
- **/
- if(!defined('IN_MYBB'))
- {
- die('This file cannot be accessed directly.');
- }
- function usersocial_info()
- {
- return array(
- 'name' => "User social fields",
- 'description' => "Display more user social ids",
- 'website' => 'http://www.g33k-zone.org/',
- 'author' => 'CrazyCat',
- 'authorsite' => 'http://www.g33k-zone.org/',
- 'version' => '1.2',
- 'compatibility' => '16*',
- 'guid' => 'da8691c12e504d9bba121d7b073bd3ed'
- );
- }
- if(defined('IN_ADMINCP'))
- {
- $plugins->add_hook('admin_user_menu', 'usersocial_menu');
- $plugins->add_hook('admin_user_action_handler', 'usersocial_action_handler');
- $plugins->add_hook('admin_load', 'usersocial_admin_load');
- $plugins->add_hook('admin_user_permissions', 'usersocial_admin_permissions');
- }
- else
- {
- $plugins->add_hook('postbit_prev', 'usersocial_postbit');
- $plugins->add_hook('postbit_pm', 'usersocial_postbit');
- $plugins->add_hook('postbit', 'usersocial_postbit');
- $plugins->add_hook('postbit_announcement', 'usersocial_postbit');
- $plugins->add_hook('member_profile_end', 'usersocial_profile');
- $plugins->add_hook('usercp_profile_start', 'usersocial_usercp');
- $plugins->add_hook('datahandler_user_update', 'usersocial_update_user');
- }
- function usersocial_menu(&$sub_menu)
- {
- global $lang;
- $lang->load('usersocial');
- $sub_menu[] = array('id' => 'usersocial', 'title' => $lang->usersocial, 'link' => 'index.php?module=user-usersocial');
- }
- function usersocial_install()
- {
- global $db;
- if (usersocial_is_installed()) {
- usersocial_uninstall();
- }
- $collation = $db->build_create_table_collation();
- if(!$db->table_exists('social_network'))
- {
- $db->write_query("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."social_network (
- `snid` int(11) NOT NULL AUTO_INCREMENT,
- `sn_name` varchar(50) NOT NULL,
- `sn_label` varchar(255) NOT NULL,
- `sn_active` int(1) NOT NULL DEFAULT '1',
- `sn_profil` int(1) NOT NULL DEFAULT '1',
- `sn_postbit` int(1) NOT NULL DEFAULT '0',
- `sn_link` varchar(250) NOT NULL,
- `sn_image` varchar(50) NOT NULL,
- `sn_order` int(5) NOT NULL,
- PRIMARY KEY (`snid`)
- ) ENGINE=MyISAM{$collation};"
- );
- }
- $db->insert_query('social_network',
- array(
- 'sn_name' => 'Facebook',
- 'sn_label' => 'Insert your Facebook username',
- 'sn_link' => 'http://www.facebook.com/#username#',
- 'sn_image' => 'facebook.png',
- 'sn_order' => 1
- )
- );
- $db->insert_query('social_network',
- array(
- 'sn_name' => 'Twitter',
- 'sn_label' => 'Insert your Twitter username',
- 'sn_link' => 'http://www.twitter.com/#username#',
- 'sn_image' => 'twitter.png',
- 'sn_order' => 2
- )
- );
- $db->insert_query('social_network',
- array(
- 'sn_name' => 'Pinterest',
- 'sn_label' => 'Insert your Pinterest username',
- 'sn_link' => 'http://www.pinterest.com/#username#/',
- 'sn_image' => 'pinterest.png',
- 'sn_order' => 3
- )
- );
- if(!$db->table_exists('social_user_network'))
- {
- $db->write_query("CREATE TABLE IF NOT EXISTS ".TABLE_PREFIX."social_user_network (
- `snid` int(11) NOT NULL,
- `uid` int(11) NOT NULL,
- `sn_value` varchar(255) NOT NULL,
- `sn_private` int(1) NOT NULL DEFAULT '0',
- UNIQUE KEY `snid` (`snid`,`uid`)
- ) ENGINE=MyISAM{$collation};"
- );
- }
- }
- function usersocial_is_installed()
- {
- global $db;
- if( $db->table_exists('social_network') && $db->table_exists('social_user_network')) {
- return true;
- }
- return false;
- }
- function usersocial_uninstall()
- {
- global $db;
- if($db->table_exists('social_network'))
- {
- $db->drop_table('social_network');
- }
- if($db->table_exists('social_user_network'))
- {
- $db->drop_table('social_user_network');
- }
- }
- function usersocial_activate()
- {
- global $db, $mybb;
- $db->insert_query('templates',
- array(
- 'title' => 'usersocial_postbit',
- 'template' => $db->escape_string('<a href="{$network[\'sn_link\']}" title="{$network[\'sn_name\']}"><img src="{$network[\'sn_image\']}" /></a>'),
- 'version' => intval(1614),
- 'dateline' => TIME_NOW,
- 'sid' => -1
- )
- );
- $db->insert_query('templates',
- array(
- 'title' => 'usersocial_member_profile_row',
- 'template' => $db->escape_string('<tr>
- <td class="trow{$network[\'even\']}"><strong>{$network[\'sn_name\']}</strong></td>
- <td class="trow{$network[\'even\']}">{$network[\'ulink\']}</td>
- </tr>'),
- 'version' => intval(1614),
- 'dateline' => TIME_NOW,
- 'sid' => -1
- )
- );
- $db->insert_query('templates',
- array(
- 'title' => 'usersocial_usercp_row',
- 'template' => $db->escape_string('<tr>
- <td><span class="smalltext">{$network[\'sn_name\']}</span></td>
- <td><input type="text" class="textbox" size="25" name="sn[{$network[\'snid\']}]" value="{$network[\'sn_value\']}" /></td>
- <td><input type="checkbox" name="snp[{$network[\'snid\']}]" {$network[\'checked\']} value="1" /></td>
- </tr>
- <tr>
- <td colspan="3"><span class="smalltext">{$network[\'sn_label\']}</span></td>
- </tr>'),
- 'version' => intval(1614),
- 'dateline' => TIME_NOW,
- 'sid' => -1
- )
- );
- $db->insert_query('templates',
- array(
- 'title' => 'usersocial_usercp',
- 'template' => $db->escape_string('<fieldset class="trow2">
- <legend><strong>{$lang->usersocial}</strong></legend>
- <table cellspacing="0" cellpadding="5">
- <tr>
- <th>{$lang->usersocial_network}</th>
- <th>{$lang->usersocial_username}</th>
- <th>{$lang->usersocial_private}</th>
- </tr>
- {$usersocial_rows}
- </table>
- </fieldset>'),
- 'version' => intval(1614),
- 'dateline' => TIME_NOW,
- 'sid' => -1
- )
- );
- require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
- find_replace_templatesets('postbit', '#'.preg_quote('{$post[\'user_details\']}').'#', '{$post[\'user_details\']}{$post[\'usersocial\']}');
- find_replace_templatesets('postbit_classic', '#'.preg_quote('{$post[\'user_details\']}').'#', '{$post[\'user_details\']}{$post[\'usersocial\']}');
- find_replace_templatesets('member_profile', '#'.preg_quote('<td class="{$bgcolors[\'msn\']}"><a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&imtype=msn&uid={$uid}\', \'imcenter\', 450, 300);">{$memprofile[\'msn\']}</a></td>').'#', '<td class="{$bgcolors[\'msn\']}"><a href="javascript:;" onclick="MyBB.popupWindow(\'misc.php?action=imcenter&imtype=msn&uid={$uid}\', \'imcenter\', 450, 300);">{$memprofile[\'msn\']}</a></td>{$memprofile[\'usersocial\']}');
- find_replace_templatesets('usercp_profile', '#'.preg_quote('{$awaysection}').'#', '{$usersocial}{$awaysection}');
- rebuild_settings();
- }
- function usersocial_deactivate()
- {
- global $db, $mybb;
- $db->delete_query('templates', "title LIKE 'usersocial%'");
- require_once MYBB_ROOT.'/inc/adminfunctions_templates.php';
- find_replace_templatesets('postbit', '#'.preg_quote('{$post[\'usersocial\']}').'#', '', 0);
- find_replace_templatesets('postbit_classic', '#'.preg_quote('{$post[\'usersocial\']}').'#', '', 0);
- find_replace_templatesets('member_profile', '#'.preg_quote('{$memprofile[\'usersocial\']}').'#', '', 0);
- find_replace_templatesets('usercp_profile', '#'.preg_quote('{$usersocial}').'#', '', 0);
- rebuild_settings();
- }
- function usersocial_action_handler(&$action)
- {
- $action['usersocial'] = array('active' => 'usersocial', 'file' => 'usersocial');
- }
- function usersocial_admin_permissions(&$admin_permissions)
- {
- global $lang;
- $lang->load('usersocial');
- $admin_permissions['usersocial'] = $lang->usersocial_admin_action;
- }
- function usersocial_admin_load()
- {
- global $run_module, $action_file, $lang;
- $lang->load('usersocial');
- if ($run_module == 'user' && $action_file == 'usersocial')
- {
- global $mybb, $db, $page, $lang;
- $page->add_breadcrumb_item($lang->usersocial, 'index.php?module=user-usersocial');
- $page->output_header($lang->usersocial);
- $mybb->input['aid'] = intval($mybb->input['aid']);
- $mybb->input['uid'] = intval($mybb->input['uid']);
- if (!$mybb->input['action'] || in_array($mybb->input['action'], array('add', 'edit')))
- {
- $sub_tabs['usersocial_view'] = array(
- 'title' => $lang->usersocial_list,
- 'link' => 'index.php?module=user-usersocial',
- 'description' => $lang->usersocial_list_desc
- );
- $sub_tabs['usersocial_add'] = array(
- 'title' => $lang->usersocial_add,
- 'link' => 'index.php?module=user-usersocial&action=add',
- 'description' => $lang->usersocial_add_desc
- );
- $sub_tabs['usersocial_edit'] = array(
- 'title' => $lang->usersocial_edit,
- 'link' => 'index.php?module=user-usersocial&action=edit',
- 'description' => $lang->usersocial_edit_desc,
- );
- }
- if (!$mybb->input['action'] || $mybb->input['action'] == 'view')
- {
- $page->output_nav_tabs($sub_tabs, 'usersocial_view');
- $table = new Table();
- $table->construct_header($lang->usersocial_icon, array('width' => '10%'));
- $table->construct_header($lang->usersocial_network, array('width' => '45%'));
- $table->construct_header($lang->usersocial_active, array('width' => '10%', 'class' => 'align_center'));
- $table->construct_header($lang->usersocial_profil, array('width' => '10%', 'class' => 'align_center'));
- $table->construct_header($lang->usersocial_post, array('width' => '10%', 'class' => 'align_center'));
- $table->construct_header($lang->usersocial_action, array('width' => '15%', 'class' => 'align_center'));
- $query = $db->simple_select('social_network', "*", "1=1", array("order_by" => 'sn_order', "order_dir" => 'ASC'));
- if($db->num_rows($query) < 1)
- {
- $table->construct_cell('<div align="center">'.$lang->usersocial_no_network.'</div>', array('colspan' => 6));
- $table->construct_row();
- }
- else
- {
- while ($network = $db->fetch_array($query))
- {
- $table->construct_cell('<img src="'.usersocial_get_icon($network['sn_image']).'" />', array('class' => 'align_center'));
- $table->construct_cell(htmlspecialchars_uni($network['sn_name']));
- $table->construct_cell('<img src="../images/usersocial/bullet_'.(($network['sn_active']==0) ? 'red' : 'green').'.png" alt="" title="'.(($network['sn_active']==0) ? $lang->no : $lang->yes).'" />', array('class' => 'align_center'));
- $table->construct_cell('<img src="../images/usersocial/bullet_'.(($network['sn_profil']==0) ? 'red' : 'green').'.png" alt="" title="'.(($network['sn_profil']==0) ? $lang->no : $lang->yes).'" />', array('class' => 'align_center'));
- $table->construct_cell('<img src="../images/usersocial/bullet_'.(($network['sn_postbit']==0) ? 'red' : 'green').'.png" alt="" title="'.(($network['sn_postbit']==0) ? $lang->no : $lang->yes).'" />', array('class' => 'align_center'));
- $popup = new PopupMenu("usersocial_{$network['snid']}", $lang->options);
- $popup->add_item($lang->usersocial_edit, "index.php?module=user-usersocial&action=edit&snid={$network['snid']}");
- $popup->add_item($lang->usersocial_del, "index.php?module=user-usersocial&action=delete&snid={$network['snid']}");
- $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
- $table->construct_row();
- }
- }
- $db->free_result($query);
- $table->output($lang->usersocial_network);
- }
- elseif ($mybb->input['action'] == 'add')
- {
- if ($mybb->request_method == 'post')
- {
- if ($mybb->input['sn_name'] == '')
- {
- flash_message($lang->usersocial_add_error, 'error');
- admin_redirect("index.php?module=user-usersocial&action=add");
- }
- $insert = array(
- 'sn_name' => $mybb->input['sn_name'],
- 'sn_label' => $mybb->input['sn_label'],
- 'sn_active' => $mybb->input['sn_active'],
- 'sn_profil' => $mybb->input['sn_profil'],
- 'sn_postbit' => $mybb->input['sn_postbit'],
- 'sn_link' => $mybb->input['sn_link'],
- 'sn_image' => $mybb->input['sn_image'],
- 'sn_order' => $mybb->input['sn_order']
- );
- log_admin_action($lang->usersocial_new_network . ' : '.$insert['sn_name']);
- usersocial_add_network($insert);
- flash_message($lang->usersocial_add_success, 'success');
- admin_redirect("index.php?module=user-usersocial");
- }
- $page->output_nav_tabs($sub_tabs, 'usersocial_add');
- $form = new Form('index.php?module=user-usersocial&action=add', "post");
- $form_container = new FormContainer($lang->usersocial_add_network);
- $form_container->output_row($lang->usersocial_row_name, $lang->usersocial_row_name_desc, $form->generate_text_box('sn_name'));
- $form_container->output_row($lang->usersocial_row_label, $lang->usersocial_row_label_desc, $form->generate_text_area('sn_label', '', array('rows' => 5, 'style' => 'width:80%;')));
- $form_container->output_row($lang->usersocial_row_active, $lang->usersocial_row_active_desc, $form->generate_yes_no_radio('sn_active'));
- $form_container->output_row($lang->usersocial_row_profil, $lang->usersocial_row_profil_desc, $form->generate_yes_no_radio('sn_profil'));
- $form_container->output_row($lang->usersocial_row_postbit, $lang->usersocial_row_postbit_desc, $form->generate_yes_no_radio('sn_postbit'));
- $form_container->output_row($lang->usersocial_row_link, $lang->usersocial_row_link_desc, $form->generate_text_box('sn_link'));
- $form_container->output_row($lang->usersocial_row_icon, $lang->usersocial_row_icon_desc, $form->generate_text_box('sn_image'));
- $form_container->output_row($lang->usersocial_row_order, $lang->usersocial_row_order_desc, $form->generate_text_box('sn_order'));
- $form_container->end();
- $buttons = array();
- $buttons[] = $form->generate_submit_button($lang->usersocial_add);
- $buttons[] = $form->generate_reset_button($lang->usersocial_cancel);
- $form->output_submit_wrapper($buttons);
- $form->end();
- }
- elseif ($mybb->input['action'] == 'edit')
- {
- if(!($network = usersocial_get_network($mybb->input['snid'])))
- {
- flash_message($lang->usersocial_edit_none, 'error');
- admin_redirect("index.php?module=user-usersocial");
- }
- if ($mybb->request_method == 'post')
- {
- if ($mybb->input['sn_name'] == '')
- {
- flash_message($lang->usersocial_edit_error, 'error');
- admin_redirect("index.php?module=user-usersocial&action=edit");
- }
- $update = array(
- 'sn_name' => $mybb->input['sn_name'],
- 'sn_label' => $mybb->input['sn_label'],
- 'sn_active' => $mybb->input['sn_active'],
- 'sn_profil' => $mybb->input['sn_profil'],
- 'sn_postbit' => $mybb->input['sn_postbit'],
- 'sn_link' => $mybb->input['sn_link'],
- 'sn_image' => $mybb->input['sn_image'],
- 'sn_order' => $mybb->input['sn_order']
- );
- log_admin_action($lang->usersocial_edit_network . ' : '.$update['sn_name']);
- usersocial_update_network($network['snid'], $update);
- flash_message($lang->usersocial_edit_success, 'success');
- admin_redirect("index.php?module=user-usersocial");
- }
- $page->output_nav_tabs($sub_tabs, 'usersocial_edit');
- $form = new Form("index.php?module=user-usersocial&action=edit&snid={$network['snid']}", "post");
- $form_container = new FormContainer($lang->usersocial_edit_network);
- $form_container->output_row($lang->usersocial_row_name, $lang->usersocial_row_name_desc, $form->generate_text_box('sn_name', $network['sn_name']));
- $form_container->output_row($lang->usersocial_row_label, $lang->usersocial_row_label_desc, $form->generate_text_area('sn_label', htmlspecialchars_uni($network['sn_label']), array('rows' => 5, 'style' => 'width:80%;')));
- $form_container->output_row($lang->usersocial_row_active, $lang->usersocial_row_active_desc, $form->generate_yes_no_radio('sn_active', intval($network['sn_active'])));
- $form_container->output_row($lang->usersocial_row_profil, $lang->usersocial_row_profil_desc, $form->generate_yes_no_radio('sn_profil', intval($network['sn_profil'])));
- $form_container->output_row($lang->usersocial_row_postbit, $lang->usersocial_row_postbit_desc, $form->generate_yes_no_radio('sn_postbit', intval($network['sn_postbit'])));
- $form_container->output_row($lang->usersocial_row_link, $lang->usersocial_row_link_desc, $form->generate_text_box('sn_link', htmlspecialchars_uni($network['sn_link'])));
- $form_container->output_row($lang->usersocial_row_icon, $lang->usersocial_row_icon_desc, $form->generate_text_box('sn_image', htmlspecialchars_uni($network['sn_image'])));
- $form_container->output_row($lang->usersocial_row_order, $lang->usersocial_row_order_desc, $form->generate_text_box('sn_order', intval($network['sn_order'])));
- $form_container->end();
- $buttons = array();
- $buttons[] = $form->generate_submit_button($lang->usersocial_add);
- $form->output_submit_wrapper($buttons);
- $form->end();
- }
- elseif($mybb->input['action'] == 'delete')
- {
- if(!($network = usersocial_get_network($mybb->input['snid'])) || ($mybb->request_method == 'post' && $mybb->input['my_post_key'] != $mybb->post_code) || $mybb->input['no'])
- {
- if(!$mybb->input['no'])
- {
- flash_message($lang->usersocial_del_error, 'error');
- }
- admin_redirect("index.php?module=user-usersocial");
- }
- if($mybb->request_method == 'post')
- {
- log_admin_action($lang->usersocial_del_network . ' : '.$network['sn_name'], $network['snid']);
- usersocial_delete_network($network['snid']);
- flash_message($lang->usersocial_del_success, 'success');
- admin_redirect("index.php?module=user-usersocial");
- }
- $form = new Form("index.php?module=user-usersocial&action=delete&snid={$network['snid']}&my_post_key={$mybb->post_code}", 'post');
- echo("
- <div class=\"confirm_action\">\n
- <p>". $lang->usersocial_del_confirm."</p><br />\n
- <p class=\"buttons\">
- {$form->generate_submit_button($lang->yes, array('class' => 'button_yes'))}
- {$form->generate_submit_button($lang->no, array("name" => "no", 'class' => 'button_no'))}
- </p>\n
- </div>
- ");
- $form->end();
- }
- $page->output_footer();
- }
- }
- function usersocial_add_network($data)
- {
- global $db;
- if (!is_array($data))
- {
- $data = array();
- }
- if ($data['sn_name'])
- {
- $data['sn_name'] = $db->escape_string($data['sn_name']);
- }
- if ($data['sn_label'])
- {
- $data['sn_label'] = $db->escape_string($data['sn_label']);
- }
- if ($data['sn_active'])
- {
- $data['sn_active'] = intval($data['sn_active']);
- }
- if ($data['sn_profil'])
- {
- $data['sn_profil'] = intval($data['sn_profil']);
- }
- if ($data['sn_postbit'])
- {
- $data['sn_postbit'] = intval($data['sn_postbit']);
- }
- if ($data['sn_image'])
- {
- $data['sn_image'] = $db->escape_string($data['sn_image']);
- }
- if ($data['sn_order'])
- {
- $data['sn_order'] = intval($data['sn_order']);
- }
- $db->insert_query('social_network', $data);
- }
- function usersocial_update_network($snid, $data)
- {
- global $db;
- if (!is_array($data))
- {
- $data = array();
- }
- if ($data['sn_name'])
- {
- $data['sn_name'] = $db->escape_string($data['sn_name']);
- }
- if ($data['sn_label'])
- {
- $data['sn_label'] = $db->escape_string($data['sn_label']);
- }
- if ($data['sn_active'])
- {
- $data['sn_active'] = intval($data['sn_active']);
- }
- if ($data['sn_profil'])
- {
- $data['sn_profil'] = intval($data['sn_profil']);
- }
- if ($data['sn_postbit'])
- {
- $data['sn_postbit'] = intval($data['sn_postbit']);
- }
- if ($data['sn_image'])
- {
- $data['sn_image'] = $db->escape_string($data['sn_image']);
- }
- if ($data['sn_order'])
- {
- $data['sn_order'] = intval($data['sn_order']);
- }
- $db->update_query('social_network', $data, "snid='{$snid}'");
- }
- function usersocial_delete_network($snid)
- {
- global $db;
- $snid = intval($snid);
- $db->delete_query('social_network', "snid='{$snid}'");
- $db->delete_query('social_user_network', "snid='{$snid}'");
- }
- function usersocial_get_icon($img)
- {
- global $mybb;
- $image = $mybb->settings['bburl'].'/images/usersocial/default.png';
- if(my_strpos($img, "ttp:/"))
- {
- $image = $img;
- }
- if(!my_strpos($img, "/") && !empty($img) && file_exists(MYBB_ROOT.'/images/usersocial/'.$img))
- {
- $image = $mybb->settings['bburl'].'/images/usersocial/'.htmlspecialchars_uni($img);
- }
- if(!empty($img) && file_exists(MYBB_ROOT.'/images/'.$img))
- {
- $image = $mybb->settings['bburl'].'/images/'.htmlspecialchars_uni($img);
- }
- return $image;
- }
- function usersocial_get_network($snid)
- {
- global $db;
- $snid = intval($snid);
- $query = $db->simple_select('social_network', '*', "snid='{$snid}'");
- $network = $db->fetch_array($query);
- $db->free_result($query);
- if($network['snid'])
- {
- return $network;
- }
- return false;
- }
- function usersocial_postbit(&$post)
- {
- global $db, $mybb, $templates;
- $post['usersocial'] = '';
- $sql = "SELECT s.sn_name, s.sn_link, s.sn_image, u.sn_value
- FROM ".TABLE_PREFIX."social_network s, ".TABLE_PREFIX."social_user_network u
- WHERE s.snid=u.snid AND u.uid='".$post['uid']."' AND u.sn_private=0 AND u.sn_value<>'' AND s.sn_active=1 AND s.sn_postbit=1
- ORDER BY s.sn_order ASC";
- $query = $db->query($sql);
- if ($db->num_rows($query)>0) {
- $post['usersocial'] = '<br />';
- while ($network = $db->fetch_array($query)) {
- $network['sn_link'] = str_replace('#username#', htmlspecialchars($network['sn_value'], ENT_QUOTES), $network['sn_link']);
- $network['sn_image'] = usersocial_get_icon($network['sn_image']);
- eval("\$post['usersocial'] .= \"".$templates->get("usersocial_postbit")."\";");
- }
- }
- }
- function usersocial_profile()
- {
- global $db, $mybb, $templates, $memprofile, $lang;
- $lang->load('usersocial');
- $memprofile['usersocial'] = '';
- $sql = "SELECT s.sn_name, s.sn_link, s.sn_image, u.sn_value, u.sn_private
- FROM ".TABLE_PREFIX."social_network s
- LEFT JOIN ".TABLE_PREFIX."social_user_network u ON ( u.snid = s.snid AND u.uid=".$mybb->user['uid'].")
- WHERE s.sn_active=1 AND s.sn_profil=1
- ORDER BY s.sn_order ASC";
- $query = $db->query($sql);
- if ($db->num_rows($query)>0) {
- $cpt = 0;
- $tr = '</tr><tr>';
- while ($network = $db->fetch_array($query)) {
- $cpt++;
- $network['even'] = ($cpt%2)+1;
- if ($network['sn_private']==1 || trim($network['sn_value'])=='')
- {
- $network['ulink'] = '';
- }
- else
- {
- $network['ulink'] = '<a href="'.str_replace('#username#', htmlspecialchars($network['sn_value'], ENT_QUOTES), $network['sn_link']).'">'. $lang->usersocial_contact .' '.$network['sn_name'].'</a>';
- }
- eval("\$memprofile['usersocial'] .= \"</tr><tr>".$templates->get("usersocial_member_profile_row")."\";");
- }
- }
- }
- function usersocial_usercp()
- {
- global $db, $mybb, $templates, $usersocial, $usersocial_rows, $lang;
- $lang->load('usersocial');
- $sql = "SELECT s.snid, s.sn_name, s.sn_link, s.sn_image, s.sn_label, u.sn_value, u.sn_private
- FROM ".TABLE_PREFIX."social_network s
- LEFT JOIN ".TABLE_PREFIX."social_user_network u ON ( u.snid = s.snid AND u.uid=".$mybb->user['uid'].")
- WHERE s.sn_active=1
- ORDER BY s.sn_order ASC";
- $query = $db->query($sql);
- $usersocial = '';
- if ($db->num_rows($query)>0)
- {
- $usersocial_rows = '';
- while ($network = $db->fetch_array($query)) {
- if ($network['sn_private']==1)
- {
- $network['checked'] = ' checked="checked"';
- }
- eval("\$usersocial_rows .= \"".$templates->get('usersocial_usercp_row')."\";");
- }
- eval("\$usersocial .= \"".$templates->get('usersocial_usercp')."\";");
- }
- }
- function usersocial_update_user()
- {
- global $db, $mybb;
- if($mybb->input['action'] == "do_profile" && $mybb->request_method == "post")
- {
- $db->delete_query('social_user_network', 'uid='.$mybb->user['uid']);
- foreach($mybb->input['sn'] as $k => $v) {
- if (isset($mybb->input['snp'][$k]) && $mybb->input['snp'][$k]==1)
- {
- $mybb->input['snp'][$k] = 1;
- }
- else
- {
- $mybb->input['snp'][$k] = 0;
- }
- $userdata = array(
- 'snid' => intval($k),
- 'uid' => intval($mybb->user['uid']),
- 'sn_value' => $db->escape_string(trim($v)),
- 'sn_private' => $mybb->input['snp'][$k]
- );
- $db->insert_query('social_user_network', $userdata);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement