/**
  * Returns post-receive-email hook config in gitolite format
  *
  * @param Project $project
  * @param GitRepository $repository
  */
 public function fetchMailHookConfig($project, $repository)
 {
     $conf = '';
     $conf .= ' config hooks.showrev = "';
     $conf .= $repository->getPostReceiveShowRev($this->url_manager);
     $conf .= '"';
     $conf .= PHP_EOL;
     if ($repository->getNotifiedMails() && count($repository->getNotifiedMails()) > 0) {
         $conf .= ' config hooks.mailinglist = "' . implode(', ', $repository->getNotifiedMails()) . '"';
     } else {
         $conf .= ' config hooks.mailinglist = ""';
     }
     $conf .= PHP_EOL;
     if ($repository->getMailPrefix() != GitRepository::DEFAULT_MAIL_PREFIX) {
         $conf .= ' config hooks.emailprefix = "' . $repository->getMailPrefix() . '"';
         $conf .= PHP_EOL;
     }
     return $conf;
 }
示例#2
0
    /**
     * LIST OF MAILS TO NOTIFY
     */
    protected function _listOfMails()
    {
        $r = new GitRepository();
        $r->setId($this->repoId);
        $r->load();
        $mails = $r->getNotifiedMails();
        ?>
<h3><?php 
        echo $this->getText('notified_mails_title');
        ?>
</h3>
    <?php 
        if (!empty($mails)) {
            ?>
<form id="add_user_form" action="/plugins/git/" method="POST">
    <input type="hidden" id="action" name="action" value="remove_mail" />
    <input type="hidden" id="group_id" name="group_id" value="<?php 
            echo $this->groupId;
            ?>
" />
    <input type="hidden" id="repo_id" name="repo_id" value="<?php 
            echo $this->repoId;
            ?>
" />
    <table>
        <?php 
            $i = 0;
            foreach ($mails as $mail) {
                echo '<tr class="' . html_get_alt_row_color(++$i) . '">';
                echo '<td>' . $mail . '</td>';
                echo '<td>';
                echo '<input type="checkbox" name="mail[]" value="' . $this->HTMLPurifier->purify($mail) . '" />';
                echo '</a>';
                echo '</td>';
                echo '</tr>';
            }
            ?>
    </table>
    <input type="submit" value="<?php 
            echo $GLOBALS['Language']->getText('global', 'btn_delete');
            ?>
" />
</form>
        <?php 
        } else {
            ?>
<h4><?php 
            echo $this->getText('add_mail_existing');
            ?>
 </h4>
<?php 
        }
    }
示例#3
0
 /**
  * Update list of people notified by post-receive-email hook
  *
  * @param GitRepository $repository
  */
 public function changeRepositoryMailingList($repository)
 {
     $path = $this->getGitRootPath() . $repository->getPath();
     $this->getDriver()->setConfig($path, 'hooks.mailinglist', implode(',', $repository->getNotifiedMails()));
     $this->setUpMailingHook($repository);
     return true;
 }
示例#4
0
 /**
  * @return bool
  */
 private function sendMail(GitRepository $repository, MailBuilder $mail_builder, $oldrev, $newrev, $refname)
 {
     $mail_raw_output = array();
     exec('/usr/share/codendi/plugins/git/hooks/post-receive-email ' . escapeshellarg($oldrev) . ' ' . escapeshellarg($newrev) . ' ' . escapeshellarg($refname), $mail_raw_output);
     $subject = isset($mail_raw_output[0]) ? $mail_raw_output[0] : self::DEFAULT_MAIL_SUBJECT;
     $mail_enhancer = new MailEnhancer();
     $this->addAdditionalMailHeaders($mail_enhancer, $mail_raw_output);
     $this->setFrom($mail_enhancer);
     $body = $this->createMailBody($mail_raw_output);
     $access_link = $repository->getDiffLink($this->repository_url_manager, $newrev);
     $notification = new Notification($repository->getNotifiedMails(), $subject, '', $body, $access_link, 'Git');
     return $mail_builder->buildAndSendEmail($repository->getProject(), $notification, $mail_enhancer);
 }