Hi,
I hope I didn't miss some settings but when I create a secret achievement there is a way you can still learn the real title of it. In the achievement list it has the secret title, picture and description as intended, but picture and title link to the leaderboard of this particular achievement and there you have not only a hint in the url, as it contains the name of the function but also the real title shows up on the leaderboard.
I fixed this by modifying your module. First I tried this to link secret achievements to the global leaderboard:
...
if (isset($variables['achievement']['secret']) && !achievements_unlocked_already($variables['achievement']['id'])) {
$variables['achievement']['points'] = t('???'); // IIiII haveEeeA aa seecFRrit and I'll NEEVvaaha hTellLL..
$variables['achievement']['title'] = t('Secret achievement'); // unless, of course, you PayPal me bribes.
$variables['achievement']['description'] = t('Continue playing to unlock this secret achievement.');
$variables['state'] = 'secret';
$variables['achievement_url'] = url('achievements/leaderboard');
}
...
That did not work and I found out it's because the $variables['achievement_url'] is not used in the following lines where the image and the achievement title are handled. So I tried this:
$variables['image'] = array(
'#theme' => 'image_formatter',
'#item' => array(
'uri' => $variables['image_path'],
'alt' => $variables['achievement']['title'],
'title' => $variables['achievement']['title'],
),
'#path' => array(
'path' => $variables['achievement_url'],
'options' => array('html' => TRUE),
),
);
$variables['achievement_title'] = array(
'#type' => 'link',
'#title' => $variables['achievement']['title'],
'#href' => $variables['achievement_url'],
);
That changed the links but the url was broken, because the 'http://www....' part was gone. It was just achievements/leaderboard.
So I tested a few other things and found this solution that worked for me:
$variables['image'] = array(
'#theme' => 'image_formatter',
'#item' => array(
'uri' => $variables['image_path'],
'alt' => $variables['achievement']['title'],
'title' => $variables['achievement']['title'],
),
'#path' => array(
'path' => 'achievements/' . 'leaderboard',
'options' => array('html' => TRUE),
),
);
$variables['achievement_title'] = array(
'#type' => 'link',
'#title' => $variables['achievement']['title'],
'#href' => 'achievements/' . 'leaderboard',
);
I guess that is not the best way to do it but it it's the only way I got it to work so far. Still I don't understand why exactly it works like this and not the other way.
Before I finish here I want to THANK YOU!! for this project. I'm using Drupal for a couple of years now, but I learned more about making own code for this system, about hooks and all that in the last few hours than in all the month and years before, because there was just no need to learn it.
I'm creating a website for a class of 5-7graders which I use to teach them about image editing, html, coding small games etc. and I've used the Badges and the Userpoints modules to reward them for succeeded tasks, logins, behavior and more which was a big success, but I know they will go crazy about this new achievement thing and all this new ways I can use it.
I hope my English was good enough so you could understand the little problem I described above and maybe you have a better solution for it.
Thanks again for the good work and the amusing comments in the code.
Regards, Ben