Commit Graph

45 Commits

Author SHA1 Message Date
Bharat Mediratta
a432a43b3b Revert "Change the item rest update processing to call the
item::move(source, target) helper when the parent member has changed.
Using the move method insures that names and slugs that could conflict
in the target album are resolved properly.  Changed the item::move
method so it returns a message to be displayed if the caller chooses.
And changed the move controller to display the message returned by the
move if the item name was renamed as part of the move."

Rolling this back for a couple of reasons:

1) Bug in move.php ("message.info" is not a function name)

2) Having the message come back from the API call as a side-effect is
sloppy.  We should find a cleaner way to do this checking.

3) having item::move() call save() on any changed values in the ORM
is counter-intuitive.  Move should move, save should save.

I think the right approach here is to roll the move() code properly into
save().

This reverts commit 2492280cc0.
2010-06-15 17:18:22 -07:00
Bharat Mediratta
48dc07dbc8 Revert "Fix for ticket #1118. Create a item::save_with_retries helper
method, which encapsulates saving an item and handling name and slug
conflicts. Call this instead of doing a save directly."

Rolled this back because it fails KISS.  We already have an API for
saving models with Item_Model::save() that's consistent with all of
our other model code.  Adding a new way to save items is confusing and
inconsistent.

This reverts commit 9504f71efc.
2010-06-15 17:17:25 -07:00
Tim Almdal
9504f71efc Fix for ticket #1118. Create a item::save_with_retries helper method, which encapsulates saving an item and handling name and slug conflicts. Call this instead of doing a save directly. 2010-06-15 14:18:23 -07:00
Tim Almdal
2492280cc0 Change the item rest update processing to call the item::move(source, target) helper when the parent member has changed. Using the move method insures that names and slugs that could conflict in the target album are resolved properly. Changed the item::move method so it returns a message to be displayed if the caller chooses. And changed the move controller to display the message returned by the move if the item name was renamed as part of the move. 2010-06-15 12:52:28 -07:00
Tim Almdal
58b21e909d Change the pattern used to convert the file name to a title. Fixes ticket#1061 2010-06-10 18:49:29 -07:00
Bharat Mediratta
4e56176f35 item::random_query() doesn't need to take a "where" clause because
it's returning a query, so the caller can add the where clause
himself.  This makes for a cleaner API.
2010-06-05 23:47:47 -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
8a8d8b4bc4 Rename item name and slug if necessary to avoid a conflict when we
move photos.  Fixes ticket #957.
2010-02-09 15:49:43 -08:00
Bharat Mediratta
16ccda0f3d Two fixes:
1) Don't call ORM_MPTT::move_to() directly.  Use the new
   model-based-validation approach of changing the parent_id and saving.

2) Item_Model::parent() can return null; check for it.
2010-01-20 23:49:10 -08:00
Bharat Mediratta
a587426cfd Don't try to set the album cover for the grandparent if we don't have edit permissions for it. 2010-01-19 01:12:09 -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
Bharat Mediratta
9864ab4b27 Move the random image functionality into the gallery REST helper since
choosing a random image is essentially a function on an item collection.
Also implemented a bunch of other query filters for item collections.

Created item::random_query() as a way of generating a reasonable
starting point for random queries.
2010-01-08 14:56:08 -08:00
Bharat Mediratta
fb65a0a585 Remove debug code. 2010-01-08 14:20:15 -08:00
Bharat Mediratta
895ac72e70 Add item::random() to return a random Item_Model. 2010-01-08 11:49:18 -08:00
Tim Almdal
d6ddbd1a31 Rollback the refactoring of the update into a helper method. Also remove the refactoring for check for commits 2009-12-30 16:12:32 -08:00
Tim Almdal
bccb6fc021 Clean up validation the check for duplicate names or slugs, finish converting the rest API to Kohana 2.4 2009-12-27 08:32:12 -08:00
Tim Almdal
07e83718a0 Forgot to commit local changes to item helper for K2.4 2009-12-26 11:26:44 -08:00
Tim Almdal
3060a6f662 Merge branch 'master' into talmdal_dev
Conflicts:
	modules/gallery/controllers/albums.php
	modules/gallery/controllers/movies.php
	modules/gallery/controllers/photos.php
2009-12-26 11:24:50 -08:00
Bharat Mediratta
0650109d4b Add merge_or_where() to MY_Datatabase_Builder and use that instead of
or_where() for compatibility and convenience.  Caught by failing unit
tests.
2009-12-22 13:50:52 -08:00
Tim Almdal
c3a0f419c6 Refactor the code to check for name or slug conflicts and to update code out of {Albums|Photos|Movies)_Controller and into the item helper so we can reuse it from the rest put handler. 2009-12-09 09:50:57 -08:00
Tim Almdal
16bed1ffd5 Remove the hidden form variable _method which was used in the no longer rest controllers. 2009-12-06 21:32:27 -08:00
Bharat Mediratta
fb899c313c Further simplifications to viewable(). Stop trying to optimize for
the case where we just have one restriction, it's unnecessary.
2009-12-06 21:28:40 -08:00
Bharat Mediratta
b9dadb77c3 Get rid of unused _method param in the item edit form.
Fix viewable() to properly OR view restrictions together.
2009-12-06 21:21:35 -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
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
Bharat Mediratta
1067e68292 Redesign the way that we consider page types to create buckets of page
types, and a subtype for specifics.  Currently the top level bucket

   collection, item, other

Here are the core subtypes so far:

   collection: album, search, tag
   item: movie, photo
   other: login, reset, comment-fragment, comment

It's legal to create new page_subtypes whenever you want.  Use the
appropriate page_type to get the coarse grain behavior that you want.
2009-11-17 14:04:45 -08: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
78ee4193b7 Remove all non Identity API methods from Identity.php. Created an MY_Session class to provide the user state changes in the session and a login.php helper that has the login form. 2009-10-16 10:06:58 -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
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
0df4b7d705 Fix line > 100 chars. 2009-09-08 21:49:28 -07:00
Bharat Mediratta
77bd3d3d40 Replace two preg_replace() calls with a single trim() call. 2009-09-08 21:49:09 -07:00
Bharat Mediratta
48becbe017 Update item::convert_filename_to_slug() to eliminate leading and
trailing hyphens.
2009-09-08 20:03:55 -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
83ebc2e2b0 Remove unused item::validate_no_name_conflict() and a debug line. 2009-09-07 20:59:11 -07:00
Bharat Mediratta
2f666f4c52 Add item::validate_url_safe() with a test. 2009-09-07 20:07:37 -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
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
e3f5a8be90 Change the setting of page type from "item" to "photo". Thre is no page type
of item.  All other references use photo for non album and non dynamic pages.

Signed-off-by: Tim Almdal <tnalmdal@shaw.ca>
2009-08-19 21:16:02 +08: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
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
Chad Kieffer
390bc7c1f6 Switch quick delete from JS confirm to jQuery UI dialog, closes ticket #355. 2009-06-14 10:42:14 -06:00
Bharat Mediratta
43abcd9386 Security pass over all controller code. Mostly adding CSRF checking
and verifying user permissions, but there are several above-the-bar
changes:

1) Server add is now only available to admins.  This is a hard
   requirement because we have to limit server access (eg:
   server_add::children) to a user subset and the current permission
   model doesn't include that.  Easiest fix is to restrict to admins.
   Got rid of the server_add permission.

2) We now know check permissions at every level, which means in
   controllers AND in helpers.  This "belt and suspenders" approach will
   give us defense in depth in case we overlook it in one area.

3) We now do CSRF checking in every controller method that changes the
   code, in addition to the Forge auto-check.  Again, defense in depth
   and it makes scanning the code for security much simpler.

4) Moved Simple_Uploader_Controller::convert_filename_to_title to
   item:convert_filename_to_title

5) Fixed a bug in sending notification emails.

6) Fixed the Organize code to verify that you only have access to your
   own tasks.  In general, added permission checks to organize which had
   pretty much no validation code.

I did my best to verify every feature that I touched.
2009-06-01 22:40:22 -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