diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-18 23:18:43 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-18 23:18:43 +0000 |
commit | 0b5a24d7943c6f8bc275d1160f4060b337a3cf7a (patch) | |
tree | 105769cfd0c1d29c75fe368b989c5380536aa40a /mod | |
parent | 09d08af9814a4edfb2050cdb47ad8ae20a944472 (diff) | |
download | elgg-0b5a24d7943c6f8bc275d1160f4060b337a3cf7a.tar.gz elgg-0b5a24d7943c6f8bc275d1160f4060b337a3cf7a.tar.bz2 |
continuing to slash and burn the profile plugin - moving the admin profile fields into core - last major change
git-svn-id: http://code.elgg.org/elgg/trunk@7673 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/profile/actions/deletedefaultprofileitem.php | 29 | ||||
-rw-r--r-- | mod/profile/actions/editdefault.php | 38 | ||||
-rw-r--r-- | mod/profile/actions/editfield.php | 15 | ||||
-rw-r--r-- | mod/profile/actions/reorder.php | 12 | ||||
-rw-r--r-- | mod/profile/actions/resetdefaultprofile.php | 22 | ||||
-rw-r--r-- | mod/profile/start.php | 15 | ||||
-rw-r--r-- | mod/profile/vendor/jquery.jeditable.mini.js | 38 | ||||
-rw-r--r-- | mod/profile/views/default/admin/appearance/defaultprofile.php | 47 | ||||
-rw-r--r-- | mod/profile/views/default/profile/edit.php | 80 | ||||
-rw-r--r-- | mod/profile/views/default/profile/editdefaultprofile.php | 29 | ||||
-rw-r--r-- | mod/profile/views/default/profile/editdefaultprofileitems.php | 65 |
11 files changed, 0 insertions, 390 deletions
diff --git a/mod/profile/actions/deletedefaultprofileitem.php b/mod/profile/actions/deletedefaultprofileitem.php deleted file mode 100644 index 6791d2c46..000000000 --- a/mod/profile/actions/deletedefaultprofileitem.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Elgg profile plugin edit default profile action removal - * - * @package ElggProfile - */ - -global $CONFIG; - -$id = get_input('id'); - -$fieldlist = get_plugin_setting('user_defined_fields', 'profile'); -if (!$fieldlist) { - $fieldlist = ''; -} - -$fieldlist = str_replace("{$id},", "", $fieldlist); -$fieldlist = str_replace(",{$id}", "", $fieldlist); -$fieldlist = str_replace("{$id}", "", $fieldlist); - -if (($id) && (set_plugin_setting("admin_defined_profile_$id", '', 'profile')) && - (set_plugin_setting("admin_defined_profile_type_$id", '', 'profile')) && - set_plugin_setting('user_defined_fields',$fieldlist,'profile')) { - system_message(elgg_echo('profile:editdefault:delete:success')); -} else { - register_error(elgg_echo('profile:editdefault:delete:fail')); -} - -forward(REFERER);
\ No newline at end of file diff --git a/mod/profile/actions/editdefault.php b/mod/profile/actions/editdefault.php deleted file mode 100644 index 96e878402..000000000 --- a/mod/profile/actions/editdefault.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php -/** - * Elgg profile plugin edit default profile action - * - * @package ElggProfile - */ - -global $CONFIG; - -$label = sanitise_string(get_input('label')); -$type = sanitise_string(get_input('type')); - -$fieldlist = get_plugin_setting('user_defined_fields', 'profile'); -if (!$fieldlist) { - $fieldlist = ''; -} - -if (($label) && ($type)){ - // Assign a random name - $n = md5(time().rand(0,9999)); - - if (!empty($fieldlist)) { - $fieldlist .= ','; - } - $fieldlist .= $n; - - if ((set_plugin_setting("admin_defined_profile_$n", $label, 'profile')) && - (set_plugin_setting("admin_defined_profile_type_$n", $type, 'profile')) && - set_plugin_setting('user_defined_fields',$fieldlist,'profile')) { - system_message(elgg_echo('profile:editdefault:success')); - } else { - register_error(elgg_echo('profile:editdefault:fail')); - } -} else { - register_error(elgg_echo('profile:editdefault:fail')); -} - -forward(REFERER);
\ No newline at end of file diff --git a/mod/profile/actions/editfield.php b/mod/profile/actions/editfield.php deleted file mode 100644 index b3bd887ef..000000000 --- a/mod/profile/actions/editfield.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Elgg profile plugin edit default profile action - * - * @package ElggProfile - */ - -$field = get_input('field'); -$text = get_input('value'); - -set_plugin_setting("admin_defined_profile_{$field}",$text,'profile'); - -echo $text; - -exit;
\ No newline at end of file diff --git a/mod/profile/actions/reorder.php b/mod/profile/actions/reorder.php deleted file mode 100644 index a30e97bac..000000000 --- a/mod/profile/actions/reorder.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php -/** - * Elgg profile plugin reorder fields - * - * @package ElggProfile - */ - -$ordering = get_input('fieldorder'); -//if (!empty($ordering)) -$result = set_plugin_setting('user_defined_fields',$ordering,'profile'); - -exit;
\ No newline at end of file diff --git a/mod/profile/actions/resetdefaultprofile.php b/mod/profile/actions/resetdefaultprofile.php deleted file mode 100644 index 3ada044e8..000000000 --- a/mod/profile/actions/resetdefaultprofile.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * Elgg profile plugin edit default profile action - * - * @package ElggProfile - */ - -global $CONFIG; - -if ($fieldlist = get_plugin_setting('user_defined_fields', 'profile')) { - $fieldlistarray = explode(',', $fieldlist); - foreach($fieldlistarray as $listitem) { - set_plugin_setting("admin_defined_profile_{$listitem}", '', 'profile'); - set_plugin_setting("admin_defined_profile_type_{$listitem}", '', 'profile'); - } -} - -set_plugin_setting('user_defined_fields', FALSE, 'profile'); - -system_message(elgg_echo('profile:defaultprofile:reset')); - -forward(REFERER);
\ No newline at end of file diff --git a/mod/profile/start.php b/mod/profile/start.php index 8ae16cfb5..eb34bf748 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -47,9 +47,6 @@ function profile_init() { // allow ECML in parts of the profile elgg_register_plugin_hook_handler('get_views', 'ecml', 'profile_ecml_views_hook'); - - // default profile fields admin item - elgg_add_admin_submenu_item('defaultprofile', elgg_echo('profile:edit:default'), 'appearance'); } /** @@ -137,18 +134,6 @@ function profile_page_handler($page) { case 'edit': require $CONFIG->path . 'pages/profile/edit.php'; return; - /* - $layout = 'one_column_with_sidebar'; - - if (!$user || !$user->canEdit()) { - register_error(elgg_echo("profile:noaccess")); - forward(); - } - - $content = profile_get_user_edit_content($user, $page); - $content = elgg_view_layout($layout, array('content' => $content)); - * - */ break; default: diff --git a/mod/profile/vendor/jquery.jeditable.mini.js b/mod/profile/vendor/jquery.jeditable.mini.js deleted file mode 100644 index 6c867383a..000000000 --- a/mod/profile/vendor/jquery.jeditable.mini.js +++ /dev/null @@ -1,38 +0,0 @@ -// http://www.appelsiini.net/projects/jeditable -(function($){$.fn.editable=function(target,options){if('disable'==target){$(this).data('disabled.editable',true);return;} -if('enable'==target){$(this).data('disabled.editable',false);return;} -if('destroy'==target){$(this).unbind($(this).data('event.editable')).removeData('disabled.editable').removeData('event.editable');return;} -var settings=$.extend({},$.fn.editable.defaults,{target:target},options);var plugin=$.editable.types[settings.type].plugin||function(){};var submit=$.editable.types[settings.type].submit||function(){};var buttons=$.editable.types[settings.type].buttons||$.editable.types['defaults'].buttons;var content=$.editable.types[settings.type].content||$.editable.types['defaults'].content;var element=$.editable.types[settings.type].element||$.editable.types['defaults'].element;var reset=$.editable.types[settings.type].reset||$.editable.types['defaults'].reset;var callback=settings.callback||function(){};var onedit=settings.onedit||function(){};var onsubmit=settings.onsubmit||function(){};var onreset=settings.onreset||function(){};var onerror=settings.onerror||reset;if(settings.tooltip){$(this).attr('title',settings.tooltip);} -settings.autowidth='auto'==settings.width;settings.autoheight='auto'==settings.height;return this.each(function(){var self=this;var savedwidth=$(self).width();var savedheight=$(self).height();$(this).data('event.editable',settings.event);if(!$.trim($(this).html())){$(this).html(settings.placeholder);} -$(this).bind(settings.event,function(e){if(true===$(this).data('disabled.editable')){return;} -if(self.editing){return;} -if(false===onedit.apply(this,[settings,self])){return;} -e.preventDefault();e.stopPropagation();if(settings.tooltip){$(self).removeAttr('title');} -if(0==$(self).width()){settings.width=savedwidth;settings.height=savedheight;}else{if(settings.width!='none'){settings.width=settings.autowidth?$(self).width():settings.width;} -if(settings.height!='none'){settings.height=settings.autoheight?$(self).height():settings.height;}} -if($(this).html().toLowerCase().replace(/(;|")/g,'')==settings.placeholder.toLowerCase().replace(/(;|")/g,'')){$(this).html('');} -self.editing=true;self.revert=$(self).html();$(self).html('');var form=$('<form />');if(settings.cssclass){if('inherit'==settings.cssclass){form.attr('class',$(self).attr('class'));}else{form.attr('class',settings.cssclass);}} -if(settings.style){if('inherit'==settings.style){form.attr('style',$(self).attr('style'));form.css('display',$(self).css('display'));}else{form.attr('style',settings.style);}} -var input=element.apply(form,[settings,self]);var input_content;if(settings.loadurl){var t=setTimeout(function(){input.disabled=true;content.apply(form,[settings.loadtext,settings,self]);},100);var loaddata={};loaddata[settings.id]=self.id;if($.isFunction(settings.loaddata)){$.extend(loaddata,settings.loaddata.apply(self,[self.revert,settings]));}else{$.extend(loaddata,settings.loaddata);} -$.ajax({type:settings.loadtype,url:settings.loadurl,data:loaddata,async:false,success:function(result){window.clearTimeout(t);input_content=result;input.disabled=false;}});}else if(settings.data){input_content=settings.data;if($.isFunction(settings.data)){input_content=settings.data.apply(self,[self.revert,settings]);}}else{input_content=self.revert;} -content.apply(form,[input_content,settings,self]);input.attr('name',settings.name);buttons.apply(form,[settings,self]);$(self).append(form);plugin.apply(form,[settings,self]);$(':input:visible:enabled:first',form).focus();if(settings.select){input.select();} -input.keydown(function(e){if(e.keyCode==27){e.preventDefault();reset.apply(form,[settings,self]);}});var t;if('cancel'==settings.onblur){input.blur(function(e){t=setTimeout(function(){reset.apply(form,[settings,self]);},500);});}else if('submit'==settings.onblur){input.blur(function(e){t=setTimeout(function(){form.submit();},200);});}else if($.isFunction(settings.onblur)){input.blur(function(e){settings.onblur.apply(self,[input.val(),settings]);});}else{input.blur(function(e){});} -form.submit(function(e){if(t){clearTimeout(t);} -e.preventDefault();if(false!==onsubmit.apply(form,[settings,self])){if(false!==submit.apply(form,[settings,self])){if($.isFunction(settings.target)){var str=settings.target.apply(self,[input.val(),settings]);$(self).html(str);self.editing=false;callback.apply(self,[self.innerHTML,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}}else{var submitdata={};submitdata[settings.name]=input.val();submitdata[settings.id]=self.id;if($.isFunction(settings.submitdata)){$.extend(submitdata,settings.submitdata.apply(self,[self.revert,settings]));}else{$.extend(submitdata,settings.submitdata);} -if('PUT'==settings.method){submitdata['_method']='put';} -$(self).html(settings.indicator);var ajaxoptions={type:'POST',data:submitdata,dataType:'html',url:settings.target,success:function(result,status){if(ajaxoptions.dataType=='html'){$(self).html(result);} -self.editing=false;callback.apply(self,[result,settings]);if(!$.trim($(self).html())){$(self).html(settings.placeholder);}},error:function(xhr,status,error){onerror.apply(form,[settings,self,xhr]);}};$.extend(ajaxoptions,settings.ajaxoptions);$.ajax(ajaxoptions);}}} -$(self).attr('title',settings.tooltip);return false;});});this.reset=function(form){if(this.editing){if(false!==onreset.apply(form,[settings,self])){$(self).html(self.revert);self.editing=false;if(!$.trim($(self).html())){$(self).html(settings.placeholder);} -if(settings.tooltip){$(self).attr('title',settings.tooltip);}}}};});};$.editable={types:{defaults:{element:function(settings,original){var input=$('<input type="hidden"></input>');$(this).append(input);return(input);},content:function(string,settings,original){$(':input:first',this).val(string);},reset:function(settings,original){original.reset(this);},buttons:function(settings,original){var form=this;if(settings.submit){if(settings.submit.match(/>$/)){var submit=$(settings.submit).click(function(){if(submit.attr("type")!="submit"){form.submit();}});}else{var submit=$('<button type="submit" />');submit.html(settings.submit);} -$(this).append(submit);} -if(settings.cancel){if(settings.cancel.match(/>$/)){var cancel=$(settings.cancel);}else{var cancel=$('<button type="cancel" />');cancel.html(settings.cancel);} -$(this).append(cancel);$(cancel).click(function(event){if($.isFunction($.editable.types[settings.type].reset)){var reset=$.editable.types[settings.type].reset;}else{var reset=$.editable.types['defaults'].reset;} -reset.apply(form,[settings,original]);return false;});}}},text:{element:function(settings,original){var input=$('<input />');if(settings.width!='none'){input.width(settings.width);} -if(settings.height!='none'){input.height(settings.height);} -input.attr('autocomplete','off');$(this).append(input);return(input);}},textarea:{element:function(settings,original){var textarea=$('<textarea />');if(settings.rows){textarea.attr('rows',settings.rows);}else if(settings.height!="none"){textarea.height(settings.height);} -if(settings.cols){textarea.attr('cols',settings.cols);}else if(settings.width!="none"){textarea.width(settings.width);} -$(this).append(textarea);return(textarea);}},select:{element:function(settings,original){var select=$('<select />');$(this).append(select);return(select);},content:function(data,settings,original){if(String==data.constructor){eval('var json = '+data);}else{var json=data;} -for(var key in json){if(!json.hasOwnProperty(key)){continue;} -if('selected'==key){continue;} -var option=$('<option />').val(key).append(json[key]);$('select',this).append(option);} -$('select',this).children().each(function(){if($(this).val()==json['selected']||$(this).text()==$.trim(original.revert)){$(this).attr('selected','selected');}});}}},addInputType:function(name,input){$.editable.types[name]=input;}};$.fn.editable.defaults={name:'value',id:'id',type:'text',width:'auto',height:'auto',event:'click.editable',onblur:'cancel',loadtype:'GET',loadtext:'Loading...',placeholder:'Click to edit',loaddata:{},submitdata:{},ajaxoptions:{}};})(jQuery); diff --git a/mod/profile/views/default/admin/appearance/defaultprofile.php b/mod/profile/views/default/admin/appearance/defaultprofile.php deleted file mode 100644 index b63525bf1..000000000 --- a/mod/profile/views/default/admin/appearance/defaultprofile.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * Elgg profile - Admin area: edit default profile fields - * - * @package ElggProfile - */ - -$title = elgg_view_title(elgg_echo('profile:edit:default')); -$form = elgg_view('profile/editdefaultprofile'); - -// List form elements -$n = 0; -$loaded_defaults = array(); -$items = array(); -if ($fieldlist = get_plugin_setting('user_defined_fields', 'profile')) { - $fieldlistarray = explode(',', $fieldlist); - foreach($fieldlistarray as $listitem) { - if ($translation = get_plugin_setting("admin_defined_profile_{$listitem}", 'profile')) { - $item = new stdClass; - $item->translation = $translation; - $item->shortname = $listitem; - $item->name = "admin_defined_profile_{$listitem}"; - $item->type = get_plugin_setting("admin_defined_profile_type_{$listitem}", 'profile'); - $items[] = $item; - } - } -} - -$listing = elgg_view('profile/editdefaultprofileitems',array('items' => $items, 'fieldlist' => $fieldlist)); - -$resetlisting = elgg_view('input/form', - array ( - 'body' => elgg_view('input/submit', array('value' => elgg_echo('profile:resetdefault'), 'class' => 'action-button disabled')), - 'action' => 'action/profile/editdefault/reset' - ) - ); - -$body = <<<__HTML -$title -$form -$listing -<div class="default_profile_reset"> - $resetlisting -</div> -__HTML; - -echo $body; diff --git a/mod/profile/views/default/profile/edit.php b/mod/profile/views/default/profile/edit.php deleted file mode 100644 index 2e3ec24a4..000000000 --- a/mod/profile/views/default/profile/edit.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php -/** - * Elgg profile edit form - * - * @package ElggProfile - * - * @uses $vars['entity'] The user entity - * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now - */ -?> -<form action="<?php echo elgg_get_site_url(); ?>action/profile/edit" method="post" id="edit_profile" class="margin-top"> -<?php echo elgg_view('input/securitytoken') ?> - - <p><label> - <?php echo elgg_echo('user:name:label'); ?></label> - <?php - echo elgg_view('input/text',array('internalname' => 'name', 'value' => elgg_get_page_owner()->name)); - ?> - </p> - -<?php - if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) - foreach($vars['config']->profile as $shortname => $valtype) { - if ($metadata = get_metadata_byname($vars['entity']->guid, $shortname)) { - if (is_array($metadata)) { - $value = ''; - foreach($metadata as $md) { - if (!empty($value)) $value .= ', '; - $value .= $md->value; - $access_id = $md->access_id; - } - } else { - $value = $metadata->value; - $access_id = $metadata->access_id; - } - } else { - $value = ''; - $access_id = ACCESS_DEFAULT; - } - - if ($shortname == 'description') { // change label positioning to allow for additional longtext field controls -?> - <p> - <label> - <?php echo elgg_echo("profile:{$shortname}") ?></label> - <?php echo elgg_view("input/{$valtype}",array( - 'internalname' => $shortname, - 'value' => $value, - )); ?> - - <?php echo elgg_view('input/access',array('internalname' => 'accesslevel['.$shortname.']', 'value' => $access_id)); ?> - </p> -<?php - } else { -?> - - <p> - <label> - <?php echo elgg_echo("profile:{$shortname}") ?><br /> - <?php echo elgg_view("input/{$valtype}",array( - 'internalname' => $shortname, - 'value' => $value, - )); ?> - </label> - <?php echo elgg_view('input/access',array('internalname' => 'accesslevel['.$shortname.']', 'value' => $access_id)); ?> - </p> - -<?php - } - - } - -?> - - <p> - <input type="hidden" name="username" value="<?php echo elgg_get_page_owner()->username; ?>" /> - <input type="submit" class="submit-button" value="<?php echo elgg_echo("save"); ?>" /> - </p> - -</form>
\ No newline at end of file diff --git a/mod/profile/views/default/profile/editdefaultprofile.php b/mod/profile/views/default/profile/editdefaultprofile.php deleted file mode 100644 index 7d701af11..000000000 --- a/mod/profile/views/default/profile/editdefaultprofile.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Elgg profile index - * - * @package ElggProfile - */ - -$label_text = elgg_echo('profile:label'); -$type_text = elgg_echo('profile:type'); - -$label_control = elgg_view('input/text', array('internalname' => 'label')); -$type_control = elgg_view('input/pulldown', array('internalname' => 'type', 'options_values' => array( - 'text' => elgg_echo('text'), - 'longtext' => elgg_echo('longtext'), - 'tags' => elgg_echo('tags'), - 'url' => elgg_echo('url'), - 'email' => elgg_echo('email') -))); - -$submit_control = elgg_view('input/submit', array('internalname' => elgg_echo('add'), 'value' => elgg_echo('add'))); - -$formbody = <<< END - <p>$label_text: $label_control - $type_text: $type_control - $submit_control</p> -END; - -echo "<p class='margin-top'>" . elgg_echo('profile:explainchangefields') . "</p>"; -echo elgg_view('input/form', array('body' => $formbody, 'action' => 'action/profile/editdefault')); diff --git a/mod/profile/views/default/profile/editdefaultprofileitems.php b/mod/profile/views/default/profile/editdefaultprofileitems.php deleted file mode 100644 index 29ce7f138..000000000 --- a/mod/profile/views/default/profile/editdefaultprofileitems.php +++ /dev/null @@ -1,65 +0,0 @@ -<script language="javascript" type="text/javascript" src="<?php echo elgg_get_site_url()?>mod/profile/vendor/jquery.jeditable.mini.js"></script> -<script language="javascript" type="text/javascript"> -var reorderURL = '<?php echo elgg_add_action_tokens_to_url(elgg_get_site_url() . 'action/profile/editdefault/reorder', FALSE); ?>'; -function sortCallback(event, ui) { - var orderArr = $('#sortable_profile_fields').sortable('toArray'); - var orderStr = orderArr.join(','); - jQuery.post(reorderURL, {'fieldorder': orderStr}); -} - -$(document).ready(function() { - $('#sortable_profile_fields').sortable({ - items: 'li', - handle: '.handle', - stop: sortCallback - }); -}); - -</script> - -<div id="list"> - <ul id="sortable_profile_fields"> -<?php - - $save = elgg_echo('save'); - $cancel = elgg_echo('cancel'); - $edit_url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/editdefault/editfield", FALSE); - - foreach($vars['items'] as $item) { - echo <<< END - -<script language="javascript" type="text/javascript"> - - $(function() { - $(".{$item->shortname}_editable").editable("$edit_url ", { - type : 'text', - submitdata: { _method: "post", 'field': '{$item->shortname}' }, - onblur: 'submit', - width:'300px', - height:'none', - style:'display:inline;', - tooltip:'Click to edit label' - }); - }); - -</script> - -END; - - echo elgg_view("profile/", array('value' => $item->translation)); - - //$even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even'; - $url = elgg_add_action_tokens_to_url(elgg_get_site_url()."action/profile/editdefault/delete?id={$item->shortname}"); - echo "<li id=\"{$item->shortname}\"><div class='delete-button'><a href=\"$url\">" . elgg_echo('delete') . "</a></div>"; - echo "<img width='16' height='16' class='handle' alt='move' title='Drag here to reorder this item' src='".elgg_get_site_url()."mod/profile/graphics/drag-handle.png'/>"; - echo "<b class=\"profile_field_editable\"><span class=\"{$item->shortname}_editable\">$item->translation</span></b>: [".elgg_echo($item->type)."]"; - echo "</li>"; - - } - -?> - </ul> -</div> -<div id="tempList"></div> - -<input name="sortableListOrder" type="hidden" id="sortableListOrder" value="<?php echo $vars['fieldlist']; ?>" /> |