Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add numeric id to projects #566

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<div class="inner-container">
<h1><?= $this->text('dashboard-menu-activity-summary') ?></h1>
<h5><?= $this->ee($this->project->name) ?></h5>
<h6><?= $this->ee($this->project->getNumericId()) ?></h6>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some text so that the users understand what is this id?


<div class="panel section-content">
<div class="panel-body">
Expand Down
10 changes: 10 additions & 0 deletions src/Goteo/Model/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,16 @@ public function getImage() {
return $this->imageInstance;
}

/**
* Convert the alfanumeric string ID into a numeric string ID
* @param int $surface Collission chance = 10**$surface
* @return string number-only string ID
*/
public function getNumericId(int $surface = 10): string
{
return substr(base_convert(hash('sha256', $this->id), 16, 10), 0, $surface);
}

/**
* Handy method to know if project can be edited (not in campaing or finished)
*/
Expand Down