Exemple #1
0
                                if ($count <= 3) {
                                    $ws_color = $task->getObjectColor($task instanceof ProjectEvent ? 1 : 12);
                                    cal_get_ws_color($ws_color, $ws_style, $ws_class, $txt_color, $border_color);
                                    $cal_text = clean($task->getTitle());
                                    if (function_exists('mb_strlen')) {
                                        $cal_text = mb_strlen($cal_text) < $to_show_len ? $cal_text : mb_substr($cal_text, 0, $to_show_len - 3) . "...";
                                    } else {
                                        $cal_text = strlen($cal_text) < $to_show_len ? $cal_text : substr($cal_text, 0, $to_show_len - 3) . "...";
                                    }
                                    $output .= "<div class='nobr og-wsname-color-{$ws_color}' style='border-radius:4px;height:17px;margin:1px;padding:1px;z-index:1000;border: 1px solid;border-color:{$border_color}'>";
                                    $output .= "<span id='o_ta_div_{$tip_pre}" . $task->getId() . "'>";
                                    $output .= "<a class=\"internalLink link-ico {$ico}\" style='vertical-align:bottom;' href='" . $task->getViewUrl() . "' onclick=\"og.disableEventPropagation(event);\" >";
                                    $output .= $cal_text . "</a>";
                                    $output .= '</span>';
                                    $output .= "</div>";
                                    $tip_text = str_replace("\r", '', lang('assigned to') . ': ' . clean($task->getAssignedToName()) . (trim(clean($task->getText())) == '' ? '' : '<br><br>' . clean(html_to_text($task->getText()))));
                                    $tip_text = str_replace("\n", '<br>', $tip_text);
                                    if (strlen_utf($tip_text) > 200) {
                                        $tip_text = substr_utf($tip_text, 0, strpos($tip_text, ' ', 200)) . ' ...';
                                    }
                                    ?>
									<script>
										addTip('o_ta_div_<?php 
                                    echo $tip_pre;
                                    ?>
' + <?php 
                                    echo $task->getId();
                                    ?>
, '<i>' + '<?php 
                                    echo $tip_title;
                                    ?>
	/**
	 * Returns an unsaved copy of the task. Copies everything except open/closed state,
	 * anything that needs the task to have an id (like tags, properties, subtask),
	 * administrative info like who created the task and when, etc.
	 *
	 * @param ProjectTask $task
	 * @return ProjectTask
	 */
	function createTaskCopy(ProjectTask $task) {
		$new = new ProjectTask ();
		$new->setMilestoneId ( $task->getMilestoneId () );
		$new->setParentId ( $task->getParentId () );
		$new->setObjectName($task->getObjectName()) ;
		$new->setAssignedToContactId ( $task->getAssignedToContactId () );
		$new->setPriority ( $task->getPriority () );
		$new->setTimeEstimate ( $task->getTimeEstimate () );
		$new->setText ( $task->getText () );
		$new->setOrder ( ProjectTasks::maxOrder ( $new->getParentId (), $new->getMilestoneId () ) );
		$new->setStartDate ( $task->getStartDate () );
		$new->setDueDate ( $task->getDueDate () );
		return $new;
	}
Exemple #3
0
function instantiate_template_task_parameters(TemplateTask $object, ProjectTask $copy, $parameterValues = array())
{
    $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($object->getTemplateId(), $object->getId());
    $manager = $copy->manager();
    foreach ($objProp as $property) {
        $propName = $property->getProperty();
        $value = $property->getValue();
        if ($manager->getColumnType($propName) == DATA_TYPE_STRING || $manager->getColumnType($propName) == DATA_TYPE_INTEGER) {
            if (is_array($parameterValues)) {
                $is_present = false;
                foreach ($parameterValues as $param => $val) {
                    if (strpos($value, '{' . $param . '}') !== FALSE) {
                        $value = str_replace('{' . $param . '}', $val, $value);
                        $is_present = true;
                    }
                }
                // if parameter not present replace the parameter code with empty string
                if (!$is_present) {
                    $value = preg_replace('/[{].*[}]/U', '', $value);
                }
            }
        } else {
            if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) {
                $operator = '+';
                if (strpos($value, '+') === false) {
                    $operator = '-';
                }
                $opPos = strpos($value, $operator);
                if ($opPos !== false) {
                    // Is parametric
                    $dateParam = substr($value, 1, strpos($value, '}') - 1);
                    if ($dateParam == 'task_creation') {
                        $date = DateTimeValueLib::now();
                    } else {
                        $date = getDateValue($parameterValues[$dateParam]);
                        if (!$date instanceof DateTimeValue) {
                            $date = DateTimeValueLib::now();
                        }
                        if ($copy instanceof ProjectTask && config_option('use_time_in_task_dates') && $propName == "due_date") {
                            $copy->setUseDueTime(1);
                            $hour_min = getTimeValue(user_config_option('work_day_end_time'));
                            $hour_min['hours'];
                            $hour_min['mins'];
                            $date->setHour($hour_min['hours']);
                            $date->setMinute($hour_min['mins']);
                            $date = $date->add('s', -logged_user()->getTimezone() * 3600);
                        }
                        if ($copy instanceof ProjectTask && config_option('use_time_in_task_dates') && $propName == "start_date") {
                            $copy->setUseStartTime(1);
                            $hour_min = getTimeValue(user_config_option('work_day_start_time'));
                            $hour_min['hours'];
                            $hour_min['mins'];
                            $date->setHour($hour_min['hours']);
                            $date->setMinute($hour_min['mins']);
                            $date = $date->add('s', -logged_user()->getTimezone() * 3600);
                        }
                    }
                    $dateUnit = substr($value, strlen($value) - 1);
                    // d, w or m (for days, weeks or months)
                    if ($dateUnit == 'm') {
                        $dateUnit = 'M';
                        // make month unit uppercase to call DateTimeValue::add with correct parameter
                    }
                    $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2);
                    //Hook::fire('template_param_date_calculation', array('op' => $operator, 'date' => $date, 'template_id' => $object->getTemplateId(), 'original' => $object, 'copy' => $copy), $dateNum);
                    $value = $date->add($dateUnit, $dateNum);
                } else {
                    $value = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $value);
                }
            }
        }
        if ($value != '') {
            if (!$copy->setColumnValue($propName, $value)) {
                $copy->object->setColumnValue($propName, $value);
            }
            if ($propName == 'text' && $copy->getTypeContent() == 'text') {
                $copy->setText(html_to_text($copy->getText()));
            }
            $copy->save();
        }
    }
    // Ensure that assigned user is subscribed
    if ($copy instanceof ProjectTask && $copy->getAssignedTo() instanceof Contact) {
        $copy->subscribeUser($copy->getAssignedTo());
    }
    $ret = null;
    Hook::fire('after_template_object_param_instantiation', array('template_id' => $object->getTemplateId(), 'original' => $object, 'copy' => $copy, 'parameter_values' => $parameterValues), $ret);
}