1<?php
2if ($group == $GLOBALS['registry']->getAuth()) {
3    $owner_title = _("My Galleries");
4    $custom = '';
5} elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) {
6    $uprefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('ansel', array(
7        'cache' => false,
8        'user' => $group
9    ));
10    $custom = $uprefs->getValue('grouptitle');
11    $identity = new Horde_Prefs_Identity(array('prefs' => $uprefs, 'user' => $group));
12    $fullname = $identity->getName();
13    if (!$fullname) {
14        $fullname = $group;
15    }
16    if (!$custom) {
17        $owner_title = sprintf(_("%s's Galleries"), htmlspecialchars($fullname));
18    } else {
19        $owner_title = $custom;
20    }
21} else {
22    $owner_title = sprintf(_("%s's Galleries"), $group);
23}
24
25$link = Ansel::getUrlFor('view', array('groupby' => $groupby,
26                                       'owner' => $group,
27                                       'view' => 'List'))->link();
28
29$num_galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')
30    ->countGalleries(
31      $GLOBALS['registry']->getAuth(),
32      array('attributes' => $group,
33            'all_levels' => false));
34
35if ($num_galleries < 5) {
36    $mini_galleries = $GLOBALS['injector']
37        ->getInstance('Ansel_Storage')
38        ->listGalleries(array('attributes' => $group, 'all_levels' => false));
39} else {
40    $mini_galleries = $GLOBALS['injector']
41        ->getInstance('Ansel_Storage')
42        ->listGalleries(array('attributes' => $group,
43                              'from' => rand(0, $num_galleries - 4),
44                              'count' => 4));
45}
46$mini_galleries = array_values($mini_galleries);
47?>
48<td class="galleryGroupsTile" width="<?php echo round(100 / $prefs->getValue('tilesperrow')) ?>%" valign="top">
49 <table>
50  <tr>
51<?php for ($i = 0; $i < count($mini_galleries); ++$i): ?>
52   <td align="center">
53    <?php if ($mini_galleries[$i]->isOldEnough() && !$mini_galleries[$i]->hasPasswd()): ?>
54     <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', false) ?>" alt="<?php echo $owner_title?>" /></a>
55    <?php else: ?>
56      <?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
57    <?php endif; ?>
58   </td>
59
60<?php if ($i == 1) echo "  </tr>\n  <tr>\n" ?>
61<?php endfor; ?>
62  </tr>
63 </table>
64
65 <p class="light">
66  <strong><?php echo $link . $owner_title ?></a></strong><br /><?php echo ((!empty($custom)) ? sprintf(_("Owned by: %s"), $fullname) . '<br />' : '') ?>
67  <?php echo sprintf(ngettext("%d Gallery", "%d Galleries", $num_galleries), $num_galleries) ?>
68 </p>
69</td>
70
71<?php if (!(++$count % $prefs->getValue('tilesperrow'))) echo "</tr>\n<tr>\n" ?>
72