コード例 #1
0
ファイル: PageController.php プロジェクト: humansky/qframe
 /**
  * Attempt to lock a page, check for access and return the lock on success, redirect to the view
  * page with an error on failure
  *
  * @param  mixed  PageModel or id of page being locked
  * @param  string the action we are checking for access to
  * @return mixed
  */
 private function lockPage($page, $action = 'approve')
 {
     if (!$page instanceof PageModel) {
         $page = new PageModel(array('pageID' => $this->_getParam('id'), 'depth' => 'response'));
     }
     $lock = LockModel::obtain($page, $this->_user);
     if ($lock === null) {
         $this->flash('error', 'A lock could not be obtained for the requested page. Please ' . 'ensure you have access and try again later.');
         $this->_redirector->gotoRouteAndExit(array('action' => 'view', 'id' => $page->pageID));
     } elseif (!$this->_user->hasAccess($action, $page)) {
         $this->denyAccess();
     }
     return $lock;
 }
コード例 #2
0
ファイル: LockModelTest.php プロジェクト: humansky/qframe
 public function testCanModifyAllowsAppropriateModification()
 {
     $page1 = new PageModel(array('pageID' => 1, 'depth' => 'page'));
     $page2 = new PageModel(array('pageID' => 2, 'depth' => 'page'));
     $user = new DbUserModel(array('dbUserID' => 1));
     $lock = LockModel::obtain($page1, $user);
     $this->assertTrue($lock instanceof LockModel);
     $this->assertTrue($lock->canModify($page1));
     $this->assertFalse($lock->canModify($page2));
 }