Mixin_WordPress_Security_Manager
The NextGEN Gallery Mixin WordPress Security Manager class.
Defined (1)
The class is defined in the following location(s).
- /products/photocrati_nextgen/modules/security/package.module.security.php
- class Mixin_WordPress_Security_Manager extends Mixin
- {
- public function get_actor($actor_id, $actor_type = null, $args = null)
- {
- if ($actor_type == null) {
- $actor_type = 'user';
- }
- $object = null;
- if ($actor_id != null) {
- switch ($actor_type) {
- case 'user':
- $object = get_userdata($actor_id);
- if ($object == false) {
- $object = null;
- }
- break;
- case 'role':
- $object = get_role($actor_id);
- if ($object == false) {
- $object = null;
- }
- break;
- }
- }
- if ($object != null) {
- $factory = C_Component_Factory::get_instance();
- $actor = $factory->create('wordpress_security_actor', $actor_type);
- $entity_props = array('type' => $actor_type, 'id' => $actor_id);
- $actor->set_entity($object, $entity_props);
- return $actor;
- }
- return $this->object->get_guest_actor();
- }
- public function get_current_actor()
- {
- // If the current_user has an id of 0, then perhaps something went wrong
- // with trying to parse the cookie. In that case, we'll force WordPress to try
- // again
- global $current_user;
- if ($current_user->ID == 0) {
- if (isset($GLOBALS['HTTP_COOKIE_VARS']) && isset($GLOBALS['_COOKIE'])) {
- $current_user = NULL;
- foreach ($GLOBALS['HTTP_COOKIE_VARS'] as $key => $value) {
- if (!isset($_COOKIE[$key])) {
- $_COOKIE[$key] = $value;
- }
- }
- }
- }
- return $this->object->get_actor(get_current_user_id(), 'user');
- }
- public function get_guest_actor()
- {
- $factory = C_Component_Factory::get_instance();
- $actor = $factory->create('wordpress_security_actor', 'user');
- $entity_props = array('type' => 'user');
- $actor->set_entity(null, $entity_props);
- return $actor;
- }
- }