/** * Method to get a version history row. * * @return stdClass|boolean On success, standard object with row data. False on failure. * * @since 3.2 */ public function getItem() { /** @var JTableContenthistory $table */ $table = JTable::getInstance('Contenthistory'); $versionId = JFactory::getApplication()->input->getInt('version_id'); if (!$table->load($versionId)) { return false; } // Get the content type's record so we can check ACL /** @var JTableContenttype $contentTypeTable */ $contentTypeTable = JTable::getInstance('Contenttype'); if (!$contentTypeTable->load($table->ucm_type_id)) { // Assume a failure to load the content type means broken data, abort mission return false; } // Access check if (!JFactory::getUser()->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table->ucm_item_id)) { $this->setError(JText::_('JERROR_ALERTNOAUTHOR')); return false; } // Good to go, finish processing the data $result = new stdClass(); $result->save_date = $table->save_date; $result->version_note = $table->version_note; $result->data = ContenthistoryHelper::prepareData($table); return $result; }
/** * Method to get a version history row. * * @return mixed On success, standard object with row data. False on failure. * * @since 3.2 */ public function getItem() { $table = JTable::getInstance('Contenthistory'); $versionId = JFactory::getApplication()->input->getInt('version_id'); if ($table->load($versionId)) { $result = new stdClass(); $result->save_date = $table->save_date; $result->version_note = $table->version_note; $result->data = ContenthistoryHelper::prepareData($table); } else { $result = false; } return $result; }
/** * Method to get a version history row. * * @return array|boolean On success, array of populated tables. False on failure. * * @since 3.2 */ public function getItems() { $input = JFactory::getApplication()->input; /** @var JTableContenthistory $table1 */ $table1 = JTable::getInstance('Contenthistory'); /** @var JTableContenthistory $table2 */ $table2 = JTable::getInstance('Contenthistory'); $id1 = $input->getInt('id1'); $id2 = $input->getInt('id2'); $result = array(); if ($table1->load($id1) && $table2->load($id2)) { // Get the first history record's content type record so we can check ACL /** @var JTableContenttype $contentTypeTable */ $contentTypeTable = JTable::getInstance('Contenttype'); $ucmTypeId = $table1->ucm_type_id; if (!$contentTypeTable->load($ucmTypeId)) { // Assume a failure to load the content type means broken data, abort mission return false; } $user = JFactory::getUser(); // Access check if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table1->ucm_item_id) || $this->canEdit($table1)) { $return = true; } else { $this->setError(JText::_('JERROR_ALERTNOAUTHOR')); return false; } // All's well, process the records if ($return == true) { foreach (array($table1, $table2) as $table) { $object = new stdClass(); $object->data = ContenthistoryHelper::prepareData($table); $object->version_note = $table->version_note; // Let's use custom calendars when present $object->save_date = JHtml::_('date', $table->save_date, 'Y-m-d H:i:s'); $dateProperties = array('modified_time', 'created_time', 'modified', 'created', 'checked_out_time', 'publish_up', 'publish_down'); foreach ($dateProperties as $dateProperty) { if (array_key_exists($dateProperty, $object->data) && $object->data->{$dateProperty}->value != '0000-00-00 00:00:00') { $object->data->{$dateProperty}->value = JHtml::_('date', $object->data->{$dateProperty}->value, 'Y-m-d H:i:s'); } } $result[] = $object; } return $result; } } return false; }
/** * Method to get a version history row. * * @return mixed On success, array of populated tables. False on failure. * * @since 3.2 */ public function getItems() { $table1 = JTable::getInstance('Contenthistory'); $table2 = JTable::getInstance('Contenthistory'); $id1 = JFactory::getApplication()->input->getInt('id1'); $id2 = JFactory::getApplication()->input->getInt('id2'); $result = array(); if ($table1->load($id1) && $table2->load($id2)) { foreach (array($table1, $table2) as $table) { $object = new stdClass(); $object->data = ContenthistoryHelper::prepareData($table); $object->version_note = $table->version_note; $object->save_date = $table->save_date; $result[] = $object; } return $result; } else { return false; } }
/** * Method to get a version history row. * * @return array|boolean On success, array of populated tables. False on failure. * * @since 3.2 */ public function getItems() { $input = JFactory::getApplication()->input; /** @var JTableContenthistory $table1 */ $table1 = JTable::getInstance('Contenthistory'); /** @var JTableContenthistory $table2 */ $table2 = JTable::getInstance('Contenthistory'); $id1 = $input->getInt('id1'); $id2 = $input->getInt('id2'); $result = array(); if ($table1->load($id1) && $table2->load($id2)) { // Get the first history record's content type record so we can check ACL /** @var JTableContenttype $contentTypeTable */ $contentTypeTable = JTable::getInstance('Contenttype'); $ucmTypeId = $table1->ucm_type_id; if (!$contentTypeTable->load($ucmTypeId)) { // Assume a failure to load the content type means broken data, abort mission return false; } $user = JFactory::getUser(); // Access check if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table1->ucm_item_id) || $this->canEdit($table1)) { $return = true; } else { $this->setError(JText::_('JERROR_ALERTNOAUTHOR')); return false; } // All's well, process the records if ($return == true) { foreach (array($table1, $table2) as $table) { $object = new stdClass(); $object->data = ContenthistoryHelper::prepareData($table); $object->version_note = $table->version_note; $object->save_date = $table->save_date; $result[] = $object; } return $result; } } return false; }
/** * Method to get a version history row. * * @return stdClass|boolean On success, standard object with row data. False on failure. * * @since 3.2 */ public function getItem() { /** @var JTableContenthistory $table */ $table = JTable::getInstance('Contenthistory'); $versionId = JFactory::getApplication()->input->getInt('version_id'); if (!$table->load($versionId)) { return false; } // Get the content type's record so we can check ACL /** @var JTableContenttype $contentTypeTable */ $contentTypeTable = JTable::getInstance('Contenttype'); if (!$contentTypeTable->load($table->ucm_type_id)) { // Assume a failure to load the content type means broken data, abort mission return false; } $user = JFactory::getUser(); // Access check if ($user->authorise('core.edit', $contentTypeTable->type_alias . '.' . (int) $table->ucm_item_id) || $this->canEdit($table)) { $return = true; } else { $this->setError(JText::_('JERROR_ALERTNOAUTHOR')); return false; } // Good to go, finish processing the data if ($return == true) { $result = new stdClass(); $result->version_note = $table->version_note; $result->data = ContenthistoryHelper::prepareData($table); // Let's use custom calendars when present $result->save_date = JHtml::_('date', $table->save_date, 'Y-m-d H:i:s'); $dateProperties = array('modified_time', 'created_time', 'modified', 'created', 'checked_out_time', 'publish_up', 'publish_down'); foreach ($dateProperties as $dateProperty) { if (array_key_exists($dateProperty, $result->data) && $result->data->{$dateProperty}->value != '0000-00-00 00:00:00') { $result->data->{$dateProperty}->value = JHtml::_('date', $result->data->{$dateProperty}->value, 'Y-m-d H:i:s'); } } return $result; } }