public function save(Doctrine_Connection $conn = null)
 {
     if (is_null($this->_get('username')) && is_null($this->_get('email_address'))) {
         return;
         //throw new sfException('Cannot save User with null username and email!');
     }
     if ($this->isNew() && sfGuardUserTable::getIfValidatedUserHasUsername($this->_get('username'))) {
         throw new sfException('Cannot save user.  This username has already been validated with another user.');
     }
     if (!$this->isNew() && in_array('is_validated', $this->_modified) && !$this->_get('is_validated')) {
         /* The user has been un-validated, probably due to changing their
          * Reddit validation key by username or password.  We need to send
          * them an email about it.
          */
         $parameters = array('user_id' => $this->getIncremented());
         $prefer_html = $this->getPreferHtml();
         $address = $this->getEmailAddress();
         $name = $this->getPreferredName() ? $this->getPreferredName() : $this->getFullName();
         $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('ChangeRedditKey', $this->getPreferredLanguage());
         $subject = $email->generateSubject($parameters);
         $body = $email->generateBodyText($parameters, $prefer_html);
         $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>');
         AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null);
         $this->addLoginMessage('You have changed information relating to your Reddit user and will need to validate your Reddit username again.  Please see your email for more information.');
     }
     parent::save($conn);
 }
Пример #2
0
 public function save(Doctrine_Connection $conn = null)
 {
     $send_message = false;
     if ($this->isNew()) {
         if (!$this->hasVerifiedSender()) {
             $this->deleteWithException("Cannot create Message " . "because sfGuardUser " . $this->getSenderId() . " has not been validated yet.", 406);
         }
         if (!$this->hasVerifiedRecipient()) {
             $this->deleteWithException("Cannot create Message " . "because sfGuardUser " . $this->getSenderId() . " has not been validated yet.", 406);
         }
         $send_message = true;
     }
     /* If the obejct is not new or has passed all rules for saving, we pass
      * it on to the parent save function.
      */
     parent::save($conn);
     if ($send_message) {
         /* The following is for sending an email to the recipient to notify them that they've received a message.
          */
         $recipient = sfGuardUserTable::getInstance()->find($this->getRecipientId());
         if (!$recipient || !$recipient->getReceiveNotificationOfPrivateMessages()) {
             return parent::save($conn);
         }
         $parameters = array('user_id' => $this->getRecipientId(), 'message_id' => $this->getIncremented());
         $prefer_html = $recipient->getPreferHtml();
         $address = $recipient->getEmailAddress();
         $name = $recipient->getPreferredName() ? $recipient->getPreferredName() : $recipient->getFullName();
         $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('NewPrivateMessage', $recipient->getPreferredLanguage());
         $subject = $email->generateSubject($parameters);
         $body = $email->generateBodyText($parameters, $prefer_html);
         $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>');
         AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null);
     }
 }
Пример #3
0
 protected function prepare($user_id)
 {
     $this->app_name = ProjectConfiguration::getApplicationName();
     $this->user = sfGuardUserTable::getInstance()->find($user_id);
     if (!$this->user) {
         throw new sfException('Cannot find User identified by ' . $user_id);
     }
     $this->name = $this->user->getPreferredName() ? $this->user->getPreferredName() : $this->user->getFullName();
 }
    protected function configure()
    {
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'test'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'pressure-test';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [{$namespace}:pressure-test|INFO] task attempts to fill the database with tons
of data to speed things up.  Call it with:

  [php symfony {$namespace}:pressure-test|INFO]
EOF;
    }
    protected function configure()
    {
        $this->addArguments(array(new sfCommandArgument('domain', sfCommandArgument::REQUIRED, 'The subreddit domain.')));
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'api_v1'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'create-default-deadlines';
        $this->briefDescription = '';
        $this->detailedDescription = <<<EOF
The [{$namespace}:create-default-deadlines|INFO] task creates a set of deadlines for a subreddit if that subreddit has no current deadlines.
Call it with:

  [php symfony {$namespace}:create-default-deadlines|INFO]
EOF;
    }
    protected function configure()
    {
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'cleanup-files';
        $this->briefDescription = 'Remove old API info from the database';
        $this->detailedDescription = <<<EOF
The [{$namespace}:cleanup-files|INFO] task removes old files from the app.

It's recommended to run this task at least once a day and no more than once
every fifteen minutes.  Best for starting would be once every six hours.

Call it with:

  [php symfony {$namespace}:cleanup-files|INFO]
EOF;
    }
    protected function configure()
    {
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'email-reminders';
        $this->briefDescription = 'Emails reminders for users to validate';
        $this->detailedDescription = <<<EOF
The [{$namespace}:email-reminders|INFO] task emails reminders for users to validate
their Reddit usernames.

It's recommended to run this task once a day.  Seriously, more than that will
result in multiple emails.  Don't do that.

Call it with:

  [php symfony {$namespace}:email-reminders|INFO]
EOF;
    }
    protected function configure()
    {
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), new sfCommandOption('subreddit', null, sfCommandOption::PARAMETER_OPTIONAL, 'An alternate subreddit location', ProjectConfiguration::getDefaultSubredditAddress())));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'validate-users';
        $this->briefDescription = 'Validates users against keys taken from subreddits';
        $this->detailedDescription = <<<EOF
The [{$namespace}:validate-users|INFO] task downloads a collection of validation
keys from a subreddit to validate usernames.

It's recommended to run this task at least once a day and no more than once
every fifteen minutes. Best for starting would be once every two hours.

Call it with:

  [php symfony {$namespace}:validate-users|INFO]
EOF;
    }
Пример #9
0
 public function executeSend(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     if ($this->getUser()->getApiUserId()) {
         sfConfig::set('app_recaptcha_active', false);
     }
     $this->form = new FeedbackForm();
     if ($this->getUser()->getApiUserId()) {
         unset($this->form['name']);
         unset($this->form['email']);
     }
     $requestData = $request->getParameter($this->form->getName());
     if (sfConfig::get('app_recaptcha_active', false)) {
         $requestData['challenge'] = $this->getRequestParameter('recaptcha_challenge_field');
         $requestData['response'] = $this->getRequestParameter('recaptcha_response_field');
     }
     $this->form->bind($requestData);
     if ($this->form->isValid()) {
         if ($this->getUser()->getApiUserId()) {
             $user_data = Api::getInstance()->get('user/' . $this->getUser()->getApiUserId(), true);
             $user = ApiDoctrine::createQuickObject($user_data['body']);
         } else {
             $user = null;
         }
         $values = $this->form->getValues();
         $name = $this->getUser()->getApiUserId() ? $user->getPreferredName() ? $user->getPreferredName() : $user->getFullName() : $this->form->getValue('name');
         $email = $this->getUser()->getApiUserId() ? $user->getEmailAddress() : $this->form->getValue('email');
         $signinUrl = $this->getUser()->getReferer($request->getReferer());
         $message = $name . ' ' . $email . "\n" . $values['message'] . "\nReferer:" . $signinUrl;
         $to = ProjectConfiguration::getApplicationFeedbackAddress();
         $subjects = sfConfig::get('app_feedback_subjects', array());
         $subject = ProjectConfiguration::getApplicationName() . ': ' . (array_key_exists($values['subject'], $subjects) ? $subjects[$values['subject']] : $values['subject']);
         $from_address = $this->getUser()->getApiUserId() ? "{$name} <{$email}>" : ProjectConfiguration::getApplicationEmailAddress();
         AppMail::sendMail($to, $from_address, $subject, $message);
         $this->getUser()->setFlash('notice', 'Your message has been sent to ' . ProjectConfiguration::getApplicationName() . '.');
         return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage');
     }
     $this->getUser()->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer());
     $this->setTemplate('feedback');
 }
    protected function configure()
    {
        $this->addArguments(array(new sfCommandArgument('subreddit', sfCommandArgument::OPTIONAL, 'The name of any specific subreddit', '%')));
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'advance-episodes';
        $this->briefDescription = 'Advances EpisodeAssignments';
        $this->detailedDescription = <<<EOF
The [{$namespace}:advance-episodes|INFO] task runs the "engine" of the app by
advancing currenlt Episodes according to the rules defined by their subreddit
admins.  It is also responsible for alerting users of when their connection with
an Episode is valid.

It's recommended to run this task at least once a day and no more than once
every half-hour.  Best for starting would be once every two hours.

Call it with:

  [php symfony {$namespace}:advance-episodes|INFO]
EOF;
    }
    protected function configure()
    {
        $this->addArguments(array(new sfCommandArgument('subreddit', sfCommandArgument::OPTIONAL, 'The name of any specific subreddit', '%')));
        $this->addOptions(array(new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'api_v1'), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine')));
        $this->namespace = str_replace(' ', '-', strtolower(ProjectConfiguration::getApplicationName()));
        $namespace = $this->namespace;
        $this->name = 'create-episodes';
        $this->briefDescription = 'Generates Episodes for all Subreddits without future Episodes.';
        $this->detailedDescription = <<<EOF
The [{$namespace}:create-episodes|INFO] task generates empty Episode objects for
those Subreddits not having any future Episodes.  Calling with with a specific
Subreddit name will generate Episode objects for only that Subreddit, assuming
that it does not have future Episodes.

It's recommended to run this task at least once a day and no more than once
every half-hour.  Best for starting would be once every two hours.

Call it with:

  [php symfony {$namespace}:create-episodes ]
EOF;
    }
Пример #12
0
 protected static function sendUsingZendMail($transport = null)
 {
     ProjectConfiguration::registerZend();
     $mail = new Zend_Mail();
     $mail->addHeader('X-MailGenerator', ProjectConfiguration::getApplicationName());
     $mail->setBodyText(self::$_message);
     $mail->setBodyHtml(self::$_html_message);
     $mail->setFrom(self::$_from);
     if (is_array(self::$_to)) {
         foreach (self::$_to as $send_to) {
             $mail->addTo($send_to);
         }
     } else {
         $mail->addTo(self::$_to);
     }
     $mail->setSubject(self::$_subject);
     if (sfConfig::get('sf_environment') != 'prod') {
         if (sfConfig::get('sf_logging_enabled')) {
             sfContext::getInstance()->getLogger()->info('Mail sent: ' . $mail->getBodyText()->getRawContent());
         }
         return false;
     }
     return $mail->send($transport);
 }
Пример #13
0
:</p>
    <ul>
        <li>Comedy routines</li>
        <li>Scholarly panels, debates, and presentations</li>
        <li>Independent music</li>
        <li>And tons of people expressing themselves.</li>
    </ul>
    <p>Please <?php 
echo link_to('register', '@sf_guard_register');
?>
 and
        <?php 
echo link_to('sign in', '@sf_guard_signin');
?>
 to participate!</p>
</div>
<div class="clear_columns">&nbsp;</div>
<div id="home_page_alert">
    <h3>We are in Beta</h3>
    <p>This is the beta version of
    <?php 
echo ProjectConfiguration::getApplicationName();
?>
.  I can't vouch for
    performance issues, and it's currently hosted on my own Linux node server.
    I'd like to move everything to Amazon, but first I'd just like to get things
    moving.  Please register your user and begin sharing episodes.  However, be
    aware that we probably won't be moving old episodes from this beta version
    to the upcoming release, so hold onto your episodes in case you need to
    re-release them again.</p>
</div>
Пример #14
0
 public function sendMail($body_function, $additional_params = array())
 {
     $user = $this->getGuardUser();
     if (!$user) {
         return;
     }
     if (!$user->getReceiveNotificationOfEpisodeApprovalPending() && $body_function == "EpisodeApprovalPending") {
         return;
     }
     if (!$user->getReceiveNotificationOfNewlyOpenedEpisodes() && $body_function == "NewlyOpenedEpisode") {
         return;
     }
     if (!$user->getReceiveNotificationOfPrivateMessages() && $body_function == "NewPrivateMessage") {
         return;
     }
     $prefer_html = $user->getPreferHtml();
     $address = $user->getEmailAddress();
     $name = $user->getPreferredName() ? $user->getPreferredName() : $user->getFullName();
     $user_id = $this->getApiUserId();
     if (!array_key_exists('user_id', $additional_params)) {
         $additional_params['user_id'] = $user_id;
     }
     if (array_key_exists('language', $additional_params)) {
         $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage($body_function, $additional_params['language']);
     } else {
         $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage($body_function);
     }
     if (!$email) {
         throw new sfException("Cannot find email '{$body_function}' in language '{$language}'.");
     }
     $subject = $email->generateSubject($additional_params);
     $body = $email->generateBodyText($additional_params, $prefer_html);
     $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>');
     return AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null);
 }
 public function getPanelTitle()
 {
     return ProjectConfiguration::getApplicationName() . " API Calls";
 }
 public function sendEmailAboutPassedDeadline($user_id, $episode_id)
 {
     // Send an email to that user telling them their EpisodeAssignment is now valid
     $parameters = array('user_id' => $user_id, 'episode_id' => $episode_id);
     $user = sfGuardUserTable::getInstance()->find($user_id);
     $prefer_html = $user->getPreferHtml();
     $address = $user->getEmailAddress();
     $name = $user->getPreferredName() ? $user->getPreferredName() : $user->getFullName();
     $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('PassedDeadlineOnEpisode', $user->getPreferredLanguage());
     $subject = $email->generateSubject($parameters);
     $body = $email->generateBodyText($parameters, $prefer_html);
     $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>');
     AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null);
     $user->addLoginMessage('Your episode passed its release deadline and has been re-assigned.');
 }
Пример #17
0
 protected function produceAtom($feedArray)
 {
     // Atom 1.0
     $doc = new DomDocument('1.0', 'utf-8');
     $feed = $doc->createElement('feed');
     $feed->setAttribute('xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
     $feed->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
     $feed->setAttribute('xml:lang', $feedArray['language']);
     $doc->appendChild($feed);
     $title = $doc->createElement('title', $feedArray['title']);
     $title->setAttribute('type', 'text');
     $subtitle = $doc->createElement('subtitle', $feedArray['description']);
     $subtitle->setAttribute('type', 'text');
     $updated = $doc->createElement('updated', date('Y-m-d\\TH:i:sP'));
     $generator = $doc->createElement('generator', ProjectConfiguration::getApplicationName() . ' Feed Module');
     $link_alternate = $doc->createElement('link');
     $link_alternate->setAttribute('rel', 'alternate');
     $link_alternate->setAttribute('type', 'text/html');
     $link_alternate->setAttribute('href', $feedArray['link']);
     $link_self = $doc->createElement('link');
     $link_self->setAttribute('rel', 'self');
     $link_self->setAttribute('type', 'application/atom+xml');
     $link_self->setAttribute('href', $feedArray['atom_link']);
     $id = $doc->createElement('id', $feedArray['link']);
     $author = $doc->createElement('author');
     $a_name = $doc->createElement('name', ProjectConfiguration::getApplicationName());
     $a_email = $doc->createElement('email', ProjectConfiguration::getApplicationEmailAddress());
     $a_uri = $doc->createElement('uri', $this->getController()->genUrl('@homepage', true));
     $author->appendChild($a_name);
     $author->appendChild($a_email);
     $author->appendChild($a_uri);
     $feed->appendChild($title);
     $feed->appendChild($subtitle);
     $feed->appendChild($updated);
     $feed->appendChild($generator);
     $feed->appendChild($link_alternate);
     $feed->appendChild($link_self);
     $feed->appendChild($id);
     $feed->appendChild($author);
     $itunes_explicit = $doc->createElement('itunes:explicit', $feedArray["is_nsfw"]);
     $itunes_summary = $doc->createElement('itunes:summary', substr($feedArray['description'], 0, 3999));
     $itunes_category = $doc->createElement('itunes:category');
     $itunes_category->setAttribute('text', 'Technology');
     $itunes_subcategory = $doc->createElement('itunes:category');
     $itunes_subcategory->setAttribute('text', 'Podcasting');
     $itunes_category->appendChild($itunes_subcategory);
     // Including the itunes:owner messes with the feed by overriding the title in iTunes.
     $feed->appendChild($itunes_explicit);
     $feed->appendChild($itunes_summary);
     $feed->appendChild($itunes_category);
     foreach ($feedArray['entries'] as $entry) {
         $fentry = $doc->createElement('entry');
         //$fentry->setAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
         $e_title = $doc->createElement('title');
         $e_title->setAttribute('type', 'html');
         $cdata_title = $doc->createCDATASection($entry['title']);
         $e_title->appendChild($cdata_title);
         $thumbnail_tag = $entry['thumbnail'] ? '<p><img src="' . $entry['thumbnail'] . '"/></p>' : '';
         $e_summary = $doc->createElement('summary');
         $e_summary->setAttribute('type', 'html');
         $cdata_summary = $doc->createCDATASection($thumbnail_tag . substr($entry['description'], 0, 500));
         $e_summary->appendChild($cdata_summary);
         $e_published = $doc->createElement('published', date('Y-m-d\\TH:i:sP', $entry['released']));
         $e_updated = $doc->createElement('updated', date('Y-m-d\\TH:i:sP', $entry['modified'] > $entry['released'] ? $entry['modified'] : $entry['released']));
         $e_link = $doc->createElement('link');
         $e_link->setAttribute('rel', 'alternate');
         $e_link->setAttribute('type', 'text/html');
         $e_link->setAttribute('href', $entry['link']);
         $e_id = $doc->createElement('id', $entry['link']);
         $e_author = $doc->createElement('author');
         $ea_name = $doc->createElement('name', $entry['author']['name']);
         $e_author->appendChild($ea_name);
         $e_enclosure = $doc->createElement('link');
         $e_enclosure->setAttribute('rel', 'enclosure');
         $audio_info = $this->getRemoteInfo($entry['audio_location']);
         $e_enclosure->setAttribute('type', $audio_info['type']);
         $e_enclosure->setAttribute('href', $entry['audio_location']);
         $e_enclosure->setAttribute('length', $audio_info['length']);
         $e_enclosure->setAttribute('title', 'Audio');
         $e_content = $doc->createElement('content');
         //$e_content->setAttribute('xmlns:xhtml',
         //                         'http://www.w3.org/1999/xhtml');
         $e_content->setAttribute('type', 'xhtml');
         $fragment = $doc->createDocumentFragment();
         $fragment->appendXML($thumbnail_tag . $entry['content']);
         $e_div = $doc->createElement('div');
         $e_div->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
         $e_div->appendChild($fragment);
         $e_content->appendChild($e_div);
         if ($entry['reddit_post_url']) {
             $e_comments = $doc->createElement('link');
             $e_comments->setAttribute('rel', 'replies');
             $e_comments->setAttribute('type', 'text/html');
             $e_comments->setAttribute('href', $entry['reddit_post_url']);
         }
         $fentry->appendChild($e_title);
         $fentry->appendChild($e_summary);
         $fentry->appendChild($e_published);
         $fentry->appendChild($e_updated);
         $fentry->appendChild($e_link);
         $fentry->appendChild($e_id);
         $fentry->appendChild($e_author);
         $fentry->appendChild($e_enclosure);
         $fentry->appendChild($e_content);
         $i_itunes_author = $doc->createElement('itunes:author', $entry['author']['name']);
         $i_itunes_summary = $doc->createElement('itunes:summary', substr(strip_tags($entry['description']), 0, 3999));
         $i_itunes_explicit = $doc->createElement('itunes:explicit', $entry['is_nsfw']);
         $fentry->appendChild($i_itunes_author);
         $fentry->appendChild($i_itunes_summary);
         $fentry->appendChild($i_itunes_explicit);
         $feed->appendChild($fentry);
     }
     $doc->formatOutput = true;
     $doc->preserveWhitespace = false;
     return $doc->saveXML();
 }
Пример #18
0
 public function save(Doctrine_Connection $conn = null)
 {
     if (!$this->isNew() && !$this->getSkipBackup() && in_array('graphic_file', $this->_modified) && $this->_get('graphic_file')) {
         $file_location = rtrim(ProjectConfiguration::getEpisodeGraphicFileLocalDirectory(), '/') . '/';
         $filename = $this->_get('graphic_file');
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $this->saveFileToApplicationBucket($file_location, $filename, 'upload', AmazonS3::ACL_PUBLIC);
             if ($response->isOK()) {
                 unlink($file_location . $filename);
             }
         }
     }
     if (!$this->isNew() && !$this->getSkipBackup() && in_array('audio_file', $this->_modified) && $this->_get('audio_file')) {
         $file_location = rtrim(ProjectConfiguration::getEpisodeAudioFileLocalDirectory(), '/') . '/';
         $filename = $this->_get('audio_file');
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $this->saveFileToApplicationBucket($file_location, $filename, 'audio');
         }
     }
     if (!$this->isNew() && in_array('is_submitted', $this->_modified) && $this->_get('is_submitted')) {
         /* The episode has been submitted.  We need to send an email about
          * it to the subreddit moderators.
          */
         $types = array('moderator');
         $memberships = sfGuardUserSubredditMembershipTable::getInstance()->getAllBySubredditAndMemberships($this->getSubredditId(), $types);
         $initial_is_submitted = $this->_get('is_submitted');
         $initial_submitted_at = $this->_get('submitted_at');
         foreach ($memberships as $membership) {
             $user = $membership->getSfGuardUser();
             $parameters = array('user_id' => $membership->getSfGuardUserId(), 'episode_id' => $this->getIncremented());
             $prefer_html = $user->getPreferHtml();
             $address = $user->getEmailAddress();
             $name = $user->getPreferredName() ? $user->getPreferredName() : $user->getFullName();
             $email = EmailTable::getInstance()->getFirstByEmailTypeAndLanguage('EpisodeApprovalPending', $user->getPreferredLanguage());
             $subject = $email->generateSubject($parameters);
             $body = $email->generateBodyText($parameters, $prefer_html);
             $from = sfConfig::get('app_email_address', ProjectConfiguration::getApplicationName() . ' <' . ProjectConfiguration::getApplicationEmailAddress() . '>');
             AppMail::sendMail($address, $from, $subject, $body, $prefer_html ? $body : null);
             $user->addLoginMessage('You have Episodes awaiting your approval.');
         }
         // @todo: The previous foreach loop sets the 'is_submitted' and 'submitted_at' columns to null.  I don't know why.
         $this->_set('is_submitted', $initial_is_submitted);
         $this->_set('submitted_at', $initial_submitted_at);
     }
     return parent::save($conn);
 }
Пример #19
0
 Tom Doggett - 
    <ul>
        <li><?php 
echo link_to('About Us', '@about_us');
?>
</li>
        <li>| <?php 
echo link_to('API', '@api');
?>
</li>
        <li>| <?php 
echo link_to('How to Help', '@how_to_help');
?>
</li>
        <li>| <?php 
echo link_to('How to Use ' . ProjectConfiguration::getApplicationName(), '@how_to_use');
?>
</li>
        <li>| <?php 
include_partial('global/feedback_link', array('feedback_text' => 'Offer Feedback'));
?>
</li>
        <li>| <?php 
echo link_to('Roadmap', '@roadmap');
?>
</li>
        <li>| <?php 
echo link_to('Blog', 'http://herddit.blogspot.com/');
?>
</li>
    </ul>