Important Notice: Effective immediately, all support will be handled through Discord. Read more about the changes coming to Anodyne's services.

[MOD] Nova 2, Send Comments to All Users

A place to show off (and others to download) completed MODs. Note: support for MODs is handled by third parties, not Anodyne Productions.

zshassun Sat Mar 15, 2014 2:09 pm

[MOD] Nova 2, Send Comments to All Users

So here is the mod I've built as a spawn of the http://forums.anodyne-productions.com/viewtopic.php?f=60&t=4055(comments to all users mod) originally for Nova 1. This should work for Nova 2. I've kinda misplaced my Nova 1 version but I'll dig around and find it if anyone wants it.

Here we go!

Copy and paste this in the appropriate section to the file nova/modules/core/controllers/nova_main.php

Code: Select all
case 'news_comment':
            // load the resources
            $this->load->model('news_model', 'news');
            
            // get all the information from the database
            $row = $this->news->get_news_item($data['news_item']);
            $name = $this->char->get_character_name($data['author']);
            $from = $this->user->get_email_address('character', $data['author']);
            $to = $this->user->get_crew_emails(TRUE, 'email_new_news_comments');
            
            // build the content of the message
            $content = sprintf(
               lang('email_content_news_comment_added'),
               "<strong>". $row->news_title ."</strong>",
               $data['comment']
            );
            
            // compile the data for the message
            $email_data = array(
               'email_subject' => lang('email_subject_news_comment_added'),
               'email_from' => ucfirst(lang('time_from')) .': '. $name .' - '. $from,
               'email_content' => ($this->email->mailtype == 'html') ? nl2br($content) : $content
            );
            
            // where should the email be coming from
            $loc = Location::email('main_news_comment', $this->email->mailtype);
            
            // parse the message
            $message = $this->parser->parse_string($loc, $email_data, true);
            
            // set the parameters for sending the email
            $this->email->from(Util::email_sender(), $name);
            $this->email->to($to);
            $this->email->reply_to($from);
            $this->email->subject($this->options['email_subject'] .' '. $email_data['email_subject']);
            $this->email->message($message);
         break;


Here it is for mission post comments to all users:
Copy and paste this in the appropriate section to the file nova/modules/core/controllers/nova_sim.php

Code: Select all
case 'post_comment':
            // load the models
            $this->load->model('posts_model', 'posts');
            
            // run the methods
            $row = $this->posts->get_post($data['post']);
            $name = $this->char->get_character_name($data['author']);
            $from = $this->user->get_email_address('character', $data['author']);
            $to = $this->user->get_crew_emails(TRUE, 'email_new_post_comments');
            
            // set the content   
            $content = sprintf(
               lang('email_content_post_comment_added'),
               "<strong>". $row->post_title ."</strong>",
               $data['comment']
            );
            
            // create the array passing the data to the email
            $email_data = array(
               'email_subject' => lang('email_subject_post_comment_added'),
               'email_from' => ucfirst(lang('time_from')) .': '. $name .' - '. $from,
               'email_content' => ($this->email->mailtype == 'html') ? nl2br($content) : $content
            );
            
            // where should the email be coming from
            $em_loc = Location::email('sim_post_comment', $this->email->mailtype);
            
            // parse the message
            $message = $this->parser->parse_string($em_loc, $email_data, true);
            
            // set the parameters for sending the email
            $this->email->from(Util::email_sender(), $name);
            $this->email->to($to);
            $this->email->reply_to($from);
            $this->email->subject($this->options['email_subject'] .' '. $email_data['email_subject']);
            $this->email->message($message);
         break;


Here it is the personal log comments to all users:
Copy and paste this in the appropriate section to the file nova/modules/core/controllers/nova_sim.php

Code: Select all
case 'log_comment':
            // load the models
            $this->load->model('personallogs_model', 'logs');
            
            // run the methods
            $row = $this->logs->get_log($data['log']);
            $name = $this->char->get_character_name($data['author']);
            $from = $this->user->get_email_address('character', $data['author']);
            $to = $this->user->get_crew_emails(TRUE, 'email_new_log_comments');
            
            // set the content   
            $content = sprintf(
               lang('email_content_log_comment_added'),
               "<strong>". $row->log_title ."</strong>",
               $data['comment']
            );
            
            // create the array passing the data to the email
            $email_data = array(
               'email_subject' => lang('email_subject_log_comment_added'),
               'email_from' => ucfirst(lang('time_from')) .': '. $name .' - '. $from,
               'email_content' => ($this->email->mailtype == 'html') ? nl2br($content) : $content
            );
            
            // where should the email be coming from
            $em_loc = Location::email('sim_log_comment', $this->email->mailtype);
            
            // parse the message
            $message = $this->parser->parse_string($em_loc, $email_data, true);
            
            // set the parameters for sending the email
            $this->email->from(Util::email_sender(), $name);
            $this->email->to($to);
            $this->email->reply_to($from);
            $this->email->subject($this->options['email_subject'] .' '. $email_data['email_subject']);
            $this->email->message($message);
         break;


Naturally when Nova updates again, you will lose these mods, because this is not done in the applications folder. So in the next updates if the same structure is used, just re-copy all of it. Please keep in mind that if, in the future, the same structure is not used, the mod will no longer work. And it could actually break your system. Just check back here when updates are made to make sure. I'll just make a new ones if the system changes and put it here.

It's a pain, but that's what we get for modding core files :-)
User avatar

Posts: 27


Stormwolfe Mon Apr 07, 2014 4:45 pm

Re: [MOD] Nova 2, Send Comments to All Users

Hey,

This is not an actual problem with the mod itself, it's a me issue with Nova and seamless substitution.

I was trying to add the News Comments to all users mod using seamless substitution (i.e. put it in applications/controllers/main.php) - not sure that was the right file though... and all I succeeded in doing was wiping out News Items entirely. I fixed by uploading a clean copy of main.php.

AgentPhoenix,

If you happen to see this, would you give me the Village Idiot's Guide to doing this so it works in seamless substitution?

Best Regards
User avatar

Posts: 467



Return to Nova MODs

Who is online

Users browsing this forum: No registered users and 2 guests

cron