More space fixes

This commit is contained in:
phl0
2025-02-24 12:28:37 +01:00
parent bf669f9e12
commit 27178d86c6
2 changed files with 14 additions and 14 deletions

View File

@@ -289,7 +289,7 @@ class Widgets extends CI_Controller {
private function prepare_last_seen_text($last_seen_days_ago) { private function prepare_last_seen_text($last_seen_days_ago) {
if ($last_seen_days_ago === 0) { if ($last_seen_days_ago === 0) {
return "Last seen less than a day ago"; return "Last seen less than a day ago";
} }
if ($last_seen_days_ago === 1) { if ($last_seen_days_ago === 1) {
return "Last seen yesterday"; return "Last seen yesterday";
} }

View File

@@ -2,11 +2,11 @@
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
/** /**
* Create URL "slug" for each user that serves as an alias for a user_id. * Create URL "slug" for each user that serves as an alias for a user_id.
* The purpose is to have user identifier for use in public URLs (i.e. for widget purposes) * The purpose is to have user identifier for use in public URLs (i.e. for widget purposes)
* that is bound to one concrete user, as the widgets might contain privacy-sensitive data. * that is bound to one concrete user, as the widgets might contain privacy-sensitive data.
* This slug is to "mask" the user_id in lieu of avoiding brute-force iteration over * This slug is to "mask" the user_id in lieu of avoiding brute-force iteration over
* user_ids in URL that might be available in particular Wavelog instance. * user_ids in URL that might be available in particular Wavelog instance.
*/ */
class Migration_user_callsign_public_slug extends CI_Migration { class Migration_user_callsign_public_slug extends CI_Migration {
@@ -15,25 +15,25 @@ class Migration_user_callsign_public_slug extends CI_Migration {
{ {
// Step 1: Add user slug column // Step 1: Add user slug column
if (!$this->db->field_exists('slug', 'users')) { if (!$this->db->field_exists('slug', 'users')) {
$fields = array( $fields = array(
'slug varchar(50) DEFAULT NULL' 'slug varchar(50) DEFAULT NULL'
); );
$this->dbforge->add_column('users', $fields); $this->dbforge->add_column('users', $fields);
} }
// Step 2: Create public user-slug for each user // Step 2: Create public user-slug for each user
if (!$this->load->is_loaded('encryption')) { if (!$this->load->is_loaded('encryption')) {
$this->load->library('encryption'); $this->load->library('encryption');
} }
$fetch_result = $this->db->get($this->config->item('auth_table')); $fetch_result = $this->db->get($this->config->item('auth_table'));
if ($fetch_result && $fetch_result->num_rows() > 0) { if ($fetch_result && $fetch_result->num_rows() > 0) {
foreach ($fetch_result->result_array() as $user_row) { foreach ($fetch_result->result_array() as $user_row) {
if ($user_row["slug"] === null) { if ($user_row["slug"] === null) {
$user_name = $user_row["user_name"]; $user_name = $user_row["user_name"];
$user_slug_base = md5($this->encryption->encrypt($user_name)); $user_slug_base = md5($this->encryption->encrypt($user_name));
$url_slug = substr($user_slug_base, 0, USER_SLUG_LENGTH); $url_slug = substr($user_slug_base, 0, USER_SLUG_LENGTH);
// update the slug only in case the slug does not exist yet // update the slug only in case the slug does not exist yet
$user_id = $user_row["user_id"]; $user_id = $user_row["user_id"];
$this->db->where('user_id', $user_id); $this->db->where('user_id', $user_id);
@@ -50,7 +50,7 @@ class Migration_user_callsign_public_slug extends CI_Migration {
public function down() public function down()
{ {
if ($this->db->field_exists('slug', 'users')) { if ($this->db->field_exists('slug', 'users')) {
$this->dbforge->drop_column('users', 'slug'); $this->dbforge->drop_column('users', 'slug');
} }
} }
} }