1 (edited by 2008-08-30 18:45:29)

Topic: [HACK] Edit/delete news link in show_news.php

Name: Edit/delete news link
Author: rokker93
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Add's a button/link on your site which allows you to go to the editnews page if you're logged in CuteNews from your site.
Instructions:
before we start keep in mind that the forum sometimes splits the word java script. This must be 1 word!!

Open index.php and look for

                else{
                   setcookie("username", $username);
                   setcookie("md5_password", $cmd5_password);
                }
        }

And add under

if($member_db[1] == "1"){ setcookie("userlevel", "loggedin", time()+3600, "/", ".yoursite.com"); }
else { }

Please replace yoursite.com with your site's url. No www or http. Eg .cutephp.com

Now search for

$config_check_referer = TRUE; // Set to TRUE for more seciruty


Change TRUE to FALSE ( Dont worry, its not that major security issue )

Now open shows.inc.php and search for

else{ $output = str_replace("{category-icon}", "", $output); }

Below that add

if($_COOKIE["userlevel"] == "loggedin"){ 
$output = str_replace("[a-edit]", "[url= onclick=\]", $output); 
$output = str_replace("[/a-edit]", "[/url]", $output); 
$output = str_replace("[a-delete]", "<a onClick=\"java script:confirmdeletenews('$news_arr[0]'); return(false)\" href=\"#\">", $output); 
$output = str_replace("[/a-delete]", "</a>", $output); 
} else { 
$output = str_replace("[a-edit]", "<!- ", $output); 
$output = str_replace("[/a-edit]", " ->", $output); 
$output = str_replace("[a-delete]", "<!- ", $output); 
$output = str_replace("[/a-delete]", " ->", $output); 
}

Now find the same line again, but further down below that add

if($_COOKIE["userlevel"] == "loggedin"){ 
$output = str_replace("[a-edit]", "[url= onclick=\]", $output); 
$output = str_replace("[/a-edit]", "[/url]", $output); 
$output = str_replace("[a-delete]", "<a onClick=\"java script:confirmdeletenews('$news_arr[0]'); return(false)\" href=\"#\">", $output); 
$output = str_replace("[/a-delete]", "</a>", $output); 
} else { 
$output = str_replace("[a-edit]", "<!- ", $output); 
$output = str_replace("[/a-edit]", " ->", $output); 
$output = str_replace("[a-delete]", "<! - ", $output); 
$output = str_replace("[/a-delete]", " ->", $output); 
}

Now open show_news.php and after the first <?PHP add

echo"<script language=\"javascript\"> 
        function confirmdeletenews(id){
        var agree=confirm(\"Are you sure you want to delete this news?\");
        if (agree)
        location.href=('index.php?mod=editnews&action=doeditnews&goto=back&source=&ifdelete=yes&id='+id);return false;
        }
</script>";

Now open editnews.mdu and search for

if($okdeleted and $okdelcom){ msg("info","News Deleted","The news item successfully was deleted.
If there were comments for this article they are also deleted."); }

Replace with

if($okdeleted and $okdelcom and $_GET[goto] == "back"){ echo"<script Language=\"JavaScript\">location.href=('$_SERVER[HTTP_REFERER]');</script>"; }
elseif($okdeleted and $okdelcom){ msg("info","News Deleted","The news item successfully was deleted.
If there were comments for this article they are also deleted."); }

// Extra's. Not needed but go with the mod
Open options.inc.mdu and search for

{category}

    {category-icon}

Replace with

{category}

    {category-icon}

[a-edit] & [/a-edit]

[a-delete] & [/a-delete]


Find

   - Shows the category icon (if any)

Replace with

    - Shows the category icon (if any)

    - Shows an edit link on news when logged in as admin

    - Shows an delete link on news when logged in as admin

Credits:
Jaybuz - For being a pain and asking for this.

Re: [HACK] Edit/delete news link in show_news.php

Thanks for this rokker (Me lazy) https://cutephp.com/forum/style_emoticons/default/tongue.gif

Re: [HACK] Edit/delete news link in show_news.php

this is an interesting addon.

Re: [HACK] Edit/delete news link in show_news.php

Can you make the edit news menu open in a popup?????
So i dont have to leave my news page https://cutephp.com/forum/style_emoticons/default/smile.gif

Re: [HACK] Edit/delete news link in show_news.php

I've edited my first post to use a popup https://cutephp.com/forum/style_emoticons/default/smile.gif and added some other features.
Hope you like.