Commit Graph

141 Commits

Author SHA1 Message Date
Bharat Mediratta
19034d140e Rename the class to Item_Model_Core so that it can be overloaded.
Related to ticket #1368.
2010-09-12 13:35:50 -07:00
Bharat Mediratta
f84c4a6192 Uniqify the name and slug when we move an item to a new location with
a conflict.  This fixes #1364.
2010-09-11 23:37:12 -07:00
Bharat Mediratta
4ba93b7cfc Return the size in bytes of the thumb, resize and full file.
Don't return thumb info if there's no thumbnail (eg: album w/ no contents)
Don't return file_url_public for albums

Fixes ticket #1347.
2010-09-07 22:23:54 -07:00
Bharat Mediratta
ab880120e6 The G2 import sets the sort_order to "asc"/"desc" but
Item_Model::get_position() expects "DESC".  This breaks navigation in
any album imported from G2 that has a descending sort order.

Two things:
1) Use "ASC"/"DESC" in G2 import for consistency
2) Make Item_Model::get_position() more robust against capitalization

Fixes ticket #1334.
2010-09-07 21:04:38 -07:00
Bharat Mediratta
2f810ec126 Add "web_url" with the url to the web version of the item. Fixes ticket #1341. 2010-09-06 19:28:34 -07:00
Bharat Mediratta
3ff91e5e33 Null out Item_Model::$data_file in Item_Model::save() when we're
creating a new item, else the item_created event will trigger
subsequent saves which will think that they need to post an
item_updated_data_file event.  Partial fix for #1286
2010-08-25 10:05:21 -07:00
Bharat Mediratta
dbe595f15e Always use the data resource to return thumbs, resizes and full sizes.
That way the client does not have to differentiate between RESTful
request types and raw request types.  If there's a public raw url,
return that as well.
2010-08-14 16:10:32 -07:00
Bharat Mediratta
9de371e1b3 Use the data_rest implementation to proxy access to raw
thumb/resize/full data files when permissions are in play.
2010-08-09 22:55:58 -07:00
Bharat Mediratta
dfb095a262 Add the ability to replace the source data file in Item_Model::save().
Refactor the rotate code in Quick_Controller to replace the data file,
and then have gallery_event::item_updated_data_file() pick up after
the change is saved, rebuild the image and handle album covers.  This
is much more portable than before and it will allow any mechanism (eg:
REST) to replace the source image.
2010-08-07 22:18:28 -07:00
Bharat Mediratta
3f48f17e54 We don't care about the name and slug for the root album so don't bother enforcing them. 2010-07-29 19:41:03 -07:00
Romain LE DISEZ
39962eaddc Accept extension .m4v as video/mp4 2010-07-10 08:09:04 -07:00
Tim Almdal
2bbce8dddb Fix for ticket #1117 align videos to the center. 2010-06-17 09:10:01 -07:00
Tim Almdal
38d09c5d1a Scale a movie to the resize size so that it doesn't overflow into the sidebar. 2010-06-17 08:03:08 -07:00
Bharat Mediratta
e3535349ab Revert "Add a "convert_ids" parameter to Item_Model::as_restful_array(), which"
This reverts commit 98fce83de5.

Conflicts:

	modules/gallery/tests/Item_Model_Test.php
2010-06-15 20:25:35 -07:00
Bharat Mediratta
3dacafb718 Revert the "preserve_ids" global query parameter. We decided that it was a
bad idea.

This reverts commit 6425d41edd.
2010-06-09 20:49:32 -07:00
Bharat Mediratta
b40057283e Add a "can_edit" field to the Item_Model's REST output. It's
applicable to the current user.
2010-06-08 20:59:24 -07:00
Bharat Mediratta
6425d41edd Add a "preserve_ids" global query parameter for REST requests that
indicates that we shouldn't opportunistically convert ids into REST
urls.
2010-06-07 23:12:52 -07:00
Bharat Mediratta
98fce83de5 Add a "convert_ids" parameter to Item_Model::as_restful_array(), which
we can turn on with a query parameter.
2010-06-07 22:23:46 -07:00
Bharat Mediratta
1240878df0 Fix-ups for d98b85f7d3
- Pass the CSS selector of the active image in as an arg to site_menu
  so that quick operations know what they're operating on.
- Change the ids from g-{photo,movie}-id to the generic g-item-id
- Initialize ajax handlers for site menu on the photo and movie page
- Drop the movie context menu, it's now in the site menu
2010-05-14 16:55:15 -07:00
Tim Almdal
6652b69193 Merge branch 'master' into bharat_dev 2010-04-07 07:29:46 -07:00
Bharat Mediratta
78db1bb339 Fix a bug where if the file name is composed of entirely illegal
characters, we'll get an empty slug.  Partial fix for #1086.
2010-04-04 14:27:39 -07:00
Bharat Mediratta
5679e30ef6 REST changes: Allow PUT and POST requests to modify members, not
just entity.

TESTS ARE NOT UPDATED YET.

- Fix item_rest::get() to maintain the proper sort order, which
  requires duplicating some Item_Model code.

- Elide "weight" from the REST version of item

- Adjust the weight of members according to the order they're returned
  from the client.  You can't add or remove members here, you can only
  reorder them.

- Changed the wire protocol to handle more complex values.
  Now "entity" and "members" are JSON encoded.  The Gallery3
  helper does this correctly.

- Changed the wire protocol for tag_item -- now it stores the
  tag and item urls in the entity, not as members.  This is more
  consistent.

- Added missing security for renaming and deleting tags.

- Got rid of vestigial tag_rest::post().  We add/remove tags
  via the relationship.
2010-04-04 11:55:54 -07:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Bharat Mediratta
5fbc472300 Fix the resize_url and file_url in as_restful_array() 2010-02-19 11:54:03 -08:00
Tim Almdal
10c0698949 Correct the view_fillsize permission to view_full. In addition, change the name of the field containing the url to the fullsize image to file_url instead of fullzie_url 2010-02-19 11:48:54 -08:00
Tim Almdal
a597b57210 return the absolute url not the relative for the full size, resize and thumb images. 2010-02-15 12:29:49 -08:00
Tim Almdal
897215689c Remove the dirty flags from the information returned from the rest request for an item. In addition, add links to the images. 2010-02-14 07:32:35 -08:00
Bharat Mediratta
ce71ea6aa7 Revert "1) Add a depth parameter to retrieving an item thru the rest api"
This reverts commit 3439671bcf.
2010-02-12 04:53:26 -08:00
Tim Almdal
3439671bcf 1) Add a depth parameter to retrieving an item thru the rest api
2) Standardize the structure of members so that client programs can consistently
   parse the return information.
3) Added a summary parameter so that client programs can easily determine if the
   information returned is summary (item type, item title) or the full meal deal
2010-02-12 09:52:57 -08:00
Bharat Mediratta
aff5d1cef4 Create the concept of a "failed authentication" as semantically
separate from a successful or failed login.

1) Rename user_login_failed event to user_authenticate_failed

2) Rename failed_logins table to failed_auth (bump Gallery module to
   v27 to rename the table)

3) auth::too_many_failed_logins -> auth::too_many_failures

4) auth::record_failed_auth_attempts -> auth::record_failed_attempts
   auth::clear_failed_auth_attempts  -> auth::clear_failed_attempts
2010-02-07 08:45:10 -08:00
Bharat Mediratta
c050acf30a Fix lots of warnings that pop up when we're in E_STRICT mode. They're
mostly issues around uninitialized variables, calling non-static
functions in a static context, calling Session functions directly
instead of on its singleton, passing non-variables by reference, and
subclasses not using the same interface as the parent class.
2010-01-31 16:07:41 -08:00
Bharat Mediratta
ee35b0a9fe Elide data that isn't useful from the REST array. 2010-01-31 13:10:34 -08:00
Bharat Mediratta
d29028c4ea Add Item_Model::as_restful_array() for convenience. 2010-01-30 23:36:11 -08:00
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