aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.12_step_120_userpic.php
blob: f907b9ff9fa1197c653ca3782430104550d9d79e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

/*
 * Copyright (C) 2008 - André Klaßen <aklassen@uos.de>
 * Copyright (C) 2008 - Marcus Lunzenauer <mlunzena@uos.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

require_once 'lib/classes/Avatar.class.php';

class Step120Userpic extends Migration {

  function description() {
    return 'modify existing user pictures according to Step00120';
  }

  function up() {
    foreach (glob($GLOBALS['DYNAMIC_CONTENT_PATH'].'/user/*.jpg') as $value) {
      if (preg_match('/\/([0-9a-f]+).jpg$/', $value, $matches)) {
        try {
          Avatar::getAvatar($matches[1])->createFrom($value);
        } catch (Exception $e) {
          $this->announce('Exception while converting avatar "%s"', $value);
          $this->write($e->getMessage()."\n");
        }
        @unlink($value);
      }
    }
  }

  function down() {
  }
}