Example #1
0
 function onGroupCreate($group)
 {
     if (!self::kunenaOnline()) {
         return;
     }
     if (JRequest::getInt('kunenaforum', 0) < 0) {
         return;
     }
     $catid = self::getForumCategory($group->categoryid);
     if ($catid === false) {
         return;
     }
     $category = new KunenaForumCategory();
     $category->set('parent_id', $catid);
     $category->set('name', $group->name);
     $category->set('description', $group->description);
     $category->set('headerdesc', $group->description);
     $category->set('accesstype', 'jomsocial');
     $category->set('access', $group->id);
     $category->set('published', $group->published);
     $success = $category->save();
     if (!$success) {
         JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_COMMUNITY_KUNENAGROUPS_GROUP_CREATE_FAILED', 'notice'));
         return;
     }
     $category->setModerator($group->ownerid, 1);
 }
Example #2
0
	/**
	 * @param bool $updateNulls
	 * @return bool
	 */
	public function store( $updateNulls = false )
	{
		if ( ! $this->_category ) {
			return false;
		}

		$store	=	$this->_category->save();

		$this->category( $this->_category );

		return $store;
	}
	/**
	 * Test category creation
	 *
	 * @param KunenaForumCategory $category
	 * @return KunenaForumCategory
	 * @depends testNew
	 */
	public function testCreate(KunenaForumCategory $category) {
		$category->name = 'Test Section';
		$category->parent_id = 0;
		$this->assertTrue($category->save(), 'Check that category save succeeds');
		$this->assertTrue($category->exists(), 'Check that saved category exists');
		$this->assertGreaterThan(0, $category->id, 'Check that saved category has id');
		$this->assertSame($category, KunenaForumCategory::getInstance($category->id), 'Check that saved category instance points to correct object');
		$category2 = clone $category;
		$this->assertTrue($category->load(), 'Check that saved category exists in database');
		$this->assertEquals($category, $category2, 'Check that database is identical to the object');
		self::$category = $category;
		return $category;
	}
Example #4
0
	/**
	 * Create section and 3 categories
	 */
	public function testCreateCategories() {
		$section = new KunenaForumCategory();
		$section->name = 'Section';
		$section->published = 1;
		$this->assertTrue($section->save(), $section->getError());
		$this->checkCategory($section);
		for ($i=1; $i<=3; $i++) {
			$category = new KunenaForumCategory();
			$category->name = "Category $i";
			$category->parent_id = $section->id;
			$category->published = 1;
			$this->assertTrue($category->save(), $category->getError());
			self::$category[$i] = $category;
			$this->checkCategory($category);
		}
	}
Example #5
0
 static function add_forum_k2($course_id, $forum_id, $forum_name)
 {
     if (!JoomdleHelperForum::forum_exists($course_id, $forum_id)) {
         $data = new KunenaForumCategory();
         if ($forum_id != -2) {
             // id=-2 indicates main course forum category
             $data->parent_id = JoomdleHelperForum::get_parent_id($course_id);
         } else {
             $data->parent_id = JoomdleHelperForum::get_main_category();
         }
         $data->name = $forum_name;
         $data->alias = '';
         $data->published = 1;
         $group_id = JoomdleHelperJoomlagroups::get_course_group_id($course_id, 'students');
         $data->pub_access = $group_id;
         $group_id = JoomdleHelperJoomlagroups::get_course_group_id($course_id, 'teachers');
         $data->admin_access = $group_id;
         $data->accesstype = 'joomla.group';
         $data->save();
         $db = JFactory::getDBO();
         $kunena_forum_id = $data->id;
         // Add to joomdle xref table
         $jf_row = new JoomdleTableForums($db);
         $forum_data['course_id'] = $course_id;
         $forum_data['moodle_forum_id'] = $forum_id;
         $forum_data['kunena_forum_id'] = $kunena_forum_id;
         $jf_row->save($forum_data);
     }
     // Get all course teachers and set them as moderators
     $teachers = JoomdleHelperContent::getCourseTeachers($course_id);
     foreach ($teachers as $teacher) {
         JoomdleHelperForum::add_moderator($course_id, $forum_id, $teacher['username']);
     }
 }
Example #6
0
 /**
  * a $item -ben adott temakor rekordhoz kapcsolodó kunena fórum kategória
  * létrehozása vagy modositása
  * @param mysql record object  $item 
  * @return boolean     
  */
 protected function storeKunenaCategory($newId, $item)
 {
     $result = true;
     $db = JFactory::getDBO();
     // $temakor GroupId meghatározása láthatóságtól függ lehet nulla is.
     $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 = 1;
     }
     if ($item->lathatosag == 0) {
         $gr = 1;
         $params = '{"access_post":["6","2","8"],"access_reply":["6","2","8"]}';
     }
     if ($item->lathatosag == 1) {
         $gr = 2;
         $params = '{"access_post":["6","2","8"],"access_reply":["6","2","8"]}';
     }
     if ($item->lathatosag == 2) {
         $params = '{"access_post":["6","' . $gr . '",8"],"access_reply":["6","' . $gr . '",8"]}';
     }
     // szülő elérése
     $db->setQuery('SELECT id FROM #__kunena_categories WHERE alias="T' . $item->szulo . '"');
     $res = $db->loadObject();
     if ($res) {
         $parentId = $res->id;
     } else {
         $parentId = 85;
     }
     //li-de témakörök
     // meglévő rekord elérése
     $db->setQuery('SELECT id FROM #__kunena_categories WHERE alias="T' . $item->id . '"');
     $res = $db->loadObject();
     if ($db->getErrorNum() > 0) {
         $db->stderr();
     }
     // forum kategoria rekord összeállítása
     $data = array();
     if ($res) {
         $data['id'] = $res->id;
     } else {
         $data['id'] = 0;
     }
     $data['parent_id'] = $parentId;
     $data['name'] = strip_tags($item->megnevezes);
     $data['description'] = strip_tags($item->leiras);
     $data['pub_acces'] = $gr;
     $data['access_type'] = 'joomla.group';
     $data['access'] = 1;
     $data['alias'] = 'T' . $newId;
     $data['params'] = $params;
     $data['admin_access'] = 0;
     $data['admin_recurse'] = 1;
     $data['pub_recurse'] = 1;
     $data['published'] = 1;
     // 2015.05.08 tapasztalat: a kunena fórum nem kultiválja ahtml entity-ket
     $data['description'] = html_entity_decode($data['description'], ENT_COMPAT, 'UTF-8');
     $data['name'] = html_entity_decode($data['name'], ENT_COMPAT, 'UTF-8');
     // fórum kategoria rekord tárolása
     $category = new KunenaForumCategory($data);
     if ($data['id'] > 0) {
         $db->setQuery('UPDATE #__kunena_categories
    SET name="' . mysql_escape_string($data['name']) . '",
    description="' . mysql_escape_string($data['description']) . '",
    pub_access="' . $gr . '",
    params = "' . mysql_escape_string($params) . '"
    WHERE id="' . $data['id'] . '"');
         $db->query();
         // DEBUG
         // echo $item->leiras.'<hr>'.$db->getQuery(); exit();
     } else {
         $category->save();
     }
     return $result;
 }
Example #7
0
 /**
  * a $item -ben adott temakor rekordhoz kapcsolodó kunena fórum kategória
  * létrehozása vagy modositása
  * @param mysql record object  $item 
  * @return boolean     
  */
 protected function storeKunenaCategory($newId, $item)
 {
     $result = true;
     $db = JFactory::getDBO();
     $user = JFactory::getUser($item->user_id);
     $gr = 1;
     $params = '{"access_post":["6","2","8"],"access_reply":["6","2","8"]}';
     // szülő beállítása
     $parentId = 86;
     // meglévő rekord elérése
     $db->setQuery('SELECT id FROM #__kunena_categories WHERE alias="K' . $newId . '"');
     $res = $db->loadObject();
     if ($db->getErrorNum() > 0) {
         $db->stderr();
     }
     // forum kategoria rekord összeállítása
     $data = array();
     if ($res) {
         $data['id'] = $res->id;
     } else {
         $data['id'] = 0;
     }
     $data['parent_id'] = $parentId;
     $data['name'] = strip_tags($user->name);
     $data['description'] = '';
     $data['pub_acces'] = $gr;
     $data['access_type'] = 'joomla.group';
     $data['access'] = 1;
     $data['alias'] = 'K' . $newId;
     $data['params'] = $params;
     $data['admin_access'] = 0;
     $data['admin_recurse'] = 1;
     $data['pub_recurse'] = 1;
     $data['published'] = 1;
     // fórum kategoria rekord tárolása
     $category = new KunenaForumCategory($data);
     if ($data['id'] > 0) {
         $db->setQuery('UPDATE #__kunena_categories
    SET name="' . mysql_escape_string($data['name']) . '",
    description="' . mysql_escape_string($data['description']) . '",
    pub_access="' . $gr . '",
    params = "' . mysql_escape_string($params) . '"
    WHERE id="' . $data['id'] . '"');
         $db->query();
     } else {
         $category->save();
     }
     return $result;
 }