Skip to content

Commit 569a1f1

Browse files
author
daniel-abbey
committed
Merge pull request #748 from LearningLocker/issue/ponder-mongoid-rackspace
Combined Pondermatic and other branches
2 parents 69e7e03 + 9de0e54 commit 569a1f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+450
-123
lines changed

app/config/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
'reminder' => array(
6262

63-
'email' => 'emails.auth.reminder',
63+
'email' => ['emails.auth.reminderHtml', 'emails.auth.reminderPlain'],
6464

6565
'table' => 'password_reminders',
6666

app/controllers/EmailController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function inviteEmail( $token ){
7373
->where('token', $token)
7474
->pluck('email');
7575
$user = \User::where('email', $email)->first();
76-
if (!isset($user->_id)) \App::abort(404, 'This token cannot be found or has expired.');
76+
if (!isset($user->_id)) \App::abort(404, 'Your email verification link has expired - please request a new one. ');
7777
Auth::loginUsingId($user->_id);
7878
\DB::table('user_tokens')
7979
->where('token', $token)

app/controllers/LrsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ public function destroy($lrs_id){
192192
public function statements($lrs_id){
193193
$site = \Site::first();
194194
$statements = (new StatementIndexer)->index(new IndexOptions([
195-
'lrs_id' => new \MongoId($lrs_id),
195+
'lrs_id' => $lrs_id,
196196
'limit' => $this->statement->count([
197-
'lrs_id' => new \MongoId($lrs_id),
197+
'lrs_id' => $lrs_id,
198198
'scopes' => ['all']
199199
]),
200200
'scopes' => ['all']

app/controllers/ReportingController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ public function statements($lrs_id, $report_id) {
9191
return View::make("{$this->views}.statements", array_merge($this->getLrs($lrs_id), [
9292
'reporting_nav' => true,
9393
'statements' => $this->report->statements($report_id, [
94-
'lrs_id' => new \MongoId($lrs_id)
94+
'lrs_id' => $lrs_id
9595
])->select('statement')->paginate(20),
9696
'report' => $this->report->show($report_id, [
97-
'lrs_id' => new \MongoId($lrs_id)
97+
'lrs_id' => $lrs_id
9898
]),
9999
'lang' => $site->lang
100100
]));
@@ -107,10 +107,10 @@ public function statements($lrs_id, $report_id) {
107107
* @param String $query to match against.
108108
* @return [Typeahead values] Typeahead values.
109109
**/
110-
public function typeahead($lrs, $segment, $query){
110+
public function typeahead($lrs_id, $segment, $query){
111111
$options = self::$segments[$segment];
112112
return Response::json($this->report->setQuery(
113-
new \MongoId($lrs),
113+
$lrs_id,
114114
$query,
115115
self::statementKey.$options['return'],
116116
self::statementKey.$options['query']
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
use \Locker\Helpers\Helpers as Helpers;
4+
5+
class LrsForeignIds extends Migration
6+
{
7+
8+
public function up()
9+
{
10+
$db = \DB::getMongoDB();
11+
12+
Lrs::get()->each(function (Lrs $lrs) use($db)
13+
{
14+
if( isset($lrs->users) ) $lrs->users = Helpers::convertIds($lrs->users);
15+
16+
$lrs->owner_id = new \MongoId($lrs->owner_id);
17+
$lrs->save();
18+
19+
echo 'IDs for lrs collection "' . $lrs->title . '" converted to MongoIds.' . PHP_EOL;
20+
});
21+
}
22+
23+
public function down()
24+
{
25+
$db = \DB::getMongoDB();
26+
27+
Lrs::get()->each(function (Lrs $lrs) use($db)
28+
{
29+
$users = $lrs->getAttribute('users');
30+
foreach ($users as &$user) {
31+
$user['_id'] = (string)$user['_id'];
32+
}
33+
$lrs->setAttribute('users', $users);
34+
35+
$lrs->owner_id = (string)$lrs->owner_id;
36+
$lrs->save();
37+
38+
echo 'IDs for lrs collection "' . $lrs->title . '" converted to strings.' . PHP_EOL;
39+
});
40+
}
41+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class ClientForeignIds extends Migration
5+
{
6+
7+
/**
8+
* Convert foreign id values from string to MongoId.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
$db = \DB::getMongoDB();
15+
16+
Client::get()->each(function (Client $client) use($db)
17+
{
18+
// The Client model has a mutator that converts lrs_id values to MongoId objects.
19+
$client->lrs_id = $client->lrs_id;
20+
$client->save();
21+
});
22+
23+
echo 'Foreign id values in client collection converted from string to MongoId.' . PHP_EOL;
24+
}
25+
26+
/**
27+
* Convert foreign id values from MongoId to string.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
// The Client model has a mutator that converts lrs_id from string to MongoId,
34+
// so the Mongo classes are used to directly modify the client collection.
35+
$db = \DB::getMongoDB();
36+
$clients = new MongoCollection($db, 'client');
37+
38+
$lrsIds = $clients->aggregateCursor([
39+
[
40+
'$group' => [
41+
'_id' => '$lrs_id'
42+
]
43+
]
44+
]);
45+
46+
foreach ($lrsIds as $lrsId) {
47+
$clients->update([
48+
'lrs_id' => $lrsId['_id']
49+
], [
50+
'$set' => [
51+
'lrs_id' => (string) $lrsId['_id']
52+
]
53+
], [
54+
'multiple' => true
55+
]);
56+
}
57+
58+
echo 'Foreign id values in client collection converted from MongoId to string.' . PHP_EOL;
59+
}
60+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class RemoveOrphanClients extends Migration
5+
{
6+
7+
/**
8+
* Removes documents from the client collection that have
9+
* an lrs_id that does not exist in the lrs collection.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
$db = \DB::getMongoDB();
16+
$clients = new MongoCollection($db, 'client');
17+
$lrss = new MongoCollection($db, 'lrs');
18+
19+
$clientCursor = $clients->find([], ['lrs_id' => true]);
20+
21+
foreach ($clientCursor as $client) {
22+
$count = $lrss->count(['_id' => $client['lrs_id']]);
23+
if ($count == 0) {
24+
$clients->remove(['_id' => $client['_id']]);
25+
}
26+
}
27+
}
28+
29+
public function down()
30+
{
31+
//
32+
}
33+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class UpdateLrsUserIds extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
// Legacy migration - now handled in 2015_09_14_090000_lrs_foreign_ids.php
16+
// Thanks to @pondermatic
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*
22+
* @return void
23+
*/
24+
public function down()
25+
{
26+
//
27+
}
28+
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
use Illuminate\Database\Migrations\Migration;
3+
4+
class SiteSuperUserId extends Migration
5+
{
6+
7+
/**
8+
* Converts site.super[{user}] value from string to MongoId.
9+
*
10+
* @return void
11+
*/
12+
public function up()
13+
{
14+
$db = \DB::getMongoDB();
15+
$sites = new MongoCollection($db, 'site');
16+
$sitesCursor = $sites->find([], ['super' => true]);
17+
18+
foreach ($sitesCursor as $site) {
19+
foreach ($site['super'] as $key => $supers) {
20+
$sites->update(
21+
['_id' => $site['_id']],
22+
['$set' => ["super.$key.user" => new MongoId($supers['user'])]],
23+
['multiple' => true]
24+
);
25+
}
26+
}
27+
}
28+
29+
/**
30+
* Converts site.super[{user}] value from MongoId to string.
31+
*
32+
* @return void
33+
*/
34+
public function down()
35+
{
36+
$db = \DB::getMongoDB();
37+
$sites = new MongoCollection($db, 'site');
38+
$sitesCursor = $sites->find([], ['super' => true]);
39+
40+
foreach ($sitesCursor as $site) {
41+
foreach ($site['super'] as $key => $supers) {
42+
$sites->update(
43+
['_id' => $site['_id']],
44+
['$set' => ["super.$key.user" => (string)$supers['user']]],
45+
['multiple' => true]
46+
);
47+
}
48+
}
49+
}
50+
}

app/lang/de_DE/users.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
'sample' => 'Einladung zum Beitritt in unseren Learning Record Store (LRS).',
1717
'invited' => 'Diese Benutzer wurden eingeladen.',
1818
'failed' => 'Dieser Benutzer konnte nicht eingeladen werden. Möglicherweise ist er bereits ein Mitglied dieses LRS oder die E-Mail-Addresse ist ungültig.',
19-
'has_invited' => 'hat Dich eingeladen beizutreten',
20-
'invite_instructions' => 'Um beizutreten, bitte diesem Link folgen'
19+
'has_added' => ':INVITOR hat Sie zu dem :LRS_TITLE Learning Record Store (LRS) aufgenommen.',
20+
'has_invited' => ':INVITOR hat Sie eingeladen, die :LRS_TITLE Learning Record Store (LRS) anzuschließen.',
21+
'instructions' => 'Bitte gehen Sie auf der folgenden Website:'
2122
),
2223
'password' => 'Passwort',
2324
'password_again' => 'Passwort bestätigen',
@@ -30,7 +31,7 @@
3031
'password_instructions' => 'Bitte diesem Account ein Passwort hinzufügen. Das ist notwendig um den Prozess fort zu setzen.',
3132
'email' => 'E-Mail',
3233
'verify' => 'Bestätigen',
33-
'verfiy_success' => 'Dieser Benutzer wurde bestätigt.',
34+
'verify_success' => 'Dieser Benutzer wurde bestätigt.',
3435
'verified' => 'Bestätigt',
3536
'verify_request' => 'Es wurde eine E-Mail mit weiteren Instruktionen versandt.',
3637
'email_verified' => 'Vielen Dank. Die E-Mail-Adresse wurde bestätigt.',
@@ -39,12 +40,18 @@
3940
'verify_resend' => 'E-Mail noch einmal versenden',
4041
'reset' => 'Passwort wiederherstellen',
4142
'success' => 'Das Passwort wurde gespeichert.',
43+
'roles' => array(
44+
'super' => 'Super Verwalter (zugreifen können und alles tun)',
45+
'plus' => 'Beobachter Plus (keine spezielle Privilegien)',
46+
'observer' => 'Beobachter (keine spezielle Privilegien)',
47+
'help' => 'Der einzige Grund, Observer und Observer plus vorhanden ist, um eine Option auf bestimmte Benutzer das Privileg, die Schaffung LRSs zu gewähren ist.',
48+
),
4249
'role_change' => 'Die Rolle des Benutzers wurde geändert.',
4350
'deleted' => 'Der Benutzer wurde gelöscht und evetuell von ihm erstellte LRSs an den Administrator transferiert.',
4451
'updated' => 'Account einstellungen wurden aktualisiert',
4552
'updated_error' => 'Der Account konnte nicht aktualisiert werden.',
46-
'registration_various' => array(
53+
'registration' => array(
4754
'thanks' => 'Vielen Dank für die Anmeldung an Learning Locker. um die Registrierung abzuschließen muss die E-Mail-Adresse verifiziert werden.',
48-
'click' => 'Zur Verifizierung bitte dem Link folgen'
55+
'instructions' => 'Bitte gehen Sie auf der folgenden Website:'
4956
)
5057
);

0 commit comments

Comments
 (0)