return; } $filespec = stripslashes($filespec); $filespec = unserialize($filespec); } $cfef = EasyContactFormsClassLoader::getObject('CustomFormEntryFiles', true); $cfef->set('CustomFormsEntries', $cfe->get('id')); $cfef->set('Description', $fld->get('Description')); $cfef->set('Date', date(DATE_ATOM)); $cfef->save(); $rmap = array(); $rmap['t'] = 'CustomFormEntryFiles'; $rmap['oid'] = $cfef->get('id'); $rmap['fld'] = 'File'; $rmap['protect'] = 'on'; $files = EasyContactFormsClassLoader::getObject('Files'); $uplresult = $files->protectedUpload($rmap, $filespec); if (!$uplresult) { return; } $filename = $filespec['name']; $filename = EasyContactFormsUtils::addMSlashes($filename); $value = $filename; $open = (string) $xml->OnlyAdminsCanDownload != 'on'; $link = $files->getFileDownloadLink($rmap['t'], $rmap['fld'], $rmap['oid'], $open); $displayvalue = "<a href='{$link}'>{$filename}</a>"; $displayxmlvalue = simplexml_load_string("<a>{$filename}</a>"); $displayxmlvalue->addAttribute('href', $link); $attachConfirmation = isset($xml->AttachToConfirmation) && $xml->AttachToConfirmation == 'on'; $attachNotification = isset($xml->AttachToNotification) && $xml->AttachToNotification == 'on'; if ($attachConfirmation || $attachNotification) {
/** * Displays a EasyContactFormsCustomFormsEntries main view record * * @param object $view * the EasyContactFormsCustomFormsEntries main view object * @param object $obj * a db object * @param int $i * record index * @param array $map * request data */ function getCustomFormsEntriesMainViewRow($view, $obj, $i, $map) { $usrname = EasyContactFormsDB::getValue("SELECT display_name FROM #wp__users WHERE ID = '" . $obj->get('SiteUser') . "'"); if ($usrname) { $obj->SiteUser = $usrname; } else { $obj->SiteUser = '******'; } ?> <tr class='ufohighlight <?php EasyContactFormsIHTML::getTrSwapClassName($i); ?> '> <td class='firstcolumn'> <input type='checkbox' id='<?php echo $view->idJoin('cb', $obj->getId()); ?> ' value='off' class='ufo-deletecb' onchange='this.value=(this.checked)?"on":"off";'> </td> <td> <?php $usr = $obj->get('Users'); if (empty($usr)) { $cff = EasyContactFormsClassLoader::getObject('CustomFormFields'); $cff->getSettingsFormButton('entry-add', EasyContactFormsT::get('CF_ProcessEntry'), "onclick='ufoCf.processEntry(" . $obj->get('id') . ", " . $view->jsconfig . ");'", 'icon_button_add'); } ?> </td> <td> <a onclick='ufo.redirect({m:"show", oid:"<?php echo $obj->get('id'); ?> ", t:"CustomFormsEntries"})' onmouseover='ufo.showInfo({t:"CustomFormsEntries", m2:"getASList", oid:<?php echo $obj->get('id'); ?> , m:"ajaxsuggest"}, this)'> <?php EasyContactFormsIHTML::echoStr($obj->get('id')); ?> </a> </td> <td> <?php EasyContactFormsIHTML::echoDate($obj->get('Date'), EasyContactFormsApplicationSettings::getInstance()->getDateFormat('PHP', TRUE), 0); ?> </td> <td> <a onclick='ufo.redirect({m:"show", oid:"<?php echo $obj->get('CustomForms'); ?> ", t:"CustomForms"})'> <?php echo $obj->get('CustomFormsDescription'); ?> </a> </td> <td> <?php echo $obj->get('PageName'); ?> </td> <td> <a onclick='ufo.redirect({m:"show", oid:"<?php echo $obj->get('Users'); ?> ", t:"Users"})'> <?php echo $obj->get('UsersDescription'); ?> </a> </td> <td> <?php echo $obj->SiteUser; ?> </td> </tr> <?php }
/** * ajaxSuggest * * provides a json-encoded filtered list to show on the client side * * @param array $_asmap * request data * * @return string * the json-encoded array */ function ajaxSuggest($_asmap) { if (!EasyContactFormsSecurityManager::roleObjectCheck($_asmap)) { $_asresponse = array(); $_asresponse['info'] = EasyContactFormsT::get('YouAreNotLoggedIn'); $_asresponsearray = array(); $_asresponsearray[] = $_asresponse; return EasyContactFormsRoot::ajaxSuggestResponse((object) $_asresponsearray); } $_asmethod = $_asmap['m2']; $_astype = $_asmap['t']; $_asobject = EasyContactFormsClassLoader::getObject($_astype); $_suggestionArray = $_asobject->{$_asmethod}($_asmap); EasyContactFormsRoot::ajaxSuggestResponse($_suggestionArray); }
/** * val * * @param $map * * * @return * */ function val($map) { foreach ($map as $key => $value) { if (!EasyContactFormsUtils::beginsWith($key, 'id-')) { continue; } $names = explode('-', $key); $fldid = intval($names[1]); if ($fldid == 0) { continue; } $fld = EasyContactFormsClassLoader::getObject('CustomFormFields', true, $fldid); if (!$fld) { continue; } $phase = (object) array('index' => 4); include $fld->getTMPFileName('proc'); } }
/** * getMTMFilter * * peforms many-to-many table filterfing * * @param array $map * request data * @param array $filters * filter list * @param string $alias * object alias to use when preparing filter statements * * @return array * an array containig mtm filters */ function getMTMFilter($map, $filters, $alias) { if (!isset($map['a'])) { return $filters; } $jsparams = json_decode(stripslashes($map['a'])); if ($jsparams->m != 'mtmview') { return $filters; } foreach ($jsparams->ca as $obj) { $mobj = EasyContactFormsClassLoader::getObject($obj->mt); $tablename = $mobj->getTableName(); $fields = $mobj->getFieldNames(); if (!in_array($obj->n, $fields)) { continue; } if (!in_array($obj->fld, $fields)) { continue; } $objid = intval($obj->oid); if (!isset($filters['fnames'])) { $filters['fnames'] = array(); } $filters['fnames'][] = $alias . '.id NOT IN (SELECT ' . $obj->n . ' FROM ' . $tablename . " WHERE {$obj->fld} = '{$objid}')"; } return $filters; }
/** * updateOrder * * @param $map * * * @return * */ function updateOrder($map) { $input = $map['a']; $input = explode(':', $input); $fsid = $input[0]; $fsid = explode('-', $fsid); $fsid = $fsid[count($fsid) - 1]; $fsid = intval($fsid); if ($fsid == 0) { return; } $input = explode('&', $input[1]); $ids = array(); foreach ($input as $items) { $items = explode('[]=', $items); $id = $items[1]; $ids[] = intval($id); } $sqlids = implode(',', $ids); $query = "SELECT\n\t\t\t\tCustomFormFields.id,\n\t\t\t\tCustomFormFields.CustomForms,\n\t\t\t\tCustomFormFields.ListPosition AS ListPosition\n\t\t\tFROM\n\t\t\t\t#wp__easycontactforms_customformfields AS CustomFormFields\n\t\t\tWHERE\n\t\t\t\tCustomFormFields.id IN (%s)\n\t\t\tORDER BY\n\t\t\t\tListPosition"; $query = sprintf($query, $sqlids); $objects = EasyContactFormsDB::getObjects($query); $lp = array(); for ($i = 0; $i < count($ids); $i++) { $lp[$ids[$i]] = $objects[$i]->ListPosition; $cf = $objects[$i]->CustomForms; } if (!isset($cf)) { return; } $cff = EasyContactFormsClassLoader::getObject('CustomFormFields'); foreach ($lp as $id => $l) { $fields = array(); $fields['ListPosition'] = $l; $fields['FieldSet'] = $fsid; $cff->update($fields, $id); } $cfo = EasyContactFormsClassLoader::getObject('CustomForms'); $cfo->updateTemplate($cf); }
/** * setFormPageStatisticsShowOnDashboard * * @param $map * * * @return * */ function setFormPageStatisticsShowOnDashboard($map) { $objid = intval($map['oid']); $obj = EasyContactFormsClassLoader::getObject('CustomFormEntryStatistics', true, $objid); $bval = $map['a'] == 'true' ? true : false; $obj->set('IncludeIntoReporting', $bval); $obj->save(); $map['m'] = 'viewDetailed'; EasyContactFormsRoot::processEvent($map); }
/** * easycontactforms_w3c_load_styles * * * @return * */ function easycontactforms_w3c_load_styles() { if (is_admin()) { return; } require_once 'easy-contact-forms-root.php'; require_once 'easy-contact-forms-applicationsettings.php'; $as = EasyContactFormsApplicationSettings::getInstance(); if ($as->get('w3cCompliant') && !$as->isEmpty('w3cStyle')) { if (!defined('EASYCONTACTFORMS__APPLICATION_ROOT')) { DEFINE('EASYCONTACTFORMS__APPLICATION_ROOT', rtrim(get_bloginfo('wpurl'), '/')); } if (!defined('EASYCONTACTFORMS__engineWebAppDirectory')) { DEFINE('EASYCONTACTFORMS__engineWebAppDirectory', plugins_url('', __FILE__)); } if (!defined('_EASYCONTACTFORMS_PLUGIN_PATH')) { DEFINE('_EASYCONTACTFORMS_PLUGIN_PATH', rtrim(plugin_dir_path(__FILE__), "/\\")); } require_once _EASYCONTACTFORMS_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'easy-contact-forms-appconfigdata.php'; $forms = EasyContactFormsClassLoader::getObject('CustomForms'); echo $forms->basicLoadStyle($as->get('w3cStyle')); } }
/** * getTypeFormDescription * * produces a view header * * @param int $id * object id * @param string $type * object type * @param string $fields * fields to select * @param string $format * format to apply * @param string $spanclass * span class to apply * * @return string * html text */ function getTypeFormDescription($id, $type, $fields = NULL, $format = NULL, $spanclass = 'formdescription') { $fields = isset($fields) ? $fields : 'Description'; $obj = EasyContactFormsClassLoader::getObject($type); $tablename = $obj->getTableName(); $query = 'SELECT ' . $fields . ' FROM ' . $tablename . ' WHERE id = %d'; return EasyContactFormsUtils::getFormDescription($id, $query, $format, $spanclass); }
/** * protectedUpload * * takes a file from a temporary folder and registers it in the file * manager * * @param array $_uldmap * request data * @param array $filespecmap * file spec */ function protectedUpload($_uldmap, $filespecmap = NULL) { $filespecmapnull = false; if (is_null($filespecmap)) { $filespecmapnull = true; $filerequestid = $_uldmap['t'] . '_' . $_uldmap['fld'] . '_' . $_uldmap['oid']; $filespecmap = $_FILES[$filerequestid]; } if (!isset($filespecmap)) { return FALSE; } if ($filespecmap['error'] != UPLOAD_ERR_OK) { return FALSE; } $ds = DIRECTORY_SEPARATOR; $protect = 0; if (isset($_uldmap['protect'])) { $protect = $_uldmap['protect'] == "on" ? 1 : 0; } $oowner = isset($_uldmap['easycontactusr']) ? $_uldmap['easycontactusr']->id : 0; $filename = $filespecmap['name']; $tmpname = $filespecmap['tmp_name']; $filesize = $filespecmap['size']; $filetype = $filespecmap['type']; $Type = $_uldmap['t']; $fieldname = $_uldmap['fld']; $id = $_uldmap['oid']; $basename = EasyContactFormsUtils::subStringBefore($filename, "."); if ($protect && ($basename == NULL || preg_match('/^[A-Fa-f0-9]{32}$/', $basename))) { echo EasyContactFormsIHTML::showMessage(EasyContactFormsT::get('ImpossibleToPerformOperation'), 'warningMessage'); return FALSE; } global $wpdb; $query = "SELECT\n\t\t\t\tCount\n\t\t\tFROM\n\t\t\t\t#wp__easycontactforms_files\n\t\t\tWHERE\n\t\t\t\tDoctype=%s\n\t\t\t\tAND Docid=%d\n\t\t\t\tAND Docfield=%s"; $query = $wpdb->prepare($query, $Type, $id, $fieldname); $counter = EasyContactFormsDB::getValue($query); $counter = isset($counter) ? $counter : 0; $query = "SELECT\n\t\t\t\tid\n\t\t\tFROM\n\t\t\t\t#wp__easycontactforms_files\n\t\t\tWHERE\n\t\t\t\tDoctype=%s\n\t\t\t\tAND Docid=%d\n\t\t\t\tAND Docfield=%s"; $query = $wpdb->prepare($query, $Type, $id, $fieldname); $fileid = EasyContactFormsDB::getValue($query); if (isset($fileid)) { EasyContactFormsFiles::deletefile($fileid); EasyContactFormsFiles::delete($fileid); } $file = EasyContactFormsClassLoader::getObject('Files', true); $file->set('Count', $counter); $file->set('Docfield', $fieldname); $file->set('Doctype', $Type); $file->set('Docid', $id); $file->set('Name', $filename); $file->set('Size', $filesize); $file->set('Type', $filetype); $file->set('Protected', $protect); $file->set('Webdir', 0); $file->set('ObjectOwner', $oowner); $filespec = (object) array(); $filespec->protect = $protect; $filespec->fieldname = $fieldname; $filespec->docType = $Type; $filespec->filename = $filename; if ($Type == "Files") { $filespec->id = $file->get('id'); $Storagename = $file->getStorageFileName($filespec); $file->set('Storagename', $Storagename); $file->set('Docid', $file->get('id')); } else { $filespec->id = $id; $Storagename = $file->getStorageFileName($filespec); $file->set('Storagename', $Storagename); } $file->save(); $filedirectory = EASYCONTACTFORMS__fileUploadDir; if (!is_dir($filedirectory)) { if (!EasyContactFormsUtils::createFolder($filedirectory)) { return FALSE; } } $newpath = $filedirectory . $ds . $Storagename; if ($filespecmapnull) { if (!move_uploaded_file($tmpname, $newpath)) { return FALSE; } } else { rename($tmpname, $newpath); } return TRUE; }
/** * getSupportPage * * * @return * */ function getSupportPage() { if (!current_user_can('manage_options')) { return; } if (EasyContactFormsSupport::submitSupportForm()) { return; } wp_enqueue_script('easy-contact-forms-html', plugins_url('easy-contact-formshtml.1.4.9.js', __FILE__), array(), false, true); wp_enqueue_script('easy-contact-forms-env', plugins_url('easy-contact-forms.env.1.4.9.js', __FILE__), array(), false, true); $env = (object) array(); $env->System = (object) array(); $env->Wordpress = (object) array(); $env->Theme = (object) array(); global $current_user; $wp_url = rtrim(site_url(), '/'); $version = '1.4.9'; $env->System->PHPVersion = phpversion(); $env->System->UserAgent = $_SERVER['HTTP_USER_AGENT']; $env->System->Server = $_SERVER['SERVER_SOFTWARE']; $env->Wordpress->Version = get_bloginfo('version'); $env->Wordpress->Home = home_url(); $env->Wordpress->Site = $wp_url; $env->Wordpress->AdminEmail = $current_user->user_email; $env->Theme = (object) array(); if (function_exists('wp_get_theme')) { $theme = wp_get_theme(); } else { $theme_path = get_stylesheet_directory() . '/style.css'; $theme = get_theme_data($theme_path); $theme = (object) $theme; } $env->Theme->Name = $theme->Name; $env->Theme->ThemeURI = $theme->ThemeURI; $env->Theme->Version = $theme->Version; $env->Plugins = array(); $plugins = get_plugins(); $plugintable = array(); $plugintable[] = "<tr><th>" . __('Name') . "</th><th>" . __('Version') . "</th><th> URI</th></tr>"; foreach (array_keys($plugins) as $key) { if (!is_plugin_active($key)) { continue; } $plugindata =& $plugins[$key]; $plugin = (object) array(); $env->Plugins[] = $plugin; $plugin->Name = $plugindata['Name']; $plugin->Version = $plugindata['Version']; $plugin->PluginURI = $plugindata['PluginURI']; $plugintable[] = "<tr><td>{$plugin->Name}</td><td>{$plugin->Version}</td><td>{$plugin->PluginURI}</td></tr>"; } $plugintable = implode('', $plugintable); $plugintable = "<table class='ufo-object-table'>{$plugintable}</table>"; global $wpdb; $query = "SELECT CustomForms.id AS id, CustomForms.Description AS Name, CustomForms.NotificationSubject, CustomForms.NotificationText, CustomForms.SendNotificationAsText AS NotificationAsText, CustomForms.SendConfirmation AS SendConfirmations, CustomForms.SendFrom AS SendFromName, CustomForms.SendFromAddress, CustomForms.ConfirmationSubject, CustomForms.ConfirmationText, CustomForms.IncludeVisitorsAddressInReplyTo AS ReplyToVisitors, CustomForms.ReplyToNameTemplate, CustomForms.ConfirmationReplyToName, CustomForms.ConfirmationReplyToAddress, Users.email AS RecipientEmail, Users.Role AS RecipientRole, EngineUsers.user_login AS RecipientUserName FROM {$wpdb->prefix}easycontactforms_customforms AS CustomForms\tLEFT JOIN {$wpdb->prefix}easycontactforms_users AS Users LEFT JOIN {$wpdb->prefix}users AS EngineUsers ON Users.CMSId = EngineUsers.ID\tON CustomForms.ObjectOwner = Users.id"; $env->Forms = $wpdb->get_results($query); $formtable = EasyContactFormsUtils::getSimpleTable($env->Forms); $env->Settings->SupportInfo = "Objects could not be loaded"; if (@(include_once 'easy-contact-forms-root.php')) { require_once 'easy-contact-forms-applicationsettings.php'; unset($env->Settings->SupportInfo); $as = EasyContactFormsClassLoader::getObject('ApplicationSettings', true, 1); $env->Settings = $as->getData(); unset($env->Settings->SecretWord); unset($env->Settings->id); unset($env->Settings->Description); } $settinstable = EasyContactFormsUtils::getSimpleObjectTable($env->Settings); $data = "\n\t\t<h4>System Information:</h4>\n\t\t<table class='ufo-object-table'>\n\t\t<tr><th>Plugin Version:</th><td>{$version}</td></tr>\n\t\t<tr><th>WP Version:</th><td>{$env->Wordpress->Version}</td></tr>\n\t\t<tr><th>WP home URL</th><td>{$env->Wordpress->Home}</td></tr>\n\t\t<tr><th>WP site URL</th><td>{$env->Wordpress->Site}</td></tr>\n\t\t<tr><th>Admin email</th><td>{$env->Wordpress->AdminEmail}</td></tr>\n\t\t<tr><th>JS Errors</th><td id='support-data-table-js-errors'><span style='color:red'>Yes</span></td></tr>\n\t\t<tr><th>jQuery version</th><td id='support-data-table-query-version'></td></tr>\n\t\t<tr><th>PHP Version:</th><td>{$env->System->PHPVersion}</td></tr>\n\t\t<tr><th>User Agent:</th><td>{$env->System->UserAgent}</td></tr>\n\t\t<tr><th>Server Software:</th><td>{$env->System->Server}</td></tr>\n\t\t<tr><th>Theme Name:</th><td>{$env->Theme->Name}</td></tr>\n\t\t<tr><th>Theme URI:</th><td>{$env->Theme->ThemeURI}</td></tr>\n\t\t<tr><th>Theme Version:</th><td>{$env->Theme->Version}</td></tr>\n\t\t</table>\n\n\t\t<h4>Active Plugins:</h4>\n\t\t{$plugintable}\n\n\t\t<h4>Settings:</h4>\n\t\t{$settinstable}\n\n\t\t<h4>Form configuration:</h4>\n\t\t{$formtable}\n\n\t\t"; $supportform = $this->getForm(); if (!is_string($supportform)) { $supportform = $supportform->get_error_message(); } echo "<div class='wrap'>"; echo EasyContactFormsSupport::validateForm(); echo "<h2>" . __('Easy Contact Forms Support') . "</h2>"; echo "<div class='postbox-container-1' style='width:620px'>"; echo "<div class='metabox-holder'>"; echo "<div class='postbox'>"; echo "<h3>" . __('Support Request') . "</h3>"; echo "<div class='inside'>"; echo "<form method='POST'>"; echo "<input type='hidden' name='support-data-product-version' value='{$version}'>"; echo "<input type='hidden' name='support-form-data' value='1'>"; echo "<input type='hidden' name='support-data-query-version' id='support-data-query-version'>"; echo "<input type='hidden' name='support-data-js-errors' id='support-data-js-errors' value='Yes'>"; $env = base64_encode(serialize($env)); echo "<input type='hidden' name='support-data-env' id='support-data-env' value='{$env}'>"; echo $supportform; echo "<label><input type='checkbox' checked onchange='document.getElementById(\"support-data-env\").disabled = !this.checked'> " . __('Send Environment Info') . "</label><br />"; echo "<br /><input class='button-primary' type='submit' value='" . __('Submit') . "'>"; echo "</form>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "<style>.ufo-object-table th {text-align:left;}.ufo-object-table{font-size:11px;}</style>"; echo "<div class='postbox-container-1' style='width:620px'>"; echo "<div class='metabox-holder'>"; echo "<div class='postbox'>"; echo "<h3>" . __('System information to be sent along with the support request:') . "</h3>"; echo "<div class='inside'>"; echo "<div>"; echo $data; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; echo "</div>"; }
/** * formatComment * * returns a formatted comment * * @param int $comment * old object status * @param array $request * request data * * @return string * the formatted comment */ function formatComment($comment, $request) { $as = EasyContactFormsApplicationSettings::getInstance(); if (!$as->get('UseTinyMCE')) { $comment = nl2br(htmlspecialchars($comment)); } $lastname = ''; $name = ''; if (isset($this->user)) { $userid = $this->user->id; $users = EasyContactFormsClassLoader::getObject('Users'); $lastname = $users->getValue('Description', $userid); $name = $users->getValue('Name', $userid); $this->_userName = trim("{$name} {$lastname}"); } $date = date($as->getDateFormat('PHP', TRUE)); return "\n\t\t\t\t<div class='ufo-div-comment'>\n\t\t\t\t\t<div class='ufo-div-comment-header'>\n\t\t\t\t\t\t{$name} {$lastname}\n\t\t\t\t\t\t<br />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{$date}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='ufo-div-comment-comment'>\n\t\t\t\t\t\t{$comment}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div class='ufo-clear-both'></div>\n\t\t\t\t"; }
/** * copy * * Copies a db object * * @param array $settings * extra settings * * @return object * An object copy */ function sibling($settings = NULL) { $fields = $this->fields; $fields = clone $fields; $newobj = EasyContactFormsClassLoader::getObject($this->type, true); $newid = $newobj->get('id'); $newobj->fields = $fields; $newobj->set('id', $newid); if (isset($fields->ListPosition)) { $newobj->set('ListPosition', $newid); } if (isset($fields->Description)) { $newobj->set('Description', $fields->Description . ' (copy)'); } if (!is_null($settings)) { foreach ($settings as $key => $value) { $newobj->set($key, $value); } } $newobj->save(); return $newobj; }
/** * processEntry * * @param $map * * * @return * */ function processEntry($map) { $currentuser = isset($map['easycontactusr']) ? $map['easycontactusr'] : NULL; if (is_null($currentuser)) { return; } $newobjectmap = array(); $newobjectmap['easycontactusr'] = $currentuser; $id = intval($map['oid']); if ($id == 0) { return; } $entry = EasyContactFormsClassLoader::getObject('CustomFormsEntries', TRUE, $id); $content = $entry->get('Content'); $xml = simplexml_load_string($content); $userid = (string) $xml->attributes()->userid; $userid = empty($userid) ? NULL : intval($userid); if (empty($userid)) { $users = EasyContactFormsClassLoader::getObject('Users'); $user = $users->getEmptyObject($newobjectmap); $siteuserid = $entry->get('SiteUser'); $siteuserid = empty($siteuserid) ? NULL : $siteuserid; if (!is_null($siteuserid)) { $usrquery = "SELECT\n\t\t\t\t\t\t\tuser_login AS username,\n\t\t\t\t\t\t\tuser_email AS email,\n\t\t\t\t\t\t\tdisplay_name AS name\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t#wp__users\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tID='{$siteuserid}'"; $susr = EasyContactFormsDB::getObjects($usrquery); $susr = $susr[0]; $susrname = !empty($susr->name) ? $susr->name : $susr->username; if (empty($susrname)) { $user->set('Description', $susrname); } if (empty($susr->email)) { $user->set('email', $susr->email); } $user->set('CMSId', $siteuserid); } } else { $user = EasyContactFormsClassLoader::getObject('Users', true, $userid); $user->user = $currentuser; } $user->save(); $entry->set('Date', EasyContactFormsUtils::getDate($entry->get('Date'), false, true, true)); $entry->set('Users', $user->get('id')); $entry->save(); $form = EasyContactFormsClassLoader::getObject('CustomForms', true, $entry->get('CustomForms')); $form->set('TotalProcessedEntries', $form->get('TotalProcessedEntries') + 1); $form->save(); unset($map['oid']); unset($map['n']); $mn = isset($map['a']) ? 'viewDetailed' : 'view'; $map['m'] = $mn; EasyContactFormsRoot::processEvent($map); }
/** * processHistory * * performs status/comment/history processing * * @param array $fieldvalues * request field data * @param string $type * object type * @param int $oid * object id * @param int $uid * current user id */ function processHistory($fieldvalues, $type, $oid, $uid) { $object = EasyContactFormsClassLoader::getObject($type, TRUE, $oid); $is_st_changed = isset($fieldvalues->Status) && $fieldvalues->Status != $object->get('Status'); $not_on_sn_chng_var = $type . '_NotifyOnStatusChange'; $not_on_st_change = EasyContactFormsApplicationSettings::getInstance()->get($not_on_sn_chng_var); $is_n_comment = isset($fieldvalues->Comment) && !empty($fieldvalues->Comment); $not_on_new_comment_var = $type . '_NotifyOnNewComment'; $not_on_new_comment = EasyContactFormsApplicationSettings::getInstance()->get($not_on_new_comment_var); $send_message = $is_n_comment && $not_on_new_comment || $is_st_changed && $not_on_st_change; if (!$is_st_changed && !$is_n_comment) { return $fieldvalues; } $type_status_map = array(); $objname = EasyContactFormsDB::getTableName($type_status_map[$type]); $status = ''; if (isset($objname)) { $sid = $is_st_changed ? intval($fieldvalues->Status) : $object->get('Status'); $status = EasyContactFormsDB::getValue("SELECT Description FROM {$objname} WHERE id='{$sid}'"); $status .= ' -- '; } $user = EasyContactFormsDB::getValue("SELECT CONCAT(Description,' ',Name) FROM #wp__easycontactforms_users WHERE id='{$uid}'"); $text = (object) array('body' => '', 'subject' => ''); $comment = ''; $delimeter = '-- ' . $user . ' -- ' . $status . date(EasyContactFormsT::get('DateTimeFormat')) . ' --<br/>'; if ($is_n_comment) { $comment = $fieldvalues->Comment; unset($fieldvalues->Comment); $text->body = $comment; $stemplate = EasyContactFormsApplicationSettings::getInstance()->get('NewCommentSubject'); $text->subject = sprintf($stemplate, $type, $object->get('Description'), $status); } if ($is_st_changed) { $stemplate = EasyContactFormsApplicationSettings::getInstance()->get('StatusChangeSubject'); $text->subject = sprintf($stemplate, $type, $object->get('Description'), $status); } $history = $delimeter . $text->body . '<br/>' . $object->get('History'); $fieldvalues->History = $history; if ($send_message) { $this->sendNotification($uid, $type, $oid, $text); } return $fieldvalues; }
/** * process * * Applies the form entry data to db * * @param int $ownerid * User who owns the results */ function process($ownerid = NULL) { $form = EasyContactFormsClassLoader::getObject('CustomForms', true, $this->get('CustomForms')); if (!class_exists('EasyContactFormsT')) { $l_locale = get_locale(); $tag = strtolower(str_replace('_', '-', $l_locale)); require_once 'easy-contact-forms-strings.php'; if (!@(include_once 'easy-contact-forms-resources_' . $tag . '.php')) { require_once 'easy-contact-forms-resources_en-gb.php'; } } if (is_null($ownerid)) { $ownerid = $form->get('ObjectOwner'); } $content = $this->get('Content'); $xml = simplexml_load_string($content); $userid = (string) $xml->attributes()->userid; $userid = empty($userid) ? NULL : intval($userid); if (is_null($userid)) { $users = EasyContactFormsClassLoader::getObject('Users'); $user = $users->getEmptyObject(array()); $user->set('ObjectOwner', $ownerid); $siteuserid = $this->get('SiteUser'); $siteuserid = empty($siteuserid) ? NULL : $siteuserid; if (!is_null($siteuserid)) { $usrquery = "SELECT\n\t\t\t\t\t\t\tuser_login AS username,\n\t\t\t\t\t\t\tuser_email AS email,\n\t\t\t\t\t\t\tdisplay_name AS name\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t#wp__users\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tID='{$siteuserid}'"; $susr = EasyContactFormsDB::getObjects($usrquery); $susr = $susr[0]; $susrname = !empty($susr->name) ? $susr->name : $susr->username; if (!empty($susrname)) { $user->set('Description', $susrname); } if (!empty($susr->email)) { $user->set('email', $susr->email); } $user->set('CMSId', $siteuserid); } } else { $user = EasyContactFormsClassLoader::getObject('Users', true, $userid); $user->set('Role', NULL); } $fields = EasyContactFormsClassLoader::getObject('CustomFormFields'); foreach ($xml->children() as $xmlfld) { $value = (string) $xmlfld->h1; unset($xmlfld->h1); if (empty($value)) { continue; } $fldid = (string) $xmlfld->attributes()->id; $fldid = intval($fldid); $settings = $fields->getValue('Settings', $fldid); if (empty($settings)) { continue; } $settings = simplexml_load_string($settings); $link = (string) $settings->LinkToAppField; if (!empty($link)) { $link = explode('_', $link); if (count($link) > 1) { $user->set($link[1], $value); } } } $content = $xml->asXML(); $user->set('History', $content . '<br /><br />' . $user->get('History')); $user->save(); $this->set('Date', EasyContactFormsUtils::getDate($this->get('Date'), false, true, true)); $this->set('Users', $user->get('id')); $this->save(); $form->set('TotalProcessedEntries', $form->get('TotalProcessedEntries') + 1); $form->save(); }
/** * checkRole * * Performs additional role check * * @param array $_ofnmap * request data * * @return string * role name */ function checkRole($_ofnmap) { $usr = $_ofnmap['easycontactusr']; if ($usr->role->Description == 'SuperAdmin') { return $usr->role->Description; } if ($usr->role->Description == 'Guest') { return $usr->role->Description; } $objtype1 = @$_ofnmap['t']; $objtype2 = @$_ofnmap['t']; $method = @$_ofnmap['m']; $objid = @$_ofnmap['oid']; if (isset($_ofnmap['specialfilter'])) { $sf = json_decode(stripslashes($_ofnmap['specialfilter'])); $objtype1 = $method == 'viewDetailed' ? $sf[0]->property : $_ofnmap['n']; $objid = $sf[0]->value->values[0]; } if (isset($_ofnmap['a'])) { $a = json_decode(stripslashes($_ofnmap['a'])); $mtm = isset($a->m) && $a->m == 'mtmview'; if ($mtm) { $objtype1 = $a->ca[0]->t; $objid = $a->ca[0]->oid; } } if (!isset($objid)) { return $usr->role->Description; } $obj = EasyContactFormsClassLoader::getObject($objtype1); $fieldlist = $obj->getFieldNames(); if (!in_array('ObjectOwner', $fieldlist)) { return $usr->role->Description; } if (!EasyContactFormsSecurityManager::isObjectOwner($objtype1, $objid, $usr->id)) { return $usr->role->Description; } $usr->role->Description = EasyContactFormsSecurityManager::getOwnerRole($usr->role->Description, $objtype1, $objtype2); return $usr->role->Description; }
$userid = $objs[0]->id; $user = EasyContactFormsClassLoader::getObject('Users', true, $objs[0]->id); } if (isset($uopts->vcid) && !empty($uopts->vcid) && $viewName != 'third') { $result = file_get_contents("http://www.vcita.com/api/experts/{$uopts->vcid}"); if ($result) { $result = json_decode($result); if (is_object($result)) { $uxml = $user->get('Options'); $uxml = simplexml_load_string($uxml); if ($result->success && $result->confirmed) { $viewName = 'third'; $uxml->vcita->Confirmed = 'true'; $user->set('Options', $uxml->asXML()); $user->save(); $fld = EasyContactFormsClassLoader::getObject('CustomFormFields', true, $id); $fld->updateTemplate(); } else { $viewName = 'second'; } $uopts->Error = isset($result->error) && !empty($result->error) ? $result->error : ''; } else { $uopts->Error = 'Cannot connect to vcita'; } } else { $uopts->Error = 'Cannot connect to vcita'; } } switch ($viewName) { case 'first': ?>
/** * getFormPageStatistics * * * @return * */ function getFormPageStatistics() { $pfs = EasyContactFormsClassLoader::getObject('CustomFormEntryStatistics'); $map = array(); $map['viewTarget'] = 'CustomFormEntryStatisticsDiv'; $map['t'] = 'CustomFormEntryStatistics'; $map['m'] = 'viewDetailed'; $pfs->map = $map; $pfs->jsconfig = $pfs->getJSConfig($map); echo "<div id='CustomFormEntryStatisticsDiv'>"; $pfs->getDetailedMainView($map); echo "</div>"; }
/** * setOption * * @param $group * * @param $name * * @param $value * * * @return * */ function setOption($group, $name, $value) { $Description = $name; $OptionGroup = $group; $query = "SELECT\n\t\t\t\tOptions.id\n\t\t\tFROM\n\t\t\t\t#wp__easycontactforms_options AS Options\n\t\t\tWHERE\n\t\t\t\tOptions.Description LIKE '{$Description}'\n\t\t\t\tAND Options.OptionGroup LIKE '{$OptionGroup}'"; $id = EasyContactFormsDB::getValue($query); if (!$id) { $option = EasyContactFormsClassLoader::getObject('Options', true); $option->set('Description', $Description); $option->set('OptionGroup', $OptionGroup); } else { $option = EasyContactFormsClassLoader::getObject('Options', true, $id); } $option->set('Value', $value); $option->save(); }
$userid = EasyContactFormsDB::getValue($query); $user = EasyContactFormsClassLoader::getObject('Users', true, $userid); $uopts = (object) array(); $uopts->Email = $user->get('email'); $uopts->FirstName = $user->get('Name'); $uopts->LastName = $user->get('Description'); echo json_encode($uopts); break; case 2: $id = $fld->get('id'); $query = "SELECT CustomForms.ObjectOwner FROM #wp__easycontactforms_customformfields AS CustomFormFields LEFT JOIN #wp__easycontactforms_customforms AS CustomForms ON CustomFormFields.CustomForms = CustomForms.id WHERE CustomFormFields.id = '{$id}'"; $userid = EasyContactFormsDB::getValue($query); if (!$userid) { return; } $user = EasyContactFormsClassLoader::getObject('Users', true, $userid); $uoptsxml = $user->isEmpty('Options') ? '<data></data>' : $user->get('Options'); $uoptsxml = simplexml_load_string($uoptsxml); if (isset($data->ChangeAccount)) { unset($uoptsxml->vcita); $uoptsxml->addChild('vcita'); } if (isset($data->UpdateStatus)) { $uoptsxml->UpdateStatus = 'true'; } else { unset($uoptsxml->UpdateStatus); } if (isset($data->Email) || isset($data->FirstName) || isset($data->LastName)) { if (!isset($uoptsxml->vcita)) { $uoptsxml->addChild('vcita'); }