Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/site/app/controllers
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-06-11 11:09:56 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-06-11 11:41:36 (GMT)
commite9361d633e8163e508a4dcde36c25c94f7e8b272 (patch)
tree3d20b380b50a9384b7c4665184ce64f6a346ab9a /site/app/controllers
parentaa81b57856816069a87d962dc7fa29d8e0b8b689 (diff)
ASLO-2
Diffstat (limited to 'site/app/controllers')
-rw-r--r--site/app/controllers/addons_controller.php11
-rw-r--r--site/app/controllers/admin_controller.php2
-rw-r--r--site/app/controllers/components/amo.php3
-rw-r--r--site/app/controllers/components/developers.php10
-rw-r--r--site/app/controllers/components/editors.php134
-rw-r--r--site/app/controllers/components/email.php11
-rw-r--r--site/app/controllers/components/image.php4
-rw-r--r--site/app/controllers/developers_controller.php191
-rw-r--r--site/app/controllers/files_controller.php9
-rw-r--r--site/app/controllers/search_controller.php2
-rw-r--r--site/app/controllers/users_controller.php1
11 files changed, 341 insertions, 37 deletions
diff --git a/site/app/controllers/addons_controller.php b/site/app/controllers/addons_controller.php
index 0cca0c3..5d7e1a3 100644
--- a/site/app/controllers/addons_controller.php
+++ b/site/app/controllers/addons_controller.php
@@ -212,6 +212,9 @@ class AddonsController extends AppController
$compat_apps = $this->Version->getCompatibleApps($_latest_version);
$this->publish('compatible_apps', array_slice($compat_apps, 0, 1));
$addon_data['compatible_apps'] = $compat_apps;
+ } else {
+ $this->publish('hasversion', false);
+ $this->publish('compatible_apps', array());
}
// if the latest version is incompatible with the current app, redirect
@@ -648,7 +651,7 @@ class AddonsController extends AppController
}
// initialize pagination component
- $this->Pagination->total = $subcat_totals[$category];
+ $this->Pagination->total = isset($subcat_totals[$category]) ? $subcat_totals[$category] : 0;
$this->Pagination->sortBy = $sort_by;
$this->Pagination->direction = $sort_dir;
list($_order,$_limit,$_page) = $this->Pagination->init();
@@ -704,6 +707,10 @@ class AddonsController extends AppController
}
$type = $this->namedArgs['type'];
+ // we are sugar
+ if ($type == 'all') {
+ // pass
+ } else
// allow addontype pages only for applicable types
if (!in_array($type, $app_listedtypes[APP_ID])) {
// @TODO throw some error
@@ -830,7 +837,7 @@ class AddonsController extends AppController
$this->publish('this_tag', $this_tag);
// Build a minimal set of addon details for publishing to view.
- $_feat_ids = $this->AddonTag->getRandomAddons($category, true, 6);
+ $_feat_ids = $this->AddonTag->getRandomAddons($category, true, 6, null, $addontype=='all' ? null : $addontype);
if (count($_feat_ids) > 0) {
$_order_by = 'FIELD(Addon.id, '.implode(',', $_feat_ids).')';
} else {
diff --git a/site/app/controllers/admin_controller.php b/site/app/controllers/admin_controller.php
index 77d305c..d9ae3ec 100644
--- a/site/app/controllers/admin_controller.php
+++ b/site/app/controllers/admin_controller.php
@@ -60,7 +60,7 @@ class AdminController extends AppController
$this->Amo->clean($this->data, false);
$this->layout = 'mozilla';
- $this->pageTitle = 'Mozilla Add-ons :: Admin Control Panel';
+ $this->pageTitle = SITE_NAME.' :: Admin Control Panel';
$this->cssAdd = array('admin', 'developers');
$this->set('cssAdd', $this->cssAdd);
diff --git a/site/app/controllers/components/amo.php b/site/app/controllers/components/amo.php
index fa24b1a..92ac9ac 100644
--- a/site/app/controllers/components/amo.php
+++ b/site/app/controllers/components/amo.php
@@ -703,6 +703,9 @@ class AmoComponent extends Object {
'count' => COUNT_ADDON_PLUGIN,
);
}
+
+ // we are sugar
+ $catlist = array();
// create two sort arrays that we can use with array_multisort later
$_weights = array();
diff --git a/site/app/controllers/components/developers.php b/site/app/controllers/components/developers.php
index 15ae6b8..ceb24f8 100644
--- a/site/app/controllers/components/developers.php
+++ b/site/app/controllers/components/developers.php
@@ -231,6 +231,11 @@ class DevelopersComponent extends Object {
function detectAddontype($file) {
$extension = substr($file['name'], strrpos($file['name'], '.'));
switch ($extension) {
+ case '.xo':
+ case '.xol':
+ return ADDON_EXTENSION;
+ break;
+
case '.xpi':
// Dictionaries have a .dic file in the dictionaries directory
$zip = new Archive_Zip($file['tmp_name']);
@@ -471,6 +476,8 @@ class DevelopersComponent extends Object {
*/
function getAllowedExtensions($addontype) {
switch ($addontype) {
+ case ADDON_EXTENSION: $allowed = array('.xo', '.xol');
+ break;
case ADDON_EXTENSION: $allowed = array('.xpi');
break;
case ADDON_THEME: $allowed = array('.jar', '.xpi');
@@ -618,7 +625,8 @@ class DevelopersComponent extends Object {
$filename .= '-'.$data['Version']['version'];
- if ($data['Addon']['addontype_id'] != ADDON_SEARCH) {
+ // we are sugar
+ if (false) {
$filename .= '-';
$appString = '';
foreach ($data['appversions'] as $appversion) {
diff --git a/site/app/controllers/components/editors.php b/site/app/controllers/components/editors.php
index 2992af2..0576751 100644
--- a/site/app/controllers/components/editors.php
+++ b/site/app/controllers/components/editors.php
@@ -124,29 +124,44 @@ class EditorsComponent extends Object {
}
}
+ $releasenotes = $this->controller->Version->findById($version['Version']['id'], array('Version.releasenotes'), null, -1);
+
$emailInfo = array('name' => $addon['Translation']['name']['string'],
'id' => $this->controller->Addon->id,
'reviewer' => $session['firstname'].' '.$session['lastname'],
'email' => implode(', ', $authors),
'comments' => $data['Approval']['comments'],
- 'version' => !empty($version) ? $version['Version']['version'] : ''
+ 'version' => !empty($version) ? $version['Version']['version'] : '',
+ 'releasenotes' => $releasenotes[0]['releasenotes']
);
$this->controller->set('info', $emailInfo);
+
+ if ($data['Approval']['ActionField'] == 'public') {
+ if (SITE_RELEASE_EMAIL) {
+ $this->controller->Email->template = 'email/aslo/release';
+ $this->controller->Email->to = SITE_RELEASE_EMAIL;
+ $this->controller->Email->subject = sprintf('[RELEASE] %s-%s', $emailInfo['name'], $emailInfo['version']);
+ $this->controller->Email->send(false, SITE_RELEASE_EMAIL);
+ }
+ }
if ($data['Approval']['ActionField'] != 'superreview') {
$this->controller->Email->template = 'email/nominated/'.$data['Approval']['ActionField'];
$this->controller->Email->to = $emailInfo['email'];
- $this->controller->Email->subject = sprintf('Mozilla Add-ons: %s Nomination', $emailInfo['name']);
+ $this->controller->Email->subject = sprintf(___('editor_review_nomination_subject', 'Mozilla Add-ons: %s Nomination'), $emailInfo['name']);
}
else {
$this->controller->Email->template = 'email/superreview';
- $this->controller->Email->to = 'amo-senior-editors@mozilla.org';
+ $this->controller->Email->to = ADMIN_EMAIL;
//Doesn't need to be localized
$this->controller->Email->subject = "Super-review requested: {$emailInfo['name']}";
}
$result = $this->controller->Email->send();
+ if ($data['Approval']['ActionField'] == 'superreview')
+ $this->superNotify($emailInfo['id'], $emailInfo['version']);
+
return true;
}
@@ -251,6 +266,8 @@ class EditorsComponent extends Object {
$authors[] = $user['email'];
}
}
+
+ $releasenotes = $this->controller->Version->findById($version['Version']['id'], array('Version.releasenotes'), null, -1);
$emailInfo = array('name' => $addon['Translation']['name']['string'],
'id' => $this->controller->Addon->id,
@@ -260,22 +277,35 @@ class EditorsComponent extends Object {
'os' => $data['Approval']['os'],
'apps' => $data['Approval']['applications'],
'version' => !empty($version) ? $version['Version']['version'] : '',
- 'files' => $files
+ 'files' => $files,
+ 'releasenotes' => $releasenotes[0]['releasenotes']
);
$this->controller->set('info', $emailInfo);
+
+ if ($data['Approval']['ActionField'] == 'public') {
+ if (SITE_RELEASE_EMAIL) {
+ $this->controller->Email->template = 'email/aslo/release';
+ $this->controller->Email->to = SITE_RELEASE_EMAIL;
+ $this->controller->Email->subject = sprintf('[RELEASE] %s-%s', $emailInfo['name'], $emailInfo['version']);
+ $this->controller->Email->send(false, SITE_RELEASE_EMAIL);
+ }
+ }
if ($data['Approval']['ActionField'] != 'superreview') {
$this->controller->Email->template = 'email/pending/'.$data['Approval']['ActionField'];
$this->controller->Email->to = $emailInfo['email'];
- $this->controller->Email->subject = sprintf('Mozilla Add-ons: %s %s', $emailInfo['name'], $emailInfo['version']);
+ $this->controller->Email->subject = sprintf(___('editor_review_superreview_subject', 'Mozilla Add-ons: %s %s'), $emailInfo['name'], $emailInfo['version']);
}
else {
$this->controller->Email->template = 'email/superreview';
- $this->controller->Email->to = 'amo-senior-editors@mozilla.org';
+ $this->controller->Email->to = ADMIN_EMAIL;
//Doesn't need to be localized
$this->controller->Email->subject = "Super-review requested: {$emailInfo['name']}";
}
$result = $this->controller->Email->send();
+
+ if ($data['Approval']['ActionField'] == 'superreview')
+ $this->superNotify($emailInfo['id'], $emailInfo['version']);
return true;
}
@@ -322,7 +352,7 @@ class EditorsComponent extends Object {
$this->controller->publish('info', $emailInfo, false);
$this->controller->Email->template = 'email/inforequest';
$this->controller->Email->to = implode(', ', $authors);
- $this->controller->Email->subject = sprintf('Mozilla Add-ons: %s %s', $emailInfo['name'], $emailInfo['version']);
+ $this->controller->Email->subject = sprintf(SITE_NAME.': %s %s', $emailInfo['name'], $emailInfo['version']);
$this->controller->Email->send();
}
@@ -362,36 +392,102 @@ class EditorsComponent extends Object {
$this->controller->redirect("/editors/queue/{$listtype}");
}
+ function broadcastNotify($group, $addonid, $versionid, $exclude, $subject, $template) {
+ $session = $this->controller->Session->read('User');
+ $subscribers = array();
+
+ foreach ($this->controller->User->findAll() as $user) {
+ if ($session['id'] != $user['User']['id'] && !in_array($user, $exclude)
+ && $user['User']['notifybroadcast']
+ && $this->controller->SimpleAcl->actionAllowed($group, '*', $user))
+ $subscribers[] = $user;
+ }
+
+ if (empty($subscribers)) return;
+
+ $addon = $this->controller->Addon->getAddon($addonid);
+ $version = $this->controller->Version->findById($versionid, null, null, null, null, -1);
+
+ // send out notification email(s)
+ $emailInfo = array(
+ 'id' => $addonid,
+ 'name' => $addon['Translation']['name']['string'],
+ 'versionid' => $versionid,
+ 'version' => $version['Version']['version']
+ );
+ $this->controller->publish('info', $emailInfo, false);
+
+ $this->controller->Email->template = $template;
+ $this->controller->Email->subject = sprintf($subject, $emailInfo['name'].'-'.$emailInfo['version']);
+
+ foreach ($subscribers as &$subscriber) {
+ $this->controller->Email->to = $subscriber['User']['email'];
+ $result = $this->controller->Email->send();
+ }
+ }
+
+ function nominateNotify($addonid, $versionid) {
+ $_ids = $this->controller->EditorSubscription->getSubscribers($addonid);
+ if (empty($_ids))
+ $exclude = array();
+ else
+ $exclude = $this->controller->User->findAllById($_ids, null, null, null, null, -1);
+
+ $this->broadcastNotify('Editors', $addonid, $versionid, $exclude,
+ SITE_NAME.': %s Nomination', '../editors/email/notify_nominate');
+ }
+
+ function pendingNotify($addonid, $versionid) {
+ $this->broadcastNotify('Editors', $addonid, $versionid, array(),
+ SITE_NAME.': %s Pending update', '../editors/email/notify_pending');
+ }
+
+ function superNotify($addonid, $versionid) {
+ $this->broadcastNotify('Admin', $addonid, $versionid, array(),
+ SITE_NAME.': %s Super-review requested', '../editors/email/notify_super');
+ }
+
/**
* Notify subscribed editors of an add-on's update
* @param int $addonid ID of add-on that was updated
* @param int $versionid ID of the add-on's new version
*/
- function updateNotify($addonid, $versionid) {
+ function updateNotify($addonid, $versionid, $release_notify) {
$_ids = $this->controller->EditorSubscription->getSubscribers($addonid);
- if (empty($_ids)) return;
- $subscribers = $this->controller->User->findAllById($_ids, null, null, null, null, -1);
- $addon = $this->controller->Addon->getAddon($addonid);
+ $addon = $this->controller->Addon->findById($addonid);
$version = $this->controller->Version->findById($versionid, null, null, null, null, -1);
-
+
// send out notification email(s)
$emailInfo = array(
'id' => $addonid,
'name' => $addon['Translation']['name']['string'],
'versionid' => $versionid,
- 'version' => $version['Version']['version']
+ 'version' => $version['Version']['version'],
+ 'comments' => 'Trusted activity',
+ 'releasenotes' => SITE_URL . '/addon/' . $addonid . '#addon-advanced'
);
$this->controller->publish('info', $emailInfo, false);
$this->controller->Email->template = '../editors/email/notify_update';
- $this->controller->Email->subject = sprintf('Mozilla Add-ons: %s Updated', $emailInfo['name']);
+ $this->controller->Email->subject = sprintf(SITE_NAME.': %s Updated', $emailInfo['name']);
- foreach ($subscribers as &$subscriber) {
- $this->controller->Email->to = $subscriber['User']['email'];
- $result = $this->controller->Email->send();
- // unsubscribe user from further updates
- $this->controller->EditorSubscription->cancelUpdates($subscriber['User']['id'], $addonid);
+ if (!empty($_ids)) {
+ $subscribers = $this->controller->User->findAllById($_ids, null, null, null, null, -1);
+
+ foreach ($subscribers as &$subscriber) {
+ $this->controller->Email->to = $subscriber['User']['email'];
+ $result = $this->controller->Email->send();
+ // unsubscribe user from further updates
+ $this->controller->EditorSubscription->cancelUpdates($subscriber['User']['id'], $addonid);
+ }
+ }
+
+ if ($addon['Addon']['trusted'] == 1 && $release_notify) {
+ $this->controller->Email->template = '../editors/email/aslo/release';
+ $this->controller->Email->to = SITE_RELEASE_EMAIL;
+ $this->controller->Email->subject = sprintf('[RELEASE] %s-%s', $emailInfo['name'], $emailInfo['version']);
+ $this->controller->Email->send(false, SITE_RELEASE_EMAIL);
}
}
diff --git a/site/app/controllers/components/email.php b/site/app/controllers/components/email.php
index b62f9f7..71f20ac 100644
--- a/site/app/controllers/components/email.php
+++ b/site/app/controllers/components/email.php
@@ -10,8 +10,8 @@ class EmailComponent
/**
* Send email using SMTP Auth by default.
*/
- var $from = 'nobody@mozilla.org';
- var $fromName = 'Mozilla Add-ons';
+ var $from = NOBODY_EMAIL;
+ var $fromName = SITE_NAME;
var $sender = null;
//var $smtpUserName = 'username'; // SMTP username
//var $smtpPassword = 'password'; // SMTP password
@@ -58,7 +58,7 @@ class EmailComponent
}
- function send($html = false)
+ function send($html = false, $reply = null)
{
vendor('phpmailer'.DS.'class.phpmailer');
@@ -81,7 +81,10 @@ class EmailComponent
}
$mail->FromName = $this->fromName;
$mail->AddAddress($this->to, $this->toName );
- $mail->AddReplyTo($this->from, $this->fromName );
+ if ($reply)
+ $mail->AddReplyTo($reply);
+ else
+ $mail->AddReplyTo($this->from, $this->fromName );
$mail->CharSet = 'UTF-8';
//$mail->WordWrap = 50; // set word wrap to 50 characters
diff --git a/site/app/controllers/components/image.php b/site/app/controllers/components/image.php
index 2329f9f..b0b6992 100644
--- a/site/app/controllers/components/image.php
+++ b/site/app/controllers/components/image.php
@@ -129,7 +129,7 @@ class ImageComponent extends Object {
}
}
else {
- return "{$this->controller->base}/en-US/firefox/images/addon_icon/{$addon_id}/".strtotime($addon['Addon']['modified']);
+ return "{$this->controller->base}/en-US/".APP_SHORTNAME."/images/addon_icon/{$addon_id}/".strtotime($addon['Addon']['modified']);
}
}
@@ -200,7 +200,7 @@ class ImageComponent extends Object {
else {
// Always use en-US and firefox and append modified timestamp for
// best caching results. Serves 150-200 million. Refrigerate after serving.
- return "{$this->controller->base}/en-US/firefox/images/{$type['url']}/{$preview_id}/".strtotime($preview['Preview']['modified']);
+ return "{$this->controller->base}/en-US/".APP_SHORTNAME."/images/{$type['url']}/{$preview_id}/".strtotime($preview['Preview']['modified']);
}
}
diff --git a/site/app/controllers/developers_controller.php b/site/app/controllers/developers_controller.php
index 308ea36..f089e63 100644
--- a/site/app/controllers/developers_controller.php
+++ b/site/app/controllers/developers_controller.php
@@ -252,7 +252,7 @@ class DevelopersController extends AppController
// For non-search-engines
if ($data['Addon']['addontype_id'] != ADDON_SEARCH) {
// Make sure GUID doesn't exist already
- if ($existing = $this->Addon->findAll("Addon.guid='{$data['Addon']['guid']}'")) {
+ if (isset($data['Addon']['guid']) && ($existing = $this->Addon->findAll("Addon.guid='{$data['Addon']['guid']}'"))) {
return $this->Error->getJSONforError(sprintf(___('devcp_new_addon_error'), $data['Addon']['guid'], $this->url("/developers/versions/add/{$existing[0]['Addon']['id']}")));
}
}
@@ -339,7 +339,7 @@ class DevelopersController extends AppController
// For non-search-engines
if ($data['Addon']['addontype_id'] != ADDON_SEARCH) {
// Make sure GUID matches add-on ID
- if ($addon['Addon']['guid'] != $data['Addon']['guid']) {
+ if (!empty($data['Addon']['guid']) && $addon['Addon']['guid'] != $data['Addon']['guid']) {
return $this->Error->getJSONforError(sprintf(___('devcp_update_addon_guid_error'), $data['Addon']['guid'], $addon['Addon']['guid']));
}
}
@@ -388,7 +388,7 @@ class DevelopersController extends AppController
}
// notify subscribed editors of update (if any)
- $this->Editors->updateNotify($addon['Addon']['id'], $version_id);
+ $this->Editors->updateNotify($addon['Addon']['id'], $version_id, true);
}
elseif ($type == 'file') {
$version_id = $this->data['Version']['id'];
@@ -442,6 +442,9 @@ class DevelopersController extends AppController
$pending = $this->Addon->query("SELECT COUNT(*) AS pending FROM files WHERE status=".STATUS_PENDING." GROUP BY status");
$pendingCount = (!empty($pending[0][0]['pending']) ? ($pending[0][0]['pending'] - 1) : 0);
+ if ($data['File']['db']['status'] == STATUS_PENDING)
+ $this->Editors->pendingNotify($addon_id, $version_id);
+
return array(
'error' => 0,
'uploadtype' => $type,
@@ -453,6 +456,54 @@ class DevelopersController extends AppController
);
}
+ function _rmtree($dir) {
+ $dir = "$dir";
+
+ if ($dh = opendir($dir)) {
+ while (FALSE !== ($item = readdir($dh))) {
+ if ($item != '.' && $item != '..') {
+ $subdir = $dir . '/' . "$item";
+ if (is_dir($subdir))
+ $this->_rmtree($subdir);
+ else
+ @unlink($subdir);
+ }
+ }
+ closedir($dh);
+ @rmdir($dir);
+ }
+ }
+
+ function _unbundle($bundle, $manifest) {
+ // Extract activity.info from .xo
+ $zip = new Archive_Zip($bundle);
+ $files = $zip->listContent();
+ $first_file = $files[0]['stored_filename'];
+ $paths = split("/", $first_file, 2);
+ $activity_info_path = $paths[0].'/'.$manifest;
+ $out = array();
+
+ $tmpdir = getenv("TMPDIR");
+ if (empty($tmpdir)) $tmpdir = "/tmp";
+
+ $tmpdir = tempnam($tmpdir, 'aslo.'.getmypid().'.');
+ if (file_exists($tmpdir))
+ unlink($tmpdir);
+ if (!mkdir($tmpdir)) {
+ $out['error'] = _('devcp_error_mktmp_failed');
+ return $out;
+ }
+
+ $activity_info = $zip->extract(array('add_path' => $tmpdir, 'by_name' => array($activity_info_path)));
+ if (empty($activity_info))
+ $out['error'] = _('devcp_error_activity_info_not_found');
+ else
+ $out['manifest'] = parse_ini_file($activity_info[0]['filename']);
+
+ $this->_rmtree($tmpdir);
+ return $out;
+ }
+
/**
* Validates the file upload for all types of uploads
*/
@@ -492,6 +543,73 @@ class DevelopersController extends AppController
);
}
+ // we are sugar
+ if (true) {
+ $bundle = $addon['File']['details']['path'];
+ $pathinfo = pathinfo($bundle);
+
+ if ($pathinfo['extension'] == '.xo') {
+ $ini = $this->_unbundle($bundle, 'activity/activity.info');
+ if (isset($ini['error']))
+ return $this->Error->getJSONforError($ini['error']);
+ $ini_file = $ini['manifest'];
+
+ if (!is_array($ini_file))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_not_found'));
+ if (!isset($ini_file['name']))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_name'));
+ if (!isset($ini_file['activity_version']))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_activity_version'));
+
+ if (isset($ini_file['bundle_id']))
+ $addon['Addon']['guid'] = $ini_file['bundle_id'];
+ else if (isset($ini_file['service_name']))
+ $addon['Addon']['guid'] = $ini_file['service_name'];
+ else
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_bundle_id'));
+
+ $addon['Addon']['name'] = $ini_file['name'];
+ $addon['Addon']['summary'] = $ini_file['name'];
+ $addon['Version']['version'] = $ini_file['activity_version'];
+
+ } else {
+ $ini = $this->_unbundle($bundle, 'library/library.info');
+ if (isset($ini['error']))
+ return $this->Error->getJSONforError($ini['error']);
+ $ini_file = $ini['manifest'];
+
+ if (!is_array($ini_file))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_not_found'));
+ if (!isset($ini_file['name']))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_name'));
+ if (!isset($ini_file['long_name']))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_summary'));
+ if (!isset($ini_file['global_name']))
+ return $this->Error->getJSONforError(_('devcp_error_activity_info_missing_bundle_id'));
+
+ $addon['Addon']['name'] = $ini_file['name'];
+ $addon['Addon']['summary'] = $ini_file['long_name'];
+ $addon['Addon']['guid'] = $ini_file['global_name'];
+
+ if (!isset($this->data['Addon']['id'])) {
+ $addon['Version']['version'] = 1;
+ } else {
+ $addon_id = $this->data['Addon']['id'];
+ $_addon = $this->Addon->findById($addon_id);
+ $version = 0;
+
+ if (!empty($_addon)) {
+ foreach ($_addon['Version'] as $i) {
+ if ($i['version'] > $version) {
+ $version = $i['version'];
+ }
+ }
+ }
+
+ $addon['Version']['version'] = $version + 1;
+ }
+ }
+ } else
// Parse install.rdf file if not a search plugin
if ($addon['Addon']['addontype_id'] != ADDON_SEARCH) {
// Extract install.rdf from xpi or jar
@@ -629,6 +747,8 @@ class DevelopersController extends AppController
function _editAddonProperties($addon_id) {
// Save translations if POST data
if (!empty($this->data['Addon']) && $this->viewVars['author_role'] >= AUTHOR_ROLE_DEV) {
+ $errors = array();
+
// Split localized fields from other fields
list($localizedFields, $unlocalizedFields) = $this->Addon->splitLocalizedFields($this->data['Addon']);
@@ -673,7 +793,15 @@ class DevelopersController extends AppController
$this->Addon->id = $addon_id;
$this->Addon->saveTranslations($addon_id, $this->params['form']['data']['Addon'], $localizedFields);
- $this->Addon->save($unlocalizedFields);
+ if (!$this->Addon->save($unlocalizedFields)) {
+ foreach ($this->Addon->validationErrors as $efield => $error) {
+ switch ($efield) {
+ case 'guid':
+ $errors[$efield] = sprintf(___('devcp_error_invalid_guid'), $unlocalizedFields[$efield]);
+ break;
+ }
+ }
+ }
if (empty($errors)) {
$this->publish('success', true);
@@ -729,6 +857,17 @@ class DevelopersController extends AppController
$addon = $this->Addon->findById($addon_id);
+ // we are sugar
+ if (true) {
+ // Sugar activities only support Sugar
+ $supportedApps = array(
+ 0 => array(
+ 'Application' => array(
+ 'id' => APP_FIREFOX
+ )
+ )
+ );
+ } else
if ($addon['Addon']['addontype_id'] == ADDON_SEARCH) {
// Search engines don't have supported applications
$supportedApps = array(
@@ -778,6 +917,11 @@ class DevelopersController extends AppController
$this->publish('applications', $this->Application->getIDList());
+ // we are sugar
+ if (true) {
+ // since we have only one application_id
+ $otherTags = array();
+ } else
// The "Other" category for each application that has one
if ($addon['Addon']['addontype_id'] == ADDON_SEARCH) {
$otherTags = array(
@@ -887,7 +1031,18 @@ class DevelopersController extends AppController
$criteria['category'] = !empty($addon['Tag']);
$criteria['previews'] = !empty($previews);
$criteria['prerelease'] = !empty($addon['Addon']['prerelease']) ? false : true;
+ $criteria['application'] = !empty($versions) ? true : false;
+ if (!empty($versions)) {
+ foreach ($addon['Version'] as $version) {
+ $apps = $this->Version->getCompatibleAppIds($version['id']);
+ if (empty($apps)) {
+ $criteria['application'] = false;
+ break;
+ }
+ }
+ }
+
return $criteria;
}
@@ -906,7 +1061,7 @@ class DevelopersController extends AppController
$criteria = $this->_checkCriteria($this->viewVars['addon_id']);
// Make sure criteria is fulfilled
- if (!$criteria['name'] || !$criteria['summary'] || !$criteria['description'] || !$criteria['category']) {
+ if (!$criteria['name'] || !$criteria['summary'] || !$criteria['description'] || !$criteria['category'] || !$criteria['application']) {
return true;
}
@@ -963,7 +1118,8 @@ class DevelopersController extends AppController
// notify subscribed editors of update
global $valid_status;
$version_id = $this->Version->getVersionByAddonId($addon['Addon']['id'], $valid_status);
- $this->Editors->updateNotify($addon['Addon']['id'], $version_id);
+ $this->Editors->updateNotify($addon['Addon']['id'], $version_id, false);
+ $this->Editors->nominateNotify($addon['Addon']['id'], $version_id);
}
}
@@ -1121,8 +1277,27 @@ class DevelopersController extends AppController
$version_id = $version['Version']['id'];
$addon_id = $version['Version']['addon_id'];
+ $need_post = (!empty($this->data['Version']) && $this->viewVars['author_role'] >= AUTHOR_ROLE_DEV);
+ $error = True;
+
+ if ($need_post && !empty($this->data['Application'])) {
+ foreach ($this->data['Application'] as $application_id => $app) {
+ if (!empty($app['new']) || empty($app['delete'])) {
+ $error = False;
+ break;
+ }
+ }
+ }
+
+ if (!$need_post) {
+ // pass
+ }
+ else if ($error) {
+ $errors = array('applications' => ___('devcp_error_empty_application_list'));
+ $this->publish('errors', $errors);
+ }
// Save data if POST data
- if (!empty($this->data['Version']) && $this->viewVars['author_role'] >= AUTHOR_ROLE_DEV) {
+ else {
// Save translated fields (only releasenotes)
list($localizedFields, $unlocalizedFields) = $this->Version->splitLocalizedFields($this->data['Version']);
$this->Version->saveTranslations($version_id, $this->params['form']['data']['Version'], $localizedFields);
@@ -1389,6 +1564,8 @@ class DevelopersController extends AppController
$return['success'][] = sprintf(___('devcp_add_previews_success_replace'), $id, $name);
else
$return['success'][] = sprintf(___('devcp_add_previews_success_upload'), $name);
+
+ $this->data['Preview']['highlight'] = $previewData['highlight'];
}
else
$return['errors'][] = sprintf(___('devcp_add_previews_save_error'), $name);
diff --git a/site/app/controllers/files_controller.php b/site/app/controllers/files_controller.php
index da78b3c..694085d 100644
--- a/site/app/controllers/files_controller.php
+++ b/site/app/controllers/files_controller.php
@@ -116,6 +116,15 @@ class FilesController extends AppController
foreach ($contents as $content) {
$isJar = false;
+ if ($addontype == ADDON_EXTENSION) {
+ $paths = split("/", $content['filename'], 2);
+ $pathinfo = pathinfo($path);
+ if ($pathinfo['extension'] == '.xo')
+ $startfile = $paths[0].'/activity/activity.info';
+ else
+ $startfile = $paths[0].'/library/library.info';
+ }
+
if (substr($content['filename'], strrpos($content['filename'], '.')) == '.jar') {
$content['folder'] = 1;
$isJar = true;
diff --git a/site/app/controllers/search_controller.php b/site/app/controllers/search_controller.php
index 65e8ebd..670bc15 100644
--- a/site/app/controllers/search_controller.php
+++ b/site/app/controllers/search_controller.php
@@ -179,7 +179,7 @@ class SearchController extends AppController
$this->publish('vfuz', $vfuz);
// execute this search
- $_result_ids = $this->Search->search($_terms, $category[0], $category[1], NULL, $lver, $hver, $vfuz, $atype, $pid, $lup, $sort);
+ $_result_ids = $this->Search->search($_terms, $category[0], $category[1], NULL, $lver, $hver, $vfuz, $atype, $pid == PLATFORM_ANY ? PLATFORM_ANY : $pid+1, $lup, $sort);
if ($this->params['action'] != 'rss') {
$this->pageTitle = _('search_pagetitle').' :: '.sprintf(_('addons_home_pagetitle'), APP_PRETTYNAME);
diff --git a/site/app/controllers/users_controller.php b/site/app/controllers/users_controller.php
index b906d1e..a848e4e 100644
--- a/site/app/controllers/users_controller.php
+++ b/site/app/controllers/users_controller.php
@@ -489,6 +489,7 @@ class UsersController extends AppController
// notifications
$changed['notifycompat'] = $this->data['User']['notifycompat'];
$changed['notifyevents'] = $this->data['User']['notifyevents'];
+ $changed['notifybroadcast'] = $this->data['User']['notifybroadcast'];
// save it
$this->User->id = $sessionuser['id'];