Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #132

Merged
merged 5 commits into from
Mar 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 55 additions & 3 deletions config/notifiers.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ DatabaseNotifier:
enabled: 1
comment:
enabled: 0
#----------------------------------------
CampfireNotifier:
status:
enabled: 0
Expand All @@ -20,19 +21,30 @@ CampfireNotifier:
message: "[Crew] message with %branch% and %date%"
add-links: 1
projects:
your-project-id:
# Specific project ID configurations
# The values here override the ones from the global configurations below
<your-project-id>:
base-url: campfire-url
api-token: campfire-api-token
room-id: room-id
status-type: ['branch', 'file']
comment-type: ['branch', 'file', 'line']
*:
base-url: campfire-url
api-token: campfire-api-token
room-id: room-id
status-type: ['branch', 'file']
comment-type: ['branch', 'file', 'line']
#----------------------------------------
XmppNotifier:
review-request:
enabled: 1
message: "New review request for branch %branch%"
add-links: 1
projects:
3:
# Specific project ID configurations
# The values here override the ones from the global configurations below
<your-project-id>:
host: jabber
port: 5222
user: username
Expand All @@ -41,4 +53,44 @@ XmppNotifier:
server: jabber.yourdomain.com
to: team-chatroom@conference.jabber.yourdomain.com
type: groupchat

# Global project configuration
*:
host: jabber
port: 5222
user: username
password: password
ressource: xmpphp
server: jabber.yourdomain.com
to: team-chatroom@conference.jabber.yourdomain.com
type: groupchat
#----------------------------------------
EmailNotifier:
status:
enabled: 0
file_message: "[Crew] message with %file% %branch% %old-status% %status% %author% %date%"
branch_message: "[Crew] message with %branch% %old-status% %status% %author% %date%"
add-links: 1
comment:
enabled: 0
branch_message: "[Crew] message with %branch% %message% %author% %date%"
file_message: "[Crew] message with %file% %branch% %message% %author% %date%"
line_message: "[Crew] message with %line% %file% %branch% %message% %author% %date%"
add-links: 1
review-request:
enabled: 0
message: "[Crew] message with %branch% and %date%"
add-links: 1
projects:
# Specific project ID configurations
# The values here override the ones from the global configurations below
<your-project-id>:
status-type: ['branch', 'file']
comment-type: ['branch', 'file', 'line']
group-email: username@domain.com
# Global project configuration
*:
status-type: ['branch', 'file']
comment-type: ['branch', 'file', 'line']
# one or multiple coma separated email address(es)
group-email: username@domain.com,username2@domain.com
email-subject: "[Crew] There is a new activity"
18 changes: 16 additions & 2 deletions lib/notifiers/BaseNotifier.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,26 @@ public function getEventConfig($eventType)

public function getCurrentProjectConfig()
{
return (isset($this->config['projects'][$this->arguments['project-id']])) ? $this->config['projects'][$this->arguments['project-id']] : array();
$config = array();
if(isset($this->config['projects'][$this->arguments['project-id']]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faudrait ajouter des { }.
Dans les coding standards de Crew, on utilise toujours les accolades même s'il n'y a qu'une instruction.

{
$config = $this->config['projects'][$this->arguments['project-id']];
}
elseif(isset($this->config['projects']['*']))
{
$config = $this->config['projects']['*'];
}
return $config;
}

protected function isEnabledForCurrentProject()
{
return isset($this->config['projects'][$this->arguments['project-id']]) || !isset($this->config['projects']);
$enabled = isset($this->config['projects'][$this->arguments['project-id']]) || !isset($this->config['projects']);
if(!$enabled)
{
$enabled = isset($this->config['projects']['*']) || !isset($this->config['projects']);
}
return $enabled;
}

protected function configure(sfEvent $event)
Expand Down
35 changes: 35 additions & 0 deletions lib/notifiers/EmailNotifier.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

class EmailNotifier extends SimpleNotifier
{
/**
* @param int $statusId
*
* @return string
*/
protected function getLabelStatus($statusId)
{
return BranchPeer::getBasecampLabelStatus($statusId);
}

/**
* @param string $message
*
* @return bool
*/
protected function send($message)
{
$configCurrentProject = $this->getCurrentProjectConfig();

if(count($configCurrentProject) == 0)
{
return false;
}

$groupEmail = $configCurrentProject['group-email'];
$emailSubject = $configCurrentProject['email-subject'];
mail($groupEmail, $emailSubject, $message);

return true;
}
}