/etc/horde/ansel/hooks.php.dist is in php-horde-ansel 3.0.5+debian0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | <?php
/**
* Ansel Hooks configuration file.
*
* THE HOOKS PROVIDED IN THIS FILE ARE EXAMPLES ONLY. DO NOT ENABLE THEM
* BLINDLY IF YOU DO NOT KNOW WHAT YOU ARE DOING. YOU HAVE TO CUSTOMIZE THEM
* TO MATCH YOUR SPECIFIC NEEDS AND SYSTEM ENVIRONMENT.
*/
class Ansel_Hooks
{
/**
* Here is an example _ansel_hook_user_age(). is called to get the user age
* when he/she tries to view an age limited content. This function must
* return an integer value of user age
*/
// public function user_age()
// {
// $query = 'SELECT age FROM user WHERE user_uid = ' . $GLOBALS['ansel_db']->quote($GLOBALS['registry']->getAuth());
// try {
// return (int)$GLOBALS['ansel_db']->queryOne($query);
// } catch (Ansel_Exception $e) {
// return 0;
// }
// }
/**
* Example hook for sending a stream notification to facebook after a user
* uploads images to Ansel. This will likely go away, being replaced by
* by an remote image import/export functionality.
*/
// public function postupload($image_ids)
// {
// $context = array('http_client' => new Horde_Http_Client(),
// 'http_request' => new Horde_Controller_Request_Http(),);
// $facebook = new Horde_Service_Facebook($GLOBALS['conf']['facebook']['key'],
// $GLOBALS['conf']['facebook']['secret'],
// $context);
// $fbp = unserialize($GLOBALS['prefs']->getValue('facebook'));
//
// // If no prefs exist just exit since there's nowhere to publish to.
// if (empty($fbp['sid'])) {
// return;
// } else {
// $facebook->auth->setUser($fbp['uid'], $fbp['sid'], 0);
// }
// // Limit of the number of images to include. This should really come
// // from a configuration parameter or at the very least, a user pref.
// // (5 is the facebook api's max)
// $limit = min(5, (count($image_ids)));
// $images = $GLOBALS['ansel_storage']->getImages(array_slice($image_ids, 0, $limit));
// $perms = array();
// $media = array();
// foreach ($images as $image) {
// // Only the gallery owner should be able to publish news about the
// // gallery, and only public galleries with no passwd or age checks
// // should be considered as well since the links on facebook would
// // be useless.
// if (!isset($perms[$image->gallery])) {
// $g = $GLOBALS['ansel_storage']->getGallery($image->gallery);
// $pwd = $g->get('passwd');
// $no_agelimit = empty($GLOBALS['conf']['ages']['limits']) || $g->get('age') == 0;
// if ($GLOBALS['registry']->getAuth() && $g->get('owner') == $GLOBALS['registry']->getAuth() && empty($pwd) && $no_agelimit) {
// $perms[$image->gallery] = true;
// } else {
// $perms[$image->gallery] = false;
// }
// }
// if ($perms[$image->gallery]) {
// $media[] = array('type' => 'image',
// 'href' => Ansel::getUrlFor('view',array('view' => 'Image', 'image' => $image->id, 'gallery' => $image->gallery), true, -1),
// 'src' => Ansel::getImageUrl($image->id, 'thumb', true));
//
// }
// }
// // For this example, just use the last image's gallery title and description
// $attachment = array('name' => $g->get('name'), 'caption' => $g->get('description'), 'media' => $media);
//
// //Do it.
// try {
// $facebook->streams->publish(sprintf("just uploaded these pictures to %s", $GLOBALS['registry']->get('name')), $attachment);
// } catch (Horde_Service_Facebook_Exception $e) {
// // For now, just pass back as a pear error...needs to be cleaned up
// $GLOBALS['notification']->push('Horde_Service_Facebook: ' . $e->getMessage(), 'horde.err');
// throw new Horde_Exception_Wrapped($e);
// }
// if (!empty($GLOBALS['notification'])) {
// $GLOBALS['notification']->push('Notification published to Facebook.', 'horde.success');
// }
// }
}
|