/** * User purchase article * * @param int $user_id * @param int $article_id * @return bool */ public function userPurchaseArticle($user_id, $article_id, $transaction) { if (!($article = ContentTable::getInstance()->getArticleForSale($article_id))) { return false; } $this->setIdUser($user_id); $this->setIdContent($article_id); $this->setIdCategory($article->getIdCategory()); $this->setTransaction($transaction); $this->save(); return true; }
/** * Get query for Category Articles List * * @param int $u_user_id - U_user ID or 0 * @return object Doctrine_Query */ public function getCategoryArticlesListQuery($u_user_id = 0) { $q = ContentTable::getInstance()->addContentPublishedListQuery(); $alias = $q->getRootAlias(); $q->andWhere($alias . '.id_category=?', $this->getId()); $q->andWhere($alias . '.id_user NOT IN (SELECT uu.id FROM user as uu WHERE uu.is_blocked = 1)'); // Filter by U_user purchased content if ($u_user_id != 0) { $q->andWhere($alias . '.id NOT IN (SELECT cp.id_content FROM ContentPurchase cp WHERE cp.id_user=?)', $u_user_id); } $q->orderBy('updated_at DESC'); return $q; }
/** * U_user purchase content: Transfer money from u_user to system * * @param <User> $user - instance of User purchased content * @param <int> $content_id - purchased article ID * @return bool */ public function purchaseContent(User $u_user, $content_id) { $article = ContentTable::getInstance()->getArticleForSale($content_id); if (!is_object($article)) { return false; } $p_user = $article->getTranslator(); $this->setOperation('purchase'); $this->setPeriod(Period::getCurrentPeriod()); $this->setAmount($article->getPrice()); $r2r_price = (int) ($article->getPrice() * Setting::getR2RPercent()) / 100; $p_user_price = $article->getPrice() - $r2r_price; $this->setIdSender($u_user->getId()); $this->setIdReceiver($p_user->getId()); // Update U_User balance $this->setSenderBalanceBefore($u_user->getBalans()); $u_user->setBalans($u_user->getBalans() - $this->getAmount()); $this->setSenderBalanceAfter($u_user->getBalans()); // Save U_User balance $u_user->save(); $u_user = null; $p_user = null; // System balance if (!($systemBalance = BalanceSystem::getCurrentBalanceInstance())) { return false; } // u_user Charges $systemBalance->setChargesUser($systemBalance->getChargesUser() + $this->getAmount()); // get p_user tariff plan $article_user_tariff = $article->getPUserTariff(); // p_user to pay and stats adn R2R summ if ($article_user_tariff == 'standart') { $systemBalance->setToPayStandart($systemBalance->getToPayStandart() + $p_user_price); $systemBalance->setSalesStandart($systemBalance->getSalesStandart() + 1); $systemBalance->setR2rStandart($systemBalance->getR2rStandart() + $r2r_price); } elseif ($article_user_tariff == 'expert') { $systemBalance->setToPayExpert($systemBalance->getToPayExpert() + $p_user_price); $systemBalance->setSalesExpert($systemBalance->getSalesExpert() + 1); $systemBalance->setR2rExpert($systemBalance->getR2rExpert() + $r2r_price); } elseif ($article_user_tariff == 'super') { $systemBalance->setToPaySuper($systemBalance->getToPaySuper() + $p_user_price); $systemBalance->setSalesSuper($systemBalance->getSalesSuper() + 1); $systemBalance->setR2rSuper($systemBalance->getR2rSuper() + $r2r_price); } // Save system balance $systemBalance->save(); $systemBalance = null; // BalanceUser u_user: update purchase stats if (!($userBalance = BalanceUserTable::getInstance()->getByUserIdAndPeriodId($this->getIdSender()))) { $userBalance = new BalanceUser(); $userBalance->setPeriod(Period::getCurrentPeriod()); $userBalance->setIdUser($this->getIdSender()); } // Save U_User purchase stats $userBalance->setSellPurchaseCnt($userBalance->getSellPurchaseCnt() + 1); $userBalance->setAmount($userBalance->getAmount() + $this->getAmount()); // save data $userBalance->save(); $userBalance = null; // BalanceUser p_user: update sell stats // Receiver: P_User balance if (!($userBalance = BalanceUserTable::getInstance()->getByUserIdAndPeriodId($this->getIdReceiver()))) { $userBalance = new BalanceUser(); $userBalance->setPeriod(Period::getCurrentPeriod()); $userBalance->setIdUser($this->getIdReceiver()); } // Transaction $this->setReceiverBalanceBefore($userBalance->getAmount()); // p_user $userBalance->setSellPurchaseCnt($userBalance->getSellPurchaseCnt() + 1); $userBalance->setAmount($userBalance->getAmount() + $this->getAmount()); $userBalance->setPayable($userBalance->getPayable() + $this->getAmount() - $r2r_price); // transaction $this->setReceiverBalanceAfter($userBalance->getAmount()); // save data $userBalance->save(); $userBalance = null; // Save transaction $this->save(); return $this; }
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; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->period = Period::getCurrentPeriod(); $this->stats_nopub = ContentTable::getInstance()->getUserStatsNoPublished($this->getUser()->getId()); // $this->stats_pub = ContentTable::getInstance()->getUserStatsPublished($this->getUser()->getId()); $this->stats_pub = $this->getUser()->getGuardUser()->getSoldStatsForPeriod($this->period); }
/** * This function runs through all the table that are class dependent. */ function convertTableByClass($course_title, $char_set, $course_id){ global $errors; //Run through all ATutor table and convert only those rows with the above courses. //todo: implement a driver class inside the TableConversion class. $temp_table = new AssignmentsTable($this->table_prefix, 'assignments', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'assignments was not converted.'; $_SESSION['redo_conversion'][$course_title]['AssignmentsTable'] = array($this->table_prefix, 'assignments', $char_set, $course_id); } $temp_table = new BackupsTable($this->table_prefix, 'backups', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'backups was not converted.'; $_SESSION['redo_conversion'][$course_title]['BackupsTable'] = array($this->table_prefix, 'backups', $char_set, $course_id); } $temp_table = new BlogPostsTable($this->table_prefix, 'blog_posts', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'blog_posts was not converted.'; $_SESSION['redo_conversion'][$course_title]['BlogPostsTable'] = array($this->table_prefix, 'blog_posts', $char_set, $course_id); } $temp_table = new ContentTable($this->table_prefix, 'content', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'content was not converted.'; $_SESSION['redo_conversion'][$course_title]['ContentTable'] = array($this->table_prefix, 'content', $char_set, $course_id); } $temp_table = new CoursesTable($this->table_prefix, 'courses', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'courses was not converted.'; $_SESSION['redo_conversion'][$course_title]['CoursesTable'] = array($this->table_prefix, 'courses', $char_set, $course_id); } $temp_table = new CourseEnrollmentTable($this->table_prefix, 'course_enrollment', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'course_enrollment was not converted.'; $_SESSION['redo_conversion'][$course_title]['CourseEnrollmentTable'] = array($this->table_prefix, 'course_enrollment', $char_set, $course_id); } $temp_table = new ExternalResourcesTable($this->table_prefix, 'external_resources', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'external_resources was not converted.'; $_SESSION['redo_conversion'][$course_title]['ExternalResourcesTable'] = array($this->table_prefix, 'external_resources', $char_set, $course_id); } $temp_table = new FaqTopicsTable($this->table_prefix, 'faq_topics', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'faq_topics was not converted.'; $_SESSION['redo_conversion'][$course_title]['FaqTopicsTable'] = array($this->table_prefix, 'faq_topics', $char_set, $course_id); } $temp_table = new FoldersTable($this->table_prefix, 'folders', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'folders was not converted.'; $_SESSION['redo_conversion'][$course_title]['FoldersTable'] = array($this->table_prefix, 'folders', $char_set, $course_id); } $temp_table = new FilesTable($this->table_prefix, 'files', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'files was not converted.'; $_SESSION['redo_conversion'][$course_title]['FilesTable'] = array($this->table_prefix, 'files', $char_set, $course_id); } $temp_table = new ForumsTable($this->table_prefix, 'forums', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'forums was not converted.'; $_SESSION['redo_conversion'][$course_title]['ForumsTable'] = array($this->table_prefix, 'forums', $char_set, $course_id); } $temp_table = new GlossaryTable($this->table_prefix, 'glossary', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'glossary was not converted.'; $_SESSION['redo_conversion'][$course_title]['GlossaryTable'] = array($this->table_prefix, 'glossary', $char_set, $course_id); } $temp_table = new GroupsTypesTable($this->table_prefix, 'groups_types', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'groups_types was not converted.'; $_SESSION['redo_conversion'][$course_title]['GroupsTypesTable'] = array($this->table_prefix, 'groups_types', $char_set, $course_id); } $temp_table = new LinksCategoriesTable($this->table_prefix, 'links_categories', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'links_categories was not converted.'; $_SESSION['redo_conversion'][$course_title]['LinksCategoriesTable'] = array($this->table_prefix, 'links_categories', $char_set, $course_id); } $temp_table = new MessagesTable($this->table_prefix, 'messages', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'messages was not converted.'; $_SESSION['redo_conversion'][$course_title]['MessagesTable'] = array($this->table_prefix, 'messages', $char_set, $course_id); } $temp_table = new MessagesSentTable($this->table_prefix, 'messages_sent', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'messages_sent was not converted.'; $_SESSION['redo_conversion'][$course_title]['MessagesSentTable'] = array($this->table_prefix, 'messages_sent', $char_set, $course_id); } $temp_table = new NewsTable($this->table_prefix, 'news', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'news was not converted.'; $_SESSION['redo_conversion'][$course_title]['NewsTable'] = array($this->table_prefix, 'news', $char_set, $course_id); } $temp_table = new PollsTable($this->table_prefix, 'polls', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'polls was not converted.'; $_SESSION['redo_conversion'][$course_title]['PollsTable'] = array($this->table_prefix, 'polls', $char_set, $course_id); } $temp_table = new ReadingListTable($this->table_prefix, 'reading_list', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'reading_list was not converted.'; $_SESSION['redo_conversion'][$course_title]['ReadingListTable'] = array($this->table_prefix, 'reading_list', $char_set, $course_id); } $temp_table = new TestsTable($this->table_prefix, 'tests', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'tests was not converted.'; $_SESSION['redo_conversion'][$course_title]['TestsTable'] = array($this->table_prefix, 'tests', $char_set, $course_id); } $temp_table = new TestQuestionsTable($this->table_prefix, 'tests_questions', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'tests_questions was not converted.'; $_SESSION['redo_conversion'][$course_title]['TestQuestionsTable'] = array($this->table_prefix, 'tests_questions', $char_set, $course_id); } $temp_table = new TestsQuestionsCategoriesTable($this->table_prefix, 'tests_questions_categories', $char_set, $course_id); if (!$temp_table->convert()){ $errors[]= $course_title.': '.$this->table_prefix.'tests_questions_categories was not converted.'; $_SESSION['redo_conversion'][$course_title]['TestsQuestionsCategoriesTable'] = array($this->table_prefix, 'tests_questions_categories', $char_set, $course_id); } }
public function getNotPublishedArticle() { if ($this->getUtype() != 'puser') { return false; } $list = ContentTable::getInstance()->getNopublishedList($this->getId()); }
UserInviteTable::createTable($manageObj); } // set up newswire table $manageObj->addTable("Newswire", "id", "INT(11) unsigned NOT NULL auto_increment", "MyISAM"); $manageObj->addColumn("Newswire", "title", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "caption", "TEXT default ''"); $manageObj->addColumn("Newswire", "source", "VARCHAR (150) default ''"); $manageObj->addColumn("Newswire", "url", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "date", "DATETIME"); // to do - deprecate $manageObj->addColumn("Newswire", "wireid", "INT(11) default 0"); // deprecated $manageObj->addColumn("Newswire", "feedid", "INT(11) default 0"); if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'content.class.php')) { require_once PATH_CORE . '/classes/content.class.php'; ContentTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'comments.class.php')) { require_once PATH_CORE . '/classes/comments.class.php'; CommentTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'cron.class.php')) { require_once PATH_CORE . '/classes/cron.class.php'; CronJobsTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'log.class.php')) { require_once PATH_CORE . '/classes/log.class.php'; LogTable::createTable($manageObj); LogExtraTable::createTable($manageObj); } // Resources for Folders and Links
/** * Return top 5 sales articles * * @return array - $array[i]['acticle'] - instance of <Content> * $array[i]['sales'] - <int> sales count */ public function getTopSalesArticles(Period $period = null) { $q = Doctrine_Query::create()->from('Content cont')->where('cont.state=?', 'public')->andWhere('cont.purchase_cnt > ?', 0)->orderBy('cont.purchase_cnt DESC')->limit(5); $q = ContentTable::addNoBlockedContent($q); return $q->execute(); }
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; }
/** * Executes rate action * * @param sfWebRequest $request */ public function executeRate(sfWebRequest $request) { if ($request->isXmlHttpRequest()) { $result = array("success" => 0); $iArticleId = $request->getParameter('article_id'); $sRateType = $request->getParameter('rate_type'); $iRating = (int) $request->getParameter('rating'); // checking input data $this->forward404Unless($iRating >= 1 && $iRating <= 5 || ($sRateType == 'content' || $sRateType != 'translate' || $sRateType == 'r2rcontent' || $sRateType != 'r2rtranslate')); $this->forward404Unless($oArticle = ContentTable::getInstance()->findOneById($iArticleId)); // updating rating if ($sRateType == 'content') { $oArticle->setUserContentRating($this->getUser()->getGuardUser()->getId(), $iRating); $result['success'] = 1; echo json_encode($result); exit; } if ($sRateType == 'translate') { $oArticle->setUserTranslateRating($this->getUser()->getGuardUser()->getId(), $iRating); $result['success'] = 1; echo json_encode($result); exit; } if ($sRateType == 'r2rcontent') { $oArticle->setR2rContRate($iRating); $oArticle->save(); $result['success'] = 1; echo json_encode($result); exit; } if ($sRateType == 'r2rtranslate') { $oArticle->setR2rTransRate($iRating); $oArticle->save(); $result['success'] = 1; echo json_encode($result); exit; } } else { $this->redirect($request->getReferer()); } }
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; }