Example #1
0
function DeleteLink()
{
    global $context, $mbname, $txt, $smcFunc, $user_info;
    if (!empty($_REQUEST['id'])) {
        $id = (int) $_REQUEST['id'];
    }
    is_not_guest();
    if (empty($id)) {
        fatal_error($txt['smflinks_nolinkselected']);
    }
    $dbresult = $smcFunc['db_query']('', '
		SELECT ID_MEMBER
		FROM {db_prefix}links
		WHERE ID_LINK = {int:this_id}
		LIMIT 1', array('this_id' => $id));
    $row = $smcFunc['db_fetch_assoc']($dbresult);
    $smcFunc['db_free_result']($dbresult);
    if (!allowedTo('delete_links_any') && (!allowedTo('delete_links_own') || $row['ID_MEMBER'] != $user_info['id'])) {
        fatal_error($txt['smflinks_perm_link_no_delete']);
    }
    $context['links_id'] = $id;
    $context['sub_template'] = 'deletelink';
    // Set the page title
    $context['page_title'] = $mbname . $txt['smflinks_title'] . ' - ' . $txt['smflinks_dellink'];
    // Check if they are allowed to delete the link
    $dbresult = $smcFunc['db_query']('', '
		SELECT ID_LINK,ID_CAT
		FROM {db_prefix}links
		WHERE ID_LINK = {int:this_id}
		LIMIT 1', array('this_id' => $id));
    $row = $smcFunc['db_fetch_assoc']($dbresult);
    $smcFunc['db_free_result']($dbresult);
    GetCatPermission($row['ID_CAT'], 'dellink');
}
Example #2
0
function DeleteLink()
{
    global $context, $mbname, $txt, $db_prefix, $ID_MEMBER;
    if (!empty($_REQUEST['id'])) {
        $id = (int) $_REQUEST['id'];
    }
    is_not_guest();
    if (empty($id)) {
        fatal_error($txt['smflinks_nolinkselected']);
    }
    $dbresult = db_query("\n\tSELECT ID_MEMBER, ID_LINK   \n\tFROM {$db_prefix}links \n\tWHERE ID_LINK = {$id} LIMIT 1", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($dbresult);
    mysql_free_result($dbresult);
    if (empty($row['ID_LINK'])) {
        fatal_error($txt['smflinks_nolinkselected']);
    }
    if (!allowedTo('delete_links_any') && (!allowedTo('delete_links_own') || $row['ID_MEMBER'] != $ID_MEMBER)) {
        fatal_error($txt['smflinks_perm_link_no_delete']);
    }
    $context['links_id'] = $id;
    $context['sub_template'] = 'deletelink';
    // Set the page title
    $context['page_title'] = $mbname . $txt['smflinks_title'] . ' - ' . $txt['smflinks_dellink'];
    // Check if they are allowed to delete the link
    $dbresult = db_query("\n\tSELECT ID_LINK,ID_CAT \n\tFROM {$db_prefix}links \n\tWHERE ID_LINK = {$id} LIMIT 1", __FILE__, __LINE__);
    $row = mysql_fetch_assoc($dbresult);
    mysql_free_result($dbresult);
    GetCatPermission($row['ID_CAT'], 'dellink');
}
Example #3
0
function DeleteLink()
{
    global $context, $txt, $smcFunc, $user_info;
    // Our link id.
    if (!empty($_REQUEST['id'])) {
        $id = (int) $_REQUEST['id'];
    }
    if (empty($id)) {
        fatal_error($txt['smflinks_nolinkselected'], false);
    }
    // No guests.
    is_not_guest();
    // Try to pull our member id.
    $dbresult = $smcFunc['db_query']('', '
		SELECT ID_MEMBER
		FROM {db_prefix}links
		WHERE ID_LINK = {int:this_id}
		LIMIT 1', array('this_id' => $id));
    // Did we try to sneak in an invalid ID?
    if ($smcFunc['db_num_rows']($dbresult) == 0) {
        fatal_error($txt['smflinks_nolinkselected'], false);
    } else {
        $row = $smcFunc['db_fetch_assoc']($dbresult);
    }
    // Free the result.
    $smcFunc['db_free_result']($dbresult);
    // See if we can truly delete this.
    if (!allowedTo('delete_links_any') && (!allowedTo('delete_links_own') || $row['ID_MEMBER'] != $user_info['id'])) {
        fatal_error($txt['smflinks_perm_link_no_delete']);
    }
    $context['links_id'] = $id;
    $context['sub_template'] = 'deletelink';
    // Set the page title
    $context['page_title'] = $context['forum_name'] . $txt['smflinks_title'] . ' - ' . $txt['smflinks_dellink'];
    // Check if they are allowed to delete the link
    $dbresult = $smcFunc['db_query']('', '
		SELECT ID_LINK, ID_CAT
		FROM {db_prefix}links
		WHERE ID_LINK = {int:this_id}
		LIMIT 1', array('this_id' => $id));
    // Any row returned?
    if ($smcFunc['db_num_rows']($dbresult) == 0) {
        fatal_error($txt['smflinks_nolinkselected'], false);
    } else {
        $row = $smcFunc['db_fetch_assoc']($dbresult);
    }
    // Free the result and then check permission.
    $smcFunc['db_free_result']($dbresult);
    GetCatPermission($row['ID_CAT'], 'dellink');
}