Commit Graph

64 Commits

Author SHA1 Message Date
Bharat Mediratta
2e420522ec Preliminary work to cut over to Kohana 2.4
- Kohana::log() -> Kohana_Log::add()
- Kohana::config_XXX -> Kohana_Config::instance()->XXX
- Implement View::set_global in MY_View
- Updated Cache_Database_Driver to latest APIs
- ORM::$loaded -> ORM::loaded()
- Updated item::viewable() to use K2.4 parenthesization
2009-11-25 13:22:24 -08:00
Tim Almdal
cbde32b0d2 Make sure the position method works for both ascending and descending sort orders. 2009-11-06 23:20:30 -08:00
Tim Almdal
88852c45ea Modified the so that a where clause can be passed into item::get_position. Was also able to remove the sub-select from the calculation of the current position as we already have the child item containing the sort column value.
Also added a where clause that ignores albums to the get_position, children and children_count method calls in photos.php and movies.php
2009-11-04 09:50:49 -08:00
Bharat Mediratta
47c75aa279 Log an alert when we can't load a user. 2009-10-30 15:40:22 -07:00
Tim Almdal
051a7ae27a Refix #812, by removing the decoding in file_proxy instead of not encoding in Item_Model when creating the relative_path_cache. 2009-10-27 20:20:32 -07:00
Tim Almdal
cb0243bbe8 Don't url encode the components of the relative_path_cache as we they refer to file paths and they are converted back in the file proxy. Fixes ticket #812 2009-10-27 19:23:30 -07:00
Tim Almdal
5212deb5b1 Merge branch 'master' into talmdal_dev 2009-10-24 10:09:57 -07:00
Tim Almdal
607662d66b When an item is renamed or move insure that the target file name doesn't exist. fixes ticket #694 2009-10-24 10:08:48 -07:00
Tim Almdal
3c936d661a Change the name of identity library from Identity to IdentityProvider. Create a helper class called identity to simplify call the Identity Provider. Move the contents of MY_Session.php to the new helper class and remove the MY_Session class 2009-10-22 13:11:03 -07:00
Tim Almdal
00eacd659f Start simplifying the interface by moving the static methods from user.php and group.php. Tried creating a identity helper, but the helper identity.php was confused with the library Identity.php. So got around this by making the methods on Identity static and calling the instance within the static methods. Also temporarily moved the user.php and group.php back into the user module. 2009-10-16 08:53:31 -07:00
Tim Almdal
00ee91837f Convert direct lookups for the user table using ORM to using the user::lookup_by_name and user_lookup API methods.
Convert the Admin_User controller
Convert the login and password change controller
Change the item model to call user::lookup to get the owner.
On the log model, delete the relationship between the log and user table, and replace with a
call to user::lookup
(cherry picked from commit 194cc3b27a)
Create the get_user_list, lookup_by_name, lookup_by_hash and get_group_list api functions
2009-10-09 01:26:35 -07:00
Bharat Mediratta
bc63e4fcf9 Make the slug field required for all items.
Make the filename field required for photos/movies.
Fixes ticket #838
2009-10-11 11:16:07 -07:00
Tim Almdal
7ad203b97a Merge branch 'master' of git@github.com:gallery/gallery3 into talmdal_dev 2009-10-08 13:47:30 -07:00
Tim Almdal
194cc3b27a First pass on converting calls to the Identity interface. Will worry about writes and saves later.
Convert the Admin_User controller
Convert the login and password change controller
Change the item model to call user::lookup to get the owner.
On the log model, delete the relationship between the log and user table, and replace with a
call to user::lookup
2009-10-05 16:28:16 -07:00
Chad Kieffer
3e6ba7acc3 Renamed most, if not all css selectors from gName to g-name. Moved a few shared images from wind to lib. Deleted unused images in the admin_wind. This will likely break a few ajax features. 2009-10-04 00:27:22 -06:00
Bharat Mediratta
e5a78d39ec Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts:
	modules/gallery/controllers/albums.php
2009-09-21 21:29:13 -07:00
Bharat Mediratta
529ded3388 2nd attempt at gracefully dealing with sort columns that contain
nulls.  This time around, do a query to determine whether or not the
sort column has nulls in it.  If it doesn't, then use our comparators
as before.

There are NULLs in the sort column, so we can't use MySQL comparators.
Fall back to iterating over every child row to get to the current one.
This can be wildly inefficient for really large albums, but it should
be a rare case that the user is sorting an album with null values in
the sort column.

Fixes #627
2009-09-21 21:28:00 -07:00
Bharat Mediratta
a6581ede0b Fix Item_Model::get_position() so that our sort is stable when the comparison
row has a null value in the sort field.  Fix for #627

Note: this changes get_position() to take an Item_Model instead of an id!
2009-09-21 11:35:27 -07:00
Bharat Mediratta
7ec490b600 rawurlencode() path components in relative_path_cache and
relative_url_cache so that they're safe for browser use.
2009-09-11 11:04:35 -07:00
Bharat Mediratta
3bd8be2651 Change the relative_path_cache and relative_url_cache columns to store
urlencoded data for ease of use when we're dealing with the data.
This fixes ticket #569 by not allowing the urls that we put into our
RSS feeds to have bad characters in them.

We have to convert a path like var/albums/foo/"quotes"/bar.jpg into
something like var/albums/foo/%22quotes%22/bar.jpg.  If we take the
approach of storing native data in the cache, then we have to explode
the path, urlencode the bits, and implode it again to avoid escaping
the / char.  By storing it escaped, we avoid this problem. I believe
(but have not tested) that this is more efficient.
2009-09-08 21:02:45 -07:00
Bharat Mediratta
cf0c8b6319 Minor tweaks to the url refactor. 2009-09-08 17:01:59 -07:00
Bharat Mediratta
2aad580f53 Move specialized (pretty) url generation back into Item_Model so that
we're not relying on overriding url::site() to do tricks around item
urls.  This means that you won't get item urls by doing
url::site("albums/37"), for example, but it also means that we won't
get pretty urls where we don't expect them (like in the action of a
<form> element).

Incidentally, this will help us move over to using the slug format
because if you've got a bad character in a url, the edit forms will
now work on it since they'll be id based.
2009-09-08 13:44:52 -07:00
Bharat Mediratta
86f88769f9 Update Item_Model::save() to consider the relative_xxx_cache fields as
insignificant, in addition to the view_count field.  This means that
we won't trigger an event, nor will we adjust the updated field if
*only* those fields are changed.
2009-09-07 21:30:48 -07:00
Bharat Mediratta
78a42d9b83 1. Actually set the slug to the new value in the controllers.
2. Fix up an issue where we were crashing if there were no conflicting rows
3. Amend Item_Model so that if you change the slug, it flushes the cache
   for all children
2009-09-07 21:09:52 -07:00
Bharat Mediratta
dccfce4c00 Correct a mental mistake in the prior change. All the xxx_url()
methods actually refer to the url to the file on disk, not the logical
item.  That's relative_url().  Perhaps some API renaming is in order?
2009-09-07 21:00:52 -07:00
Bharat Mediratta
3f997562de Add support for a per-item "slug" which will be the user-visible url
component for that given item.  Album hierarchies are represented by
nested slugs.  By default, we convert the filename to a slug when you
create an album, photo or movie.
2009-09-07 15:42:08 -07:00
Bharat Mediratta
a09a6a06be Refactor how we use $this->relative_path() so that we're not calling
it twice on both sides of a ternary operator.
2009-09-02 11:28:41 -07:00
Tim Almdal
38b2efc44c Fix for 641... extend viewable functionality to comments. Viewable unit test is not working. 2009-08-29 11:43:10 -07:00
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