protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection(); $sql = 'SELECT id FROM community'; $where = array(); if ( $options['cmin'] && $options['cmax'] && $options['cmin'] <= $options['cmax']) { $sql .= ' WHERE id BETWEEN ? AND ?'; $where = array(intval($options['cmin']),intval($options['cmax'])); } $commuIds = $this->conn->fetchColumn($sql, $where); foreach ($commuIds as $cid) { for ($i=0; $i < $options['number']; ++$i) { $ct = new CommunityTopic(); $ct->setCommunity(Doctrine::getTable('community')->find($cid)); $ct->setMemberId(self::fetchRandomMemberId($cid)); $ct->setName('name'); $ct->setBody('body'); $ct->save(); $ct->free(); $this->logSection('created a community topic', sprintf("%s", $cid)); } } }
public function insert(SimpleXMLElement $xml) { $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string) $xml->author->uri)); if (!$member) { return false; } if ($this->member) { $acl = $this->getCollectionAcl($this->getParentObject(), $this->member); if (!$acl || !$acl->isAllowed($this->member->id, null, 'add')) { return false; } } $topic = new CommunityTopic(); $topic->setMember($member); $topic->setCommunity($this->getParentObject()); $topic->setName((string) $xml->title); $topic->setBody((string) $xml->content); $topic->save(); return $topic; }