diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-07-31 19:38:29 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-07-31 19:38:29 +0000 |
commit | 1d3b83e6791b1e9e3386bb79937ef58240ba94ba (patch) | |
tree | b90b7ff2fdf45cfc8c9924d30e1fde914d80f247 /actions/admin | |
parent | a1f08342c8b8502197159a9fd78e48e6cead4ea0 (diff) | |
download | elgg-1d3b83e6791b1e9e3386bb79937ef58240ba94ba.tar.gz elgg-1d3b83e6791b1e9e3386bb79937ef58240ba94ba.tar.bz2 |
moved some actions into the admin directory
Diffstat (limited to 'actions/admin')
-rw-r--r-- | actions/admin/create_thumbnails.php | 60 | ||||
-rw-r--r-- | actions/admin/flickrSetup.php | 36 | ||||
-rw-r--r-- | actions/admin/imtest.php | 18 | ||||
-rw-r--r-- | actions/admin/settings.php | 77 |
4 files changed, 191 insertions, 0 deletions
diff --git a/actions/admin/create_thumbnails.php b/actions/admin/create_thumbnails.php new file mode 100644 index 000000000..18dae6b78 --- /dev/null +++ b/actions/admin/create_thumbnails.php @@ -0,0 +1,60 @@ +<?php +/** + * Tidypics Thumbnail Creation Test + * + * Called through ajax + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +include dirname(dirname(__FILE__)) . "/lib/resize.php"; + +global $CONFIG; + +$guid = get_input('guid'); + +$image = get_entity($guid); +if (!$image || !($image instanceof TidypicsImage)) { + echo "Unable to get original image"; + return; +} + +$filename = $image->getFilename(); +$container_guid = $image->container_guid; +if (!$filename || !$container_guid) { + echo "Error retrieving information about the image"; + return; +} + +$title = $image->title; +$prefix = "image/$container_guid/"; +$filestorename = substr($filename, strlen($prefix)); + +$image_lib = get_plugin_setting('image_lib', 'tidypics'); +if (!$image_lib) { + $image_lib = "GD"; +} + +if ($image_lib == 'ImageMagick') { // ImageMagick command line + + if (tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + +} else if ($image_lib == 'ImageMagickPHP') { // imagick PHP extension + + if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + +} else { + + if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + +} // end of image library selector + +echo "<img id=\"tidypics_image\" src=\"{$CONFIG->wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&size=large\" alt=\"{$title}\" />"; diff --git a/actions/admin/flickrSetup.php b/actions/admin/flickrSetup.php new file mode 100644 index 000000000..ee31b8c34 --- /dev/null +++ b/actions/admin/flickrSetup.php @@ -0,0 +1,36 @@ +<?php +/** + * Setup the user's flickr username and store it + */ +require_once dirname(dirname(__FILE__)) . "/lib/phpFlickr/phpFlickr.php"; +$f = new phpFlickr("26b2abba37182aca62fe0eb2c7782050"); + +$flickr_username = get_input( "flickr_username" ); +$album_id = get_input( "album_id" ); +$return_url = get_input( "return_url" ); +$user = get_loggedin_user(); + +if( empty( $flickr_username )) { + register_error( elgg_echo( 'flickr:enterusername' )); + forward( $return_url ); + die; //just in case +} else { + $flickr_user = $f->people_findByUsername( $flickr_username ); + if( !empty( $flickr_user["id"] )) { + create_metadata( $user->guid, "flickr_username", $flickr_username, "text", $user->guid, ACCESS_PUBLIC ); + create_metadata( $user->guid, "flickr_id", $flickr_user["id"], "text", $user->guid, ACCESS_PUBLIC ); + if( $album_id ) { + create_metadata( $user->guid, "flickr_album_id", $album_id, "text", $user->guid, ACCESS_PUBLIC ); + $album = get_entity( $album_id ); + } + + system_message( sprintf( elgg_echo( 'flickr:savedusername' ), $flickr_username )); + system_message( sprintf( elgg_echo( 'flickr:saveduserid' ), $flickr_user["id"] )); + system_message( sprintf( elgg_echo( 'flickr:savedalbum' ), $album->title )); + } else { + register_error( sprintf( elgg_echo( 'flickr:errorusername' ), $flickr_username )); + } +} + +forward($_SERVER['HTTP_REFERER']); +//echo "<pre>"; var_dump( array($flickr_username, $return_url )); echo "</pre>"; diff --git a/actions/admin/imtest.php b/actions/admin/imtest.php new file mode 100644 index 000000000..293a9b2e8 --- /dev/null +++ b/actions/admin/imtest.php @@ -0,0 +1,18 @@ +<?php +/** + * Tidypics ImageMagick Location Test + * + * Called through ajax + */ + +$location = $_GET['location']; + +$command = $location . "convert -version"; + +$result = system($command, $return_val); + +if ($return_val == 0) { + echo $result; +} else { + echo "Unable to run ImageMagick. Please check the path."; +} diff --git a/actions/admin/settings.php b/actions/admin/settings.php new file mode 100644 index 000000000..2c529d950 --- /dev/null +++ b/actions/admin/settings.php @@ -0,0 +1,77 @@ +<?php +/** + * Save settings of Tidypics + * + */ + +global $CONFIG; + +admin_gatekeeper(); +action_gatekeeper(); + + +// Params array (text boxes and drop downs) +$params = get_input('params'); +$result = false; +foreach ($params as $k => $v) { + if (!set_plugin_setting($k, $v, 'tidypics')) { + register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics')); + forward($_SERVER['HTTP_REFERER']); + } +} + +// check boxes +if (is_array(get_input('download_link'))) { // this can be done due to way Elgg uses checkboxes + set_plugin_setting('download_link', 'enabled', 'tidypics'); +} else { + set_plugin_setting('download_link', 'disabled', 'tidypics'); +} + +if (is_array(get_input('tagging'))) { + set_plugin_setting('tagging', 'enabled', 'tidypics'); +} else { + set_plugin_setting('tagging', 'disabled', 'tidypics'); +} + +if (is_array(get_input('photo_ratings'))) { + set_plugin_setting('photo_ratings', 'enabled', 'tidypics'); +} else { + set_plugin_setting('photo_ratings', 'disabled', 'tidypics'); +} + +if (is_array(get_input('exif'))) { + set_plugin_setting('exif', 'enabled', 'tidypics'); +} else { + set_plugin_setting('exif', 'disabled', 'tidypics'); +} + +if (is_array(get_input('view_count'))) { + set_plugin_setting('view_count', 'enabled', 'tidypics'); +} else { + set_plugin_setting('view_count', 'disabled', 'tidypics'); +} + +if (is_array(get_input('grp_perm_override'))) { + set_plugin_setting('grp_perm_override', 'enabled', 'tidypics'); +} else { + set_plugin_setting('grp_perm_override', 'disabled', 'tidypics'); +} + + +// image sizes +$image_sizes = array(); +$image_sizes['large_image_width'] = get_input('large_thumb_width'); +$image_sizes['large_image_height'] = get_input('large_thumb_height'); +$image_sizes['small_image_width'] = get_input('small_thumb_width'); +//$image_sizes['small_image_height'] = get_input('small_thumb_height'); +$image_sizes['small_image_height'] = get_input('small_thumb_width'); +$image_sizes['thumb_image_width'] = get_input('thumb_width'); +//$image_sizes['thumb_image_height'] = get_input('thumb_height'); +$image_sizes['thumb_image_height'] = get_input('thumb_width'); +set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics'); + + + +system_message(elgg_echo('tidypics:settings:save:ok')); + +forward($_SERVER['HTTP_REFERER']); |