示例#1
0
 /**
  * method to install the component
  *
  * @return void
  */
 function install($parent)
 {
     // $parent is the class calling this method
     $parent->getParent()->setRedirectURL('index.php?option=com_courses');
     $path = JPATH_ADMINISTRATOR . '/components/com_categories';
     require_once $path . '/models/category.php';
     $config = array('table_path' => $path . '/tables');
     $model = new CategoriesModelCategory($config);
     $data = array('id' => 0, 'parent_id' => 0, 'level' => 1, 'path' => 'uncategorised', 'extension' => 'com_courses', 'title' => 'Uncategorised', 'alias' => 'uncategorised', 'note' => '', 'description' => '', 'published' => 1, 'language' => '*');
     $status = $model->save($data);
     if (!$status) {
         JError::raiseWarning(500, JText::_('Unable to create default course category.'));
     }
 }
示例#2
0
    /**
     * Jenents kategória létrehozása az $item -ben lévő témakörhöz
     * @param integer $newId
     * @param mysqlrecord $item
     * @return void
     */
    protected function storeJeventsCategory($newId, $item)
    {
        $db = JFactory::getDBO();
        $user = JFactory::getUser();
        // szülő Jevents kategoria elérése
        $db->setQuery('SELECT * FROM #__categories WHERE alias="t' . $item->szulo . '"');
        $szulo = $db->loadObject();
        if (!$szulo) {
            $szulo = new stdClass();
            $szulo->id = 0;
        }
        // megvan már a rekord?
        $db->setQuery('SELECT * FROM #__categories WHERE alias="t' . $newId . '"');
        $old = $db->loadObject();
        if ($old == false) {
            $category_data = array();
            $category_data['id'] = 0;
            $category_data['parent_id'] = $szulo->id;
            $category_data['title'] = $item->megnevezes;
            $category_data['description'] = $item->leiras;
            $category_data['alias'] = 't' . $newId;
            $category_data['extension'] = 'com_jevents';
            $category_data['published'] = 1;
            $category_data['language'] = '*';
            $category_data['access'] = 1;
            $category_data['params'] = array("category_layout" => "", "image" => "", "catcolour" => "", "overlaps" => "0", "admin" => $user->id);
            $config = array('table_path' => JPATH_ADMINISTRATOR . '/components/com_categories/tables');
            $new_category = new CategoriesModelCategory($config);
            $result = $new_category->save($category_data);
        } else {
            $db->setQuery('UPDATE #__categories
        SET title="' . mysql_escape_string($item->megnevezes) . '",
            description = "' . mysql_escape_string($item->leiras) . '"
        WHERE alias="t' . $newId . '"');
            $db->query();
            if ($db->getErrorNum() > 0) {
                $db->stderr();
            }
        }
        // JEvents category jogosultságok beállítása
        // $item->lathatosag: 0-mindenki, 1-regisztraltak, 2-téma tagok
        // usergoups 1:public, 2:Registered, 3:Author, 4:Editor, 6:Manager, 8:superuser, más: usergroup_id
        // kategoriához tartozó usergroup_id meghatározása
        $db->setQuery('SELECT id FROM #__usergroups WHERE title like "[' . $newId . ']%"');
        $res = $db->loadObject();
        if ($db->getErrorNum() > 0) {
            $db->stderr();
        }
        if ($res) {
            $gr = $res->id;
        } else {
            $gr = 0;
        }
        if ($item->lathatosag == 0) {
            // mindenki
            $rules = '';
        }
        if ($item->lathatosag == 1) {
            // regisztráltak
            $rules = '{"core.create":{"1":0,"2":1,"' . $gr . '":1},
"core.delete":{"1":0,"2":1,"' . $gr . '":1},
"core.edit":{"1":0,"2":1,"' . $gr . '":1},
"core.edit.state":{"1":0,"2":1,"' . $gr . '":1},
"core.edit.own":{"1":0,"2":1,"' . $gr . '":1},
"download":{"1":0,"2":1,"' . $gr . '":1}
}';
        }
        if ($item->lathatosag == 2) {
            // téma tagok
            if ($gr > 0) {
                $rules = '{"core.create":{"1":0,"2":0,"' . $gr . '":1},
"core.delete":{"1":0,"2":0,"' . $gr . '":1},
"core.edit":{"1":0,"2":0,"' . $gr . '":1},
"core.edit.state":{"1":0,"2":0,"' . $gr . '":1},
"core.edit.own":{"1":0,"2":0,"' . $gr . '":1},
"download":{"1":0,"2":0,"' . $gr . '":1}
}';
            } else {
                $rules = '{"core.create":{"1":0,"2":1,"' . $gr . '":1},
"core.delete":{"1":0,"2":1,"' . $gr . '":1},
"core.edit":{"1":0,"2":1,"' . $gr . '":1},
"core.edit.state":{"1":0,"2":1,"' . $gr . '":1},
"core.edit.own":{"1":0,"2":1,"' . $gr . '":1},
"download":{"1":0,"2":1}
}';
            }
        }
        $db->setQuery('UPDATE #__assets
     SET rules="' . mysql_escape_string($rules) . '"
     WHERE name="com_jevents.category.' . $newId . '"');
        $result = $db->query();
        if ($db->getErrorNum() > 0) {
            $db->stderr();
        }
    }
示例#3
0
 private function _getErrorPageCatId()
 {
     $this->_errorPageCatId = (int) ShlDbHelper::selectResult('#__categories', array('id'), array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1));
     // we have a category, all good
     if (!empty($this->_errorPageCatId)) {
         return $this->_errorPageCatId;
     }
     // no category for our content yet. Create it
     $basePath = JPATH_ADMINISTRATOR . '/components/com_categories';
     require_once $basePath . '/models/category.php';
     $config = array('table_path' => $basePath . '/tables');
     $catmodel = new CategoriesModelCategory($config);
     $catData = array('id' => 0, 'parent_id' => 1, 'level' => 1, 'path' => 'sh404sef-custom-content', 'extension' => 'com_content', 'title' => 'sh404SEF custom content', 'alias' => 'sh404sef-custom-content', 'description' => 'Do not delete please!', 'published' => 1, 'language' => '*');
     $status = $catmodel->save($catData);
     if (!$status) {
         throw new Sh404sefExceptionDefault('Unable to create sh404SEF content category!', 500);
     }
     // now get and store the id
     $this->_errorPageCatId = (int) ShlDbHelper::selectResult('#__categories', array('id'), array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1));
     if (empty($this->_errorPageCatId)) {
         throw new Sh404sefExceptionDefault('Unable to read sh404SEF content category! You might need to use the Rebuild button in Joomla! categories manager, as categories on your site may be broken. This often happens after migrating a Joomla! site to a newer version.', 500);
     }
     return $this->_errorPageCatId;
 }
 /**
  * Set Default DB
  *
  * @return void
  *
  * @since 1.7.0
  */
 private function setDefaultDB()
 {
     // Create categories for our component
     $basePath = JPATH_ADMINISTRATOR . '/components/com_categories';
     require_once $basePath . '/models/category.php';
     $config = ['table_path' => $basePath . '/tables'];
     $catmodel = new CategoriesModelCategory($config);
     $catData = ['id' => 0, 'parent_id' => 0, 'level' => 1, 'path' => 'default-team', 'extension' => 'com_churchdirectory', 'title' => 'Default Team', 'alias' => 'default-team', 'description' => '<p>Default Team where members are assigned if non are specified.</p>', 'published' => 1, 'language' => '*'];
     $status = $catmodel->save($catData);
     if (!$status) {
         JFactory::getApplication()->enqueueMessage(JText::_('Unable to create default ChurchDirectory category!'), 'error');
     }
 }
示例#5
0
	/**
	 * Create a single category and return its ID. If the category alias already
	 * exists, return the ID of that specific category alias.
	 * 
	 * @param type $level
	 * @param type $levelpath
	 * @param type $parent_id
	 * @return type 
	 */
	private function createCategory($level = 1, $levelpath = '1', $parent_id = 1)
	{
		$logger = $this->getState('logger');
		$title = 'Overload ';
		$alias = 'overload-';
		$title .= $levelpath;
		$alias .= str_replace('.', '-', $levelpath);
		
		$data = array(
			'parent_id'		=> $parent_id,
			'level'			=> $level,
			'extension'		=> 'com_content',
			'title'			=> $title,
			'alias'			=> $alias,
			'description'	=> '<p>Sample content generated by Overload</p>',
			'access'		=> 1,
			'params'		=> array('target' => '', 'image' => ''),
			'metadata'		=> array('page_title' => '', 'author' => '', 'robots' => '', 'tags' => ''),
			'hits'			=> 0,
			'language'		=> '*',
			'associations'	=> array(),
			'published'		=> 1
		);

		$basePath = JPATH_ADMINISTRATOR . '/components/com_categories';
		require_once $basePath . '/models/category.php';
		$config = array('table_path' => $basePath . '/tables');
		$model = new CategoriesModelCategory($config);
		$result = $model->save($data);
		
		if($result === false) {
			$db = $this->getDbo();
			$query = $db->getQuery(true);
			$query
				->select('id')
				->from( $db->qn('#__categories') )
				->where($db->qn('alias').' = '.$db->q($alias));
			$db->setQuery($query);
			$id = $db->loadResult();
			JLog::add("Existing category $levelpath, ID $id", JLog::DEBUG);
			
			// Enable an existing category
			$cat = $model->getItem($id);
			if(!$cat->published) {
				$cat->published = 1;
			}
			$cat = (array)$cat;
			$model->save($cat);
			
			return $id;
		} else {
			$id = $model->getState($model->getName().'.id');
			JLog::add("New category $levelpath, ID $id", JLog::DEBUG);
			return $id;
		}
	}
 private function _getErrorPageCatId()
 {
     $this->_errorPageCatId = (int) Sh404sefHelperDb::selectResult('#__categories', array('id'), array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1));
     // we have a category, all good
     if (!empty($this->_errorPageCatId)) {
         return $this->_errorPageCatId;
     }
     // no category for our content yet. Create it
     $basePath = JPATH_ADMINISTRATOR . '/components/com_categories';
     require_once $basePath . '/models/category.php';
     $config = array('table_path' => $basePath . '/tables');
     $catmodel = new CategoriesModelCategory($config);
     $catData = array('id' => 0, 'parent_id' => 0, 'level' => 1, 'path' => 'sh404sef-custom-content', 'extension' => 'com_content', 'title' => 'sh404SEF custom content', 'alias' => 'sh404sef-custom-content', 'description' => 'Do not delete please!', 'published' => 1, 'language' => '*');
     $status = $catmodel->save($catData);
     if (!$status) {
         throw new Sh404sefExceptionDefault('Unable to create sh404SEF content category!', 500);
     }
     // now get and store the id
     $this->_errorPageCatId = (int) Sh404sefHelperDb::selectResult('#__categories', array('id'), array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1));
     if (empty($this->_errorPageCatId)) {
         throw new Sh404sefExceptionDefault('Unable to read sh404SEF content category!', 500);
     }
     return $this->_errorPageCatId;
 }
示例#7
0
 private function migrateOldFeatures()
 {
     $db = JFactory::getDBO();
     /** UPDATE PAGE SORT ORDERS */
     $query = 'select count(*) from #__survey_pages where sort_order = 0';
     $db->setQuery($query);
     $count = intval($db->loadResult());
     if ($count > 0) {
         $query = 'update #__survey_pages set sort_order = sort_order + 1';
         $db->setQuery($query);
         $db->query();
     }
     // Create categories for our component
     $basePath = JPATH_ADMINISTRATOR . '/components/com_categories';
     require_once $basePath . '/models/category.php';
     jimport('joomla.application.categories');
     $categories = JCategories::getInstance('CommunitySurveys');
     $root = $categories->get(0);
     if ($root && count($root->getChildren()) == 0) {
         $config = array('table_path' => $basePath . '/tables');
         $catmodel = new CategoriesModelCategory($config);
         $catData = array('id' => 0, 'parent_id' => 0, 'level' => 1, 'path' => 'uncategorized', 'extension' => 'com_communitysurveys', 'title' => 'Uncategorized', 'alias' => 'uncategorized', 'description' => '<p>This category contains all uncategorized surveys</p>', 'published' => 1, 'language' => '*');
         $status = $catmodel->save($catData);
         if (!$status) {
             JError::raiseWarning(500, JText::_('Unable to create default content category!'));
         } else {
             $categories = JCategories::getInstance('CommunitySurveys', array('assetid' => 'csinstaller'));
             $nodes = $categories->get(0)->getChildren();
             if ($nodes[0]->id) {
                 $query = 'update #__survey set catid = ' . $nodes[0]->id;
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
 }