diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-07-15 02:40:27 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-07-15 02:40:27 (GMT) |
commit | 260db50bb569cbcf46dbfd1e1441511f05912824 (patch) | |
tree | d32c12d3303def22fd3e7ec997fed198dba5970e | |
parent | 46f9cde6a4171c7ade1b05fc110ca5e6c6b9f98c (diff) |
Setup appversions before uploading new .xo
-rw-r--r-- | site/app/controllers/developers_controller.php | 18 | ||||
-rw-r--r-- | site/app/models/version.php | 26 | ||||
-rw-r--r-- | site/app/views/developers/uploader.thtml | 23 |
3 files changed, 38 insertions, 29 deletions
diff --git a/site/app/controllers/developers_controller.php b/site/app/controllers/developers_controller.php index eb04bbe..435cee0 100644 --- a/site/app/controllers/developers_controller.php +++ b/site/app/controllers/developers_controller.php @@ -237,7 +237,7 @@ class DevelopersController extends AppController $this->publish('type', 'new'); $this->publish('hasAgreement', false); - $this->render('uploader'); + $this->_uploader(); } /** @@ -280,6 +280,8 @@ class DevelopersController extends AppController $this->Version->save($data['Version']); $data['Version']['id'] = $this->Version->getLastInsertId(); + $this->Version->addCompatibleApp($data['Version']['id'], SITE_APP, $this->data['appversion_min'], $this->data['appversion_max']); + // Save appversions if (!empty($data['appversions'])) { foreach ($data['appversions'] as $appversion) { @@ -406,6 +408,8 @@ class DevelopersController extends AppController } } $data['Version']['id'] = $version_id; + + $this->Version->addCompatibleApp($data['Version']['id'], SITE_APP, $this->data['appversion_min'], $this->data['appversion_max']); // Add Files $data['File']['db']['version_id'] = $version_id; @@ -1255,6 +1259,16 @@ class DevelopersController extends AppController $this->render('versions'); } + function _uploader() { + $app_versions = $this->Appversion->findAllByApplication_id(SITE_APP, + array('Appversion.id', 'Appversion.version'), 'Appversion.version ASC'); + $this->publish('app_versions', $app_versions); + $app_names = $this->Application->getNames(); + $this->publish('app_name', $app_names[SITE_APP]); + + $this->render('uploader'); + } + /** * Add a Version * @param int $addon_id the add-on id @@ -1272,7 +1286,7 @@ class DevelopersController extends AppController $addon = $this->Addon->findById($addon_id, array('Addon.dev_agreement')); $this->publish('hasAgreement', $addon['Addon']['dev_agreement']); - $this->render('uploader'); + $this->_uploader(); } /** diff --git a/site/app/models/version.php b/site/app/models/version.php index e323ac2..70c7468 100644 --- a/site/app/models/version.php +++ b/site/app/models/version.php @@ -301,31 +301,5 @@ class Version extends AppModel return $file_ids; } - function save($data = null, $validate = true, $fieldList = array()) { - $result = parent::save($data, $validate, $fieldList); - - if ($result) { - $versions = $this->getCompatibleApps($this->id); - - if (empty($versions)) { - $sql = " - SELECT - a.id - FROM - appversions AS a - WHERE - a.application_id = ".SITE_APP." - ORDER BY - a.version DESC - LIMIT 1"; - - $rows = $this->query($sql); - $version = $rows[0]['a']['id']; - $this->addCompatibleApp($this->id, SITE_APP, $version, $version); - } - } - - return $result; - } } ?> diff --git a/site/app/views/developers/uploader.thtml b/site/app/views/developers/uploader.thtml index ff38933..d294816 100644 --- a/site/app/views/developers/uploader.thtml +++ b/site/app/views/developers/uploader.thtml @@ -113,10 +113,31 @@ <?php endif; ?> <div id="file-upload"<?=($showAgreement ? ' style="display: none;"' : '')?>> + <form id="upload-form" method="post" enctype="multipart/form-data" action="<?=$html->url('/developers/json/fileupload/'.$type)?>" target="upload-frame" onsubmit="return upload.uploadFile();"> + <h3><?=___('devcp_versions_edit_header_compat')?></h3> + <p><?=sprintf(___('devcp_versions_edit_adjust'), '/pages/appversions')?></p> + <table id="edit-versions-targetapps-table" class="pretty-table"><tbody> + <?php + echo '<td class="appname">'.$app_name.'</td>'; + echo '<td><select name="data[appversion_min]">'; + $max = 0; + foreach ($app_versions as $i) { + echo '<option value="'.$i['Appversion']['id'].'"'.($max == 0 ? ' selected="selected"' : '').'>'.$i['Appversion']['version'].'</option>'; + $max = $i['Appversion']['id']; + } + echo '</select>'; + echo ' — '; + echo '<select name="data[appversion_max]">'; + foreach ($app_versions as $i) { + echo '<option value="'.$i['Appversion']['id'].'"'.($max == $i['Appversion']['id'] ? ' selected="selected"' : '').'>'.$i['Appversion']['version'].'</option>'; + } + echo '</select></td>'; + ?> + </tbody></table> + <h3><?=___('devcp_uploader_header_upload')?></h3> <p><?=___('devcp_uploader_p_upload')?> <br /> - <form id="upload-form" method="post" enctype="multipart/form-data" action="<?=$html->url('/developers/json/fileupload/'.$type)?>" target="upload-frame" onsubmit="return upload.uploadFile();"> <?=$html->hiddenSession();?> <?=(!empty($addon_id) ? '<input type="hidden" name="data[Addon][id]" value="'.$addon_id.'" />' : '')?> <?=(!empty($version_id) ? '<input type="hidden" name="data[Version][id]" value="'.$version_id.'" />' : '')?> |