Пример #1
0
 /**
  * getPageChangeEmails($notify)
  * @param  $notify: hash ( page => (userid => userhash) )
  * @return array
  *         unique array of ($emails, $userids)
  */
 function getPageChangeEmails($notify)
 {
     global $request;
     $emails = array();
     $userids = array();
     foreach ($notify as $page => $users) {
         if (glob_match($page, $this->pagename)) {
             global $request;
             $curuser = $request->getUser();
             $curusername = $curuser->UserName();
             $curuserprefs = $curuser->getPreferences();
             $curuserprefsemail = $curuserprefs->get('email');
             $ownModifications = $curuserprefs->get('ownModifications');
             $majorModificationsOnly = $curuserprefs->get('majorModificationsOnly');
             foreach ($users as $userid => $user) {
                 $usermail = $user['email'];
                 if ($usermail == $curuserprefsemail and $ownModifications) {
                     // It's my own modification
                     // and I do not want to receive it
                     continue;
                 }
                 if ($majorModificationsOnly) {
                     $backend =& $request->_dbi->_backend;
                     $version = $backend->get_latest_version($this->pagename);
                     $versiondata = $backend->get_versiondata($this->pagename, $version, true);
                     if ($versiondata['is_minor_edit']) {
                         // It's a minor modification
                         // and I do not want to receive it
                         continue;
                     }
                 }
                 if (!$user) {
                     // handle the case for ModeratePage:
                     // no prefs, just userid's.
                     $emails[] = $this->userEmail($userid, false);
                     $userids[] = $userid;
                 } else {
                     if (!empty($user['verified']) and !empty($user['email'])) {
                         $emails[] = $user['email'];
                         $userids[] = $userid;
                     } elseif (!empty($user['email'])) {
                         // do a dynamic emailVerified check update
                         $email = $this->userEmail($userid, true);
                         if ($email) {
                             $notify[$page][$userid]['verified'] = 1;
                             $request->_dbi->set('notify', $notify);
                             $emails[] = $email;
                             $userids[] = $userid;
                         }
                     }
                     // ignore verification
                     /*
                     if (DEBUG) {
                         if (!in_array($user['email'], $emails))
                             $emails[] = $user['email'];
                     }
                     */
                 }
             }
         }
     }
     $this->emails = array_unique($emails);
     $this->userids = array_unique($userids);
     return array($this->emails, $this->userids);
 }
Пример #2
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);
 }
Пример #3
0
 function getPageChangeEmails($notify)
 {
     $emails = array();
     $userids = array();
     foreach ($notify as $page => $users) {
         if (glob_match($page, $this->_pagename)) {
             foreach ($users as $userid => $user) {
                 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[] = $prefs->get('email');
                     $userids[] = $userid;
                 } else {
                     if (!empty($user['verified']) and !empty($user['email'])) {
                         $emails[] = $user['email'];
                         $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['email'];
                                 $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['email'];
                                 $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);
 }
Пример #4
0
 function allPagesByCreator($wildcard, $include_empty = false, $sortby = false, $limit = false, $exclude = false)
 {
     $dbi = $GLOBALS['request']->getDbh();
     $allPagehandles = $dbi->getAllPages($include_empty, $sortby, $limit, $exclude);
     $allPages = array();
     if ($wildcard === '[]') {
         $wildcard = $GLOBALS['request']->_user->getAuthenticatedId();
         if (!$wildcard) {
             return $allPages;
         }
     }
     $do_glob = preg_match('/[\\?\\*]/', $wildcard);
     while ($pagehandle = $allPagehandles->next()) {
         $name = $pagehandle->getName();
         $creator = $pagehandle->getCreator();
         if ($creator) {
             if ($do_glob) {
                 if (glob_match($wildcard, $creator)) {
                     $allPages[] = $name;
                 }
             } elseif ($wildcard == $creator) {
                 $allPages[] = $name;
             }
         }
     }
     return $allPages;
 }
Пример #5
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->args = $this->getArgs($argstr, $request);
     extract($this->args);
     $this->request =& $request;
     if (!$from_lang) {
         $from_lang = $request->getPref('lang');
     }
     if (!$from_lang) {
         $from_lang = $GLOBALS['LANG'];
     }
     $this->lang = $from_lang;
     if (empty($languages)) {
         $available_languages = listAvailableLanguages();
         if ($from_lang == 'en') {
             // "en" is always the first.
             array_shift($available_languages);
         }
         // put from_lang to the very end.
         if (in_array($from_lang, $available_languages)) {
             $languages = $available_languages;
         } else {
             $languages = array_merge($available_languages, array($from_lang));
         }
     } elseif (strstr($languages, ',')) {
         $languages = explode(',', $languages);
     } else {
         $languages = array($languages);
     }
     if (in_array('zh', $languages) or in_array('ja', $languages)) {
         // If the current charset != utf-8 the text will not be displayed correctly.
         // But here we cannot change the header anymore. So we can decide to ignore them,
         // or display them with all the errors.
         //FIXME: do iconv the ob
         if ($GLOBALS['charset'] != 'utf-8' and !defined('NEED_ICONV_TO')) {
             define('NEED_ICONV_TO', 'utf-8');
             //either the extension or external
             //$GLOBALS['charset'] = 'utf-8';
         }
     }
     $to_lang = $languages[0];
     if (!empty($string) and count($languages) == 1) {
         return $this->translate($string, $to_lang, $from_lang);
     }
     if (!empty($page)) {
         $pagename = $page;
         if ($dbi->isWikiPage($pagename)) {
             $url = '';
             // google can only translate from english and french
             if (in_array($from_lang, array('en', 'fr'))) {
                 $url = "http://translate.google.com/translate";
                 $url .= "?langpair=" . urlencode($from_lang . "|" . $to_lang);
                 $url .= "&u=" . urlencode(WikiURL($pagename, false, true));
             }
             // redirect or transclude?
             if ($url) {
                 return $request->redirect($url);
             }
             return HTML(fmt("TODO: Google can only translate from english and french. Find a translation service for %s to language %s", WikiURL($pagename, false, true), $to_lang));
         } else {
             return $this->error(fmt("%s is empty", $pagename));
         }
     }
     $pagelist = new PageList('', $exclude, $this->args);
     $pagelist->_columns[0]->_heading = "{$from_lang}";
     foreach ($languages as $lang) {
         if ($lang == $from_lang) {
             continue;
         }
         $field = "custom:{$lang}";
         $pagelist->addColumnObject(new _PageList_Column_customlang($field, $from_lang, $this));
     }
     if (!empty($string)) {
         $pagelist->addPage($string);
         return $pagelist;
     }
     switch ($what) {
         case 'allpages':
             $pagelist->addPages($dbi->getAllPages($include_empty, $sortby, $limit, $exclude));
             break;
         case 'pages':
             // not all pages, only the pgsrc pages
             if (!is_array($exclude)) {
                 $exclude = $pagelist->explodePageList($exclude, false, $sortby, $limit, $exclude);
             }
             $path = FindLocalizedFile(WIKI_PGSRC);
             $pgsrc = new fileSet($path);
             foreach ($pgsrc->getFiles($exclude, $sortby, $limit) as $pagename) {
                 $pagename = urldecode($pagename);
                 if (substr($pagename, -1, 1) == '~') {
                     continue;
                 }
                 if (in_array($pagename, $exclude)) {
                     continue;
                 }
                 // exclude page.
                 if ($match != '*' and !glob_match($match, $pagename)) {
                     continue;
                 }
                 $page_handle = $dbi->getPage($pagename);
                 $pagelist->addPage($page_handle);
             }
             break;
         case 'wikiwords':
             if (!isset($this->_locales[$from_lang])) {
                 $this->init_locale($from_lang);
             }
             $locale =& $this->_locales[$from_lang];
             if (is_array($locale)) {
                 $count = 0;
                 foreach ($locale as $from => $to) {
                     if ($match != '*' and !glob_match($match, $from)) {
                         continue;
                     }
                     if (isWikiWord($from)) {
                         $count++;
                         $pagelist->addPage($from);
                         if ($limit and $count > $limit) {
                             break;
                         }
                     }
                 }
             }
             break;
             // all Button texts, which need a localized .png
             // where to get them from? templates/*.tmpl: Button()
             // and WikiLink(?,'button')
             // navbar links, actionpages, and admin requests
         // all Button texts, which need a localized .png
         // where to get them from? templates/*.tmpl: Button()
         // and WikiLink(?,'button')
         // navbar links, actionpages, and admin requests
         case 'buttons':
             $buttons = $GLOBALS['AllActionPages'];
             $fileset = new FileSet(FindFile("themes/MacOSX/buttons/en"), "*.png");
             foreach ($fileset->getFiles() as $file) {
                 $b = urldecode(substr($file, 0, -4));
                 if (!in_array($b, $buttons)) {
                     $buttons[] = $b;
                 }
             }
             $count = 0;
             foreach ($buttons as $button) {
                 $pagelist->addPage($button);
                 if ($limit and ++$count > $limit) {
                     break;
                 }
             }
             break;
     }
     return $pagelist;
 }