public static function getInstance() { if (self::$Instance === null) { self::$Instance = new ContactManager(); } return self::$Instance; }
function __construct() { if ($this->listeners === null) { $this->listeners = new ArrayList(); } $this->contactManager = ContactManager::getInstance(); }
$uid=$sm->getUid($sessionid,$mysql); $title = "Local Contact Manager"; echo <<<HEADER <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>$title</title> </head> <body> HEADER; echo "<h1><enhanCSE/> Local Contact Manager</h1>"; echo '<p align="right"><a href="logout.php">Logout!</a></p>'; $cm = new ContactManager(); if(isset($_POST['action'])){ $action = $_POST['action']; switch($action) { case 'New Contact ...' : { $cm->displayForm($mysql); break; } case 'Edit' : { if(!isset($_POST['cid'])) echo "<p>The contact was not selected. Please try again.</p>"; else { $cid = $_POST['cid'];
function viewContactReport($userID, $domainID, $CSVFlag, $programId, $includeInactive) { //print $includeInactive ? 'inactive included' : 'inactive excluded'; $userObject = clone $_SESSION['UserObject']; $contactManager = new ContactManager($domainID, $userID); $programString['csv'] = ''; $programString['standard'] = ''; if ($programId != '') { $programList = $_SESSION['UserObject']->PointChannels()->participationTypeList(); if (array_key_exists($programId, $programList)) { $programString['csv'] = $programList[$programId]; $programString['standard'] = '<strong>' . $programList[$programId] . '</strong><br />'; } } $contactReport = $contactManager->GetContactReport($programId); $limit = count($contactReport); $pointString = ''; if ($limit) { if ($CSVFlag === true) { $viewContactReport = 'Contact Summary Report for ' . $userObject->localDomain()->description() . "\n" . $programString['csv'] . "\n" . 'Profile,' . 'Name,' . 'Use,' . 'Type,' . 'Location,' . 'Priority,' . 'Contact,' . 'Status' . "\n"; for ($inx = 0; $inx < $limit; $inx++) { if ($contactReport[$inx]->status() == 'Active' || $contactReport[$inx]->status() != 'Active' && $includeInactive) { $viewContactReport .= $contactReport[$inx]->profile() . ',' . (strlen($contactReport[$inx]->name()) ? '"' . $contactReport[$inx]->name() . '"' : '') . ',' . $contactReport[$inx]->contactUse() . ',' . $contactReport[$inx]->type() . ',' . $contactReport[$inx]->location() . ',' . $contactReport[$inx]->priorityLevel() . ',' . $contactReport[$inx]->contactValue() . ',' . $contactReport[$inx]->status() . "\n"; } } } else { $viewContactReport = '<table align="right" cellpadding="0" cellspacing="0" border="0">' . "\n"; $viewContactReport .= '<tr>' . "\n"; $viewContactReport .= '<td class="export"><a href="#" id="exportTableTip" onClick="processBasicCSVExportWithProgram(\'' . rtrim($pointString, ',') . '\',\'' . $domainID . '\',\'' . $programId . '\');" ><img src="_template/images/blank.gif" height="31" width="31" border="0" /><a/></td>' . "\n"; $viewContactReport .= '</tr>' . "\n"; $viewContactReport .= '</table>' . "\n"; $viewContactReport .= '<div>' . '<div style="text-align: center; margin-bottom: 10px;">' . 'Contact Summary Report<br />' . '<strong>' . $userObject->localDomain()->description() . '</strong><br/>' . $programString['standard'] . '</div>' . '<div style="margin-left: 30px;">' . '<table class="sortable" border="0" cellspacing="0" cellpadding="5">' . '<thead>' . '<tr> ' . '<th style="border-bottom: 2px solid; border-top: 2px solid; border-left: 2px solid; font-size: 12px;"> </th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Profile</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Name</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Use</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Type</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Location</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Priority</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; font-size: 12px; border-left: 1px solid;">Contact</th>' . '<th style="border-bottom: 2px solid; border-top: 2px solid; border-right: 2px solid; font-size: 12px; border-left: 1px solid;">Status</th></tr>' . '</thead>' . '<tbody>'; $recordNumber = 1; for ($inx = 0; $inx < $limit; $inx++) { if ($contactReport[$inx]->status() == 'Active' || $contactReport[$inx]->status() != 'Active' && $includeInactive) { $viewContactReport .= '<tr><td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="right">' . $recordNumber++ . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->profile() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . (strlen($contactReport[$inx]->name()) ? $contactReport[$inx]->name() : ' ') . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->contactUse() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->type() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->location() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="right">' . $contactReport[$inx]->priorityLevel() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->contactValue() . '</td>' . '<td style="border-bottom: 1px solid; border-left: 1px solid; border-right: 1px solid; font-size: 12px;" align="left">' . $contactReport[$inx]->status() . '</td></tr>'; } } $viewContactReport .= '</tbody></table></div></div>'; } } else { $viewContactReport = '<div class="error" style="width: 700px;">There are no contacts available to report upon.</div>' . "\n"; } return $viewContactReport; }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _contactUpdate() { global $objUpdate, $_CONFIG; try { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient', array('id' => array('type' => 'INT', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0), 'name' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0))); \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_form' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'type' => array('type' => 'ENUM(\'text\',\'label\',\'checkbox\',\'checkboxGroup\',\'date\',\'file\',\'multi_file\',\'hidden\',\'password\',\'radio\',\'select\',\'textarea\',\'recipient\')', 'notnull' => true, 'default' => 'text'), 'attributes' => array('type' => 'TEXT'), 'is_required' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'check_type' => array('type' => 'INT(3)', 'notnull' => true, 'default' => '1'), 'order_id' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); /**************************** * ADDED: Contrexx v3.0.0 * ****************************/ /* * Create new table 'module_contact_form_field_lang' * to store language patameters of each field */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field_lang', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'fieldID' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'fieldID'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'langID'), 'attributes' => array('type' => 'text', 'after' => 'name')), array('fieldID' => array('fields' => array('fieldID', 'langID'), 'type' => 'UNIQUE'))); /* * Migrate name and attributes fields from 'module_contact_form_field' table * to 'module_contact_form_field_lang' table for active frontend language. * For other languages empty string */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_field', 'name') && \Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) { $query = "SELECT `field`.`id`, `field`.`id_form`, `field`.`name`, `field`.`attributes`, `form`.`langId`\n FROM `" . DBPREFIX . "module_contact_form_field` AS `field`\n JOIN `" . DBPREFIX . "module_contact_form` AS `form`\n ON `form`.`id` = `field`.`id_form`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if ($objResult) { while (!$objResult->EOF) { $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1\n FROM `" . DBPREFIX . "module_contact_form_field_lang`\n WHERE `fieldID` = " . $objResult->fields['id'] . "\n AND `langID` = " . $objResult->fields['langId'] . "\n LIMIT 1"); if ($rowCountResult->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_contact_form_field_lang` (\n `fieldID`, `langID`, `name`, `attributes`\n ) VALUES (\n " . $objResult->fields['id'] . ",\n " . $objResult->fields['langId'] . ",\n '" . addslashes($objResult->fields['name']) . "',\n '" . addslashes($objResult->fields['attributes']) . "')"; \Cx\Lib\UpdateUtil::sql($query); } $objResult->MoveNext(); } } } /* * Create table 'module_contact_recipient_lang' */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient_lang', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'recipient_id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(11)', 'notnull' => true, 'after' => 'recipient_id'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'langID')), array('recipient_id' => array('fields' => array('recipient_id', 'langID'), 'type' => 'UNIQUE'))); /* * Transfer recipientId and name from 'module_contact_recipient' * to 'module_contact_recipient_lang' */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_recipient', 'name')) { $query = "SELECT `id`, `id_form`, `name` FROM `" . DBPREFIX . "module_contact_recipient`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { $langId = 1; if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) { $query = "SELECT `langId`\n FROM `" . DBPREFIX . "module_contact_form`\n WHERE `id` = " . $objResult->fields['id_form']; $formLangId = \Cx\Lib\UpdateUtil::sql($query); $langId = $formLangId->fields['langId'] != null ? $formLangId->fields['langId'] : 1; } else { $langId = 1; } /* * Check for row already exsist */ $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1 as count\n FROM `" . DBPREFIX . "module_contact_recipient_lang`\n WHERE `recipient_id` = " . $objResult->fields['id'] . "\n AND `langID` = " . $langId . "\n LIMIT 1"); if ($rowCountResult->RecordCount() == 0) { $query = "INSERT INTO `" . DBPREFIX . "module_contact_recipient_lang` (\n `recipient_id`, `langID`, `name`\n ) VALUES (\n " . $objResult->fields['id'] . ",\n {$langId},\n '" . addslashes($objResult->fields['name']) . "')"; \Cx\Lib\UpdateUtil::sql($query); } $objResult->MoveNext(); } } /* * Drop column 'recipient name' from 'module_contact_recipient' */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_recipient', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0, 'after' => 'id'), 'email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'id_form'), 'sort' => array('type' => 'INT(11)', 'notnull' => true, 'default' => 0, 'after' => 'email'))); /* * Create new table 'module_contact_form_submit_data' */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_submit_data', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_entry' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id'), 'id_field' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id_entry'), 'formlabel' => array('type' => 'TEXT', 'after' => 'id_field'), 'formvalue' => array('type' => 'TEXT', 'after' => 'formlabel'))); /* * Transfer 'data' field of 'module_contact_form_data' table to 'field_label' and 'field_value' * in 'module_contact_form_submit_data' after base64 decoding * Fetch fieldId from 'module_contact_form_field_lang' table by matching fieldLabel */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_data', 'data')) { /* * Execute migrate script for every 30 dataset */ $query = "SELECT `id`, `id_form`, `data`\n FROM `" . DBPREFIX . "module_contact_form_data`\n WHERE `data` != ''\n LIMIT 30"; while (($objResult = \Cx\Lib\UpdateUtil::sql($query)) && $objResult->RecordCount()) { while (!$objResult->EOF) { $fields_attr = explode(";", $objResult->fields['data']); foreach ($fields_attr as $key => $value) { $field_attr = explode(",", $value); $field_label = base64_decode($field_attr[0]); $field_value = base64_decode($field_attr[1]); /* * In the contrexx 2.1.4, the recipient fields were stored as 'contactFormField_recipient' in the submitted data. */ if ($field_label == "contactFormField_recipient" && \Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form_field', 'name')) { $form_recipient_query = "SELECT `name`\n FROM `" . DBPREFIX . "module_contact_form_field`\n WHERE `type` = 'recipient'\n AND `id_form` = " . $objResult->fields['id_form'] . "\n LIMIT 1"; $formRecipientResult = \Cx\Lib\UpdateUtil::sql($form_recipient_query); $field_label = $formRecipientResult->fields['name']; } $form_label_query = ' SELECT `lang`.`fieldID` FROM `' . DBPREFIX . 'module_contact_form_field` AS `field` LEFT JOIN `' . DBPREFIX . 'module_contact_form_field_lang` AS `lang` ON `lang`.`fieldID` = `field`.`id` WHERE (`field`.`id_form` = ' . $objResult->fields['id_form'] . ') AND (`lang`.`name` = "' . contrexx_raw2db($field_label) . '") '; $formLabelResult = \Cx\Lib\UpdateUtil::sql($form_label_query); $fieldId = $formLabelResult->fields['fieldID'] != null ? $formLabelResult->fields['fieldID'] : 0; $submitCount = \Cx\Lib\UpdateUtil::sql("SELECT 1\n FROM `" . DBPREFIX . "module_contact_form_submit_data`\n WHERE `id_entry` = " . $objResult->fields['id'] . "\n AND `id_field` = " . $fieldId . "\n LIMIT 1"); if ($submitCount->RecordCount() == 0) { $submitQuery = "INSERT INTO `" . DBPREFIX . "module_contact_form_submit_data` (\n `id_entry`, `id_field`, `formlabel`, `formvalue`\n ) VALUES (\n " . $objResult->fields['id'] . ",\n " . $fieldId . ",\n '" . addslashes($field_label) . "',\n '" . addslashes($field_value) . "')"; \Cx\Lib\UpdateUtil::sql($submitQuery); } } /* * Empty column 'data' of the current dataset */ $updateQuery = "UPDATE `" . DBPREFIX . "module_contact_form_data`\n SET `data` = ''\n WHERE `id` = " . $objResult->fields['id']; \Cx\Lib\UpdateUtil::sql($updateQuery); $objResult->MoveNext(); } } } /* * Alter table 'module_contact_form_data' by dropping 'data' field and adding 'id_lang' */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_data', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'id_form' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'id'), 'id_lang' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'id_form'), 'time' => array('type' => 'INT(14)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'id_lang'), 'host' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'time'), 'lang' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'after' => 'host'), 'browser' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'after' => 'lang'), 'ipaddress' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'after' => 'browser'))); /* * Alter table 'module_contact_form_field' by dropping name and attributes column * Add 'special_type' column */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_field', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'id_form' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => 0, 'after' => 'id'), 'type' => array('type' => 'ENUM(\'text\',\'label\',\'checkbox\',\'checkboxGroup\',\'country\',\'date\',\'file\',\'multi_file\',\'fieldset\',\'hidden\',\'horizontalLine\',\'password\',\'radio\',\'select\',\'textarea\',\'recipient\',\'special\')', 'notnull' => true, 'default' => 'text', 'after' => 'id_form'), 'special_type' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'after' => 'type'), 'is_required' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'special_type'), 'check_type' => array('type' => 'INT(3)', 'notnull' => true, 'default' => 1, 'after' => 'is_required'), 'order_id' => array('type' => 'SMALLINT(5)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'check_type'))); /* * Update 'id_lang' column with form language id */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'langId')) { $query = "SELECT `id`, `id_form` FROM `" . DBPREFIX . "module_contact_form_data`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if ($objResult) { while (!$objResult->EOF) { $query = "UPDATE `" . DBPREFIX . "module_contact_form_data`\n SET `id_lang` = (\n SELECT `langId` from `" . DBPREFIX . "module_contact_form`\n WHERE `id` = " . $objResult->fields['id_form'] . "\n ) WHERE `id` = " . $objResult->fields['id']; \Cx\Lib\UpdateUtil::sql($query); $objResult->MoveNext(); } } } /* * Create table 'module_contact_form_lang' */ \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form_lang', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'formID' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'id'), 'langID' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'after' => 'formID'), 'is_active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => 1, 'after' => 'langID'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'is_active'), 'text' => array('type' => 'TEXT', 'after' => 'name'), 'feedback' => array('type' => 'TEXT', 'after' => 'text'), 'mailTemplate' => array('type' => 'TEXT', 'after' => 'feedback'), 'subject' => array('type' => 'VARCHAR(255)', 'after' => 'mailTemplate')), array('formID' => array('fields' => array('formID', 'langID'), 'type' => 'UNIQUE'))); /* * Migrate few fields from module_contact_form to module_contact_form_lang * and remaining fields to module_contact_form of new version */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'name')) { $query = "SELECT `id`, `name`, `subject`, `text`, `feedback`, `langId`\n FROM `" . DBPREFIX . "module_contact_form`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); while (!$objResult->EOF) { /* * Check for row already exsist */ $rowCountResult = \Cx\Lib\UpdateUtil::sql("SELECT 1\n FROM `" . DBPREFIX . "module_contact_form_lang`\n WHERE `formID` = " . $objResult->fields['id'] . "\n AND `langID` = " . $objResult->fields['langId'] . "\n LIMIT 1"); if ($rowCountResult->RecordCount() == 0) { $formLangQuery = "INSERT INTO `" . DBPREFIX . "module_contact_form_lang` (\n `formID`,\n `langID`,\n `is_active`,\n `name`,\n `text`,\n `feedback`,\n `mailTemplate`,\n `subject`\n ) VALUES (\n " . $objResult->fields['id'] . ",\n " . $objResult->fields['langId'] . ",\n 1,\n '" . addslashes($objResult->fields['name']) . "',\n '" . addslashes($objResult->fields['text']) . "',\n '" . addslashes($objResult->fields['feedback']) . "',\n '" . addslashes('<table> <tbody> <!-- BEGIN form_field --> <tr> <td> [[FIELD_LABEL]] </td> <td> [[FIELD_VALUE]] </td> </tr> <!-- END form_field --> </tbody> </table>') . "',\n '" . addslashes($objResult->fields['subject']) . "'\n )"; \Cx\Lib\UpdateUtil::sql($formLangQuery); } $objResult->MoveNext(); } } /* * Alter table 'module_contact_form' by dropping name, subject, feedback and form text * Add new column 'html_mail' */ if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_contact_form', 'html_mail')) { $htmlMailIsNew = false; } else { $htmlMailIsNew = true; } \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'unsigned' => true, 'primary' => true, 'auto_increment' => true), 'mails' => array('type' => 'TEXT', 'after' => 'id'), 'showForm' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'mails'), 'use_captcha' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'showForm'), 'use_custom_style' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 0, 'after' => 'use_captcha'), 'send_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0, 'after' => 'use_custom_style'), 'use_email_of_sender' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => 0, 'after' => 'send_copy'), 'html_mail' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => 1, 'after' => 'use_email_of_sender'), 'send_attachment' => array('type' => 'TINYINT(1)', 'notnull' => true, 'unsigned' => true, 'default' => '0'))); if ($htmlMailIsNew) { \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_contact_form SET html_mail = 0'); } if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.1.5')) { // for all versions >= 2.2.0 // change all fields currently set to 'file' to 'multi_file' ('multi_file' is same as former 'file' in previous versions) \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_contact_form_field` SET `type` = 'multi_file' WHERE `type` = 'file'"); } /** * Update the content pages */ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) { $em = \Env::get('em'); $cl = \Env::get('ClassLoader'); $cl->loadFile(ASCMS_CORE_MODULE_PATH . '/contact/admin.class.php'); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $Contact = new \ContactManager(); $Contact->initContactForms(); foreach ($Contact->arrForms as $id => $form) { foreach ($form['lang'] as $langId => $lang) { if ($lang['is_active'] == true) { $page = $pageRepo->findOneByModuleCmdLang('contact', $id, $langId); if ($page) { $page->setContent($Contact->_getSourceCode($id, $langId)); $page->setUpdatedAtToNow(); $em->persist($page); } } } } $em->flush(); } /******************************************* * EXTENSION: Database structure changes * * ADDED: Contrexx v3.1.0 * *******************************************/ if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_contact_form', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'mails' => array('type' => 'text', 'after' => 'id'), 'showForm' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'mails'), 'use_captcha' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'showForm'), 'use_custom_style' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'use_captcha'), 'save_data_in_crm' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'use_custom_style'), 'send_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'save_data_in_crm'), 'use_email_of_sender' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'send_copy'), 'html_mail' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'use_email_of_sender'), 'send_attachment' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'html_mail'))); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
define('GROK', TRUE); define('iEMS_PATH', ''); require_once iEMS_PATH . 'Connections/crsolutions.php'; //in 3, connections get loaded by iEMSLoader require_once iEMS_PATH . 'iEMSLoader.php'; $Loader = new iEMSLoader(false); $User = new User(); $User = $_SESSION['UserObject']; $PointChannels = new PointChannels(); $PointChannels->Load($User->id(), $User->Domains(0)->id(), '', null, true, null, null); $eol = "\n"; $delm = ','; outputForCSV(); if ($_GET['contacts'] == 'true') { print '"' . 'Contact by Resource Report for ' . $User->fullName() . '"' . $eol; $contactManager = new ContactManager($User->lseDomain()->id(), $User->ID()); $priorities = $contactManager->GetPriorities(); $contactUses = $contactManager->GetContactUses(); $contactValueTypes = $contactManager->GetContactValueTypes(); $contactValueSubtypes = $contactManager->GetContactValueSubtypes(); if ($_GET['format'] != 'hierarchical') { print 'Resource ID' . $delm . 'Resource' . $delm . 'Asset ID' . $delm . 'Asset Description' . $delm . 'Program' . $eol; } } else { print '"' . 'Assets by Resource Report for ' . $User->fullName() . '"' . $eol; if ($_GET['format'] != 'hierarchical') { print 'Resource ID' . $delm . 'Resource' . $delm . 'Asset ID' . $delm . 'Asset Description' . $delm . 'Program' . $eol; } } foreach ($PointChannels->resources() as $resourceObjectID => $attrib) { $resourceDesc = trim(str_replace($attrib['identifier'], "", $attrib['description']));
// Currencies table fields \Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'is_default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_payment_processors'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { \Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM(\'internal\',\'external\')', 'notnull' => true, 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'company_url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''))); } } if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { // contact core_module // update the content pages $em = \Env::get('em'); $cl = \Env::get('ClassLoader'); $cl->loadFile(ASCMS_CORE_MODULE_PATH . '/contact/admin.class.php'); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $Contact = new \ContactManager(); $Contact->initContactForms(); foreach ($Contact->arrForms as $id => $form) { foreach ($form['lang'] as $langId => $lang) { if ($lang['is_active'] == true) { $page = $pageRepo->findOneByModuleCmdLang('contact', $id, $langId); if ($page) { $page->setContent($Contact->_getSourceCode($id, $langId)); $page->setUpdatedAtToNow(); $em->persist($page); } } } } $em->flush(); }
<?php header('Content-Type: application/json'); //indique que le retour doit $etre traité en json require './liste_include_ajax.php'; require '../classes/connexion.class.php'; require '../classes/contact.class.php'; require '../classes/contactManager.class.php'; $db = Connexion::getInstance($dsn, $user, $pass); try { $mg = new ContactManager($db); $retour = $mg->addContact($_GET); print json_encode(array('retour' => $retour)); } catch (PDOException $e) { }
/** * * @param Account $account * @param <type> $settings * @return <type> */ public function performSync() { echo "-----synching contacts<br>\n"; $fnContactManager = new FunambolContactManager(); $wmContactManager = new ContactManager(); if (!$fnContactManager->InitManager() || !$wmContactManager->InitManager()) { echo "managers not inited<br>\n"; return false; } $user_id = $this->_account->IdUser; // in minutes. with dayLightSavingTime adjustment // WARNING // this is different from calendars $accountOffset = $this->_settings->AllowUsersChangeTimeZone ? $this->_account->GetDefaultTimeOffset() : $this->_account->GetDefaultTimeOffset($this->_settings->DefaultTimeZone); echo "making wmContactManager<br>\n"; echo "about to call wmContactManager->InitAccount<br>\n"; $wmContactManager->InitAccount($this->_account); echo "about to call wmContactManager->GetFullContactsList<br>\n"; $wmContactContainers = $wmContactManager->GetFullContactsList(true); echo "making fnContactManager<br>\n"; $fnContactManager->InitAccount($this->_account->Email); $fnContactContainers = $fnContactManager->GetFullContactsList(); echo "fnContactContainers LOOP STARTED<br>\n"; foreach ($fnContactContainers as $fnContactContainer) { // we are interested in the following set of fields from Funambol PIM record // 1. id - unique ID of the Funambol PIM record, INT // 2. last_update INT which is UNIX_TIMESTAMP*1000 + MSECS // 3. status 'N', 'U' and 'D' respectively // first_name // middle_name // last_name $funambolId = $fnContactContainer->GetValue('id'); $funambolStatus = $fnContactContainer->GetValue('status'); echo "---funambolId={$funambolId}, funambolStatus={$funambolStatus}<br/>\n"; $wmContactContainer = $this->GetContactContainerByFunambolId($wmContactContainers, $funambolId); if ($wmContactContainer == null) { echo "no in WM<br/>\n"; // this contact is presented in Funambol DB but is NOT presented in WM //if($funambolStatus === FUNAMBOL_STATUS_DELETED) //{ //echo "does not need sync<br/>\n"; // this case does not need sync // account is alredy deleted prior to get known to us //} //else //{ echo "adding from FN to WM<br/>\n"; // new account, need to insert in into WM $wmContactContainer = $this->ConvertFunambolToWMContactContainer($fnContactContainer, $user_id, TRUE); $wmContactManager->CreateContact($wmContactContainer); //} } else { echo "old known contact, sync it<br/>\n"; echo "wmId=" . $wmContactContainer->GetValue('IdAddress') . "<br/>\n"; // this contact is known for both Funambol and WM // 1. compare modification time // 2. update more old one // GMT modification date as 2000-12-31 23:59:59 $wmDateModified = $wmContactContainer->GetValue('DateModified'); // seconds from Epoch for this date $wmTimestampModified = strtotime($wmDateModified); // local server's timestamp - offset to get GMT as seconds from Epoch $fnTimestampModified = $this->ConvertFNtoWMTimestamp($fnContactContainer->GetValue('last_update'), TRUE); echo " wmtime=" . $wmDateModified . " " . $wmTimestampModified . "<br/>\n" . " fntime=" . date('Y-m-d H:i:s', $fnTimestampModified) . " " . $fnTimestampModified . " " . $fnContactContainer->GetValue('last_update') . "<br/>\n"; if ($wmTimestampModified == $fnTimestampModified) { echo "already synced<br/>\n"; } else { if ($wmTimestampModified > $fnTimestampModified) { echo "WM is newer, updating FN<br/>\n"; $fnContactContainer = $this->ConvertWMToFunambolContactContainer($wmContactContainer, TRUE); $fnContactManager->ReplaceContact($fnContactContainer); $fnContactManager->ReplaceContactAddressInfo($fnContactContainer); $fnContactManager->ReplaceContactOtherInfo($fnContactContainer); } else { echo "FN is newer, updating WM<br/>\n"; $wmCC = $this->ConvertFunambolToWMContactContainer($fnContactContainer, $user_id, TRUE); $wmCC->SetValue('IdAddress', $wmContactContainer->GetValue('IdAddress'), 'int'); $wmCC->SetValue('IdUser', $wmContactContainer->GetValue('IdUser'), 'int'); $wmCC->SetValue('DateCreated', $wmContactContainer->GetValue('DateCreated')); if ($wmContactManager->UpdateContact($wmCC)) { echo "updated<br/>\n"; } else { echo "NOT updated<br/>\n"; } } } // unset contact from $wmContactContainers // usable for old contacts only $this->RemoveWMContactContainer($wmContactContainers, $wmContactContainer); } // if( this contact is a new one or an old one ) } // foreach ($fnContactContainers as $fnContactContainer) echo "fnContactContainers LOOP ENDED<br>\n"; // here $wmContactContainers contains only newly created contacts on WM -side // we need to propagate them to Funambol echo "wmContactContainers LOOP STARTED<br>\n"; foreach ($wmContactContainers as $wmContactContainer) { echo "adding from WM to FN<br/>\n"; $fnContactContainer = $this->ConvertWMToFunambolContactContainer($wmContactContainer, TRUE); $fnContactManager->ReplaceContact($fnContactContainer); $fnContactManager->ReplaceContactAddressInfo($fnContactContainer); $fnContactManager->ReplaceContactOtherInfo($fnContactContainer); // get newly create id in Funambol DB and update WM table with it $wmContactContainer->SetValue('FunambolContactId', $fnContactContainer->GetValue('id')); $wmContactManager->UpdateFunambolContactId($wmContactContainer); } // foreach ($wmContactContainers as $wmContactContainer) echo "wmContactContainers LOOP ENDED<br>\n"; return true; }
/** * controlPanel::panel() * * @param mixed $baseDateArray * @param mixed $dateSpan * @param mixed $username * @param mixed $userID * @param mixed $domainID * @param mixed $connection * @param string $selectedPoints * @param string $selectedView * @param string $selectedPresentation * @param mixed $comparisonArray * @param mixed $selectedRange * @param mixed $lastAction * @param mixed $mvcSelection * @return * * @abstract This is the core function for building the control panel. * * {@source} */ function panel($baseDateArray, $dateSpan, $mdrUser, $connection, $master_connection, $selectedPoints = '', $selectedContactProfiles, $selectedView = 'charts', $selectedPresentation = 'individual', $selectedReport, $comparisonArray, $selectedRange, $repSelectedRange, $lastAction, $mvcSelection) { //$mdrUser->preDebugger($_SESSION); //not sure why I decided to split creation of some of the form elements between here, and their respective forms below --- really really need to refactor this; it is schizophrenic //echo "clsControlPanel->panel: connection='" . $connection . "', master_connection='" . $master_connection . "'<br>\n"; $cpString = ''; $viewOptions = ''; $presentationOptions = ''; $rangeOptions = ''; $repRangeOptions = ''; $reportOptions = ''; $advPointString = ''; $src = ''; $aryDateRange = array('thisWeek' => 'This Week', 'lastWeek' => 'Last Week', 'thisMonth' => 'This Month', 'lastMonth' => 'Last Month'); foreach ($aryDateRange as $inx => $value) { if ($inx == $selectedRange) { $rangeFlag = ' SELECTED'; } else { $rangeFlag = ''; } $rangeOptions .= '<option value="' . $inx . '"' . $rangeFlag . '>' . $value . '</option>'; } $rangeOptions = '<option value="">-- none --</option>' . $rangeOptions; $aryView = array('tabularData' => 'Tabular Data', 'tabularPrices' => 'Tabular Prices'); foreach ($aryView as $inx => $value) { $checkedView = ''; if ($selectedView != '') { if ($inx == $selectedView) { $checkedView = ' checked'; } } if ($inx == 'charts') { $visibilityFlag = 'visible'; } else { $visibilityFlag = 'hidden'; } $script = ''; $viewOptions .= '<li><input type="radio" name="view" value="' . $inx . '" ' . $script . ' ' . $checkedView . ' />' . $value . '</li>'; } $viewOptions = ' <div name="viewOptions">' . $viewOptions . '</div> '; $aryPresentation = array('individual' => 'Individual Charts', 'allInOne' => 'All-in-One Chart', 'aggregate' => 'Aggregate Points'); foreach ($aryPresentation as $inx => $value) { $checkedPresentation = ''; $disabledFlag = ''; if ($selectedPresentation != '') { if ($selectedPresentation == 'comparison') { if ($inx != 'allInOne') { $disabledFlag = 'disabled'; } else { $checkedPresentation = ' checked'; } } elseif ($inx == $selectedPresentation) { $checkedPresentation = ' checked'; } } elseif ($inx == 'allInOne') { $checkedPresentation = ' checked'; } $presentationOptions .= '<li><label><input type="radio" id="presentation" name="presentation" value="' . $inx . '"' . $checkedPresentation . ' ' . $disabledFlag . '/>' . $value . '</label></li>'; } $repDateRange = array('thisWeek' => 'This Week', 'lastWeek' => 'Last Week', 'thisMonth' => 'This Month', 'lastMonth' => 'Last Month', 'thisYear' => 'This Year', 'lastYear' => 'Last Year'); foreach ($repDateRange as $inx => $value) { if ($inx == $repSelectedRange) { $rangeFlag = ' SELECTED'; } else { $rangeFlag = ''; } $repRangeOptions .= '<option value="' . $inx . '"' . $rangeFlag . '>' . $value . '</option>'; } $repRangeOptions = '<option value="">-- none --</option>' . $repRangeOptions; $reports = array('aveHourlyProfile' => 'Ave. Hourly Profile', 'aveHourVsPeakHour' => 'Ave. Hour vs. Peak Hour', 'topTenPeaks' => 'Top Ten Peaks', 'dailyUsageProfile' => 'Daily Usage Profile', 'weeklyUsageProfile' => 'Weekly Usage Profile', 'monthlyUsageProfile' => 'Monthly Usage Profile'); foreach ($reports as $inx => $value) { //$isChecked = ($inx == $selectedReport); if ($inx == $selectedReport) { $isChecked = ' checked'; } else { $isChecked = ''; } $reportOptions .= '<li><label><input type="radio" id="report" name="report" value="' . $inx . '" ' . $isChecked . '/>' . $value . '</label></li>'; } if ($selectedPoints == '') { $sp = $this->gatherDefaultPoints($master_connection, $mdrUser); $selectedPoints['basic'] = $sp; $selectedPoints['advanced'] = $sp; $selectedPoints['event'] = $sp; $selectedPoints['reports'] = $sp; } if (!empty($selectedPoints) && $selectedPoints['advanced'] != '') { $ids = ''; foreach ($selectedPoints['advanced'] as $id => $status) { $ids .= $id . ','; } $advPointString = rtrim($ids, ','); } $visiblePoints = $this->gatherVisiblePoints($master_connection, $mdrUser, true); $dayAheadPoints = $this->gatherVisibleDayAheadPoints($mdrUser, true); $meterForm = $this->meterForm($mdrUser->userName(), $visiblePoints, $selectedPoints['basic'], $baseDateArray['basic']); $dayAheadForm = ''; $dayAheadForm = $this->dayAheadForm($dayAheadPoints, $selectedPoints['dayAhead']); $eventDateSelect = ''; if ($selectedPoints['event'] != '') { $eventDateSelect = $this->eventDateSelectBuilder($selectedPoints['event'], $mdrUser, $src); } $multiVersusCompare = ''; $aryMVC[0]['value'] = 'multi'; $aryMVC[0]['caption'] = 'Multi-Day Chart'; //$aryMVC[0]['script'] = 'onClick="mvcToggle0()"'; $aryMVC[1]['value'] = 'compare'; $aryMVC[1]['caption'] = 'Comparison Chart'; //$aryMVC[1]['script'] = 'onClick="mvcToggle1()"'; $aryMVC[2]['value'] = 'export'; $aryMVC[2]['caption'] = 'Long-Term CSV Export'; //$aryMVC[2]['script'] = 'onClick="mvcToggle2()"'; foreach ($aryMVC as $inx => $fieldSettings) { $mvcChecked = ''; if ($fieldSettings['value'] == $mvcSelection) { $aryMVC[$inx]['status'] = 'checked'; } else { $aryMVC[$inx]['status'] = ''; } } $eventsForm = $this->eventsForm($mdrUser->userName(), $visiblePoints, $selectedPoints['event'], $eventDateSelect, $baseDateArray['event'], $mdrUser); //now that we feed so many dates into advMeterForm, we should consider using an array $advMeterForm = $this->advMeterForm($baseDateArray['advancedFrom'], $baseDateArray['advancedTo'], $baseDateArray['advancedCSVFrom'], $baseDateArray['advancedCSVTo'], $rangeOptions, $visiblePoints, $selectedPoints['advanced'], $viewOptions, $presentationOptions, $mdrUser->userName(), $mdrUser->id(), $connection, $comparisonArray, $aryMVC); $uptimeForm = $this->uptimeStatisticsForm($baseDateArray['uptimeFrom'], $baseDateArray['uptimeTo'], $repRangeOptions, $visiblePoints, $selectedPoints['time'], $mdrUser->userName(), $mdrUser->id(), $connection, $comparisonArray, $aryMVC); $contactManager = new ContactManager($mdrUser->Domains(0)->id(), $mdrUser->id()); $contactProfiles = $contactManager->GetUniqueProfiles(); $contactUses = $contactManager->GetContactUses(); //$selectedContactProfiles = ''; $assetForm = ''; //$assetForm = $mdrUser->isLseUser() ? $this->assetForm($mdrUser) : ''; //$mdrUser->preDebugger($contactProfiles); $contactProfilesForm = $this->contactProfilesForm($mdrUser->Domains(0)->id(), $mdrUser->id(), $contactUses, $contactProfiles, $selectedContactProfiles, $mdrUser); $summaryReportsForm = $this->summaryReportsForm($baseDateArray['reportFrom'], $baseDateArray['reportTo'], $repRangeOptions, $visiblePoints, $selectedPoints['reports'], $reportOptions, $mdrUser->userName(), $mdrUser->id(), $connection, $comparisonArray, $aryMVC); return ' <!-- begin control panel -->' . $this->assemble($meterForm, $advMeterForm, $uptimeForm, $eventsForm, $assetForm, $contactProfilesForm, $summaryReportsForm, $mdrUser->id(), $mdrUser->userName(), $lastAction, $advPointString, $mdrUser, $dayAheadForm) . '<!-- end control panel --> '; }