function bp_checkins_settings_admin()
{
    global $bp_checkins_logs_slug;
    $active = __('Activity checkins', 'bp-checkins');
    if (!empty($_GET['tab']) && $_GET['tab'] == 'component') {
        $active = __('Checkins & Places Component', 'bp-checkins');
    }
    if (!empty($_GET['tab']) && $_GET['tab'] == 'foursquare') {
        $active = __('Foursquare API Settings', 'bp-checkins');
    }
    $upload_size_unit = $max_upload_size = wp_max_upload_size();
    $sizes = array('KB', 'MB', 'GB');
    for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
        $upload_size_unit /= 1024;
    }
    if ($u < 0) {
        $upload_size_unit = 0;
        $u = 0;
    } else {
        $upload_size_unit = (int) $upload_size_unit;
    }
    do_action('bp_checkins_cron_options');
    $schedules = wp_get_schedules();
    $admin_page = bp_checkins_16_new_admin();
    if ($admin_page == 'bp-general-settings.php') {
        $admin_page = 'admin.php';
    }
    $buddy_settings_page = bp_core_do_network_admin() ? 'settings.php' : 'options-general.php';
    ?>
	<div class="wrap">
		<?php 
    screen_icon('bp-checkins');
    ?>
		
		<h2 class="nav-tab-wrapper"><?php 
    bp_checkins_admin_tabs($active);
    ?>
</h2>
		
		<?php 
    if (isset($_POST['bpci-admin'])) {
        ?>

			<div id="message" class="updated fade">
				<p><?php 
        _e('Settings Saved', 'bp-checkins');
        ?>
</p>
			</div>

		<?php 
    }
    ?>
		
		<form action="" method="post" id="bp-admin-form">
			
			<?php 
    if (empty($_GET['tab'])) {
        ?>
			
			<table class="form-table">
				<tbody>
						<tr>
							<th scope="row"><?php 
        _e('Disable Activity checkins in profile and group post forms', 'bp-checkins');
        ?>
</th>
							<td>
								<input type="radio" name="bpci-admin[bp-checkins-disable-activity-checkins]"<?php 
        if ((int) bp_get_option('bp-checkins-disable-activity-checkins')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-activity-checkins-yes" value="1" /> <?php 
        _e('Yes', 'bp-checkins');
        ?>
 &nbsp;
								<input type="radio" name="bpci-admin[bp-checkins-disable-activity-checkins]"<?php 
        if (!(int) bp_get_option('bp-checkins-disable-activity-checkins') || '' == bp_get_option('bp-checkins-disable-activity-checkins')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-activity-checkins-no" value="0" /> <?php 
        _e('No', 'bp-checkins');
        ?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php 
        _e('Hide position of user&#39;s friends in friends list', 'bp-checkins');
        ?>
</th>
							<td>
								<input type="radio" name="bpci-admin[bp-checkins-disable-geo-friends]"<?php 
        if ((int) bp_get_option('bp-checkins-disable-geo-friends')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-geo-friends-yes" value="1" /> <?php 
        _e('Yes', 'bp-checkins');
        ?>
 &nbsp;
								<input type="radio" name="bpci-admin[bp-checkins-disable-geo-friends]"<?php 
        if (!(int) bp_get_option('bp-checkins-disable-geo-friends') || '' == bp_get_option('bp-checkins-disable-geo-friends')) {
            ?>
 checked="checked"<?php 
        }
        ?>
 id="bp-disable-geo-friends-no" value="0" /> <?php 
        _e('No', 'bp-checkins');
        ?>
							</td>
						</tr>
				</tbody>
			</table>
			
			<?php 
    } elseif ($_GET['tab'] == 'component') {
        ?>
				
				<?php 
        if (!(int) bp_get_option('bp-checkins-activate-component') || '' == bp_get_option('bp-checkins-activate-component')) {
            ?>
					
					<input type="hidden" name="bpci-admin[bp-checkins-activate-component]" value="1">
					
					<p>
						<?php 
            _e('If you want to activate this component, simply click on the &#39;Save Settings&#39; button, then you will be able to edit its behavior', 'bp-checkins');
            ?>
					</p>
					
				<?php 
        } else {
            ?>
					
					<h3><?php 
            _e('Checkins Component', 'bp-checkins');
            ?>
</h3>
					
					<table class="form-table">
						<tbody>
								<tr>
									<th scope="row"><?php 
            _e('Enable image uploads in Checkins (it needs at least <b>64M</b> of memory limit)', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[bp-checkins-enable-image-uploads]"<?php 
            if ((int) bp_get_option('bp-checkins-enable-image-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-image-uploads-yes" value="1"/> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
										<input type="radio" name="bpci-admin[bp-checkins-enable-image-uploads]"<?php 
            if (!(int) bp_get_option('bp-checkins-enable-image-uploads') || '' == bp_get_option('bp-checkins-enable-image-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-image-uploads-no" value="0"/> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
								</tr>
						</tbody>
					</table>
					
					<h3><?php 
            printf(__('<a href="%s">Places Component</a>', 'bp-checkins'), admin_url('edit.php?post_type=places'));
            ?>
 : </h3>
					
					<table class="form-table">
						<tbody>
								<tr>
									<th scope="row"><?php 
            _e('Enable image uploads in Places', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[bp-checkins-enable-place-uploads]"<?php 
            if ((int) bp_get_option('bp-checkins-enable-place-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-image-uploads-yes" value="1"/> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
										<input type="radio" name="bpci-admin[bp-checkins-enable-place-uploads]"<?php 
            if (!(int) bp_get_option('bp-checkins-enable-place-uploads') || '' == bp_get_option('bp-checkins-enable-place-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-image-uploads-no" value="0"/> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Max width for the image added via an url in Places', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="text" name="bpci-admin[bp-checkins-max-width-image]" 
										<?php 
            if ((int) bp_get_option('bp-checkins-max-width-image')) {
                echo 'value="' . intval(bp_get_option('bp-checkins-max-width-image')) . '"';
            } else {
                echo 'value="300"';
            }
            ?>
	 
										 id="bp-checkins-max-width-image"/> &nbsp;
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Enable image uploads in Places comments (it needs at least <b>64M</b> of memory limit)', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[bp-checkins-enable-comment-image-uploads]"<?php 
            if ((int) bp_get_option('bp-checkins-enable-comment-image-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-comment-image-uploads-yes" value="1"/> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
										<input type="radio" name="bpci-admin[bp-checkins-enable-comment-image-uploads]"<?php 
            if (!(int) bp_get_option('bp-checkins-enable-comment-image-uploads') || '' == bp_get_option('bp-checkins-enable-comment-image-uploads')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-comment-image-uploads-no" value="0"/> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Enable info box to show friends that checked in a place to logged in user', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[bp-checkins-enable-box-checkedin-friends]"<?php 
            if ((int) bp_get_option('bp-checkins-enable-box-checkedin-friends')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-box-checkedin-friends-yes" value="1"/> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
											<input type="radio" name="bpci-admin[bp-checkins-enable-box-checkedin-friends]"<?php 
            if (!(int) bp_get_option('bp-checkins-enable-box-checkedin-friends') || '' == bp_get_option('bp-checkins-enable-box-checkedin-friends')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-enable-box-checkedin-friends-no" value="0"/> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Amount of milliseconds for the timer in Live places', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="text" name="bpci-admin[bp-checkins-live-places-timer]" 
										<?php 
            if ((int) bp_get_option('bp-checkins-live-places-timer')) {
                echo 'value="' . intval(bp_get_option('bp-checkins-live-places-timer')) . '"';
            } else {
                echo 'value="8000"';
            }
            ?>
	 
										 id="bp-checkins-live-places-timer"/> &nbsp;
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Disable timer in the comments of live places', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[bp-checkins-disable-timer]"<?php 
            if ((int) bp_get_option('bp-checkins-disable-timer')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-disable-timer-yes" value="1"/> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
										<input type="radio" name="bpci-admin[bp-checkins-disable-timer]"<?php 
            if (!(int) bp_get_option('bp-checkins-disable-timer') || '' == bp_get_option('bp-checkins-disable-timer')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-disable-timer-no" value="0"/> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
								</tr>
						</tbody>
					</table>
					
					
					<h3><?php 
            _e('Shared settings', 'bp-checkins');
            ?>
</h3>
					
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row"><?php 
            printf(__('Max upload file size for images (%s)', 'bp-checkins'), $sizes[$u]);
            ?>
</th>
								<td>
									<input type="text" name="bpci-admin[bp-checkins-max-upload-size]" 
									<?php 
            if ((int) bp_get_option('bp-checkins-max-upload-size')) {
                echo 'value="' . intval(bp_get_option('bp-checkins-max-upload-size')) . '"';
            } else {
                echo 'value="' . intval($upload_size_unit) . '"';
            }
            ?>
	 
									 id="checkins-max-upload-size"/> &nbsp;
								</td>
							</tr>
						</tbody>
					</table>
					<p>&nbsp;</p>
					<p class="description"><?php 
            _e('Image uploads in checkin component or in the comments of places uses the HTML5 File and File Reader API, it may not work for all users depending on their browser...', 'bp-checkins');
            ?>
</p>
					
					<h3><?php 
            _e('Disable Checkins and Places components', 'bp-checkins');
            ?>
</h3>
					
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row"><?php 
            _e('Check the &#39;yes&#39; option and save the settings to disable the components', 'bp-checkins');
            ?>
</th>
								<td>
									<input type="radio" name="bpci-admin[bp-checkins-activate-component]"<?php 
            if (!(int) bp_get_option('bp-checkins-activate-component') || '' == bp_get_option('bp-checkins-activate-component')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-activate-component-yes" value="0" /> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
									<input type="radio" name="bpci-admin[bp-checkins-activate-component]"<?php 
            if ((int) bp_get_option('bp-checkins-activate-component')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-activate-component-no" value="1" /> <?php 
            _e('No', 'bp-checkins');
            ?>
								</td>
							</tr>
						</tbody>
					</table>
					
				<?php 
        }
        ?>
			
			<?php 
    } elseif ($_GET['tab'] == 'foursquare') {
        ?>
				
				<?php 
        if (!bp_is_active('settings')) {
            ?>
					
					<div id="message" class="updated">
						<p>
							<?php 
            printf(__('If you want to use this feature, you need to activate the Account Settings BuddyPress component, to do so, please activate it in <a href="%s">BuddyPress settings</a>', 'bp-checkins'), bp_get_admin_url(add_query_arg(array('page' => 'bp-components'), $buddy_settings_page)));
            ?>
						</p>
					</div>
				
				<?php 
        } elseif (!(int) bp_get_option('bp-checkins-activate-component') || '' == bp_get_option('bp-checkins-activate-component')) {
            ?>
					
					<p>
						<?php 
            printf(__('If you want to use this feature, you need to activate the Checkins and Places component, to do so use <a href="%s">the appropriate tab</a>', 'bp-checkins'), bp_get_admin_url(add_query_arg(array('page' => 'bp-checkins-admin', 'tab' => 'component'), $admin_page)));
            ?>
					</p>
					
				<?php 
        } else {
            ?>
					
					<h3><?php 
            _e('Foursquare credentials', 'bp-checkins');
            ?>
</h3>

					<table class="form-table">
						<tbody>
								<tr>
									<th scope="row"><?php 
            _e('Client ID', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="text" name="bpci-admin[foursquare-client-id]" value="<?php 
            if (bp_get_option('foursquare-client-id') && "" != bp_get_option('foursquare-client-id')) {
                echo bp_get_option('foursquare-client-id');
            }
            ?>
" id="foursquare_client_id">
									</td>
									<td>
										<p class="description"><?php 
            _e('given by Foursquare once you registered an API key.', 'bp-checkins');
            ?>
</p>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Client Secret', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="text" name="bpci-admin[foursquare-client-secret]" value="<?php 
            if (bp_get_option('foursquare-client-secret') && "" != bp_get_option('foursquare-client-secret')) {
                echo bp_get_option('foursquare-client-secret');
            }
            ?>
" id="foursquare_secret_id">
									</td>
									<td>
										<p class="description"><?php 
            _e('given by Foursquare once you registered an API key.', 'bp-checkins');
            ?>
</p>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Callback Url', 'bp-checkins');
            ?>
</th>
									<td>
										<p style="color:green"><?php 
            echo site_url(bp_get_checkins_root_slug());
            ?>
</p>
									</td>
									<td>
										<p class="description"><?php 
            _e('The callback url is needed when registering a Foursquare API key.', 'bp-checkins');
            ?>
</p>
									</td>
								</tr>
						</tbody>
					</table>

					<p class="description"><?php 
            printf(__('If you have not registered a Foursquare API Key, yet, you can get one by clicking <a href="%s">here</a>. You will be able to choose your application name, your application website and the callback url displayed in green on this screen.', 'bp-checkins'), 'https://foursquare.com/oauth/register');
            ?>
</p>

					<h3><?php 
            _e('Foursquare import preferences', 'bp-checkins');
            ?>
</h3>

					<table class="form-table">
						<tbody>
								<tr>
									<th scope="row"><?php 
            _e('Use WordPress Cron', 'bp-checkins');
            ?>
</th>
									<td>
										<select name="bpci-admin[foursquare-cron-schedule]" id="foursquare_cron_schedule">
											<option value="0"><?php 
            _e('Do not use WP Cron', 'bp-checkins');
            ?>
</option>
											<?php 
            foreach ($schedules as $value_interval => $display_interval) {
                ?>
												<option value="<?php 
                echo $value_interval;
                ?>
" <?php 
                selected(bp_get_option('foursquare-cron-schedule'), $value_interval);
                ?>
><?php 
                echo $display_interval['display'];
                ?>
</option>
											<?php 
            }
            ?>
										</select>
									</td>
									<td>
										<p class="description"><?php 
            _e('WordPress Cron is run when a frontend or admin page is loaded on your web site', 'bp-checkins');
            ?>
</p>
										<?php 
            if (!empty($bp_checkins_logs_slug)) {
                ?>
											<p class="description"><a href="<?php 
                bp_checkins_admin_url($bp_checkins_logs_slug);
                ?>
"><?php 
                _e('Foursquare import logs page', 'bp-checkins');
                ?>
</a></p>
										<?php 
            }
            ?>
									</td>
								</tr>
								<tr>
									<th scope="row"><?php 
            _e('Enable your members to import manually their checkins', 'bp-checkins');
            ?>
</th>
									<td>
										<input type="radio" name="bpci-admin[foursquare-user-import]"<?php 
            if (!(int) bp_get_option('foursquare-user-import') || '' == bp_get_option('foursquare-user-import')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="foursquare_user_import_yes" value="0" /> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
										<input type="radio" name="bpci-admin[foursquare-user-import]"<?php 
            if ((int) bp_get_option('foursquare-user-import')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="foursquare_user_import_no" value="1" /> <?php 
            _e('No', 'bp-checkins');
            ?>
									</td>
									<td>
										<p class="description"><?php 
            _e('If enabled, members will be able to import their checkins from the checkins tab of their settings area', 'bp-checkins');
            ?>
</p>
									</td>
								</tr>
						</tbody>
					</table>
					<h3><?php 
            _e('Disable Foursquare API', 'bp-checkins');
            ?>
</h3>
					
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row"><?php 
            _e('Check the &#39;yes&#39; option and save the settings to disable foursquare API', 'bp-checkins');
            ?>
</th>
								<td>
									<input type="radio" name="bpci-admin[bp-checkins-deactivate-foursquare]"<?php 
            if ((int) bp_get_option('bp-checkins-deactivate-foursquare') == 1) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-deactivate-foursquare-yes" value="1" /> <?php 
            _e('Yes', 'bp-checkins');
            ?>
 &nbsp;
									<input type="radio" name="bpci-admin[bp-checkins-deactivate-foursquare]"<?php 
            if (!(int) bp_get_option('bp-checkins-deactivate-foursquare') || '' == bp_get_option('bp-checkins-deactivate-foursquare')) {
                ?>
 checked="checked"<?php 
            }
            ?>
 id="bp-checkins-deactivate-foursquare-no" value="0" /> <?php 
            _e('No', 'bp-checkins');
            ?>
								</td>
							</tr>
						</tbody>
					</table>
					
				<?php 
        }
        ?>
				
			<?php 
    }
    ?>
			
			<p class="submit">
				<input class="button-primary" type="submit" name="bp_checkins_admin_submit" id="bp-checkins-admin-submit" value="<?php 
    _e('Save Settings', 'bp-checkins');
    ?>
" />
			</p>

			<?php 
    wp_nonce_field('bp-checkins-admin');
    ?>
			
		</form>
		
	</div>
	<?php 
}
function bp_checkins_places_get_delete_comment_link($comment_id = false)
{
    $url = bp_get_root_domain() . '/' . bp_get_checkins_root_slug() . '/comments/delete/' . $comment_id;
    $link = wp_nonce_url($url, 'bp_checkins_comment_delete_link');
    return apply_filters('bp_checkins_places_comment_delete_link', $link);
}