Yet Another Global Announcements Mod (YAGAM)

Started by Nibogo, February 11, 2009, 12:47:15 AM

Previous topic - Next topic

Nibogo

Quote from: drhamad on February 27, 2009, 06:14:15 PM
I'd really like the ability to make GA's with comments into regular threads when they're un-GA'd.  That's a major thing for me, as just because I no longer wish to announce something, it doesn't mean I want to eliminate the thread.

That is pretty interesting , but pretty hard to do too. I can try but is not sure of this will be a feature.

- Announcement Log [DONE]
- Force Users to read a Global Announcement after Login [DONE]

I include that feature will be nice for some people.

drhamad

Yes, it would be difficult, no question.  Much more useful though.

Also, here's something easier:  the ability to put the announcements at the top of the BoardIndex as well.
FMVperformance:  3.51m posts, 63k members, 11 boards, 1 database

Mazda3Forums - SmallVolvos - MazdaSpeeders Mazda Club - FordFusionClubMazda CX-7 Club - MyMazda6
Now introducing: MKSdrivers.com - FocusDrivers - TaurusDrivers

Özgür

Maybe..

+ Topic to Announcements or Announcement to Topic Converter..
+ Announcements comments like forum message or may be a bit more regular
+ SSI Function of Announcements like ssi_announcements($announcement_id) or Announcements list SSI function.
+ Announcements on the home page to show the selected (look Attachments.)
+ Pretty url support
+ Random Announcement link to index (like random news fade)
...
=))
So Long

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Nibogo

Quote from: Özgür´ on February 28, 2009, 04:29:48 AM
Maybe..

+ Topic to Announcements or Announcement to Topic Converter..
+ Announcements comments like forum message or may be a bit more regular
+ SSI Function of Announcements like ssi_announcements($announcement_id) or Announcements list SSI function.
+ Announcements on the home page to show the selected (look Attachments.)
+ Pretty url support
+ Random Announcement link to index (like random news fade)
...
=))


+ Require a lot of work
+ I don't think of this is necessary , there are just comments
+ I like this idea
+ Maybe or maybe not..
+ Nice idea too
+ You can put a news with the Announcement Url

Thanks

Quote from: edi67 on February 28, 2009, 09:27:19 AM
dont forget sticky topic ;)

This has been finished

fords8

NIBOGO, nice to see you still adding to this mod. Looking forward to the next release.

Özgür

Thanks NIBOGO.

Quote from: NIBOGO on February 28, 2009, 06:41:54 PM
+ You can put a news with the Announcement Url
No, I do not talk about it.
I'm talking about a function, etc "random_announcement_link();"
This function randomly one at a time to display announcements. (In each refresh)
Only the announcement title is given to announcement link. (Not announcement body text.)
So Long

Nibogo

Quote from: Özgür´ on March 01, 2009, 12:06:53 AM
Thanks NIBOGO.

Quote from: NIBOGO on February 28, 2009, 06:41:54 PM
+ You can put a news with the Announcement Url
No, I do not talk about it.
I'm talking about a function, etc "random_announcement_link();"
This function randomly one at a time to display announcements. (In each refresh)
Only the announcement title is given to announcement link. (Not announcement body text.)

I don't want to require the Announcements.php file to all the forum. Maybe as an Subs.php function but I'm not 100% sure about this one

Yağız...

@Özgür,
Try to add this at the end of SSI.php(before ?>):
function ssi_random_announcement_link()
{
   global $smcFunc, $scripturl;
   $dbresult = $smcFunc['db_query']('', "
   SELECT id_announcement, enable, title
   FROM {db_prefix}announcements
   WHERE enable = '1'
   ORDER BY RAND()
   LIMIT 1");
   while ($row = $smcFunc['db_fetch_assoc']($dbresult))
   {
      echo '<a href="',$scripturl,'?action=announcements;aid=',$row['id_announcement'],'">',$row['title'], '</a>';
   }
   $smcFunc['db_free_result']($dbresult);
}

Add this where you want show announcement:
global $boarddir;
require_once($boarddir . '/SSI.php');
ssi_random_announcement_link();

I didn't try but it should be something like this.




shumilica

Hello. Just installed the mod, works fine for default theme but i have another theme that i use (vogue ) and it is a bit different. I can't figure it out how to modify it...
Can you, nibogo, give a little help, or somebody else that has knowledge of php...?
Thanks in advance!


Oh... and if anybody needs Romanian translation for YAGAM I will attach it here. Nibogo, if you want you can put it in the package  :)
And modifications.romanian.php:

// YAGAM - Admin and MessageIndex Strings
$txt['yagam_admin'] = 'Anunturi Globale';
$txt['yagam_topics'] = 'Topicuri Normale';
$txt['yagam_created'] = 'Creat:';
$txt['whoall_announcements'] = 'Vizualizeaza un Anunt Global';
$txt['permissionname_yagam_manage'] = 'Manage Global Announcements';
$txt['permissionhelp_yagam_manage'] = 'Sets if the user can manage the global announcements.';
$txt['permissionname_yagam_comment'] = 'Comment Global Announcements';
$txt['permissionhelp_yagam_comment'] = 'Sets if the user can comment the global announcements of allow comments.';
$txt['yagam_edit2'] = 'Editeaza';
$txt['yagam_edit'] = 'Editeaza anuntul';
$txt['yagam_remove'] = 'Sterge Anuntul';
$txt['yagam_remove2'] = 'Sterge';
$txt['yagam_admin_add'] = 'Adauga un Anunt Global';
$txt['announcement_no_permission'] = 'Nu aveti permisiunea de a vizualiza acest anunt global';



UPDATE:

NEVERMIND! I was able to change it and now looks good. If somebody needs it:

After this

// If this person can approve items and we have some awaiting approval tell them.
if (!empty($context['unapproved_posts_message']))
{
echo '
<tr class="windowbg2">
<td colspan="' , !empty($options['display_quick_mod']) ? '8' : '7' , '" class="smalltext headerpadding">
<span style="color: red;">!</span> ', $context['unapproved_posts_message'], '
</td>
</tr>';
}


Put this code provided by Nibogo in the first place. So I only modified the place it should go in this theme (it looks the same!)

// YAGAM starts here with the announcement bar, normal bar and the windowclass
$announcement_bar = false;
        $normal_bar = false;
$windowclass = "windowbg";     

       foreach($context['announcements']  as $announcement)
   {        
// Ok , I have permission to see this??
$pGroups = explode(',',$announcement['permissions']);
        $announcement_permission = count(array_intersect($user_info['groups'], $pGroups)) == 0 ? false : true;

// Lets check if the announcement can be shown in this board
$pBoards = explode(',', $announcement['id_boards']);
foreach ($pBoards as $board_announcement)
{    

// Lets Add the Global Announcement Bar only with the permission and the board = 0 or current board
if ((ltrim($board_announcement) == $board_info['id'] || $announcement['id_boards'] == 0) && ($announcement_permission == true || $context['user']['is_admin']) && !$announcement_bar){
            echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '" style="padding:8px 4px;"><b>'.$txt['yagam_admin'].'</b></td></tr>';
            $announcement_bar = true;
            }

// You can see this if you have permission and the ga is enable or you are the admin
                if ((ltrim($board_announcement) == $board_info['id'] || $announcement['id_boards'] == 0) && ($announcement_permission == true || $context['user']['is_admin']))
                {
echo '
<tr class="windowbg2">
<td class="windowbg2 icon1">
<img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" />
</td>
<td class="windowbg2 icon2">
<img src="', $settings['images_url'], '/post/exclamation.gif" alt="" />
</td>
<td  class="subject ', $windowclass, '">
<a href="',$scripturl,'?action=announcements;aid=',$announcement['id_announcement'],'">',$announcement['title'], '</a><br />
</td>
<td class="windowbg2 starter">
<a href="'.$scripturl.'?action=profile;u=',$announcement['author'], '">',$announcement['real_name'], '</a>
</td>
<td class="windowbg replies">';
if ($announcement['can_comment'] == '1')
echo''.$announcement['comment_total'].'';
else
    echo'--';
echo'</td>
<td class="windowbg views">
',$announcement['views'], '
</td>
<td class="windowbg2 lastpost">
'.$txt['yagam_created'].' : ',timeformat($announcement['date']), '
</td>';
if (allowedTo('yagam_manage') && !empty($options['display_quick_mod']))
echo '<td class="windowbg2 moderate"><a href="',$scripturl,'?action=announcements;sa=edit;id=',$announcement['id_announcement'],'" title="'.$txt['yagam_edit'].'"><img src="'.$settings['images_url'].'/buttons/modify.gif" alt="',$txt['yagam_edit2'], '"></a>
<a href="',$scripturl,'?action=announcements;sa=deleteverify;id=',$announcement['id_announcement'],'" title="'.$txt['yagam_remove'].'"><img src="'.$settings['images_url'].'/buttons/delete.gif" alt="',$txt['yagam_remove2'], '"></a>
</td>';
echo'</tr>';

// Alternate the style class
                if (!empty($windowclass) && $windowclass == "windowbg")
                  $windowclass = "windowbg2";
                else
                  $windowclass = "windowbg";                   
}

}
}
// The Normal Bar
            if($announcement_bar && !$normal_bar){
            echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '" style="padding:8px 4px;"><b>'.$txt['yagam_topics'].'</b></td></tr>';
            $normal_bar = true;
            }
Today, if you're not confused it means you're not thinking clear!

Özgür

Thanks Yağız But not work.
Unknown column 'a.enable' in 'where clause'
Dosya: /home/rockayse/public_html/rk/SSI.php
I change "a.enable" to "enable" work now.
So Long

Yağız...

Ah sorry, I had to delete it but I forgot. Thanks for the fix.

Xepernas

Quote from: shumilica on March 03, 2009, 01:45:52 AMNEVERMIND! I was able to change it and now looks good. If somebody needs it

Thanks a huge lot, Shumilica. You've just unlocked Yagam for a wide array of babylon-based themes (Slick Blue, Black day, New Babylon 2, etc), that were until now incompatible - at least to us non-techs who had no idea where to paste the Yagam code.

I still have a tiny issue with that solution though, that may be related (or not) to the fact you were not using SMF2 RC1 : In the Global Announcements zone, the "hot topic", "subject icon", "replies count" and "views count" are aligned to the left of their respective columns, unlike their Normal Topics counterparts (that are generally centered). Do you have an idea on how to correct this ? Or could anybody else tell ?



Nibogo

Thanks shumilica for the translation :)

I need someone with a nice level of english because You know my english sucks and I want to check the English strings , anybody can help me with that??

shumilica

Quote from: Xepernas on March 03, 2009, 09:30:59 AM
Quote from: shumilica on March 03, 2009, 01:45:52 AMNEVERMIND! I was able to change it and now looks good. If somebody needs it
I still have a tiny issue with that solution though, that may be related (or not) to the fact you were not using SMF2 RC1 : In the Global Announcements zone, the "hot topic", "subject icon", "replies count" and "views count" are aligned to the left of their respective columns, unlike their Normal Topics counterparts (that are generally centered). Do you have an idea on how to correct this ? Or could anybody else tell ?

Yes, I didn't noticed that when I posted the message, so please select all the code from above and replace it with this:

// YAGAM starts here with the announcement bar, normal bar and the windowclass
$announcement_bar = false;
        $normal_bar = false;
$windowclass = "windowbg";    

       foreach($context['announcements']  as $announcement)
   {       
// Ok , I have permission to see this??
$pGroups = explode(',',$announcement['permissions']);
        $announcement_permission = count(array_intersect($user_info['groups'], $pGroups)) == 0 ? false : true;

// Lets check if the announcement can be shown in this board
$pBoards = explode(',', $announcement['id_boards']);
foreach ($pBoards as $board_announcement)
{    

// Lets Add the Global Announcement Bar only with the permission and the board = 0 or current board
if ((ltrim($board_announcement) == $board_info['id'] || $announcement['id_boards'] == 0) && ($announcement_permission == true || $context['user']['is_admin']) && !$announcement_bar){
            echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '" style="padding:8px 4px;"><b>'.$txt['yagam_admin'].'</b></td></tr>';
            $announcement_bar = true;
            }

// You can see this if you have permission and the ga is enable or you are the admin
                if ((ltrim($board_announcement) == $board_info['id'] || $announcement['id_boards'] == 0) && ($announcement_permission == true || $context['user']['is_admin']))
                {
echo '
<tr class="windowbg2">
<td class="windowbg2 icon1">
<img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" />
</td>
<td class="windowbg2 icon2">
<img src="', $settings['images_url'], '/post/exclamation.gif" alt="" />
</td>
<td  class="subject ', $windowclass, '">
<a href="',$scripturl,'?action=announcements;aid=',$announcement['id_announcement'],'">',$announcement['title'], '</a><br />
</td><td class="windowbg replies">';
if ($announcement['can_comment'] == '1')
echo''.$announcement['comment_total'].'';
else
    echo'--';
echo'</td>

<td class="windowbg2 starter">
<a href="'.$scripturl.'?action=profile;u=',$announcement['author'], '">',$announcement['real_name'], '</a>
</td>
<td class="windowbg views">
',$announcement['views'], '
</td>
';

echo'
<td class="windowbg2 lastpost">
'.$txt['yagam_created'].' : ',timeformat($announcement['date']), '
</td>';
if (allowedTo('yagam_manage') && !empty($options['display_quick_mod']))
echo '<td class="windowbg2 moderate"><a href="',$scripturl,'?action=announcements;sa=edit;id=',$announcement['id_announcement'],'" title="'.$txt['yagam_edit'].'"><img src="'.$settings['images_url'].'/buttons/modify.gif" alt="',$txt['yagam_edit2'], '"></a>
<a href="',$scripturl,'?action=announcements;sa=deleteverify;id=',$announcement['id_announcement'],'" title="'.$txt['yagam_remove'].'"><img src="'.$settings['images_url'].'/buttons/delete.gif" alt="',$txt['yagam_remove2'], '"></a>
</td>';
echo'</tr>';

// Alternate the style class
                if (!empty($windowclass) && $windowclass == "windowbg")
                  $windowclass = "windowbg2";
                else
                  $windowclass = "windowbg";                   
}

}
}
// The Normal Bar
            if($announcement_bar && !$normal_bar){
            echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '" style="padding:8px 4px;"><b>'.$txt['yagam_topics'].'</b></td></tr>';
            $normal_bar = true;
            }

It should work... for me it works and I use RC1, but the theme is for 2.0beta4

Nibogo, do you want somebody to check the texts or the coding so that it will be in perfect english? :-?
One question, i saw somebody talking about an option to force people who enter the forum to read the global announcement, will this be implemented in the next version? ;;)

Today, if you're not confused it means you're not thinking clear!



Advertisement: