Example #1
0
 function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->params = $this->state->params;
     $this->modules = JFactory::getDocument()->loadRenderer('modules');
     $this->toolbar = $this->getToolbar();
     $dispatcher = JDispatcher::getInstance();
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // Process the content plugins.
     if (!empty($this->item)) {
         // Fake content item
         PFObjectHelper::toContentItem($this->item);
         // Import plugins
         JPluginHelper::importPlugin('content');
         $context = 'com_pfprojects.project';
         // Trigger events
         $results = $dispatcher->trigger('onContentPrepare', array($context, &$this->item, &$this->params, 0));
         $this->item->event = new stdClass();
         $results = $dispatcher->trigger('onContentAfterTitle', array($context, &$this->item, &$this->params, 0));
         $this->item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$this->item, &$this->params, 0));
         $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->params, 0));
         $this->item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Prepare the document
     $this->prepareDocument();
     // Display
     parent::display($tpl);
 }
 /**
  * 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 getTopicMessage($lang, $receiver, $user, $after, $before, $is_new)
 {
     // Get the changed fields
     $props = array('description', 'created_by', 'access');
     $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() . PFforumHelperRoute::getTopicRoute($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;
 }
Example #3
0
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     $uid = $user->get('id');
     $item = $this->get('Item');
     $state = $this->get('State');
     $print = JRequest::getBool('print');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // Check the view access.
     if (!$item->params->get('access-view')) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     // Set active project
     if (!PFApplicationHelper::setActiveProject($item->project_id)) {
         JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
         return false;
     }
     // Merge milestone params. If this is single-milestone view, menu params override milestone params
     // Otherwise, milestone params override menu item params
     $params = $state->get('params');
     $active = $app->getMenu()->getActive();
     $temp = clone $params;
     // Check to see which parameters should take priority
     if ($active) {
         $current_link = $active->link;
         if (strpos($current_link, 'view=milestone') && strpos($current_link, '&id=' . (string) $item->id)) {
             $item->params->merge($temp);
             // Load layout from active query (in case it is an alternative menu item)
             if (isset($active->query['layout'])) {
                 $this->setLayout($active->query['layout']);
             }
         } else {
             // Merge the menu item params with the milestone params so that the milestone params take priority
             $temp->merge($item->params);
             $item->params = $temp;
             // Check for alternative layouts (since we are not in a single-milestone menu item)
             if ($layout = $item->params->get('milestone_layout')) {
                 $this->setLayout($layout);
             }
         }
     } else {
         // Merge so that milestone params take priority
         $temp->merge($item->params);
         $item->params = $temp;
         // Check for alternative layouts (since we are not in a single-milestone menu item)
         if ($layout = $item->params->get('milestone_layout')) {
             $this->setLayout($layout);
         }
     }
     $offset = $state->get('list.offset');
     // Fake some content item properties to avoid plugin issues
     PFObjectHelper::toContentItem($item);
     // Process the content plugins.
     JPluginHelper::importPlugin('content');
     $results = $dispatcher->trigger('onContentPrepare', array('com_pfmilestones.milestone', &$item, &$params, $offset));
     $item->event = new stdClass();
     $results = $dispatcher->trigger('onContentAfterTitle', array('com_pfmilestones.milestone', &$item, &$params, $offset));
     $item->event->afterDisplayTitle = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_pfmilestones.milestone', &$item, &$params, $offset));
     $item->event->beforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_pfmilestones.milestone', &$item, &$params, $offset));
     $item->event->afterDisplayContent = trim(implode("\n", $results));
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($item->params->get('pageclass_sfx'));
     // Assign references
     $this->assignRef('params', $params);
     $this->assignRef('state', $state);
     $this->assignRef('user', $user);
     $this->assignRef('item', $item);
     $this->assignRef('print', $print);
     $this->toolbar = $this->getToolbar();
     $this->_prepareDocument();
     parent::display($tpl);
 }
Example #4
0
 /**
  * Method to generate the email message for completed milestones
  *
  * @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     $table        Instance of the item table after it was updated
  *
  * @return    string
  */
 public static function getMilestoneCompletedMessage($lang, $receiver, $user, $table)
 {
     // Get the changed fields
     $props = array('description', 'created_by', 'access', array('start_date', 'NE-SQLDATE'), array('end_date', 'NE-SQLDATE'));
     $changes = PFObjectHelper::toArray($table, $props);
     $txt_prefix = self::$prefix;
     $format = $lang->_($txt_prefix . '_MESSAGE_COMPLETED');
     $changes = PFnotificationsHelper::formatChanges($lang, $changes);
     $footer = sprintf($lang->_('COM_PROJECTFORK_EMAIL_FOOTER'), JURI::root());
     $link = JRoute::_(JURI::root() . PFmilestonesHelperRoute::getMilestoneRoute($table->id, $table->project_id));
     $txt = sprintf($format, $receiver->name, $user->name, $changes, $link);
     $txt = str_replace('\\n', "\n", $txt . "\n\n" . $footer);
     return $txt;
 }
Example #5
0
 /**
  * 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 getDesignMessage($lang, $receiver, $user, $after, $before, $is_new)
 {
     if (isset($after->approved)) {
         $changes = array('album_id' => self::translateValue('album_id', $after->album_id), 'title' => $after->title, 'file_name' => $after->file_name, 'file_size' => $after->file_size . 'kb', 'created_by' => $after->created_by, 'description' => $after->description);
         $format = $lang->_('COM_PROJECTFORK_DESIGN_EMAIL_' . ($after->approved ? 'APPROVED' : 'DECLINED') . '_MESSAGE');
     } else {
         // Get the changed fields
         $props = array('created_by', 'access', 'album_id', 'file_name', 'description');
         $changes = array();
         if (is_object($before) && is_object($after)) {
             $changes = PFObjectHelper::getDiff($before, $after, $props);
         }
         if (!count($changes)) {
             return false;
         }
         if (array_key_exists('album_id', $changes)) {
             $changes['album_id'] = self::translateValue('album_id', $changes['album_id']);
         }
         $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() . PFdesignsHelperRoute::getDesignRoute($after->id, $after->project_id, $after->album_id, '0'));
     $txt = sprintf($format, $receiver->name, $user->name, $changes, $link);
     $txt = str_replace('\\n', "\n", $txt . "\n\n" . $footer);
     return $txt;
 }
Example #6
0
 /**
  * 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 getProjectMessage($lang, $receiver, $user, $after, $before, $is_new)
 {
     $txt_prefix = self::$prefix . '_' . ($is_new ? 'NEW' : 'UPD');
     // Get the changed fields
     $props = array('description', 'catid', 'created_by', 'access', 'start_date', 'end_date');
     $changes = array();
     if (is_object($before) && is_object($after)) {
         $changes = PFObjectHelper::getDiff($before, $after, $props);
     }
     if (!count($changes)) {
         return false;
     }
     $format = $lang->_($txt_prefix . '_MESSAGE');
     $changes = PFnotificationsHelper::formatChanges($lang, $changes);
     $footer = sprintf($lang->_('COM_PROJECTFORK_EMAIL_FOOTER'), JURI::root());
     $link = JRoute::_(JURI::root() . PFprojectsHelperRoute::getDashboardRoute($after->id . ':' . $after->alias));
     $txt = sprintf($format, $receiver->name, $user->name, $changes, $link);
     $txt = str_replace('\\n', "\n", $txt . "\n\n" . $footer);
     return $txt;
 }
Example #7
0
 function display($tpl = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $dispatcher = JDispatcher::getInstance();
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $this->user = $user;
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $this->toolbar = $this->getToolbar();
     if ($this->item->revision) {
         // If we're looking at a specific revision
         $this->revision =& $this->item->revision;
     }
     // Get all revisions
     $this->model_revisions = JModelLegacy::getInstance('Revisions', 'PFdesignsModel');
     // Need to override the revisions state filter if not set
     $rev_state = (int) $this->model_revisions->getState('filter.state');
     $rev_filter = $this->model_revisions->getState('filter.isset');
     if (!$rev_state) {
         $rev_state = 1;
     }
     if ($this->item->state != $rev_state && !$rev_filter) {
         $this->model_revisions->setState('filter.state', $this->item->state);
         $this->model_revisions->setState('filter.isset', true);
     }
     // Get all revisions
     $this->revisions = (array) $this->model_revisions->getItems();
     // Get the revisions toolbar
     $this->toolbar_rev = $this->getRevisionsToolbar();
     // Merge item params.
     $this->params = $this->state->get('params');
     $active = $app->getMenu()->getActive();
     $temp = clone $this->params;
     // Check to see which parameters should take priority
     if ($active) {
         $currentLink = $active->link;
         if (strpos($currentLink, 'view=design') && strpos($currentLink, '&id=' . (string) $this->item->id)) {
             $this->item->params->merge($temp);
             // Load layout from active query (in case it is an alternative menu item)
             if (isset($active->query['layout'])) {
                 $this->setLayout($active->query['layout']);
             }
         } else {
             // Merge the menu item params with the milestone params so that the milestone params take priority
             $temp->merge($this->item->params);
             $this->item->params = $temp;
             // Check for alternative layouts (since we are not in a menu item)
             if ($layout = $this->item->params->get('design_layout')) {
                 $this->setLayout($layout);
             }
         }
     } else {
         // Merge so that item params take priority
         $temp->merge($this->item->params);
         $this->item->params = $temp;
         // Check for alternative layouts (since we are not in a menu item)
         if ($layout = $this->item->params->get('design_layout')) {
             $this->setLayout($layout);
         }
     }
     if ($this->revision) {
         // Check the view access to the item (the model has already computed the values).
         if ($this->revision->params->get('access-view') != true && ($this->revision->params->get('show_noauth') != true && $user->get('guest'))) {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return;
         }
         // Fake some article content item
         PFObjectHelper::toContentItem($this->revision);
         $this->revision->event = new stdClass();
         // Process the content plugins.
         JPluginHelper::importPlugin('content');
         $offset = $this->state->get('list.offset');
         $results = $dispatcher->trigger('onContentPrepare', array('com_pfdesigns.revision', &$this->revision, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_pfdesigns.revision', &$this->revision, &$this->params, $offset));
         $this->revision->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_pfdesigns.revision', &$this->revision, &$this->params, $offset));
         $this->revision->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_pfdesigns.revision', &$this->revision, &$this->params, $offset));
         $this->revision->event->afterDisplayContent = trim(implode("\n", $results));
     } else {
         // Check the view access to the item (the model has already computed the values).
         if ($this->item->params->get('access-view') != true && ($this->item->params->get('show_noauth') != true && $user->get('guest'))) {
             JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
             return;
         }
         // Fake some article content item
         PFObjectHelper::toContentItem($this->item);
         $this->item->event = new stdClass();
         // Process the content plugins.
         JPluginHelper::importPlugin('content');
         $offset = $this->state->get('list.offset');
         $results = $dispatcher->trigger('onContentPrepare', array('com_pfdesigns.design', &$this->item, &$this->params, $offset));
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_pfdesigns.design', &$this->item, &$this->params, $offset));
         $this->item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_pfdesigns.design', &$this->item, &$this->params, $offset));
         $this->item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_pfdesigns.design', &$this->item, &$this->params, $offset));
         $this->item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx'));
     $this->_prepareDocument();
     parent::display($tpl);
 }