Beispiel #1
0
 public function setConfig($name, $value)
 {
     $config = Doctrine::getTable('CommunityConfig')->findOneByNameAndCommunityId($name, $this->getId());
     if (!$config) {
         $config = new CommunityConfig();
         $config->setCommunity($this);
         $config->setName($name);
     }
     $config->setValue($value);
     $config->save();
 }
 public function save()
 {
     foreach ($this->getValues() as $key => $value) {
         $config = Doctrine::getTable('CommunityConfig')->retrieveByNameAndCommunityId($key, $this->community->getId());
         if (!$config) {
             $config = new CommunityConfig();
             $config->setCommunity($this->community);
             $config->setName($key);
         }
         $config->setValue($value);
         $config->save();
     }
 }
Beispiel #3
0
 /**
  * Executes index action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeSearch(sfWebRequest $request)
 {
     $value = Doctrine::getTable("CommunityConfig")->retrieveValueByNameAndCommunityId($request['key'], $request['community_id']);
     if ($value) {
         $ar = array("status" => "success", "data" => array("community_id" => $request['community_id'], "key" => $request['key'], "value" => $value));
         return $this->renderText(json_encode($ar));
     } else {
         $q = new CommunityConfig();
         $q->setName('memo');
         $q->setValue('');
         $q->setCommunityId($request['community_id']);
         $q->save();
         $ar = array("status" => "success", "data" => array("community_id" => $request['community_id'], "key" => $request['key'], "value" => ''));
         return $this->renderText(json_encode($ar));
     }
 }
 public function save()
 {
     $community = Doctrine::getTable('Community')->find($this->getValue('id'));
     if (!$community) {
         return false;
     }
     $communityConfig = Doctrine::getTable('CommunityConfig')->retrieveByNameAndCommunityId('is_default', $community->getId());
     if (!$communityConfig) {
         $communityConfig = new CommunityConfig();
     }
     $communityConfig->setCommunity($community);
     $communityConfig->setName('is_default');
     $communityConfig->setValue(1);
     $communityConfig->save();
     return true;
 }
 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;
 }