function buildActionItem($action) { require_once PATH_CORE . '/classes/user.class.php'; require_once PATH_CORE . '/classes/template.class.php'; $uit = new UserInfoTable($this->db); $fbIds = $uit->getFbIdsForUsers(array($action->userid1)); $fbId = $fbIds[0]; if ($action->userid2) { $fbIds2 = $uit->getFbIdsForUsers(array($action->userid2)); $fbId2 = $fbIds2[0]; } if (!$fbId) { // cant return anything or #&*$@! paging gets screwed //$code .= '<div class="hidden">No fbId found for userid '. $action->userid1 . '</div>'; $this->db->log("Action Feed: No fbId found for userid {$action->userid1} performing {$action->action} on {$action->t}"); return ''; //$code; } $ago .= self::getElapsedString(strtotime($action->t)); switch ($action->action) { case 'completedChallenge': $code .= $this->fetchChallengeCompletedFeedItem($action, $fbId, false); // hack for now so the console can access it also //$ct = new ChallengeTable($this->db); break; case 'signup': /*$code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) .' joined the action team!'; */ $code .= '<div class="profilePicLarger">' . template::buildLinkedProfilePic($fbIds[0], 'size="square"') . ' ' . '</div> <div class="storyBlockWrap"> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' joined the ' . SITE_TEAM_TITLE . '!</span> ' . $ago . '</h3> </div><!__end "storyBlockWrap"__>'; break; case 'friendSignup': $code .= '<div class="profilePicLarger">' . template::buildLinkedProfilePic($fbIds[0], 'size="square"') . ' ' . '</div> <div class="storyBlockWrap"> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' got credit for inviting ' . template::buildLinkedProfileName($fbId2) . '!</span> ' . $ago . '</h3> </div><!__end "storyBlockWrap"__>'; break; case 'chatStory': require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; // hack: since jeff put the fbId in itemid2 for chatStory $fbId2 = $action->userid2; if ($content->load($contentid)) { $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster">' . '<div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div>' . '<div class="avatar">' . template::buildLinkedProfilePic($fbId2, 'size="square" with="30" height="30"') . '</div>' . '<h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' chatted with ' . template::buildLinkedProfileName($fbId2) . ' about the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> </div><!__end "storyBlockWrap"__>'; } break; //case 'acceptedInvite': // actually want to filter these? // yeah, dont show these //break; //case 'acceptedInvite': // actually want to filter these? // yeah, dont show these //break; case 'redeemed': require_once PATH_CORE . '/classes/prizes.class.php'; $prizeTable = new PrizeTable($this->db); $prize = $prizeTable->getRowObject(); if ($prize->load($action->itemid) && !$prize->isWeekly && !$prize->isGrand) { /* $indefarticle = template::getIndefiniteArticle($prize->title); $code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) ." used {$prize->pointCost} points to get $indefarticle " . template::buildRewardLink($prize->title, $prize->id) ."" . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width=70); //$code .= ' '. self::getElapsedString(strtotime($action->t)); */ $code .= '<div class="thumb">' . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width = 70) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' redeemed <span class="pointValue">' . $prize->pointCost . '<span class="pts"> points</span></span>.</span> ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildRewardLink($prize->title, $prize->id) . ' </p> <p class="storyCaption"></p> </div><!__end "storyBlockWrap"__>'; } else { // debug: //$code .= 'No prize found for id ' . $action->itemid; } break; case 'wonPrize': // implement require_once PATH_CORE . '/classes/prizes.class.php'; $prizeTable = new PrizeTable($this->db); $prize = $prizeTable->getRowObject(); if ($prize->load($action->itemid)) { if ($prize->isWeekly) { $winText = 'won a Weekly Prize!'; } if ($prize->isGrand == 1) { $winText = 'won the Grand Prize and made the planet green with envy!'; } if ($prize->isGrand > 1) { $winText = 'won a Runner-up Prize!'; } $code .= '<div class="thumb">' . template::buildLinkedRewardPic($prize->id, $prize->thumbnail, $width = 70) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' ' . $winText . ' ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildRewardLink($prize->title, $prize->id) . ' </p> <p class="storyCaption"></p> </div><!__end "storyBlockWrap"__>'; } else { // debug: //$code .= 'No prize found for id ' . $action->itemid; } break; break; case 'publishStory': // TODO ? //return ''; //break; // TODO ? //return ''; //break; case 'postBlog': case 'postStory': require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; if ($content->load($contentid)) { /*$code .= template::buildLinkedStoryImage($content->imageid, $contentid); $code .= template::buildLinkedProfilePic($fbIds[0], 'size="square"') .' '. template::buildLinkedProfileName($fbIds[0]) .' posted a story'; $code .= '<p>' . template::buildStoryLink($content->title, $contentid) .'</p>'; */ $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" with="30" height="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' posted a story</span> ' . $ago . '</h3> </div> <p class="storyHead">' . template::buildStoryLink($content->title, $contentid) . ' </p> <p class="storyCaption">' . $this->templateObj->ellipsis(strip_tags($content->caption, 200)) . ' ' . template::buildStoryLink('...more', $contentid) . '</p> </div><!__end "storyBlockWrap"__>'; //'</li>' } break; case 'vote': // ignore require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $contentid = $action->itemid; // grrrr if ($content->load($contentid)) { $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster">' . '<h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' voted on the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> </div><!__end "storyBlockWrap"__> '; } break; case 'comment': /* * * <li class="panel_block"> <div class="thumb"><a href="http://www.msnbc.msn.com/id/28529073/"><img src="{URL_BASE}/index.php?p=scaleImg&id=34608&x=185&y=130&fixed=x&crop" /></a> </div> <div class="storyBlockWrap"> <h3><span class="bold"><a href="'.URL_CANVAS.'?p=profile&memberid=1180126201" onclick="return switchPage('profile', '', 1180126201);"><fb:name ifcantsee="Anonymous" uid="1180126201" capitalize="true" firstnameonly="false" linked="false" /></a> commented on the story <a href="#">It's Time to Aim Low</a></span> on Feb 2, 2009</h3> <blockquote> <div class="quotes"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam dolor nunc, vehicula et, tristique sed, auctor et, massa.</p> <p> Nam at purus vitae diam commodo venenatis. Ut leo enim, vestibulum eget, rhoncus in, suscipit laoreet, magna. Aliquam diam. Nunc tempor lorem eget nisl.</p> </div> </blockquote> </div><!__end "storyBlockWrap"__> </li> */ // assume comment->siteContentId is what is stored... require_once PATH_CORE . '/classes/content.class.php'; require_once PATH_CORE . '/classes/comments.class.php'; require_once PATH_CORE . '/classes/video.class.php'; $contentTable = new ContentTable($this->db); $commentTable = new CommentTable($this->db); $videoTable = new VideoTable($this->db); $content = $contentTable->getRowObject(); $comment = $commentTable->getRowObject(); $video = $videoTable->getRowObject(); $commentid = $action->itemid; // grr $contentid = $action->itemid2; // grrrr if ($comment->load($commentid) && $content->load($contentid)) { if ($comment->videoid && $video->load($comment->videoid)) { $quoteContents = '<div style="text-align:center;">' . videos::buildPlayerFromLink($video->embedCode, 160, 100) . '</div>'; } else { $quoteContents = '<p>' . $this->templateObj->ellipsis(strip_tags($comment->comments), 200) . ' ' . template::buildStoryLink('...more', $contentid) . '</p>'; } $code .= ' <div class="thumb">' . template::buildLinkedStoryImage($content->imageid, $contentid) . '</div> <div class="storyBlockWrap"> <div class="feed_poster"><div class="avatar">' . template::buildLinkedProfilePic($fbIds[0], 'size="square" height="30" width="30"') . '</div> <h3><span class="bold">' . template::buildLinkedProfileName($fbIds[0]) . ' commented on the story ' . template::buildStoryLink($content->title, $contentid) . '</span> ' . $ago . '</h3> </div> <blockquote> <div class="quotes">' . $quoteContents . '</div> </blockquote> </div><!__end "storyBlockWrap"__> '; } break; } return $code; }
function ajaxBanStoryPoster(&$app = null, $cid = 0, $userid = 0) { // to do - make sure user is admin // cid - cid of user to ban $contentTable = new ContentTable($this->db); $c = $contentTable->getRowObject(); $c->load($cid); if ($c->userid != $userid) { $this->db->update("Content", "isBlocked=1", "userid=" . $c->userid); // block all stories by this user $this->db->update("Comments", "isBlocked=1", "userid=" . $c->userid); // block all comments by this user require_once PATH_CORE . '/classes/user.class.php'; $uit = new UserInfoTable($this->db); $ut = new UserTable($this->db); $u = $ut->getRowObject(); $ui = $uit->getRowObject(); $u->load($c->userid); // block story $c->isBlocked = 1; $c->update(); // block user $u->isBlocked = 1; $u->update(); $ui->load($c->userid); $facebook = $app->loadFacebookLibrary(); $this->db->log('To Ban ' . $ui->fbId); //$facebook->api_client->admin_banUsers($ui->fbId); // load facebook library - call ban api $code = 'Ban complete.'; } else { $code = 'Error: Trying to ban yourself again, huh?'; } return $code; }
function remoteSerialize($data) { // take comment from NewsCloud // look up postedById and get local userid require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($this->db); $user = $userTable->getRowObject(); $user->load($data[uid]); if (!$user) { $userid = $user->userid; } else { $userid = 0; } require_once PATH_CORE . '/classes/content.class.php'; $contentTable = new ContentTable($this->db); $content = $contentTable->getRowObject(); $content->load($data[contentid], 'contentid'); if (!$content) { $siteContentId = $content->siteContentId; } else { $siteContentId = 0; } // look up contentid and get local siteContentId $data = $this->serialize(0, $data[commentid], $siteContentId, $data[contentid], $data[comments], $data[uid], $userid, $data[member_name], $data[date]); return $data; }