You are here: Home
registerFunction( 'onBeforeUserUpdate','protectFields', 'getProtectFieldsTab' ); /** * Protection Tab Class for handling the CB tab api * @package Community Builder * @author JoomlaJoe and Beat */ class getProtectFieldsTab extends cbTabHandler { /** * Constructor */ function getProtectFieldsTab() { $this->cbTabHandler(); } /** * gets object with name, title and table corresponding to a field id * @access private * @param int fieldId * @returns mixed : either object, or null if no match */ function getFieldInfo($protectFieldId) { global $database; if ($protectFieldId == "0") return null; $query = "SELECT `name`,`table`,`title`,`type` FROM #__comprofiler_fields WHERE published=1 AND fieldid=".$protectFieldId; $database->setQuery($query); $protectObj = null; $database->loadObject($protectObj); return $protectObj; } /** * Discards all changes the user makes to email field. Admins are allowed to change email addresses. * Method is called before user data is stored in the database * @access private * @param object holds the core mambo user data * @param object holds the community builder user data * @param object holds the field information * @return boolean true check ok no changes, FALSE error raised */ function checkMyFieldChanges(&$user,&$cbUser,$protectObj) { global $database, $my, $_PLUGINS; if ($protectObj === null) return true; $params = $this->params; $alertMsg = htmlspecialchars($params->get('alertMsg', '0')); $protectFieldName = $protectObj->name; $protectTable = $protectObj->table; $protectTitle = $protectObj->title; //if ($my->gid != 2) { // admins can change their profile unrestricted from the backend if ($protectTable != "#__comprofiler") { $query = "SELECT `".$database->getEscaped($protectFieldName)."` FROM #__users WHERE id=".$user->id." LIMIT 1"; $pObject =& $user; } else { $query = "SELECT `".$database->getEscaped($protectFieldName)."` FROM #__comprofiler WHERE id=".$user->id." LIMIT 1"; $pObject =& $cbUser; } $database->setQuery($query); $pOriginalField = $database->loadResult(); //The field before the change was attempted if ($pObject->$protectFieldName != $pOriginalField) { $_PLUGINS->raiseError(0); $_PLUGINS->_setErrorMSG(htmlspecialchars(getLangDefinition($protectTitle))." ".$alertMsg); $pObject->$protectFieldName = $pOriginalField; return false; } //} return true; } /** * generates javascript code to check and flag at browser end * @access private * @param object tab reflecting the tab database entry * @param object mosUser reflecting the user being displayed * @param object holds the field information */ function getEditTabJScode(&$user,$protectObj) { if ($protectObj == null) return; $params = $this->params; $alertMsg = $params->get('alertMsg', '0'); $protectFieldName = $protectObj->name; $protectTitle = $protectObj->title; $protectValue = $user->$protectFieldName; //Type matters ;) $protectType = $protectObj->type; //We need to add square brackets for accessing select, multiselect and mulitcheckbox in JS $addBrackets = ""; if($protectType == "multiselect" || $protectType == "select" || $protectType == "multicheckbox"){$addBrackets = "[]";} $this->_addValidationJS( "\t if (getInputValue(me['".htmlspecialchars($protectFieldName).$addBrackets."'])!=getInputDefaultValue(me['".htmlspecialchars($protectFieldName).$addBrackets."'])){\n" ."\t errorMSG += \"".html_entity_decode(getLangDefinition($protectTitle)." ".$alertMsg)."\\n\"\n" ."\t me['".htmlspecialchars($protectFieldName).$addBrackets."'].style.background = \"red\";\n" ."\t setInputValue(me['".htmlspecialchars($protectFieldName).$addBrackets."'],getInputDefaultValue(me['".htmlspecialchars($protectFieldName).$addBrackets."']));\n" ."\t iserror=1;\n" ."\t} else {\n" ."\t me['".htmlspecialchars($protectFieldName).$addBrackets."'].style.background = cbDefaultFieldBackground;\n" ."\t}\n"); // also see event: 'onBeforeUserUpdate' : must also be implemented as above to avoid changes with JS off. } /** * Discards all changes the user makes to email field. Admins are allowed to change email addresses. * Method is called before user data is stored in the database * @param array holds the core mambo user data * @param array holds the community builder user data */ function protectFields(&$user,&$cbUser) { $params = $this->params; $protectFieldId = $params->get('protect1', '0'); $result1 = $this->checkMyFieldChanges($user, $cbUser, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect2', '0'); $result2 = $this->checkMyFieldChanges($user, $cbUser, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect3', '0'); $result3 = $this->checkMyFieldChanges($user, $cbUser, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect4', '0'); $result4 = $this->checkMyFieldChanges($user, $cbUser, $this->getFieldInfo($protectFieldId)); return result1 && result2 && restult3 && result4; } /** * Generates the HTML to display the user edit tab * @param object tab reflecting the tab database entry * @param object mosUser reflecting the user being displayed * @param int 1 for front-end, 2 for back-end * @returns mixed : either string HTML for tab content, or false if ErrorMSG generated */ function getEditTab($tab,$user,$ui) { if ($ui == 2) return ""; // don't protect backend user edits. $params = $this->params; //Functions used in every check. So let's include them here only once. $this->_addValidationJS( "\t // ===================================================================\n" ."\t //JavaScript functions\n" ."\t // Author: Matt Kruse \n" ."\t // WWW: http://www.mattkruse.com/\n" ."\t // ===================================================================\n" ."\t //-------------------------------------------------------------------\n" ."\t // isArray(obj)\n" ."\t // Returns true if the object is an array, else false\n" ."\t //-------------------------------------------------------------------\n" ."\t function isArray(obj){return(typeof(obj.length)==\"undefined\")?false:true;}\n" ."\t //-------------------------------------------------------------------\n" ."\t // getInputValue(input_object[,delimiter])\n" ."\t // Get the value of any form input field\n" ."\t // Multiple-select fields are returned as comma-separated values, or\n" ."\t // delmited by the optional second argument\n" ."\t // (Doesn't support input types: button,file,reset,submit)\n" ."\t //-------------------------------------------------------------------\n" ."\t function getInputValue(obj,delimiter) {\n" ."\t var use_default=(arguments.length>2)?arguments[2]:false;\n" ."\t if (isArray(obj) && (typeof(obj.type)==\"undefined\")) {\n" ."\t var values=new Array();\n" ."\t for(var i=0;i0)?obj.options[obj.selectedIndex].value:null;\n" ."\t case 'select-multiple': \n" ."\t if (obj.options==null) { return null; }\n" ."\t var values=new Array();\n" ."\t for(var i=0;i1)?arguments[1]:false;\n" ."\t if(isArray(obj)&&(typeof(obj.type)==\"undefined\")){\n" ."\t for(var i=0;iget('protect1', '0'); $this->getEditTabJScode($user, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect2', '0'); $this->getEditTabJScode($user, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect3', '0'); $this->getEditTabJScode($user, $this->getFieldInfo($protectFieldId)); $protectFieldId = $params->get('protect4', '0'); $this->getEditTabJScode($user, $this->getFieldInfo($protectFieldId)); return ""; } } // end class getProtectFieldsTab. ?>registerFunction('onAfterUserApproval', 'afterApproveUser', 'subscribeMailman'); $_PLUGINS->registerFunction('onAfterNewUser', 'afterNewUser', 'subscribeMailman'); $_PLUGINS->registerFunction('onAfterDeleteUser', 'afterDeleteUser', 'subscribeMailman'); $_PLUGINS->registerFunction('onBeforeUserUpdate', 'beforeUpdateUser', 'subscribeMailman'); $_PLUGINS->registerFunction('onBeforeUpdateUser', 'beforeUpdateUser', 'subscribeMailman'); include 'Snoopy.class.php'; function plug_subscribemailman_install() { $html = ' Thank you for downloading and installing this CB plugin!

I want to pass on some credit to the team behind Snoopy, the web client class for PHP .

Remember to set the parameters and publish the plugin

'; return $html; } function plug_subscribemailman_uninstall() { return '

Thank you for trying this plugin!

'; } class subscribeMailman extends cbEventHandler { var $snoopy_instance; var $login_cookies_instance; function getSnoopy() { global $snoopy_instance; if (!isSet ($snoopy_instance)) $snoopy_instance = new Snoopy; return $snoopy_instance; } function subscribeMailman() { $this->cbEventHandler(); } function afterApproveUser($user, $approved, $succes) { if ($approved) { $this->Subscribe($user->email); } else { $this->unSubscribe($user->email); } return true; } function afterNewUser($user, $cbUser, $stored = false, $smth = true) { $this->Subscribe($user->email); return true; } function beforeUpdateUser(& $user, & $cbUser) { global $database; $query = "SELECT email, block FROM #__users WHERE id = $user->id"; $database->setQuery($query); $old_row = $database->LoadRow(); $old_email = $old_row[0]; $old_block = $old_row[1]; if ($old_email != $user->email) { $this->unSubscribe($old_email); if (! $user->block ) { $this->Subscribe($user->email); } } else if ($user->block != $old_block) { if (! $user->block ) { $this->Subscribe($user->email); } else { $this->unSubscribe($user->email); } } return true; } function afterDeleteUser($user, $store = true) { $this->unSubscribe($user->email); return true; } function mailman_login() { global $login_cookies_instance; if (!isSet ($login_cookies)) { $params = $this->params; $submit['adminpw'] = $params->get('admin_password', ''); $url = $params->get('admin_url', ''); $s = $this->getSnoopy(); $s->submit($url, $submit); while (list ($key, $val) = each($s->headers)) { list ($title, $value) = split(":", $val); if ($title == 'Set-Cookie') { $cookieList = split(';', $value); while (list ($k, $v) = each($cookieList)) { list ($cookieKey, $cookieVal) = split('=', trim($v)); $login_cookies_instance[trim($cookieKey)] = trim($cookieVal); } } } } return $login_cookies_instance; } function Subscribe($email) { $login_cookies = $this->mailman_login(); $params = $this->params; $url = $params->get('admin_url', '').'/members/add'; $postdata['subscribe_or_invite'] = $params->get('new_invite_only', '0'); $postdata['send_welcome_msg_to_this_batch'] = $params->get('new_welcome_msg', '0'); $postdata['send_notifications_to_list_owner'] = $params->get('new_send_notifications_to_list_owner', '0'); $postdata['subscribees'] = $email."\n"; $postdata['invitation'] = ""; $s = $this->getSnoopy(); $s->cookies = $login_cookies; $s->submittext($url, $postdata); } function unSubscribe($email) { $login_cookies = $this->mailman_login(); $params = $this->params; $url = $params->get('admin_url', '').'/members/remove'; $postdata['send_unsub_ack_to_this_batch'] = $params->get('delete_send_ack', '0'); $postdata['send_unsub_notifications_to_list_owner'] = $params->get('delete_send_notifications_to_list_owner', '0'); $postdata['unsubscribees'] = $email."\n"; $s = $this->getSnoopy(); $s->cookies = $login_cookies; $s->submittext($url, $postdata); } } ?>
Lost your Username or your Password ?
  • If you lost your username, please enter your E-mail Address, leaving Username field empty, then click the Send Username button, and your username will be sent to your email address.
  • If you lost your password but know your username, please enter your Username and your E-mail Address, press the Send Password button, and you will receive a new password shortly. Use this new password to access the site.
  • If you forgot both your username and your password, please recover the username first, then the password. To recover your username, please enter your E-mail Address, leaving Username field empty, then click the Send Username button, and your username will be sent to your email address. From there you can use this same form to recover your password.

Events Calendar

« < February 2018 > »
M T W T F S S
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 1 2 3 4

CB Login

Latest Events

No events