protected function executeTransaction($conn, $arguments = array(), $options = array()) { $n = (int) $options['number']; $adminMember = Doctrine::getTable('Member')->find($options['admin-member']); if (!$adminMember) { throw new Exception("not found member: " . $options['admin-member']); } $communityCategory = Doctrine::getTable('CommunityCategory')->find($options['category']); if (!$communityCategory) { throw new Exception("not found category: " . $options['category']); } for ($i = 0; $i < $n; $i++) { $community = new Community(); $community->setName('dummy'); $community->setCommunityCategory($communityCategory); $community->save(); $community->setName(sprintf($options['name-format'], $community->getId())); $community->save(); $configData = array(array('description', $community->getName())); if (version_compare(OPENPNE_VERSION, '3.5.0-dev', '>=')) { // new version $configData[] = array('register_policy', 'open'); } else { // old version $configData[] = array('register_poricy', 'open'); } foreach ($configData as $config) { $communityConfig = new CommunityConfig(); $communityConfig->setCommunity($community); $communityConfig->setName($config[0]); $communityConfig->setValue($config[1]); $communityConfig->save(); } $communityMember = new CommunityMember(); $communityMember->setCommunity($community); $communityMember->setMember($adminMember); if (version_compare(OPENPNE_VERSION, '3.3.1-dev', '>=')) { $communityMember->addPosition('admin'); } else { $communityMember->setPosition('admin'); } $communityMember->save(); $this->logSection('community+', $community->getName()); } }
private function createCluster($memberNum, $offset) { $memberIds = array(); $members = Doctrine::getTable('Member')->createQuery()->select('id')->where('is_active != 0')->limit($memberNum)->offset($memberNum * $offset)->execute(); for ($i = 0; $i < $memberNum; ++$i) { $community = new Community(); $community->setName('dummy'); $community->save(); $community->setName(sprintf('dummy%d community', $community->getId())); $community->save(); $configData = array( array('description', $community->getName()), array('topic_authority', 'public'), array('public_flag', 'public'), array('register_policy', 'open') ); foreach ($configData as $config) { $communityConfig = new CommunityConfig(); $communityConfig->setCommunity($community); $communityConfig->setName($config[0]); $communityConfig->setValue($config[1]); $communityConfig->save(); $communityConfig->free(); } for ($j = 0; $j < $memberNum; ++$j) { $communityMember = new CommunityMember(); $communityMember->setCommunity($community); $communityMember->setMember($members[$j]); if (0 == $j) { $communityMember->addPosition('admin'); } $communityMember->save(); } } }
public function insert(SimpleXMLElement $xml) { $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string) $xml->author->uri)); if (!$member) { return false; } $community = new Community(); $community->setName((string) $xml->title); $community->save(); $admin = new CommunityMember(); $admin->setPosition('admin'); $admin->setMember($member); $admin->setCommunity($community); $admin->save(); $config = new CommunityConfig(); $config->setName('description'); $config->setValue((string) $xml->content); $config->setCommunity($community); $config->save(); return $community; }