/exchange/code/trunk/administrator/components/com_exchange/helpers/zine.php
PHP | 92 lines | 47 code | 8 blank | 37 comment | 4 complexity | 4801d9b22d607c172c5768a5028f3fe9 MD5 | raw file
- <?php
- /**
- * @version $Id: zine.php 280 2010-09-18 02:14:15Z eddieajau $
- * @package NewLifeInIT
- * @subpackage com_exchange
- * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License version 2 or later.
- * @link http://www.theartofjoomla.com
- */
- // no direct access
- defined('_JEXEC') or die;
- /**
- * Function to find the id of a section that was created
- * during the Core to Magazine migration process. It matches
- * the new section with the old section by the alias.
- *
- * @param int $oldId The old numeric id of row in the #__sections table.
- * @return int The numeric id of the section in #__jxzine_categories or 0.
- */
- function getZineSectionId($oldId)
- {
- $db = &JFactory::getDBO();
- $db->setQuery('SELECT a.id'
- . ' FROM #__jxzine_categories AS a'
- . ' JOIN #__sections AS b ON b.alias = a.alias'
- . ' WHERE a.parent_id = 0'
- . ' AND a.section = 1'
- . ' AND b.id = '.(int)$oldId);
- return (int)$db->loadResult();
- }
- /**
- * Function to find the id of a category that was created
- * during the Core to Magazine migration process. It matches
- * the new category with the old category by the alias.
- *
- * @param int $oldId The old numeric id of row in the #__categories table.
- * @return int The numeric id of the category in #__jxzine_categories or 0.
- */
- function getZineCategoryId($oldId)
- {
- $db = &JFactory::getDBO();
- $db->setQuery('SELECT a.id'
- . ' FROM #__jxzine_categories AS a'
- . ' JOIN #__categories AS b ON b.alias = a.alias'
- . ' WHERE a.parent_id = 1'
- . ' AND a.section = -1'
- . ' AND b.id = '.(int)$oldId);
- return (int)$db->loadResult();
- }
- /**
- * Function to find the id of an author based on the created_by_alias
- * during the Core to Magazine migration process. If the author does not
- * exist yet, it will be created.
- *
- * @param string $oldAlias The created_by_alias of the article from #__content.
- * @return int The numeric id of the author in #__jxzine_authors or 0.
- */
- function getZineAuthorIdByAlias($oldAlias)
- {
- if (empty($oldAlias)) {
- return 0;
- }
- // Try to load the author id from the database.
- $db = &JFactory::getDBO();
- $db->setQuery('SELECT a.id'
- . ' FROM #__jxzine_authors AS a'
- . ' WHERE fullname = '.$db->Quote($oldAlias));
- $id = (int)$db->loadResult();
- if ($id > 0) {
- // Return the author id.
- return $id;
- }
- else {
- // Add the author to the database.
- $db->setQuery('INSERT INTO #__jxzine_authors'
- . ' SET fullname = '.$db->Quote($oldAlias));
- // Return the author id.
- if ($db->query()) {
- $id = (int)$db->insertid();
- return $id;
- }
- }
- return 0;
- }