public function executeRefresh() { $post = PostPeer::retrieveByPK($this->getRequestParameter('id')); $blog = $post->getBlog(); $this->forward404Unless($blog->getId() == $this->getUser()->getId()); if ($post) { try { $items = FeedParser::parse($blog->getFeed()); foreach ($items as $item) { if ($item->link == $post->getLink()) { $post->removeTags(); foreach ($item->tags as $name) { $tag = TagPeer::retriveByName($name, true); $post->addTag($tag); } if ($post->hasTags()) { $shortened = $post->setFullContent($item->content); $post->setLink($item->link); $post->setTitle($item->title); $post->setCreatedAt($item->pubdate); $post->setShortened($shortened); $post->save(); } break; } } $this->setFlash('updated', 'Wpis został odświeżony.'); } catch (Exception $e) { $this->setFlash('updated', 'Odswieżanie wpisu nie powiodło się.'); } } $this->redirect('ucp/index'); }
public static function getNewestTimestamp(Blog $blog) { $c = new Criteria(); $c->addDescendingOrderByColumn(PostPeer::CREATED_AT); $c->add(PostPeer::BLOG_ID, $blog->getId()); $post = PostPeer::doSelectOne($c); return $post ? $post->getCreatedAt(null) : 0; }
public function executeDelete() { $post = PostPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($post); $post->setDeleted(true); $post->save(); $this->redirect('post/list'); }
/** * The component to display a single thread */ public function executeShowThread() { $this->thread = ThreadPeer::retrieveByPK($this->threadID); $this->post = PostPeer::getFirstForThreadId($this->threadID); //First are experts anserws ( firest best than other ) //Than are other users answers ( first best than other ) $this->expert_best_posts = PostPeer::getForThreadIdAndFor($this->threadID, $this->post->getId(), true, 1); $this->expert_others_posts = PostPeer::getForThreadIdAndFor($this->threadID, $this->post->getId(), true, 0); $this->other_best_posts = PostPeer::getForThreadIdAndFor($this->threadID, $this->post->getId(), false, 1); $this->other_others_posts = PostPeer::getForThreadIdAndFor($this->threadID, $this->post->getId(), false, 0); }
public function executeIndex() { $blog = $this->getUser()->getBlog(); if (!$blog->getApproved()) { $this->blog = $blog; return 'NotApproved'; } $c = new Criteria(); $c->add(PostPeer::BLOG_ID, $this->getUser()->getId()); $c->add(PostPeer::DELETED, false); $c->addDescendingOrderByColumn(PostPeer::CREATED_AT); $c->setLimit(10); $this->posts = PostPeer::doSelect($c); }
public function executeIndex() { $name = $this->getRequestParameter('tag', ''); $c = new Criteria(); if ($name) { $c->add(TagPeer::NAME, $name); $tag = TagPeer::doSelectOne($c); $this->forward404Unless($tag); $c->clear(); $c->addJoin(PostTagPeer::POST_ID, PostPeer::ID, Criteria::LEFT_JOIN); $c->add(PostTagPeer::TAG_ID, $tag->getId()); } $c->addDescendingOrderByColumn(PostPeer::CREATED_AT); $c->setLimit(sfConfig::get('app_posts_in_feed', 10)); $c->add(PostPeer::DELETED, false); $posts = PostPeer::doSelect($c); $this->feed = $this->createFeed($posts, $name); ReaderPeer::increment(); }
} } ?> <?php } ?> <?php echo link_to($user->getName(), sfConfig::get('app_rayku_url') . '/tutor/' . $user->getUsername(), array('class' => 'username')); ?> </div> <div class="points" style="font-weight:normal;color:#666">Posts: <strong> <?php $logedUserId = $user->getID(); $v = new Criteria(); $v->add(PostPeer::POSTER_ID, $logedUserId); $_postCount = PostPeer::doCount($v); echo $_postCount; ?> </strong> </div> <div class="points" style="font-weight:normal;color:#666;margin-top:4px;">RP: <strong> <?php $query = mysql_query("select * from user where id=" . $logedUserId . " ", $connection) or die(mysql_error()); $detailPoints = mysql_fetch_assoc($query); echo $detailPoints['points']; ?> </strong> </div> <!-- Expert Rank --> <?php
public function getRepliesCount() { return PostPeer::getCountForThread($this); }
static function getCountOfBestResponseForCreatedThreadsByUser($user) { $c = new Criteria(); $c->add(ThreadPeer::POSTER_ID, $user->getId()); $c->addJoin(PostPeer::THREAD_ID, ThreadPeer::ID, Criteria::JOIN); $c->add(PostPeer::BEST_RESPONSE, 1); return PostPeer::doCount($c); }
/** * Get the associated Post object * * @param PropelPDO Optional Connection object. * @return Post The associated Post object. * @throws PropelException */ public function getPost(PropelPDO $con = null) { if ($this->aPost === null && $this->post_id !== null) { $this->aPost = PostPeer::retrieveByPk($this->post_id); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aPost->addComments($this); */ } return $this->aPost; }
$experts = UserPeer::getForExpertCategory($category->getId()); ?> <?php if ($experts != NULL) { ?> <div class="box"> <div class="top"></div> <div class="content"> <div class="title" style="color:#1c517c; font-size:16px">Top 5 Experts In <?php echo $category->getName(); ?> </div> <?php // $experts = UserPeer::getForExpertCategory( $category->getId() ); foreach ($experts as $expert) { $best_resp_count = PostPeer::getCountOfBestResponseForExpert($expert); echo '<div class="expert">'; echo '<strong><a href="' . sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $expert->getUsername() . '" style="color:#6E6E6E">' . $expert->getName() . '</a>: </strong>'; echo $best_resp_count . ' Best Responses'; echo '</div>'; } ?> </div> <div class="spacer"></div> <div class="bottom"></div> </div> <?php } ?> <?php echo link_to('Back to Public Forums', '@view_forums', array('class' => 'btmlnk'));
/** * Action to display login page */ public function executeIndex() { $connection = RaykuCommon::getDatabaseConnection(); if ($this->getRequestParameter('username') == null) { $this->redirect("/dashboard"); } $c = new Criteria(); $c->add(UserPeer::USERNAME, $this->getRequestParameter('username')); $user = UserPeer::doSelectOne($c); $this->user = $user; $this->tutor_id = $user->getId(); $c = new Criteria(); $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN); $rankexperts = ExpertCategoryPeer::doSelect($c); $rankUsers = array(); $ji = 0; $eachExpertOnlyOnce = array(); $rankScore = array(); /** * @todo this loop parses all experts only to later use only one of them in template - fix this */ foreach ($rankexperts as $exp) { if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) { continue; } $eachExpertOnlyOnce[] = $exp->getUserId(); $query = mysql_query("select * from user_score where user_id=" . $exp->getUserId(), $connection) or die(mysql_error()); $score = mysql_fetch_assoc($query); if ($score['score'] != 0) { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $rankUsers[$ji] = array("score" => $score['score'], "userid" => $exp->getUserId(), "createdat" => $_thisUser->getCreatedAt()); $ji++; } } asort($rankUsers); arsort($rankUsers); $this->rankUsers = $rankUsers; ////////////////////////////// if (!empty($_GET['expert_id'])) { $_expert_id = !empty($_GET['expert_id']) ? $_GET['expert_id'] : 0; $userId = $this->getUser()->getRaykuUserId(); if ($_expert_id) { $query = mysql_query("select * from expert_subscribers where expert_id = " . $_expert_id . " and user_id =" . $userId, $connection) or die(mysql_error()); if (mysql_num_rows($query) == 0) { $_query = mysql_query("insert into expert_subscribers(expert_id, user_id) values(" . $_expert_id . ", " . $userId . ")", $connection) or die("Error--->" . mysql_error()); $queryScore = mysql_query("select * from user_score where user_id =" . $_expert_id, $connection) or die(mysql_error()); $rowScore = mysql_fetch_assoc($queryScore); $newScore = ''; $newScore = $rowScore['score'] + 10; mysql_query("update user_score set score = " . $newScore . " where user_id =" . $_expert_id, $connection) or die(mysql_error()); } } $this->redirect("/tutor/" . $user->getUsername()); } if ($this->getRequestParameter('content') != null) { $this->expertid = $this->getUser()->getRaykuUser()->getId(); $this->expertusr = $this->getUser()->getRaykuUser()->getUsername(); $this->content = $this->getRequestParameter('content'); $c = new Criteria(); $c->add(ExpertsPromoTextPeer::EXP_ID, $this->expertid); $expertstext = ExpertsPromoTextPeer::doSelectOne($c); if ($expertstext != null) { $expertstext->setContent($this->content); $expertstext->save(); } else { $promo = new ExpertsPromoText(); $promo->setExpId($this->expertid); $promo->setContent($this->content); $promo->save(); } } $this->expert = $user; $f = new Criteria(); $f->add(PostPeer::POSTER_ID, $user->getId()); $f->add(PostPeer::BEST_RESPONSE, '1'); $f->addDescendingOrderByColumn('ID'); $this->bestResponses = PostPeer::doSelect($f); $f->setLimit(6); $this->best_responses = PostPeer::doSelect($f); $expertId = $user->getId(); $userId = $this->getUser()->getRaykuUserId(); $this->currentUser = $this->getUser()->getRaykuUser(); // last n whiteboard sessions $cLastSessions = new Criteria(); if ($userId != $expertId) { $cPublicA = $cLastSessions->getNewCriterion(WhiteboardChatPeer::EXPERT_ID, $expertId); $cPublicB = $cLastSessions->getNewCriterion(WhiteboardChatPeer::IS_PUBLIC, true); $cPublicC = $cLastSessions->getNewCriterion(WhiteboardChatPeer::ASKER_ID, $userId); $cPublicB->addOr($cPublicC); $cPublicA->addAnd($cPublicB); } else { $cPublicA = $cLastSessions->getNewCriterion(WhiteboardChatPeer::EXPERT_ID, $userId); $cPublicB = $cLastSessions->getNewCriterion(WhiteboardChatPeer::ASKER_ID, $userId); $cPublicA->addOr($cPublicB); } $cLastSessions->add($cPublicA); $cLastSessions->add(WhiteboardChatPeer::STARTED_AT, null, Criteria::ISNOTNULL); $cLastSessions->addDescendingOrderByColumn(WhiteboardChatPeer::ID); $this->totalSessions = WhiteboardChatPeer::doSelect($cLastSessions); $cLastSessions->setLimit(3); $this->lastSessions = WhiteboardChatPeer::doSelect($cLastSessions); }
define('SF_ROOT_DIR', realpath(dirname(__FILE__) . '/..')); define('SF_APP', 'backend'); define('SF_ENVIRONMENT', 'prod'); define('SF_DEBUG', false); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $blogs = BlogPeer::getApproved(); logmsg('Skrypt odswiezajacy'); logmsg('Feedow do sprawdzenia: %d', count($blogs)); logmsg(str_repeat('-', 80)); foreach ($blogs as $blog) { logmsg('Parsowanie feedu %s', $blog->getFeed()); try { $items = FeedParser::parse($blog->getFeed()); $ts = PostPeer::getNewestTimestamp($blog); logmsg('Najnowszy wpis (timestamp): %d', $ts); foreach ($items as $item) { if (!parseItem($blog, $item, $ts)) { break; } } } catch (Exception $e) { logmsg('Blad: %s', $e->getMessage()); } logmsg(str_repeat('-', 80) . "\n"); } logmsg('Odswiezanie zakonczone.'); function parseItem($blog, $item, $ts) { if ($ts != 0 && $item->pubdate <= $ts) {
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(PostPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(PostPeer::DATABASE_NAME); $criteria->add(PostPeer::ID, $pks, Criteria::IN); $objs = PostPeer::doSelect($criteria, $con); } return $objs; }
<?php $c = new Criteria(); $c->add(UserPeer::TYPE, '5'); $c->addDescendingOrderByColumn(UserPeer::POINTS); $c->setLimit(10); $experts = UserPeer::doSelect($c); ?> <ul class="experts"> <?php foreach ($experts as $expert) { ?> <?php $c = new Criteria(); $c->add(PostPeer::POSTER_ID, $expert->getId()); $c->add(PostPeer::BEST_RESPONSE, '1'); $best_resp = PostPeer::doCount($c); ?> <li><?php echo link_to($expert->getName(), sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $expert->getUsername()); ?> : <?php echo $best_resp; ?> Best Responses</li> <?php } ?> </ul> </div> <div class="bot"></div> </div>-->
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PostPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setBlogId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setCreatedAt($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setYear($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setMonth($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setTitle($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setLink($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setContent($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setContentMore($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setShortened($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setDeleted($arr[$keys[10]]); } }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PostPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setTitle($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setKeywords($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setMetadata($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setContent($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setIsPublished($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCreatedAt($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setUpdatedAt($arr[$keys[7]]); } }
public function executeRemove() { $this->validAjaxRequest(); $res = new \AjaxResponse(); if (!($postImg = \PostImages::retrieveById($this->request()->post('id')))) { $res->type = \AjaxResponse::ERROR; $res->message = t("Image not found"); return $this->renderText($res->toString()); } if ($postImg->delete()) { $otherImages = []; if (($otherImages = \PostPeer::getPostImg($postImg->getPostId())) && $postImg->getIsMain()) { $otherImages[0]->setIsMain(true); $otherImages[0]->save(); } $result = []; foreach ($otherImages as $image) { $t = $image->toArray(); $t['thumb_url'] = $image->getThumbs(96, 96); $t['url'] = $image->getUrl(); $result[] = $t; } $res->images = $result; $res->postImg = $postImg->toArray(); $res->type = \AjaxResponse::SUCCESS; return $this->renderText($res->toString()); } $res->type = \AjaxResponse::ERROR; $res->message = t("Unknown error"); return $this->renderText($res->toString()); }
?> </div> <div class="cmmt"> <div class="info"> <?php $date = RaykuCommon::formatDateForPost($post->getUpdatedAt()); ?> <div class="postdate">Posted on <?php echo $date; ?> </div> <?php $thread = ThreadPeer::retrieveByPK($post->getThreadId()); if ($rowBest["poster_id"] != $user->getId()) { if ($sf_user->getRaykuUserId() == $thread->getPosterId()) { $best_resp_count = PostPeer::getCountOfBestResponseForThread($thread); if ($best_resp_count < 1) { echo link_to('Set as best', 'forum/bestresponse?post_id=' . $post->getId() . '&temp=' . $post->getUpdatedAt(), array('class' => 'setbest')); } } } ?> </div> <!-- <p class="message"><?php // echo nl2br(htmlentities($post)) ?> </p> --> <?php //$_post = explode("",$post); ?>
<?php use_helper('MyAvatar', 'Javascript'); $post = PostPeer::retrieveByPk($object['ID']); $poster = UserPeer::retrieveByPK($post->getPosterId()); $thread = $post->getThreadId(); ?> <div class="entry"> <?php if ($poster->getPicture() != '') { ?> <?php echo avatar_tag_for_user($poster); ?> <?php } else { ?> <img src="<?php echo image_path('dev/emptyprofile.gif', false); ?> " alt="" /> <?php } ?> <div class="container"> <div> <?php $sLink = 'Posted by: ' . $poster->getName() . ' - Inside ' . $object['NAME']; echo link_to($sLink, 'forum/thread?thread_id=' . $post->getThreadId(), array('class' => 'name'));
public function executeStats() { $stats = array(); $c = new Criteria(); // readers_cnt $date = date('Y-m-d', strtotime('-1 day')); $c->clear(); $c->add(ReaderPeer::DATE, $date); $readers = ReaderPeer::doSelectOne($c); $cnt = $readers ? $readers->getCnt() : 0; $tcnt = $cnt % 100; $str = ''; if ($tcnt == 1) { $str = 'osoba'; } else { if ($tcnt >= 12 && $tcnt <= 14) { $str = 'osób'; } else { if ($tcnt % 10 > 1 && $tcnt % 10 < 5) { $str = 'osoby'; } else { $str = 'osób'; } } } $stats['reader_cnt'] = $cnt == 0 ? 'brak danych' : sprintf('%d %s', $cnt, $str); // blog_cnt $c->clear(); $c->add(BlogPeer::APPROVED, true); $stats['blog_cnt'] = BlogPeer::doCount($c); // post_cnt $c->clear(); $c->add(PostPeer::DELETED, false); $stats['post_cnt'] = PostPeer::doCount($c); // month_avg $c->clear(); $c->addAscendingOrderByColumn(PostPeer::CREATED_AT); $post = PostPeer::doSelectOne($c); $ots = $post ? $post->getCreatedAt(null) : time(); $years = date('Y') - date('Y', $ots); $months = $years * 12 + (date('n') - date('n', $ots)); $stats['month_avg'] = $months > 0 ? round($stats['post_cnt'] / $months) : 0; // assign $this->stats = $stats; }
public function executeEdit() { $post = \Posts::retrieveById($this->request()->get('id')); $taxonomy = $this->request()->get('taxonomy'); if (!$post) { Session::getInstance()->setFlash('post_error', t('Post not found')); $this->redirect($this->createUrl('post/default', array('taxonomy' => $taxonomy))); } if (null == $taxonomy) { $taxonomy = $post->getTaxonomy(); } $error = array(); if ($this->request()->isPostRequest()) { if ($this->_save($post, $error)) { Session::getInstance()->setFlash('post_message', t($post->getTitle() . ' was saved')); $this->redirect($this->createUrl('post/default', array('taxonomy' => $taxonomy))); } } $images = \PostPeer::getPostImg($post->getId()); $files = \PostPeer::getPostAttachments($post->getId()); //Hydrate $jsData = $post->toArray(); $jsData['images'] = []; foreach ($images as $img) { $t = $img->toArray(); $t['thumb_url'] = $img->getThumbs(96, 96); $t['url'] = $img->getUrl(); $jsData['images'][] = $t; } $jsData['files'] = []; foreach ($files as $f) { $jsData['files'] = $f->toArray(); } $this->document()->addJsVar('post', $jsData); //JS URL $this->document()->addJsVar('img_upload_url', $this->createUrl('post_img/upload')); $this->document()->addJsVar('img_remove_url', $this->createUrl('post_img/remove')); $this->document()->addJsVar('img_set_main_url', $this->createUrl('post_img/make_star')); $this->document()->addJsVar('img_update_url', $this->createUrl('post_img/update')); $this->setView('Post/form'); $this->view()->assign(array('post' => $post, 'taxonomy' => $taxonomy, 'error' => $error, 'page_title' => t('Edit ' . $post->getTitle()))); return $this->renderComponent(); }
<div style="display: none;"> <div id="inline1" style="width:630px;height:650px;overflow:auto;padding:25px" align="left"> <div class="body-main"> <div class="qa"> <div class="ta"> <?php $_thread = explode("/", $_SERVER['REQUEST_URI']); $_thread_id = $_thread[3]; $thread = ThreadPeer::retrieveByPK($_thread_id); $c = new Criteria(); $c->add(PostPeer::THREAD_ID, $thread->getId()); $c->addAscendingOrderByColumn(PostPeer::ID); $post = PostPeer::doSelectOne($c); $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; if (!empty($logedUserId)) { $c = new Criteria(); $c->add(UserPeer::ID, $logedUserId); $actionCheck = UserPeer::doSelectOne($c); if ($actionCheck->getType() == '5') { echo form_tag('@expertreply_thread?forum_id=' . $thread->getCategoryId() . '&thread_id=' . $thread->getId()); } else { echo form_tag('@userreply_thread?forum_id=' . $thread->getCategoryId() . '&thread_id=' . $thread->getId()); } } ?>
public function executeExpertReplyThread() { $connection = RaykuCommon::getDatabaseConnection(); $c = new Criteria(); $c->add(ForumPeer::TYPE, 0); $this->publicforums = ForumPeer::doSelect($c); $this->allcategories = CategoryPeer::doSelect($c = new Criteria()); $this->forum = $this->getRequestParameter('forum_id'); $this->thread = ThreadPeer::retrieveByPK($this->getRequestParameter('thread_id')); $c = new Criteria(); $c->add(PostPeer::THREAD_ID, $this->thread->getId()); $this->post = PostPeer::doSelectOne($c); $user = $this->getUser()->getRaykuUser(); if ($this->getRequestParameter('post_edit_content') != '') { $threadId = $this->getRequestParameter('thread_id'); $_thread = ThreadPeer::retrieveByPK($threadId); $_thread->setTitle($this->getRequestParameter('post_edit_title')); $_thread->save(); $v = new Criteria(); $v->add(PostPeer::THREAD_ID, $threadId); $v->addAscendingOrderByColumn(PostPeer::ID); $post = PostPeer::doSelectOne($v); $post->setContent($this->getRequestParameter('post_edit_content')); $post->save(); return $this->redirect('@view_thread?thread_id=' . $threadId); } if ($this->getRequestParameter('post_body') != '') { if ($this->getRequestParameter('final_id') != '') { $_quick_reply = ''; $_post_id = $this->getRequestParameter('final_id'); $_Post = PostPeer::retrieveByPK($_post_id); $_User = UserPeer::retrieveByPK($_Post->getPosterId()); $_quick_reply .= "<div style='margin-left:20px'><em><strong>Quote from " . $_User->getUsername() . "</strong></em><br><br>"; $_explode_post = explode("*^-", $_Post->getContent()); if (count($_explode_post) > 1) { $_quick_reply .= $_explode_post[1]; } else { $_quick_reply .= $_Post->getContent(); } $_quick_reply .= "</div>"; $_post_body_msg = $this->getRequestParameter('post_body'); $_quick_reply .= $_post_body_msg; $user->makeNewPost($this->getRequestParameter('thread_id'), $_quick_reply); ///////////////////updating the ip of the user $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection)); mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection); ///////////////////updating the ip of the user } else { $user->makeNewPost($this->getRequestParameter('thread_id'), $this->getRequestParameter('post_body')); ///////////////////updating the ip of the user $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection)); mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection); ///////////////////updating the ip of the user } if ($this->getUser()->getRaykuUser()->getType() == '5') { $c = new Criteria(); $c->add(ThreadPeer::ID, $this->getRequestParameter('thread_id')); $thread = ThreadPeer::doSelectOne($c); $c = new Criteria(); $c->add(UserPeer::ID, $thread->getPosterId()); $user = UserPeer::doSelectOne($c); if ($thread->getNotifyPm() == '1') { $subject = 'Expert Response for your Question'; $body = 'Hi there, <br><br> A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '" has just responsed to your question, "' . $thread->getTitle() . '" on the question boards. Take a look!<br><br> Rayku Administration'; //Grab the user object $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId()); //Send the message $currentuser->sendMessage($user->getId(), $subject, $body); } if ($thread->getNotifyEmail() == '1') { $this->mail = new sfMail(); //Set the to, from, and subject headers $this->mail->addAddress($user->getEmail()); $this->mail->setFrom('Expert <' . $this->getUser()->getRaykuUser()->getEmail() . '>'); $this->mail->setSubject('Expert Response to your Question'); $this->mail->setBody('Hi there,<br> A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '", has just responded to your question (below) on the question boards. Take a look!<br><br> ' . $thread->getTitle() . ''); $this->mail->send(); } } return $this->redirect('@view_thread?thread_id=' . $this->thread->getId()); } }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = PostPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setPosterId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setThreadId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCreatedAt($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setUpdatedAt($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setContent($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setBestResponse($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setReported($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setUserIp($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setBanned($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setReportedDate($arr[$keys[10]]); } }
</div> <?php $c = new Criteria(); $c->add(UserPeer::ID, $post->getPosterId()); $user = UserPeer::doSelectOne($c); ?> <?php echo link_to($user->getUsername(), '@profile?username='******'class' => 'author')); ?> <?php $c = new Criteria(); $c->add(PostPeer::THREAD_ID, $post->getId()); $countofpost = PostPeer::doCount($c); ?> <div class="replies"><?php echo $countofpost - 1; ?> Replies</div> <div class="spacer"></div> </div> <?php } ?> <?php
function withinPosts() { $this->addFromStatement(PostPeer::search($this->criteria)); }
/** * Returns the number of related Posts. * * @param Criteria $criteria * @param boolean $distinct * @param Connection $con * @throws PropelException */ public function countPosts($criteria = null, $distinct = false, $con = null) { // include the Peer class include_once 'lib/model/om/BasePostPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } $criteria->add(PostPeer::BLOG_ID, $this->getId()); return PostPeer::doCount($criteria, $distinct, $con); }
/** * Selects a collection of Comment objects pre-filled with all related objects except User. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Comment objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptUser(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } CommentPeer::addSelectColumns($criteria); $startcol2 = CommentPeer::NUM_COLUMNS - CommentPeer::NUM_LAZY_LOAD_COLUMNS; PostPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (PostPeer::NUM_COLUMNS - PostPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(CommentPeer::POST_ID, PostPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseCommentPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = CommentPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = CommentPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = CommentPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); CommentPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Post rows $key2 = PostPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = PostPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = PostPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); PostPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Comment) to the collection in $obj2 (Post) $obj2->addComment($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Selects a collection of PostTag objects pre-filled with all related objects except Tag. * * @return array Array of PostTag objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptTag(Criteria $c, $con = null) { $c = clone $c; // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } PostTagPeer::addSelectColumns($c); $startcol2 = PostTagPeer::NUM_COLUMNS - PostTagPeer::NUM_LAZY_LOAD_COLUMNS + 1; PostPeer::addSelectColumns($c); $startcol3 = $startcol2 + PostPeer::NUM_COLUMNS; $c->addJoin(PostTagPeer::POST_ID, PostPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = PostTagPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = PostPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getPost(); //CHECKME if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addPostTag($obj1); break; } } if ($newObject) { $obj2->initPostTags(); $obj2->addPostTag($obj1); } $results[] = $obj1; } return $results; }