diff options
| -rw-r--r-- | includes/controllers/repository_ctrl.php | 41 | ||||
| -rw-r--r-- | repo.php | 2 |
2 files changed, 14 insertions, 29 deletions
diff --git a/includes/controllers/repository_ctrl.php b/includes/controllers/repository_ctrl.php index 6f0ece4e4a..1a535fbfce 100644 --- a/includes/controllers/repository_ctrl.php +++ b/includes/controllers/repository_ctrl.php @@ -39,7 +39,6 @@ require_once WT_ROOT.'includes/functions/functions_import.php'; class RepositoryController extends BaseController { var $rid; var $repository = null; - var $uname = ""; var $diffrepository = null; var $accept_success = false; var $canedit = false; @@ -47,16 +46,16 @@ class RepositoryController extends BaseController { function init() { $this->rid = safe_GET_xref('rid'); - $repositoryrec = find_other_record($this->rid, WT_GED_ID); + $gedrec = find_other_record($this->rid, WT_GED_ID); - if (find_updated_record($this->rid, WT_GED_ID)!==null) { - $repositoryrec = "0 @".$this->rid."@ REPO\n"; - } else if (!$repositoryrec) { + if (find_other_record($this->rid, WT_GED_ID) || find_updated_record($this->rid, WT_GED_ID)!==null) { + $this->repository = new Repository($gedrec); + $this->repository->ged_id=WT_GED_ID; // This record is from a file + } else if (!$gedrec) { return false; } - $this->repository = new Repository($repositoryrec); - $this->repository->ged_id=WT_GED_ID; // This record is from a file + $this->rid=$this->repository->getXref(); // Correct upper/lower case mismatch if (!$this->repository->canDisplayDetails()) { print_header(i18n::translate('Repository')); @@ -65,10 +64,6 @@ class RepositoryController extends BaseController { exit; } - $this->uname = WT_USER_NAME; - - $this->rid=$this->repository->getXref(); // Correct upper/lower case mismatch - //-- perform the desired action switch($this->action) { case 'addfav': @@ -118,19 +113,16 @@ class RepositoryController extends BaseController { break; } - //-- check for the user //-- if the user can edit and there are changes then get the new changes - if ($this->show_changes && WT_USER_CAN_EDIT && ($newrec = find_updated_record($this->rid, WT_GED_ID))!==null) { - $this->diffrepository = new Repository($newrec); - $this->diffrepository->setChanged(true); - $repositoryrec = $newrec; - } - - if ($this->repository->canDisplayDetails()) { - $this->canedit = WT_USER_CAN_EDIT; + if ($this->show_changes && WT_USER_CAN_EDIT) { + $newrec = find_updated_record($this->rid, WT_GED_ID); + if (!empty($newrec)) { + $this->diffrepository = new Repository($newrec); + $this->diffrepository->setChanged(true); + } } - if ($this->show_changes && $this->canedit) { + if ($this->show_changes) { $this->repository->diffMerge($this->diffrepository); } } @@ -146,13 +138,6 @@ class RepositoryController extends BaseController { return i18n::translate('Unable to find record with ID'); } } - /** - * check if use can edit this person - * @return boolean - */ - function userCanEdit() { - return $this->canedit; - } /** * get edit menu @@ -86,7 +86,7 @@ foreach ($repositoryfacts as $fact) { print_main_media($controller->rid); // new fact link -if ($controller->userCanEdit()) { +if ($controller->repository->canEdit()) { print_add_new_fact($controller->rid, $repositoryfacts, 'REPO'); // new media echo '<tr><td class="descriptionbox ', $TEXT_DIRECTION, '">'; |
