Hello,
How to quickly get the ID of the viewed profile being in BxDolFilesModule.php.Specifically I need to modify function isAllowedAdd().
Things like:
$profileID, getID( $_GET['ID'] ), bx_get('ID'), etc. don't work due to the fact that this is not xxxprofilexxx.php file.
Btw. what could be the reason that I can't get this ID by let's say: $this->oAlbums->iOwnerId? Constructor, not initiated?
I stuck on this and can't overcome the issue without a big roundabout.. Would be very grateful for help
|
Hey, there are two ID's normally when dealing with certain modules, the User who owns the album, and the current user visiting the page, so not sure which one you want. Also, it's not recommended that you edit the dolphin core files, if you are just trying to make some changes in a particular module, find the class that is extending BxDolFilesModule and overwrite the isAllowedAdd() method there instead. That way it doesn't affect all other modules relying on the core class.
If you describe exactly what you're trying to achieve I might be able to help you more.
sup |
thanks martinoboi,
I ment I need the ID of the user who owns the album. The purpose is when one user is viewing someone's else profile he shouldn't see the "Upload" button after clicking "Photos" link. The link to "Upload" button is stored in sys_menu_actions table in database and calls isAllowedAdd() function for instance which is the reason I want to modify it to quickly achieve the goal.
Of course I realize that modifying dolphin core files is not recommended and basically I try to avoid this :)
|
simple put your own condition after isAllowedAdd()? Isn't that obvious?
thanks martinoboi,
I ment I need the ID of the user who owns the album. The purpose is when one user is viewing someone's else profile he shouldn't see the "Upload" button after clicking "Photos" link. The link to "Upload" button is stored in sys_menu_actions table in database and calls isAllowedAdd() function for instance which is the reason I want to modify it to quickly achieve the goal.
Of course I realize that modifying dolphin core files is not recommended and basically I try to avoid this :)
so much to do.... |
this is not so easy as you think.. because it seems that there are no available variables or functions to get the viewed profile ID from there... my question was not about condition, which is a piece of cake but how to get in easy way the viewed profile ID in that file...
simple put your own condition after isAllowedAdd()? Isn't that obvious?
thanks martinoboi,
I ment I need the ID of the user who owns the album. The purpose is when one user is viewing someone's else profile he shouldn't see the "Upload" button after clicking "Photos" link. The link to "Upload" button is stored in sys_menu_actions table in database and calls isAllowedAdd() function for instance which is the reason I want to modify it to quickly achieve the goal.
Of course I realize that modifying dolphin core files is not recommended and basically I try to avoid this :)
|
depending where you use it there are you can try $this->oProfileGen->_iProfileID.
or import the BxTemplProfileView.
so much to do.... |
as I previously mentioned I can't do something like "$this->oProfileGen->_iProfileID" because "oProfileGen" isn't a data field defined in BxDolFilesModule and BxDolFilesModule isn't a class derived from BxBaseProfileView (where it's originally defined).
Let's say I import BxTemplProfileView like you said and what next? I need to call a constructor of this class to get oProfileGen (otherwise it will be null). And guess what parameter requires this constructor?.. Of course profileID I'm looking for and If I had It there wouldn't be my question on this forum ;) I have a filling that I missed something and there is some very very easy solution for this... anyway thanks for trying help me
depending where you use it there are you can try $this->oProfileGen->_iProfileID.
or import the BxTemplProfileView.
|
If i understand what you are trying to to then this should work probably. Give it a try.
Edit the DB same place. and put this replacing everything.
$oModule = BxDolModule::getInstance('BxPhotosModule');
return (getLoggedId() && $oModule->isAllowedAdd() && $oModule->isProfileOwn()) ? _t('_sys_upload') : '';
Now go to PhotosModule class and put this in the file. You can put this function in the parent class to "BxDolFilesModule"
function isProfileOwn() {
$sUri = $_SERVER['REQUEST_URI'];
if(strpos($sUri, '/main')) {
return true;
}
else if(strpos($sUri, '/owner')) {
return false;
}
return true;
}
Ok, done. Do reply if its what you were looking for. Good Luck
so much to do.... |
Yeah, this is basically what I was looking for :) Thanks a lot Prashank, when I saw your the code I new that this time it will work out ;)
Anyway I have to add a few words. First of all I was looking some easy solution and I hoped that there is some quick transition between profiles and photos to get this ID like some function, variable I missed etc. Here are the reasons I try to avoid url string operations on urls from my programming experience:
1. sometimes it's difficult to predict some exceptions, for instance if there is a username called "main" the button will be visible for other users being on his page, of course this can be fixed by adding another condition, this is not too important anyway because we have other conditions which blocks adding files into not our profiles but hackers can make some damage sometimes this way
2. the second thing is that in my case this is more complex as I don't have my/main in the path and only browse/owner/ because I didn't want to add albums that way and it had been modified before. So In my case I need to retrive the nickname, get the ID from nickname and compare to the ID of the logged user. Anyway I handled this and it works right now.
3.String operations are more time consuming and I also was learnt to avoid this.
Anyway if there is no any variable, function etc. the solution you provided seems to be the only one, so thanks once again for help :)
Now you can see why one stupid ID can make so much trouble and time loss ;)
Regards
|
The reality is that when you are viewing the the album of the profile, its not his profile actually, so getting the ID is hard.
One way i can think rightnow is to go to BxDolFilesModule.php line 646 and make the getID($sParamValue1) value global.
if($sParamName == 'browse' && $sParamValue == 'owner') {
$GLOBALS['oTopMenu']->setCurrentProfileID(getID($sParamValue1));
$this->aPageTmpl['header'] = _t('_' . $this->_oConfig->getMainPrefix() . '_browse_by_owner', $sParamValue1);
}
This is the code that sets the sub menu of the profile there. I am actually not sure how practical it is. Just to let you know.
And strpos() is not that slow actually.
so much to do.... |
oh oh just had another idea without globals. I will post the code after doing some tests. so much to do.... |
Ok, here we go.
Open BxDolFilesModule and put this after var $aSectionsAdmin = array();
var $_iViewed= 0;
Now find if($sParamName == 'browse' && $sParamValue == 'owner') {
and make it like this
if($sParamName == 'browse' && $sParamValue == 'owner') { $this->_iViewed= getID($sParamValue1); $GLOBALS['oTopMenu']->setCurrentProfileID($this->_iViewed); $this->aPageTmpl['header'] = _t('_' . $this->_oConfig->getMainPrefix() . '_browse_by_owner', $sParamValue1); }
And put this function after that
function isProfileOwn() { if(!$this->_iViewed) return true; if($this->_iViewed == $this->_iProfileId) return true; return false; } Leave the DB modified like before and you are done. Enjoy :D
so much to do.... |
I'm at work right now so will look at it when I'm back and then I will test it and let you know ;)
thanks for being so helpful!!! ;)
Regards
|
Works great!!! This is what exactly I was looking for! :)
Short code, no unnecessary operations, great and function will be useful in other places ;)
The _iViewed field and $this->_iViewed=getID($sParamValue1) was the key! Thanks a lot once again!!!
|
You are very welcome. Glad your problem is solved so much to do.... |
I have a similar interest in obtaining the ID of the owner of a post, album, etc when viewing a page. In my case I want to be able to grab the custom CSS from the owners profile and insert it in the page. I know how to insert the custom CSS (I added it to the account page) and it involves adding the key to the page template. With the ID of the author of the blog post, album, etc, I can then include the function that will grab the CSS from the database and insert the CSS in the template file. Geeks, making the world a better place |