This is my first real coding task in PHP. I need to add the ability for JMU staff members to send items to the surplus storage without allowing malicious users to edit the locations of other people’s items. The second piece I need to add is for librarians so that they can view and edit all other posts from other librarians.
I need to more specifically define what this surplus function does.
- Who can see and use the dropdown to edit the location of the item? I have restricted users, readers, and admins.
- What fields does the function need to change? We have a status and a location field in the dashboard.
- What are the fields of the lost objects?
- What are the fields attached to users and how do I differentiate them?
The last two questions are questions I can answer myself through exploring PODS and php prints of variable arrays.
print "<div class='milesPrints'>" . __FUNCTION__ . "</div><br>";
$arr = get_defined_vars(); print_r($arr["nameOfArrayToPrint"]);
I want to know what this following line does in PHP.
$pieces['params']->pod == 'item_found'
From what I understand $pieces is a variable from pods that represents the current active page for a user. It is a dynamically typed array. No types are needed since PHP is dynamically typed meaning the type is whatever you set it to. I don’t know what the arrow does. In c that is a dereferencing operator. We are checking to see if some parameter matches the ‘item_found’ constant that Annette defined. From this explanation the arrow -> is used to access some attribute of an object in a dynamic context. The :: double colons are used to access things in a static context. Accessing class constants would use :: .
var_dump prints it all out. PHP requires semi-colons ; .
I need to sort through the pods $pieces variable. Here are docs. Returning pieces in a pre save filter automatically saves the changes. If it isn’t returned then the changes aren’t saved.