Changeset 1027192
- Timestamp:
- 11/17/2014 10:35:33 AM (11 years ago)
- Location:
- third-light-browser/trunk
- Files:
-
- 5 edited
-
includes/settings.php (modified) (13 diffs)
-
js/IMS.IframeApp.js (modified) (1 diff)
-
js/IMS.IframeAppOverlay.js (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
-
thirdlightbrowser.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
third-light-browser/trunk/includes/settings.php
r905592 r1027192 121 121 <div class="wrap"> 122 122 <?php screen_icon(); ?> 123 <h2> My Settings</h2>123 <h2>Third Light Browser Settings</h2> 124 124 125 125 <form method="post" action="options.php"> … … 151 151 ); 152 152 153 $general_settings = " general_settings";153 $general_settings = "site_settings"; 154 154 add_settings_section( 155 155 $general_settings, // ID 156 __(' GeneralSettings'), // Title157 function(){ _e(' General settings for the Third Light Browser:'); },156 __('Site Settings'), // Title 157 function(){ _e('Settings to configure the Third Light Browser to work with a Third Light IMS site.'); }, 158 158 'my-setting-admin' // Page 159 159 ); … … 166 166 'my-setting-admin', // Page 167 167 $general_settings // Section 168 ); 168 ); 169 170 $apikey = "apikey"; 171 add_settings_field( 172 $apikey, // ID 173 __('Third Light API Key'), // Title 174 $this->input_apikey_field(array(self::NAME, "global_options", $apikey)), // Callback 175 'my-setting-admin', // Page 176 $general_settings // Section 177 ); 169 178 170 179 $autoLogin = "automaticLogin"; … … 178 187 ); 179 188 189 $display_settings = "display_settings"; 190 add_settings_section( 191 $display_settings, // ID 192 __('Display Settings'), // Title 193 function(){ _e('Settings to configure the appearance of the Third Light Browser.'); }, 194 'my-setting-admin' // Page 195 ); 196 180 197 $theme = "theme"; 181 198 add_settings_field( … … 187 204 )), 188 205 'my-setting-admin', 189 $ general_settings206 $display_settings 190 207 ); 191 208 … … 199 216 )), 200 217 'my-setting-admin', 201 $ general_settings218 $display_settings 202 219 ); 203 220 … … 211 228 )), 212 229 'my-setting-admin', 213 $ general_settings230 $display_settings 214 231 ); 215 232 … … 279 296 } 280 297 298 $keyValid = false; 281 299 //if there is an apikey, is it valid. If so, set the sessionId from it. Else, complain and set sessionId to false. 282 if($global_options["automaticLogin"] !== "disabled" && !empty($global_options["apikey"])) 283 { 284 try{ 285 $imsAPI = new IMSApiClient($global_options["site"], $global_options["apikey"]); 286 $keyValid = true; 300 if(!empty($global_options["apikey"])) 301 { 302 try{ 303 $imsAPI = new IMSApiClient($global_options["site"], $global_options["apikey"]); 304 $keyValid = true; 305 $globalSFFConfig = $imsAPI->Config_CheckFeatureAvailable(array("featureKey"=> "SECURE_FILE_FETCH_PERMANENT")); 306 if(!$globalSFFConfig) 307 { 308 add_settings_error(self::NAME, null, __('The Third Light site does not have permanent Secure File Fetch enabled - this is required by the Third Light Browser.')); 309 } 310 $globalRevConfig = $imsAPI->Config_CheckFeatureAvailable(array("featureKey"=> "REVISIONS")); 311 if(!$globalRevConfig && !empty($global_options["showRevisions"])) 312 { 313 add_settings_error(self::NAME, null, __('Version control is disabled on the Third Light site.')); 314 } 287 315 } 288 316 catch(IMSApiActionException $e) { … … 295 323 add_settings_error(self::NAME, null, __('The API key could not be validated.')); 296 324 } 297 if(!$keyValid){ 298 add_settings_error(self::NAME, null, __('Automatic log in requires that the API key be configured correctly.')); 299 $global_options["automaticLogin"] = "disabled"; 300 } 301 } 302 else 303 { 304 $global_options["automaticLogin"] = "disabled"; 325 } 326 327 328 if($global_options["automaticLogin"] !== "disabled") 329 { 330 if(!$keyValid) { 331 add_settings_error("automaticLogin", null, __('Automatic log in requires that the API key be configured correctly.')); 332 $global_options["automaticLogin"] = "disabled"; 333 } 305 334 } 306 335 … … 313 342 314 343 //if we try to autologin and don't provide a userref, turn autologin off: 315 if(!$global_options["userRef"]) 316 { 344 if(($global_options["automaticLogin"] === "username") && !$global_options["userRef"]) 345 { 346 add_settings_error(self::NAME, null, __('Username for automatic login was not supplied.')); 317 347 $global_options["automaticLogin"] = "disabled"; 318 348 } … … 428 458 } 429 459 460 461 public function input_apikey_field($fieldName){ 462 return function() use ($fieldName){ 463 if(!function_exists("curl_init")) { 464 echo "<p>"._("Third Light API integration requires the cURL PHP extension, but it is not installed")."</p>"; 465 return; 466 } 467 468 echo "<p><small>"._('An optional API key for your Third Light IMS site. Supplying this enables additional authentication and metadata options.')."</small></p>"; 469 call_user_func($this->input_field_factory($fieldName, "thirdlight-apikey-field")); 470 }; 471 } 472 473 430 474 public function input_autologin_field($fieldName){ 431 475 return function() use ($fieldName){ 476 if(!function_exists("curl_init")) { 477 echo "<p>"._("Automatic login requires the cURL PHP extension, but it is not installed")."</p>"; 478 return; 479 } 432 480 433 481 //generate a standard input field: 434 482 call_user_func($this->input_dropdown_factory(array(self::NAME, "global_options", $fieldName), array( 435 "username" => __("Username"), 436 "email" => __("Email Address"), 437 "disabled" => __("No Automatic Login") 483 "username" => __("A specific username"), 484 "email" => __("A specific e-mail address"), 485 "username_dynamic" => __("The username from WordPress"), 486 "email_dynamic" => __("The e-mail address from WordPress"), 487 "disabled" => __("No automatic login") 438 488 ), "thirdlight-automaticlogin-field")); 489 490 439 491 440 492 echo '<div class="thirdlight-automaticlogin-options">'; … … 443 495 echo '<p class="thirdlight-userref-desc"></p>'; 444 496 call_user_func($this->input_field_factory(array(self::NAME, "global_options", "userRef"), "thirdlight-userref-field")); 445 446 //apikey:447 echo "<p>"._("An API key is required for automatic login:")."</p>";448 call_user_func($this->input_field_factory(array(self::NAME, "global_options", "apikey"), "thirdlight-apikey-field"));449 497 450 498 echo '</div>'; … … 464 512 switch(this.value) { 465 513 case "disabled": 514 case "username_dynamic": 515 case "email_dynamic": 466 516 $autoLoginOptions.hide(); 467 517 break; -
third-light-browser/trunk/js/IMS.IframeApp.js
r905592 r1027192 99 99 if(typeof data != "object") return; 100 100 if(typeof data.action != "string") return; 101 if(data == null) return;101 if(data === null) return; 102 102 103 103 //data is OK, let's use it: -
third-light-browser/trunk/js/IMS.IframeAppOverlay.js
r905592 r1027192 34 34 } 35 35 36 // I attach events to elements and return a func which detatches:37 function addEvent(el, evt, func){38 if(el.addEventListener) {39 el.addEventListener(evt, func, false);40 return function(){ el.removeEventListener(evt, func); }41 }42 else if(el.attachEvent) {43 evt = "on"+evt;44 el.attachEvent(evt, func);45 return function(){ el.detatchEvent(evt, func); }46 }47 }48 49 36 // I make sure that dimensions passed in are valid: 50 37 function dim(val){ 51 38 if(typeof val == "number") return val+"px"; 52 39 if(typeof val == "string") { 53 ndim = parseInt(val,10);40 var ndim = parseInt(val,10); 54 41 if(isNaN(ndim)) throw Error("IframeAppOverlay: cannot parse val "+val); 55 42 var suffix = val.match(/[0-9]+(.*)$/)[1]; … … 107 94 108 95 // I turn off scrolling on body until the function I return is executed: 109 reenableScrolling = (function(){96 var reenableScrolling = (function(){ 110 97 var body = document.getElementsByTagName("body")[0]; 111 98 var oldoverflow = body.style.overflow; -
third-light-browser/trunk/readme.txt
r905644 r1027192 3 3 Tags: Third Light Browser, image library, thirdlight, Third Light, IMS, digital asset management, DAM 4 4 Requires at least: 3.4.0 5 Tested up to: 3.96 Stable tag: 0. 0.65 Tested up to: 4.0 6 Stable tag: 0.1.0 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 == Changelog == 35 35 36 = 0.1.0 = 37 * Update for WordPress 4.0 38 * Detect insufficient PHP version at plugin activation time. 39 * Support login using user name or e-mail address from WordPress 40 * Detect sites without needed features when an API key is provided 41 36 42 = 0.0.6 = 37 43 * Minor tweaks to bring inline with WordPress submission guidelines. … … 54 60 * Initial release. 55 61 56 == Upgrade Notice ==57 58 = 0.0.5 =59 If using PHP < 5.4, you must upgrade to this version to avoid breakage. -
third-light-browser/trunk/thirdlightbrowser.php
r905594 r1027192 4 4 * Plugin URI: http://www.thirdlight.com 5 5 * Description: This plugin allows users to use a Third Light server as an image library in WordPress. 6 * Version: 0. 0.66 * Version: 0.1.0 7 7 * Author: Third Light 8 8 * Author URI: http://www.thirdlight.com … … 43 43 $options = array( 44 44 "options" => array_merge( 45 $global_options, 46 array( 45 // $global_options, 46 [], 47 array( 47 48 "metadata" => $global_options["showMetadata"] == "yes"? true : false, 48 49 "revisions" => $global_options["showRevisions"] == "yes"? true : false, … … 54 55 ); 55 56 56 //get a sessionId based on the current options to pass to the client. 57 //if this cannot be obtained, set isValid to a suitable error message. 58 $sessionId = call_user_func(function() use ($global_options, $options, &$isValid) { 59 if($global_options["automaticLogin"] == "disabled") return false; 60 61 try 62 { 63 $API = new IMSApiClient($global_options["site"], $global_options["apikey"]); 64 $userDetails = $API->Core_ImpersonateUser(array( 65 "userRef" => $global_options["userRef"], 66 "lookupType" => $global_options["automaticLogin"] 67 )); 68 } 69 catch(IMSApiActionException $e) 70 { 71 $isValid = "The automatic login name/email address provided in the Third Light Browser settings does not appear to be valid."; 57 //get a sessionId based on the current options to pass to the client. 58 //if this cannot be obtained, set isValid to a suitable error message. 59 $sessionId = call_user_func(function() use ($global_options, &$options, &$isValid) { 60 if($global_options["automaticLogin"] == "disabled") return false; 61 global $current_user; 62 $alertOnError = false; 63 try 64 { 65 switch($global_options["automaticLogin"]) 66 { 67 case "email": 68 case "username": 69 $userRef = $global_options["userRef"]; 70 $lookupType = $global_options["automaticLogin"]; 71 $alertOnError = true; 72 break; 73 case "username_dynamic": 74 if(!is_user_logged_in()) 75 { 76 return false; 77 } 78 get_currentuserinfo(); 79 $lookupType = "username"; 80 $userRef= $current_user->user_login; 81 break; 82 case "email_dynamic": 83 if(!is_user_logged_in()) 84 { 85 return false; 86 } 87 get_currentuserinfo(); 88 $lookupType = "email"; 89 $userRef= $current_user->user_email; 90 break; 91 default: 92 // Not supported type 93 $isValid = "The automatic login configuration provided in the Third Light Browser settings does not appear to be valid."; 94 return false; 95 } 96 $API = new IMSApiClient($global_options["site"], $global_options["apikey"]); 97 try 98 { 99 $userDetails = $API->Core_ImpersonateUser(array( 100 "userRef" => $userRef, 101 "lookupType" => $lookupType 102 )); 103 } 104 catch(IMSApiActionException $e) 105 { 106 if($alertOnError) 107 { 108 $isValid = "The automatic login name/email address provided in the Third Light Browser settings does not appear to be valid."; 109 } 110 else 111 { 112 $isValid = "Your account does not appear to be enabled for use with the Third Light Browser."; 113 } 114 return false; 115 } 116 } 117 catch(IMSApiActionException $e) 118 { 119 $isValid = "The Third Light Browser does not appear to be configured correctly"; 72 120 return false; 73 121 } … … 75 123 return $userDetails["sessionId"]; 76 124 }); 125 126 77 127 78 128 //if we got a sessionId, pass it to the client: … … 153 203 <?php 154 204 } 205 206 register_activation_hook(__FILE__, "activate"); 207 function activate() 208 { 209 if(version_compare(PHP_VERSION, '5.4', '<')) { 210 deactivate_plugins( basename( __FILE__ ) ); 211 wp_die('<p>The <strong>Third Light Browser</strong> plugin requires PHP 5.4 or greater.</p>','Plugin Activation Error', array( 'response'=>200, 'back_link'=>TRUE ) ); 212 } 213 global $wp_version; 214 if(version_compare( $wp_version, '3.4', '<' )) { 215 deactivate_plugins( basename( __FILE__ ) ); 216 wp_die('<p>The <strong>Third Light Browser</strong> plugin requires WordPress 3.4 or greater.</p>','Plugin Activation Error', array( 'response'=>200, 'back_link'=>TRUE ) ); 217 } 218 219 }
Note: See TracChangeset
for help on using the changeset viewer.