Commit Graph

87 Commits

Author SHA1 Message Date
Bharat Mediratta
afb3fa71b9 Get rid of internal_only designation -- it's too hard to enforce cleanly. 2010-01-17 16:58:47 -08:00
Bharat Mediratta
4f8c98a7bc Move rules entirely down into validate() so that we can be more
sophisticated but keep all our rules in one place.

Add rules for most fields.
2010-01-17 12:13:25 -08:00
Bharat Mediratta
fdcb4a1f32 PHPdoc. 2010-01-16 18:16:47 -08:00
Bharat Mediratta
a5aacfa4a6 Don't forget to save when we make insignificant chagnes only. 2010-01-16 18:10:40 -08:00
Bharat Mediratta
efdb73cb98 Make movie creation use model based validation. Move movie related
logic from movie::create() into Item_Model
2010-01-16 12:00:50 -08:00
Bharat Mediratta
9f6dba7238 Check for illegal extensions in valid_name()
Fix a bug where we were not calling valid_data_file correctly.
2010-01-16 11:12:19 -08:00
Bharat Mediratta
bf085a1a17 Convert photo uploading over to the new model based validation
approach.

- Rearrange Simple_Uploader_Controller::add_photo() to validate
  the form early in the process, and switch to using model based
  validation.

- Move thumbnail generation into gallery_event::item_created() so
  that it's decoupled from the model.

- Delete photo::create() and move all of its logic into
  Item_Model::save().

- Add Item_Model::$data_file to track the data file associated
  with new movies and photos.

- Do some cleanup on the validation callbacks -- it turns out the
  2nd argument is the field name not the value.
2010-01-16 00:51:31 -08:00
Bharat Mediratta
434d351b2f Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Conflicts:
	modules/gallery/models/item.php
2010-01-16 00:15:23 -08:00
Bharat Mediratta
dcf4b5e71a Don't pass MY_ORM::original() to update event handlers, since after
parent::save() it'll be reset.  Clone it first.

This is an alternate fix for #978.
2010-01-16 00:13:28 -08:00
Bharat Mediratta
654b103355 Validate the model type. 2010-01-15 13:41:46 -08:00
Bharat Mediratta
50e3cc5837 Move model business logic out of album::create() and into
Item_Model::save().  This makes creating albums similar to editing
them and makes it difficult to create an album poorly.  I expect to be
able to remove a lot of code from the photo and movie helper because
it's duplicated here.

In order to do this, I refactored ORM_MPTT::add_to_parent() into
ORM_MPTT::save() so we now add it to the parent when we do save.  This
allows us to call save() only once which saves a database call per
add.

The Albums_Controller logic is roughly the same as before.

Haven't updated the tests yet, they're going to fail miserably since
many of them depend on album::create() which is now gone.
2010-01-15 12:15:20 -08:00
Bharat Mediratta
94f58e8b65 Move setting Item_Model::rand_key into Item_Model::save() since it's
business logic.
2010-01-15 10:48:39 -08:00
Bharat Mediratta
1a557ce5a6 Use $value in valid_xxx() functions instead of the member field. They're equivalent, but it's more intuitive this way. 2010-01-15 10:36:56 -08:00
Bharat Mediratta
b3e328c9ff Begin the process of converting to model based validation. Right
now only Albums_Controller::update() supports the pattern.  All
form and controller based validation happening when editing an
album has been moved over.

Model based validation means that our REST controllers share the
same validation as web controllers.  We'll have consistency
enforced at the model level, which is a Good Thing.

The basic pattern is now:
1) Rules are in the model

2) ORM::validate() (which is called by ORM::save() but you can
   call it directly, too) checks the model for all the rules and
   throws an ORM_Validation_Exception if there are failures

3) Actions are no longer taken when you call Item_Model::__set().
   Instead, they're all queued up and executed when you call
   Item_Model::save().

Notes:
- item::validate_xxx() functions are now in Item_Model::
- We still call $form->validate() because the form can have
 rules (and forms triggered by events will likely continue to
 have rules.
2010-01-14 21:04:09 -08:00
Tim Almdal
8ae0d4c196 Change uppercase NULL to lowercase null to match the gallery3 style guide 2010-01-04 13:00:15 -08:00
Tim Almdal
bfcd4efe92 Another K2.4 holder over... We had, when checking for position, ->where(, "=", NULL) which would never find any. It should have been ->where(, "is", NULL) 2010-01-04 12:39:48 -08:00
Bharat Mediratta
4ab2400d18 Add a cache buster to the resize and file urls. This fixes ticket 2010-01-02 13:47:28 -08:00
Bharat Mediratta
f65794785a Take precautions against deleting var/albums, var/thumbs or var/resizes.
Fixes ticket #916.
2010-01-02 10:51:47 -08:00
Bharat Mediratta
a6da027aad The default value for $offset should always be null (according to the
new K24 ORM).

Fix up a bad where tuple in the test.
2009-12-22 16:22:24 -08:00
Bharat Mediratta
ca1f7d0da7 Convert a database query. 2009-12-18 01:12:16 -08:00
Bharat Mediratta
9b3b9c6da6 Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev 2009-12-16 17:58:49 -08:00
Bharat Mediratta
02b3c4e704 Adjust for the fact that movies have JPG thumbnails. Fixes ticket 2009-12-16 15:18:08 -08:00
Bharat Mediratta
8c03c7a073 Convert some database calls. 2009-12-13 17:15:12 -08:00
Bharat Mediratta
96b00d6cfe Convert some more Database::instance() calls to db::build() form. 2009-11-26 21:14:54 -08:00
Bharat Mediratta
a3d904bcba ORM::find_all() now uses null as the default value for offset. 2009-11-26 19:36:57 -08:00
Bharat Mediratta
54be15191b Overload Database_Builder to add merge_where() which takes predefined
where clauses and adds them to the existing query.  Update all
existing queries that take an additional where clause to use it.
2009-11-26 18:47:40 -08:00
Bharat Mediratta
1fd0e14359 Convert all DB where() calls to take 3 arguments.
Convert all open_paren() calls to and_open() or or_open() as appropriate.
2009-11-26 12:09:04 -08:00
Bharat Mediratta
2ee38b3d8e ORM::$rules now has a special meaning. Use $form_rules for our
internal rules code.
2009-11-26 11:36:09 -08:00
Bharat Mediratta
0121bfd585 ORM::orderby -> ORM::order_by 2009-11-25 19:26:52 -08:00
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
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