diff options
Diffstat (limited to 'site/app/controllers/admin_controller.php')
-rw-r--r-- | site/app/controllers/admin_controller.php | 154 |
1 files changed, 22 insertions, 132 deletions
diff --git a/site/app/controllers/admin_controller.php b/site/app/controllers/admin_controller.php index d9ae3ec..7495e90 100644 --- a/site/app/controllers/admin_controller.php +++ b/site/app/controllers/admin_controller.php @@ -39,7 +39,7 @@ class AdminController extends AppController { var $name = 'Admin'; - var $uses = array('Addon', 'Addontype', 'Application', 'Approval', 'Appversion', 'Cannedresponse', 'Collection', 'CollectionPromo', 'Eventlog', 'Feature', 'File', 'Group', 'Platform', 'Tag', 'Translation', 'User', 'Version', 'Memcaching'); + var $uses = array('Addon', 'Addontype', 'Application', 'Approval', 'Appversion', 'Cannedresponse', 'Eventlog', 'Feature', 'File', 'Group', 'Platform', 'Tag', 'Translation', 'User', 'Version', 'Memcaching'); var $components = array('Amo', 'Audit', 'Developers', 'Error', 'Versioncompare'); var $helpers = array('Html', 'Javascript'); //These defer to their own access checks @@ -67,11 +67,12 @@ class AdminController extends AppController $this->set('jsAdd', array('developers', 'jquery-compressed.js', - 'jquery.autocomplete.pack.js')); + 'jquery.autocomplete.js')); $this->set('suppressJQuery', 1); $this->breadcrumbs = array('Admin Control Panel' => '/admin/index'); $this->set('breadcrumbs', $this->breadcrumbs); + $this->set('suppressJQuery', 1); $this->set('subpagetitle', 'Admin Control Panel'); @@ -113,7 +114,7 @@ class AdminController extends AppController } if (!defined('USERAPP')) { - define('USERAPP', 1); // Firefox + define('USERAPP', SITE_APP); // Firefox } $this->Session->write('Features', array('userlang' => USERLANG, 'userapp' => USERAPP)); @@ -151,10 +152,11 @@ class AdminController extends AppController $this->set('last24', $last24); //Counts - $count['extensions'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_EXTENSION); - $count['themes'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_THEME); - $count['dictionaries'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_DICT); - $count['searchengines'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_SEARCH); + $count['activities'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_ACTIVITY); + //$count['extensions'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_EXTENSION); + //$count['themes'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_THEME); + //$count['dictionaries'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_DICT); + //$count['searchengines'] = $this->Addon->query("SELECT COUNT(*) FROM addons WHERE addontype_id=".ADDON_SEARCH); $now = time(); $count['activeSessions'] = $this->Addon->query("SELECT COUNT(*) FROM cake_sessions WHERE expires > {$now}"); $this->set('count', $count); @@ -522,77 +524,6 @@ class AdminController extends AppController $this->set('page', 'applications'); $this->render('applications_create'); } - - /** - * Collections Manager - */ - function collections($action='') { - switch($action) { - case 'promobox': - $this->_collectionsPromoBox(); - break; - default: - $this->set('page', 'collections'); - $this->render('collections'); - break; - } - } - - function _collectionsPromoBox() { - - if (!empty($_POST)) { - switch ($_POST['action']) { - case 'add': - global $valid_languages; - // It's easiest just to split out the stuff we need here and pass it into a custom function. - if (preg_match('/\[(\d+)\]/', $this->data['Collection']['name'], $matches)) { - $_collection_id = $matches[1]; - } else { - $this->Error->addError('Collection ID must be specified in brackets.'); - } - - if (in_array($_POST['locale'], array_keys($valid_languages))) { - $_locale = $_POST['locale']; - } else if ($_POST['locale'] == 'all') { - $_locale = ''; - } else { - $this->Error->addError('Invalid locale specified.'); - } - - if (in_array($_POST['titletagline'], array_keys($this->CollectionPromo->titles_and_taglines))) { - $_titletagline = $_POST['titletagline']; - } else { - $this->Error->addError('Invalid Title/TagLine specified.'); - } - - if ($this->Error->noErrors()) { - $this->CollectionPromo->promoteCollection($_collection_id, $_titletagline, $_locale); - $this->data = array(); // reset so it doesn't prefill the box again - $this->publish('changeSuccess', true); - } - break; - case 'delete': - list($_collection_id, $_titletagline, $_locale) = explode('--',$_POST['target']); - $_locale = ($_locale == 'all') ? '' : $_locale; - - if ($this->CollectionPromo->demoteCollection($_collection_id, $_titletagline, $_locale) === false) { - $this->Error->addError('Failed to demote collection.'); - } else { - $this->publish('changeSuccess', true); - } - break; - } - } - - $this->set('titles_and_taglines', $this->CollectionPromo->titles_and_taglines); - $this->publish('promoted_collections', $this->CollectionPromo->findAll()); - $this->set('locales', LANGUAGE_CONFIG::getAllValidLanguages('english',true)); - - $this->set('errors', $this->Error->errors); - $this->set('page', 'collections'); - $this->set('subpage', 'promobox'); - $this->render('collections_promobox'); - } /** * Category Manager @@ -607,6 +538,10 @@ class AdminController extends AppController $this->set('breadcrumbs', $this->breadcrumbs); $applications = array('All'); + + // we are sugar + $applications = array(); + $_applications = $this->Amo->getApplicationName(); if (!empty($_applications)) { foreach ($_applications as $app_id => $app_name) { @@ -1541,7 +1476,7 @@ class AdminController extends AppController if (!empty($this->data['User']['password'])) { $session = $this->Session->read('User'); - if ($this->User->checkPassword($session, $this->data['User']['password'])) { + if (md5($this->data['User']['password']) == $session['password']) { $this->set('config', $config); $this->set('rand', $sessionConfig['rand']); @@ -1629,17 +1564,16 @@ class AdminController extends AppController if (!empty($flagged)) { foreach ($flagged as $k => $addon) { $version = $this->Version->findByAddon_id($addon['Addon']['id'], - array('Version.id', 'Version.addon_id', 'Version.version'), - 'Version.created DESC'); - if (!$version) $version = array(); + array('Version.id', 'Version.addon_id', + 'Version.version' + ), 'Version.created DESC'); $flagged[$k] = array_merge_recursive($flagged[$k], $version); $history = $this->Approval->find( - "Approval.addon_id={$addon['Addon']['id']} AND - ((Approval.reviewtype='nominated' AND Approval.action=".STATUS_NOMINATED.") OR - (Approval.reviewtype='pending' AND Approval.action=".STATUS_PENDING."))", - null, 'Approval.created DESC'); - if (!$history) $history = array(); + "Approval.addon_id={$addon['Addon']['id']} AND + ((Approval.reviewtype='nominated' AND Approval.action=".STATUS_NOMINATED.") OR + (Approval.reviewtype='pending' AND Approval.action=".STATUS_PENDING."))", + null, 'Approval.created DESC'); $flagged[$k] = array_merge_recursive($flagged[$k], $history); } } @@ -1657,8 +1591,7 @@ class AdminController extends AppController function users($user_id = 0, $type = 'edit') { $this->breadcrumbs['User Manager'] = '/admin/users'; $this->set('breadcrumbs', $this->breadcrumbs); - $this->set('suppressJQuery', 0); - + if (!empty($user_id)) { $this->Amo->clean($user_id); $this->User->id = $user_id; @@ -1704,10 +1637,6 @@ class AdminController extends AppController case 'edit': default: $this->User->save($this->data['User']); - - // save author "about me" - list($localizedFields, $unlocalizedFields) = $this->User->splitLocalizedFields($this->data['User']); - $this->User->saveTranslations($user_id, $this->params['form']['data']['User'], $localizedFields); //Log admin action $this->Eventlog->log($this, 'admin', 'user_edit', null, $user_id); @@ -1718,9 +1647,6 @@ class AdminController extends AppController } else { $user = $this->User->read(); - // grab translated fields - $translations = $this->User->getAllTranslations($user_id); - $this->set('translations', $translations); } } elseif (!empty($_GET['q'])) { @@ -1731,9 +1657,6 @@ class AdminController extends AppController $this->flash('E-mail not found.', '/admin/users'); return; } - // grab translated fields - $translations = $this->User->getAllTranslations($user['User']['id']); - $this->set('translations', $translations); } $this->set('page', 'users'); @@ -1803,38 +1726,5 @@ class AdminController extends AppController $this->set('results', $results); $this->render('userlookup', 'ajax'); } - - /** - * AJAX Collection lookup. Matches either name or nickname - */ - function collectionLookup() { - if (!$this->SimpleAcl->actionAllowed('Admin', '%', $this->Session->read('User')) || - !$this->SimpleAcl->actionAllowed('Editor', '*', $this->Session->read('User')) ) { - $this->Amo->accessDenied(); - } - global $app_shortnames; - - $text = $_REQUEST['q']; - $this->Amo->clean($text); - $results = array(); - - $_query = "SELECT - collections.id, translations.localized_string, collections.nickname, collections.application_id - FROM collections LEFT JOIN translations ON collections.name=translations.id - WHERE (translations.locale='".LANG."' - AND translations.localized_string LIKE '%{$text}%') - OR collections.nickname LIKE '%{$text}%' - ORDER BY translations.localized_string"; - - if ($collections = $this->Collection->query($_query)) { - foreach ($collections as $collection) { - $_application = array_search($collection['collections']['application_id'], $app_shortnames); - $results[] = "{$collection['translations']['localized_string']}|ID: {$collection['collections']['id']}|App: {$_application}|nickname: {$collection['collections']['nickname']};"; - } - } - - $this->set('results', $results); - $this->render('userlookup', 'ajax'); - } } ?> |