Commit Graph

31 Commits

Author SHA1 Message Date
Tim Almdal
24d7f5df8c Refactor the get maximum weight functionality into a method in the item helper, so that we can use it else where (i.e. the new organize module)
Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
2009-08-18 05:21:17 +08:00
Bharat Mediratta
e8c57290a2 Change the children and descendants APIs to be more consistent and to
remove Gallery3 concepts from ORM_MPTT.

The following API methods:
  ORM_MPTT::children
  ORM_MPTT::children_count
  ORM_MPTT::descendants
  ORM_MPTT::descendants_count

All now take a $where clause that allow you to pass through additional
field parameters.

old API:
  $album->children(10, 0, "photos")
  $album->children_count("photos")

new API:
  $album->children(10, 0, array("type" => "photos"))
  $album->children_count(array("type" => "photos"))

This gives us a more flexible API and simplifies the code.  While I
was in there, I changed the way we deal with default orderby values so
that we just assign the default value in the function definition,
which allows us to get rid of all conditionals in the implementation
which results in simpler code.
2009-08-05 10:38:53 -07:00
Tim Almdal
187d4b209d Change the children methods on Item_Core and ORM_MPTT in order to
specify a type parameter, so tht we can filter the children based
on type (i.e. album, photo, etc).
In addition, expose the sort order, so that we can specify the order
we want to return the children.
2009-08-05 07:38:35 -07:00
Bharat Mediratta
7ad0808a11 Change the API for getting to the original state of an ORM.
Old API:  $obj->original("field_name")
  New API:  $obj->original()->field_name

This allows us to revert the varous xxx_updated events back to passing
an original ORM as well as the the updated one.  This makes for a
cleaner event API.

  Old API:  comment_updated($comment) { $comment->original("field_name") }
  Old API:  comment_updated($old, $new) { $old->field_name }
2009-08-02 12:09:00 -07:00
Bharat Mediratta
fc3273da4d Add some code to guard the weight calculation against zero rows when
we're doing an initial install.
2009-07-30 08:02:54 -07:00
Bharat Mediratta
ca96d47196 Oops, I removed too much in my last change. Put talmdal's query back,
but change it to use Database instead of ORM for a little more
efficiency.
2009-07-29 16:58:29 -07:00
Bharat Mediratta
7438a9c889 Remove some scary debug code. 2009-07-29 16:40:01 -07:00
Tim Almdal
ead6a61d9e Fix for ticket #576
Add a weight index to the item table and changed the retrieval of the maximum
weight to select weight from items order by weight desc limit 1.

Upgrades the gallery module to version 10

Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
2009-07-30 01:59:07 +08:00
Bharat Mediratta
7efb4b4cdf Remove the unnecessary ORDER BY on $this->sort_column in
get_position(), and instead apply an ORDER BY on `id` in the 2nd query
so that we have stability among the equal elements.  This should
result in cheaper (and more sensible) queries.
2009-07-27 15:17:14 -07:00
Andy Staudacher
e68599f6d7 Merge branch 'master' of git@github.com:gallery/gallery3 2009-07-27 11:27:50 -07:00
Andy Staudacher
d18f31ab21 Revert "Remove an useless ORDER BY."... the order by wasn't all that useless.
This reverts commit c80d2da0a9.

Conflicts:

	modules/gallery/models/item.php
2009-07-27 11:25:23 -07:00
Tim Almdal
4edf86f0eb Revert "Fix for ticket #452"
This reverts commit 809e52d80c.
2009-07-27 11:14:03 -07:00
Andy Staudacher
570e0b0267 Merge branch 'master' of git://github.com/rledisez/gallery3 into rledisez/master 2009-07-26 22:45:53 -07:00
Tim Almdal
809e52d80c Fix for ticket #452
1) Change access_Core::user_can to return true for all permissions if the
   owner is the specified user.
2) Change Item_Model::viewable to set the owner_id is the first view_restriction
   This allowed simplification of the generating the where clause to a single
   $this->orwhere instead of a where and an orwhere.
2009-07-25 23:45:48 -07:00
Romain LE DISEZ
23bb6eb7e3 Rename columns that use reserved SQL words : items.left and items.right 2009-07-25 19:06:54 +02:00
Romain LE DISEZ
d3fa2bed68 Merge commit 'upstream/master' 2009-07-20 10:49:47 +02:00
Bharat Mediratta
c461881110 Don't post the item_updated() event if we're just updating the view count. 2009-07-19 13:20:08 -07:00
Romain LE DISEZ
c78744d4f8 Merge commit 'upstream/master' 2009-07-18 17:51:23 +02:00
Bharat Mediratta
cd907c2b42 Change model_cache::clear() API to clear everything. This prevents
old ORM relationships from hanging around, which was causing problems
when doing MPTT manipulations (resulting in incorrect permission
propagation-- very bad!)
2009-07-17 12:51:27 -07:00
Bharat Mediratta
8a6556b30b Fix a bug where moved items don't properly inherit permissions from
their new target.  After each move, recalculate the permissions for
the new parent's hierarchy.

Fixes ticket #552
2009-07-17 08:14:08 -07:00
Bharat Mediratta
0f766b149d Second non-trivial change to the event code. We now publish model
related events from within the model handling code.  The only
exception to this currently is item_created which is challenging
because we have to save the item using ORM_MPTT::add_to_parent()
before the object itself is fully set up.  When we get that down to
one call to save() we can publish that event from within the model
also.
2009-07-16 12:31:40 -07:00
Bharat Mediratta
5b3b675b6d Non-trivial changes to the event handling code:
1) The item_updated event no longer takes the old and new items.
   Instead we overload ORM to track the original data and make
   that available via the item.  This will allow us to move event
   publishing down into the API methods which in turn will give us
   more stability since we won't require each controller to remember
   to do it.

2) ORM class now tracks the original values.  It doesn't track
   the original relationships (no need for that, yet)

3) Added new events:
     item_deleted
     group_deleted
     user_deleted
2009-07-16 11:19:34 -07:00
Romain LE DISEZ
7f5030ac20 Merge commit 'upstream/master' 2009-07-16 17:31:20 +02:00
Tim Almdal
8ed6d1183b Fix for #319.
Created a new view "movieplayer.html.php", which is rendered by
Item_Model::movie_img().  Changed movie.html.php to use movie_img to render
the movie player link.
2009-06-30 08:21:00 -07:00
Romain LE DISEZ
be354ab98b Remove an useless ORDER BY.
It improves compatibility with PgSQL.
(Replay of c80d2da0a9)
2009-06-24 23:40:47 +02:00
Bharat Mediratta
ba7163bd30 Fix get_position() to properly deal with duplicate values in the sort column. Fixes #389 2009-06-23 14:50:41 -07:00
Bharat Mediratta
4e3b84eb39 Escape {$this->sort_column} in get_position() 2009-06-23 14:23:11 -07:00
Bharat Mediratta
4f0a3fefa0 Fix a bug in Item_Model::get_position() where we incorrectly using the
grandparent id.  Oops.  This caused navigation from photo back up to
album to be broken.

Also update Photos_Controller to use the active sort order.. it was
still hardcoded to use the id.  It's more efficient now, yay.

Fixes ticket #340.
2009-06-04 22:11:08 -07:00
Tim Almdal
0f987880e6 Fix for ticket #320 2009-06-02 12:08:47 -07:00
Bharat Mediratta
9a7e642cd6 Don't let relative_path() try to update the database if the Item_Model
is not loaded, else you get weird errors.
2009-05-31 22:30:48 -07:00
Bharat Mediratta
28b41056e3 Restructure things so that the application is now just another module.
Kohana makes this type of transition fairly straightforward in that
all controllers/helpers/etc are still located in the cascading
filesystem without any extra effort, except that I've temporarily
added a hack to force modules/gallery into the module path.

Rename what's left of "core" to be "application" so that it conforms
more closely to the Kohana standard (basically, just
application/config/config.php which is the minimal thing that you need
in the application directory)

There's still considerable work left to be done here.
2009-05-27 15:07:27 -07:00