Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Addon enabled but did not show up on create discussion page.

This discussion is related to the EMailDiscussion addon.
ProsperProsper ✭✭
edited November 2015 in Vanilla 2.0 - 2.8

This addon used to work on vanilla version 2.1.13p1 until after upgrade to 2.2. It enabled on dashboard but did not appear on create discussion page. The default.php code for the addon is pasted below. Please can someone fix this addon, if possible let the addon show disccussion title, body, pictures etc on the email.

<?php if (!defined('APPLICATION')) exit(); $PluginInfo['EMailDiscussion'] = array( 'Description' => 'Allows users that have certain permissions to mark a discussion as an announcement and have it sent to everybody', 'Version' => '0.2', 'RequiredApplications' => NULL, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'RegisterPermissions' => array('Plugins.EMailNotification.Send'), 'HasLocale' => FALSE, 'Author' => "Catalin David", 'AuthorEmail' => '[email protected]' ); class EMailDiscussion extends Gdn_Plugin { public function PostController_BeforeFormButtons_Handler($Sender) { $Session = Gdn::Session(); if($Session->CheckPermission('Plugins.EMailNotification.Send')) { if (in_array($Sender->RequestMethod, array('discussion', 'editdiscussion'))) { $FormValues = $Sender->EventArguments['FormPostValues']; echo "<ul class='PostOptions'><li>"; echo $Sender->Form->CheckBox('EMailDiscussion', T('EMail this discussion'), array('value' => '1')); echo "</li></ul>"; } } } public function PostController_AfterDiscussionSave_Handler($Sender) { $Session = Gdn::Session(); $UserName = $Session->User->Name; $ActivityHeadline = $UserName . " has started a new discussion"; $EMailCheckBox = $Sender->Form->GetFormValue('EMailDiscussion', ''); $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID; $DiscussionName = $Sender->EventArguments['Discussion']->Name; $CategoryID = $Sender->EventArguments['Discussion']->CategoryID; $Story = "Entitled..." . $Sender->EventArguments['Discussion']->Name; $SQL = Gdn::SQL(); if($EMailCheckBox == '1') { //send an e-mail to everybody //1) select all users' e-mail address $SqlEmails = $SQL->Select('EMail','','EMail') ->From('User') ->Get(); $Emails = array(); while($Email = $SqlEmails->NextRow(DATASET_TYPE_ARRAY)) { $Emails[] = $Email['EMail']; } //2) get current user $Session = Gdn::Session(); $Name = $Session->User->Name; //3) mail //bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $Subject = "Important topic on " . $_SERVER['HTTP_HOST'] ; $Message = ' <html> <head> <title>'. $Subject .'</title> </head> <body> <p>A new message has been posted by ' . $Name . '. It can be accessed at <a href="http://'. $_SERVER['HTTP_HOST'] .'/index.php?p=/discussion/'. $DiscussionID .'">Link</a> </p> </body> </html> '; $Headers = 'MIME-Version: 1.0' . "\r\n". 'Content-type: text/html; charset=iso-8859-1' . "\r\n". 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); foreach($Emails as $Email) { mail($Email, $Subject, $Message, $Headers); } } } public function Setup() { $SQL = Gdn::SQL(); $Database = Gdn::Database(); $PermissionModel = Gdn::PermissionModel(); $PermissionModel->Database = $Database; $PermissionModel->SQL = $SQL; // Define some global addon permissions. $PermissionModel->Define(array( 'Plugins.EMailNotification.Send' )); // Set the initial administrator permissions. $PermissionModel->Save(array( 'RoleID' => 16, 'Plugins.EMailNotification.Send' => 1 )); // Make sure that User.Permissions is blank so new permissions for users get applied. $SQL->Update('User', array('Permissions' => ''))->Put(); } }


  • Any help please.

  • jackmaessenjackmaessen ✭✭✭
    edited November 2015

    Tested on 2.2 and i have no problem with it.

    Pleas look if maybe some css style puts the element on display: none
    Which theme are you using?

  • ProsperProsper ✭✭
    edited November 2015

    @jackmaessen - thank you for your comment. Please what EmailDiscussion version do you use? Mine is version 0.2 as shown on the screenshot but there is only versio 0.1 on Vanilla addon section. Should I downgrade to version 0.1? I use custom theme cloned from default theme,. EmailDiscussion used to work on my vanilla version 2.1.13p1 but stopped after upgrade to 2.2.

  • I tested 0.1 and 0.2 version and both are working fine.
    You should enable Baseline theme (default theme of Vanilla) and disable all other plugins and see if it works correctly

  • @jackmaessen - You are right. I had CSS hiding "I agree to the terms of service" and "Remember me on this computer" on the registration page which unfortunately affected the "post a discussion page" too.

Sign In or Register to comment.