Example #1
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $categoryName = $pl->getParameterValue("category", "MODULE", "AMODULE");
     $details = $pl->getParameterValue("details", "MODULE", "AMODULE");
     $preview = $pl->getParameterValue("preview", "MODULE", "AMODULE");
     $order = $pl->getParameterValue("order", "MODULE", "AMODULE");
     $limit = $pl->getParameterValue("limit", "MODULE", "AMODULE");
     if ($categoryName !== null) {
         $category = DB_CategoryPeer::instance()->selectByName($categoryName, $site->getSiteId());
         if ($category == null) {
             throw new ProcessException(_("The category can not be found."));
         }
     }
     // now select pages according to the specified criteria
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     if ($category) {
         $c->add("category_id", $category->getCategoryId());
     }
     switch ($order) {
         case 'dateCreatedDesc':
             $c->addOrderDescending('page_id');
             break;
         case 'dateCreatedAsc':
             $c->addOrderAscending('page_id');
             break;
         case 'dateEditedDesc':
             $c->addOrderDescending('date_last_edited');
             break;
         case 'dateEditedAsc':
             $c->addOrderAscending('date_last_edited');
             break;
         case 'titleDesc':
             $c->addOrderDescending("COALESCE(title, unix_name)");
             break;
         default:
             $c->addOrderAscending("COALESCE(title, unix_name)");
     }
     if ($limit && is_numeric($limit) && $limit > 0) {
         $c->setLimit($limit);
     }
     $pages = DB_PagePeer::instance()->select($c);
     // by default cathegorize by first letter...
     $runData->contextAdd("pages", $pages);
     $runData->contextAdd("details", $details);
     $runData->contextAdd("preview", $preview);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $limit = $pl->getParameterValue("limit", "MODULE");
     if ($limit == null || !is_numeric($limit) || $limit < 1 || $limit > 300) {
         $limit = 5;
     }
     $categoryId = $pl->getParameterValue("categoryId", "MODULE", "AMODULE");
     if ($categoryId !== null) {
         $category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
         if ($category == null || $category->getSiteId() != $site->getSiteId()) {
             throw new ProcessException(_("The category can not be found."));
         }
     }
     // get recent forum posts
     $c = new Criteria();
     $c->add("forum_post.site_id", $site->getSiteId());
     if ($category) {
         $c->add("forum_post.category_id", $category->getCategoryId());
     }
     $c->addJoin("thread_id", "forum_thread.thread_id");
     $c->addOrderDescending("post_id");
     $c->setLimit($limit);
     $posts = DB_ForumPostPeer::instance()->select($c);
     $runData->contextAdd("posts", $posts);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     // now just get notifications for the site...
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderDescending('notification_id');
     $c->setLimit(20);
     $nots = DB_AdminNotificationPeer::instance()->select($c);
     $channel['title'] = _('Admin notifications for site') . ' "' . htmlspecialchars($site->getName()) . '"';
     $channel['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications";
     $items = array();
     foreach ($nots as $not) {
         $extra = $not->getExtra();
         $item = array();
         $item['title'] = $not->getTitle();
         switch ($not->getType()) {
             case "NEW_MEMBER_APPLICATION":
                 $item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/ma";
                 break;
             default:
                 $item['link'] = "http://" . $site->getDomain() . "/admin:manage/start/notifications" . "#notification-" . $not->getNotificationId();
         }
         $body = $not->getBody();
         $body = preg_replace('/onclick="[^"]+"/', '', $body);
         $item['description'] = $body;
         $item['guid'] = $channel['link'] . "#notification-" . $not->getNotificationId();
         $item['date'] = date('r', $not->getDate()->getTimestamp());
         // TODO: replace relative links with absolute links!
         $content = '';
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
Example #4
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $threadId = $pl->getParameterValue("threadId");
     $site = $runData->getTemp("site");
     $db = Database::connection();
     $db->begin();
     $thread = DB_ForumThreadPeer::instance()->selectByPrimaryKey($threadId);
     if ($thread == null || $thread->getSiteId() !== $site->getSiteId()) {
         throw new ProcessException(_("No thread found... Is it deleted?"), "no_thread");
     }
     $category = $thread->getForumCategory();
     WDPermissionManager::instance()->hasForumPermission('moderate_forum', $runData->getUser(), $category);
     $runData->contextAdd("thread", $thread);
     $runData->contextAdd("category", $thread->getForumCategory());
     // and select categories to move into too.
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderDescending("visible");
     $c->addOrderAscending("sort_index");
     $groups = DB_ForumGroupPeer::instance()->select($c);
     $res = array();
     foreach ($groups as $g) {
         $c = new Criteria();
         $c->add("group_id", $g->getGroupId());
         $c->addOrderAscending("sort_index");
         $categories = DB_ForumCategoryPeer::instance()->select($c);
         foreach ($categories as $cat) {
             $res[] = array('group' => $g, 'category' => $cat);
         }
     }
     $runData->contextAdd("categories", $res);
     $db->commit();
 }
Example #5
0
 public function build($runData)
 {
     $userId = $runData->getUserId();
     $pl = $runData->getParameterList();
     $messageId = $pl->getParameterValue("message_id");
     $message = DB_PrivateMessagePeer::instance()->selectByPrimaryKey($messageId);
     if ($message->getFromUserId() != $userId) {
         throw new ProcessException(_("Error selecting message."), "no_message");
     }
     $runData->contextAdd("message", $message);
     // get next & previous message
     $messageId = $message->getMessageId();
     $c = new Criteria();
     $c->add("from_user_id", $userId);
     $c->add("message_id", $messageId, ">");
     $c->add("flag", 1);
     $c->addOrderAscending("message_id");
     $newerMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
     $c = new Criteria();
     $c->add("from_user_id", $userId);
     $c->add("message_id", $messageId, "<");
     $c->add("flag", 1);
     $c->addOrderDescending("message_id");
     $olderMessage = DB_PrivateMessagePeer::instance()->selectOne($c);
     $runData->contextAdd("newerMessage", $newerMessage);
     $runData->contextAdd("olderMessage", $olderMessage);
 }
 public function run()
 {
     // check!
     $c = new Criteria();
     $c->add("status", null);
     $c->addOrderDescending("backup_id");
     $sb = DB_SiteBackupPeer::instance()->selectOne($c);
     // select only one!
     if (!$sb) {
         return;
     }
     $db = Database::connection();
     $sb->setStatus("started");
     $sb->save();
     $db->begin();
     try {
         $b = new Backuper();
         $b->setConfig($sb);
         $b->backup();
         // check
         $sb->setStatus("completed");
         $sb->setDate(new ODate());
         $sb->setRand($b->getRand());
         $sb->save();
     } catch (Exception $e) {
         $sb->setStatus("failed");
         $sb->save();
     }
     $db->commit();
 }
Example #7
0
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     // get the petition campaign...
     $campaignId = $pl->getParameterValue("id");
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->add("deleted", false);
     $c->add("identifier", $campaignId);
     $camp = DB_PetitionCampaignPeer::instance()->selectOne($c);
     if (!$camp) {
         throw new ProcessException(_("The campaign can not be found."));
     }
     // get signatures!
     $limit = $pl->getParameterValue("limit");
     if ($limit === null || !is_numeric($limit)) {
         $limit = 50;
     }
     $c = new Criteria();
     $c->add("campaign_id", $camp->getCampaignId());
     $c->add("confirmed", true);
     $c->addOrderDescending("signature_id");
     if ($limit > 0) {
         $c->setLimit($limit);
     }
     $signatures = DB_PetitionSignaturePeer::instance()->select($c);
     $runData->contextAdd("signatures", $signatures);
     $runData->contextAdd("campaign", $camp);
 }
Example #8
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $c = new Criteria();
     $c->addJoin("page_id", "page.page_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->add("page.site_id", $site->getSiteId());
     $c->addOrderDescending("page_revision.revision_id");
     $c->setLimit(30);
     $revisions = DB_PageRevisionPeer::instance()->select($c);
     $channel['title'] = _('Recent page changes from site') . ' "' . htmlspecialchars($site->getName()) . '" (a Wikidot site)';
     $channel['link'] = "http://" . $site->getDomain();
     $items = array();
     foreach ($revisions as $rev) {
         $page = $rev->getPage();
         $item = array();
         $item['link'] = 'http://' . $site->getDomain() . '/' . $page->getUnixName();
         $desc = '';
         $flags = array();
         if ($rev->getFlagText()) {
             $flags[] = _("source change");
         }
         if ($rev->getFlagTitle()) {
             $flags[] = _("title change");
         }
         if ($rev->getFlagFile()) {
             $flags[] = _("file action");
         }
         if ($rev->getFlagRename()) {
             $flags[] = _("page move/rename");
         }
         if ($rev->getFlagMeta()) {
             $flags[] = _("metadata changed");
         }
         if ($rev->getFlagNew()) {
             $flags[] = _("new page");
         }
         $item['title'] = '"' . $page->getTitleOrUnixName() . '" - ' . implode(', ', $flags);
         $desc = '';
         $desc .= _('Page') . ': <a href="http://' . $site->getDomain() . '/' . $page->getUnixName() . '">' . htmlspecialchars($page->getTitle()) . '</a> (' . $page->getUnixName() . ')<br/>';
         $desc .= _('Current revision number') . ': ' . $rev->getRevisionNumber() . '<br/>';
         $desc .= _('Date changed') . ': ' . date('r', $rev->getDateLastEdited()->getTimestamp()) . '<br/>';
         $desc .= _('Change type') . ': ' . implode(', ', $flags) . '<br/>';
         if ($rev->getComments()) {
             $desc .= _('Change comments') . ': ' . htmlspecialchars($rev->getComments()) . '<br/>';
         }
         $desc .= _('By') . ': ' . WDRenderUtils::renderUser($rev->getUserOrString()) . '<br/>';
         $desc .= '<br/>' . _('Page content preview') . ': <br/>' . $page->getPreview();
         $item['description'] = $desc;
         $item['content'] = $desc;
         $item['guid'] = $item['link'] . "#revision-" . $rev->getRevisionId();
         $item['date'] = date('r', $rev->getDateLastEdited()->getTimestamp());
         $content = '';
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
 public function build($runData)
 {
     // find all current applications
     $c = new Criteria();
     $c->add("site_id", $runData->getTemp("site")->getSiteId());
     $c->add("status", "pending");
     $c->addOrderDescending("application_id");
     $applications = DB_MemberApplicationPeer::instance()->select($c);
     $runData->contextAdd("applications", $applications);
 }
Example #10
0
 public function build($runData)
 {
     // get current blocks!
     $c = new Criteria();
     $c->add("user_id", $runData->getUserId());
     $c->addOrderDescending("block_id");
     $blocks = DB_PrivateUserBlockPeer::instance()->select($c);
     if (count($blocks) > 0) {
         $runData->contextAdd("blocks", $blocks);
     }
 }
Example #11
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $categoryId = $pl->getParameterValue("c");
     $channel = array();
     $channel['title'] = $site->getName() . " - " . _("new forum threads");
     $channel['link'] = "http://" . $site->getDomain() . "/forum/start";
     $channel['description'] = _("Threads in forums of the site") . " \"" . $site->getName() . "\"";
     if ($site->getSubtitle()) {
         $channel['description'] .= " - " . $site->getSubtitle();
     }
     $items = array();
     $c = new Criteria();
     $c->add("forum_thread.site_id", $site->getSiteId());
     $c->add("forum_group.visible", true);
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addJoin("forum_thread.category_id", "forum_category.category_id");
     $c->addJoin("forum_category.group_id", "forum_group.group_id");
     $c->addOrderDescending("thread_id");
     $c->setLimit(20);
     $threads = DB_ForumThreadPeer::instance()->select($c);
     foreach ($threads as $thread) {
         $item = array();
         $item['title'] = $thread->getTitle();
         $item['link'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle();
         $item['guid'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId();
         $item['date'] = date('r', $thread->getDateStarted()->getTimestamp());
         //replace relative links with absolute links!
         $post = $thread->getFirstPost();
         if (!$post) {
             continue;
         }
         $content = $post->getText();
         $content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
         $content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
         $content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
         if ($thread->getDescription()) {
             $item['description'] = $thread->getDescription();
         }
         $item['content'] = $content;
         if ($post->getUserId() > 0) {
             $item['authorUserId'] = $post->getUserId();
             $user = $post->getUser();
             $item['author'] = $user->getNickName();
         } else {
             $item['author'] = $post->getUserString();
         }
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
 public function build($runData)
 {
     // just get invitations
     $userId = $runData->getUserId();
     $c = new Criteria();
     $c->add("user_id", $userId);
     $c->addOrderDescending("invitation_id");
     $invs = DB_MemberInvitationPeer::instance()->select($c);
     if (count($invs) > 0) {
         $runData->contextAdd("invitations", $invs);
     }
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $userId = $pl->getParameterValue("userId");
     if ($runData->getUser() && $userId == $runData->getUser()->getUserId()) {
         $own = true;
     }
     $categoryId = $pl->getParameterValue("categoryId");
     $limit = $pl->getParameterValue("limit");
     if ($limit == null || !is_numeric($limit)) {
         $limit = 20;
     }
     $pageNumber = $pl->getParameterValue("page");
     $op = $pl->getParameterValue("options");
     if ($pageNumber === null) {
         $pageNumber = 1;
     }
     $perPage = $limit;
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     $c = new Criteria();
     if ($categoryId !== null && is_numeric($categoryId)) {
         $c->add("forum_thread.category_id", $categoryId);
     }
     $c->add("forum_post.user_id", $userId);
     if (!$own) {
         $c->add("site.private", false);
     }
     $c->addJoin("thread_id", "forum_thread.thread_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addJoin("forum_post.site_id", "site.site_id");
     $c->add("site.deleted", false);
     $c->addOrderDescending("post_id");
     $c->setLimit($count, $offset);
     $posts = DB_ForumPostPeer::instance()->select($c);
     $counted = count($posts);
     $pagerData = array();
     $pagerData['currentPage'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['knownPages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['totalPages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['totalPages'] = $totalPages;
     }
     $posts = array_slice($posts, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("posts", $posts);
 }
 public function build($runData)
 {
     // get current blocks!
     $site = $runData->getTemp("site");
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderDescending("block_id");
     $blocks = DB_IpBlockPeer::instance()->select($c);
     if (count($blocks) > 0) {
         $runData->contextAdd("blocks", $blocks);
     }
 }
Example #15
0
 public function build($runData)
 {
     $pageId = $runData->getParameterList()->getParameterValue("page_id");
     if (!$pageId || !is_numeric($pageId)) {
         throw new ProcessException(_("The page can not be found or does not exist."), "no_page");
     }
     $c = new Criteria();
     $c->add('page_id', $pageId);
     $c->addOrderDescending('revision_id');
     $pageRevisions = DB_PageRevisionPeer::instance()->select($c);
     $runData->contextAdd("pageRevisions", $pageRevisions);
 }
Example #16
0
 /**
  * Scans for the last post.
  */
 public function findLastPost()
 {
     $c = new Criteria();
     $c->add("category_id", $this->getCategoryId());
     $c->add("last_post_id", null, "!=");
     $c->addOrderDescending("last_post_id");
     $thread = DB_ForumThreadPeer::instance()->selectOne($c);
     if ($thread) {
         $this->setLastPostId($thread->getLastPostId());
     } else {
         $this->setLastPostId(null);
     }
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $categoryId = $pl->getParameterValue("c");
     $category = DB_ForumCategoryPeer::instance()->selectByPrimaryKey($categoryId);
     if ($category == null) {
         throw new ProcessException(_("No such category."), "no_category");
     }
     $channel = array();
     $channel['title'] = $category->getName() . " (new threads)";
     $channel['link'] = "http://" . $site->getDomain() . "/forum/c-" . $categoryId . "/" . $category->getUnixifiedName();
     $channel['description'] = _("Threads in the forum category") . " \"" . $category->getName() . "\"";
     if ($category->getDescription()) {
         $channel['description'] .= " - " . $category->getDescription();
     }
     $items = array();
     $c = new Criteria();
     $c->add("category_id", $categoryId);
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addOrderDescending("thread_id");
     $c->setLimit(20);
     $threads = DB_ForumThreadPeer::instance()->select($c);
     foreach ($threads as $thread) {
         $item = array();
         $item['title'] = $thread->getTitle();
         $item['link'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle();
         $item['guid'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId();
         $item['date'] = date('r', $thread->getDateStarted()->getTimestamp());
         //replace relative links with absolute links!
         $post = $thread->getFirstPost();
         $content = $post->getText();
         $content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
         $content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
         $content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
         if ($thread->getDescription()) {
             $item['description'] = $thread->getDescription();
         }
         $item['content'] = $content;
         if ($post->getUserId() > 0) {
             $item['authorUserId'] = $post->getUserId();
             $user = $post->getUser();
             $item['author'] = $user->getNickName();
         } else {
             $item['author'] = $post->getUserString();
         }
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     // get recent forum threads
     $pl = $runData->getParameterList();
     $limit = $pl->getParameterValue("limit", "MODULE");
     if ($limit == null || !is_numeric($limit) || $limit < 1 || $limit > 300) {
         $limit = 5;
     }
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderDescending("thread_id");
     $c->setLimit($limit);
     $threads = DB_ForumThreadPeer::instance()->select($c);
     $runData->contextAdd("threads", $threads);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $user = $runData->getUser();
     if (!$user) {
         $runData->setModuleTemplate("misc/AskToLoginModule");
         return;
     }
     // now get the ivitations!
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->add("user_id", $user->getUserId());
     $c->addOrderDescending("invitation_id");
     $invitations = DB_EmailInvitationPeer::instance()->select($c);
     $runData->contextAdd("invitations", $invitations);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $showAll = (bool) $runData->getParameterList()->getParameterValue("showAll");
     // get  invitations
     $c = new Criteria();
     if (!$showAll) {
         $q = "SELECT * FROM email_invitation, admin " . "WHERE admin.site_id='" . $site->getSiteId() . "' " . "AND email_invitation.site_id='" . $site->getSiteId() . "' " . "AND admin.user_id = email_invitation.user_id ORDER BY invitation_id DESC";
         $c->setExplicitQuery($q);
     } else {
         $c->add("site_id", $site->getSiteId());
         $c->addOrderDescending("invitation_id");
     }
     $invitations = DB_EmailInvitationPeer::instance()->select($c);
     $runData->contextAdd("invitations", $invitations);
     $runData->contextAdd("showAll", $showAll);
 }
Example #21
0
 public function build($runData)
 {
     $user = $runData->getUser();
     $pl = $runData->getParameterList();
     $pageNumber = $pl->getParameterValue("page");
     if ($pageNumber === null) {
         $pageNumber = 1;
     }
     $limit = $pl->getParameterValue("limit");
     if ($limit == null || !is_numeric($limit)) {
         $limit = 20;
     }
     $perPage = $limit;
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     // join the tables:
     // watched_page, page_revision, user, page, site. ???
     $c = new Criteria();
     $c->addJoin("page_id", "page.page_id");
     $c->addJoin("page_id", "watched_page.page_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->add("watched_page.user_id", $user->getUserId());
     $c->addOrderDescending("page_revision.revision_id");
     $c->setLimit($count, $offset);
     $revisions = DB_PageRevisionPeer::instance()->select($c);
     $counted = count($revisions);
     $pagerData = array();
     $pagerData['currentPage'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['knownPages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['totalPages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['totalPages'] = $totalPages;
     }
     $revisions = array_slice($revisions, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("revisions", $revisions);
 }
Example #22
0
 public function build($runData)
 {
     $user = $runData->getUser();
     $pl = $runData->getParameterList();
     $pageNumber = $pl->getParameterValue("page");
     if ($pageNumber === null) {
         $pageNumber = 1;
     }
     $limit = $pl->getParameterValue("limit");
     if ($limit == null || !is_numeric($limit)) {
         $limit = 20;
     }
     $perPage = $limit;
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     // join the tables: watched_forum_thread, forum_thread, forum_post, site, user???. OK???
     $c = new Criteria();
     $c->addJoin("thread_id", "forum_thread.thread_id");
     $c->addJoin("thread_id", "watched_forum_thread.thread_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->add("watched_forum_thread.user_id", $user->getUserId());
     $c->addOrderDescending("post_id");
     $c->setLimit($count, $offset);
     $posts = DB_ForumPostPeer::instance()->select($c);
     $counted = count($posts);
     $pagerData = array();
     $pagerData['currentPage'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['knownPages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['totalPages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['totalPages'] = $totalPages;
     }
     $posts = array_slice($posts, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("posts", $posts);
 }
 public function build($runData)
 {
     $pl = $runData->getParameterList();
     $postId = $pl->getParameterValue("postId");
     $site = $runData->getTemp("site");
     if ($postId == null || !is_numeric($postId)) {
         throw new ProcessException(_("No post specified."), "no_post");
     }
     $post = DB_ForumPostPeer::instance()->selectByPrimaryKey($postId);
     if ($post == null || $post->getSiteId() != $site->getSiteId()) {
         throw new ProcessException(_("No post specified."), "no_post");
     }
     // get all revisions
     $c = new Criteria();
     $c->add("post_id", $postId);
     $c->addOrderDescending("revision_id");
     $revs = DB_ForumPostRevisionPeer::instance()->select($c);
     $runData->contextAdd("revisions", $revs);
     $runData->contextAdd("post", $post);
     $runData->ajaxResponseAdd("postId", $postId);
 }
 public function build($runData)
 {
     $siteId = $runData->getTemp("site")->getSiteId();
     $pl = $runData->getParameterList();
     $pageNumber = $pl->getParameterValue("page");
     if ($pageNumber == null || !is_numeric($pageNumber) || $pageNumber < 1) {
         $pageNumber = 1;
     }
     // now just get notifications for the user...
     $perPage = 30;
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     $c = new Criteria();
     $c->add("site_id", $siteId);
     $c->addOrderDescending('notification_id');
     $c->setLimit($count, $offset);
     $nots = DB_AdminNotificationPeer::instance()->select($c);
     // now see if number of selected is equal $perPage + 1. If so -
     // there is at least 1 more page to show...
     $counted = count($nots);
     $pagerData = array();
     $pagerData['current_page'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['known_pages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['total_pages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['total_pages'] = $totalPages;
     }
     $nots = array_slice($nots, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("notifications", $nots);
     $runData->contextAdd("notificationsCount", count($nots));
 }
Example #25
0
 public function build($runData)
 {
     $user = $runData->getTemp("user");
     $userId = $user->getUserId();
     // set language for the user
     $lang = $user->getLanguage();
     $runData->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');
     // now just get watched page changes for the user...
     $c = new Criteria();
     $c->addJoin("page_id", "page.page_id");
     $c->addJoin("page_id", "watched_page.page_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->add("watched_page.user_id", $user->getUserId());
     $c->addOrderDescending("page_revision.revision_id");
     $c->setLimit(30);
     $revisions = DB_PageRevisionPeer::instance()->select($c);
     $channel['title'] = _('Wikidot.com watched pages changes for user') . ' "' . $user->getNickName() . '"';
     $channel['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/watched-changes";
     $items = array();
     foreach ($revisions as $rev) {
         $page = $rev->getPage();
         $site = $page->getSite();
         $item = array();
         $item['title'] = '"' . $page->getTitleOrUnixName() . '" ' . _('on site') . ' "' . $site->getName() . '"';
         $item['link'] = 'http://' . $site->getDomain() . '/' . $page->getUnixName();
         $desc = '';
         $flags = array();
         if ($rev->getFlagText()) {
             $flags[] = _("source change");
         }
         if ($rev->getFlagTitle()) {
             $flags[] = _("title change");
         }
         if ($rev->getFlagFile()) {
             $flags[] = _("file action");
         }
         if ($rev->getFlagRename()) {
             $flags[] = _("page move/rename");
         }
         if ($rev->getFlagMeta()) {
             $flags[] = _("metadata changed");
         }
         if ($rev->getFlagNew()) {
             $flags[] = _("new page");
         }
         $desc .= _('Site') . ': <a href="http://' . $site->getDomain() . '">' . htmlspecialchars($site->getName()) . '</a><br/>';
         $desc .= _('Page') . ': <a href="http://' . $site->getDomain() . '/' . $page->getUnixName() . '">' . htmlspecialchars($page->getTitle()) . '</a> (' . $page->getUnixName() . ')<br/>';
         $desc .= _('Current revision number') . ': ' . $rev->getRevisionNumber() . '<br/>';
         $desc .= _('Date changed') . ': ' . date('r', $rev->getDateLastEdited()->getTimestamp()) . '<br/>';
         $desc .= _('Change type') . ': ' . implode(', ', $flags) . '<br/>';
         if ($rev->getComments()) {
             $desc .= _('Change comments') . ': ' . htmlspecialchars($rev->getComments()) . '<br/>';
         }
         $desc .= _('By') . ': ' . WDRenderUtils::renderUser($rev->getUserOrString()) . '<br/>';
         $desc .= '<br/>' . _('Page content preview') . ': <br/>' . $page->getPreview();
         $item['description'] = $desc;
         $item['content'] = $desc;
         $item['guid'] = $channel['link'] . "#revision-" . $rev->getRevisionId();
         $item['date'] = date('r', $rev->getDateLastEdited()->getTimestamp());
         $content = '';
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
Example #26
0
 public function build($runData)
 {
     // select recent revisions...
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     // get options
     $pageNumber = $pl->getParameterValue("page");
     $op = $pl->getParameterValue("options");
     if ($pageNumber === null) {
         $pageNumber = 1;
     }
     if ($op) {
         $json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
         $o = $json->decode($op);
     }
     if (count($o) == 0) {
         $o['all'] == true;
     }
     $perPage = $pl->getParameterValue("perpage");
     if ($perPage == null) {
         $perPage = 20;
     }
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     $c = new Criteria();
     $c->add("page_revision.site_id", $site->getSiteId());
     if (!$o['all'] && count($o) > 0) {
         $c2 = new Criteria();
         if ($o['new']) {
             $c2->addOr("flag_new", true);
         }
         if ($o['source']) {
             $c2->addOr("flag_text", true);
         }
         if ($o['title']) {
             $c2->addOr("flag_title", true);
         }
         if ($o['move']) {
             $c2->addOr("flag_rename", true);
         }
         if ($o['meta']) {
             $c2->addOr("flag_meta", true);
         }
         if ($o['files']) {
             $c2->addOr("flag_file", true);
         }
         $c->addCriteriaAnd($c2);
     }
     $categoryId = $pl->getParameterValue("categoryId");
     if ($categoryId && is_numeric($categoryId)) {
         $c->add("page.category_id", $categoryId);
     }
     $c->addJoin("page_id", "page.page_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addOrderDescending("page_revision.revision_id");
     $c->setLimit($count, $offset);
     $revisions = DB_PageRevisionPeer::instance()->select($c);
     $counted = count($revisions);
     $pagerData = array();
     $pagerData['currentPage'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['knownPages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['totalPages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['totalPages'] = $totalPages;
     }
     $revisions = array_slice($revisions, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("revisions", $revisions);
     $runData->contextAdd("revisionsCount", count($revisions));
 }
 public function build($runData)
 {
     $user = $runData->getTemp("user");
     $userId = $user->getUserId();
     // set language for the user
     $lang = $user->getLanguage();
     $runData->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');
     // now just get notifications for the user...
     $c = new Criteria();
     $c->add("user_id", $userId);
     $c->addOrderDescending('notification_id');
     $c->setLimit(20);
     $nots = DB_NotificationPeer::instance()->select($c);
     $channel['title'] = sprintf(_('%s account notifications for user'), GlobalProperties::$SERVICE_NAME) . ' "' . htmlspecialchars($user->getNickName()) . '"';
     $channel['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/notifications";
     $items = array();
     foreach ($nots as $not) {
         $extra = $not->getExtra();
         $item = array();
         $item['title'] = $not->getTitle();
         switch ($not->getType()) {
             case "new_private_message":
                 $item['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/messages/inboxmessage/" . $extra['message_id'];
                 break;
             case "new_membership_invitation":
                 $item['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/invitations";
                 break;
             case 'membership_application_accepted':
                 $item['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/applications";
                 break;
             case 'membership_application_declined':
                 $item['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/applications";
                 break;
             default:
                 $item['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/notifications" . "#notification-" . $not->getNotificationId();
         }
         $body = $not->getBody();
         $body = preg_replace('/onclick="[^"]+"/', '', $body);
         $item['description'] = $body;
         $item['guid'] = $channel['link'] . "#notification-" . $not->getNotificationId();
         $item['date'] = date('r', $not->getDate()->getTimestamp());
         // TODO: replace relative links with absolute links!
         $content = '';
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }
Example #28
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("page_id");
     $pageNumber = $pl->getParameterValue("page");
     $perPage = $pl->getParameterValue("perpage");
     $json = new JSONService(SERVICES_JSON_LOOSE_TYPE);
     $o = $json->decode($pl->getParameterValue("options"));
     $offset = ($pageNumber - 1) * $perPage;
     $count = $perPage * 2 + 1;
     // get the page
     $page = DB_PagePeer::instance()->selectByPrimaryKey($pageId);
     if ($page == null || $page->getSiteId() !== $site->getSiteId()) {
         throw new ProcessException(_("Error selecting the page."), "no_page");
     }
     $c = new Criteria();
     $c->add('page_id', $pageId);
     // check options
     if (!$o['all'] && count($o) > 0) {
         $c2 = new Criteria();
         if ($o['new']) {
             $c2->addOr("flag_new", true);
         }
         if ($o['source']) {
             $c2->addOr("flag_text", true);
         }
         if ($o['title']) {
             $c2->addOr("flag_title", true);
         }
         if ($o['move']) {
             $c2->addOr("flag_rename", true);
         }
         if ($o['meta']) {
             $c2->addOr("flag_meta", true);
         }
         if ($o['files']) {
             $c2->addOr("flag_file", true);
         }
         $c->addCriteriaAnd($c2);
     }
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->addOrderDescending('revision_id');
     $c->setLimit($count, $offset);
     $pr = DB_PageRevisionPeer::instance()->select($c);
     // now see if number of selected is equal $perPage + 1. If so -
     // there is at least 1 more page to show...
     $counted = count($pr);
     $pagerData = array();
     $pagerData['current_page'] = $pageNumber;
     if ($counted > $perPage * 2) {
         $knownPages = $pageNumber + 2;
         $pagerData['known_pages'] = $knownPages;
     } elseif ($counted > $perPage) {
         $knownPages = $pageNumber + 1;
         $pagerData['total_pages'] = $knownPages;
     } else {
         $totalPages = $pageNumber;
         $pagerData['total_pages'] = $totalPages;
     }
     $pr = array_slice($pr, 0, $perPage);
     $runData->contextAdd("pagerData", $pagerData);
     $runData->contextAdd("page", $page);
     $runData->contextAdd("currentRevision", $page->getCurrentRevision());
     $runData->contextAdd("revisions", $pr);
 }
Example #29
0
 /** 
  * Scans for the last post.
  */
 public function findLastPost()
 {
     $c = new Criteria();
     $c->add("thread_id", $this->getThreadId());
     $c->addOrderDescending("post_id");
     $post = DB_ForumPostPeer::instance()->selectOne($c);
     if ($post) {
         $this->setLastPostId($post->getPostId());
     }
     return $post;
 }
Example #30
0
 public function build($runData)
 {
     $user = $runData->getTemp("user");
     $userId = $user->getUserId();
     // set language for the user
     $lang = $user->getLanguage();
     $runData->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');
     // now just get watched page changes for the user...
     $c = new Criteria();
     $c->addJoin("thread_id", "forum_thread.thread_id");
     $c->addJoin("thread_id", "watched_forum_thread.thread_id");
     $c->addJoin("user_id", "ozone_user.user_id");
     $c->add("watched_forum_thread.user_id", $user->getUserId());
     $c->addOrderDescending("post_id");
     $c->setLimit(30);
     $posts = DB_ForumPostPeer::instance()->select($c);
     $channel['title'] = _('Wikidot.com watched forum discussions for user') . ' "' . $user->getNickName() . '"';
     $channel['link'] = "http://" . GlobalProperties::$URL_HOST . "/account:you/start/watched-forum";
     $items = array();
     foreach ($posts as $post) {
         $thread = $post->getForumThread();
         $site = $post->getSite();
         $item = array();
         $item['title'] = $post->getTitle() . ' (' . _('on site') . ' "' . htmlspecialchars($site->getName()) . '")';
         $item['link'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle() . '#post-' . $post->getPostId();
         $item['guid'] = "http://" . $site->getDomain() . "/forum/t-" . $thread->getThreadId() . '#post-' . $post->getPostId();
         $item['date'] = date('r', $post->getDatePosted()->getTimestamp());
         $content = $post->getText();
         $content = preg_replace(';(<.*?)(src|href)="/([^"]+)"([^>]*>);si', '\\1\\2="http://' . $site->getDomain() . '/\\3"\\4', $content);
         $content = preg_replace(';<script\\s+[^>]+>.*?</script>;is', '', $content);
         $content = preg_replace(';(<[^>]*\\s+)on[a-z]+="[^"]+"([^>]*>);si', '\\1 \\2', $content);
         // add extra info.
         $content .= '<br/><hr/>';
         $content .= _('Site') . ': <a href="http://' . $site->getDomain() . '">' . htmlspecialchars($site->getName()) . '</a><br/>';
         $content .= _('Forum category') . ': <a href="http://' . $site->getDomain() . '/forum/c-' . $thread->getCategoryId() . '">' . htmlspecialchars($thread->getForumCategory()->getName()) . '</a><br/>';
         $content .= _('Forum thread') . ': <a href="http://' . $site->getDomain() . '/forum/t-' . $thread->getThreadId() . '/' . $thread->getUnixifiedTitle() . '">' . htmlspecialchars($thread->getTitle()) . '</a><br/>';
         $content .= _('Author of the post') . ': ' . WDRenderUtils::renderUser($post->getUserOrString()) . '<br/>';
         $item['content'] = $content;
         if ($post->getUserId() > 0) {
             $item['authorUserId'] = $post->getUserId();
             $user = $post->getUser();
             $item['author'] = $user->getNickName();
         } else {
             $item['author'] = $post->getUserString();
         }
         $items[] = $item;
     }
     $runData->contextAdd("channel", $channel);
     $runData->contextAdd("items", $items);
 }