コード例 #1
0
ファイル: ModuleProcessor.php プロジェクト: jbzdak/wikidot
 public function renderModule1($matches)
 {
     try {
         $out = $this->renderModule($matches[1], $matches[2]);
     } catch (Exception $e) {
         $p = new ProcessExceptionHandler();
         $out = $p->handleInlineModule($e, OZONE::getRunData());
     }
     return $out;
 }
コード例 #2
0
ファイル: DB_Notification.php プロジェクト: jbzdak/wikidot
 public function getUrls()
 {
     $type = $this->getType();
     $extra = $this->getExtra();
     if ($extra['urls']) {
         return $extra['urls'];
     }
     $lang = OZONE::getRunData()->getLanguage();
     switch ($type) {
         case 'new_private_message':
             $urls = array(array(_('read the message'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/messages/inboxmessage/' . $extra['message_id']), array(_('inbox folder'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/messages'));
             break;
         case 'new_membership_invitation':
             $urls = array(array(_('view invitation'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/invitations'));
             break;
         case 'removed_from_members':
             $urls = array(array(_('sites you are a member of'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/memberof'));
             break;
         case 'added_to_moderators':
             $urls = array(array(_('sites you moderate'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/moderatorof'));
             break;
         case 'removed_from_moderators':
             $urls = array(array(_('sites you moderate'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/moderatorof'));
             break;
         case 'added_to_administrators':
             $urls = array(array(_('sites you administer'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/adminof'));
             break;
         case 'removed_from_administrators':
             $urls = array(array(_('sites you administer'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/adminof'));
             break;
         case 'membership_application_accepted':
             $urls = array(array(_('your applications'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/applications'), array(_('sites you are a member of'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/memberof'));
             break;
         case 'membership_application_declined':
             $urls = array(array(_('your applications'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/applications'), array(_('sites you are a member of'), 'http://' . GlobalProperties::$URL_HOST . '/account:you/start/memberof'));
             break;
     }
     return $urls;
 }
コード例 #3
0
ファイル: EventLogger.php プロジェクト: jbzdak/wikidot
 private function newEvent()
 {
     $event = new DB_LogEvent();
     $event->setDate(new ODate());
     // now to make things easier dig into some global variables and set what is needed
     $runData = OZONE::getRunData();
     //site
     $site = $runData->getTemp("site");
     $event->setSiteId($site->getSiteId());
     $event->setTemp("site", $site);
     // user_id (if any)
     $event->setUserId($runData->getUserId());
     $event->setTemp("user", $runData->getUser());
     //ip address
     list($ip, $proxy) = explode("|", $runData->createIpString());
     $event->setIp($ip);
     $event->setProxy($proxy);
     // user agent
     $event->setUserAgent($_SERVER['HTTP_USER_AGENT']);
     return $event;
 }
コード例 #4
0
ファイル: WDDigestSender.php プロジェクト: jbzdak/wikidot
 public function handleUser($user)
 {
     $db = Database::connection();
     $db->begin();
     $c = new Criteria();
     $c->add("user_id", $user->getUserId());
     $c->add("notify_email", true);
     $c->addOrderAscending("notification_id");
     $nots = DB_NotificationPeer::instance()->select($c);
     if (count($nots) == 0) {
         $db->commit();
         return;
     }
     if (count($nots) > 0) {
         $q = "UPDATE notification SET notify_email=FALSE " . "WHERE user_id='" . $user->getUserId() . "' AND " . "notify_email = TRUE";
         $db->query($q);
     }
     // set language
     $lang = $user->getLanguage();
     OZONE::getRunData()->setLanguage($lang);
     $GLOBALS['lang'] = $lang;
     // and for gettext too:
     switch ($lang) {
         case 'pl':
             $glang = "pl_PL";
             break;
         case 'en':
             $glang = "en_US";
             break;
     }
     putenv("LANG={$glang}");
     putenv("LANGUAGE={$glang}");
     setlocale(LC_ALL, $glang . '.UTF-8');
     $nots2 = array();
     foreach ($nots as &$not) {
         if ($not->getType() == "new_private_message") {
             // check if the message is read or still new
             $extra = $not->getExtra();
             $pm = DB_PrivateMessagePeer::instance()->selectByPrimaryKey($extra['message_id']);
             if ($pm && $pm->getFlagNew()) {
                 $body = $not->getBody();
                 $body = preg_replace('/<br\\/>Preview.*$/sm', '', $body);
                 $body = preg_replace(';You have.*?<br/>;sm', '', $body);
                 $not->setBody($body);
                 $nots2[] = $not;
             }
         } else {
             $nots2[] = $not;
         }
     }
     $count = count($nots2);
     // now send an email
     $oe = new OzoneEmail();
     $oe->addAddress($user->getName());
     $oe->setSubject(sprintf(_("%s Account Notifications"), GlobalProperties::$SERVICE_NAME));
     $oe->contextAdd('user', $user);
     $oe->contextAdd('notifications', $nots2);
     $oe->contextAdd('count', $count);
     $oe->setBodyTemplate('DigestEmail');
     if (!$oe->send()) {
         throw new ProcessException("The email can not be sent to address " . $user->getName(), "email_failed");
     }
     $db->commit();
 }
コード例 #5
0
 public function getUrls()
 {
     $type = $this->getType();
     $extra = $this->getExtra();
     if ($extra['urls']) {
         return $extra['urls'];
     }
     $lang = OZONE::getRunData()->getLanguage();
     $site = OZONE::getRunData()->getTemp("site");
     switch ($type) {
         case 'NEW_MEMBER_APPLICATION':
             $urls = array(array(_('check pending applications'), 'http://' . $site->getDomain() . '/admin:manage/start/ma'));
             break;
         case 'INVITATION_ACCEPTED':
             $urls = array(array(_('site members'), 'http://' . $site->getDomain() . '/admin:manage/start/members-list'));
             break;
         case 'INVITATION_DECLINED':
             break;
         case 'NEW_MEMBER_BY_PASSWORD':
             $urls = array(array('_(site members)', 'http://' . $site->getDomain() . '/admin:manage/start/members-list'));
             break;
         case 'MEMBER_RESIGNED':
             $urls = array(array(_('site members'), 'http://' . $site->getDomain() . '/admin:manage/start/members-list'));
             break;
         case 'MODERATOR_RESIGNED':
             $urls = array(array(_('site moderators'), 'http://' . $site->getDomain() . '/admin:manage/start/moderators'), array(_('site members'), 'http://' . $site->getDomain() . '/admin:manage/start/members-list'));
             break;
         case 'ADMIN_RESIGNED':
             $urls = array(array(_('site adminitrators'), 'http://' . $site->getDomain() . '/admin:manage/start/admins'), array(_('site members'), 'http://' . $site->getDomain() . '/admin:manage/start/members-list'));
             break;
     }
     return $urls;
 }