예제 #1
0
 public function getCategories()
 {
     return sfSimpleForumCategoryPeer::retrieveByOwnerId($this->getId());
 }
예제 #2
0
 public function getForumCategories()
 {
     $categories = sfSimpleForumCategoryPeer::retrieveByProjectId($this->getId());
     if ($categories == null) {
         $owner_object = sfSimpleForumOwnerPeer::retrieveByModelId('project', $this->getId());
         if ($owner_object == null) {
             $owner_object = new sfSimpleForumOwner();
             $owner_object->setModel('project');
             $owner_object->setModelId($this->getId());
             $owner_object->setTitle($this->getTitle() . ' Forum Categories');
             $owner_object->save();
         }
         $category = new sfSimpleForumCategory();
         $category->setName($this->getTitle() . ' Default');
         $category->setDescription('Default forum for project ' . $this->getTitle());
         $category->setOwnerId($owner_object->getId());
         $category->save();
         $forum = $category->newForum('Default ' . $this->getTitle() . ' Forum', 'A general forum for discussing anything related to the project "' . $this->getTitle() . '"');
         return $owner_object->getCategories();
     }
     return $categories;
 }
예제 #3
0
 public function countsfSimpleForumCategorys($criteria = null, $distinct = false, $con = null)
 {
     include_once 'lib/model/om/BasesfSimpleForumCategoryPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     $criteria->add(sfSimpleForumCategoryPeer::OWNER_ID, $this->getId());
     return sfSimpleForumCategoryPeer::doCount($criteria, $distinct, $con);
 }
if (!$app) {
    throw new Exception('No app has been detected in this project');
}
// -- path to the symfony project where the plugin resides
$sf_path = dirname(__FILE__) . '/../../../..';
// bootstrap
include $sf_path . '/test/bootstrap/functional.php';
// create a new test browser
$browser = new sfTestBrowser();
$browser->initialize();
// initialize database manager
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
// cleanup database
sfSimpleForumCategoryPeer::doDeleteAll();
sfSimpleForumForumPeer::doDeleteAll();
sfSimpleForumPostPeer::doDeleteAll();
// Now we can start to test
$t = new lime_test(34, new lime_output_color());
// Initialization
$cat = new sfSimpleForumCategory();
$cat->save();
$forum = new sfSimpleForumForum();
$forum->setCategoryId($cat->getId());
$forum->save();
$topic = new sfSimpleForumTopic();
$topic->setTitle('This is a test');
$topic->setsfSimpleForumForum($forum);
$topic->save();
$user0 = new sfGuardUser();
 public static function doSelectJoinAllExceptsfSimpleForumPost(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BasesfSimpleForumForumPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BasesfSimpleForumForumPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     sfSimpleForumForumPeer::addSelectColumns($c);
     $startcol2 = sfSimpleForumForumPeer::NUM_COLUMNS - sfSimpleForumForumPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     sfSimpleForumCategoryPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + sfSimpleForumCategoryPeer::NUM_COLUMNS;
     $c->addJoin(sfSimpleForumForumPeer::CATEGORY_ID, sfSimpleForumCategoryPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = sfSimpleForumForumPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = sfSimpleForumCategoryPeer::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->getsfSimpleForumCategory();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addsfSimpleForumForum($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initsfSimpleForumForums();
             $obj2->addsfSimpleForumForum($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = sfSimpleForumCategoryPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setOwnerId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setStrippedName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDescription($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setRank($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setCreatedAt($arr[$keys[6]]);
     }
 }
예제 #7
0
 public function getsfSimpleForumCategory($con = null)
 {
     if ($this->asfSimpleForumCategory === null && $this->category_id !== null) {
         include_once 'lib/model/om/BasesfSimpleForumCategoryPeer.php';
         $this->asfSimpleForumCategory = sfSimpleForumCategoryPeer::retrieveByPK($this->category_id, $con);
     }
     return $this->asfSimpleForumCategory;
 }
 public static function retrieveByPK($id, $owner_id, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(sfSimpleForumCategoryPeer::ID, $id);
     $criteria->add(sfSimpleForumCategoryPeer::OWNER_ID, $owner_id);
     $v = sfSimpleForumCategoryPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }