| Server IP : 54.36.91.62 / Your IP : 216.73.217.111 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/nice/administrator/components/com_community/ |
Upload File : |
<?php
/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
defined('_JEXEC') or die('Restricted access');
abstract class CommunityDefaultItem
{
/**
* Check if default category exist
* @param [string] $name [table name]
* @return [boolean] [description]
*/
static public function checkDefaultCategories($name)
{
$db = Factory::getDBO();
$extraquery = '';
$tableName = '#__community_'.$name.'_category';
switch ($name) {
case 'userpoints':
$tableName = '#__community_userpoints';
$extraquery = ' WHERE ' . $db->quoteName('system') .' = 1';
break;
case 'fields':
$tableName = '#__community_fields';
break;
}
$query = 'SELECT COUNT(*) FROM ' . $db->quoteName( $tableName ) . $extraquery;
$db->setQuery( $query );
$result = ( $db->loadResult() > 0 ) ? false : true;
return $result;
}
/**
* Add default Event Categories
*/
static public function addDefaultEventsCategories()
{
$db = Factory::getDBO();
$query = 'INSERT INTO '.$db->quoteName("#__community_events_category").'(' . $db->quoteName('name') .', ' . $db->quoteName('description') .' ) VALUES ' .
'( ' . $db->Quote('General') .', ' . $db->Quote('General events') .'),'.
'( ' . $db->Quote('Birthday') .', ' . $db->Quote('Birthday events') .'),'.
'( ' . $db->Quote('Party') .', ' . $db->Quote('Party events') .')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add defautl Group Categories
*/
static public function addDefaultGroupCategories()
{
$db = Factory::getDBO();
$query = 'INSERT INTO ' . $db->quoteName('#__community_groups_category') . ' (' . $db->quoteName('id') .', ' . $db->quoteName('name') .', ' . $db->quoteName('description') .') VALUES ' .
'(' . $db->Quote('1') .', ' . $db->Quote('General') .', ' . $db->Quote('General group category.') .'),'.
'(' . $db->Quote('2') .', ' . $db->Quote('Internet') .', ' . $db->Quote('Internet group category.') . '),'.
'(' . $db->Quote('3') .', ' . $db->Quote('Business') .', ' . $db->Quote('Business group category') .'),'.
'(' . $db->Quote('4') .', ' . $db->Quote('Automotive') .', ' . $db->Quote('Automotive group category') .'),'.
'(' . $db->Quote('5') .', ' . $db->Quote('Music') .', ' . $db->Quote('Music group category') .')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add default videos categories
*/
static public function addDefaultVideosCategories()
{
$db = Factory::getDBO();
$query = 'INSERT INTO '.$db->quoteName('#__community_videos_category') .'(' . $db->quoteName('id') .', ' . $db->quoteName('name') .', ' . $db->quoteName('description') .', ' . $db->quoteName('published') .' )'.
' VALUES ( NULL , ' . $db->Quote('General') .', ' . $db->Quote('General video channel') .', ' . $db->Quote('1') .')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add default polls categories
*/
static public function addDefaultPollsCategories()
{
$db = Factory::getDBO();
$query = 'INSERT INTO '.$db->quoteName('#__community_polls_category') .'(' . $db->quoteName('id') .', ' . $db->quoteName('name') .', ' . $db->quoteName('description') .' )'.
' VALUES ( NULL , ' . $db->Quote('General') .', ' . $db->Quote('General poll') .')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add default Page Categories
*/
static public function addDefaultPagesCategories()
{
$db = Factory::getDBO();
$query = 'INSERT INTO ' . $db->quoteName('#__community_pages_category') . ' (' . $db->quoteName('id') .', ' . $db->quoteName('name') .', ' . $db->quoteName('description') .') VALUES ' .
'(' . $db->Quote('1') .', ' . $db->Quote('General') .', ' . $db->Quote('General page category.') .'),'.
'(' . $db->Quote('2') .', ' . $db->Quote('Internet') .', ' . $db->Quote('Internet page category.') . '),'.
'(' . $db->Quote('3') .', ' . $db->Quote('Business') .', ' . $db->Quote('Business page category') .'),'.
'(' . $db->Quote('4') .', ' . $db->Quote('Automotive') .', ' . $db->Quote('Automotive page category') .'),'.
'(' . $db->Quote('5') .', ' . $db->Quote('Music') .', ' . $db->Quote('Music page category') .')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add default Userpoints
*/
static public function addDefaultUserPoints()
{
$db = Factory::getDBO();
$query = "INSERT INTO `#__community_userpoints` (`id`, `rule_name`, `rule_description`, `rule_plugin`, `action_string`, `component`, `access`, `points`, `published`, `system`) VALUES
(1, 'Profile Application Added', 'Assign number of points and determine whether an activity stream item will be created when user adds a profile application.', 'com_community', 'application.add', '', 1, 0, 1, 1),
(2, 'Profile Application Removed', 'Assign number of points and determine whether an activity stream item will be created when user removes a profile application.', 'com_community', 'application.remove', '', 1, 0, 0, 1),
(3, 'Photo Upload', 'Assign number of points for the photo upload action and determine if an activity stream item will be created.', 'com_community', 'photo.upload', '', 1, 0, 1, 1),
(4, 'New Group Created', 'Assign number of points when a user creates a new group and determines if an activity stream item will be created.', 'com_community', 'group.create', '', 1, 3, 1, 1),
(5, 'New Group Discussion', 'Assign number of points when a user opens a new discussion in group and determine if an activity stream item for this action will be created.', 'com_community', 'group.discussion.create', '', 1, 2, 1, 1),
(6, 'User Leave The Group', 'Deduct points when a registered user leaves a group. * There is no activity stream item for this action.', 'com_community', 'group.leave', '', 1, -1, 1, 1),
(7, 'Friend Request Is Approved', 'Assign number of points when user approves a friend request and determine if an activity stream item for this action will be created.', 'com_community', 'friends.request.approve', '', 1, 1, 1, 1),
(8, 'New Photo Album Created', 'Assign number of points when a user creates new album and determine if an activity stream item for this action will be created.', 'com_community', 'album.create', '', 1, 1, 1, 1),
(9, 'Post Group Comment', 'Assign a number of points when a user posst from a group''s share box and determine if to create an activity stream item for this action.', 'com_community', 'group.wall.create', '', 1, 1, 1, 1),
(10, 'Join Group', 'Assign a number of points when user joins the group and determine if to create an activity stream item for this action.', 'com_community', 'group.join', '', 1, 1, 1, 1),
(11, 'Reply Group''s Discussion', 'Assign a number of points when a registered user replies on a group''s discussion and determine if to create an activity stream item for this action.', 'com_community', 'group.discussion.reply', '', 1, 1, 1, 1),
(12, 'Comment Profile From Share Box', 'Assign a number of points when a user posts from a Share Box on other people''s profiles and determine if to create an activity stream item for this action.', 'com_community', 'profile.wall.create', '', 1, 1, 1, 1),
(13, 'Post Status From Share Box', 'Assign a number of points when a user posts a status from a Share Box and determine if to create an activity stream item for this action.', 'com_community', 'profile.status.update', '', 1, 1, 1, 1),
(14, 'Profile Updated', 'Assign a number of points when a profile is updated. There is no activity stream item for this action.', 'com_community', 'profile.save', '', 1, 1, 1, 1),
(15, 'Group Updated', 'Assign a number of points when a user updates the group information and determine if to create an activity stream item for this action.', 'com_community', 'group.updated', '', 1, 1, 1, 1),
(16, 'Change Group Avatar', 'Assign a number of points when a group admin or owner changes its avatar.', 'com_community', 'group.avatar.upload', '', 1, 0, 1, 1),
(17, 'Create Group''s Announcement', 'Assign a number of points when a user publishes a new announcement in a group and determine if to create an activity stream item for this action.', 'com_community', 'group.news.create', '', 1, 1, 1, 1),
(18, 'Comment Photo', 'Assign number of points when a new photo comment is added and determine if to create an activity stream item for this action', 'com_community', 'photos.wall.create', '', 1, 1, 1, 1),
(19, 'Remove Friend', 'Deduct points when a registered user removes a friend. There is no activity stream item for this action', 'com_community', 'friends.remove', '', 1, 0, 1, 1),
(20, 'Change Profile Picture', 'Assign a number of points when a user changes a profile picture and determine if to create an activity stream item for this action', 'com_community', 'profile.avatar.upload', '', 1, 1, 0, 1),
(21, 'Update Profile Privacy', 'Assign a number of points when user update profile privacy. There is no activity stream item for this action.', 'com_community', 'profile.privacy.update', '', 1, 0, 1, 1),
(22, 'Reply Private Message', 'Give points when a user replies to a private message. Activity stream items for this action do not exist.', 'com_community', 'inbox.message.reply', '', 1, 0, 1, 1),
(23, 'New Private Message', 'Give points when a user sends a new private message.', 'com_community', 'inbox.message.send', '', 1, 0, 1, 1),
(24, 'Remove Group Member', 'Assign a number of points when a group owner or admin user removes a group memeber.', 'com_community', 'group.member.remove', '', 1, 0, 1, 1),
(25, 'Delete Announcement', 'Deduct points when a user removes an announcement in group.', 'com_community', 'group.news.remove', '', 1, 0, 1, 1),
(26, 'Remove Wall Comment', 'Deduct points to the original poster when a wall comment is removed.', 'com_community', 'wall.remove', '', 1, 0, 1, 1),
(27, 'Delete Photo Album', 'Deduct points when a user deletes a photo album.', 'com_community', 'album.remove', '', 1, 0, 1, 1),
(28, 'Delete Photo', 'Deduct points when a user deletes a photo.', 'com_community', 'photo.remove', '', 1, 0, 1, 1),
(29, 'Event Updated', 'Assign a number of points when a user updates event information.', 'com_community', 'events.update', '', 1, 1, 1, 1),
(30, 'Post Event Wall', 'Give points when registered user post wall on event.', 'com_community', 'event.wall.create', '', 1, 1, 1, 1),
(31, 'Remove video', 'Deduct points when user remove a video.', 'com_community', 'video.remove', '', 1, -1, 1, 1),
(32, 'Add video', 'Add points when user adds a video.', 'com_community', 'video.add', '', 1, 1, 1, 1),
(33, 'Add Event', 'Add points when user created new event.', 'com_community', 'events.create', '', 1, 1, 1, 1),
(34, 'Like photo', 'Add points when usegr like a photo', 'com_community', 'photo.like', '', 1, 1, 1, 1),
(35, 'Like album', 'Add points when user like an album', 'com_community', 'album.like', '', 1, 1, 1, 1),
(36, 'Like videos', 'Add points when user like a video', 'com_community', 'videos.like', '', 1, 1, 1, 1),
(37, 'Like profile', 'Add points when user like a profile', 'com_community', 'profile.like', '', 1, 1, 1, 1),
(38, 'Like profile status', 'Add points when user like a profile status', 'com_community', 'profile.stream.like', '', 1, 1, 1, 1),
(39, 'Change profile cover', 'Add points when user change the profile cover photo', 'com_community', 'profile.cover.upload', '', 1, 1, 1, 1),
(40, 'Change group cover', 'Add points when user change the group cover photo', 'com_community', 'group.cover.upload', '', 1, 1, 1, 1),
(41, 'Change event cover', 'Add points when user change the event cover photo', 'com_community', 'event.cover.upload', '', 1, 1, 1, 1),
(42, 'Comment album', 'Add points of points when new album comment is added', 'com_community', 'albums.comment', '', 1, 1, 1, 1),
(43, 'Comment video', 'Add points of points when new video comment is added', 'com_community', 'videos.comment', '', 1, 1, 1, 1),
(44, 'Like group', 'Add points when user like a group', 'com_community', 'groups.like', '', 1, 1, 1, 1),
(45, 'Like event', 'Add points when user like a event', 'com_community', 'events.like', '', 1, 1, 1, 1),
(46, 'Unlike photo', 'Deduct points when user unlike a photo', 'com_community', 'photo.unlike', '', 1, -1, 1, 1),
(47, 'Unlike album', 'Deduct points when user unlike an album', 'com_community', 'album.unlike', '', 1, -1, 1, 1),
(48, 'Unlike video', 'Deduct points when user unlike a video', 'com_community', 'videos.unlike', '', 1, -1, 1, 1),
(49, 'Unlike group', 'Deduct points when user unlike a group', 'com_community', 'groups.unlike', '', 1, -1, 1, 1),
(50, 'Unlike event', 'Deduct points when user unlike a event', 'com_community', 'events.unlike', '', 1, -1, 1, 1),
(51, 'Unlike profile', 'Deduct points when user unlike a profile', 'com_community', 'profile.unlike', '', 1, -1, 1, 1),
(52, 'Unlike profile status', 'Deduct points when user unlike a profile status', 'com_community', 'profile.stream.unlike', '', 1, -1, 1, 1),
(53, 'Attend event', 'Add points when user attended to event', 'com_community', 'events.attend', '', 1, 1, 1, 1),
(54, 'Wont Attend event', 'Deduct points when user attended to event', 'com_community', 'events.wontattend', '', 1, -1, 1, 1),
(55, 'Profile featured', 'Add points when site admin featured profile', 'com_community', 'users.featured', '', 1, 1, 1, 1),
(56, 'Album featured', 'Add points when site admin featured album', 'com_community', 'albums.featured', '', 1, 1, 1, 1),
(57, 'Video featured', 'Add points when site admin featured video', 'com_community', 'videos.featured', '', 1, 1, 1, 1),
(58, 'Group featured', 'Add points when site admin featured group', 'com_community', 'groups.featured', '', 1, 1, 1, 1),
(59, 'Event featured', 'Add points when site admin featured event', 'com_community', 'events.featured', '', 1, 1, 1, 1),
(60, '
Following', 'Add points when user following someone', 'com_community', 'followers.add', '', 1, 1, 1, 1),
(61, '
Unfollow', 'Deduct points when user unfollow someone', 'com_community', 'followers.remove', '', 1, 1, -1, 1),
(62, 'New Page Created', 'Assign number of points when a user creates a new page and determines if an activity stream item will be created.', 'com_community', 'page.create', '', 1, 3, 1, 1),
(63, 'Like page', 'Add points when user like a page', 'com_community', 'pages.like', '', 1, 1, 1, 1),
(64, 'Unlike page', 'Deduct points when user unlike a page', 'com_community', 'pages.unlike', '', 1, -1, 1, 1),
(65, 'Change Page Avatar', 'Assign a number of points when a page admin or owner changes its avatar.', 'com_community', 'page.avatar.upload', '', 1, 0, 1, 1)";
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Check if JomSocial Menu type exits
* @return [boolean] [return true/false]
*/
static public function menuTypesExist()
{
$db = JFactory::getDBO();
$query = 'SELECT COUNT(*) FROM ' . $db->quoteName( '#__menu_types' ) . ' '
. 'WHERE ' . $db->quoteName( 'menutype' ) . ' = ' . $db->Quote( 'jomsocial');
$db->setQuery( $query );
$needUpdate = ( $db->loadResult() >= 1 ) ? true : false;
return $needUpdate;
}
/**
* Add Default Menu types
*/
static public function addDefaultMenuTypes()
{
$db = Factory::getDBO();
$query = 'INSERT INTO ' . $db->quoteName( '#__menu_types' ) . ' (' . $db->quoteName('menutype') .',' . $db->quoteName('title') .',' . $db->quoteName('description') .') VALUES '
. '( ' . $db->Quote( 'jomsocial' ) . ',' . $db->Quote( 'JomSocial toolbar' ) . ',' . $db->Quote( 'Toolbar items for JomSocial toolbar') . ')';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Check if menu exist
* @return [boolean] [return true/false]
*/
static public function menuExist()
{
$db = Factory::getDBO();
$query = 'SELECT COUNT(*) FROM ' . $db->quoteName( '#__menu' ) . ' '
. 'WHERE ' . $db->quoteName( 'link' ) . ' LIKE ' . $db->Quote( '%option=com_community%')
. ' AND '. $db->quoteName('title').' <> '. $db->Quote('COM_COMMUNITY');
//. 'AND ' . $db->quoteName('menutype ') . ' = ' . $db->Quote('jomSocial');
$db->setQuery( $query );
$needUpdate = ( $db->loadResult() >= 1 ) ? true : false;
return $needUpdate;
}
/**
* Update Menu Item
* @return [boolean] [return true/false]
*/
static public function updateMenuItems()
{
// Get new component id.
$component = ComponentHelper::getComponent('com_community');
$component_id = 0;
if (is_object($component) && isset($component->id)){
$component_id = $component->id;
}
if ($component_id > 0)
{
// Update the existing menu items.
$db = Factory::getDBO();
$query = 'UPDATE ' . $db->quoteName( '#__menu' ) . ' '
. 'SET '.$db->quoteName(JOOMLA_MENU_COMPONENT_ID).'=' . $db->Quote( $component_id ) . ' '
. 'WHERE ' . $db->quoteName('link') .' LIKE ' . $db->Quote('%option=com_community%');
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
$query = 'UPDATE ' . $db->quoteName( '#__menu' ) . ' '
. 'SET '.$db->quoteName('level').'=' . $db->Quote( 1 ) . ' '
. 'WHERE ' . $db->quoteName('link') .' LIKE ' . $db->Quote('%option=com_community%')
. 'AND '.$db->quoteName( 'level' ).'= 0';
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
}
return true;
}
/**
* Add Menu items
*/
static public function addMenuItems()
{
$db = Factory::getDBO();
// Get new component id.
$component = ComponentHelper::getComponent('com_community');
$component_id = 0;
if (is_object($component) && isset($component->id))
{
$component_id = $component->id;
}
$column_name = JOOMLA_MENU_NAME;
$column_cid = JOOMLA_MENU_COMPONENT_ID;
// Get the default menu type
// 2 Joomla bugs occur in /Administrator mode
// Bug 1: JFactory::getApplication('site') failed. It always return id = 'administrator'.
// Bug 2: JMenu::getDefault('*') failed. JAdministrator::getLanguageFilter() doesn't exist.
// If these 2 bugs are fixed, we can call the following syntax:
// $defaultMenuType = JFactory::getApplication('sites')->getMenu()->getDefault()->menutype;
jimport('joomla.application.application');
$defaultMenuType = CMSApplication::getInstance('site')->getMenu()->getDefault('workaround_joomla_bug')->menutype;
// Update the existing menu items.
$row = Table::getInstance ( 'menu', 'JTable' );
$row->menutype = $defaultMenuType;
$row->$column_name = 'JomSocial';
$row->alias = 'JomSocial';
$row->access = 1;
$row->link = 'index.php?option=com_community&view=frontpage';
$row->type = 'component';
$row->published = '1';
$row->$column_cid = $component_id;
$row->id = null; //new item
$row->language = '*';
$row->check();
$row->store();
// if ( !$row->store() )
// {
// return false;
// }
$query = 'UPDATE '. $db->quoteName( '#__menu' )
. ' SET `parent_id` = ' .$db->quote(1)
. ', `level` = ' . $db->quote(1)
. ' WHERE `id` = ' . $db->quote($row->id) ;
$db->setQuery( $query );
$db->execute();
// if ($db->getErrorNum())
// {
// return false;
// }
if ( ! self::addDefaultToolbarMenus())
{
return false;
}
// update memu items with component id
if ( ! self::updateMenuItems())
{
return false;
}
return true;
}
/**
* Add default customs Fields
*/
static public function addDefaultCustomFields()
{
$db = Factory::getDBO();
$query = 'INSERT INTO ' . $db->quoteName('#__community_fields') . ' (' . $db->quoteName('id') . ', ' . $db->quoteName('type') . ', ' . $db->quoteName('ordering') . ', ' . $db->quoteName('published') . ', ' . $db->quoteName('min') . ', ' . $db->quoteName('max') . ', ' . $db->quoteName('name') . ', ' . $db->quoteName('tips') . ', ' . $db->quoteName('visible') . ', ' . $db->quoteName('required') . ', ' . $db->quoteName('searchable') . ', ' . $db->quoteName('options') . ', ' . $db->quoteName('fieldcode') . ', ' . $db->quoteName('params') . ') VALUES '.
'(' . $db->Quote('1') . ', ' . $db->Quote('group') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('10') . ', ' . $db->Quote('100') . ', ' . $db->Quote('Basic Information') . ', ' . $db->Quote('Basic information for user') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('2') . ', ' . $db->Quote('gender') . ', ' . $db->Quote('2') . ', ' . $db->Quote('1') .', ' . $db->Quote('10') . ', ' . $db->Quote('100') . ', ' . $db->Quote('Gender') . ', ' . $db->Quote('Select gender') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('COM_COMMUNITY_MALE'."\n".'COM_COMMUNITY_FEMALE'."\n".'COM_COMMUNITY_NOT_SPECIFIED') . ', ' . $db->Quote('FIELD_GENDER') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('3') . ', ' . $db->Quote('birthdate') .', ' . $db->Quote('3') .', ' . $db->Quote('1') .', ' . $db->Quote('10') .', ' . $db->Quote('100') .', ' . $db->Quote('Birthdate') .', ' . $db->Quote('Enter your date of birth so other users will know when to wish you a happy birthday ') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('') .', ' . $db->Quote('FIELD_BIRTHDATE') . ', ' . $db->Quote('') .'),' .
'(' . $db->Quote('4') . ', ' . $db->Quote('textarea') . ', ' . $db->Quote('4') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('800') . ', ' . $db->Quote('About me') . ', ' . $db->Quote('Tell us more about yourself') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('FIELD_ABOUTME') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('5') . ', ' . $db->Quote('location') . ', ' . $db->Quote('5') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('100000') . ', ' . $db->Quote('Location') .', ' . $db->Quote('Your Location') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('FIELD_LOCATION') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('6') . ', ' . $db->Quote('group') . ', ' . $db->Quote('6') . ', ' . $db->Quote('1') . ', ' . $db->Quote('10') . ', ' . $db->Quote('100') . ', ' . $db->Quote('Contact Information') . ', ' . $db->Quote('Specify your contact details') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('7') . ', ' . $db->Quote('text') . ', ' . $db->Quote('7') . ', ' . $db->Quote('1') . ', ' . $db->Quote('10') . ', ' . $db->Quote('100') . ', ' . $db->Quote('Mobile phone') .', ' . $db->Quote('Mobile carrier number so other users can contact you.') . ', ' . $db->Quote('1') . ', ' . $db->Quote('0') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('FIELD_MOBILE') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('8') . ', ' . $db->Quote('text') . ', ' . $db->Quote('8') . ', ' . $db->Quote('1') . ', ' . $db->Quote('10') . ', ' . $db->Quote('100') . ', ' . $db->Quote('Land phone') . ', ' . $db->Quote('Contact number so other users can contact you.') . ', ' . $db->Quote('1') . ', ' . $db->Quote('0') . ', ' . $db->Quote('1') . ', ' . $db->Quote('') . ', ' . $db->Quote('FIELD_LANDPHONE') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('9') . ', ' . $db->Quote('url') . ', ' . $db->Quote('9') .', ' . $db->Quote('1') .', ' . $db->Quote('10') .', ' . $db->Quote('100') .', ' . $db->Quote('Website') .', ' . $db->Quote('Your website') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('') .', ' . $db->Quote('FIELD_WEBSITE') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('10') . ', ' . $db->Quote('group') . ', ' . $db->Quote('10') .', ' . $db->Quote('1') . ', ' . $db->Quote('10') .', ' . $db->Quote('100') .', ' . $db->Quote('Education') .', ' . $db->Quote('Educations') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('') . ', ' . $db->Quote('') . ', ' . $db->Quote('') .'),' .
'(' . $db->Quote('11') . ', ' . $db->Quote('text') .', ' . $db->Quote('11') .', ' . $db->Quote('1') .', ' . $db->Quote('10') .', ' . $db->Quote('200') .', ' . $db->Quote('College / University') .', ' . $db->Quote('Your college or university name') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('') .', ' . $db->Quote('FIELD_COLLEGE') . ', ' . $db->Quote('') . '),' .
'(' . $db->Quote('12') . ', ' . $db->Quote('text') . ', ' . $db->Quote('12') .', ' . $db->Quote('1') .', ' . $db->Quote('5') .', ' . $db->Quote('100') .', ' . $db->Quote('Graduation Year') .', ' . $db->Quote('Graduation year') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('1') .', ' . $db->Quote('') .', ' . $db->Quote('FIELD_GRADUATION') . ', ' . $db->Quote('') .')';
$db->setQuery( $query );
$db->execute();
$hide_ids = array(5,7,8,9,10,11,12);
$query= "UPDATE "
. $db->quoteName('#__community_fields')
. " SET " . $db->quoteName('required') . "=" . $db->quote(0)
// . ", " . $db->quoteName('visible') . "=" . $db->quote(0)
// . ", " . $db->quoteName('required') . "=" . $db->quote(0)
. " WHERE " . $db->quoteName('id') ." IN (" . implode(',',$hide_ids) .")";
$db->setQuery( $query );
try {
$db->execute();
} catch (Exception $e) {
return false;
}
return true;
}
/**
* Add default toolbar menu
*/
static public function addDefaultToolbarMenus()
{
$db = Factory::getDBO();
$file = JPATH_ROOT . '/administrator/components/com_community/toolbar.xml';
$menu_name = JOOMLA_MENU_NAME;
$menu_parent = JOOMLA_MENU_PARENT;
$menu_level = JOOMLA_MENU_LEVEL;
$items = new SimpleXMLElement( $file , NULL , true );
$items = $items->items;
$component = ComponentHelper::getComponent('com_community');
$i = 1;
foreach( $items->children() as $item )
{
$obj = new stdClass();
$obj->$menu_name = (string) $item->name;
$obj->alias = (string) $item->alias;
$obj->link = (string) $item->link;
$obj->access = (string) $item->access;
$obj->menutype = 'jomsocial';
$obj->type = 'component';
$obj->component_id = $component->id;
$obj->published = 1;
$obj->$menu_parent = JOOMLA_MENU_ROOT_PARENT;
$obj->language = '*';
$childs = $item->childs;
//J1.6: menu item ordering follow lft and rgt
$query = 'SELECT ' . $db->quoteName( 'rgt' ) . ' '
. 'FROM ' . $db->quoteName( '#__menu' ) . ' '
. 'ORDER BY ' . $db->quoteName( 'rgt' ) . ' DESC LIMIT 1';
$db->setQuery( $query );
$obj->lft = $db->loadResult() + 1;
$totalchild = $childs?count($childs->children()):0;
$obj->rgt = $obj->lft + $totalchild * 2 + 1;
try {
$db->insertObject('#__menu', $obj);
} catch (Exception $e) {
return false;
}
$parentId = $db->insertid();
if( $childs )
{
$x = 1;
foreach( $childs->children() as $child )
{
$childObj = new stdClass();
$childObj->$menu_name = (string) $child->name;
$childObj->alias = (string) $child->alias;
$childObj->link = (string) $child->link;
$childObj->access = (string) $item->access;
$childObj->menutype = 'jomsocial';
$childObj->type = 'component';
$childObj->component_id = $component->id;
$childObj->published = 1;
$childObj->$menu_parent = $parentId;
$childObj->$menu_level = JOOMLA_MENU_LEVEL_PARENT + 1;
$childObj->language = '*';
//J1.6: menu item ordering follow lft and rgt
$childObj->lft = $obj->lft + ($x - 1)* 2 + 1;
$childObj->rgt = $childObj->lft + 1;
try {
$db->insertObject('#__menu', $childObj);
} catch (Exception $e) {
return false;
}
$x++;
}
}
$i++;
}
return true;
}
}