Commit Graph

108 Commits

Author SHA1 Message Date
Bharat Mediratta
2bfcec9620 Prevent brute force login attacks by reducing login attempts to 1 per
minute after there have been 5 consecutive failed login attempts.

Fix for ticket #589.
2010-01-30 19:48:57 -08:00
Tim Almdal
c4e3604315 Strongly type the argument list to the model::validate method. 2010-01-29 14:04:27 -08:00
Bharat Mediratta
4b32a71afc Convert back to using ORM::factory(..., $id) instead of calling where(). 2010-01-27 22:34:11 -08:00
Bharat Mediratta
212633d05a Prevent accidentally deleting the root album. 2010-01-27 21:52:18 -08:00
Bharat Mediratta
5c68519d92 Specialize the album cover id check to allow the root album to have no
album cover.
2010-01-26 00:23:45 -08:00
Bharat Mediratta
953c9283ad Always keep the original around when updating existing items, because
we need it for the item_updated event.
2010-01-25 23:39:24 -08:00
Bharat Mediratta
dde429f71e Whitespace. 2010-01-20 23:49:20 -08:00
Bharat Mediratta
995faaa27f Stop using MY_ORM::original(). It's got very odd semantics and we are
not capturing all cases for setting and resetting $original, which
leads to some weird and hard to reproduce behavior.

Instead, if we need the original just reload it from the database.
This may result in a somewhat excessive load in places, but we'll have
to fix that in a later optimization pass.
2010-01-20 22:45:19 -08:00
Bharat Mediratta
e39c8df19f Fix some validation checks to check to see if the original was loaded
before deciding whether or not we changed a value.

Change valid_name to be cascading, not parallel.
2010-01-19 21:20:36 -08:00
Bharat Mediratta
6aee6cde25 Move data initialization into the constructor so that it happens
before validate() is called, which is important with our two phase web
controllers.

Make valid_parent smarter about moving existing items, vs new items.
2010-01-19 20:53:21 -08:00
Bharat Mediratta
afe2128bb0 Make video/x-flv a valid movie mime_type 2010-01-19 19:30:18 -08:00
Bharat Mediratta
703882f4df Update valid_parent() to disallow moving an item inside its own hierarchy.
Move move_to() inside save()
2010-01-18 22:50:50 -08:00
Bharat Mediratta
0e2f4a7a37 Fix renaming in save() by moving the actual rename action under
parent::save().  This is consistent with other changes because all
filesystem operations happen after the database change is committed.

Also, inline rename() since it's fairly simple now.
2010-01-18 20:13:46 -08:00
Bharat Mediratta
1cfee16e38 In valid_name, don't query on the id if it's null. 2010-01-18 13:09:58 -08:00
Bharat Mediratta
39bb08db28 Make set_data_file() chainable. 2010-01-17 20:02:30 -08:00
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
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