4 users online. Create an account or sign in to join them.Users
Custom Event Function
This is an open discussion with 14 replies, filed under General.
Search
You should define a new entry manager object like this:
$em = new EntryManager(Symphony::Engine()); $data = $em->fetch(...);
Am I allowed to put that in the public function load()? When I add that I get an error:
Fatal error: Class 'EntryManager' not found in... on line...
In which case you'll need to include the EntryManager class :-)
require_once(TOOLKIT . '/class.entrymanager.php');
Doesn't EntryManager only work inside the __trigger function?
Edit:
Can you check that actually, because it used to, and it still should. Which means that if it doesn't then something is broken somewhere, and it should also be available in the load function too.
I've seen it definitely used before in the __trigger function, which is invoked by the load function.
Doesn't EntryManager only work inside the __trigger function?
This has not been my experience.
Is this the best technique to prevent members from DOM hacking and messing with other members entries/settings? I know the member extension comes with event filters for locking things down, would that be a preferred method to reference?
I see this being a potentially huge problem on a couple of sites I'm currently developing, but if this is a viable solution, it seems like it might be easier to achieve.
Is this the best technique to prevent members from DOM hacking and messing with other members entries/settings?
Check out the Default Event Values extension.
Bump for my edit earlier.
Been able to return an array of data with this method:
$EntryManager = new EntryManager(Symphony::Engine()); $data = $EntryManager->fetch(256); //256 is $_POST['id']
But when I attempt to use any of that data it fails. I've been trying with this method:
$someVar = $data->getData(238);
I cannot seem to used getData from entrymanager.php although it includes it? Is there another way to use the information that fetch provides?
But when I attempt to use any of that data it fails
In what way? What happens if you var_dump($data), what does it include?
I get an array with object data. It contains all the data that I need (in this case the email address of the user).
Though I don't know how to grab the data from the array itself. I thought that was the purpose of getData(), but apparently I'm not using it correctly.
I've also tried print_r($data[0]->etc, etc) with no luck.
Here is small sample of var_dump($data);
array(1) {
[0]=>
object(Entry)#27 (5) {
["_Parent:protected"]=>
object(EntryManager)#21 (6) {
["_Parent:protected"]=>
object(Frontend)#1 (7) {
["Profiler"]=>
object(Profiler)#2 (0) {
}
["Cookie"]=>
object(Cookie)#8 (6) {
["_index:private"]=>
string(4) "sym-"
["_session:private"]=>
string(32) "43da0f3c2344415a3e171224a23b1041"
["_timeout:private"]=>
int(1209600)
["_path:private"]=>
string(1) "/"
["_domain:private"]=>
NULL
["_httpOnly:private"]=>
bool(false)
}
["Author"]=>
NULL
["_env"]=>
array(0) {
}
["Database"]=>
object(MySQL)#6 (3) {
["_result:private"]=>
resource(160) of type (Unknown)
["_lastQuery:private"]=>
string(90) "SELECT SQL_CACHE * FROM `sym_entries_data_305` WHERE `entry_id` IN (256) ORDER BY `id` ASC"
["_lastResult:private"]=>
array(0) {
You're very close! EntryManager::fetch returns an array of Entry objects, which you've got in the $data variable. So at the moment you're calling getData() on a PHP array, which won't work. You need to get the Entry object from the array first, either with $data[0] or reset($data), and then you can call getData() on it :-)
Ah.. so getData() only works on object data?
This worked perfectly:
print_r($data[0]->getData());
Thanks for the info. Much appreciated!!
Yep, getData is a method of the Entry class so you call it on Entry objects.
Create an account or sign in to comment.
I'm creating a front-end form that will "verify" a submitter's email before allowing them to update an entry through the form. (So people can't type in random ID's and mess with other's settings. It's a pretty low security form.) I already know the ID of the entry as a hidden field. I know that I could do this more easily by adding the email in a hidden field, but that would kinda defeat the purpose of the mini-security I'm making.
I'm customizing the load() function within the event, but right now I get an error related to class 'EntryManager', can I not use this within the load() function?
public function load(){ //Saw this somewhere, thought I should "fetch" an object of the ID, but I get an error: Class 'EntryManager' not found $postid = $EntryManager->fetch($_POST['id']); //I want to get the value of field 228 (an email field) of the entry id $realemail = $postid->getData(238)); //Once I have that entry's email field, I want to compare it to what the user entered on the form if(isset($_POST['action']['filter-reminder-reset']) && $_POST['email-verification'] == $realemail){ return $this->__trigger(); } }