private function _get_proxy() { $album = test::random_album(); $photo = test::random_photo($album); access::deny(identity::everybody(), "view_full", $album); access::deny(identity::registered_users(), "view_full", $album); $proxy = ORM::factory("digibug_proxy"); $proxy->uuid = random::hash(); $proxy->item_id = $photo->id; return $proxy->save(); }
public function user_can_no_access_test() { $item = test::random_album(); access::deny(identity::everybody(), "view", $item); access::deny(identity::registered_users(), "view", $item); $user = identity::create_user("access_test", "Access Test", "*****", "*****@*****.**"); foreach ($user->groups() as $group) { $user->remove($group); } $user->save(); $this->assert_false(access::user_can($user, "view", $item), "Should be unable to view"); }
public function setup() { $this->_server = $_SERVER; $root = ORM::factory("item", 1); $this->_album = album::create($root, rand(), "test album"); access::deny(identity::everybody(), "view_full", $this->_album); access::deny(identity::registered_users(), "view_full", $this->_album); $rand = rand(); $this->_item = photo::create($this->_album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand); $this->_proxy = ORM::factory("digibug_proxy"); $this->_proxy->uuid = md5(rand()); $this->_proxy->item_id = $this->_item->id; $this->_proxy->save(); }
private function _get_admin_view($form, $errors) { $v = new Admin_View("admin.html"); $v->page_title = t("User registration"); $v->content = new View("admin_register.html"); $v->content->action = "admin/register/update"; $v->content->policy_list = array("admin_only" => t("Only site administrators can create new user accounts."), "visitor" => t("Visitors can create accounts and no administrator approval is required."), "admin_approval" => t("Visitors can create accounts but administrator approval is required.")); $admin = identity::admin_user(); $v->content->disable_email = empty($admin->email) || $form["policy"] == "admin_only" ? "disabled" : ""; if (empty($admin->email)) { module::set_var("registration", "email_verification", false); } // below lines added Shad Laws, v2 $v->content->disable_admin_notify = empty($admin->email) || $form["policy"] !== "admin_approval" ? "disabled" : ""; if (empty($admin->email)) { module::set_var("registration", "admin_notify", false); } $v->content->group_list = array(); foreach (identity::groups() as $group) { if ($group->id != identity::everybody()->id && $group->id != identity::registered_users()->id) { $v->content->group_list[$group->id] = $group->name; } } $hidden = array("name" => "csrf", "value" => access::csrf_token()); if (count($v->content->group_list)) { $v->content->group_list = array("" => t("Choose the default group")) + $v->content->group_list; } else { $hidden["group"] = ""; } $v->content->hidden = $hidden; $v->content->pending = ORM::factory("pending_user")->find_all(); $v->content->activate = "admin/register/activate"; $v->content->form = $form; $v->content->errors = $errors; return $v; }
/** * Import a single group. */ static function import_group(&$queue) { $messages = array(); $g2_group_id = array_shift($queue); if (self::map($g2_group_id)) { return; } try { $g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id)); } catch (Exception $e) { throw new G2_Import_Exception(t("Failed to import Gallery 2 group with id: %id,", array("id" => $g2_group_id)), $e); } switch ($g2_group->getGroupType()) { case GROUP_NORMAL: try { $group = identity::create_group($g2_group->getGroupName()); $messages[] = t("Group '%name' was imported", array("name" => $g2_group->getGroupname())); } catch (Exception $e) { // Did it fail because of a duplicate group name? $group = identity::lookup_group_by_name($g2_group->getGroupname()); if ($group) { $messages[] = t("Group '%name' was mapped to the existing group group of the same name.", array("name" => $g2_group->getGroupname())); } else { throw new G2_Import_Exception(t("Failed to import group '%name'", array("name" => $g2_group->getGroupname())), $e); } } break; case GROUP_ALL_USERS: $group = identity::registered_users(); $messages[] = t("Group 'Registered' was converted to '%name'", array("name" => $group->name)); break; case GROUP_SITE_ADMINS: $messages[] = t("Group 'Admin' does not exist in Gallery 3, skipping"); break; // This is not a group in G3 // This is not a group in G3 case GROUP_EVERYBODY: $group = identity::everybody(); $messages[] = t("Group 'Everybody' was converted to '%name'", array("name" => $group->name)); break; } if (isset($group)) { self::set_map($g2_group->getId(), $group->id, "group"); } return $messages; }
/** * Import a single group. */ static function import_group(&$queue) { $g2_group_id = array_shift($queue); if (self::map($g2_group_id)) { return; } try { $g2_group = g2(GalleryCoreApi::loadEntitiesById($g2_group_id)); } catch (Exception $e) { return t("Failed to import Gallery 2 group with id: %id\n%exception", array("id" => $g2_group_id, "exception" => $e->__toString())); } switch ($g2_group->getGroupType()) { case GROUP_NORMAL: try { $group = identity::create_group($g2_group->getGroupName()); } catch (Exception $e) { // @todo For now we assume this is a "duplicate group" exception $group = identity::lookup_user_by_name($g2_group->getGroupname()); } $message = t("Group '%name' was imported", array("name" => $g2_group->getGroupname())); break; case GROUP_ALL_USERS: $group = identity::registered_users(); $message = t("Group 'Registered' was converted to '%name'", array("name" => $group->name)); break; case GROUP_SITE_ADMINS: $message = t("Group 'Admin' does not exist in Gallery 3, skipping"); break; // This is not a group in G3 // This is not a group in G3 case GROUP_EVERYBODY: $group = identity::everybody(); $message = t("Group 'Everybody' was converted to '%name'", array("name" => $group->name)); break; } if (isset($group)) { self::set_map($g2_group->getId(), $group->id); } return $message; }
public function user_can_no_access_test() { $root = ORM::factory("item", 1); $item = album::create($root, rand(), "test album"); access::deny(identity::everybody(), "view", $item); access::deny(identity::registered_users(), "view", $item); $user = identity::create_user("access_test", "Access Test", ""); foreach ($user->groups as $group) { $user->remove($group); } $user->save(); $this->assert_false(access::user_can($user, "view", $item), "Should be unable to view"); }