Current time: 05-23-2012, 08:56 PM Hello There, Guest! (LoginRegister)


Post Reply 
First post image in the portal?
01-27-2012, 04:56 PM
Post: #1
First post image in the portal?
This user has been denied support. This user has been denied support.
Hello friends,

Maybe someone can help me...
I want to show in my portal, only the first image in my post, but I don't know how to make that possible.

I installed this plugin to cut off characters:
http://mods.mybb.com/view/portal-announcement-cut-off

But doesn't work like I want, because a URL can have different numbers of characters...
Unless someone could change the code to appear only the first image inside the [ img ] [ /img] tags.
Is that possible?

PHP Code:
<?php

if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("portal_announcement""portalannc");



function 
portalannc_info()
{
    return array(
        
"name"            => "Portal Announcement Cut Off.",
        
"description"    => "It sets a minimum of characters for portal announcements.",
        
"website"        => "http://www.mybb.com/",
        
"version"        => "1.0",
        
"author"        => "bubulang",
        
"authorsite"    => "http://community.mybb.com/user-29135.html",
        
"compatibility"  => "16*",
        
'guid'        => 'a18f4b6eed189c9ffd4e4708708c15dc'
    
);
}

function 
portalannc_activate()
{
    global 
$db;
    
    
$query $db->simple_select("settinggroups""gid""name='portal'");
    
$gid $db->fetch_field($query"gid");
    
    
$setting = array(
        
'name' => 'patcutoff',
        
'title' => 'Portal Announcement Cut Off',
        
'description' => 'Set a minimum of characters for portal announcements?',
        
'optionscode' => 'yesno',
        
'value' => 'yes',
        
'disporder' => '20',
        
'gid' => intval($gid)
    );
    
$db->insert_query('settings',$setting);
    
    
    
$characters = array(
        
'name' => 'characters',
        
'title' => 'Characters',
        
'description' => 'Number of characters before the announcement is cut off',
        
'optionscode' => 'text',
        
'value' => '',
        
'disporder' => '21',
        
'gid' => intval($gid)
    );
    
$db->insert_query('settings',$characters);
    
    
$cutoffmessage = array(
        
'name' => 'cutoffmessage',
        
'title' => 'Announcement Cut Off Message',
        
'description' => 'Message to be displayed when announcemet is cut off',
        
'optionscode' => 'text',
        
'value' => '..... More',
        
'disporder' => '22',
        
'gid' => intval($gid)
    );
    
$db->insert_query('settings',$cutoffmessage);
    

rebuild_settings();
}

function 
portalannc_deactivate()
{
    global 
$db;

$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='patcutoff'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='characters'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='cutoffmessage'");
    
rebuild_settings();
}
    
function 
portalannc()    
{
global 
$mybb$announcement;

if(
$mybb->settings['patcutoff'] == AND $mybb->settings['characters'] < my_strlen($announcement['message'])){
$announcement['message'] = my_substr($announcement['message'], 0$mybb->settings['characters']);
$announcement['message'] .= "[url=".$mybb->settings['bburl']."/".$announcement['threadlink']."]".$mybb->settings['cutoffmessage']."[/url]";
}
}

?>

Can someone help me? Smile
Thank you!
Find all posts by this user
Quote this message in a reply
01-27-2012, 05:14 PM
Post: #2
RE: First post image in the portal?
replace the function portalannc() with this

PHP Code:
function portalannc()    
{
    global 
$mybb$announcement;

    if(
$mybb->settings['patcutoff'] == AND $mybb->settings['characters'] < my_strlen($announcement['message']))
    {
        
$pos stripos($announcement['message'], "[/img]");
        if(
$pos !== false)
        {
            
$mybb->settings['characters']) = $pos 6;
        }
    
        
$announcement['message'] = my_substr($announcement['message'], 0$mybb->settings['characters']);
        
$announcement['message'] .= "[url=".$mybb->settings['bburl']."/".$announcement['threadlink']."]".$mybb->settings['cutoffmessage']."[/url]";
    }


CommunityPlugins.com
Latest Updates: Advanced File Verification v1.3, Usergroup Titles v1.0, MyBBPublisher v1.8.1
Visit this user's website Find all posts by this user
Quote this message in a reply
01-27-2012, 06:14 PM
Post: #3
RE: First post image in the portal?
This user has been denied support. This user has been denied support.
WOW perfect !!! Thank you my friend Big Grin

I only removed ")" from:
PHP Code:
$mybb->settings['characters']) = $pos 6

Because was causing an error...
Thank you once again Big Grin
Rep on you Smile
Find all posts by this user
Quote this message in a reply
01-27-2012, 06:25 PM
Post: #4
RE: First post image in the portal?
^ OFF TOPIC : well, you know it was just a typo ! he provided required code within a few minutes ..
Find all posts by this user
Quote this message in a reply
01-27-2012, 06:44 PM
Post: #5
RE: First post image in the portal?
sorry about that, i apparently grabbed one too many characters in the copy/paste

glad its working

CommunityPlugins.com
Latest Updates: Advanced File Verification v1.3, Usergroup Titles v1.0, MyBBPublisher v1.8.1
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication