From ae9b87a7720f57c2e42fc61d207756c7d22bae8f Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 20 Feb 2013 22:06:39 -0800 Subject: [PATCH] Admin UI - Inline editing for userclasses --- e107_admin/users.php | 7 +++-- e107_handlers/form_handler.php | 49 ++++++++++++++++++++++++++---- e107_plugins/faqs/admin_config.php | 2 +- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/e107_admin/users.php b/e107_admin/users.php index c89818eaf..5c47173c8 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -213,7 +213,7 @@ class users_admin_ui extends e_admin_ui 'user_email' => array('title' => LAN_EMAIL, 'type' => 'text', 'width' => 'auto'), 'user_hideemail' => array('title' => LAN_USER_10, 'type' => 'boolean', 'width' => 'auto', 'thclass'=>'center', 'class'=>'center', 'filter'=>true, 'batch'=>true, 'readParms'=>'trueonly=1'), 'user_xup' => array('title' => 'Xup', 'type' => 'text', 'width' => 'auto'), - 'user_class' => array('title' => LAN_USER_12, 'type' => 'userclasses' , 'writeParms' => 'classlist=classes', 'filter'=>true, 'batch'=>true), + 'user_class' => array('title' => LAN_USER_12, 'type' => 'userclasses' , 'writeParms' => 'classlist=classes', 'inline'=>true, 'filter'=>true, 'batch'=>true), 'user_join' => array('title' => LAN_USER_14, 'type' => 'datestamp', 'width' => 'auto', 'writeParms'=>'readonly=1'), 'user_lastvisit' => array('title' => LAN_USER_15, 'type' => 'datestamp', 'width' => 'auto'), 'user_currentvisit' => array('title' => LAN_USER_16, 'type' => 'datestamp', 'width' => 'auto'), @@ -1975,7 +1975,7 @@ class users_admin_form_ui extends e_admin_form_ui } - + //TODO Reduce to simple edit/delete buttons only Other options included on edit page or available via inline or batch editing. function options($val, $mode) // old drop-down options. { $controller = $this->getController(); @@ -1995,8 +1995,9 @@ class users_admin_form_ui extends e_admin_form_ui - "; + if ($user_perms != "0") { // disabled user info diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index d39f62c71..596d770d6 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -313,7 +313,9 @@ class e_form $url .= "&iframe=1"; $title = "Media Manager : ".$category; - $ret = "".$label.""; + $ret = "".$label.""; // using colorbox. + // $ret = "".$label.""; // using bootstrap. + // $footer = "
Save
"; $footer = ''; @@ -662,7 +664,7 @@ class e_form //TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ? - return $this->text($name_fld,$default_name,20, "typeahead=users&readonly=".vartrue($options['readonly'])) + return $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly'])) .$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id; @@ -2180,17 +2182,52 @@ class e_form break; case 'userclass': - $value = $this->_uc->uc_get_classname($value); + $dispvalue = $this->_uc->uc_get_classname($value); + // Inline Editing. + if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up + { + $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + + $array = e107::getUserClass()->uc_required_class_list(); //XXX Ugly looking (non-standard) function naming - TODO discuss name change. + $source = str_replace('"',"'",json_encode($array)); + + //NOTE Leading ',' required on $value; so it picks up existing value. + $value = "".$dispvalue.""; + } + else + { + $value = $dispvalue; + } break; case 'userclasses': + $classes = explode(',', $value); - $value = array(); + $uv = array(); foreach ($classes as $cid) { - $value[] = $this->_uc->uc_get_classname($cid); + $uv[] = $this->_uc->uc_get_classname($cid); } - $value = implode(vartrue($parms['separator'],"
"), $value); + $dispvalue = implode(vartrue($parms['separator'],"
"), $uv); + + // Inline Editing. + if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up + { + $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + + $array = e107::getUserClass()->uc_required_class_list('classes'); //XXX Ugly looking (non-standard) function naming - TODO discuss name change. + $source = str_replace('"',"'",json_encode($array)); + + //NOTE Leading ',' required on $value; so it picks up existing value. + $value = "".$dispvalue.""; + } + else + { + $value = $dispvalue; + } + + + break; /*case 'user_name': diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index 277f56489..eb831f6bb 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -78,7 +78,7 @@ class faq_cat_ui extends e_admin_ui 'faq_info_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readParms'=>'editable=1'), 'faq_info_about' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name 'faq_info_parent' => array('title'=> LAN_CATEGORY, 'type' => 'text', 'width' => '5%'), - 'faq_info_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'), + 'faq_info_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int', 'inline'=>true), 'faq_info_order' => array('title'=> LAN_ORDER, 'type' => 'text', 'width' => '5%', 'thclass' => 'left' ), 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center','readParms'=>'sort=1') );