本文整理汇总了PHP中CerberusApplication类的典型用法代码示例。如果您正苦于以下问题:PHP CerberusApplication类的具体用法?PHP CerberusApplication怎么用?PHP CerberusApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CerberusApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showTab
function showTab()
{
@($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer', 0));
$visit = CerberusApplication::getVisit();
/* @var $visit CerberusVisit */
$translate = DevblocksPlatform::getTranslationService();
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->tpl_path);
$tpl->cache_lifetime = "0";
$view = C4_AbstractViewLoader::getView('', 'audit_log');
if (null == $view) {
$view = new C4_TicketAuditLogView();
$view->id = 'audit_log';
$view->name = $translate->_('auditlog.audit_log');
$view->view_columns = array(SearchFields_TicketAuditLog::CHANGE_DATE, SearchFields_TicketAuditLog::WORKER_ID, SearchFields_TicketAuditLog::CHANGE_FIELD, SearchFields_TicketAuditLog::CHANGE_VALUE);
$view->params = array();
$view->renderLimit = 15;
$view->renderPage = 0;
$view->renderSortBy = SearchFields_TicketAuditLog::CHANGE_DATE;
$view->renderSortAsc = false;
}
$view->params = array(SearchFields_TicketAuditLog::TICKET_ID => new DevblocksSearchCriteria(SearchFields_TicketAuditLog::TICKET_ID, DevblocksSearchCriteria::OPER_EQ, $ticket_id));
$view->renderPage = 0;
C4_AbstractViewLoader::setView($view->id, $view);
$tpl->assign('view', $view);
$tpl->display('file:' . $this->tpl_path . '/display/log/index.tpl');
}
示例2: getTemplateHandler
public static function getTemplateHandler()
{
$tpl = DevblocksPlatform::getTemplateService();
$tpl_path = dirname(__FILE__) . '/templates/';
$tpl->assign('path', $tpl_path);
$tpl->cache_lifetime = "0";
$total_new_count = 0;
foreach (DAO_WorkflowView::getGroupTotals() as $data) {
$total_new_count += $data["total"];
}
$tpl->assign('total_new_count', $total_new_count);
$newest = isset($_SESSION["fluid_latest_seen"]) ? $_SESSION["fluid_latest_seen"] : time() - 3600;
$worker = CerberusApplication::getActiveWorker();
$memberships = $worker->getMemberships();
$params = array(SearchFields_Ticket::TICKET_TEAM_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, 'in', array_keys($memberships)), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, 'eq', 0), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, 'eq', 0), SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, 'eq', 0), SearchFields_Ticket::TICKET_UPDATED_DATE => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_UPDATED_DATE, '>', $newest));
list($results, $total) = DAO_Ticket::search(array(SearchFields_Ticket::TICKET_ID, SearchFields_Ticket::TICKET_MASK, SearchFields_Ticket::TICKET_SUBJECT, SearchFields_Ticket::TICKET_LAST_WROTE), $params, 5, 0, SearchFields_Ticket::TICKET_UPDATED_DATE, false, true);
$tickets = array();
foreach ($results as $ticket) {
if ($ticket[SearchFields_Ticket::TICKET_UPDATED_DATE] > $newest) {
$newest = $ticket[SearchFields_Ticket::TICKET_UPDATED_DATE];
}
$tickets[] = $ticket;
}
$_SESSION["fluid_latest_seen"] = $newest;
$tpl->assign("recent_tickets_json", json_encode($tickets));
$tpl->assign("recent_ticket_count", json_encode($total));
return $tpl;
}
示例3: showTab
function showTab()
{
$visit = CerberusApplication::getVisit();
$translate = DevblocksPlatform::getTranslationService();
$tpl = DevblocksPlatform::getTemplateService();
$tpl->cache_lifetime = "0";
$tpl_path = dirname(dirname(__FILE__)) . '/templates/';
$tpl->assign('path', $tpl_path);
@($request_path = DevblocksPlatform::importGPC($_REQUEST['request'], 'string', ''));
$tpl->assign('request_path', $request_path);
@($stack = explode('/', $request_path));
@array_shift($stack);
// research
@array_shift($stack);
// fnr
@($action = array_shift($stack));
switch ($action) {
default:
// if(null == ($view = C4_AbstractViewLoader::getView(null, self::VIEW_RESEARCH_FNR_SEARCH))) {
// $view = new C4_KbArticleView();
// $view->id = self::VIEW_RESEARCH_FNR_SEARCH;
// $view->name = $translate->_('common.search_results');
// C4_AbstractViewLoader::setView($view->id, $view);
// }
//
// $tpl->assign('view', $view);
// $tpl->assign('view_fields', C4_KbArticleView::getFields());
// $tpl->assign('view_searchable_fields', C4_KbArticleView::getSearchFields());
// $tpl->assign('response_uri', 'research/fnr/search');
$fnr_topics = DAO_FnrTopic::getWhere();
$tpl->assign('fnr_topics', $fnr_topics);
$tpl->display($tpl_path . 'research_tab/index.tpl');
break;
}
}
示例4: isVisible
function isVisible()
{
// check login
$visit = CerberusApplication::getVisit();
if (empty($visit)) {
return false;
} else {
return true;
}
}
示例5: render
function render()
{
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->_TPL_PATH);
$visit = CerberusApplication::getVisit();
$translate = DevblocksPlatform::getTranslationService();
$response = DevblocksPlatform::getHttpResponse();
$tpl->assign('request_path', implode('/', $response->path));
$stack = $response->path;
array_shift($stack);
// research
$tab_manifests = DevblocksPlatform::getExtensions('cerberusweb.research.tab', false);
uasort($tab_manifests, create_function('$a, $b', "return strcasecmp(\$a->name,\$b->name);\n"));
$tpl->assign('tab_manifests', $tab_manifests);
@($tab_selected = array_shift($stack));
if (empty($tab_selected)) {
$tab_selected = '';
}
$tpl->assign('tab_selected', $tab_selected);
$tpl->display('file:' . $this->_TPL_PATH . 'research/index.tpl');
}
示例6: handleRequest
function handleRequest(DevblocksHttpRequest $request)
{
$translate = DevblocksPlatform::getTranslationService();
$stack = $request->path;
// URLS like: /files/10000/plaintext.txt
array_shift($stack);
// files
$file_id = array_shift($stack);
// 10000
$file_name = array_shift($stack);
// plaintext.txt
// Security
if (null == ($active_worker = CerberusApplication::getActiveWorker())) {
die($translate->_('common.access_denied'));
}
if (empty($file_id) || empty($file_name) || null == ($file = DAO_Attachment::get($file_id))) {
die($translate->_('files.not_found'));
}
// Security
$message = DAO_Ticket::getMessage($file->message_id);
if (null == ($ticket = DAO_Ticket::getTicket($message->ticket_id))) {
die($translate->_('common.access_denied'));
}
// Security
$active_worker_memberships = $active_worker->getMemberships();
if (null == $active_worker_memberships[$ticket->team_id]) {
die($translate->_('common.access_denied'));
}
// Set headers
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT\n");
header("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT\n");
header("Cache-control: private\n");
header("Pragma: no-cache\n");
header("Content-Type: " . $file->mime_type . "\n");
header("Content-transfer-encoding: binary\n");
header("Content-Length: " . $file->getFileSize() . "\n");
echo $file->getFileContents();
exit;
}
示例7: savePluginsAction
function savePluginsAction()
{
$translate = DevblocksPlatform::getTranslationService();
$worker = CerberusApplication::getActiveWorker();
if (!$worker || !$worker->is_superuser) {
echo $translate->_('common.access_denied');
return;
}
if (DEMO_MODE) {
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'plugins')));
return;
}
@($plugins_enabled = DevblocksPlatform::importGPC($_REQUEST['plugins_enabled'], 'array'));
$pluginStack = DevblocksPlatform::getPluginRegistry();
if (is_array($plugins_enabled)) {
foreach ($plugins_enabled as $plugin_id) {
$plugin = $pluginStack[$plugin_id];
$plugin->setEnabled(true);
unset($pluginStack[$plugin_id]);
}
}
// [JAS]: Clear unchecked plugins
foreach ($pluginStack as $plugin) {
// [JAS]: We can't force disable core here [TODO] Improve
if ($plugin->id == 'cerberusweb.core') {
continue;
}
$plugin->setEnabled(false);
}
DevblocksPlatform::clearCache();
// Run any enabled plugin patches
// [TODO] Should the platform do this automatically on enable in order?
$patchMgr = DevblocksPlatform::getPatchService();
$patches = DevblocksPlatform::getExtensions("devblocks.patch.container", false, true);
if (is_array($patches)) {
foreach ($patches as $patch_manifest) {
/* @var $patch_manifest DevblocksExtensionManifest */
$container = $patch_manifest->createInstance();
/* @var $container DevblocksPatchContainerExtension */
$patchMgr->registerPatchContainer($container);
}
}
if (!$patchMgr->run()) {
// fail
die("Failed updating plugins.");
// [TODO] Make this more graceful
}
// Reload plugin translations
DAO_Translation::reloadPluginStrings();
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('config', 'plugins')));
}
示例8: doRegisterAction
function doRegisterAction()
{
@($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string', ''));
$tpl = DevblocksPlatform::getTemplateService();
$settings = CerberusSettings::getInstance();
$from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM, null);
$from_personal = $settings->get(CerberusSettings::DEFAULT_REPLY_PERSONAL, "Support Dept.");
$url = DevblocksPlatform::getUrlService();
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$code = CerberusApplication::generatePassword(8);
if (!empty($email) && null != ($addy = DAO_Address::lookupAddress($email, true))) {
// Already registered?
if ($addy->is_registered) {
$tpl->assign('register_error', sprintf("'%s' is already registered.", $email));
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'register')));
return;
}
$fields = array(DAO_Address::IS_REGISTERED => 0, DAO_Address::PASS => $code);
DAO_Address::update($addy->id, $fields);
} else {
$tpl->assign('register_error', sprintf("'%s' is an invalid e-mail address.", $email));
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'register')));
return;
}
$message = $mail_service->createMessage();
$message->setTo($email);
$message->setFrom(array($from => $from_personal));
$message->setSubject("Confirming your support e-mail address");
$message->setBody(sprintf("This is a message to confirm your recent registration request at:\r\n" . "%s\r\n" . "\r\n" . "Your confirmation code is: %s\r\n" . "\r\n" . "If you've closed the browser window, you can continue by visiting:\r\n" . "%s\r\n" . "\r\n" . "Thanks!\r\n" . "%s\r\n", $url->write('', true), $code, $url->write('c=register&a=confirm', true), $from_personal));
$headers = $message->getHeaders();
$headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
$result = $mailer->send($message);
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('portal', UmPortalHelper::getCode(), 'register', 'confirm')));
}
示例9: doRecoverStep1Action
function doRecoverStep1Action()
{
$translate = DevblocksPlatform::getTranslationService();
@($email = DevblocksPlatform::importGPC($_REQUEST['email'], 'string'));
$worker = DAO_Worker::lookupAgentEmail($email);
if (empty($email) || empty($worker)) {
return;
}
$_SESSION[self::KEY_FORGOT_EMAIL] = $email;
try {
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$mail = $mail_service->createMessage();
$code = CerberusApplication::generatePassword(10);
$_SESSION[self::KEY_FORGOT_SENTCODE] = $code;
$settings = CerberusSettings::getInstance();
$from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
$personal = $settings->get(CerberusSettings::DEFAULT_REPLY_PERSONAL);
// Headers
$mail->setTo(array($email));
$mail->setFrom(array($from => $personal));
$mail->setSubject($translate->_('signin.forgot.mail.subject'));
$mail->generateId();
$headers = $mail->getHeaders();
$headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
$mail->setBody(vsprintf($translate->_('signin.forgot.mail.body'), $code));
if (!$mailer->send($mail)) {
throw new Exception('Password Forgot confirmation email failed to send.');
}
} catch (Exception $e) {
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step1', 'failed')));
}
DevblocksPlatform::redirect(new DevblocksHttpResponse(array('login', 'forgot', 'step2')));
}
示例10: parseMessage
/**
* Enter description here...
*
* @param CerberusParserMessage $message
* @return integer
*/
public static function parseMessage(CerberusParserMessage $message, $options = array())
{
/*
* options:
* 'no_autoreply'
*/
$logger = DevblocksPlatform::getConsoleLog();
$settings = DevblocksPlatform::getPluginSettingsService();
$helpdesk_senders = CerberusApplication::getHelpdeskSenders();
// Pre-parse mail filters
$pre_filters = Model_PreParseRule::getMatches($message);
if (is_array($pre_filters) && !empty($pre_filters)) {
// Load filter action manifests for reuse
$ext_action_mfts = DevblocksPlatform::getExtensions('cerberusweb.mail_filter.action', false);
// Loop through all matching filters
foreach ($pre_filters as $pre_filter) {
// Do something with matching filter's actions
foreach ($pre_filter->actions as $action_key => $action) {
switch ($action_key) {
case 'blackhole':
return NULL;
break;
case 'redirect':
@($to = $action['to']);
CerberusMail::reflect($message, $to);
return NULL;
break;
case 'bounce':
@($msg = $action['message']);
@($subject = 'Delivery failed: ' . self::fixQuotePrintableString($message->headers['subject']));
// [TODO] Follow the RFC spec on a true bounce
if (null != ($fromAddressInst = CerberusParser::getAddressFromHeaders($message->headers))) {
CerberusMail::quickSend($fromAddressInst->email, $subject, $msg);
}
return NULL;
break;
default:
// Plugin pre-parser filter actions
if (isset($ext_action_mfts[$action_key])) {
if (null != @($ext_action = $ext_action_mfts[$action_key]->createInstance())) {
try {
/* @var $ext_action Extension_MailFilterAction */
$ext_action->run($pre_filter, $message);
} catch (Exception $e) {
}
}
}
break;
}
}
}
}
$headers =& $message->headers;
// From
if (null == ($fromAddressInst = CerberusParser::getAddressFromHeaders($headers))) {
$logger->err("[Parser] 'From' address could not be created.");
return NULL;
}
// To/Cc/Bcc
$to = array();
$sTo = @$headers['to'];
$bIsNew = true;
if (!empty($sTo)) {
// [TODO] Do we still need this RFC address parser?
$to = CerberusParser::parseRfcAddress($sTo);
}
// Subject
// Fix quote printable subject (quoted blocks can appear anywhere in subject)
$sSubject = "";
if (isset($headers['subject']) && !empty($headers['subject'])) {
$sSubject = $headers['subject'];
if (is_array($sSubject)) {
$sSubject = array_shift($sSubject);
}
}
// The subject can still end up empty after QP decode
if (empty($sSubject)) {
$sSubject = "(no subject)";
}
// Date
$iDate = @strtotime($headers['date']);
// If blank, or in the future, set to the current date
if (empty($iDate) || $iDate > time()) {
$iDate = time();
}
// Is banned?
if (1 == $fromAddressInst->is_banned) {
$logger->info("[Parser] Ignoring ticket from banned address: " . $fromAddressInst->email);
return NULL;
}
// Overloadable
$enumSpamTraining = '';
// Message Id / References / In-Reply-To
@($sMessageId = $headers['message-id']);
//.........这里部分代码省略.........
示例11: getCommunityToolAction
function getCommunityToolAction()
{
$worker = CerberusApplication::getActiveWorker();
if (!$worker || !$worker->is_superuser) {
echo "Access denied.";
return;
}
@($portal = DevblocksPlatform::importGPC($_REQUEST['portal'], 'string', ''));
@($is_submitted = DevblocksPlatform::importGPC($_POST['is_submitted'], 'integer', 0));
UmPortalHelper::setCode($portal);
if (!empty($is_submitted)) {
$is_submitted = time();
}
$tpl = DevblocksPlatform::getTemplateService();
$tpl->cache_lifetime = "0";
$tpl_path = dirname(__FILE__) . '/templates/';
$tpl->assign('path', $tpl_path);
$tpl->assign('portal', $portal);
$tpl->assign('is_submitted', $is_submitted);
if (null != ($instance = DAO_CommunityTool::getByCode($portal))) {
$tpl->assign('instance', $instance);
$manifest = DevblocksPlatform::getExtension($instance->extension_id, false, true);
if (null != ($tool = $manifest->createInstance())) {
/* @var $app Extension_UsermeetTool */
$tpl->assign('tool', $tool);
}
}
// Community Record
$community_id = $instance->community_id;
$community = DAO_Community::get($community_id);
$tpl->assign('community', $community);
// Install
$url_writer = DevblocksPlatform::getUrlService();
$url = $url_writer->write('c=portal&a=' . $portal, true);
$url_parts = parse_url($url);
$host = $url_parts['host'];
@($port = $_SERVER['SERVER_PORT']);
$base = substr(DEVBLOCKS_WEBPATH, 0, -1);
// consume trailing
$path = substr($url_parts['path'], strlen(DEVBLOCKS_WEBPATH) - 1);
// consume trailing slash
@($parts = explode('/', $path));
if ($parts[1] == 'index.php') {
// 0 is null from /part1/part2 paths.
unset($parts[1]);
}
$path = implode('/', $parts);
$tpl->assign('host', $host);
$tpl->assign('is_ssl', $url_writer->isSSL() ? 1 : 0);
$tpl->assign('port', $port);
$tpl->assign('base', $base);
$tpl->assign('path', $path);
$tpl->display('file:' . $tpl_path . 'community/config/tab/tool_config.tpl');
}
示例12: saveKbCategoryEditPanelAction
function saveKbCategoryEditPanelAction()
{
$active_worker = CerberusApplication::getActiveWorker();
if (!$active_worker->hasPriv('core.kb.categories.modify')) {
return;
}
@($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
@($name = DevblocksPlatform::importGPC($_REQUEST['name'], 'string'));
@($parent_id = DevblocksPlatform::importGPC($_REQUEST['parent_id'], 'integer', 0));
@($delete = DevblocksPlatform::importGPC($_REQUEST['delete_box'], 'integer', 0));
@($return = DevblocksPlatform::importGPC($_REQUEST['return']));
if (!empty($id) && !empty($delete)) {
$ids = DAO_KbCategory::getDescendents($id);
DAO_KbCategory::delete($ids);
// Change $return to category parent
$return = "research/kb/" . sprintf("%06d", $parent_id);
} elseif (empty($id)) {
// create
$fields = array(DAO_KbCategory::NAME => $name, DAO_KbCategory::PARENT_ID => $parent_id);
DAO_KbCategory::create($fields);
} else {
// update
$fields = array(DAO_KbCategory::NAME => $name, DAO_KbCategory::PARENT_ID => $parent_id);
DAO_KbCategory::update($id, $fields);
}
if (!empty($return)) {
$return_path = explode('/', $return);
DevblocksPlatform::redirect(new DevblocksHttpResponse($return_path));
}
}
示例13: saveEntryAction
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);
}
示例14: saveTaskPeekAction
function saveTaskPeekAction()
{
@($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', ''));
@($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
@($link_namespace = DevblocksPlatform::importGPC($_REQUEST['link_namespace'], 'string', ''));
@($link_object_id = DevblocksPlatform::importGPC($_REQUEST['link_object_id'], 'integer', 0));
@($do_delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0));
$active_worker = CerberusApplication::getActiveWorker();
if (!empty($id) && !empty($do_delete)) {
// delete
$task = DAO_Task::get($id);
// Check privs
if ($active_worker->hasPriv('core.tasks.actions.create') && $active_worker->id == $task->worker_id || $active_worker->hasPriv('core.tasks.actions.update_nobody') && empty($task->worker_id) || $active_worker->hasPriv('core.tasks.actions.update_all')) {
DAO_Task::delete($id);
}
} else {
// create|update
$fields = array();
// Title
@($title = DevblocksPlatform::importGPC($_REQUEST['title'], 'string', ''));
if (!empty($title)) {
$fields[DAO_Task::TITLE] = $title;
}
// Completed
@($completed = DevblocksPlatform::importGPC($_REQUEST['completed'], 'integer', 0));
$fields[DAO_Task::IS_COMPLETED] = intval($completed);
// [TODO] This shouldn't constantly update the completed date (it should compare)
if ($completed) {
$fields[DAO_Task::COMPLETED_DATE] = time();
} else {
$fields[DAO_Task::COMPLETED_DATE] = 0;
}
// Due Date
@($due_date = DevblocksPlatform::importGPC($_REQUEST['due_date'], 'string', ''));
@($fields[DAO_Task::DUE_DATE] = empty($due_date) ? 0 : intval(strtotime($due_date)));
// Worker
@($worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0));
@($fields[DAO_Task::WORKER_ID] = intval($worker_id));
// Content
@($content = DevblocksPlatform::importGPC($_REQUEST['content'], 'string', ''));
@($fields[DAO_Task::CONTENT] = $content);
// Link to object (optional)
if (!empty($link_namespace) && !empty($link_object_id)) {
@($fields[DAO_Task::SOURCE_EXTENSION] = $link_namespace);
@($fields[DAO_Task::SOURCE_ID] = $link_object_id);
}
// Save
if (!empty($id)) {
DAO_Task::update($id, $fields);
} else {
$id = DAO_Task::create($fields);
// Write a notification (if not assigned to ourselves)
// $url_writer = DevblocksPlatform::getUrlService();
$source_extensions = DevblocksPlatform::getExtensions('cerberusweb.task.source', true);
if (!empty($worker_id)) {
// && $active_worker->id != $worker_id (Temporarily allow self notifications)
if (null != @($source_renderer = $source_extensions[$link_namespace])) {
/* @var $source_renderer Extension_TaskSource */
$source_info = $source_renderer->getSourceInfo($link_object_id);
$source_name = $source_info['name'];
$source_url = $source_info['url'];
if (empty($source_name) || empty($source_url)) {
break;
}
$fields = array(DAO_WorkerEvent::CREATED_DATE => time(), DAO_WorkerEvent::WORKER_ID => $worker_id, DAO_WorkerEvent::URL => $source_url, DAO_WorkerEvent::TITLE => 'New Task Assignment', DAO_WorkerEvent::CONTENT => sprintf("%s\n%s says: %s", $source_name, $active_worker->getName(), $title), DAO_WorkerEvent::IS_READ => 0);
DAO_WorkerEvent::create($fields);
}
}
}
// Custom field saves
@($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Task::ID, $id, $field_ids);
}
if (!empty($view_id) && null != ($view = C4_AbstractViewLoader::getView('', $view_id))) {
$view->render();
}
exit;
}
示例15: saveOrgPeekAction
function saveOrgPeekAction()
{
$active_worker = CerberusApplication::getActiveWorker();
@($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
@($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
@($org_name = DevblocksPlatform::importGPC($_REQUEST['org_name'], 'string', ''));
@($street = DevblocksPlatform::importGPC($_REQUEST['street'], 'string', ''));
@($city = DevblocksPlatform::importGPC($_REQUEST['city'], 'string', ''));
@($province = DevblocksPlatform::importGPC($_REQUEST['province'], 'string', ''));
@($postal = DevblocksPlatform::importGPC($_REQUEST['postal'], 'string', ''));
@($country = DevblocksPlatform::importGPC($_REQUEST['country'], 'string', ''));
@($phone = DevblocksPlatform::importGPC($_REQUEST['phone'], 'string', ''));
@($website = DevblocksPlatform::importGPC($_REQUEST['website'], 'string', ''));
@($delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0));
if (!empty($id) && !empty($delete)) {
// delete
if ($active_worker->hasPriv('core.addybook.org.actions.delete')) {
DAO_ContactOrg::delete($id);
}
} else {
// create/edit
if ($active_worker->hasPriv('core.addybook.org.actions.update')) {
$fields = array(DAO_ContactOrg::NAME => $org_name, DAO_ContactOrg::STREET => $street, DAO_ContactOrg::CITY => $city, DAO_ContactOrg::PROVINCE => $province, DAO_ContactOrg::POSTAL => $postal, DAO_ContactOrg::COUNTRY => $country, DAO_ContactOrg::PHONE => $phone, DAO_ContactOrg::WEBSITE => $website);
if ($id == 0) {
$id = DAO_ContactOrg::create($fields);
} else {
DAO_ContactOrg::update($id, $fields);
}
// Custom field saves
@($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Org::ID, $id, $field_ids);
}
}
$view = C4_AbstractViewLoader::getView($view_id);
$view->render();
}