/** * updateDateFieldReminderSettings - use this to update the date-fields reminder settings in the database. * * @param $field_id The date field concerned by the notification. * @param $group_artifact_id The tracker id * @param $start When will the notification start taking effect, with regards to date occurence (in days) * @param $type What is the type of the notification (after date occurence, before date occurence) * @param $frequency At which frequency (in days) the notification wil occur * @param $recurse How many times the notification mail will be sent * @param $submitter Is submitter notified ? * @param $assignee Is assignee notified ? * @param $cc Is cc notified ? * @param $commenter Is commetner notified ? * * @return true on success, false on failure. */ function updateDateFieldReminderSettings(ArtifactType $at, ArtifactField $field, $group_artifact_id, $start, $notif_type, $frequency, $recurse, $people_notified) { $res = $this->getDateFieldReminderSettings($field->getID(), $group_artifact_id); if ($res && !db_error($res)) { $notified_users = implode(",", $people_notified); if (db_numrows($res) == 0) { // No reminder, create it $insert = 'INSERT INTO artifact_date_reminder_settings' . '(field_id, group_artifact_id, notification_start, notification_type, frequency, recurse, notified_people)' . ' VALUES' . ' (' . db_ei($field->getId()) . ',' . db_ei($group_artifact_id) . ',' . db_ei($start) . ',' . db_ei($notif_type) . ',' . db_ei($frequency) . ',' . db_ei($recurse) . ',"' . db_es($notified_users) . '")'; $inserted = db_query($insert); if ($inserted) { $this->populateProcessingForField($at, $field->getId(), $group_artifact_id); return true; } return false; } else { //update reminder settings $update = sprintf('UPDATE artifact_date_reminder_settings' . ' SET notification_start=%d' . ' , notification_type=%d' . ' , frequency=%d' . ' , recurse=%d' . ' , notified_people="%s"' . ' WHERE group_artifact_id=%d' . ' AND field_id=%d', db_ei($start), db_ei($notif_type), db_ei($frequency), db_ei($recurse), db_es($notified_users), db_ei($group_artifact_id), db_ei($field->getId())); $result = db_query($update); return $result; } } else { return false; } }
/** * getter method to get summary property * * @return String : text diplayed in the left of gantt chart */ function getSummary($engine) { $af = new ArtifactField(); $af->fetchData($this->chart->getGraphicReport()->getAtid(), $this->chart->getSummary()); $engine->summary_label = $af->getLabel(); $res = $this->getTFValues($af); $this->_fillEngineData($res, $engine, 'summary'); }
/** * Display Date Field Notification Settings form * * @param * @return void */ function displayDateFieldNotificationSettings(ArtifactType $at, ArtifactField $field) { //get date field reminder settings from database $tdrArtifactField = new TrackerDateReminder_ArtifactField(); $res = $tdrArtifactField->getDateFieldReminderSettings($field->getID(), $at->getID()); $enabled = db_numrows($res) == 1; $start = db_result($res, 0, 'notification_start'); $frequency = db_result($res, 0, 'frequency'); $recurse = db_result($res, 0, 'recurse'); $notified_people = db_result($res, 0, 'notified_people'); $notified_groups = array(); $notified_users = array(); if (trim($notified_people) != "") { $notif = explode(",", $notified_people); foreach ($notif as $value) { if (preg_match("/^g/", $value)) { array_push($notified_groups, $value); } else { array_push($notified_users, $value); } } } if (count($notified_groups) == 0) { $notified_groups[] = '100'; } if (count($notified_users) == 0) { $notified_users[] = '100'; } $notif_type = db_result($res, 0, 'notification_type'); if ($notif_type == 1) { $after = "selected"; $before = ""; } else { $after = ""; $before = "selected"; } $out = ''; $baseActionUrl = '/tracker/admin/index.php?func=date_field_notification&group_id=' . $at->Group->getID() . '&atid=' . $at->getID() . '&field_id=' . $field->getID(); if ($enabled) { $out .= '<H3>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notif_settings_del_title') . '</H3>'; $out .= '<FORM ACTION="' . $baseActionUrl . '&delete_reminder=true" METHOD="POST">'; $out .= '<P>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notif_settings_del_desc') . '</P>'; $out .= '<INPUT TYPE="SUBMIT" NAME="reminder" VALUE="' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notif_settings_del_button') . '" />'; $out .= '</FORM>'; } $out .= '<FORM ACTION="' . $baseActionUrl . '" METHOD="POST" name="date_field_notification_settings_form"> <INPUT TYPE="HIDDEN" NAME="field_id" VALUE="' . $field->getID() . '"> <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . $at->Group->getID() . '"> <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . $at->getID() . '">'; $out .= '<h3>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notif_settings_field', array($field->getLabel())) . '</h3>'; $out .= '<fieldset> <TABLE BORDER="0" WIDTH="930px"><TR height="30"><TD>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part1', array($field->getLabel())) . '</TD><TD> <INPUT TYPE="TEXT" NAME="start" SIZE="5" VALUE="' . $start . '"> ' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'days') . '</TD><TD colspan=3"> <SELECT NAME="notif_type"> <OPTION VALUE="0" ' . $before . '>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notify_before') . ' <OPTION VALUE="1" ' . $after . '>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'notify_after') . ' </SELECT> ' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part2') . '</TD></TR><TR><TD valign="top">' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part3') . ' <INPUT TYPE="TEXT" NAME="recurse" SIZE="5" VALUE="' . $recurse . '"> ' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part4') . '</TD><TD valign="top"> '; $artRoleNames = array(array('value' => '1', 'text' => $GLOBALS['Language']->getText('tracker_common_types', 'role_SUBMITTER_short_desc')), array('value' => '2', 'text' => $GLOBALS['Language']->getText('tracker_common_types', 'role_ASSIGNEE_short_desc')), array('value' => '3', 'text' => $GLOBALS['Language']->getText('tracker_common_types', 'role_CC_short_desc')), array('value' => '4', 'text' => $GLOBALS['Language']->getText('tracker_common_types', 'role_COMMENTER_short_desc'))); $out .= html_build_multiple_select_box_from_array($artRoleNames, 'notified_users[]', $notified_users, 4, true, '', false, '', false, '', false); $out .= '</TD><TD valign="top">' . $GLOBALS['Language']->getText('global', 'and') . ' </TD> <TD valign="top">'; $qry = sprintf('SELECT ugroup_id, name FROM ugroup' . ' WHERE (group_id = %d || group_id = 100)' . ' AND ugroup_id <> 1' . ' AND ugroup_id <> 2' . ' AND ugroup_id <> 100', db_ei($at->Group->getID())); $res = db_query($qry); while ($rows = db_fetch_array($res)) { $groupNames[] = array('value' => 'g' . $rows['ugroup_id'], 'text' => util_translate_name_ugroup($rows['name'])); } $out .= html_build_multiple_select_box_from_array($groupNames, 'notified_groups[]', $notified_groups, 8, true, '', false, '', false, '', false); $out .= '</SELECT></TD><TD valign="top">' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part5') . ' <INPUT TYPE="TEXT" NAME="frequency" SIZE="5" VALUE="' . $frequency . '"> ' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'days') . '.</TD></TR></TABLE><INPUT TYPE="SUBMIT" NAME="submit_notif_settings" value="' . $GLOBALS['Language']->getText('global', 'btn_update') . '"></P></FORM></fieldset><P>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part6', array($field->getLabel())) . '<P>' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'reminder_form_part7', array($field->getLabel())) . '</P>' . '<P>'; echo $out; }
/** * function to generate data array based on base_field (and eventually group_field if group_field != null) * @return array : data array */ function generateData() { require_once 'common/tracker/ArtifactField.class.php'; $af_x = new ArtifactField(); $af_x->fetchData($this->atid, $this->field_X); // is_null($this->field_Y)) // $af_x->isStandardField()) // $af_x->isUsername() $result['field1'] = array(); $result['field2'] = array(); $result['c'] = array(); if (!is_null($this->field_Y)) { $af_y = new ArtifactField(); $af_y->fetchData($this->atid, $this->field_Y); } if ($af_x->isUsed() && (!isset($af_y) || $af_y->isUsed())) { $select = "SELECT STRAIGHT_JOIN "; $from = "FROM "; $where = "WHERE "; $group_by = "GROUP BY "; $order_by = "ORDER BY "; // We always join on artifact: it helps to restrict the data set and // with the current table schema it helps joins and mysql optimiser to // find the right indexes without FORCE INDEX statement. This was crucial // on type 3 query because mysql was not able to use index on // (artifact_id, field_id, value_int) so perfs was horrible. $from .= "artifact a "; $where .= "a.artifact_id IN (" . implode($this->artifacts, ',') . ") "; if ($af_x->isStandardField() && !$af_x->isUsername()) { //echo "1"; $field = "afvl.value"; $select .= "afvl.value AS field1 "; $from .= "INNER JOIN artifact_field_value_list afvl"; $from .= " ON (afvl.group_artifact_id = a.group_artifact_id AND afvl.field_id=" . db_ei($af_x->getId()) . " AND afvl.value_id = a." . db_es($this->field_X) . ") "; } else { if ($af_x->isStandardField() && $af_x->isUsername()) { //echo "2"; $field = "u.user_id"; $select .= "u.realName AS field1, u.user_id AS id1 "; $from .= "INNER JOIN user u"; $from .= " ON (u.user_id=a." . db_es($this->field_X) . ") "; } else { if (!$af_x->isStandardField() && !$af_x->isUsername()) { //echo "3"; $field = "afvl.value_id"; $select .= "afvl.value AS field1 "; $from .= "INNER JOIN artifact_field_value afv"; $from .= " ON (afv.artifact_id = a.artifact_id AND afv.field_id = " . db_ei($af_x->getId()) . ") "; $from .= "INNER JOIN artifact_field_value_list afvl"; $from .= " ON (afvl.group_artifact_id = a.group_artifact_id AND afvl.field_id = afv.field_id AND afvl.value_id = afv.valueInt) "; } else { //if (!$af_x->isStandardField() && ($af_x->isUsername())) //echo "4"; $field = "u.user_id"; $select .= "u.realName AS field1, u.user_id AS id1 "; $from .= "INNER JOIN artifact_field_value afv"; $from .= " ON (afv.artifact_id = a.artifact_id AND afv.field_id=" . db_ei($af_x->getId()) . ") "; $from .= "INNER JOIN user u"; $from .= " ON (u.user_id=afv.valueInt) "; } } } $group_by .= $field . " "; $order_by .= $field . " ASC"; // now if the second field exist if (!is_null($this->field_Y)) { $af_y = new ArtifactField(); $af_y->fetchData($this->atid, $this->field_Y); if ($af_y->isStandardField() && !$af_y->isUsername()) { //echo " : 1<br>"; $field = "afvl1.value_id"; $select .= ",afvl1.value AS field2 "; $from .= "INNER JOIN artifact_field_value_list afvl1"; $from .= " ON (afvl1.group_artifact_id = a.group_artifact_id AND afvl1.field_id = " . db_ei($af_y->getId()) . " AND afvl1.value_id = a." . db_es($af_y->getName()) . ") "; } else { if ($af_y->isStandardField() && $af_y->isUsername()) { //echo " : 2<br>"; $field = "u1.user_id"; $select .= ",u1.realName AS field2, u1.user_id AS id2 "; $from .= "INNER JOIN user u1"; $from .= " ON (u1.user_id=a." . db_es($this->field_Y) . ") "; } else { if (!$af_y->isStandardField() && !$af_y->isUsername()) { //echo " : 3<br>"; $field = "afvl1.value_id"; $select .= ",afvl1.value AS field2 "; $from .= "INNER JOIN artifact_field_value afv1"; $from .= " ON (afv1.artifact_id = a.artifact_id AND afv1.field_id = " . db_ei($af_y->getId()) . ") "; $from .= "INNER JOIN artifact_field_value_list afvl1"; $from .= " ON (afvl1.group_artifact_id = a.group_artifact_id AND afvl1.field_id = afv1.field_id AND afvl1.value_id = afv1.valueInt) "; } else { //if (!$af_y->isStandardField() && ($af_y->isUsername())) //echo " : 4<br>"; $field = "u1.user_id"; $select .= ",u1.realName AS field2, u1.user_id AS id2 "; $from .= "INNER JOIN artifact_field_value afv1"; $from .= " ON (afv1.artifact_id = a.artifact_id AND afv1.field_id = " . db_ei($af_y->getId()) . ") "; $from .= "INNER JOIN user u1"; $from .= " ON (u1.user_id=afv1.valueInt)"; } } } $group_by .= "," . $field . " "; $order_by .= "," . $field . " ASC"; } $select .= ",COUNT(0) AS c "; //artifact permissions $sql_group_id = "SELECT group_id FROM artifact_group_list WHERE group_artifact_id=" . db_ei($this->atid); $result_group_id = db_query($sql_group_id); if (db_numrows($result_group_id) > 0) { $row = db_fetch_array($result_group_id); $group_id = $row['group_id']; } $user = UserManager::instance()->getCurrentUser(); $ugroups = $user->getUgroups($group_id, array('artifact_type' => $this->atid)); $from .= " LEFT JOIN permissions\n ON (permissions.object_id = CONVERT(a.artifact_id USING utf8)\n AND \n permissions.permission_type = 'TRACKER_ARTIFACT_ACCESS') "; $where .= " AND (a.use_artifact_permissions = 0\n OR\n permissions.ugroup_id IN (" . implode(',', $ugroups) . ")\n ) "; $sql = "{$select} {$from} {$where} {$group_by} {$order_by}"; //echo "$sql<br>\n"; $res = db_query($sql); for ($i = 0; $i < db_numrows($res); $i++) { $r[$i] = db_fetch_array($res); $result['field1'][$i] = $r[$i]['field1']; if ($af_x->isUsername() && $r[$i]['id1'] == 100) { $result['field1'][$i] = $GLOBALS['Language']->getText('global', 'none'); } if (!is_null($this->field_Y)) { $result['field2'][$i] = $r[$i]['field2']; if ($af_y->isUsername() && $r[$i]['id2'] == 100) { $result['field2'][$i] = $GLOBALS['Language']->getText('global', 'none'); } } $result['c'][$i] = $r[$i]['c']; } } for ($i = 0; $i < count($result['field1']); $i++) { $x = array_search($result['field1'][$i], $this->x_values); if ($x === false) { $this->x_values[count($this->x_values)] = $result['field1'][$i]; } } if (!is_null($this->field_Y)) { for ($i = 0; $i < count($result['field2']); $i++) { $y = array_search($result['field2'][$i], $this->y_values); if ($y === false) { $this->y_values[count($this->y_values)] = $result['field2'][$i]; } } } // data initialisation for ($i = 0; $i < count($this->x_values); $i++) { if (!is_null($this->field_Y)) { for ($j = 0; $j < count($this->y_values); $j++) { $this->data[$i][$j] = 0; } } else { $this->data[$i] = 0; } } for ($i = 0; $i < count($result['c']); $i++) { $x = array_search($result['field1'][$i], $this->x_values); if (!is_null($this->field_Y)) { $y = array_search($result['field2'][$i], $this->y_values); if ($x !== false && $y !== false) { $this->data[$x][$y] = $result['c'][$i]; } } else { if ($x !== false) { $this->data[$x] = $result['c'][$i]; } } } }
function userCanVisualize() { if ($this->field_due) { $artifact_field_due = new ArtifactField(); $artifact_field_due->fetchData($GLOBALS['ath']->getID(), $this->field_due); if (!$artifact_field_due->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($this->field_percentage) { $artifact_field_percentage = new ArtifactField(); $artifact_field_percentage->fetchData($GLOBALS['ath']->getID(), $this->field_percentage); if (!$artifact_field_percentage->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($this->field_righttext) { $artifact_field_fieldright = new ArtifactField(); $artifact_field_fieldright->fetchData($GLOBALS['ath']->getID(), $this->field_righttext); if (!$artifact_field_fieldright->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($this->summary) { $artifact_field_summary = new ArtifactField(); $artifact_field_summary->fetchData($GLOBALS['ath']->getID(), $this->summary); if (!$artifact_field_summary->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($this->field_start) { $artifact_field_start = new ArtifactField(); $artifact_field_start->fetchData($GLOBALS['ath']->getID(), $this->field_start); if (!$artifact_field_start->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($this->field_finish) { $artifact_field_finish = new ArtifactField(); $artifact_field_finish->fetchData($GLOBALS['ath']->getID(), $this->field_finish); if (!$artifact_field_finish->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } return true; }
function userCanVisualize() { $artifact_field_base = new ArtifactField(); $artifact_field_base->fetchData($GLOBALS['ath']->getID(), $this->field_base); if ($this->field_group) { $artifact_field_group = new ArtifactField(); $artifact_field_group->fetchData($GLOBALS['ath']->getID(), $this->field_group); if (!$artifact_field_group->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return false; } } if ($artifact_field_base->userCanRead($GLOBALS['group_id'], $GLOBALS['ath']->getID(), user_getid())) { return true; } else { return false; } }