Ejemplo n.º 1
0
 static function repliesLabel($replies = 0, $activity = null)
 {
     static $format = null;
     if (is_null($format)) {
         $params = JComponentHelper::getParams('com_projectfork');
         $format = $params->get('date_format');
         if (!$format) {
             $format = JText::_('DATE_FORMAT_LC1');
         }
     }
     $html = array();
     $text = JText::plural('COM_PROJECTFORK_N_REPLIES', (int) $replies);
     if ($replies == 0) {
         $html[] = '<span class="label">' . $text . '</span>';
     } else {
         $title = '';
         $class = '';
         $style = '';
         if ($activity && $activity != JFactory::getDbo()->getNullDate()) {
             $title = ' title="' . PFDate::relative($activity) . '::' . JHtml::_('date', $activity, $format) . '"';
             $style = ' style="cursor: help"';
             $class = ' hasTip';
         }
         $html[] = '<span class="label label-success' . $class . '"' . $title . $style . '>' . $text . '</span>';
     }
     return implode('', $html);
 }
Ejemplo n.º 2
0
 /**
  * Method to update the start and end dates of tasks
  * associated with the milestone.
  *
  * @param     integer    $id       The milestone id
  * @param     string     $start    The milestone start date
  * @param     string     $end      The milestone end date
  *
  * @return    void
  */
 protected function updateTimeline($id, $start = null, $end = null)
 {
     jimport('projectfork.library');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $nd = $db->getNullDate();
     $has_start = !(empty($start) || $start == $nd);
     $has_end = !(empty($end) || $end == $nd);
     // Do nothing if no start and end date are set
     if (!$has_start && !$has_end) {
         return;
     }
     $this_const = array($start, $end);
     $prev_const = array($this->prev_start, $this->prev_end);
     // Get all tasks
     $query->select('id, start_date, end_date')->from('#__pf_tasks')->where('milestone_id = ' . (int) $id)->order('id ASC');
     $db->setQuery($query);
     $tasks = (array) $db->loadObjectList('id');
     // Process tasks
     foreach ($tasks as $i => $item) {
         $item_has_start = !(empty($item->start_date) || $item->start_date == $nd);
         $item_has_end = !(empty($item->end_date) || $item->end_date == $nd);
         // Skip if not start and end date are set
         if (!$item_has_start && !$item_has_end) {
             continue;
         }
         $span = array($item->start_date, $item->end_date);
         // Shift dates
         list($new_start, $new_end) = PFDate::shiftTimeline($span, $this_const, $prev_const);
         // Update the database
         $updates = array();
         if ($item_has_start && $item->start_date != $new_start) {
             $updates[] = 'start_date = ' . $db->quote($new_start);
             $milestones[$i]->start_date = $new_start;
         }
         if ($item_has_end && $item->end_date != $new_end) {
             $updates[] = 'end_date = ' . $db->quote($new_end);
             $milestones[$i]->end_date = $new_end;
         }
         if (count($updates)) {
             $query->clear()->update('#__pf_tasks')->set(implode(', ', $updates))->where('id = ' . (int) $item->id);
             $db->setQuery($query);
             $db->execute();
         }
     }
 }
Ejemplo n.º 3
0
 public static function complete($i, $complete = 0, $can_change = false, $parents = array(), $users = array(), $start = null)
 {
     $html = array();
     $uid = JFactory::getUser()->get('id');
     $nd = JFactory::getDbo()->getNullDate();
     $p_tooltip = null;
     $u_tooltip = null;
     $s_tooltip = null;
     if ($can_change) {
         // Check if the user is assigned to the task
         if (count($users)) {
             $can_change = false;
             foreach ($users as $user) {
                 if ((int) $user->user_id == $uid) {
                     $can_change = true;
                 }
             }
             if (!$can_change) {
                 $u_tooltip = JText::_('COM_PROJECTFORK_TASKS_NOT_ASSIGNED');
             }
         }
         // Check if all dependencies are completed
         if ($can_change && $complete == 0) {
             if (count($parents)) {
                 $req = array();
                 foreach ($parents as $parent) {
                     if ($parent->complete != '1') {
                         $can_change = false;
                         $req[] = htmlspecialchars($parent->title, ENT_COMPAT, 'UTF-8');
                     }
                 }
                 if (!$can_change) {
                     $p_tooltip = JText::_('COM_PROJECTFORK_TASKS_DEPENDS_ON') . '::' . implode('<br/>', $req);
                 }
             }
         }
         // Check if the task can be started
         if ($can_change && $complete == 0) {
             if ($start && $start != $nd) {
                 $now = time();
                 $ts = strtotime($start);
                 if ($ts > $now) {
                     $can_change = false;
                     $s_tooltip = JText::_('COM_PROJECTFORK_TASKS_NOT_STARTED') . '::' . PFDate::relative($start);
                 }
             }
         }
     }
     if ($can_change) {
         $class = $complete ? ' btn-success active' : '';
         $title = $complete ? '' : JText::_('COM_PROJECTFORK_FIELD_COMPLETE_LABEL');
         $icon = $complete ? 'checkbox-unchecked' : 'checkbox-unchecked';
         $html[] = '<div class="btn-group">';
         $html[] = '<a id="complete-btn-' . $i . '" class="btn btn-mini' . $class . ' hasTooltip" rel="tooltip" title="' . $title . '" href="javascript:void(0);" onclick="PFtask.complete(' . $i . ');">';
         $html[] = '<span aria-hidden="true" class="icon-ok"></span>';
         $html[] = '</a>';
         $html[] = '</div>';
         $html[] = '<input type="hidden" id="complete' . $i . '" value="' . (int) $complete . '"/>';
     } else {
         $class = $complete ? ' label-success' : '';
         $icon = $complete ? 'icon-ok' : 'icon-ok';
         $title = '';
         if ($p_tooltip || $u_tooltip || $s_tooltip) {
             $class .= ' hasTip';
             if ($p_tooltip) {
                 $title = ' title="' . $p_tooltip . '"';
             }
             if ($u_tooltip) {
                 $title = ' title="' . $u_tooltip . '"';
             }
             if ($s_tooltip) {
                 $title = ' title="' . $s_tooltip . '"';
             }
         }
         $html[] = '<div class="btn-group">';
         $html[] = '<a id="complete-btn-' . $i . '" class="btn btn-mini disabled' . $class . '"' . $title . '>';
         $html[] = '<span aria-hidden="true" class="' . $icon . '"></span>';
         $html[] = '</a>';
         $html[] = '</div>';
         $html[] = '<input type="hidden" id="complete' . $i . '" value="' . (int) $complete . '"/>';
     }
     return implode('', $html);
 }
Ejemplo n.º 4
0
 /**
  * Returns the author of an item as label
  *
  * @param     string    $name      The user name
  * @param     string    $date      The date
  * @param     string    $format    The new date format for the tooltip
  *
  * @return    string               The label html
  */
 public static function author($name = null, $date = null, $format = null)
 {
     if (!$name || !$date) {
         return '';
     }
     $string = PFDate::relative($date);
     if ($string == false) {
         return '';
     }
     $tooltip = $string . '::' . JHtml::_('date', $date, $format ? $format : JText::_('DATE_FORMAT_LC1'));
     $html = array();
     $html[] = '<span class="label hasTip" title="' . $tooltip . '" style="cursor: help">';
     $html[] = '<i class="icon-user"></i> ';
     $html[] = htmlspecialchars($name, ENT_COMPAT, 'UTF-8');
     $html[] = '</span>';
     return implode('', $html);
 }