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 static function sendNotificationMail(Community $community, $id, $type, $nickname, $subject, $body) { if (version_compare(OPENPNE_VERSION, '3.6beta1-dev', '<')) { return null; } sfContext::getInstance()->getConfiguration()->loadHelpers(array('opUtil')); $params = array('community_name' => $community->getName(), 'wiki_name' => $subject, 'nickname' => $nickname, 'body' => $body); $rs = Doctrine::getTable('CommunityMember')->createQuery()->where('community_id = ?', array($community->getId()))->andWhere('is_receive_mail_pc = ? OR is_receive_mail_mobile = ?', array(true, true))->execute(array(), Doctrine::HYDRATE_ON_DEMAND); foreach ($rs as $r) { $member = $r->getMember(); $memberPcAddress = $member->getConfig('pc_address'); $memberMobileAddress = $member->getConfig('mobile_address'); $from = self::getPostMailAddress('mail_community_' . $type . '_comment_create', array('id' => $id, 'hash' => $member->getMailAddressHash())); if ($r->getIsReceiveMailPc() && $memberPcAddress) { $params['url'] = app_url_for('pc_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberPcAddress, $from, $params); } if ($r->getIsReceiveMailMobile() && $memberMobileAddress) { $params['url'] = app_url_for('mobile_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberMobileAddress, $from, $params); } } }