/** * Generates a list of RSS feed items. * * @return void */ function display() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $params = $app->getParams(); $doc->link = htmlspecialchars(JFactory::getURI()->toString()); $feed_email = $app->getCfg('feed_email') == '' ? 'site' : $app->getCfg('feed_email'); $site_email = $app->getCfg('mailfrom'); // Set the query limit to the feed setting JRequest::setVar('limit', (int) $app->getCfg('feed_limit', 20)); // Get model data $rows = $this->get('Items'); foreach ($rows as $row) { // Load individual item creator class $item = new JFeedItem(); $item->title = html_entity_decode($this->escape($row->title), ENT_COMPAT, 'UTF-8'); $item->link = JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($row->slug, $row->project_slug)); $item->description = $row->description; $item->date = $row->created ? date('r', strtotime($row->created)) : ''; $item->author = $row->author_name; $item->authorEmail = $feed_email == 'site' ? $site_email : $row->author_email; // Categorize the item if (!empty($row->project_title)) { $item->category = array(html_entity_decode($this->escape($row->project_title), ENT_COMPAT, 'UTF-8')); } // Loads item info into the RSS array $doc->addItem($item); } }
protected function getTitleLink() { if ($this->client_id) { $link = 'index.php?option=' . $this->item->extension . '&task=' . $this->item->name . '.edit' . '&id=' . (int) $this->item->item_id; } else { $item_slug = $this->item->item_id . ':' . $this->item->metadata->get('alias'); $p_slug = $this->item->xref_id . ':' . $this->item->metadata->get('p_alias'); $link = PFmilestonesHelperRoute::getMilestoneRoute($item_slug, $p_slug); } return JRoute::_($link); }
?> "> <span aria-hidden="true" class="icon-pencil"></span><?php echo JText::_('COM_PROJECTFORK_ACTION_EDIT'); ?> </a> </div> <?php } ?> <?php if ($cmnts_enabled) { ?> <div class="btn-group"> <a class="btn btn-mini" href="<?php echo JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($item->slug, $item->project_slug)); ?> #comments"> <span aria-hidden="true" class="icon-comment"></span> <?php echo $item->comments; ?> <?php echo JText::_('COM_PROJECTFORK_COMMENTS'); ?> </a> </div> <?php } ?> <?php if ($tasks_enabled) {
/** * Method to generate the email message * * @param object $lang Instance of the default user language * @param object $receiveer Instance of the the receiving user * @param object $user Instance of the user who made the change * @param object $after Instance of the item table after it was updated * @param object $before Instance of the item table before it was updated * @param boolean $is_new True if the item is new ($before will be null) * * @return string */ public static function getMilestoneMessage($lang, $receiver, $user, $after, $before, $is_new) { // Get the changed fields $props = array('description', 'created_by', 'access', array('start_date', 'NE-SQLDATE'), array('end_date', 'NE-SQLDATE')); $changes = array(); if (is_object($before) && is_object($after)) { $changes = PFObjectHelper::getDiff($before, $after, $props); } if ($is_new) { $changes = PFObjectHelper::toArray($after, $props); } $txt_prefix = self::$prefix . '_' . ($is_new ? 'NEW' : 'UPD'); $format = $lang->_($txt_prefix . '_MESSAGE'); $changes = PFnotificationsHelper::formatChanges($lang, $changes); $footer = sprintf($lang->_('COM_PROJECTFORK_EMAIL_FOOTER'), JURI::root()); $link = JRoute::_(JURI::root() . PFmilestonesHelperRoute::getMilestoneRoute($after->id, $after->project_id)); $txt = sprintf($format, $receiver->name, $user->name, $changes, $link); $txt = str_replace('\\n', "\n", $txt . "\n\n" . $footer); return $txt; }
/** * Generates the toolbar for the top of the view * * @return string Toolbar with buttons */ protected function getToolbar() { $access = PFmilestonesHelper::getActions($this->item->id); $uid = JFactory::getUser()->get('id'); $app = JFactory::getApplication(); if ($this->item->id) { $slug = $this->item->id . ':' . $this->item->alias; $project_slug = $app->input->getCmd('filter_project'); $return = base64_encode(PFmilestonesHelperRoute::getMilestoneRoute($slug, $project_slug)); PFToolbar::button('COM_PROJECTFORK_ACTION_EDIT', '', false, array('access' => $access->get('core.edit') || $access->get('core.edit.own') && $uid == $this->item->created_by, 'href' => JRoute::_(PFmilestonesHelperRoute::getMilestonesRoute() . '&task=form.edit&id=' . $slug . '&return=' . $return))); } if (PFApplicationHelper::enabled('com_pftasks')) { PFToolbar::button(JText::sprintf('JGRID_HEADING_TASKLISTS_AND_TASKS', intval($this->item->lists), intval($this->item->tasks)), '', false, array('href' => JRoute::_(PFtasksHelperRoute::getTasksRoute($this->item->project_id, $this->item->id)), 'icon' => 'icon-chevron-right', 'class' => '')); } return PFToolbar::render(); }
/** * Method to get a list of items of a project to render in the gantt chart * * @return array $items The items to render */ protected static function getItemsDetail() { $data = self::getProjectDetails(); $user = JFactory::getUser(); $config = JFactory::getConfig(); $params = self::$params; $items = array(); $can_edit_m_state = $user->authorise('core.edit.state', 'com_pfmilestones'); $can_edit_t_state = $user->authorise('core.edit.state', 'com_pftasks'); $default = array('1', '0', '2'); $show_ms = $params->get('show_milestones', $default); $show_l = $params->get('show_lists', $default); $show_t = $params->get('show_tasks', $default); $ms_display = (int) $params->get('ms_display'); $highlight = (int) $params->get('highlight_today'); $date_now = new JDate('now', 'UTC'); $date_now->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset')))); $today = $date_now->toUnix() * 1000; $icons = array('milestone' => 'icon-flag', 'tasklist' => 'icon-list-view', 'task-complete' => 'icon-checkbox', 'task-incomplete' => 'icon-checkbox-unchecked'); $prev_level = 0; $level = 0; // Fix "Show Task Lists" setting from older module versions if (!is_array($show_l)) { if ($show_l == '1') { $show_l = array('1', '0', '2'); } else { $show_l = array('-1'); } } // Fix empty "Show X" settings if (is_array($show_ms) && count($show_ms) == 0) { $show_ms = $default; } if (is_array($show_l) && count($show_l) == 0) { $show_l = $default; } if (is_array($show_t) && count($show_t) == 0) { $show_t = $default; } // Map item keys $map_ms = array(); $map_l = array(); $map_t = array(); foreach ($data as $i => $record) { if ($record->type == 'milestone') { $map_ms[$record->id] = $i; } if ($record->type == 'tasklist') { $map_l[$record->id] = $i; } if ($record->type == 'task') { $map_t[$record->id] = $i; } } foreach ($data as $i => $record) { $link = '#'; $prev_level = $level; $dep = array(); if ($record->type == 'milestone') { // Hide milestone? if (!in_array($record->state, $show_ms)) { continue; } $slug = $record->id . ':' . $record->alias; $pslug = self::$project . ':' . $record->p_alias; $link = JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($slug, $pslug)); $level = 0; $class = 'gantt-m'; $bid = 'gantt-m-' . $record->id; $can_edit = $can_edit_m_state; } if ($record->type == 'tasklist') { // Hide list? if (!in_array($record->state, $show_l)) { continue; } $slug = $record->id . ':' . $record->alias; $pslug = self::$project . ':' . $record->p_alias; $mslug = $record->milestone_id . ':' . $record->m_alias; $link = JRoute::_(PFtasksHelperRoute::getTasksRoute($pslug, $mslug, $slug)); $class = 'gantt-l'; $bid = 'gantt-l-' . $record->id; $can_edit = $can_edit_t_state; if ($record->milestone_id) { if (isset($map_ms[$record->milestone_id])) { $k = $map_ms[$record->milestone_id]; $ms = $data[$k]; if (!in_array($ms->state, $show_ms)) { $record->milestone_id = 0; } } } $level = $record->milestone_id ? 1 : 0; } if ($record->type == 'task') { // Hide task? if (!in_array($record->state, $show_t)) { continue; } $slug = $record->id . ':' . $record->alias; $pslug = self::$project . ':' . $record->p_alias; $mslug = $record->milestone_id . ':' . $record->m_alias; $lslug = $record->list_id . ':' . $record->l_alias; $link = JRoute::_(PFtasksHelperRoute::getTaskRoute($slug, $pslug, $mslug, $lslug)); $bid = 'gantt-t-' . $record->id; $record->type .= '-' . ($record->complete ? 'complete' : 'incomplete'); if ($record->milestone_id) { if (isset($map_ms[$record->milestone_id])) { $k = $map_ms[$record->milestone_id]; $ms = $data[$k]; if (!in_array($ms->state, $show_ms)) { $record->milestone_id = 0; } } } if ($record->list_id) { if (isset($map_l[$record->list_id])) { $k = $map_l[$record->list_id]; $l = $data[$k]; if (!in_array($l->state, $show_l)) { $record->list_id = 0; } } } if ($record->l_ms) { if (isset($map_l[$record->l_ms])) { $k = $map_l[$record->list_id]; $l = $data[$k]; if (!in_array($l->state, $show_l)) { $record->l_ms = 0; } } } if (in_array('-1', $show_l)) { $record->l_ms = 0; } $level = $record->list_id ? $record->l_ms ? 2 : 1 : ($record->milestone_id ? 1 : 0); $class = 'gantt-t'; $can_edit = $can_edit_t_state; // Add task dependencies if (count($record->parents)) { foreach ($record->parents as $parent) { $dep[] = 'gantt-t-' . $parent; } } } // Set arrow direction and indentation if ($level == 0) { $indent = '<i class="icon-arrow-right-3"></i> '; } else { $indent = '<i class="icon-arrow-' . ($ms_display ? 'down' : 'up') . '-3" style="margin-left:' . 16 * $level . 'px"></i> '; } if (!$can_edit) { $name = '<i class="' . $icons[$record->type] . '"></i> ' . '<span>' . ucfirst(htmlspecialchars($record->title)) . '</span>'; } else { $name = '<i class="' . $icons[$record->type] . '"></i> ' . '<a href="' . $link . '">' . ucfirst(htmlspecialchars($record->title)) . '</a>'; } // Create row object $row = new stdClass(); $row->name = $indent . $name; $row->desc = self::formatDuration($record->duration, $record->start_time, $record->end_time, $record->complete); $row->values = array(); // Create row item object $item = new stdClass(); if ($record->type == 'milestone' && $ms_display) { $item->label = '<i class="icon-flag"></i>'; $item->from = '/Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . ')/'; } else { $item->label = ucfirst(htmlspecialchars($record->title)); $item->from = '/Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . ')/'; } $item->to = '/Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . ')/'; $item->id = $bid; $item->desc = ''; // Determine custom class $item->customClass = $class; if ($record->complete) { $item->customClass .= '-complete'; } elseif ($record->start_time > self::$time_today) { $item->customClass .= '-notstarted'; } elseif ($record->end_time < self::$time_today) { $item->customClass .= '-behind'; } // Add dependencies if (count($dep)) { $item->dep = $dep; } // Highlight today? if ($highlight) { $hl = new stdClass(); $hl->label = ''; $hl->desc = ''; $hl->from = '/Date()/'; $hl->to = '/Date()/'; $hl->customClass = 'gantt-today'; $row->values[] = $hl; } $row->values[] = $item; $items[] = $row; } return $items; }
/** * Method to get a list of items of a project to render in the calendar * * @return array $items The items to render */ protected static function getItemsDetail() { $data = self::getProjectDetails(); $user = JFactory::getUser(); $params = self::$params; $uid = $user->id; $items = array(); $can_edit_m_state = $user->authorise('core.edit.state', 'com_pfmilestones'); $can_edit_t_state = $user->authorise('core.edit.state', 'com_pftasks'); $default = array('1', '0', '2'); $show_ms = $params->get('show_milestones', $default); $show_t = $params->get('show_tasks', $default); $ms_display = (int) $params->get('ms_display', 0); $t_display = (int) $params->get('task_display', 0); $filter_ms_complete = (int) $params->get('filter_ms_complete', 1); $filter_t_complete = (int) $params->get('filter_t_complete', 1); $filter_assigned = (int) $params->get('filter_assigned', 0); $truncate = (int) $params->get('truncate', 0); // Fix empty "Show X" settings if (is_array($show_ms) && count($show_ms) == 0) { $show_ms = $default; } if (is_array($show_t) && count($show_t) == 0) { $show_t = $default; } foreach ($data as $i => $record) { $title = ucfirst(htmlspecialchars($record->title, ENT_COMPAT, 'UTF-8')); $title2 = str_replace('&', '&', $title); if ($truncate > 0 && strlen($title) > $truncate + 3) { $title = substr($title, 0, $truncate) . '...'; } $item = '{'; $item .= 'title:\'' . $title . '\','; $item .= 'title_alt:\'' . $title2 . '\','; if ($record->type == 'milestone') { // Hide milestone? if (!in_array($record->state, $show_ms) || $filter_ms_complete == 1 && $record->complete) { continue; } $slug = $record->id . ':' . $record->alias; $pslug = self::$project . ':' . $record->p_alias; $link = JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($slug, $pslug)); $item .= 'i_type:\'ms\','; if ($ms_display == 0) { // Deadline // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'\','; $item .= 'allDay: true,'; } elseif ($ms_display == 1) { // Start and Deadline if ($record->start_time > 0) { $item2 = '{'; $item2 .= 'title:\'' . $title . '\','; $item2 .= 'title_alt:\'' . $title2 . '\','; // $item2 .= 'start:new Date(' . ($record->start_time * 1000) . '),'; $item2 .= 'start:new Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . '),'; $item2 .= 'allDay: true,'; $item2 .= 'ev_type:\'start\','; // Color if ($record->complete) { $item2 .= 'color:\'#468847\','; } elseif ($record->end_time < self::$time_today) { $item2 .= 'color:\'#B94A48\','; } $item2 .= 'url:\'' . JRoute::_(PFmilestonesHelperRoute::getMilestoneRoute($slug, $pslug)) . '\''; $item2 .= '}'; $items[] = $item2; } // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'end\','; $item .= 'allDay: true,'; } elseif ($ms_display == 2) { // Entire span if ($record->start_time > 0) { // $item .= 'start:new Date(' . ($record->start_time * 1000) . '),'; $item .= 'start:new Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . '),'; // $item .= 'end:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'end:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'span\','; } else { // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'end\','; $item .= 'allDay: true,'; } } } if ($record->type == 'task') { // Hide task? if (!in_array($record->state, $show_t) || $filter_t_complete == 1 && $record->complete) { continue; } if ($filter_assigned && !in_array($uid, $record->users)) { continue; } if ($record->complete) { $item .= 'i_type:\'tc\','; } else { $item .= 'i_type:\'ti\','; } $slug = $record->id . ':' . $record->alias; $pslug = self::$project . ':' . $record->p_alias; $mslug = $record->milestone_id . ':' . $record->m_alias; $lslug = $record->list_id . ':' . $record->l_alias; $link = JRoute::_(PFtasksHelperRoute::getTaskRoute($slug, $pslug, $mslug, $lslug)); if ($t_display == 0) { // Deadline // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'\','; $item .= 'allDay: true,'; } elseif ($t_display == 1) { // Start and Deadline if ($record->start_time > 0) { $item2 = '{'; $item2 .= 'title:\'' . ucfirst(htmlspecialchars($record->title)) . '\','; // $item2 .= 'start:new Date(' . ($record->start_time * 1000) . '),'; $item2 .= 'start:new Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . '),'; $item2 .= 'allDay: true,'; $item2 .= 'ev_type:\'start\','; // Color if ($record->complete) { $item2 .= 'color:\'#468847\','; } elseif ($record->end_time < self::$time_today) { $item2 .= 'color:\'#B94A48\','; } $item2 .= 'url:\'' . JRoute::_(PFtasksHelperRoute::getTaskRoute($slug, $pslug, $mslug, $lslug)) . '\''; $item2 .= '}'; $items[] = $item2; } // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'end\','; $item .= 'allDay: true,'; } elseif ($t_display == 2) { // Entire span if ($record->start_time > 0) { // $item .= 'start:new Date(' . ($record->start_time * 1000) . '),'; $item .= 'start:new Date(' . $record->start_year . ', ' . ($record->start_month - 1) . ', ' . $record->start_day . '),'; // $item .= 'end:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'end:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'span\','; } else { // $item .= 'start:new Date(' . ($record->end_time * 1000) . '),'; $item .= 'start:new Date(' . $record->end_year . ', ' . ($record->end_month - 1) . ', ' . $record->end_day . '),'; $item .= 'ev_type:\'end\','; $item .= 'allDay: true,'; } } } // Color if ($record->complete) { $item .= 'color:\'#468847\','; } elseif ($record->end_time < self::$time_today) { $item .= 'color:\'#B94A48\','; } $item .= 'url:\'' . $link . '\''; $item .= '}'; $items[] = $item; } return '[' . implode(',', $items) . ']'; }