]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
* Extended profile - make cloned datefields work correctly with calendar popup
authorZach Copley <zach@status.net>
Wed, 16 Mar 2011 09:41:32 +0000 (02:41 -0700)
committerZach Copley <zach@status.net>
Wed, 16 Mar 2011 09:41:32 +0000 (02:41 -0700)
* Validate URLs

plugins/ExtendedProfile/extendedprofilewidget.php
plugins/ExtendedProfile/js/profiledetail.js
plugins/ExtendedProfile/profiledetailsettingsaction.php

index 7f62d3eae40d2dc55e53a30d704082ec1bed3036..1ef6440ed69bc1d3932821eba870866b49c8efed 100644 (file)
@@ -369,6 +369,7 @@ class ExtendedProfileWidget extends Form
         );
 
         $this->out->element('div', 'label', _m('End'));
+
         $this->out->input(
             $id . '-end',
             null,
index e1b06562e03df591be8ba6ac2319adedae6f002a..99a3f78a4332536a45e82c3c5fb6b016321e45bb 100644 (file)
@@ -46,7 +46,13 @@ SN_EXTENDED.replaceIndex = function(elem, oldIndex, newIndex) {
 
 SN_EXTENDED.resetRow = function(elem) {
     $(elem).find('input, textarea').attr('value', '');
+    $(elem).find('input').removeAttr('disabled');
     $(elem).find("select option[value='office']").attr("selected", true);
+    $(elem).find("input:checkbox").attr('checked', false);
+    $(elem).find("input[name$=-start], input[name$=-end]").each(function() {
+        $(this).removeClass('hasDatepicker');
+        $(this).datepicker({ dateFormat: 'd M yy' });
+    });
 };
 
 SN_EXTENDED.addRow = function() {
@@ -118,4 +124,21 @@ $(document).ready(function() {
     $('.add_row').live('click', SN_EXTENDED.addRow);
     $('.remove_row').live('click', SN_EXTENDED.removeRow);
 
+    $('input:checkbox[name$=current]').each(function() {
+        var input = $(this).parent().siblings('input[id$=-end]');
+        if ($(this).is(':checked')) {
+            $(input).attr('disabled', 'true');
+        }
+    });
+
+    $('input:checkbox[name$=current]').live('click', function()  {
+        var input = $(this).parent().siblings('input[id$=-end]');
+        if ($(this).is(':checked')) {
+            $(input).val('');
+            $(input).attr('disabled', 'true');
+        } else {
+            $(input).removeAttr('disabled');
+        }
+    });
+
 });
index 719717e088f972b1d77f35b8dbac09d27e28d6c6..7b03f247edc24c4f2b74973c0750edced615e701 100644 (file)
@@ -262,6 +262,14 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
         $this->removeAll($user, 'website');
         $i = 0;
         foreach($sites as $site) {
+
+            if (!Validate::uri(
+                $site['value'],
+                array('allowed_schemes' => array('http', 'https')))
+            ) {
+                throw new Exception(sprintf(_m('Invalid URL: %s'), $site['value']));
+            }
+
             if (!empty($site['value'])) {
                 ++$i;
                 $this->saveField(
@@ -287,7 +295,12 @@ class ProfileDetailSettingsAction extends ProfileSettingsAction
         $expArray = array();
 
         foreach ($experiences as $exp) {
-            list($company, $current, $end, $start) = array_values($exp);
+            if (sizeof($experiences) == 4) {
+                list($company, $current, $end, $start) = array_values($exp);
+            } else {
+                $end = null;
+                list($company, $current, $start) = array_values($exp);
+            }
             if (!empty($company)) {
                 $expArray[] = array(
                     'company' => $company,