Author Topic: REQUEST - lock and unlock threads.  (Read 7418 times)

Offline LI Oddities

REQUEST - lock and unlock threads.
« on: April 15, 2007, 11:49:12 pm »
I would like to see an object that one can buy that would allow them to lock or unlock a thread. It should basicly toggle the locked status on use.
« Last Edit: April 19, 2007, 01:01:31 am by LI Oddities »

Offline LI Oddities

Re: REQUEST - lock and unlock threads.
« Reply #1 on: April 19, 2007, 01:02:18 am »
I solved my own question. Seeing as I dont know PHP or SQL I didn't think I could but moding the sticky item was cake.

Offline Lew_Cipher

Re: REQUEST - lock and unlock threads.
« Reply #2 on: April 25, 2007, 01:10:01 am »
I solved my own question. Seeing as I dont know PHP or SQL I didn't think I could but moding the sticky item was cake.

Can you post what you did or, better yet, package it as an item for us?

Offline zsw007

Re: REQUEST - lock and unlock threads.
« Reply #3 on: October 04, 2007, 09:29:54 am »
I solved my own question. Seeing as I dont know PHP or SQL I didn't think I could but moding the sticky item was cake.

Can you post what you did or, better yet, package it as an item for us?

please
Quote from: zsw007
im not an expert yet,sorry

Applaud me if you like my post(which means i helped you), i like Applauds :P

Offline inkstains

Re: REQUEST - lock and unlock threads.
« Reply #4 on: October 04, 2007, 07:27:16 pm »
name the php file

lockTopic.php

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: StickyTopic.php 79 2007-01-18 08:26:55Z daniel15                        $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_lockTopic extends itemTemplate
{
 
    function 
getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail 'dansoft@dansoftaustralia.net';

          
$this->name 'Lock Topic';
          
$this->desc 'Lock any one of your topics!';
          
$this->price 400;

          
$this->require_input true;
          
$this->can_use_item true;
    }

    function 
getUseInput()
{
global $db_prefix$ID_MEMBER;

$returnStr '
Please choose which topic you would like to lock: <br />
<select name="lockTopic">'
;

$result db_query("
SELECT t.ID_TOPIC, t.locked, m.subject
FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_MEMBER_STARTED = 
{$ID_MEMBER} AND m.ID_MSG = t.ID_FIRST_MSG"__FILE____LINE__);
while ($row mysql_fetch_assoc($result))
{
if ($row['locked'] == 0)
{
$returnStr .= '<option value="' $row['ID_TOPIC'] . '">' $row['subject'] . '</option>';
}
}

$returnStr .= '</select>';
        return 
$returnStr;
    }

    function 
onUse()
{
global $db_prefix$ID_MEMBER;

if (!isset($_POST['lockTopic'])) die('ERROR: No topic chosen!');
$_POST['lockTopic'] = (int) $_POST['lockTopic'];

$result db_query("
SELECT locked, ID_MEMBER_STARTED
FROM 
{$db_prefix}topics
WHERE ID_TOPIC = 
{$_POST['lockTopic']}"__FILE____LINE__);
$row mysql_fetch_assoc($result);

if (mysql_num_rows($result) == 0)
die('ERROR: That topic does not exist!');
if ($row['ID_MEMBER_STARTED'] != $ID_MEMBER)
die ('ERROR: That isn\'t your topic!');

db_query("
UPDATE 
{$db_prefix}topics  
SET locked = 1
WHERE ID_TOPIC = 
{$_POST['lockTopic']}
LIMIT 1"
__FILE____LINE__);
 
        return 
'Made topic #' $_POST['lockTopic'] . ' locked!';
    }
}

?>


Offline zsw007

Re: REQUEST - lock and unlock threads.
« Reply #5 on: October 05, 2007, 06:58:05 am »
name the php file

lockTopic.php

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: StickyTopic.php 79 2007-01-18 08:26:55Z daniel15                        $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_lockTopic extends itemTemplate
{
 
    function 
getItemDetails()
{
$this->authorName 'Daniel15';
$this->authorWeb 'http://www.dansoftaustralia.net/';
$this->authorEmail 'dansoft@dansoftaustralia.net';

          
$this->name 'Lock Topic';
          
$this->desc 'Lock any one of your topics!';
          
$this->price 400;

          
$this->require_input true;
          
$this->can_use_item true;
    }

    function 
getUseInput()
{
global $db_prefix$ID_MEMBER;

$returnStr '
Please choose which topic you would like to lock: <br />
<select name="lockTopic">'
;

$result db_query("
SELECT t.ID_TOPIC, t.locked, m.subject
FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_MEMBER_STARTED = 
{$ID_MEMBER} AND m.ID_MSG = t.ID_FIRST_MSG"__FILE____LINE__);
while ($row mysql_fetch_assoc($result))
{
if ($row['locked'] == 0)
{
$returnStr .= '<option value="' $row['ID_TOPIC'] . '">' $row['subject'] . '</option>';
}
}

$returnStr .= '</select>';
        return 
$returnStr;
    }

    function 
onUse()
{
global $db_prefix$ID_MEMBER;

if (!isset($_POST['lockTopic'])) die('ERROR: No topic chosen!');
$_POST['lockTopic'] = (int) $_POST['lockTopic'];

$result db_query("
SELECT locked, ID_MEMBER_STARTED
FROM 
{$db_prefix}topics
WHERE ID_TOPIC = 
{$_POST['lockTopic']}"__FILE____LINE__);
$row mysql_fetch_assoc($result);

if (mysql_num_rows($result) == 0)
die('ERROR: That topic does not exist!');
if ($row['ID_MEMBER_STARTED'] != $ID_MEMBER)
die ('ERROR: That isn\'t your topic!');

db_query("
UPDATE 
{$db_prefix}topics  
SET locked = 1
WHERE ID_TOPIC = 
{$_POST['lockTopic']}
LIMIT 1"
__FILE____LINE__);
 
        return 
'Made topic #' $_POST['lockTopic'] . ' locked!';
    }
}

?>


thanks  ;)   O0
Quote from: zsw007
im not an expert yet,sorry

Applaud me if you like my post(which means i helped you), i like Applauds :P

Offline inkstains

Re: REQUEST - lock and unlock threads.
« Reply #6 on: October 05, 2007, 09:12:39 am »
i should say i only made that item to lock topics. there are no unlock functions but it wouldn't be to hard to add the options to that file.