<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
  <title>aC forum: Milestone Bug.</title>
  <link>http://www.activecollab.com/forums/topic/1896/</link>
  <description>Recent posts on topic: Milestone Bug.</description>
  <dc:language>en-us</dc:language>
  <pubDate>Thu, 16 Oct 2008 02:57:18 UTC</pubDate>
  
  <item>
    <link>http://www.activecollab.com/forums/post/8895/#post8895</link>
    <guid>http://www.activecollab.com/forums/post/8895/#post8895</guid>
    <title>Post #1 by aamirpitafi</title>
    <dc:creator>aamirpitafi</dc:creator>
    <description><![CDATA[<p>Hi,<br />
<br />
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 :<br />
<br />
function add() {<br />
$this-&gt;setTemplate('add_milestone');<br />
<br />
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {<br />
flash_error(lang('no access permissions'));<br />
$this-&gt;redirectToReferer(get_url('milestone'));<br />
} // if<br />
<br />
$milestone_data = array_var($_POST, 'milestone');<br />
if(!is_array($milestone_data)) {<br />
$milestone_data = array(<br />
'due_date' =&gt; DateTimeValueLib::now(),<br />
); // array<br />
} // if<br />
$milestone = new ProjectMilestone();<br />
tpl_assign('milestone_data', $milestone_data);<br />
tpl_assign('milestone', $milestone);<br />
<br />
if(is_array(array_var($_POST, 'milestone'))) {<br />
$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));<br />
<br />
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));<br />
<br />
$milestone-&gt;setFromAttributes($milestone_data);<br />
if(!logged_user()-&gt;isMemberOfOwnerCompany()) $milestone-&gt;setIsPrivate(false);<br />
<br />
$milestone-&gt;setProjectId(active_project()-&gt;getId());<br />
$milestone-&gt;setAssignedToCompanyId(array_var($assigned_to, 0, 0));<br />
$milestone-&gt;setAssignedToUserId(array_var($assigned_to, 1, 0));<br />
<br />
try {<br />
DB::beginWork();<br />
<br />
$milestone-&gt;save();<br />
$milestone-&gt;setTagsFromCSV(array_var($milestone_data, 'tags'));<br />
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);<br />
<br />
DB::commit();<br />
<br />
// Send notification<br />
try {<br />
if(array_var($milestone_data, 'send_notification') == 'checked') {<br />
Notifier::milestoneAssigned($milestone); // send notification<br />
} // if<br />
} catch(Exception $e) {<br />
<br />
} // try<br />
<br />
flash_success(lang('success add milestone', $milestone-&gt;getName()));<br />
$this-&gt;redirectTo('milestone');<br />
<br />
} catch(Exception $e) {<br />
DB::rollback();<br />
tpl_assign('error', $e);<br />
} // try<br />
} // if<br />
} // add<br />
<br />
So I fix it and also please remove the validate check on date because there is no need.<br />
<br />
function validate(&amp;$errors) {<br />
if(!$this-&gt;validatePresenceOf('name')) $errors[] = lang('milestone name required');<br />
//if(!$this-&gt;validatePresenceOf('due_date')) $errors[] = lang('milestone due date required');<br />
} // validate<br />
<br />
function add() {<br />
$this-&gt;setTemplate('add_milestone');<br />
<br />
if(!ProjectMilestone::canAdd(logged_user(), active_project())) {<br />
flash_error(lang('no access permissions'));<br />
$this-&gt;redirectToReferer(get_url('milestone'));<br />
} // if<br />
<br />
$milestone_data = array_var($_POST, 'milestone');<br />
if(!is_array($milestone_data)) {<br />
$milestone_data = array(<br />
'due_date' =&gt; DateTimeValueLib::now(),<br />
); // array<br />
} // if<br />
$milestone = new ProjectMilestone();<br />
<br />
if(is_array(array_var($_POST, 'milestone'))) {<br />
$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));<br />
<br />
$assigned_to = explode(':', array_var($milestone_data, 'assigned_to', ''));<br />
<br />
$milestone-&gt;setFromAttributes($milestone_data);<br />
if(!logged_user()-&gt;isMemberOfOwnerCompany()) $milestone-&gt;setIsPrivate(false);<br />
<br />
$milestone-&gt;setProjectId(active_project()-&gt;getId());<br />
$milestone-&gt;setAssignedToCompanyId(array_var($assigned_to, 0, 0));<br />
$milestone-&gt;setAssignedToUserId(array_var($assigned_to, 1, 0));<br />
<br />
try {<br />
DB::beginWork();<br />
<br />
$milestone-&gt;save();<br />
$milestone-&gt;setTagsFromCSV(array_var($milestone_data, 'tags'));<br />
ApplicationLogs::createLog($milestone, active_project(), ApplicationLogs::ACTION_ADD);<br />
<br />
DB::commit();<br />
<br />
// Send notification<br />
try {<br />
if(array_var($milestone_data, 'send_notification') == 'checked') {<br />
Notifier::milestoneAssigned($milestone); // send notification<br />
} // if<br />
} catch(Exception $e) {<br />
<br />
} // try<br />
<br />
flash_success(lang('success add milestone', $milestone-&gt;getName()));<br />
$this-&gt;redirectTo('milestone');<br />
<br />
} catch(Exception $e) {<br />
DB::rollback();<br />
tpl_assign('error', $e);<br />
} // try<br />
} // if<br />
<br />
tpl_assign('milestone_data', $milestone_data);<br />
tpl_assign('milestone', $milestone);<br />
<br />
} // add<br />
<br />
same as in edit case @:)<br />
<br />
Regards Amir Aziz</p>]]></description>
    <pubDate>Fri, 21 Sep 2007 22:17:38 UTC</pubDate>
  </item>
</channel>
</rss>