function saveEntryAction() { $active_worker = CerberusApplication::getActiveWorker(); // Make sure we're an active worker if (empty($active_worker) || empty($active_worker->id)) { return; } @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($do_delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0)); @($email = DevblocksPlatform::importGPC($_POST['email'], 'string', '')); @($mood = DevblocksPlatform::importGPC($_POST['mood'], 'integer', 0)); @($quote = DevblocksPlatform::importGPC($_POST['quote'], 'string', '')); @($url = DevblocksPlatform::importGPC($_POST['url'], 'string', '')); @($source_extension_id = DevblocksPlatform::importGPC($_POST['source_extension_id'], 'string', '')); @($source_id = DevblocksPlatform::importGPC($_POST['source_id'], 'integer', 0)); // Translate email string into addy id, if exists $address_id = 0; if (!empty($email)) { if (null != ($author_address = DAO_Address::lookupAddress($email, true))) { $address_id = $author_address->id; } } // Delete entries if (!empty($id) && !empty($do_delete)) { if (null != ($entry = DAO_FeedbackEntry::get($id))) { // Only superusers and owners can delete entries if ($active_worker->is_superuser || $active_worker->id == $entry->worker_id) { DAO_FeedbackEntry::delete($id); } } return; } // New or modify $fields = array(DAO_FeedbackEntry::QUOTE_MOOD => intval($mood), DAO_FeedbackEntry::QUOTE_TEXT => $quote, DAO_FeedbackEntry::QUOTE_ADDRESS_ID => intval($address_id), DAO_FeedbackEntry::SOURCE_URL => $url); // Only on new if (empty($id)) { $fields[DAO_FeedbackEntry::LOG_DATE] = time(); $fields[DAO_FeedbackEntry::WORKER_ID] = $active_worker->id; } if (empty($id)) { // create $id = DAO_FeedbackEntry::create($fields); // Post-create actions if (!empty($source_extension_id) && !empty($source_id)) { switch ($source_extension_id) { case 'feedback.source.ticket': // Create a ticket comment about the feedback (to prevent dupes) if (null == ($worker_address = DAO_Address::lookupAddress($active_worker->email))) { break; } $comment_text = sprintf("== Capture Feedback ==\n" . "Author: %s\n" . "Mood: %s\n" . "\n" . "%s\n", !empty($author_address) ? $author_address->email : 'Anonymous', empty($mood) ? 'Neutral' : (1 == $mood ? 'Praise' : 'Criticism'), $quote); $fields = array(DAO_TicketComment::ADDRESS_ID => $worker_address->id, DAO_TicketComment::COMMENT => $comment_text, DAO_TicketComment::CREATED => time(), DAO_TicketComment::TICKET_ID => intval($source_id)); DAO_TicketComment::create($fields); break; } } } else { // modify DAO_FeedbackEntry::update($id, $fields); } // Custom field saves @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array())); DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_FeedbackEntry::ID, $id, $field_ids); }
function showOppPanelAction() { @($opp_id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string', '')); $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = dirname(dirname(__FILE__)) . '/templates/'; $tpl->assign('path', $tpl_path); /* * [IMPORTANT -- Yes, this is simply a line in the sand.] * You're welcome to modify the code to meet your needs, but please respect * our licensing. Buy a legitimate copy to help support the project! * http://www.cerberusweb.com/ */ $license = CerberusLicense::getInstance(); if (empty($id) && (empty($license['serial']) || !empty($license['serial']) && isset($license['a'])) && 10 <= DAO_FeedbackEntry::getItemCount()) { $tpl->display('file:' . $tpl_path . 'crm/opps/rpc/trial.tpl'); return; } $tpl->assign('view_id', $view_id); $tpl->assign('email', $email); if (!empty($opp_id) && null != ($opp = DAO_CrmOpportunity::get($opp_id))) { $tpl->assign('opp', $opp); if (null != ($address = DAO_Address::get($opp->primary_email_id))) { $tpl->assign('address', $address); } } $custom_fields = DAO_CustomField::getBySource(CrmCustomFieldSource_Opportunity::ID); $tpl->assign('custom_fields', $custom_fields); if (!empty($opp_id)) { $custom_field_values = DAO_CustomFieldValue::getValuesBySourceIds(CrmCustomFieldSource_Opportunity::ID, $opp_id); if (isset($custom_field_values[$opp->id])) { $tpl->assign('custom_field_values', $custom_field_values[$opp->id]); } } $workers = DAO_Worker::getAllActive(); $tpl->assign('workers', $workers); $tpl->display('file:' . $tpl_path . 'crm/opps/rpc/peek.tpl'); }
function doBulkUpdate($filter, $do, $ids = array()) { @set_time_limit(0); $change_fields = array(); $custom_fields = array(); // Make sure we have actions if (empty($do)) { return; } // Make sure we have checked items if we want a checked list if (0 == strcasecmp($filter, "checks") && empty($ids)) { return; } if (is_array($do)) { foreach ($do as $k => $v) { switch ($k) { default: // Custom fields if (substr($k, 0, 3) == "cf_") { $custom_fields[substr($k, 3)] = $v; } break; } } } $pg = 0; if (empty($ids)) { do { list($objects, $null) = DAO_FeedbackEntry::search(array(), $this->params, 100, $pg++, SearchFields_FeedbackEntry::ID, true, false); $ids = array_merge($ids, array_keys($objects)); } while (!empty($objects)); } $batch_total = count($ids); for ($x = 0; $x <= $batch_total; $x += 100) { $batch_ids = array_slice($ids, $x, 100); DAO_FeedbackEntry::update($batch_ids, $change_fields); // Custom Fields self::_doBulkSetCustomFields(ChCustomFieldSource_FeedbackEntry::ID, $custom_fields, $batch_ids); unset($batch_ids); } unset($ids); }