srchub

srchub Commit Details


Date:2014-12-27 19:40:29 (9 years 11 months ago)
Author:Natalie Adams
Branch:master
Commit:b8c7f906eb9cdd7fef2dafe8f2dce73dc26fb0fd
Parents: cc6f2b2ca8b5cc0eeb509f403e5cd02781cdb775
Message:Moving exceptions to clean method

Changes:

File differences

indefero/src/IDF/Form/ProjectRequest.php
4343
4444
4545
46
47
46
4847
49
50
51
52
53
48
5449
5550
5651
......
6156
6257
6358
59
60
61
62
63
64
65
66
67
68
6469
6570
6671
......
7075
7176
7277
73
78
7479
7580
7681
$this->user = $extra['user'];
}
function save($commit=true)
public function clean_shortname()
{
if (!$this->isValid()) {
throw new Exception(__('Cannot save the model from an invalid form.'));
}
$shortname = $this->cleaned_data['shortname'];
$shortname = mb_strtolower($this->cleaned_data['shortname']);
if (preg_match('/[^\-A-Za-z0-9]/', $shortname)) {
throw new Pluf_Form_Invalid(__('This shortname contains illegal characters, please use only letters, digits and dash (-).'));
}
throw new Pluf_Form_Invalid(__('The shortname cannot end with the dash (-) character.'));
}
return trim($shortname);
}
function save($commit=true)
{
if (!$this->isValid()) {
throw new Exception(__('Cannot save the model from an invalid form.'));
}
$checksql = new Pluf_SQL(sprintf("shortname='%s'", $this->cleaned_data['shortname']));
$requestcheck = Pluf::factory("IDF_Project")->getCount(array('filter'=>$checksql->gen()));
if ($requestcheck == 1)
$request = new IDF_ProjectRequest();
// The trim really isn't needed - but does ensure that no whitespace will end up in the name
$request->shortname = trim($shortname);
$request->shortname = $this->cleaned_data['shortname'];
$request->repotype = $this->cleaned_data['repotype'];
$request->desc = $this->cleaned_data['desc'];
$request->submitter = $this->user;

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.05744s using 14 queries.