Пример #1
0
 function getContent()
 {
     $hp = Codendi_HTMLPurifier::instance();
     $content = '';
     $p = new WikiPage($this->wikipage_group_id, $this->wikipage_wiki_page);
     //Todo: prevent wiki initialisation
     //Todo: prevent whole wiki permission bypassing
     //Todo: fix internal link (make them link to /wiki/ instead of current location (eg: /my/widgets )
     //Todo: display a link to go to the page
     //Todo: check that page exists before doing something
     if ($p->isAutorized(UserManager::instance()->getCurrentUser()->getId())) {
         $content .= $p->render($lite = true, $full_screen = true);
     }
     return $content;
 }
 /** @return PaginatedWikiPages */
 public function getPaginatedUserPages(PFUser $user, $project_id, $limit, $offset, $pagename)
 {
     $pages = array();
     if ($pagename !== '') {
         $row_pages = $this->dao->searchPaginatedUserWikiPagesByPagename($project_id, $limit, $offset, $pagename);
     } else {
         $row_pages = $this->dao->searchPaginatedUserWikiPages($project_id, $limit, $offset);
     }
     $total_size = (int) $this->dao->foundRows();
     foreach ($row_pages as $page) {
         $wiki_page = new WikiPage($project_id, $page['pagename']);
         if ($wiki_page->isAutorized($user->getId())) {
             $pages[] = $wiki_page;
         }
     }
     return new PaginatedWikiPages($pages, $total_size);
 }
Пример #3
0
 /**
  * _buildPageLink - private
  *
  * @param  WikiPage $wikiPage
  * @param  string   $title
  * @return string   $href
  */
 function _buildPageLink(&$wikiPage, $title = null)
 {
     $href = '';
     // Check permission
     if ($wikiPage->isAutorized(user_getid())) {
         $pagename = $wikiPage->getPagename();
         // Build page link
         if (empty($title)) {
             $title = $pagename;
         }
         $link = '/wiki/index.php?group_id=' . $this->gid . '&pagename=' . urlencode($pagename);
         // Display title as emphasis if corresponding page does't exist.
         if ($wikiPage->isEmpty()) {
             $title = '<em>' . $title . '</em>';
             $link .= '&action=edit';
         }
         // Build Lock image if a permission is set on the corresponding page
         if ($wikiPage->permissionExist()) {
             $permLink = $this->wikiLink . '&view=pagePerms&id=' . $wikiPage->getId();
             $title = $title . '<img src="' . util_get_image_theme("ic/lock.png") . '" border="0" alt="Lock" />';
         }
         $href = '<a href="' . $link . '">' . $title . '</a>';
     }
     return $href;
 }
Пример #4
0
 function getPageChangeEmails($notify)
 {
     $emails = array();
     $userids = array();
     foreach ($notify as $page => $users) {
         if (glob_match($page, $this->_pagename)) {
             foreach ($users as $userid => $user) {
                 $um = UserManager::instance();
                 $dbUser = $um->getUserByUserName($userid);
                 $wiki = new Wiki($_REQUEST['group_id']);
                 $wp = new WikiPage($_REQUEST['group_id'], $_REQUEST['pagename']);
                 if ($dbUser && ($dbUser->isActive() || $dbUser->isRestricted()) && $wiki->isAutorized($dbUser->getId()) && $wp->isAutorized($dbUser->getId())) {
                     if (!$user) {
                         // handle the case for ModeratePage: no prefs, just userid's.
                         global $request;
                         $u = $request->getUser();
                         if ($u->UserName() == $userid) {
                             $prefs = $u->getPreferences();
                         } else {
                             // not current user
                             if (ENABLE_USER_NEW) {
                                 $u = WikiUser($userid);
                                 $u->getPreferences();
                                 $prefs =& $u->_prefs;
                             } else {
                                 $u = new WikiUser($GLOBALS['request'], $userid);
                                 $prefs = $u->getPreferences();
                             }
                         }
                         $emails[] = user_getemail_from_unix($userid);
                         $userids[] = $userid;
                     } else {
                         if (!empty($user['verified']) and !empty($user['email'])) {
                             $emails[] = user_getemail_from_unix($userid);
                             $userids[] = $userid;
                         } elseif (!empty($user['email'])) {
                             global $request;
                             // do a dynamic emailVerified check update
                             $u = $request->getUser();
                             if ($u->UserName() == $userid) {
                                 if ($request->_prefs->get('emailVerified')) {
                                     $emails[] = user_getemail_from_unix($userid);
                                     $userids[] = $userid;
                                     $notify[$page][$userid]['verified'] = 1;
                                     $request->_dbi->set('notify', $notify);
                                 }
                             } else {
                                 // not current user
                                 if (ENABLE_USER_NEW) {
                                     $u = WikiUser($userid);
                                     $u->getPreferences();
                                     $prefs =& $u->_prefs;
                                 } else {
                                     $u = new WikiUser($GLOBALS['request'], $userid);
                                     $prefs = $u->getPreferences();
                                 }
                                 if ($prefs->get('emailVerified')) {
                                     $emails[] = user_getemail_from_unix($userid);
                                     $userids[] = $userid;
                                     $notify[$page][$userid]['verified'] = 1;
                                     $request->_dbi->set('notify', $notify);
                                 }
                             }
                             // ignore verification
                             /*
                             if (DEBUG) {
                                 if (!in_array($user['email'],$emails))
                                     $emails[] = $user['email'];
                             }
                             */
                         }
                     }
                 }
             }
         }
     }
     $emails = array_unique($emails);
     $userids = array_unique($userids);
     return array($emails, $userids);
 }
Пример #5
0
 /**
  * Check access permissions for wiki and wiki pages.
  *
  * Check restriction for:
  *  wiki: whole wiki can be restricted.
  *  wikipage: each page of the wiki can be restricted.
  */
 function checkPermissions()
 {
     // Check if user can access to whole wiki
     if (!$this->wiki->isAutorized(user_getid())) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('wiki_wikiservice', 'acces_denied_whole', session_make_url("/project/memberlist.php?group_id=" . $this->gid)), CODENDI_PURIFIER_DISABLED);
         exit_permission_denied();
     }
     // Check if user can access to selected page
     if (!empty($_REQUEST['pagename'])) {
         $wp = new WikiPage($this->gid, $_REQUEST['pagename']);
         if (!$wp->isAutorized(user_getid())) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('wiki_wikiservice', 'acces_denied_page', session_make_url("/project/memberlist.php?group_id=" . $this->gid)), CODENDI_PURIFIER_DISABLED);
             exit_permission_denied();
         }
     }
 }