Skip to content

Commit

Permalink
Updates to fix unittests after latest changes
Browse files Browse the repository at this point in the history
also some cleanup

Issue #80
  • Loading branch information
jeroenrnl committed Jan 22, 2017
1 parent c0696fd commit d725a90
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions UnitTests/permissionsControllerTest.php
Expand Up @@ -63,7 +63,7 @@ public function testUpdateAllAlbumsAction() {
$request=new request(array(
"GET" => array(),
"POST" => array(
"_action" => "update_albums",
"_action" => "updatealbums",
"_access_level_all_checkbox" => 1,
"group_id" => 3,
"access_level_all" => 2,
Expand Down Expand Up @@ -93,7 +93,7 @@ public function testUpdateRemoveAlbumsAction() {
$request=new request(array(
"GET" => array(),
"POST" => array(
"_action" => "update_albums",
"_action" => "updatealbums",
"_remove_permission_album__2" => 1,
"group_id" => 3),
"SERVER" => array()
Expand All @@ -119,9 +119,10 @@ public function testUpdateAddAlbumsAction() {
$request=new request(array(
"GET" => array(),
"POST" => array(
"_action" => "update_albums",
"_action" => "updatealbums",
"album_id_new" => 1,
"group_id_new" => 3,
"group_id" => 3,
"group_id_new" => 3,
"access_level_new" => 4,
"watermark_level_new" => 6,
"writable_new" => 0),
Expand Down
4 changes: 2 additions & 2 deletions php/album.php
Expand Up @@ -81,7 +81,7 @@
<h1>
<ul class="actionlink">
<li><a href="albums.php"><?php echo translate("return") ?></a></li>
<?php if($action != "insert"): ?>
<?php if ($action != "insert"): ?>
<li><a href="album.php?_action=delete&amp;album_id=<?php
echo $album->get("album_id") ?>">
<?php echo translate("delete") ?>
Expand All @@ -98,7 +98,7 @@
<input type="submit" value="<?php echo translate($action, 0) ?>">

</form>
<?php
<?php
if ($user->isAdmin()) {
if ($_action == "new") {
echo new block("message", array(
Expand Down
2 changes: 1 addition & 1 deletion php/classes/album.inc.php
Expand Up @@ -394,7 +394,7 @@ public function getPermissionArray($getGroup=false) {
foreach ($groups as $group) {
$permissions = $group->getGroupPermissions($this);
if ($permissions) {
if($getGroup) {
if ($getGroup) {
$perms[]=$group;
} else {
$perms[]=$permissions;
Expand Down
10 changes: 5 additions & 5 deletions php/classes/permissions/controller.inc.php
Expand Up @@ -40,6 +40,11 @@ class controller extends genericController {
*/
public function __construct(request $request) {
parent::__construct($request);
if (isset($this->request["group_id"])) {
$this->setObject(new group($this->request["group_id"]));
} else if (isset($this->request["album_id"])) {
$this->setObject(new album($this->request["album_id"]));
}
array_push($this->actions, "updatealbums", "updategroups");
$this->doAction();
}
Expand All @@ -48,8 +53,6 @@ public function __construct(request $request) {
* Process changes to group permissions
*/
protected function actionUpdategroups() {
$album = new album($this->request["album_id"]);
$this->setObject($album);
// Check if the "Grant access to all groups" checkbox is ticked
if ($this->request["_access_level_all_checkbox"]) {
$groups = group::getAll();
Expand Down Expand Up @@ -99,8 +102,6 @@ protected function actionUpdategroups() {
* Process changes to album permissions
*/
protected function actionUpdatealbums() {
$group = new group($this->request["group_id"]);
$this->setObject($group);
// Check if the "Grant access to all albums" checkbox is ticked
if ($this->request["_access_level_all_checkbox"]) {
$albums = album::getAll();
Expand All @@ -118,7 +119,6 @@ protected function actionUpdatealbums() {
foreach ($albums as $album) {
$album->lookup();
$id=$album->getId();
$name=$album->getName();

if (isset($this->request["_remove_permission_album__$id"])) {
// first check if album needs to be revoked
Expand Down

0 comments on commit d725a90

Please sign in to comment.