1
danvarey
Debaser post count
  • 2009/5/26 8:50

  • danvarey

  • Just popping in

  • Posts: 10

  • Since: 2008/9/5 9


I have installed debaser and its working properly. But the posts are not counted on XOOPS Brasil posts. I searched whole XOOPS and whole settings of debaser for that, but there is nothing mentioned like that.
Can anyone let me know how to correct this

2
frankblack
Re: Debaser post count
  • 2009/5/26 15:57

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


There is no setting for this right now, but I will have a look where to implement this in the old version. As a proof that debaser is not dead: Resized Image

3
frankblack
Re: Debaser post count
  • 2009/6/21 10:28

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Edit upload.php and insert after (about) line 237:
if (is_object($xoopsUser) {
$current_userid $xoopsUser->getVar('uid');
$member_handler = &xoops_gethandler('member');
$poster = &$member_handler->getUser($current_userid);
$member_handler->updateUserByField($poster'posts'$poster->getVar('posts') + 1);
}


Locate the places where the files will be deleted and insert the above code but with -1.

I wonder anyway, why incrementPost is deprecated in 2.3x. Not a handy function? And why it isn't triggered with a notice that it is deprecated. Funny enough, that there was (is) incrementPost, but no decrementPost. ???

4
trabis
Re: Debaser post count
  • 2009/6/21 11:05

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


I think there is no need to go around:
if (is_object($xoopsUser) {
$xoopsUser->setVar('posts'$xoopsUser->getVar('posts') + 1);
$user_handler =& xoops_gethandler('user');
$user_handler->insert($xoopsUser);
}


You said:"
Funny enough, that there was (is) incrementPost, but no decrementPost. ???
"

Maybe that is one of the reasons it is deprecated. Using just the handler you can increment or decrement whatever field you want. The code you need for it is nearly the same you need to call the member handler and trigger the increment post so, you agree?

If we are going to create shortcuts for simple jobs then we just getting more and more shortcuts that we can't remember, that we need to check if exist or not for that class, etc.
Same goes for methods like ->uid() instead of ->getVar('uid')
This shortcuts should be deprecated to.

5
frankblack
Re: Debaser post count
  • 2009/6/21 11:37

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Thx for the code, but I disagree. I do believe in the benefits of shortcuts. In my job I have to work with Photoshop all day long. So every time moving the cursor to the menu, selecting "Bild", selecting "Einstellen", selecting "Selektive Farbkorrektur" would make my day at work a bit longer than it is already. So I get used to using keyboard shortcuts.

Do you want to keep the overall-code-lines in XOOPS shorter or more efficient? Hmmm, if I get this right the old-fashioned way would be:
if (is_object($xoopsUser)) $xoopsUser->incrementPost();


Just my thoughts...

6
trabis
Re: Debaser post count
  • 2009/6/21 11:55

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You are looking at a single method, but think big, think about
incrementPost
decrementPost
updateLastlogin
toggleNotificationMethod
resetThemeToDefault
...

You can think in more and more methods that would be handy but, with what cost?

If I need to perform some of this actions in a module of mine I can do it with my eyes closed using the same handler method, using always same convention.

It takes more time to type but it is much easier to learn. And, more important, it works for any field and any object and any handler that extends xoopsObject/XoopsPersistableObjectHandler

7
frankblack
Re: Debaser post count
  • 2009/6/21 12:16

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


From the perspective of a module developer who can type blindly code you are right. From the perspective of a novice who is not so much into the matter you are wrong.

I was always fond of the little helpers which are hidden inside XOOPS core. Developing my module is really HARD WORK for me (others would laugh about my code), but I am really glad for the tiny helpers supporting me. It is (still) amazing that even being a non-pro you can get some nice and quick results without having to much skills.

Or does the development of XOOPS - specifically modules - should be left to the pros?

Just my pov, I'll get along with the coming improvements, but it takes me a bit longer.

8
ghia
Re: Debaser post count
  • 2009/6/21 14:08

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Frank, I agree with you on this!
Quote:
And, more important, it works for any field and any object and any handler that extends xoopsObject/XoopsPersistableObjectHandler
That's right, but you are using very low level functions, which requires a lot of typing, the knowledge of internal var names and rely on several calls, which need to be aligned in the proper consecutive order, etc.
The whole point of extending a class is to bundle these groups of everyday used functions into new functions and give them an easy name, which make it obvious to use and to read in the module programming. The difference in code of these two identical functions, shows it all.
if (is_object($xoopsUser) {
$xoopsUser->setVar('posts'$xoopsUser->getVar('posts') + 1);
$user_handler =& xoops_gethandler('user');
$user_handler->insert($xoopsUser);
}

versus
if (is_object($xoopsUser)) $xoopsUser->incrementPost();

Class users (=programmers who use the class in their module etc) shouldn't be bothered with these inside details.
Instead of labeling these functions as deprecated, they should be promoted!
The low level functions as getVar and setVar are only to be used if there is no other choice: if there is no upper level class function or for programming one.

9
frankblack
Re: Debaser post count
  • 2009/6/21 14:42

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Quote:
Frank, I agree with you on this!


Thx! I really wish, that my skills were better and I must not use low-level-workarounds (in my case).

Perhaps it would be useful, if skilled and non-skilled developers explain their "requirements" to make XOOPS (modules) better?

I already met some points in XOOPS while non-skilled-programming where I had some good (easy) thoughts on how to solve problems, but ...

Here are three of them:
a) why does the code in xoopsConfig and xoopsModuleConfig differ for multigroup?

b) a) arose from the problem, that I heavily use(d) various permissions. But each checkRight I use triggers a database query. OK, I thought, then use xoopsModuleConfig which is one big array and use the permissions there, but this is not satisfying, because guests are excluded.

So I asked for one big permission array, but the code I was told wasn't working:
$criteria = new CriteriaCompo(new Criteria('gperm_modid''moduleidasinteger'));
$criteria->add('groupidsasarray');
$perms $gperm_handler->getObjects($criteria,true,false);


Anyone knows a proper solution to get ALL the permissions for a module in ONE shot?

c) I wanted to save queries for my blocks writing all the functions into one file, having code re-usable for all the functions, but this is not working if the blocks are displayed outside the module, so I made a preg_match to use fail-safe-code in this code. Any workaround for this?

10
trabis
Re: Debaser post count
  • 2009/6/21 20:27

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


a) Don't understand

b) criteria->add(...) expects a criteria and not an array. You can remove that line if you want all module permissions. If you looking good solution for manage permissions, please take a look at smartsection or smartobject

c) "but this is not working if the blocks are displayed outside the module".
Where is the problem? Are you using $xoopsConfig, $xoopsModule in your functions? You should take a look on smartsection or news module. Here is a simple function to get configs from a block:
function mymenus_getModuleConfig($dirname 'mymenus')
{
    static 
$config;
    if (!
$config) {
        global 
$xoopsModule;
        if (isset(
$xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $dirname) {
            global 
$xoopsModuleConfig;
            
$config =& $xoopsModuleConfig;
        } else {
            
$hModule =& xoops_gethandler('module');
            
$module $hModule->getByDirname($dirname);
            
$hConfig =& xoops_gethandler('config');
            
$config $hConfig->getConfigsByCat(0$module->getVar('mid'));
        }
    }
    return 
$config;
}

Login

Who's Online

171 user(s) are online (119 user(s) are browsing Support Forums)


Members: 0


Guests: 171


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits