Permalink
Browse files

Separates the isProtected() check into transcription and talk pages.

  • Loading branch information...
1 parent ea2b402 commit b7393c683d5eccd36cf0028eb792f004bed3a1b8 Jim Safley committed Apr 29, 2011
Showing with 40 additions and 20 deletions.
  1. +40 −20 lib/Scripto/Document.php
View
@@ -431,33 +431,29 @@ public function unprotectPage()
}
/**
- * Determine whether the current page is edit protected.
+ * Determine whether the current transcription page is edit protected.
*
* @return bool
*/
- public function pageIsProtected()
+ public function isProtectedTranscriptionPage()
{
if (is_null($this->_pageId)) {
- throw new Scripto_Exception('The document page must be set before determining whether it is protected.');
- }
-
- $pageProtections = $this->_transcriptionPageInfo['protections'];
-
- // There are no protections.
- if (empty($pageProtections)) {
- return false;
+ throw new Scripto_Exception('The document page must be set before determining whether the transcription page is protected.');
}
-
- // Iterate the page protections.
- foreach ($pageProtections as $pageProtection) {
- // The page is edit protected.
- if ('edit' == $pageProtection['type'] || 'create' == $pageProtection['type']) {
- return true;
- }
+ return $this->_isProtectedPage($this->_transcriptionPageInfo['protections']);
+ }
+
+ /**
+ * Determine whether the current talk page is edit protected.
+ *
+ * @return bool
+ */
+ public function isProtectedTalkPage()
+ {
+ if (is_null($this->_pageId)) {
+ throw new Scripto_Exception('The document page must be set before determining whether the talk page is protected.');
}
-
- // There are no edit protections.
- return false;
+ return $this->_isProtectedPage($this->_talkPageInfo['protections']);
}
/**
@@ -589,6 +585,30 @@ protected function _canEdit(array $pageProtections)
return true;
}
+ /**
+ * Determine whether the current page is edit protected.
+ *
+ * @return bool
+ */
+ protected function _isProtectedPage(array $pageProtections)
+ {
+ // There are no protections.
+ if (empty($pageProtections)) {
+ return false;
+ }
+
+ // Iterate the page protections.
+ foreach ($pageProtections as $pageProtection) {
+ // The page is edit protected.
+ if ('edit' == $pageProtection['type'] || 'create' == $pageProtection['type']) {
+ return true;
+ }
+ }
+
+ // There are no edit protections.
+ return false;
+ }
+
/**
* Get information for the specified page.
*

0 comments on commit b7393c6

Please sign in to comment.