We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Which file to edit for /user/username ? | Forum

Marina Bircher
Marina Bircher Apr 2 '15
Hi dear readers


The Oxwall software is greate, but ... the documentation is a joke, isnt it? :(


Where can I find the file which handles the user profiles when I go to mysite.com/user/username - I want to find the $_GET['username'] , is that possible? 


Which tutorials should I read, watch to understand how oxwall works? I can php very well, and a little bit smarty; but its really hard without a (good) documentation. - but I'm very thankfull that you are so helpful.


Greets!

Nickolay
Nickolay Apr 2 '15
Have a look at custom plugin development tutorial (+source for Plugin Skeleton). URLs are handled by router and rules for it are in init.php file of every plugin (in your situation it's core \ow_system_plugins\base\) - there you'll find what controller/action is called.
Marina Bircher
Marina Bircher Apr 2 '15
Thx for the hint, I'm going to read it now.


So when I have the Profile page of my User:

/user/UserName1


which file in\ow_system_plugins\base\ is handling the $_GET['UserName1'] ? 


My goal is to change the functionality so that we can get User Profil with the 'unique ID' not the username! 


Where can that be found? 

Nickolay
Nickolay Apr 2 '15

There's a line in init.php file:

$router->addRoute(new OW_Route('base_user_profile', 'user/:username', 'BASE_CTRL_ComponentPanel', 'profile'));
that means that BASE_CTRL_ComponentPanel::profile() will be called. And it's not $_GET['username'] you'll be looking for, but $params['username'] in action method.


But actually if you want profile links to contain ID instead of USERNAME everywhere modifying controller action won't be enough because of the way SEF urls are built. You'll have to replace every instance of

OW::getRouter()->urlForRoute('base_user_profile', array('username'=> ....

and

{url_for_route for="base_user_profile:[username=>$username]"}

in smarty templates, that is not a very good way to go.

Marina Bircher
Marina Bircher Apr 2 '15
Hey Nickolay thanks for your support! very kind of you!


It worked for me, what do you mean with SEF?


I changed the profile() function in the component_panel.php class:

instead of the first line, i wrote the second

// $userDto = $userService->findByUsername($paramList['username']);
$userDto = $userService->findById($paramList['username']);


I really only care about the Profiles. Those shouldnt be reachable with the username.


Thanks for your help!

The Forum post is edited by Marina Bircher Apr 2 '15
Nickolay
Nickolay Apr 2 '15
> It worked for me, what do you mean with SEF?

There're a lot of places in core and custom plugins where the link to profile is generated like user/[USERNAME] (if you do not edit this, oxwall will just return 404 on requests with username). Search for occurrences of "base_user_profile", you'll find what I'm talking about.

Marina Bircher
Marina Bircher Apr 2 '15
I searched for "base_user_profile" ... for example I saw the usage in  ow_plugins\winks\classes\console_event_handler.php  LineNr:105


$userUrl = OW::getRouter()->urlForRoute('base_user_profile', array('username'=>BOL_UserService::getInstance()->getUserName($wink->getUserId())));

But my change doesnt have any effects to this or other functions like this. I tested it, I couldnt see any errors. I hope it will stay like that.  ( For example I sent winks, or messages, or gifts... it works ) 



The Forum post is edited by Marina Bircher Apr 2 '15
Marina Bircher
Marina Bircher Apr 2 '15
Ok I found now one thing that doesnt work, like I want that it should work.

The mailbox plugin! I have there to change the function which is setting the "href" for the a-tag with the CSS ID #dialogProfileUrl ! I found that function in \ow_plugins\mailbox\static\js\contactmanager.js  :

this.model.profileUrlSetSubject.addObserver(function(){
self.profileUrlControl.attr('href', self.model.profileUrl);
)}

I tried to understand how that plugin works. Its really hard to understand whats happening in that javascript backbone code. Do you know where this profileUrl is coming from? how can I set there another Field in the DB instead of "username".


We'll make it! :D      



Nickolay
Nickolay Apr 2 '15
Actually I pointed you the right answer - it's not only mailbox you'll find this error but in many other places. The one you've found


OW::getRouter()->urlForRoute('base_user_profile', array('username'=>BOL_UserService::getInstance()->getUserName($wink->getUserId())));


will have to be


OW::getRouter()->urlForRoute('base_user_profile', array('username'=>$wink->getUserId()));


if you want it to work with your modification above. So what you need is to find all of it and change to use user ID instead of USERNAME when passing to urlForRoute method. You changes in controller only makes the difference when you request the right URL, i.e. /user/USER_ID, but not if all the real links on site will contain /user/USERNAME. I think I made it clearer now.

Marina Bircher
Marina Bircher Apr 3 '15

Quote from Nickolay


OW::getRouter()->urlForRoute('base_user_profile', array('username'=>BOL_UserService::getInstance()->getUserName($wink->getUserId())));


will have to be


OW::getRouter()->urlForRoute('base_user_profile', array('username'=>$wink->getUserId()));



No Nickolay, the Wink function works already how it is! I dont have to change that. It works. 


The only Problem is in the Views when we have a Link (<a href="user/username">Visit Profile</a>) to a Profile!  The click on "send Wink" doesnt redirect People to other Profiles, but the click on an Avatar in the Chat redirect the User to other Profiles. 


Like I asked, do you know where the self.model.profileUrl comes from in  in \ow_plugins\mailbox\static\js\contactmanager.js?


this.model.profileUrlSetSubject.addObserver(function(){
self.profileUrlControl.attr('href'self.model.profileUrl);
)}


I couldnt find the connection from Javascript to this model in php. 


Mario Carriere
Mario Carriere Apr 3 '15
Hi Marina,

profileUrl is set in toolbar.php.



Mario
Nickolay
Nickolay Apr 3 '15
You just don't quite get me, I'm not talking about your particular problem in mailbox plugin or somewhere else. Your initial change does not effect functionality of other plugins, it effects only how links to user profiles will be handled.

For example:

> I have there to change the function which is setting the "href" for the a-tag with the CSS ID #dialogProfileUrl

I think you do understand that there are a lot of places in core and custom plugins where <a href="... links to user profile pages. And your example in mailbox is just one accasion among dozens - I've pointed you the right way: search for base_user_profile string in *.php,*.html files and fix it to user USER_ID instead of USERNAME (even if I helped you to fix self.model.profileUrl - it would not save you the trouble of facing problems in all other places later and asking the same question again and again)


P.S. Or maybe there's a slight chance you haven't explained your intension good enough. You want links to user profiles to look like user/999 everywhere on your website, yes?

Marina Bircher
Marina Bircher Apr 3 '15

@Mario

Thx, I got it. I was searching for the function, which gets the username from the database for the mailbox.


@Nickolay

Yeah I understand what you mean... but for now I tested it and havent seen other Problems, but I think/know you are right, there will be other places in the code ... I hope I will find the solution by myself and wont annoy you :p
Quote from Nickolay

P.S. Or maybe there's a slight chance you haven't explained your intension good enough. You want links to user profiles to look like user/999 everywhere on your website, yes?

YES! :)



I got it for the chat/mailbox plugin! 

changed in:

ow_plugins\mailbox\bol\conversation_service.php


from:

$profileUrl = BOL_UserService::getInstance()->getUserUrl($conversationOpponentId);


to:

$profileUrl = BOL_UserService::getInstance()->getUserID($conversationOpponentId);


And it works for now : )



Edit: you are right, there are to many other places where I have to change it... dont you think there is a way to change that? 


The Forum post is edited by Marina Bircher Apr 3 '15
Mario Carriere
Mario Carriere Apr 3 '15
Can I ask you what do you use for coding?

If you want the mailbox/chat plugin to fully use the id, you may need to change a few more...

 .
Mario
Nickolay
Nickolay Apr 3 '15
You making a bit blind changes not really understanding the concept. I've told you about the only one valid solution, but it requires for you to have more knowledge of the software than you have right now. 

As of right now you're just being naive thinking "And it works for now : )", belive me. The thing that it works only means that it does not have a problem in particular place you've checked, but not in others.


P.S. Mario, actually it's not about profileUrl variable, you are also following the wrong way Marina pointed you.


Edit: you are right, there are to many other places where I have to change it... dont you think there is a way to change that? 

It was quick) Unfortunataly it cannot be done just by copy/paste or find/replace - you'll need to go to every line where base_user_profile is present and edit it manually so that ID would be passed as 'username' to router. But it's not very difficult either.

The Forum post is edited by Nickolay Apr 3 '15
Mario Carriere
Mario Carriere Apr 3 '15
Hi Nickolay,

I know. I did follow the thread... ;)

I understand your point and you're right.

She's experimenting with the site and I only want to help her do so. This is how I have learn what I know about Oxwall. I have sent a few installations to the drain trying things... lol

So, in my mind, she choose the level of risk she's willing to take with her experimentation. And even in the wrong path, you learn things...

Thanks!

Mario
Marina Bircher
Marina Bircher Apr 3 '15
I'm sorry, but like I said the documentation is just ridiculus!! So I dont have another chance to learn how this software works than experimenting blind around. 


Mario I use Intellij. 


I will try and when I find a way, I'll write a Tutorial, maybe there are other people who want this functionallity. 


I will learn it! I will understand it! : ) thanks for your support!



Mario Carriere
Mario Carriere Apr 3 '15
Marina,

I use Netbeans IDE. It's free and very useful.

By selecting a file, you see in the navigator all the classes, variables, etc... You can also link it to your site by FTP. Using it allowed me to compensate the lack of documentation for Oxwall.

You can also search for keyword like variables, classes...

I know it's not easy to adapt to a new IDE and I don't know Intellij but maybe this is worth a try...

Never the less, keep learning!



Mario

PS. The Skeleton Plugin is also helpful. Available in the store... free. Skeleton Pluguin

The Forum post is edited by Mario Carriere Apr 3 '15
Nickolay
Nickolay Apr 3 '15
Okey, thought it's a bit offtopic, I agree there's no really easy way to learn considering the lack of documentation, but noone would argue that it feels a bit better to do this with at least one eye open) That is my initial point.


@Marina Just for consideration I've noticed your thread about online users you were trying to literally rip out from the index page - maybe it'll be good for you to start with making a tiny widget for that task and learn in process. Besides I like yuor intention to learn and share - it's what makes any support forum more alive, as much as the software itself.


P.S. @Mario About Netbeans, actually JetBrains makes one of the world best IDEs (I mean it) and the things you've mentioned are really basic for any IDE present, so no need for a change here.

The Forum post is edited by Nickolay Apr 3 '15
Mario Carriere
Mario Carriere Apr 3 '15
Nickolay,

Thanks for the info about JetBrains. But at 199$ a license, I will stick with Netbeans... ;)
At least for now...

And about your initial point, you're absolutely right. This is why I really like those technical threads. I'm far from being a professional php developper and I greatly value all the inputs I get from them.

Experimenting, reading the forum and going thru the small documentation allowed me to write my first plugin; a tool to troubleshoot cron job. To give back to the Oxwall communities, I made it available for free in the store. I'm now working on 2 bigger project. 

So thanks to you!

Mario

PS. Sorry to be a little offtopic...
The Forum post is edited by Mario Carriere Apr 3 '15
Pages: 1 2 »