Hi again,
I wrote some code to automatically create category with the username of the user.
This create the category if the user go on the page "Add pictures" and if he hasn't yet main category.
I think this have to be improved, because I'm using SQL request in the view.html.php file.
Edit the file: YourSite/components/com_phocagallery/views/user/view.html.php
And add this code:
Code: Select all
if($ownerMainCategory == null){
$db =& JFactory::getDBO();
// User parameters
$query = 'SELECT count(*) FROM `#__phocagallery_user`';
$db->setQuery($query);
$ordering = $db->loadResult();
$newUser = null;
$newUser->userid = $user->id;
$newUser->published = 1;
$newUser->approved = 1;
$newUser->ordering = $ordering;
//Create User in DB
$fields = array(
'userid',
'published',
'approved',
'ordering');
$values = array(
(int)$newUser->userid,
(int)$newUser->published,
(int)$newUser->approved,
(int)$newUser->ordering);
$query = 'INSERT INTO `#__phocagallery_user` ('.implode(',',$fields).') VALUES ('.implode(',',$values).')';
$db->setQuery($query);
$db->query();
// Category parameters
$query = 'SELECT count(*) FROM `#__phocagallery_categories`';
$db->setQuery($query);
$ordering = $db->loadResult();
$new = null;
$new->owner_id = $user->id;
$new->title = $user->username;
$new->alias = str_replace(" ", "-", strToLower($user->username));
$new->image_position = 'left';
$new->date = date('Y-m-d H:i:s', time());
$new->published = 1;
$new->approved = 1;
$new->ordering = $ordering + 1;
$new->access = 1;
$new->userfolder = $new->alias;
$new->language = '*';
$new->accessuserid = '-1';
$new->uploaduserid = $user->id;
$new->deleteuserid = $user->id;
//Create Category in DB
$fields = array(
'owner_id',
'title',
'alias',
'image_position',
'date',
'published',
'approved',
'ordering',
'access',
'userfolder',
'language',
'accessuserid',
'uploaduserid',
'deleteuserid');
$values = array(
(int)$new->owner_id,
$db->quote($new->title),
$db->quote($new->alias),
$db->quote($new->image_position),
$db->quote($new->date),
(int)$new->published,
(int)$new->approved,
(int)$new->ordering,
(int)$new->access,
$db->quote($new->userfolder),
$db->quote($new->language),
$db->quote($new->accessuserid),
$db->quote($new->uploaduserid),
$db->quote($new->deleteuserid));
$query = 'INSERT INTO `#__phocagallery_categories` ('.implode(',',$fields).') VALUES ('.implode(',',$values).')';
$db->setQuery($query);
$result = $db->query();
//create the folder in the good place
mkdir('images/phocagallery/'.$new->userfolder, 0755, true);
//Reload owner main category
$ownerMainCategory = $model->getOwnerMainCategory($user->id);
}
Just after the lines: (~l-134)
Code: Select all
$model = $this->getModel('user');
$ownerMainCategory = $model->getOwnerMainCategory($user->id);
Don't forget to replace '#_' by your database prefix.
Then you can add this property in your css file to hide the "Main category" menu:
#phocagallery-pane .category { display: none;}
--
http://xldev.fr