Changeset 3433
- Timestamp:
- 02/10/07 00:44:02 (2 years ago)
- Files:
-
- plugins/sfBlogPlugin/config/schema.yml (modified) (2 diffs)
- plugins/sfBlogPlugin/lib/model/om/BasesfBlogPostPeer.php (modified) (3 diffs)
- plugins/sfBlogPlugin/modules/blog/actions/actions.class.php (modified) (1 diff)
- plugins/sfBlogPlugin/modules/blog_auth/actions/actions.class.php (modified) (1 diff)
- plugins/sfBlogPlugin/modules/blog_comment/actions/actions.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfBlogPlugin/config/schema.yml
r3431 r3433 13 13 sf_blog_tag: 14 14 _attributes: { phpName: sfBlogTag, package: plugins.sfBlogPlugin.lib.model } 15 sf_blog_post_id: 15 sf_blog_post_id: { type: integer, foreignTable: sf_blog_post, foreignReference: id, onDelete: cascade } 16 16 tag: { type: varchar, size: 255 } 17 17 normalized_tag: { type: varchar, size: 255 } … … 24 24 created_at: 25 25 content: { type: longvarchar } 26 sf_blog_post_id: 26 sf_blog_post_id: { type: integer, foreignTable: sf_blog_post, foreignReference: id, onDelete: cascade } plugins/sfBlogPlugin/lib/model/om/BasesfBlogPostPeer.php
r3431 r3433 437 437 $affectedRows = 0; try { 438 438 $con->begin(); 439 $affectedRows += sfBlogPostPeer::doOnDeleteCascade(new Criteria(), $con); 439 440 $affectedRows += BasePeer::doDeleteAll(sfBlogPostPeer::TABLE_NAME, $con); 440 441 $con->commit(); … … 467 468 try { 468 469 $con->begin(); 469 470 $affectedRows += sfBlogPostPeer::doOnDeleteCascade($criteria, $con); 470 471 $affectedRows += BasePeer::doDelete($criteria, $con); 471 472 $con->commit(); … … 475 476 throw $e; 476 477 } 478 } 479 480 481 protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) 482 { 483 $affectedRows = 0; 484 485 $objects = sfBlogPostPeer::doSelect($criteria, $con); 486 foreach($objects as $obj) { 487 488 489 include_once 'plugins/sfBlogPlugin/lib/model/sfBlogTag.php'; 490 491 $c = new Criteria(); 492 493 $c->add(sfBlogTagPeer::SF_BLOG_POST_ID, $obj->getId()); 494 $affectedRows += sfBlogTagPeer::doDelete($c, $con); 495 496 include_once 'plugins/sfBlogPlugin/lib/model/sfBlogComment.php'; 497 498 $c = new Criteria(); 499 500 $c->add(sfBlogCommentPeer::SF_BLOG_POST_ID, $obj->getId()); 501 $affectedRows += sfBlogCommentPeer::doDelete($c, $con); 502 } 503 return $affectedRows; 477 504 } 478 505 plugins/sfBlogPlugin/modules/blog/actions/actions.class.php
r3432 r3433 1 1 <?php 2 2 3 /** 4 * blog actions. 5 * 6 * @package erestar.net 7 * @subpackage blog 8 * @author Your name here 9 * @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $ 10 */ 11 class blogActions extends sfActions 3 //If you've copied and pasted the origional file into your own apps modules, use the line below and 4 //uncomment out the other 5 //require_once(sfConfig::get('sf_plugins_dir').'/sfBlogPlugin/modules/blog/lib/BaseBlogActions.class.php'); 6 7 require_once(dirname(__FILE__).'/../lib/BaseBlogActions.class.php'); 8 9 class blogActions extends BaseBlogsfActions 12 10 { 13 /**14 * Executes index action15 *16 */17 public function executeIndex()18 {19 $this->forward('blog', 'list');20 }21 22 public function executeList()23 {24 if($this->getRequestParameter('tag')) {25 $blogs = sfBlogPostPeer::doSelectByTags($this->getRequestParameter('tag'));26 }27 11 28 else {29 $c = new Criteria();30 $c->add(sfBlogPostPeer::IS_PUBLISHED, true);31 $c->addDescendingOrderByColumn(sfBlogPostPeer::CREATED_AT );32 33 $blogs = sfBlogPostPeer::doSelect($c);34 }35 36 $this->blogs = $blogs;37 }38 39 public function executeShow()40 {41 $this->blog = sfBlogPostPeer::retrieveByTitle($this->getRequestParameter('title'));42 }43 12 } plugins/sfBlogPlugin/modules/blog_auth/actions/actions.class.php
r3432 r3433 1 <?php 1 <?php 2 //If you've copied and pasted the origional file into your own apps modules, use the line below and 3 //uncomment out the other 4 //require_once(sfConfig::get('sf_plugins_dir').'/sfBlogPlugin/modules/blog/lib/BaseBlog_authActions.class.php'); 2 5 3 /** 4 * blog_auth actions. 5 * 6 * @package erestar.net 7 * @subpackage blog_auth 8 * @author Your name here 9 * @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $ 10 */ 11 require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php'); 6 require_once(dirname(__FILE__).'/../lib/BaseBlog_authActions.class.php'); 12 7 13 class blog_authActions extends BasesfGuardAuthActions 14 { 15 /** 16 * Executes index action 17 * 18 */ 8 class blog_authActions extends BaseBlog_authActions { 19 9 20 public function executeRegister()21 {22 if($this->getRequest()->getMethod() != sfWebRequest::POST )23 {24 require_once(dirname(__FILE__).'/../lib/jpgraph_antispam.php');25 $antispam = new AntiSpam();26 $antispam_string = $antispam->rand(5);27 $this->getUser()->setAttribute('antispam', $antispam_string);28 }29 30 else {31 $user = new sfGuardUser();32 $user->setUsername($this->getRequestParameter('username'));33 $user->setPassword($this->getRequestParameter('password'));34 35 $user->save();36 $user->addPermissionByName('blog_commenter');37 38 $this->getUser()->signin($user, true);39 $referer = $this->getRequestParameter('referer', '@homepage');40 $this->redirect($referer);41 }42 }43 44 public function executeAntispam() {45 if (!$string = $this->getUser()->getAttribute('antispam')) {46 return sfView::NONE;47 }48 require_once(dirname(__FILE__).'/../lib/jpgraph_antispam.php');49 $this->getResponse()->setContentType('image/jpeg');50 $antispam = new AntiSpam($string);51 echo $antispam->stroke();52 return sfView::NONE;53 }54 55 public function handleErrorRegister()56 {57 $this->message = "Invalid parameters";58 59 return sfView::SUCCESS;60 }61 62 public function executeSignout() {63 $this->getUser()->setAuthenticated(false);64 $this->getUser()->signOut();65 $referer = $this->getRequestParameter('referer', '@homepage');66 $this->redirect($referer);67 }68 10 } 69 70 71 11 ?> plugins/sfBlogPlugin/modules/blog_comment/actions/actions.class.php
r3431 r3433 1 <?php 2 // auto-generated by sfPropelCrud 3 // date: 2007/02/09 14:20:21 1 <?php 2 //If you've copied and pasted the origional file into your own apps modules, use the line below and 3 //uncomment out the other 4 //require_once(sfConfig::get('sf_plugins_dir').'/sfBlogPlugin/modules/blog/lib/BaseBlog_commentActions.class.php'); 5 6 require_once(dirname(__FILE__).'/../lib/BaseBlog_commentActions.class.php'); 7 8 class blog_commentActions extends BaseBlog_commentActions { 9 10 } 4 11 ?> 5 <?php6 7 /**8 * blog_comment actions.9 *10 * @package erestar.net11 * @subpackage blog_comment12 * @author Your name here13 * @version SVN: $Id: actions.class.php 3335 2007-01-23 16:19:56Z fabien $14 */15 class blog_commentActions extends sfActions16 {17 public function executeIndex()18 {19 return $this->forward('blog_comment', 'list');20 }21 22 public function executeList()23 {24 $this->sf_blog_comments = sfBlogCommentPeer::doSelect(new Criteria());25 }26 27 public function executeShow()28 {29 $this->sf_blog_comment = sfBlogCommentPeer::retrieveByPk($this->getRequestParameter('id'));30 $this->forward404Unless($this->sf_blog_comment);31 }32 33 public function executeCreate()34 {35 $this->sf_blog_comment = new sfBlogComment();36 $blog = sfBlogPostPeer::retrieveByPK($this->getRequestParameter('post_id'));37 $this->forward404If(!$blog, 'That post does not exist.');38 $this->sf_blog_comment->setsfBlogPostId($blog->getId());39 $this->blog = $blog;40 $this->setTemplate('edit');41 }42 43 public function executeEdit()44 {45 $this->sf_blog_comment = sfBlogCommentPeer::retrieveByPk($this->getRequestParameter('id'));46 $this->forward404Unless($this->sf_blog_comment);47 }48 49 public function executeUpdate()50 {51 if (!$this->getRequestParameter('id'))52 {53 $sf_blog_comment = new sfBlogComment();54 }55 else56 {57 $sf_blog_comment = sfBlogCommentPeer::retrieveByPk($this->getRequestParameter('id'));58 $this->forward404Unless($sf_blog_comment);59 }60 61 $blog = sfBlogPostPeer::retrieveByPK($this->getRequestParameter('sf_blog_post_id'));62 $this->forward404If(!$blog);63 64 $sf_blog_comment->setId($this->getRequestParameter('id'));65 $sf_blog_comment->setAuthorId($this->getUser()->getGuardUser()->getId());66 $sf_blog_comment->setContent($this->getRequestParameter('content'));67 $sf_blog_comment->setSfBlogPostId($this->getRequestParameter('sf_blog_post_id') ? $this->getRequestParameter('sf_blog_post_id') : null);68 69 $sf_blog_comment->save();70 71 72 73 return $this->redirect('@get_blog_by_name?title='.$blog->getTitle());74 }75 76 public function executeDelete()77 {78 $sf_blog_comment = sfBlogCommentPeer::retrieveByPk($this->getRequestParameter('id'));79 80 $this->forward404Unless($sf_blog_comment);81 82 $sf_blog_comment->delete();83 84 return $this->redirect('blog_comment/list');85 }86 }