Fixed issue 219, notification when adding a wrong user in a project.
This commit is contained in:
parent
668b49df40
commit
c866d09e27
@ -133,6 +133,16 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form
|
|||||||
'IDF_Form_Admin_ProjectCreate', $params);
|
'IDF_Form_Admin_ProjectCreate', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean_owners()
|
||||||
|
{
|
||||||
|
return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['owners']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean_members()
|
||||||
|
{
|
||||||
|
return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['members']);
|
||||||
|
}
|
||||||
|
|
||||||
public function clean_svn_remote_url()
|
public function clean_svn_remote_url()
|
||||||
{
|
{
|
||||||
$this->cleaned_data['svn_remote_url'] = (!empty($this->cleaned_data['svn_remote_url'])) ? $this->cleaned_data['svn_remote_url'] : '';
|
$this->cleaned_data['svn_remote_url'] = (!empty($this->cleaned_data['svn_remote_url'])) ? $this->cleaned_data['svn_remote_url'] : '';
|
||||||
|
@ -61,6 +61,16 @@ class IDF_Form_Admin_ProjectUpdate extends Pluf_Form
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean_owners()
|
||||||
|
{
|
||||||
|
return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['owners']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean_members()
|
||||||
|
{
|
||||||
|
return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['members']);
|
||||||
|
}
|
||||||
|
|
||||||
public function save($commit=true)
|
public function save($commit=true)
|
||||||
{
|
{
|
||||||
if (!$this->isValid()) {
|
if (!$this->isValid()) {
|
||||||
|
@ -67,6 +67,46 @@ class IDF_Form_MembersConf extends Pluf_Form
|
|||||||
$this->project->membershipsUpdated();
|
$this->project->membershipsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean_owners()
|
||||||
|
{
|
||||||
|
return self::checkBadLogins($this->cleaned_data['owners']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean_members()
|
||||||
|
{
|
||||||
|
return self::checkBadLogins($this->cleaned_data['members']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From the input, find the bad logins.
|
||||||
|
*
|
||||||
|
* Throw a Pluf_Form_Invalid exception when bad logins are found.
|
||||||
|
*
|
||||||
|
* @param string Comma, new line delimited list of logins
|
||||||
|
* @return string Comma, new line delimited list of logins
|
||||||
|
*/
|
||||||
|
public static function checkBadLogins($logins)
|
||||||
|
{
|
||||||
|
$bad = array();
|
||||||
|
foreach (preg_split("/\015\012|\015|\012|\,/", $logins, -1, PREG_SPLIT_NO_EMPTY) as $login) {
|
||||||
|
$sql = new Pluf_SQL('login=%s', array(trim($login)));
|
||||||
|
try {
|
||||||
|
$user = Pluf::factory('Pluf_User')->getOne(array('filter'=>$sql->gen()));
|
||||||
|
if (null == $user) {
|
||||||
|
$bad[] = $login;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$bad[] = $login;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$n = count($bad);
|
||||||
|
if ($n) {
|
||||||
|
$badlogins = Pluf_esc(implode(', ', $bad));
|
||||||
|
throw new Pluf_Form_Invalid(sprintf(_n('The following login is invalid: %s.', 'The following login are invalids: %s.', $n), $badlogins));
|
||||||
|
}
|
||||||
|
return $logins;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The update of the memberships is done in different places. This
|
* The update of the memberships is done in different places. This
|
||||||
* avoids duplicating code.
|
* avoids duplicating code.
|
||||||
|
@ -86,6 +86,11 @@ class IDF_Form_TabsConf extends Pluf_Form
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean_authorized_users()
|
||||||
|
{
|
||||||
|
return IDF_Form_MembersConf::checkBadLogins($this->cleaned_data['authorized_users']);
|
||||||
|
}
|
||||||
|
|
||||||
public function save($commit=true)
|
public function save($commit=true)
|
||||||
{
|
{
|
||||||
if (!$this->isValid()) {
|
if (!$this->isValid()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user