Milestone Bug.
Page: 1
aamirpitafi
on Sep 21. 2007. 5:05 pm
Hi,
I am a professional developer and i have experience in class working environment so i download your code and install it i see a bug on the milestone, when i add the the milestone with out entering any data , the date to be 1970 and no option for user to enter current date so i check this and found the bug in your code in MilestoneController.class.php, on add() function your code is :
function add() {
$this->setTemplate('add_milestone');
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('milestone'));
} // if
$milestone_data = array_var($_POST, 'milestone');
if(!is_array($milestone_data)) {
$milestone_data = array(
'due_date' => DateTimeValueLib::now(),
); // array
} // if
$milestone = new ProjectMilestone();
tpl_assign('milestone_data', $milestone_data);
tpl_assign('milestone', $milestone);
if(is_array(array_var($_POST, 'milestone'))) {
$milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970));
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
$milestone->setFromAttributes($milestone_data);
if(!logged_user()->isMemberOfOwnerCompany()) $milestone->setIsPrivate(false);
$milestone->setProjectId(active_project()->getId());
$milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
$milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
try {
DB::beginWork();
$milestone->save();
$milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);
DB::commit();
// Send notification
try {
if(array_var($milestone_data, 'send_notification') == 'checked') {
Notifier::milestoneAssigned($milestone); // send notification
} // if
} catch(Exception $e) {
} // try
flash_success(lang('success add milestone', $milestone->getName()));
$this->redirectTo('milestone');
} catch(Exception $e) {
DB::rollback();
tpl_assign('error', $e);
} // try
} // if
} // add
So I fix it and also please remove the validate check on date because there is no need.
function validate(&$errors) {
if(!$this->validatePresenceOf('name')) $errors[] = lang('milestone name required');
//if(!$this->validatePresenceOf('due_date')) $errors[] = lang('milestone due date required');
} // validate
function add() {
$this->setTemplate('add_milestone');
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('milestone'));
} // if
$milestone_data = array_var($_POST, 'milestone');
if(!is_array($milestone_data)) {
$milestone_data = array(
'due_date' => DateTimeValueLib::now(),
); // array
} // if
$milestone = new ProjectMilestone();
if(is_array(array_var($_POST, 'milestone'))) {
$milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970));
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
$milestone->setFromAttributes($milestone_data);
if(!logged_user()->isMemberOfOwnerCompany()) $milestone->setIsPrivate(false);
$milestone->setProjectId(active_project()->getId());
$milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
$milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
try {
DB::beginWork();
$milestone->save();
$milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);
DB::commit();
// Send notification
try {
if(array_var($milestone_data, 'send_notification') == 'checked') {
Notifier::milestoneAssigned($milestone); // send notification
} // if
} catch(Exception $e) {
} // try
flash_success(lang('success add milestone', $milestone->getName()));
$this->redirectTo('milestone');
} catch(Exception $e) {
DB::rollback();
tpl_assign('error', $e);
} // try
} // if
tpl_assign('milestone_data', $milestone_data);
tpl_assign('milestone', $milestone);
} // add
same as in edit :@)
Regards Amir Aziz
I am a professional developer and i have experience in class working environment so i download your code and install it i see a bug on the milestone, when i add the the milestone with out entering any data , the date to be 1970 and no option for user to enter current date so i check this and found the bug in your code in MilestoneController.class.php, on add() function your code is :
function add() {
$this->setTemplate('add_milestone');
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('milestone'));
} // if
$milestone_data = array_var($_POST, 'milestone');
if(!is_array($milestone_data)) {
$milestone_data = array(
'due_date' => DateTimeValueLib::now(),
); // array
} // if
$milestone = new ProjectMilestone();
tpl_assign('milestone_data', $milestone_data);
tpl_assign('milestone', $milestone);
if(is_array(array_var($_POST, 'milestone'))) {
$milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970));
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
$milestone->setFromAttributes($milestone_data);
if(!logged_user()->isMemberOfOwnerCompany()) $milestone->setIsPrivate(false);
$milestone->setProjectId(active_project()->getId());
$milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
$milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
try {
DB::beginWork();
$milestone->save();
$milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);
DB::commit();
// Send notification
try {
if(array_var($milestone_data, 'send_notification') == 'checked') {
Notifier::milestoneAssigned($milestone); // send notification
} // if
} catch(Exception $e) {
} // try
flash_success(lang('success add milestone', $milestone->getName()));
$this->redirectTo('milestone');
} catch(Exception $e) {
DB::rollback();
tpl_assign('error', $e);
} // try
} // if
} // add
So I fix it and also please remove the validate check on date because there is no need.
function validate(&$errors) {
if(!$this->validatePresenceOf('name')) $errors[] = lang('milestone name required');
//if(!$this->validatePresenceOf('due_date')) $errors[] = lang('milestone due date required');
} // validate
function add() {
$this->setTemplate('add_milestone');
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('milestone'));
} // if
$milestone_data = array_var($_POST, 'milestone');
if(!is_array($milestone_data)) {
$milestone_data = array(
'due_date' => DateTimeValueLib::now(),
); // array
} // if
$milestone = new ProjectMilestone();
if(is_array(array_var($_POST, 'milestone'))) {
$milestone_data['due_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'milestone_due_date_month', 1), array_var($_POST, 'milestone_due_date_day', 1), array_var($_POST, 'milestone_due_date_year', 1970));
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));
$milestone->setFromAttributes($milestone_data);
if(!logged_user()->isMemberOfOwnerCompany()) $milestone->setIsPrivate(false);
$milestone->setProjectId(active_project()->getId());
$milestone->setAssignedToCompanyId(array_var($assigned_to, 0, 0));
$milestone->setAssignedToUserId(array_var($assigned_to, 1, 0));
try {
DB::beginWork();
$milestone->save();
$milestone->setTagsFromCSV(array_var($milestone_data, 'tags'));
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);
DB::commit();
// Send notification
try {
if(array_var($milestone_data, 'send_notification') == 'checked') {
Notifier::milestoneAssigned($milestone); // send notification
} // if
} catch(Exception $e) {
} // try
flash_success(lang('success add milestone', $milestone->getName()));
$this->redirectTo('milestone');
} catch(Exception $e) {
DB::rollback();
tpl_assign('error', $e);
} // try
} // if
tpl_assign('milestone_data', $milestone_data);
tpl_assign('milestone', $milestone);
} // add
same as in edit :@)
Regards Amir Aziz
Topic is locked. If you have something important to say about issues discussed on this page please write at hi@a51dev.com.



