Update of /cvsroot/phpwebsite-comm/modules/featuredphoto/class
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7357/class
Modified Files:
manager.php
Log Message:
Added Flickr library and settings
Index: manager.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/featuredphoto/class/manager.php,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** manager.php 8 Oct 2007 03:25:49 -0000 1.30
--- manager.php 22 Jan 2008 03:22:33 -0000 1.31
***************
*** 59,62 ****
--- 59,63 ----
PHPWS_Core::initModClass('controlpanel', 'Panel.php');
$linkBase = 'index.php?module=featuredphoto';
+
$tabs['manageBlocks'] = array ('title'=>dgettext('featuredphoto', 'Manage Photo Blocks'), 'link'=> $linkBase);
if (Current_User::allow('featuredphoto', 'edit_blocks'))
***************
*** 64,67 ****
--- 65,72 ----
$tabs['newBlock'] = array ('title'=>dgettext('featuredphoto', 'New Photo Block'), 'link'=> $linkBase);
}
+ if (Current_User::allow('featuredphoto', 'edit_settings'))
+ {
+ $tabs['editSettings'] = array ('title'=>dgettext('featuredphoto', 'Settings'), 'link'=> $linkBase);
+ }
$panel = new PHPWS_Panel('featuredphoto');
***************
*** 288,291 ****
--- 293,308 ----
/******************** END PHOTO CASES *********************/
+ /****************** BEGIN SETTINGS CASES ******************/
+
+ case 'editSettings':
+ $title = dgettext('featuredphoto', 'Settings');
+ $content = FeaturedPhoto_Manager::editSettings();
+ break;
+
+ case 'postSettings':
+ FeaturedPhoto_Manager::postSettings();
+ break;
+
+ /******************* END SETTINGS CASES *******************/
}
***************
*** 590,593 ****
--- 607,686 ----
}
+ function editSettings()
+ {
+ FeaturedPhoto_Manager::checkPermission('edit_settings');
+
+ $form = new PHPWS_Form;
+ $form->addHidden('module', 'featuredphoto');
+ $form->addHidden('action', 'postSettings');
+
+ $form->addCheck('flickr_support');
+ $form->setMatch('flickr_support', PHPWS_Settings::get('featuredphoto', 'flickr_support'));
+ $form->setLabel('flickr_support', dgettext('featuredphoto', 'Enable Flickr Support'));
+
+ $form->addText('flickr_api_key', PHPWS_Settings::get('featuredphoto', 'flickr_api_key'));
+ $form->setLabel('flickr_api_key', dgettext('featuredphoto', 'Flickr API Key'));
+ $form->setSize('flickr_api_key', 50, 200);
+
+ $form->addText('flickr_username', PHPWS_Settings::get('featuredphoto', 'flickr_username'));
+ $form->setLabel('flickr_username', dgettext('featuredphoto', 'Flickr Username'));
+ $form->setSize('flickr_username', 50, 200);
+
+ $form->addSubmit('submit', dgettext('featuredphoto', 'Update Settings'));
+
+ $template = $form->getTemplate();
+ $template['FLICKR_NOTICE'] = dgettext('featuredphoto',
+ 'This module uses the Flickr API but is not endorsed or certified by Flickr.');
+
+ return PHPWS_Template::process($template, 'featuredphoto', 'settings.tpl');
+ }
+
+ function postSettings()
+ {
+ FeaturedPhoto_Manager::checkPermission('edit_settings');
+
+ $success_msg = dgettext('featuredphoto', 'Your settings have been successfully saved.');
+ $error_saving_msg = dgettext('featuredphoto', 'Error saving the settings. Check error log for details.');
+ $error_inputs_msg = dgettext('featuredphoto', 'Please specify both API key and username.');
+ $error_flickr_msg = dgettext('featuredphoto', 'Error from Flickr. Check error log for details.');
+ $ret_msg = &$success_msg;
+
+ $api_key = trim($_POST['flickr_api_key']);
+ $username = trim($_POST['flickr_username']);
+
+ PHPWS_Settings::set('featuredphoto', 'flickr_support', 0 );
+ PHPWS_Settings::set('featuredphoto', 'flickr_api_key', $api_key );
+ PHPWS_Settings::set('featuredphoto', 'flickr_username', $username);
+
+ if (isset($_POST['flickr_support']))
+ {
+ if (!empty($api_key) && !empty($username))
+ {
+ PHPWS_Core::initModClass('featuredphoto', 'lib/Flickr.php');
+
+ $f = new PHPWS_Flickr($api_key);
+ if (!PHPWS_Error::logIfError($f->people_findByUsername($username)))
+ {
+ PHPWS_Settings::set('featuredphoto', 'flickr_support', 1);
+ }
+ else
+ {
+ $ret_msg = &$error_flickr_msg;
+ }
+ }
+ else
+ {
+ $ret_msg = &$error_inputs_msg;
+ }
+ }
+
+ if (PHPWS_Error::logIfError(PHPWS_Settings::save('featuredphoto')))
+ {
+ $ret_msg = &$error_saving_msg;
+ }
+
+ FeaturedPhoto_Manager::sendMessage($ret_msg, 'editSettings');
+ }
+
}// END CLASS FeaturedPhoto_Manager
|