public function __construct($data = array())
 {
     parent::__construct($data);
     $this->site = opPluginChannelServerToolkit::getConfig('related_redmine_base_url', 'http://redmine.openpne.jp/');
     $this->request_format = 'xml';
     $this->element_name = 'users';
 }
/**
* Copyright 2010 Kousuke Ebihara
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function get_plugin_download_url($name, $version, $extension = '')
{
    $base_url = opPluginChannelServerToolkit::getConfig('package_download_base_url');
    if ($base_url) {
        $filename = $name . '-' . $version;
        if ($extension) {
            $filename .= '.' . $extension;
        }
        return $base_url . $filename;
    }
    $route = '@plugin_download_without_extension';
    if ($extension) {
        $route = '@plugin_download_' . $extension;
    }
    $route .= '?version=' . $version . '&name=' . $name;
    return url_for($route, true);
}
 public function executeReleaseDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->release->delete();
     $path = opPluginChannelServerToolkit::getFilePathToCache($this->release->Package->name, $this->release->version);
     @unlink($path);
     $this->getUser()->setFlash('notice', 'The release is removed successfully.');
     $this->redirect('package_home', $this->release->Package);
 }
<?php

slot('op_sidemenu');
include_partial('pluginInformationBar', array('package' => $release->Package));
end_slot();
?>

<?php 
use_helper('opPluginChannelServerPlugin');
$channelOption = '';
if (opPluginChannelServerToolkit::getConfig('channel_name') !== opPluginManager::OPENPNE_PLUGIN_CHANNEL) {
    $channelOption = ' --channel=' . opPluginChannelServerToolkit::getConfig('channel_name');
}
op_include_parts('listBox', 'releaseInfoList', array('title' => __('Detail of this release'), 'list' => array(__('Plugin') => $release->Package->name, __('Version') => $release->version, __('Stability') => __($release->stability), __('Release Note') => PEAR::isError($info->getRawValue()) ? '' : nl2br($info['notes']), __('Installation') => __('Install the plugin:') . '<br />
      <code>$ ./symfony opPlugin:install ' . $release->Package->name . ' -r ' . $release->version . $channelOption . '</code><br />
      <br />' . __('Migrate your model and database:') . '<br />
      <code>$ ./symfony openpne:migrate --target=' . $release->Package->name . '</code><br />
      ', __('Download') => link_to(get_plugin_download_url($release->Package->name, $release->version, 'tgz'), get_plugin_download_url($release->Package->name, $release->version, 'tgz')))));
if ($release->isAllowed($sf_user->getRawValue()->getMember(), 'delete')) {
    op_include_form('removeRelease', $form, array('title' => __('Do you want to delete this release?'), 'button' => __('Delete'), 'url' => url_for('@release_delete?id=' . $release->id)));
}
?>
 1.0.0 "First stable release."</code>
<?php 
if (opPluginChannelServerToolkit::getConfig('channel_name') !== opPluginManager::OPENPNE_PLUGIN_CHANNEL) {
    ?>
<br />
<br />
[<?php 
    echo __('OpenPNE 3.5.0 +');
    ?>
]<br />
<code>$ ./symfony opPlugin:define <?php 
    echo $package->name;
    ?>
 1.0.0 "First stable release." --channel=<?php 
    echo opPluginChannelServerToolkit::getConfig('channel_name');
    ?>
</code>
<?php 
}
?>
<dl>
<dt><?php 
echo __('The first argument');
?>
</dt><dd><?php 
echo __('The name of plugin which you want to release');
?>
</dd>
<dt><?php 
echo __('The second argument');
 public function executeDownloadTgz(sfWebRequest $request)
 {
     $version = $request['version'];
     $this->package = $this->getRoute()->getObject();
     $this->release = Doctrine::getTable('PluginRelease')->findOneByPackageIdAndVersion($this->package->id, $version);
     $this->forward404Unless($this->release);
     $bin = $this->release->File->FileBin->bin;
     $path = opPluginChannelServerToolkit::getFilePathToCache($this->package->name, $version);
     @file_put_contents($path, $bin);
     @chmod($path, 0777);
     header('Content-type: ' . $this->release->File->type);
     echo $bin;
     exit;
 }
<style type="text/css">
.example
{
  margin-bottom: 1em;
  padding: 1em;
  background-color: #CCCCCC;
}
</style>

<?php 
if (opPluginChannelServerToolkit::getConfig('channel_name') !== opPluginManager::OPENPNE_PLUGIN_CHANNEL) {
    include_box('usageBox', __('How to use this plugin channel server'), '<p>' . __('If you want to use plugins in this channel server, please install by the following command:') . '</p>' . '<div class="example"><code>$ ./symfony opPlugin:install [plugin-name] --channel=' . opPluginChannelServerToolkit::getConfig('channel_name') . '</code></div>' . '<p>' . __('You can set this server as your default channel server (only OpenPNE 3.5.0 +). Edit your config/OpenPNE.yml like:') . '</p>' . '<div class="example"><code>default_plugin_channel_server: ' . opPluginChannelServerToolkit::getConfig('channel_name') . '</code></div>');
} else {
    include_box('usageBox', __('How to use this plugin channel server'), '<p>' . __('If you want to use plugins in this channel server, please install by the following command:') . '</p>' . '<div class="example"><code>$ ./symfony opPlugin:install [plugin-name]</code></div>');
}
 protected function uploadToS3(File $file)
 {
     $key = sfConfig::get('op_plugin_channel_s3_key');
     $secret = sfConfig::get('op_plugin_channel_s3_secret');
     $bucket = sfConfig::get('op_plugin_channel_s3_bucket');
     if ($key && $secret && $bucket) {
         opPluginChannelServerToolkit::uploadFileToS3($key, $secret, $bucket, $file);
     }
 }
 public function updateObject($values = null)
 {
     $member = sfContext::getInstance()->getUser()->getMember();
     $baseUrl = opPluginChannelServerToolkit::getConfig('related_redmine_base_url', 'http://redmine.openpne.jp/');
     if (is_null($values)) {
         $values = $this->getValues();
     }
     $image = null;
     if (array_key_exists('file_id', $values)) {
         $image = $values['file_id'];
         unset($values['file_id']);
     }
     $obj = parent::updateObject($values);
     $obj->save();
     if ($this->isNew()) {
         $obj->PluginMember[0]->Member = $member;
         $obj->PluginMember[0]->position = 'lead';
         $obj->PluginMember[0]->is_active = true;
     }
     if ($image instanceof sfValidatedFile) {
         $oldImage = clone $obj->Image;
         $obj->Image = new File();
         $obj->Image->setFromValidatedFile($image);
         $obj->Image->name = 'plugin_' . $obj->getId() . '_' . $obj->Image->name;
         if ($oldImage) {
             $oldImage->delete();
         }
     } elseif ($this->getValue('file_id_delete')) {
         if ($obj->Image) {
             $obj->Image->delete();
             $obj->Image = null;
         }
     }
     sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
     $pluginUrl = url_for('package_home', $obj, true);
     $url = $this->injectAPIKeyToRedminUrl($baseUrl, $member->getConfig('redmine_api_token'));
     $user = new opRedmineUserResource();
     $user->find($member->getConfig('redmine_username'));
     $url = $this->injectAPIKeyToRedminUrl($baseUrl, $member->getConfig('redmine_api_token'));
     $project = new opRedmineProjectResource();
     $project->site = $url;
     $project->find($this->generatePluginIdentifier($obj->name));
     if ($project->error) {
         $parentId = opPluginChannelServerToolkit::getConfig('parent_project_id');
         $project = new opRedmineProjectResource(array('name' => $obj->name, 'identifier' => $this->generatePluginIdentifier($obj->name), 'homepage' => $pluginUrl, 'description' => $obj->description, 'parent_id' => $parentId));
         $project->site = $url;
     } else {
         $project->set('description', $obj->description);
         $project->set('homepage', $pluginUrl);
     }
     $result = $project->save();
     $projectMember = new opRedmineMemberResource(array('user_ids' => array($user->id), 'role_ids' => array(opPluginChannelServerToolkit::getConfig('user_role_id', 1))));
     $projectMember->site = $url . '/projects/' . $this->generatePluginIdentifier($obj->name) . '/';
     $projectMember->save();
     if (!empty($values['is_relating_redmine'])) {
         $obj->bts = $baseUrl . 'projects/' . $this->generatePluginIdentifier($obj->name);
     }
     $obj->save();
 }