/** * update * This function is an all encompasing update function that * calls the mini ones does all the error checking and all that * good stuff */ public function update(array $data) { if (empty($data['username'])) { AmpError::add('username', T_('Error Username Required')); } if ($data['password1'] != $data['password2'] and !empty($data['password1'])) { AmpError::add('password', T_("Error Passwords don't match")); } if (AmpError::occurred()) { return false; } if (!isset($data['fullname_public'])) { $data['fullname_public'] = false; } foreach ($data as $name => $value) { if ($name == 'password1') { $name = 'password'; } else { $value = scrub_in($value); } switch ($name) { case 'password': case 'access': case 'email': case 'username': case 'fullname': case 'fullname_public': case 'website': case 'state': case 'city': if ($this->{$name} != $value) { $function = 'update_' . $name; $this->{$function}($value); } break; case 'clear_stats': Stats::clear($this->id); break; default: // Rien a faire break; } } return $this->id; }
UI::show_box_top(T_('Catalog Created'), 'box box_catalog_created'); echo "<h2>" . T_('Catalog Created') . "</h2>"; Error::display('general'); Error::display('catalog_add'); UI::show_box_bottom(); show_confirmation('', '', AmpConfig::get('web_path') . '/admin/catalog.php'); } else { require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php'; } break; case 'clear_stats': if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; } Stats::clear(); $url = AmpConfig::get('web_path') . '/admin/catalog.php'; $title = T_('Catalog statistics cleared'); $body = ''; show_confirmation($title, $body, $url); break; case 'show_add_catalog': require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php'; break; case 'clear_now_playing': if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; } Stream::clear_now_playing(); show_confirmation(T_('Now Playing Cleared'), T_('All now playing data has been cleared'), AmpConfig::get('web_path') . '/admin/catalog.php');