Permalink
Browse files

Loose ends on rating refactor

Simplified some queries
Finished splitting getChilderen() into getChildren() and
getChildrenForUser()
Simplified some methods
Fixed some unittest issues
Added database change to zoph_update
  • Loading branch information...
1 parent 176c22a commit 058b8c75ca42ec70eb3058966307b7aa00597bef @jeroenrnl committed Jan 16, 2013
View
11 php/UnitTests/createTestData/createTest.php
@@ -39,6 +39,7 @@
$lang=new language("en");
+user::setCurrent(new user(1));
createTestData::run();
/**
* Fill the database with data, so tests can be run.
@@ -189,6 +190,7 @@ private static function createGroupPermissions() {
}
private static function importTestImages() {
+
$photos=testData::getPhotos();
$photoLocation=testData::getPhotoLocation();
$photoAlbums=testData::getPhotoAlbums();
@@ -208,6 +210,10 @@ private static function importTestImages() {
$imported=cliimport::photos($files, array());
foreach($imported as $photo) {
+ $user=new user(1);
+ $user->lookup();
+ user::setCurrent($user);
+
$id=$photo->get("photo_id");
if(isset($photoLocation[$id])) {
$photo->set("location_id",$photoLocation[$id]);
@@ -239,6 +245,7 @@ private static function importTestImages() {
$obj = new comment();
$user = new user($user_id);
$user->lookup();
+ user::setCurrent($user);
$subj="Comment by " . $user->getName();
@@ -257,10 +264,12 @@ private static function importTestImages() {
foreach($ratings[$id] as $user_id => $rating) {
$user = new user($user_id);
$user->lookup();
+ user::setCurrent($user);
+
// Set fake remote IP address:
$_SERVER["REMOTE_ADDR"]=$user->getName() . ".zoph.org";
- $photo->rate($user, $rating);
+ $photo->rate($rating);
$photo->update();
$total+=$rating;
$count++;
View
2 php/UnitTests/createTestData/testData.php
@@ -45,7 +45,7 @@ public static function getCategories() {
3 => array(2,"indianRed1"),
4 => array(2,"DarkRed"),
5 => array(1,"blue"),
- 6 => array(6,"LightBlue"),
+ 6 => array(5,"LightBlue"),
7 => array(6,"DarkBlue"),
8 => array(1,"Yellow"),
9 => array(1,"white"),
View
324 php/UnitTests/db.xml
@@ -196,7 +196,7 @@
</row>
<row>
<field name="category_id">6</field>
- <field name="parent_category_id">6</field>
+ <field name="parent_category_id">5</field>
<field name="category">LightBlue</field>
<field name="category_description" xsi:nil="true" />
<field name="sortname" xsi:nil="true" />
@@ -400,430 +400,430 @@
<row>
<field name="comment_id">1</field>
<field name="user_id">2</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by brian</field>
<field name="comment">I love that Special Red :-)</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">brian.zoph.org</field>
</row>
<row>
<field name="comment_id">2</field>
<field name="user_id">5</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by freddie</field>
<field name="comment">Beautiful!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">freddie.zoph.org</field>
</row>
<row>
<field name="comment_id">3</field>
<field name="user_id">7</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by roger</field>
<field name="comment">Nice</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">roger.zoph.org</field>
</row>
<row>
<field name="comment_id">4</field>
<field name="user_id">2</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by brian</field>
<field name="comment">The letters are all distorted!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">brian.zoph.org</field>
</row>
<row>
<field name="comment_id">5</field>
<field name="user_id">5</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by freddie</field>
<field name="comment">Crap :-(</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">freddie.zoph.org</field>
</row>
<row>
<field name="comment_id">6</field>
<field name="user_id">3</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by jimi</field>
<field name="comment">Self portrait!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">jimi.zoph.org</field>
</row>
<row>
<field name="comment_id">7</field>
<field name="user_id">3</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by jimi</field>
<field name="comment">Me and [b]Brian[/b]!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">jimi.zoph.org</field>
</row>
<row>
<field name="comment_id">8</field>
<field name="user_id">2</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by brian</field>
<field name="comment">:-)</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">brian.zoph.org</field>
</row>
<row>
<field name="comment_id">9</field>
<field name="user_id">4</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by paul</field>
<field name="comment">Just beautiful</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">paul.zoph.org</field>
</row>
<row>
<field name="comment_id">10</field>
<field name="user_id">6</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by phil</field>
<field name="comment">That &lt;span style=&quot;background: grey&quot;&gt;grey&lt;/span&gt; is annoying me so badly, I'm illegally using HTML in this comment!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">phil.zoph.org</field>
</row>
<row>
<field name="comment_id">11</field>
<field name="user_id">1</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:11</field>
<field name="subject">Comment by admin</field>
<field name="comment">Can you guys stop this, or I am [b]revoking[/b] your accounts!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="ipaddr">admin.zoph.org</field>
</row>
<row>
<field name="comment_id">12</field>
<field name="user_id">6</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:12</field>
<field name="subject">Comment by phil</field>
<field name="comment">Love this picture!</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:12</field>
<field name="ipaddr">phil.zoph.org</field>
</row>
<row>
<field name="comment_id">13</field>
<field name="user_id">4</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:12</field>
<field name="subject">Comment by paul</field>
<field name="comment">Can't [i]you[/i] [b]see[/b] it isn't even [u]sharp[/u] on the right side, Phil? :mrgreen:</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:12</field>
<field name="ipaddr">paul.zoph.org</field>
</row>
<row>
<field name="comment_id">14</field>
<field name="user_id">1</field>
- <field name="comment_date">2012-12-29 12:51:00</field>
+ <field name="comment_date">2013-01-16 10:50:12</field>
<field name="subject">Comment by admin</field>
<field name="comment">Really, I am going to [b]revoke[/b] your accounts! :mad:</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:12</field>
<field name="ipaddr">admin.zoph.org</field>
</row>
</table_data>
<table_data name="zoph_conf">
<row>
<field name="conf_id">interface.title</field>
<field name="value">Zoph UnitTest</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.width</field>
- <field name="value">1000px</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="value">600px</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.template</field>
<field name="value">default</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.autocomplete</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.language</field>
<field name="value">en</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.user.default</field>
<field name="value">0</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.user.cli</field>
<field name="value">0</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.max.days</field>
<field name="value">30</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.sort.order</field>
<field name="value">date</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">interface.sort.dir</field>
<field name="value">asc</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">ssl.force</field>
<field name="value">never</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">url.http</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">url.https</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.images</field>
<field name="value">/data/images/</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.upload</field>
<field name="value">upload</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.magic</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.unzip</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.untar</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.ungz</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">path.unbz</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">maps.provider</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">maps.geocode</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">maps.key.cloudmade</field>
<field name="value">f3b46b04edd64ea79066b7e6921205df</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.enable</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.upload</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.maxupload</field>
<field name="value">10000000</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.parallel</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.rotate</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.resize</field>
<field name="value">resample</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.dated</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.dated.hier</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.filemode</field>
<field name="value">0644</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.dirmode</field>
<field name="value">0755</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.cli.thumbs</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.cli.exif</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.cli.size</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.cli.hash</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">import.cli.copy</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">watermark.enable</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">watermark.file</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">watermark.pos.x</field>
<field name="value">center</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">watermark.pos.y</field>
<field name="value">center</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">watermark.transparency</field>
<field name="value">50</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">rotate.enable</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">rotate.command</field>
<field name="value">convert</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">rotate.backup</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">rotate.backup.prefix</field>
<field name="value">orig_</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">share.enable</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">share.salt.full</field>
- <field name="value">282adde1df5abb92595c8c7184a87eef2aee142d</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="value">904328704a1cd39a27e1ee865b7f7ad56547f974</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">share.salt.mid</field>
- <field name="value">a66cd0715ff212f189d5966bf5fdec5dd4914732</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="value">214fd0b4b714ee6faf932820fa2c0349b166f0e6</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.download</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.comments</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.mail</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.mail.bcc</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.annotate</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">feature.rating</field>
<field name="value">1</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">date.tz</field>
<field name="value" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">date.guesstz</field>
<field name="value"></field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">date.format</field>
<field name="value">d-m-Y</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
<row>
<field name="conf_id">date.timeformat</field>
<field name="value">H:i:s T</field>
- <field name="timestamp">2012-12-29 11:50:49</field>
+ <field name="timestamp">2013-01-16 09:38:30</field>
</row>
</table_data>
<table_data name="zoph_group_permissions">
@@ -833,55 +833,55 @@
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">1</field>
<field name="album_id">2</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">2</field>
<field name="album_id">1</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">2</field>
<field name="album_id">2</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">2</field>
<field name="album_id">3</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">4</field>
<field name="album_id">1</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">4</field>
<field name="album_id">2</field>
<field name="access_level">5</field>
<field name="watermark_level">3</field>
<field name="writable">0</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
</table_data>
<table_data name="zoph_groups">
@@ -910,47 +910,47 @@
<row>
<field name="group_id">1</field>
<field name="user_id">2</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">1</field>
<field name="user_id">5</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">1</field>
<field name="user_id">7</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">1</field>
<field name="user_id">9</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">2</field>
<field name="user_id">8</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">2</field>
<field name="user_id">4</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">3</field>
<field name="user_id">6</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">4</field>
<field name="user_id">2</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
<row>
<field name="group_id">4</field>
<field name="user_id">3</field>
- <field name="changedate">2012-12-29 11:50:59</field>
+ <field name="changedate">2013-01-16 09:50:10</field>
</row>
</table_data>
<table_data name="zoph_pages">
@@ -1484,151 +1484,151 @@
<field name="photo_id">1</field>
<field name="rating">8</field>
<field name="ipaddress">brian.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">2</field>
<field name="user_id">5</field>
<field name="photo_id">1</field>
<field name="rating">7</field>
<field name="ipaddress">freddie.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">3</field>
<field name="user_id">7</field>
<field name="photo_id">1</field>
<field name="rating">8</field>
<field name="ipaddress">roger.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">4</field>
<field name="user_id">9</field>
<field name="photo_id">1</field>
<field name="rating">7</field>
<field name="ipaddress">johnd.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">5</field>
<field name="user_id">2</field>
<field name="photo_id">2</field>
<field name="rating">5</field>
<field name="ipaddress">brian.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">6</field>
<field name="user_id">5</field>
<field name="photo_id">2</field>
<field name="rating">3</field>
<field name="ipaddress">freddie.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">7</field>
<field name="user_id">7</field>
<field name="photo_id">2</field>
<field name="rating">6</field>
<field name="ipaddress">roger.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">8</field>
<field name="user_id">9</field>
<field name="photo_id">2</field>
<field name="rating">3</field>
<field name="ipaddress">johnd.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">9</field>
<field name="user_id">3</field>
<field name="photo_id">3</field>
<field name="rating">5</field>
<field name="ipaddress">jimi.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">10</field>
<field name="user_id">4</field>
<field name="photo_id">4</field>
<field name="rating">7</field>
<field name="ipaddress">paul.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">11</field>
<field name="user_id">8</field>
<field name="photo_id">4</field>
<field name="rating">6</field>
<field name="ipaddress">johnl.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">12</field>
<field name="user_id">6</field>
<field name="photo_id">5</field>
<field name="rating">10</field>
<field name="ipaddress">phil.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">13</field>
<field name="user_id">3</field>
<field name="photo_id">5</field>
<field name="rating">9</field>
<field name="ipaddress">jimi.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">14</field>
<field name="user_id">3</field>
<field name="photo_id">6</field>
<field name="rating">7</field>
<field name="ipaddress">jimi.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">15</field>
<field name="user_id">2</field>
<field name="photo_id">6</field>
<field name="rating">5</field>
<field name="ipaddress">brian.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">16</field>
<field name="user_id">4</field>
<field name="photo_id">8</field>
<field name="rating">9</field>
<field name="ipaddress">paul.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">17</field>
<field name="user_id">6</field>
<field name="photo_id">8</field>
<field name="rating">3</field>
<field name="ipaddress">phil.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
</row>
<row>
<field name="rating_id">18</field>
<field name="user_id">6</field>
<field name="photo_id">10</field>
<field name="rating">10</field>
<field name="ipaddress">phil.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:12</field>
</row>
<row>
<field name="rating_id">19</field>
<field name="user_id">4</field>
<field name="photo_id">10</field>
<field name="rating">1</field>
<field name="ipaddress">paul.zoph.org</field>
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:12</field>
</row>
</table_data>
<table_data name="zoph_photo_relations">
@@ -1645,9 +1645,10 @@
<field name="photographer_id">2</field>
<field name="location_id">3</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:50:59</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:10</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1662,7 +1663,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1679,9 +1680,10 @@
<field name="photographer_id">2</field>
<field name="location_id">4</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:50:59</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:10</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1696,7 +1698,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1713,9 +1715,10 @@
<field name="photographer_id">2</field>
<field name="location_id">4</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:50:59</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:10</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1730,7 +1733,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1747,9 +1750,10 @@
<field name="photographer_id">3</field>
<field name="location_id">5</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:50:59</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1764,7 +1768,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1781,9 +1785,10 @@
<field name="photographer_id">3</field>
<field name="location_id">5</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:50:59</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1798,7 +1803,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1815,9 +1820,10 @@
<field name="photographer_id">3</field>
<field name="location_id">6</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:51:00</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1832,7 +1838,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1849,9 +1855,10 @@
<field name="photographer_id">3</field>
<field name="location_id">7</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:51:00</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1866,7 +1873,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1883,9 +1890,10 @@
<field name="photographer_id">4</field>
<field name="location_id">10</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:51:00</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1900,7 +1908,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1917,9 +1925,10 @@
<field name="photographer_id">5</field>
<field name="location_id">13</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:51:00</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1934,7 +1943,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
@@ -1951,9 +1960,10 @@
<field name="photographer_id">6</field>
<field name="location_id">14</field>
<field name="view" xsi:nil="true" />
+ <field name="rating" xsi:nil="true" />
<field name="description" xsi:nil="true" />
- <field name="date">2012-12-29</field>
- <field name="time">12:51:00</field>
+ <field name="date">2013-01-16</field>
+ <field name="time">10:50:11</field>
<field name="time_corr">0</field>
<field name="camera_make" xsi:nil="true" />
<field name="camera_model" xsi:nil="true" />
@@ -1968,7 +1978,7 @@
<field name="focus_dist" xsi:nil="true" />
<field name="ccd_width" xsi:nil="true" />
<field name="comment" xsi:nil="true" />
- <field name="timestamp">2012-12-29 11:51:00</field>
+ <field name="timestamp">2013-01-16 09:50:11</field>
<field name="lat" xsi:nil="true" />
<field name="lon" xsi:nil="true" />
<field name="mapzoom" xsi:nil="true" />
View
2 php/UnitTests/userTest.php
@@ -334,7 +334,7 @@ public function testCrumbs() {
* Tests only 1 user with no ratings
* full testing is done in the rating object
*/
- public function testgetRatingGraph() {
+ public function testGetRatingGraph() {
$user=new user(1);
$graph=$user->getRatingGraph();
$this->assertInternalType("array", $graph);
View
2 php/albums.php
@@ -38,7 +38,7 @@
$obj=&$album;
$ancestors = $album->get_ancestors();
$order = $user->prefs->get("child_sortorder");
- $children = $album->getChildren($order);
+ $children = $album->getChildrenForUser($order);
$totalPhotoCount = $album->getTotalPhotoCount();
$photoCount = $album->getPhotoCount();
View
2 php/categories.php
@@ -37,7 +37,7 @@
$obj=&$category;
$ancestors = $category->get_ancestors();
$order = $user->prefs->get("child_sortorder");
- $children = $category->getChildren($order);
+ $children = $category->getChildrenForUser($order);
$photoCount = $category->getPhotoCount();
$totalPhotoCount = $category->getTotalPhotoCount();
View
18 php/category.inc.php
@@ -96,20 +96,17 @@ public function getChildren($order=null) {
$sql =
"SELECT c.*, category as name " .
$order_fields . " FROM " .
- DB_PREFIX . "categories as c LEFT JOIN " .
- DB_PREFIX . "photo_categories as pc " .
- "ON c.category_id=pc.category_id LEFT JOIN " .
- DB_PREFIX . "photos as ph " .
- "ON pc.photo_id=ph.photo_id " .
+ DB_PREFIX . "categories as c " .
"WHERE parent_category_id=" . $id .
" GROUP BY c.category_id " .
$order;
- return category::getRecordsFromQuery("category", $sql);
+
+ $this->children=category::getRecordsFromQuery("category", $sql);
+ return $this->children;
}
public function getChildrenForUser($order=null) {
- $children=$this->getChildren($order);
- return remove_empty($this->getChildren);
+ return remove_empty($this->getChildren($order));
}
function getPhotoCount() {
@@ -181,7 +178,6 @@ function getTotalPhotoCount() {
}
}
-
return category::getCountFromQuery($sql);
}
@@ -331,7 +327,7 @@ public function getDetails() {
if ($user->is_admin()) {
$sql = "SELECT ".
- "COUNT(ph.photo_id) AS count, " .
+ "COUNT(DISTINCT ph.photo_id) AS count, " .
"MIN(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS oldest, " .
"MAX(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS newest, " .
"MIN(ph.timestamp) AS first, " .
@@ -348,7 +344,7 @@ public function getDetails() {
" GROUP BY pc.category_id";
} else {
$sql = "SELECT " .
- "COUNT(ph.photo_id) AS count, " .
+ "COUNT(DISTINCT ph.photo_id) AS count, " .
"MIN(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS oldest, " .
"MAX(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS newest, " .
"MIN(ph.timestamp) AS first, " .
View
7 php/classes/zophTreeTable.inc.php
@@ -116,6 +116,7 @@ function getBranchIdArray(&$id_array) {
$id_array[] = $this->get($key);
$this->getChildren();
+
if ($this->children) {
foreach($this->children as $c) {
$c->getBranchIdArray($id_array);
@@ -156,7 +157,7 @@ function get_xml_tree($xml, $search, $user=null) {
$newchild->appendChild($newchildtitle);
}
$order = $user->prefs->get("child_sortorder");
- $children=$this->getChildren($order);
+ $children=$this->getChildrenForUser($order);
if($children) {
$childset=$xml->createElement($rootname);
foreach($children as $child) {
@@ -179,7 +180,7 @@ public function getDetailsXML(array $details=null) {
if(!isset($details)) {
$details=$this->getDetails();
}
- $children=$this->getChildren();
+ $children=$this->getChildrenForUser();
if(is_array($children)) {
$details["children"]=count($children);
}
@@ -205,7 +206,7 @@ function create_tree_select_array($name, $user = null, $rec = null,
} else {
$order="name";
}
- $children = $rec->getChildren($order);
+ $children = $rec->getChildrenForUser($order);
if ($children) {
foreach ($children as $child) {
$select_array = create_tree_select_array($name, $user, $child,
View
53 php/place.inc.php
@@ -128,25 +128,20 @@ public function getChildren($order=null) {
}
$sql =
- "SELECT pl.*, pl.title as name " .
+ "SELECT *, title as name " .
$order_fields . " FROM " .
- DB_PREFIX . "places as pl LEFT JOIN " .
- DB_PREFIX . "photos as ph " .
- "ON pl.place_id = ph.location_id " .
+ DB_PREFIX . "places as pl " .
"WHERE pl.parent_place_id=" . (int) $this->getId() .
" GROUP BY pl.place_id " .
$order;
-
- return place::getRecordsFromQuery("place", $sql);
+ $this->children=place::getRecordsFromQuery("place", $sql);
+ return $this->children;
}
public function getChildrenForUser($order=null) {
- $children=$this->getChildren($order);
- return remove_empty($this->getChildren);
+ return remove_empty($this->getChildren($order));
}
-
-
public function tzid_to_timezone() {
$tzkey=$this->get("timezone_id");
if($tzkey>0) {
@@ -264,28 +259,25 @@ public function getPhotos() {
public function getPhotoCount() {
$user=user::getCurrent();
- $id = $this->get("place_id");
-
if ($user->is_admin()) {
$sql =
- "select count(*) from " .
+ "SELECT COUNT(*) FROM " .
DB_PREFIX . "photos " .
- "where location_id = '" . escape_string($id) . "'";
+ "WHERE location_id = " . (int) $this->getId();
} else {
$sql =
- "select count(*) from " .
- DB_PREFIX . "photos as p JOIN " .
- DB_PREFIX . "photo_albums as pa " .
+ "SELECT COUNT(DISTINCT p.photo_id) FROM " .
+ DB_PREFIX . "photos AS p JOIN " .
+ DB_PREFIX . "photo_albums AS pa " .
"ON p.photo_id = pa.photo_id JOIN " .
- DB_PREFIX . "group_permissions as gp " .
+ DB_PREFIX . "group_permissions AS gp " .
"ON pa.album_id = gp.album_id JOIN " .
- DB_PREFIX . "groups_users as gu " .
+ DB_PREFIX . "groups_users AS gu " .
"ON gp.group_id = gu.group_id " .
- "WHERE p.location_id = " . escape_string($id) .
- " AND gu.user_id = '" . escape_string($user->get("user_id")) .
- "' AND gp.access_level >= p.level";
+ "WHERE p.location_id = " . (int) $this->getId() .
+ " AND gu.user_id = " . (int) $user->getId() .
+ " AND gp.access_level >= p.level";
}
-
return photo::getCountFromQuery($sql);
}
@@ -295,13 +287,9 @@ public function getPhotoCount() {
*/
public function getTotalPhotoCount() {
$user=user::getCurrent();
- if ($this->get("parent_place_id")) {
- $id_list = $this->getBranchIds();
- $id_constraint = "p.location_id in ($id_list)";
- }
- else {
- $id_constraint = "";
- }
+
+ $id_list = $this->getBranchIds();
+ $id_constraint = "p.location_id in ($id_list)";
if ($user->is_admin()) {
$sql =
@@ -328,7 +316,6 @@ public function getTotalPhotoCount() {
$sql .= " AND $id_constraint";
}
}
-
return zophTable::getCountFromQuery($sql);
}
@@ -418,7 +405,7 @@ public function getDetails() {
if ($user->is_admin()) {
$sql = "SELECT ".
- "COUNT(ph.photo_id) AS count, " .
+ "COUNT(DISTINCT ph.photo_id) AS count, " .
"MIN(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS oldest, " .
"MAX(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS newest, " .
"MIN(ph.timestamp) AS first, " .
@@ -433,7 +420,7 @@ public function getDetails() {
" GROUP BY ph.location_id";
} else {
$sql = "SELECT " .
- "COUNT(ph.photo_id) AS count, " .
+ "COUNT(DISTINCT ph.photo_id) AS count, " .
"MIN(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS oldest, " .
"MAX(DATE_FORMAT(CONCAT_WS(' ',ph.date,ph.time), GET_FORMAT(DATETIME, 'ISO'))) AS newest, " .
"MIN(ph.timestamp) AS first, " .
View
4 php/places.php
@@ -41,8 +41,7 @@
$obj=&$place;
$ancestors = $place->get_ancestors();
$order = $user->prefs->get("child_sortorder");
- $children = $place->getChildren($order);
-
+ $children = $place->getChildrenForUser($order);
$totalPhotoCount = $place->getTotalPhotoCount();
$photoCount = $place->getPhotoCount();
@@ -171,7 +170,6 @@
<a href="photos.php?location_id=<?php echo $place->get("place_id") ?>"><?php echo translate("view photos")?></a>
</span>
<?php
-
if ($photoCount > 1) {
echo sprintf(translate("There are %s photos"), $photoCount);
echo " $fragment.<br>\n";
View
2 php/templates/default/view_tree.tpl.php
@@ -38,7 +38,7 @@
<ul class="tree" id="<?php echo $tpl_id ?>">
<?php foreach ($tpl_items as $item): ?>
- <?php $children=$item->getChildren(); ?>
+ <?php $children=$item->getChildrenForUser(); ?>
<li class="collapsed">
<?php if($children): ?>
<div class="toggle" onclick="thumbview.toggle(this.parentNode)"></div>
View
2 php/util.inc.php
@@ -698,7 +698,7 @@ function check_js($user) {
}
}
-function remove_empty($children) {
+function remove_empty(array $children) {
$user=user::getCurrent();
$clean=array();
// If user is not admin, remove any children that do not have photos
View
2 sql/zoph_update-0.10.sql
@@ -34,6 +34,8 @@ CREATE TABLE zoph_conf (
ALTER TABLE zoph_prefs DROP COLUMN desc_thumbnails;
+ALTER TABLE zoph_photos DROP COLUMN rating;
+
CREATE INDEX photo_id ON zoph_photo_ratings(photo_id);
CREATE VIEW zoph_view_photo_avg_rating AS

0 comments on commit 058b8c7

Please sign in to comment.