I'm having no luck at all.
I've implemented exactly what's described in these two docs.
http://docs.elgg.org/wiki/CronPlugins
http://docs.elgg.org/wiki/PermissionsCheck
But every time I call get_entities() it only returns PUBLIC entities. But the whole point of Cron jobs is to to automated processing *behind the scenes* so I'd think most folks would need access to the "meat and potatoes" of their Elgg system...ie. PRIVATE entities.
Here's the previous thread I started - http://community.elgg.org/mod/groups/topicposts.php?topic=182208&group_guid=7
If anyone, anywhere, has ever gotten this to work, I'd love to see some code! If the Elgg developer who actually wrote the permissions_check plugin hook functionality is reading this...please HELP!!
Or should I just report a bug? I'm not sure how to proceed because I've been stuck on this one thing for a few days now.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
We may be making progress.. I'm running as bare php code. thru the browser - If it works here it should work via CRON. Note that sneaky sleep(2), auth, login 2x ? Something I read somewhere about delayed / cached IO. btw am using get on on guid (2).
<head>
<title>
UTIL____LOGIN_ADMIN.php
</title>
<h2>UTIL____LOGIN_ADMIN.php</h2>
</haad>
<body style="margin-left:25px;">
<?php
echo "<pre>\nENGINE START";
require_once("engine/start.php");
echo "\nAUTHENTICATE -- CHECK";
if ($user = authenticate("ADMIN","PWD) )
{
echo "\nAUTHENTICATE -- OK ";
echo "\nLOGIN -- CHECK";
$result = login($user, false);
}
sleep(2);
if ($user = authenticate("ADMIN","PWD) )
$result = login($user, false);
sleep(2);
if ($result)
{
echo "\nLOGIN -- OK ";
echo "\nGET_ACCESS_LIST= ",get_access_list();
$entity = get_entity(2);
echo "\n<hr>";
echo "\n<h2>ENTITY (2)::</h2>";
print_r($entity);
echo "\n<hr>";
$result = logout();
}
else
{
echo "\nAUTHENTICATE / LOGIN -- ERROR ";
}
//forward("pg/dashboard/");
?>
UTIL____LOGIN_ADMIN.php
Shit hahaha - I actually tried sleep(10) a while back but that didn't seem to help, I still had to refresh the page to get the correct access.
Ok I'll play with it some more - thanks so much for your help!
did you do just 1 sleep(10) ?
i did --
" Note that sneaky sleep(2), auth, login 2x ? Something I read somewhere about delayed / cached IO.."
i.e.
auth
login
sleep
auth
login
seems to do ok..;;-O
Nope, I just tried authenticate(), login(), sleep(2) repeat x 5 (yes five times!)
It never gives me access_id 0 on the first page load.
Maybe this is a limitation of the cron plugin hook?
I suppose I could have my cron job point to a raw PHP page rather than loading /pg/cron/*
Ok I'll try that next.
Just try that bare code I did and shove it into CRON... and see..;;;-O
oopss, and drop that permissions check code out !!!
I just tried it, but no luck. I had to comment out the require_once("engine/start.php"); though.
try entity (2) ?
Ok, I tried just running your bare PHP code in a "test.php" file through my browser. I'm getting different results than you. The access list still doesn't show a 0. So I guess something is just fuxxored with my Elgg installation?
What version are you running?
At least we can eliminate the cron plugin hook being the problem!
UTIL____LOGIN_ADMIN.php
Well of course entity(2) will work, it has ACCESS_ID = 2 (PUBLIC). The whole issue is trying to retrieve entities that have ACCESS_ID = 0 (PRIVATE) ;)
You don't even need to be logged in to retrieve GUID 2.
Ok I GOT IT FIGURED OUT! Finally!
I decided to just trace through the code so I was looking in access.php, specifically at the get_access_sql_suffix() function
And I noticed that part of the logic in creating the access SQL query does a check to see if the global variable $is_admin is TRUE;
Then I found that this handy-dandy admin_init() function sets the global $is_admin variable.
The solution?
One line after the login():
Sweeeeeeeeeeeeeeeeeeeeeeet
It's beer 'o clock now. :)
- Previous
- 1
- 2
- 3
- Next
You must log in to post replies.