Block Type: phpblock
Block Location: Left/Right/Center/Frontpage/Article Block
SMF/TP Supported Versions: SMF 1.1RC2 and up, TP 0.8.6 and up
Description:
This block allows you to have a member submitted links block within your site. Members are granted access per membergroup. You can grant ADD, EDIT, and DELETE access individually to any group(s). Admins of course have all access. You can also deny access to any member regardless if they are in an allowed group. Additionally, you can supply a deny group which denies a member access if they are a member of that group even if they are a member of an allowed group.
Members fill in a short description for the site and the URL. Mouse "hovering" over links displays member who submitted link. Links are displayed in block, x number of columns as you specify in the configuration. Members in a membergroup that have EDIT or DELETE access will see a radio button before the link for selection when editing or deleting links. They will also have an edit button and/or delete button depending on that access.
Additionally, if you allow members to edit and/or delete their own links, then members who have submitted links will have the radio buttons before each of their links and the edit and/or delete button at the bottom to act on those links as appropriate.
Config Variables:
$li_addlink_groups = array('') :: Set the membergroups you want able to ADD links in this array. Multiple groups supported - Example array('5', '9', '16').
$li_editlink_groups = array('') :: Set the membergroups you want able to EDIT links in this array. Multiple groups supported - Example array('6', '3', '12').
$li_dellink_groups = array('') :: Set the membergroups you want able to DELETE links in this array. Multiple groups supported - Example array('2', '4', '6').
$li_deny_groups = array('') :: If user is a member of any of these groups, deny them ADD/EDIT/DELETE access regardless of other group membership they have.
$li_deny_members = array('') :: If user's member ID is in this array, deny them ADD/EDIT/DELETE access regardless of any group membership they have.
$li_edit_own = x :: 0 = No, 1 = Yes - allow users to edit links they submitted
$li_del_own = x :: 0 = No, 1 = Yes - allow users to delete links they submitted
$li_editbox_size = <integer> :: Size of the edit box displayed for Description and URL
$li_urlname_maxsize = <integer> :: Maximum size of the text used for the URL Name (description)
$li_columns = <integer> :: Number of columns of links you want displayed.
$li_start_row = <tr "some options / styles"> :: Allows you to configure row styles and options if you want (default = '<tr>')
$li_start_col = <td "some options / styles"> :: Allows you to configure column styles and options if you want (default = '<td>')
$li_tablename = tablename (without prefix) :: Set this to the table name you want to use. The smf prefix you have configured in smf will automatically be prepended to this name.
$li_sort = sort order :: 0 = sort chronologically, 1 = sort alphabetically, 2 = sort by submitter name.
$li_sort_direction = ascending or descending :: 0 = ascending, 1 = descending.
There are other configuration variables that are less important or at least don't need to be changed as much. For info on those, see the comments in the code itself.
//////////////////////////////////////////////
// Linkit Version 1.7.1
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update May 18, 2007
//
// 1.7.1:
// - added explicit sort by ID when $li_sort = 0 so that if you edit your database table, changing ID numbers,
// you can sort by the ID instead of the order data was entered into the table
//
// This is a php block and/or php Article snippet. It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate. Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links. You
// can create the table manually if necessary.
//
//////////////////////////////////////////////
/*
****************************************
****************************************
*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// ***** SECURITY OPTIONS *****
// who has addlink access? - format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('14');
$li_addlink_groups = array('');
// who can edit links? - same format as addlink
$li_editlink_groups = array('');
// who can delete links? - same format as addlink
$li_dellink_groups = array('');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 0;
$li_del_own = 0;
// ***** LAYOUT OPTIONS *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns? change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';
// approximate number of lines displayed in block 0 = unlimited
$li_blocklines = 30;
// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;
// make it easier to use non-blanking spaces (TP blocks/articles will remove them from your code the next time you edit the same block/article)
// using a variable instead, will let you keep that code intact.
$nbsp = '&'.'nbsp;';
// ***** OTHER OPTIONS *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "Linkit!";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links! ".$nbsp."Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
if (!empty($li_title))
echo '<center><b>' . $li_title . '</b></center><br />';
if (!empty($li_desc))
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/
//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;
// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}
switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}
// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];
// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}
// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed! Table NOT Created!<br />\n");
}
}
// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Inserted into database!<br />\n");
}
}
// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT modified in database!<br />\n");
}
}
}
// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Deleted from database!<br />\n");
}
}
/////////// MAIN CODE HERE ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];
// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}
// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}
// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}
//////////// MAIN DISPLAY CODE HERE ///////////////
// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename ORDER BY id ASC";
}
$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}
// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}
function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}
function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}
function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}
// -->
</script>
';
// if we set number of lines, make that setting here
if (!empty($li_blocklines)){
// pad according to class chosen
switch ($li_useclass){
case 1:
// smalltext class - padding 8 for IE, and 5 for all other browsers
$li_blocklines += empty($context['browser']['is_ie']) ? 5 : 8;
break;
case 2:
// normaltext class - padding 14 for IE, and 9 for all other browsers
$li_blocklines += empty($context['browser']['is_ie']) ? 9 : 14;
break;
default:
// no class - padding 10 for IE, 9 for all other browsers
$li_blocklines += empty($context['browser']['is_ie']) ? 9 : 10;
}
echo '
<div style="width: 100%; overflow: auto; height: '.$li_blocklines.'em;">
';
}
// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}
// preset our current column to first column
$li_current_column = 1;
// start our table and first row
echo '<center><table width="90%" border="0"><tr>' . "\n";
// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;
// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] . '</a></td>' . "\n";
// next column number
$li_current_column++;
}
// end our last row and our table
echo "</tr>\n</table></center>\n";
// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form, \'li_checkbox\');"> Check/Uncheck all</input></div>';
}
// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test" onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" /> ';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" /> ';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}
// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';
// and finally, end our form
echo '</form>';
// if we added the <div> for our blocklines, close it here
if (!empty($li_blocklines))
echo '</div>';
// free the result for good measure
mysql_free_result($dbresult);
takes a little configurating but i like! forum sponsors can be added to a special group and given access to post what links they wish and edit them as need possibly for specials or what have you. thanks for the snippet!
if anyone else is going to use this, it goes in a php block, and change the wording so it says url doesnt require http:// as this is added automatically.
nice...
Sorry... I should have put a bit more explanation in there, but it was a bit late. :laugh:
Some things to note:
- putting http:// in front of your link in the URL Link editbox is not required as the script will do this for you if it is absent
- the edit button (e), for those that have edit privilege, uses the same URL Name and URL Link editboxes for making changes. If you leave one or the other empty, that value is left unchanged for that link entry. In otherwords, to keep the same "name" for the link, just leave the URL Name editbox empty (same for URL Link box if you only want to change the name and not the link). Obviously at least one needs to have something in it to make a change.
- the delete button (d) does not require either editbox, it simply deletes that entry.
- each permission (add, edit, delete) is seperate, so theoretically you could have members with edit permission but not add. Don't know why you would, but the versatility is there.
- Admins always have add/edit/delete permissions.
- Mouse hover on name shows who submitted the link
- The editbox for the URL Name is resticted to 20 characters because I wanted it to fit in a side block and prevent the block from being messed up if someone happened to put in a long name. Obviously if you put this in a center block you can support much longer names without messing up the "look" of the site.
Things I still plan to do:
- link authentication so users with only Add permission don't have to ask an Admin to fix their typo's all the time. Possibly asking the user if they want a test popup to the link before adding it to the database, with a confirmation after it or something.
- add another setting to to turn on/off ability for a member to edit and/or delete links "they" added.
There are a few other things I plan to do (hopefully this weekend - work has been busy), which I will post soon as I get to it.
If you don't want to play with this code yourself, but have ideas of something you want in it, let me know and I'll try to accommodate.
thanx dude. Looks good...
This is very good. I love how it actually uses permissions by membergroup. I have been trying to add some stuff to my site to give some perks to the people that have donated to our clan. This is a good feature that the guys at my site will love.
I know this is off topic but does anyone know of a way to restrict certain BBCodes by membergroup?
Thanks again for the great block.
Modified the code a bit to fix the "Undefined Index" warnings left in your Forum error logs. These would occur if the page was refreshed outside of using the form since the $_POST vars would no longer be set. Sorry about that. ;)
New code has replaced original code in the original post. Get it from there.
Thank you Thurnoc for the code and the work behind it :)
One more quick update before I head out for some weekend fun - Updated the code in first post to not allow duplicates.
Hmm. Getting an error message: "Unexpected error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)" Any ideas what I've...
~not done
~done, but shouldn't have
~done, but done wrong
Bound to be be one of them!
Very cool !!!
Works if placed in a php article as well.. Thanks a million for this!!
Quote from: zillion on August 10, 2006, 12:58:36 AM
Hmm. Getting an error message: "Unexpected error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"
Well, typically that error has to do with not authenticating to the MySQL server. If your SMF and TinyPortal are working correctly however, this should not be the case.
Did you have any other errors prior to putting in the Linkit block? Try removing the Linkit block, clear your forum errors so it is empty, then manuever around in TP and SMF selecting different options and return to see if you have any other errors listed in your admin control panel.
Also, what version of PHP and MySQL is your server running? And what version of SMF/TinyPortal?
I probably should have stated (and I will update the first post to state so) that this has been tested in SMF 1.1 RC2 w/ Tiny Portal 0.86 by myself. I don't know if some others have tried it in different flavors of SMF/TP successfully or not. I tried to make it as generic as possible, but in order to use some of the built-in globals, it may be SMF specific.
(For the record I'm using: SMF 1.1 RC2, Tinyportal 0.8.6, PHP 4.3.1 and MySQL 4.1.11)
STEP ONE: Deleted Block, cleared Error Log, furkled-around and inspected Error Log. One entry shows:
Today at 13:59
http://ccgi.zillion.plus.com/netsandedges/index.php
8: Undefined index: prepend
File: /files/home3/zillion/MMM/libraries/lib-view-zone.inc.php
Line: 288
This seems to relate to my Adserver (Max Media Manager)
STEP TWO: Cleared Error Log, reinstalled block, inspected error log and it now shows three errors:
Today at 13:59
http://ccgi.zillion.plus.com/netsandedges/index.php
2: mysql_query(): A link to the server could not be established
File: /files/home3/zillion/netsandedges/Themes/TPAmberRC2/TPortal.template.php (eval?)
Line: 177
Today at 13:59
http://ccgi.zillion.plus.com/netsandedges/index.php
2: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
File: /files/home3/zillion/netsandedges/Themes/TPAmberRC2/TPortal.template.php (eval?)
Line: 177
Today at 13:59
http://ccgi.zillion.plus.com/netsandedges/index.php
8: Undefined index: prepend
File: /files/home3/zillion/MMM/libraries/lib-view-zone.inc.php
Line: 288
Hmm... it almost looks as though you might have another php block somewhere that is making some MySQL calls and then at the end of it, closes the connection (i.e. mysql_close($link) somewhere near the end of it). I'm not sure about the order index for blocks (going by creation date, or positional) but I would start by looking at the last php block you made prior to the Linkit block and see if it has a mysql_close() function in it.
In the mean time, I'm looking through my code for any inconsistencies or errors that might cause your issue under some sort of circumstances.
I'm reminded of that old children tune that goes something like "Conjunction junction... what's your function? ... putting AND, BUT, and OR, together to make them function..."
Problem: Adding links where you put the full URL including the "http://" part caused the link to show up as "http://http//<some link>". The Edit feature worked correctly however.
Resolution: Mistakingly used an OR (||) instead of an AND (&&) in the Add link function - got my conjuctions mixed up ;)
heh.. fixed code in original post
Quote from: Thurnok on August 11, 2006, 09:08:51 PM
.. you might have another php block somewhere that is making some MySQL calls and then at the end of it, closes the connection (i.e. mysql_close($link) somewhere near the end of it).
I do have two other php blocks, but neither has the mysql_close function in the script.
I got the error info below:
QuoteNot Found
The requested URL /forum/forum/index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I noticed the error : URL /forum/forum/index.php seems duplicated.
Ps: My forum installed in Http://mydomain.com/forum
What should I do know ? thanx
Quote from: yj98 on August 12, 2006, 02:40:34 PMI noticed the error : URL /forum/forum/index.php seems duplicated.
Ps: My forum installed in Http://mydomain.com/forum
What should I do know ? thanx
FIXED: New code posted in original post.
If you weren't using the root of the domain as your forum location, you would receive that problem. It should be corrected now, check it out and let me know.
Additionally: Added two denial arrays. You can now list groups that if a member is in, they are denied the ADD/EDIT/DELETE access regardless if they are in a previous group that was authorized. You can also deny individual users access regardless if they are in a group with access or not. Both are in the configuration area of the snippet and are arrays like the others.
Yes. Cool. Its working . Thanx . Keep up good code. Thurnok.
Here's My front-page: http://irpsoft.com/forum
But another issues is coming . No member except ADMIN could add link, even Global moderator cannot.
Make sure you add the membergroups you want to have Add access in the beginning of the snippet. In the User Configurable items area:
$li_addlink_groups = array('');
This is an array that holds the membergroups ID numbers that you want to be able to "add" links. To use it, find the membergroup ID numbers of the groups you want to give access and enter them like this example:
$li_addlink_groups = array('7', '9', '14');
The above example would give "add" access to membergroups 7, 9, and 14.
To find the membergroup numbers for each membergroup, go to your control panel, select the Membergroups menu item under the Members category, and hover your mouse over each membergroup's Modify link. The number for that membergroup should be the last item in the link that the statusbar shows.
Changed HTTP_REFERER to PHP_SELF. Seems some sites don't set the former superglobal.
Added a variable in the config section to set the size of the URL Name and URL Link editboxes. Adjust as you need for your block size.
Ok, I'll do some real work next time. ;)
Modified code in first post. This will now work properly in IE, and in an Article not displayed on the Frontpage.
Ive just put this in on my forum and its working like a dream I just need to keep an eye on it now and make sure all the links students put up are pg13. :) little darlings that they are have a tendency to neglect their studies for things more shall we say naturallllll. :D
Ok... I lied when I said I would do some real work next time. A friend of mine was using my snippet and asked for some change. Here is the result of that.
This is the Linkit! block that you should use for either a center block or an article. It is good if you have many links submitted by your members.
What's different:
This version creates a table of x number columns and displays the links across those columns, creating new rows as needed. You can also modify the starting row and column tags if you like ($li_start_row and $li_start_col), for example to add your own style/font/colors/whatever.
$li_columns in the LAYOUT section of the Configuration area defines the number of columns. Set this to your preference as looks best for your site. I'm using 3 on one of mine, and 4 on others. All other features are identical to the original version.
Since the layouts between this version and the original are different, I'll leave the original code in the first post and place this version's code here.
Here's the code (oh yea, place in center block as phpblock or article as php article):
REMOVED! SEE FIRST POST
Here's a screenie of it in an Article (not on frontpage) from admin perspective:
Nice work Thurnok! Seems a lot of people like this stuff.
eh... its just a simple little thing. Unfortunately my time is spread so thin with work I rarely seem to have time for anything elaborate anymore. But when I do get some time, I will definately make something nice.
But I'm glad its getting some use. :)
To check this TP Block out, without having to install it on your own site, you can demo it at my TP blocks site: http://tpblocks.ccs-net.com
Register to get a view of both from the "user" perspective, as well as an "admin" perspective.
Modified original code.
Changed to go to the TP table prefix instead of the SMF table prefix since it is a TP block, not an SMF hack/mod/whatever.
If you have an existing version and are copying any new updates to this block, you should first rename your existing linkit table to fit the new name. For example, if you left the table info using defaults it would currently be something like smf_linkit where the new name would be something like smf_tp_linkit. In other words, smf_ prefix to smf_tp_ prefix.
Simply rename your table to the new name to keep all current link information when you use the new code from here forward.
so is it the code in the first post that you have now modified?
woops! Thanks for pointing that out daft! I completely forgot I had both the left/right blocks version and the center/article version in the same thread over here at TP. Hehe.. ok, I just updated both versions in this thread (just to be sure).
Also, note that there is an IE Caveat: the edit and delete buttons do not work in IE due to IE's implimentation (or should I say mis-implimentation) of the <button> tag. I'll fix this shortly.
Both versions have been updated to work with IE fully now. To find out more info on why it didn't work originally, and what I did to fix it, go to my TP blocks site and read this message (http://tpblocks.ccs-net.com/index.php?topic=8.msg28#msg28).
Update 1.2
- The Linkit Center and Linkit are now one and the same. With Linkit Center you can simply set your columns to 1 and it will work in a left/right block just fine. So there will no longer be two different versions of Linkit from this point on.
- No more Edit and Delete buttons for each link - a single radio button now (conserves space)
- The real reason for the radio buttons - TRULY fixed IE problem - works in IE now FOR REAL!
The updated code is in the first post.
Great idea and obviously lots of fans. Thanks...I get the following error message:
Parse error: parse error, unexpected T_STRING in /home/mkjddj/public_html/smf/Sources/Load.php(1607) : eval()'d code(34) : eval()'d code on line 1
make sure you put it into a phpblock
This is a very flexible and easy to use snippet.
and there is a lot of ways to use it...have fun all ;)
Thurnok, did you say there is a left/right-block version? I can't see it ...
Great snippet, btw.
There used to be, but the center block version actually works for left/right blocks as well. Simply set the columns to 1 and it works great for left/right blocks. :)
got it, thanks
I still get an error message trying to install...Parse error: parse error, unexpected T_STRING in /home/mkjyey/public_html/smf/Sources/Load.php(1607) : eval()'d code(34) : eval()'d code on line 1 ...and am thinking i may have to manually install a table. how do i do this? thanks!
Not sure what you are doing, but that error does not indicate a problem with table creation. It is generally idicative of a typo in code, but I'm unable to reproduce the problem.
What version of SMF and TP are you running on?
If you want me to take a peek, you can PM me with site name, and a temp admin id/pass to look for you.
Very nice snippet.. is it possible to add a scrollbar ??
Cheers
Knat
Possible for a future update, however mostly it will depend on time and when the TP Link module is released. Linkit is more of a temporary solution to the Link module (~possibly~).
Very nice work, Thurnok. How would I go about making it so the links wrap instead of expanding the cell to accomodate? I'd like to put longer url names in but am finding that it's pushing the right side of my page off the screen.
It should automatically wrap, but it may have to do with the Theme you are using. Here's an Admin shot, and a User shot of it with a long URL Name that wraps - see screenies:
Great job!!
One question about the layout although not critical... how can I move the 'add URL link' box below the text itself? The 'add URL name' box appears neatly below the text...
Thanks
[edit] - Problem solved. Seems to me it's only the blocks width that causes the problem!
@sledge
Another thing you might consider is either expanding the block size (left or right - whichever side you have it in), or placing it in a center block / article instead. Especially if you want to have really long descriptive names for the links. With a center block/article, you can also set the columns to 3 or 4 or whatever to have multi-column display of the links.
@sanax
Good deal. Yea, sometimes it is a matter of a couple pixels depending on your theme. Adjusting the block size usually will do the trick. If need be, you can always add a
<br />
tag right after the text in the code forcing a line break.
Quote@sledge
Another thing you might consider is either expanding the block size (left or right - whichever side you have it in), or placing it in a center block / article instead. Especially if you want to have really long descriptive names for the links. With a center block/article, you can also set the columns to 3 or 4 or whatever to have multi-column display of the links.
Got it! I think it was my theme (Oxygen) causing it because nothing I tried worked, except the following:
$li_columns = 3;
// want to add your own styles to the rows/columns? change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td width="33%" padding-left: 3; padding-right: 3" bgcolor="#F4F5FA">';I defined the width of the cells and now they wrap beautifully.
Another question: Is there a way to alter the code so the new links go to the top instead of the bottom? I use your block to list interesting news from around the world (have a look: http://www.politipoll.net). I don't want to edit every link each day, but add one to the top and delete one from the bottom as I find interesting stories. Is it possible?
A sorting feature has been planned, I just hadn't gotten around to doing it yet. hehe
But certainly, sorting by alphabetically, or chronologically is possible and I do have plans to impliment that, just has been on the end of a long list.
Update 1.3
- added sorting - sort by chronological, alphabetic, or submitted by order and either ascending or descending
Updated code in first post.
$li_sort = x ; x=0 - chronological || x=1 - alphabetical || x=2 - submitted by
$li_sort_direction = x ; x=0 - ascending || x=1 - descending
:up: :up:
Now that is very cool...
Thanks Thurnok :)
PERFECT!! Thank you Thurnok! It works magnificently.
Good Job! thank you
I wish users could edit their own sent links
very cool, thanks for the cool code. I put mine in an article :up:
Quote from: korea on December 10, 2006, 10:00:47 AM
Good Job! thank you
I wish users could edit their own sent links
Right now you can give users the right to edit links, but they could then edit anyone's, not just their own.
Next release will have this option...
Update 1.4
- added ability to allow users to edit and/or delete links they submitted
- reverted name back to Linkit! (since it is for any block, not just center)
$li_edit_own = x; // 0 = No, 1 = Yes - user allowed to edit links they submitted
$li_del_own = x; // 0 = No, 1 = Yes - user allowed to delete links they submitted
Updated code in first post
Awesome, thanks for the update. :up:
I have to uninstall and install again? can you tell me how to update please?
Just overwrite the code you have with code from Thurnok's first post
thanks what file should I overwrite? you mean I download it and replace every thing and then upload it into my server?
what if some day I want to unstall it throgh package manager? will uninstalling go well?
what file should I overwrite?
thanks
Block code snippets do not go in any file. You copy/paste them into the textarea box presented by the block manager for the block you placed the code in.
In other words, go to your admin control panel, choose Manage Blocks, then find the block you placed the linkit code into. Edit that block replacing all that is there with the code that is in the first post of this topic.
Thurnok.... This code rocks!!
Thanks for sharing it!!
My pleasure. :)
Added ability to use TP's "smalltext" or "normaltext" class for link items (in addition to the already existing custom column style variable). This way, you can either turn on smalltext, or not by setting the $li_useclass variable.
New code in first post.
Quote from: Thurnok on December 28, 2006, 12:18:02 AM
Added ability to use TP's "smalltext" or "normaltext" class for link items (in addition to the already existing custom column style variable). This way, you can either turn on smalltext, or not by setting the $li_useclass variable.
New code in first post.
Great, thanks Thurnok! :up:
When adding links:
-Is there a way I can add a little image instead of text for only some of them.
Hey that last post was my 1k post :smiley6600: :laugh:
@brianjw - Not currently. A future version might add that, but it was beyond the scope and intent for this block code.
@RoarinRow - congratz! :)
I love all these snippets, now if I can get my users to use them, that would be great! :2funny: j/k
Yea.. sometimes members just need a little "prodding". hehe
Quote from: brianjw on December 29, 2006, 11:29:02 PM
When adding links:
-Is there a way I can add a little image instead of text for only some of them.
For the URL name use a html image tag as follows:
<img src="http://wwwimage.cbsnews.com/images/2006/12/27/image2299925g.jpg" width="80" height="80">My question is: is it possible to limit the amount of links that can be posted, with the older links "automatically" falling off and being removed from the database?
Quote from: Sledge on January 01, 2007, 01:34:24 AM
Quote from: brianjw on December 29, 2006, 11:29:02 PM
When adding links:
-Is there a way I can add a little image instead of text for only some of them.
For the URL name use a html image tag as follows:
<img src="http://wwwimage.cbsnews.com/images/2006/12/27/image2299925g.jpg" width="80" height="80">
My question is: is it possible to limit the amount of links that can be posted, with the older links "automatically" falling off and being removed from the database?
Yes, I too would like to know, if there is a limit we can put??
just for reference...thanks
QuoteMy question is: is it possible to limit the amount of links that can be posted, with the older links "automatically" falling off and being removed from the database?
The reason I ask is because I use Linkit to show news links (have a look: http://www.politipoll.net). I add several links a day, but also have to delete all the old ones by hand. Even if the radio buttons could be made check boxes so I can delete all the old posts at once, that would be just as helpful.
Well, to add removing links that are "old", would require adding a date/time stamp to the table. Probably a variable to determine what constitutes "old", then parsing the table on each view to see if any links "qualify" to be removed. Possibly a future update.
Another option would be to limit the number of links to "x", then dropping the "total links - x" links with the lowest IDs.
Hmm, yea, I'm diggin it. But what if we used checkboxes instead of radio buttons? That way I could delete a bunch of links at once instead of going through them one at a time? I dinked with the code and managed to get it to use checkboxes instead, but it still only deleted the oldest link.
Well, the issue with using checkboxes is that another mechanism would then need to be used for "editing" a link entry vice deleting one. In otherwords, you check 5 checkboxes out of 100 links, then click "Edit" - you are going to change all 5 to the same URL or the same Description? Obviously that would not be a desirable result.
When I initially created this block, I used small buttons (2 of them, one edit button, one delete button) next to each link that you clicked to perform the desired action. Unfortunately, IE has problems with the BUTTON tag (submit won't work properly because you need the ID of each link item to be returned as the button's variable result, but submit button result is the same as the button's text display - an ugly thing to do). So I changed it to a radio button next to each link and a single Edit and Delete button for operating on the seleted link.
So to keep it as user friendly (and admin friendly), this worked out the best. However, I'll look into changing the radio buttons to checkboxes, and adjusting the code to work properly depending on if you select to Edit or Delete. This might take a back-seat however to some other projects that I'm way behind on now, so might be a bit before I can get to it.
Take your time, you've done plenty already. Thanks for the info and a great block. It's the centerpiece of the frontpage of my forum.
Quote from: Sledge on January 01, 2007, 01:34:24 AM
Quote from: brianjw on December 29, 2006, 11:29:02 PM
When adding links:
-Is there a way I can add a little image instead of text for only some of them.
For the URL name use a html image tag as follows:
<img src="http://wwwimage.cbsnews.com/images/2006/12/27/image2299925g.jpg" width="80" height="80">
My question is: is it possible to limit the amount of links that can be posted, with the older links "automatically" falling off and being removed from the database?
Sorry breezed over this and missed this... Yes, you "can" do this, but remember that you need to adjust the max size of the description text in the code. Using an img tag will generally need much larger size than what you actually want to allow for descriptions (especially for a left or right block) so your users may accidentally (or intentionally) use rather long descriptions (because the limitation is for all users).
In other words, you can make the description text max size 50 or 100 so you can accommodate long urls for the img tag and such, but this would mean that any user that you've given access to "add" links can use up that 50 or 100 text space as well with just text. This might make your Linkit block a bit visually unappealing with all the long description text for various user submitted links if you are using a left or right block since they are usually small width blocks. The text will wrap, but this means you could have 3, 4, or longer lines used for a single link. Guess you just need to keep your members in check with this.
One other thing to be aware of... if your users use the img tag, they can display any image there, regardless of its nature, size, etc. So you could get undesirable results like porn pictures, or overly large images that totally mess up your page layout. So, the moral of the story here is, to use with caution. Limiting the description to 20 or 30 characters generally prevents "most" of the issues since it is difficult to use an img tag with so few characters available due to URL text lengths and such.
In the future, I might add image support where you can allow members to submit an image instead of a text description, but where the block will limit the image dimensions to an Admin setting so you can control the size of the images. As far as the actual content of the image, the only solution there would be an approval system where the admin would need to approve the image before the link shows up. Not sure whether I want to go there or not at this point. We'll have to wait to see what will be turning out for the TinyPortal Links module.
Welll it is alright because only staff are allowed to post links on my site :D
Yes, good that works for you. Others are using it as intended, member submittable links. Therefore, I was making more of a general FYI for everyone. hehe
i dont understand the membergroup numbers thing, what would the member group numbers be for global members, admins, guests, members?
If you look in your database (phpmyadmin) and then in the table (membergroups) you see the numbers for the diffrent membergroups there.
EG Amdin have 1 and so on
You can also go to the membergroups list (admin control panel -> membergroups) and simply hover your mouse over each group's modify link and look at the link in your browser's status bar. The membergroup number for that group will be displayed at the end of that link.
You can hover over the actual membergroup name too, all except for the moderator name (which has no link except the modify link at the end).
The membergroup number for registered users that are not assigned any particular group is 0.
Note that you do not need to put the Admin membergroup in, Admins automatically have access by design. Additionally, it is HIGHLY advisable to not allow guests to add/edit/delete links.
Ok, for some reason im getting this error at the moment.
QuoteQuery Failed! Table NOT Created!
I'm not much of a coder but I believe something is wrong with the code you have in the block. Did you change the code?
I would recommend copying the code from post 1 in this topic and paste that into a block. However if you copy and pasted it freshly and gives you this error I will never know :coolsmiley:
After you enable the Linkit block, the first time a page where it is enabled is accessed, it will attempt to create the table that holds the link information. The name of the table is defined by the $li_tablename variable.
Make sure you have a valid table name in there (the default "linkit" should be valid). Generally the reason for getting the error you received could be a number of things:
- you don't have rights to create tables (shouldn't be the case here however)
- the table already exists but is corrupt
- something happened while it was trying to create the table, and it wasn't successful
Check to see if the table was actually created. If so, drop the linkit table, then load the page again to see if it successfully creates it. If you get the same problem, or if the table was never created, try manually creating the table via phpMyAdmin.
oh yeah i did change something, now its working thanks man!
I'm a little late getting to this party, but I sure am glad to be here... this is one great piece code!
Thanks Thurnok, ya done good! ;D
Works like a charm, only had one little glitch and that was solved after I figured out that the membergroup numbers should be entered as ââ,¬Â¦Ã¢â,¬Ëœ2ââ,¬â,,¢, ââ,¬Ëœ3ââ,¬â,,¢, ââ,¬Ëœ4ââ,¬â,,¢) and not as ââ,¬Â¦ ââ,¬Ëœ2, 3, 4ââ,¬â,,¢.
This bloc works great, all that remains now is to see if my members will use it. ;)
Thanks Ken.. hope you enjoy. :)
Update 1.6
- changed radio buttons to checkboxes
- allow multiple links to be deleted simultaneously
- added visual link verification
- added class to form buttons / text ;o)
see code for info
Updated code in first post
Cool, thank you Thurnok! :up:
Very nice additions Thurnok, especially the visual link verification.
Thurnok
It could see linkit buttons and text fields/test etc as Admin, but not as a normal member. So I tried to change groups allowed to submitt links but now I see this line appearing on TP.
Parse error: syntax error, unexpected '*' in /home/casestud/public_html/Sources/Load.php(1733) : eval()'d code(35) : eval()'d code on line 1
My phpblock has the following code
*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// ***** SECURITY OPTIONS *****
// who has addlink access? - format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
// who can edit links? - same format as addlink
$li_editlink_groups = array('1', '2', '3' '4', '5', '6' '7' '8');
// who can delete links? - same format as addlink
$li_dellink_groups = array('1', '2', '3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;
// ***** LAYOUT OPTIONS *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns? change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';
// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;
// ***** OTHER OPTIONS *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links! Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/
//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;
// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}
switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}
// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];
// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}
// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed! Table NOT Created!<br />\n");
}
}
// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Inserted into database!<br />\n");
}
}
// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT modified in database!<br />\n");
}
}
}
// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Deleted from database!<br />\n");
}
}
/////////// MAIN CODE HERE ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];
// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}
// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}
// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}
//////////// MAIN DISPLAY CODE HERE ///////////////
// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY
url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER
BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}
$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}
// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}
function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}
function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}
function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}
// -->
</script>
';
// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}
// preset our current column to first column
$li_current_column = 1;
// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";
// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;
// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .
'</a></td>' . "\n";
// next column number
$li_current_column++;
}
// end our last row and our table
echo "</tr>\n</table>\n";
// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,
\'li_checkbox\');"> Check/Uncheck all</input></div>';
}
// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"
onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" /> ';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" /> ';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}
// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';
// and finally, end our form
echo '</form>';
// free the result for good measure
mysql_free_result($dbresult);
Please help me where could be the problem..
Best regards, :)
Jim
You are missing several lines of code. Putting a forward slash ( / ) before the first asterisk ( * ) on your line one would do the trick, but here's the lines you are missing that go above your shown line 1:
//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text ;o)
//
// This is a php block and/or php Article snippet. It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate. Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links. You
// can create the table manually if necessary.
//
//////////////////////////////////////////////
/*
Also something for you to note, unless you somehow changed group 1 from the Admin group to something else, you should take that out of all the arrays. It is not necessary, as admins automatically can do all the features.
Additionally, groups 4-8 (the default post count groups) can be removed from the arrays and simply add the group 0 to them if you want all registered users to have the capability.
One final note, I see you have it so registered users (all the post count groups anyway) set to also edit links. The $li_editlink_groups array is to allow someone to edit "any" links, not just their own. I'm not sure you intended on allowing all registered users to have the capability to edit "any" links. Instead, you can simply turn on edit own and/or delete own (as I see you have), and remove the post count groups (and registered member group 0) from $li_editlink_groups completely.
In otherwords, here's what I would change your permissions in the block to:
// Example: $li_addlink_groups = array('14');
$li_addlink_groups = array('0','2','3');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');
Groups 2 and 3 are for global mods and local mods. I'm assuming you want them to have the ability to Add/Edit/Delete links without regard to what actual member groups they are in, so you can leave just those two groups in the edit/delete arrays.
The above will let any of your registered users to Add links to the block. It will also allow them to edit or delete their own (assuming you don't change that part of the code where you already have it set for them). However, global mods and local mods will be able to Add/Edit/Delete any links in the block.
Thurnok !
Thank you for your great help. It is working for me now. Kindly see that I dont want all users be able to delete and edit links so I did as you advised. Here is my code now.
//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text ;o)
//
// This is a php block and/or php Article snippet. It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate. Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links. You
// can create the table manually if necessary.
//
//////////////////////////////////////////////
/*
/*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// ***** SECURITY OPTIONS *****
// who has addlink access? - format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('0');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;
// ***** LAYOUT OPTIONS *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns? change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';
// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;
// ***** OTHER OPTIONS *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links! Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/
//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;
// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}
switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}
// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];
// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}
// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed! Table NOT Created!<br />\n");
}
}
// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Inserted into database!<br />\n");
}
}
// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT modified in database!<br />\n");
}
}
}
// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Deleted from database!<br />\n");
}
}
/////////// MAIN CODE HERE ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];
// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}
// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}
// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}
//////////// MAIN DISPLAY CODE HERE ///////////////
// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY
url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER
BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}
$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}
// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}
function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}
function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}
function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}
// -->
</script>
';
// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}
// preset our current column to first column
$li_current_column = 1;
// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";
// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;
// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .
'</a></td>' . "\n";
// next column number
$li_current_column++;
}
// end our last row and our table
echo "</tr>\n</table>\n";
// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,
\'li_checkbox\');"> Check/Uncheck all</input></div>';
}
// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"
onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" /> ';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" /> ';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}
// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';
// and finally, end our form
echo '</form>';
// free the result for good measure
mysql_free_result($dbresult);
Thank you once again, Have a good day. :)
Jim
No problem, you are welcome. :)
I should probably have changed the comments in my code to make it more clear with respect to edit/delete for "all" links vs. "own" links. I'll do that in a future version.
Happy Linking!
Quote from: funxlab on January 30, 2007, 01:59:26 AM
Thurnok !
Thank you for your great help. It is working for me now. Kindly see that I dont want all users be able to delete and edit links so I did as you advised. Here is my code now.
//////////////////////////////////////////////
// Linkit Version 1.6
// Developed by Thurnok
// thurnok -AT- tinyport .DOT. net
// Complete Computer Services
// August 22, 2006
//
// Last update January 23, 2007
//
// 2.0:
// - changed radio buttons to checkboxes
// - allow multiple links to be deleted simultaneously
// - added visual link verification
// - added class to form buttons / text ;o)
//
// This is a php block and/or php Article snippet. It works in any block
// position (left/right/center/frontpage/article).
// It allows for multiple columns of links via a table.
//
// Linkit allows you to give your users the ability to add links to your
// site in a Tiny Portal block that you designate. Your Admins can
// edit/remove entries, and you determine what 'groups' can post links!
// You can also give groups abilities to edit or delete links as well.
// Additionally, you can allow members to edit/delete their own submissions.
//
// This script will create a table for the links using your current
// TP table prefix followed by linkit (ex: smf_tp_linkit) and using your
// current database credential information.
// NOTE: Your database user/permissions used for SMF must allow you to
// create a table or you will never be able to store the links. You
// can create the table manually if necessary.
//
//////////////////////////////////////////////
/*
/*** !! User Configuration Section !! ***
****************************************
****************************************
*/
// ***** SECURITY OPTIONS *****
// who has addlink access? - format is array('<groupnum>', '<groupnum>', ...)
// Example: $li_addlink_groups = array('2', '3' '4', '5', '6' '7' '8');
$li_addlink_groups = array('0');
// who can edit links? - same format as addlink
$li_editlink_groups = array('2','3');
// who can delete links? - same format as addlink
$li_dellink_groups = array('2','3');
// group that you want members denied usage even if in a group above
$li_deny_groups = array('');
// members you want to deny usage even if allowed above
$li_deny_members = array('');
// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;
// ***** LAYOUT OPTIONS *****
// size of the edit boxes (<input>)
$li_editbox_size = 15;
// max size of the input for the URL Name (30 or less is best)
$li_urlname_maxsize = 30;
// sorting option - 0 = chronological, 1 = alphabetic, 2 = submitter
$li_sort = 0;
// sorting direction - 0 = ascending, 1 = descending
$li_sort_direction = 0;
// number of columns of links to display
$li_columns = 1;
// want to add your own styles to the rows/columns? change the tag info here
$li_start_row = '<tr>';
$li_start_col = '<td>';
// you can make the columns use one of TinyPortal's text classes ("normaltext" or "smalltext") or none.
// this will add to the $li_start_col variable the classtype you choose (0 = no class, 1 = smalltext, 2 = normaltext)
// if you are making your own text styles in the $li_start_col variable above, you should set $li_useclass = 0
$li_useclass = 1;
// ***** OTHER OPTIONS *****
// you can set the tablename to other than linkit if you like
$li_tablename = "linkit";
// and the title displayed
$li_title = "linkit";
// add some descriptive text here if you like to display under title
$li_desc = "Member added links! Please add only your most favorite links.";
// Print our title - or comment the line to not display a title
echo '<center><b>' . $li_title . '</b></center><br />';
echo '<font size=1>' . $li_desc . '</font><p />';
/*
****************************************
****************************************
*/
//////////////////////////////////////////////
//
// The rest of this you should leave as is
// unless you are overly industrious :)
//
//////////////////////////////////////////////
// globals for database vars
global $db_prefix, $tp_prefix;
// globals for user information
global $context, $user_info, $ID_MEMBER;
// fix for TP 0.8.6 and lower
if (empty($tp_prefix)){
$tp_prefix = $settings['tp_prefix'];
}
switch ($li_useclass){
case 1:
$li_classtxt = ' class="smalltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
case 2:
$li_classtxt = ' class="normaltext" ';
$li_start_col = substr($li_start_col, 0, -1) . $li_classtxt . '>';
break;
default:
$li_classtxt = '';
break;
}
// get our script url (including parameters - like ?page=6)
$myself = $_SERVER['REQUEST_URL'];
// put the SMF table prefix in front of your tablename from above
$li_tablename = $tp_prefix . $li_tablename;
// check if user is in a group that is allowed to add links
$li_add_auth = array_intersect($li_addlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to edit links
$li_edit_auth = array_intersect($li_editlink_groups, $user_info['groups']);
// check if user is in a group that is allowed to delete links
$li_del_auth = array_intersect($li_dellink_groups, $user_info['groups']);
// deny if in one of the deny groups or members
if (array_intersect($li_deny_groups, $user_info['groups']) || @in_array($ID_MEMBER, $li_deny_members)){
$li_add_auth = false;
$li_edit_auth = false;
$li_del_auth = false;
$li_edit_own = false;
$li_del_own = false;
}
// Admins are always allowed to add/edit/delete links
if ($context['user']['is_admin']){
$li_add_auth = 1;
$li_edit_auth = 1;
$li_del_auth = 1;
}
// set up all our functions ahead of time
// function to create table if not already there
function LinkitCreateTable($li_tablename) {
// set up the query that will create the table appropriately
$dbquery = "CREATE table $li_tablename (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
url_name TEXT, url TEXT, submitted_by TEXT);";
if (!mysql_query($dbquery)) {
die("Query Failed! Table NOT Created!<br />\n");
}
}
// function to add links to the table
function LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $li_submittedby) {
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// first see if this would be a duplicate, if so, do not post it
$dbquery = "SELECT * FROM $li_tablename
WHERE url LIKE '" . $li_urllink . "'";
$dbresult = mysql_query($dbquery);
if ($row = mysql_fetch_assoc($dbresult)){
// if a row is found, then there's already this link in table, don't dupe it
return;
}
$dbquery = "INSERT INTO $li_tablename VALUES (0, \"$li_urlname\", \"$li_urllink\", \"$li_submittedby\");";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Inserted into database!<br />\n");
}
}
// function to edit links in the table
function LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_id) {
// make sure only one ID is actually in there
if ((string)(int)$li_id === (string)$li_id){
// change only values that were there in form
$dbquery = "UPDATE $li_tablename SET ";
if ($li_urlname){
// if there was a url name provided, add it to UPDATE query
$dbquery .= "url_name=\"$li_urlname\" ";
}
if ($li_urllink){
// add HTTP:// if necessary at front of link to prevent BASE URL applying in front of link provided
if ( (strtolower(substr($li_urllink, 0, 7)) != "http://") && (strtolower(substr($li_urllink, 0, 6)) != "ftp://") ){
$li_urllink = "http://" . $li_urllink;
}
// since url link was provided, add it to UPDATE query
if ($li_urlname){
// since we already added url name, put comma and space before the url link update part
$dbquery .= ", url=\"$li_urllink\" ";
} else {
// didn't have an url name added, so no comma needed
$dbquery .= "url=\"$li_urllink\" ";
}
}
// add rest of query
$dbquery .= "WHERE id=\"$li_id\";";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT modified in database!<br />\n");
}
}
}
// function to delete links from the table
function LinkitDelLink($li_tablename, $li_id) {
// delete link(s) in $li_id
$dbquery = "DELETE FROM $li_tablename WHERE id in ( " . $li_id . ")";
if (!mysql_query($dbquery)) {
die("Query Failed! Link NOT Deleted from database!<br />\n");
}
}
/////////// MAIN CODE HERE ////////////
// convert $_POST vars to prevent undefined index errors
$li_add = empty($_POST['li_add']) ? 0 : 1;
$li_edit = empty($_POST['li_edit']) ? 0 : 1;
$li_del = empty($_POST['li_del']) ? 0 : 1;
$li_urlname = empty($_POST['li_urlname']) ? '' : $_POST['li_urlname'];
$li_urllink = empty($_POST['li_urllink']) ? '' : $_POST['li_urllink'];
$li_checklist = empty($_POST['li_checklist']) ? '' : $_POST['li_checklist'];
// if someone just added a link, post it to the database
if ($li_add){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname && $li_urllink){
LinkitAddLink($li_tablename, $li_urlname, $li_urllink, $user_info['username']);
}
}
// if someone just edited a link, modify it in database
if ($li_edit && $li_checklist){
$li_urlname = trim($li_urlname);
$li_urllink = trim($li_urllink);
if ($li_urlname || $li_urllink){
LinkitEditLink($li_tablename, $li_urlname, $li_urllink, $li_checklist);
}
}
// if someone just deleted a link, remove it from database
if ($li_del && $li_checklist){
LinkitDelLink($li_tablename, $li_checklist);
}
//////////// MAIN DISPLAY CODE HERE ///////////////
// set query to select all data in appropriate order
switch ($li_sort){
// alphabetical order
case 1:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY url_name DESC" : "SELECT * from $li_tablename ORDER BY
url_name";
break;
// submitted by order
case 2:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY submitted_by DESC" : "SELECT * from $li_tablename ORDER
BY submitted_by";
break;
// chronological order
default:
$dbquery = $li_sort_direction ? "SELECT * from $li_tablename ORDER BY id DESC" : "SELECT * from $li_tablename";
}
$dbresult = mysql_query($dbquery);
if (!$dbresult){
if (mysql_errno() == 1146){
// table doesn't exist, create it!
LinkitCreateTable($li_tablename);
// get our result again
$dbresult = mysql_query($dbquery);
if (!$dbresult) die("Unexpected error: " . mysql_error());
} else {
die("Unexpected error: " . mysql_error());
}
}
// javascript validations
echo '
<script type="text/javascript">
<!--
function addCheck(){
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
if (urlname.value.replace(/ /g,"") == "" || urllink.value.replace(/ /g,"") == ""){
alert("Missing information - Must supply both URL Name and URL Link!");
return false;
}
}
function editCheck(){
retval = false;
checklist = "";
numchecked = 0;
urlname = document.li_form.li_urlname;
urllink = document.li_form.li_urllink;
checkboxes = document.li_form.li_checkbox;
if (urlname.value.replace(/ /g,"") != "" || urllink.value.replace(/ /g,"") != ""){
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist = checkboxes[i].value;
numchecked++;
}
}
switch (numchecked){
case 0:
alert("You must select a link to edit first!");
break;
case 1:
document.li_form.li_checklist.value = checklist;
retval = true;
break;
default:
alert("You can only edit one link at a time!");
break;
}
} else {
alert("No information entered!");
}
return retval;
}
function delCheck(){
retval = false;
checklist = "";
checkboxes = document.li_form.li_checkbox;
for (i=0; i<checkboxes.length; i++){
if (checkboxes[i].checked == true){
checklist += (checklist != "" ? "," : "") + checkboxes[i].value;
}
}
document.li_form.li_checklist.value = checklist;
if (checklist != ""){
retval = true;
}
if (!retval){
alert("Select a link first!");
}
return retval;
}
function urlTest(){
urllink = document.li_form.li_urllink.value;
if (urllink.replace(/ /g,"") != ""){
if (urllink.toLowerCase().substr(0, 7) != "http://" && urllink.toLowerCase().substr(0, 8) != "https://"){
urllink = "http://" + urllink;
}
// display a new window and open url in it
window.open(urllink, "TestUrl", "width=600px, height=400px, resizable, scrollbars", true);
} else {
alert("Need a link to test!");
}
}
// -->
</script>
';
// start our form
if (empty($context['browser']['is_ie'])){
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post'.$li_classtxt.'>' . "\n";
} else {
echo "\n" . '<form name="li_form" action="' . $myself . '" method=post>' . "\n";
}
// preset our current column to first column
$li_current_column = 1;
// start our table and first row
echo '<table width="100%" border="0"><tr>' . "\n";
// gets set to 1 if there is at least one radio button made next to a link
$li_link_owner = 0;
// parse our data out
while ($row = mysql_fetch_assoc($dbresult)){
// new row?
if ($li_current_column > $li_columns){
// time to end current row and start new one
$li_current_column = 1;
echo "</tr>\n" . $li_start_row . "\n";
}
// each link has a column to start with
echo ' ' . $li_start_col;
// if they have edit or delete privileges then display checkbox
if ($li_edit_auth || $li_del_auth){
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
} elseif (($user_info['username'] == $row['submitted_by']) && ($li_edit_own || $li_del_own)){
// if they own this link in the list, and either edit own or delete own is on, display checkbox
echo '<input type=checkbox name="li_checkbox" id="li_checkbox" value="'.$row['id'].'" /> ';
$li_link_owner = 1;
}
echo '<a href="' . $row['url'] . '" title="Submitted by ' . $row['submitted_by'] . '" target=_blank>' . $row['url_name'] .
'</a></td>' . "\n";
// next column number
$li_current_column++;
}
// end our last row and our table
echo "</tr>\n</table>\n";
// if there are checkboxes, add the check/uncheck all
if ($li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<div'.$li_classtxt.'><input type=checkbox name="li_checkall" value="" onClick="invertAll(this, this.form,
\'li_checkbox\');"> Check/Uncheck all</input></div>';
}
// if user is allowed to add/edit/delete links (or their own and one exists), display URL Name and URL Link edit boxes
if ($li_add_auth || $li_edit_auth || $li_del_auth || ($li_link_owner && ($li_edit_own || $li_del_own))){
echo '<br />
<div'.$li_classtxt.'>URL Name:</div>
<input type=text name="li_urlname" size=' . $li_editbox_size . ' maxlength=' . $li_urlname_maxsize . '><br />
<div'.$li_classtxt.'>URL Link:</div>
<input type=text name="li_urllink" size=' . $li_editbox_size . '><input type=button name="li_testurl" value="Test"
onClick="return urlTest()"><br /><br />
';
}
// if user is allowed to add links, display Add button
if ($li_add_auth){
echo '<input type=submit name="li_add" value="Add" onClick="return addCheck()" /> ';
}
// if user is allowed to edit links (or their own and one exists), display edit link button
if ($li_edit_auth || ($li_link_owner && $li_edit_own)){
echo '<input type=submit name="li_edit" value="Edit" onClick="return editCheck()" /> ';
}
// if user is allowed to delete links (or their own and one exists), display delete link button
if ($li_del_auth || ($li_link_owner && $li_del_own)){
echo '<input type=submit name="li_del" value="Del" onClick="return delCheck()" />';
}
// our hidden elements
echo '<input type=hidden name="li_checklist" value="">';
// and finally, end our form
echo '</form>';
// free the result for good measure
mysql_free_result($dbresult);
Thank you once again, Have a good day. :)
Jim
Hmmmmm I can't seem to delete the checked links.An error box keeps popping up telling me to select a link.
Oh Well.
houston ,
you need to enter an link first and then click on test. Can you add a link without testing it first?
Jim
@houston
What browser are you using? I only test on Mozilla, FireFox, and IE. I don't think I have any code that wouldn't specifically work for other browsers (like Opera, etc.) but you never know.
Try copying the code from the first post of this thread again and overwrite your block code with it, then set your specific settings again. Just in case your original copy/paste missed something.
Quote from: funxlab on February 02, 2007, 10:33:19 PM
houston ,
you need to enter an link first and then click on test. Can you add a link without testing it first?
Jim
Been there, done that and left the t-shirt behind.
Did not try to add a link without testing it though.
I will give it another go and maybe keep the t-shirt this time.
Cheers
Yes, you can add a link without first testing it. I haven't enabled any URL validation, though someone asked me about that some time back. I'm contemplating that for the future.
However, the test button at least allows your users to verify that the link they are about to add is valid (brings up a page) and is the one they intended, prior to actually submitting it. This is a good idea in all cases, but certainly helpful to the admin if you are not allowing members to edit or delete their own links (an option).
Just what i needed. :)
Thank you for this.
First of all, thank you. This is a very useful block snippet!
I think I found a small bug.
The name that is displayed for a submitter when you mouse hover over a link is the submitter's "username" and not the submitter's "Display name."
I only noticed this because I had used some obscure name for my original login and then changed my username to 'Admin' for everyday use. When I post links it shows the original name and not the 'Admin' name.
This is not a bug. This is by design. The reason being, a number of boards allow users to change their username. The $user_info['username'] of the submitter is written to the Linkit table so that additional calls to the database do not need to be done when storing submitter info, as well as when reading the info. In otherwords, my original intent was to minimize the db accesses. This being the case, if I wrote the display name info, it would become inaccurate very quickly for sites allowing Display Name changes.
I'm planning a new version however, that will make it inevitable that more db access will be required, and as part of that the Admin will be able to choose whether to use username, or display name for mouse-overs. The new version will allow various display modes (simple list, descriptive list, detailed list, category list) and will include categories/subcategories.
Thurnok are you developing the link Module for TP ?? If your not perhaps you should. It seems like all we are missing is integration with the TP admin section..
Great work all the way around..
That would be Bloc's call. TP is his baby, though I'd be happy to provide work in that area. In the mean time, for those that want to have the admin configuration in the ACP, I could work that up.
Maybe if you really wanted to make it easy and awesome. You can make it a mod and integrate it with TP kind of like Felblog ;) And have its own TP Admin section...who knows...you can do anything with PHP :)
You can't get much easier than Blocks - copy/paste
Set a few simple variables the way you want them, and then you are off and running. Modules are for things that are much more complicated, although I could certainly make this block very complicated if I put some time into it. ;)
In any case, this is a Block, and since TP 1.0 will have a Link module, there is no reason for me to make Linkit into a module.
Well yeah, but who says the link module will have any blocks... probably though... knowing bloc, since he already has blocks for all the smf features, when he gets his module features they certainly will probably be there. But your system works very good as well. Maybe Bloc will use some of the code for a Link Block if/when he makes one for the module. :)
Update 1.7
- Added auto-scrollbar sizing of block
$li_blocklines = xx;
Set the $li_blocklines variable to the approximate number of lines of links to display in the block. This assumes there is no inside title ($li_title) and no inside description ($li_desc) [i.e. setting them to null string values] and the user does not have the editboxes and buttons displayed or any checkboxes. Adjust as necessary to suit your liking. The block will size to your setting and once enough info has filled past the block size, the block will stay the same size, but will have a vertical scrollbar automatically in place to scroll through the undisplayed info.
Setting $li_blocklines = 0 will disable the autoscroll feature and the block will increase in size to fit the data as it did in previous versions of Linkit.
This feature is good for left/right blocks when you have alot of links and don't want the block growing so large that it disrupts the layout of your site.
Enjoy! :)
So strange, it didn't work for me. I just had a blank screen :o I carried all my settings over to the new code and nothing.
Hmm... do you get any errors in your error log? Strange indeed. You can see it working at my TP Blocks site (http://www.tpblocks.com).
Perhaps a copy/paste issue with missing a semicolon somewhere or something? If you want me to check it out for you Roarin... PM me with some info.
Minor update
Update 1.7.1
- added explicit sort by ID when $li_sort = 0 so that if you edit your database table, changing ID numbers, you can sort by the ID instead of the order data was entered into the table
- centered table for those of you using images instead of text for the link names
hi, it worked fine on my site, but i can't edit nor delete the links, im logged as the administrator and i set the security options to
// who can edit links? - same format as addlink
$li_editlink_groups = array('1');// allow members to edit/delete their own links? (0 = No, 1 = Yes)
$li_edit_own = 1;
$li_del_own = 1;even if im logged as administrator, and checked on the radio button beside the link that i made, the error says.
Quoteyou must select a link to edit first!
and when i try to delete a link, this is the error i get
Quoteselect a link first!
even if the radio button is checked.
another question, how can i make the links autoscroll?
im using smf1.1.3 with tp0.9.8
Any ideas? I'm having the same problem... can't edit or delete my own links...
Thanks! Great block Thurnok!!
As others have said many times "Thanks Thurnok!"
I'd like to be able to group my links with sub categories. Nothing serious, here's a visual of what I mean:
Dealers
www.dealer1.com
www.dealer2.com
Clubs
www.club1.com
www.club2.com
Accessories
www.accessories1.com
www.accessories2.com
I thought about putting a fake link in to allow for this but I don't think it'd work with sorting. Is something that's doable?
One more thing, when I log out of my site and view it as a guest the title of the block goes away and reads "-no title-" instead. It works correctly when logged in as a regular user where it displays as "Links". Can you help with this?
I love this block! I hope the edit links thing gets fixed though!
Thank you so much.
Quote from: milesenglish on December 17, 2007, 05:11:30 AM
One more thing, when I log out of my site and view it as a guest the title of the block goes away and reads "-no title-" instead. It works correctly when logged in as a regular user where it displays as "Links". Can you help with this?
Did you set the other language options for it as well? In each block you have other boxes to display the title in another language.
Sorry... been on hiatus for 6+ months, so I haven't been around to see / answer any questions. I'm still not fully back, but hopefully I can answer a few questions.
@ cru / dannbass / Anthea - I'm not sure where the problem lies, but perhaps it is something with the new SMF. Linkit was last tested (by myself anyway) with SMF 1.1.2 / TP 0982. The latest version of LinkIt (1.7.1) is working on my TP Blocks site still. Once I have time to get back to TP stuff, I will update as necessary for the latest SMF and TP.
@ milesenglish - at one time I thought about putting in a category feature, but dropped it due to the future TP Module stuff. Plan was to convert this block to a TP Module (before I got too tied up at work with a 16+ hours/day 6+ days/week schedule for the past 6 months). Down to about a 12 hour day now, so I'm almost getting back to normal... when I get back to normal, I will re-evaluating LinkIt's future.
Thurnok, Well first let me say assume script. Just to reassure you I have it working on the latest download of TP. Not the Beta but the one offered here on TP. Works great just had to make a couple of tweaks and it just works.
QuoteNot the Beta but the one offered here on TP
Actually it is Beta release that one to. And from this site ? You know of any other site you can get hold of TP mod from ?
Hahaha! Of course your right G6, my bad. Linkit works just fine and like I said above, just a little tweaking here and there to get it to do what I wanted. I wanted to be able to use an image for the link to a site so I had to increase the size of the URL Name box. This allowed me to add the image path and the path for the link. Very easy to install and configure. On a scale of 1 to 10 I would rate this snib a 10 and should be a must have. O0
Hey folks, real newbie here with all this, so how do I add this block to my site? copy/paste the code to where & how? thanks for the baby steps.
NEVER mind, I found the help section, thanks again.