当前位置: 首页>>代码示例>>PHP>>正文


PHP DevblocksPlatform::getEventService方法代码示例

本文整理汇总了PHP中DevblocksPlatform::getEventService方法的典型用法代码示例。如果您正苦于以下问题:PHP DevblocksPlatform::getEventService方法的具体用法?PHP DevblocksPlatform::getEventService怎么用?PHP DevblocksPlatform::getEventService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DevblocksPlatform的用法示例。


在下文中一共展示了DevblocksPlatform::getEventService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 function run()
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $logger->info("[Heartbeat] Starting Heartbeat Task");
     // Heartbeat Event
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('cron.heartbeat', array()));
 }
开发者ID:rmiddle,项目名称:usermeet,代码行数:8,代码来源:cron.classes.php

示例2: update

 static function update($ids, $fields)
 {
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     /*
      * Make a diff for the requested objects in batches
      */
     foreach ($ids as $id) {
         $objects = DAO_CustomerRecipient::get($id);
         $object_changes = array();
         $pre_fields = get_object_vars($objects);
         $changes = array();
         foreach ($fields as $field_key => $field_val) {
             // Make sure the value of the field actually changed
             if ($pre_fields[$field_key] != $field_val) {
                 $changes[$field_key] = array('from' => $pre_fields[$field_key], 'to' => $field_val);
             }
         }
         // If we had changes
         if (!empty($changes)) {
             $object_changes[$id] = array('model' => array_merge($pre_fields, $fields), 'changes' => $changes);
         }
         /*
          * Make the changes
          */
         parent::_update($ids, 'customer_recipient', $fields);
     }
     /*
      * Trigger an event about the changes
      */
     if (!empty($object_changes)) {
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('dao.customer.recipient.update', array('objects' => $object_changes)));
     }
 }
开发者ID:rmiddle,项目名称:feg,代码行数:36,代码来源:customer_recipient.php

示例3: _workerAssignedTask

 private function _workerAssignedTask($event)
 {
     $translate = DevblocksPlatform::getTranslationService();
     $events = DevblocksPlatform::getEventService();
     $worker_id = $event->params['worker_id'];
     $context = $event->params['context'];
     $task_id = $event->params['context_id'];
     $mail_service = DevblocksPlatform::getMailService();
     $mailer = null;
     // lazy load
     $settings = DevblocksPlatform::getPluginSettingsService();
     $reply_to = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_FROM, CerberusSettingsDefaults::DEFAULT_REPLY_FROM);
     $reply_personal = $settings->get('cerberusweb.core', CerberusSettings::DEFAULT_REPLY_PERSONAL, CerberusSettingsDefaults::DEFAULT_REPLY_PERSONAL);
     $task = DAO_Task::get($task_id);
     // Sanitize and combine all the destination addresses
     $next_worker = DAO_Worker::get($worker_id);
     $notify_emails = $next_worker->email;
     if (empty($notify_emails)) {
         return;
     }
     try {
         if (null == $mailer) {
             $mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
         }
         // Create the message
         $mail = $mail_service->createMessage();
         $mail->setTo(array($notify_emails));
         $mail->setFrom(array($reply_to => $reply_personal));
         $mail->setReplyTo($reply_to);
         $mail->setSubject(sprintf("[Task Assignment #%d]: %s", $task->id, $task->title));
         $headers = $mail->getHeaders();
         $headers->addTextHeader('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
         $headers->addTextHeader('Precedence', 'List');
         $headers->addTextHeader('Auto-Submitted', 'auto-generated');
         $body = sprintf("[Task Assignment #%d]: %s", $task->id, $task->title);
         $mft = DevblocksPlatform::getExtension($context, false, true);
         $ext = $mft->createInstance();
         $url = $ext->getPermalink($task_id);
         $body .= "\r\n" . $url;
         // Comments
         $comments = DAO_Comment::getByContext(CerberusContexts::CONTEXT_TASK, $task_id);
         foreach ($comments as $comment_id => $comment) {
             $address = DAO_Address::get($comment->address_id);
             $body .= "\r\nCommented By: " . $address->first_name . " " . $address->last_name;
             $body .= "\r\n" . $comment->comment;
         }
         unset($comments);
         $body .= "\r\n";
         $mail->setBody($body);
         $result = $mailer->send($mail);
     } catch (Exception $e) {
         echo "Task Email Notification failed to send<br>";
     }
 }
开发者ID:rmiddle,项目名称:cerb5_plugins,代码行数:54,代码来源:App.php

示例4: run

 function run()
 {
     // Heartbeat Event
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('cron.heartbeat', array()));
 }
开发者ID:rmiddle,项目名称:cerb4,代码行数:6,代码来源:cron.classes.php

示例5: run

 function run()
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $logger->info("[Sensors] Starting...");
     // Only pull enabled sensors with an extension_id
     $sensors = DAO_Sensor::getWhere(sprintf("%s=%d", DAO_Sensor::IS_DISABLED, 0));
     $sensor_types = DevblocksPlatform::getExtensions('portsensor.sensor', true);
     if (is_array($sensors)) {
         foreach ($sensors as $sensor) {
             if (!empty($sensor->extension_id) && isset($sensor_types[$sensor->extension_id])) {
                 // Skip external sensors
                 if ('sensor.external' == $sensor->extension_id) {
                     continue;
                 }
                 $runner = $sensor_types[$sensor->extension_id];
                 $output = sprintf("%s (%s)", $sensor->name, $sensor->extension_id);
                 if (method_exists($runner, 'run')) {
                     $fields = array();
                     $success = $runner->run($sensor, $fields);
                     $fields[DAO_Sensor::UPDATED_DATE] = time();
                     $fields[DAO_Sensor::FAIL_COUNT] = $success ? 0 : intval($sensor->fail_count) + 1;
                     DAO_Sensor::update($sensor->id, $fields);
                 }
                 $logger->info("[Sensors] Running {$output}... {$result}");
             }
         }
     }
     // Sensor Runner Event
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('cron.sensors.post', array()));
     $logger->info("[Sensors] Finished!");
 }
开发者ID:jstanden,项目名称:portsensor,代码行数:32,代码来源:cron.classes.php

示例6: parseMessage


//.........这里部分代码省略.........
             if ($file->mime_type == 'message/rfc822') {
                 continue;
             }
             $fields = array(DAO_Attachment::MESSAGE_ID => $email_id, DAO_Attachment::DISPLAY_NAME => $filename, DAO_Attachment::MIME_TYPE => $file->mime_type, DAO_Attachment::FILE_SIZE => intval($file->file_size));
             $file_id = DAO_Attachment::create($fields);
             if (empty($file_id)) {
                 @unlink($file->tmpname);
                 // remove our temp file
                 continue;
             }
             // Make file attachments use buckets so we have a max per directory
             $attachment_bucket = sprintf("%03d/", mt_rand(1, 100));
             $attachment_file = $file_id;
             if (!file_exists($attachment_path . $attachment_bucket)) {
                 @mkdir($attachment_path . $attachment_bucket, 0770, true);
                 // [TODO] Needs error checking
             }
             rename($file->getTempFile(), $attachment_path . $attachment_bucket . $attachment_file);
             // [TODO] Split off attachments into its own DAO
             DAO_Attachment::update($file_id, array(DAO_Attachment::FILEPATH => $attachment_bucket . $attachment_file));
         }
     }
     // Pre-load custom fields
     if (isset($message->custom_fields) && !empty($message->custom_fields)) {
         foreach ($message->custom_fields as $cf_id => $cf_val) {
             if (is_array($cf_val) && !empty($cf_val) || !is_array($cf_val) && 0 != strlen($cf_val)) {
                 DAO_CustomFieldValue::setFieldValue('cerberusweb.fields.source.ticket', $id, $cf_id, $cf_val);
             }
         }
     }
     // Finalize our new ticket details (post-message creation)
     if ($bIsNew && !empty($id) && !empty($email_id)) {
         // First thread (needed for anti-spam)
         DAO_Ticket::updateTicket($id, array(DAO_Ticket::FIRST_MESSAGE_ID => $email_id));
         // Prime the change fields (which a few things like anti-spam might change before we commit)
         $change_fields = array(DAO_Ticket::TEAM_ID => $group_id);
         $out = CerberusBayes::calculateTicketSpamProbability($id);
         if (!empty($group_id)) {
             @($spam_threshold = DAO_GroupSettings::get($group_id, DAO_GroupSettings::SETTING_SPAM_THRESHOLD, 80));
             @($spam_action = DAO_GroupSettings::get($group_id, DAO_GroupSettings::SETTING_SPAM_ACTION, ''));
             @($spam_action_param = DAO_GroupSettings::get($group_id, DAO_GroupSettings::SETTING_SPAM_ACTION_PARAM, ''));
             if ($out['probability'] * 100 >= $spam_threshold) {
                 $enumSpamTraining = CerberusTicketSpamTraining::SPAM;
                 switch ($spam_action) {
                     default:
                     case 0:
                         // do nothing
                         break;
                     case 1:
                         // delete
                         $change_fields[DAO_Ticket::IS_CLOSED] = 1;
                         $change_fields[DAO_Ticket::IS_DELETED] = 1;
                         break;
                     case 2:
                         // move
                         $buckets = DAO_Bucket::getAll();
                         // Verify bucket exists
                         if (!empty($spam_action_param) && isset($buckets[$spam_action_param])) {
                             $change_fields[DAO_Ticket::TEAM_ID] = $group_id;
                             $change_fields[DAO_Ticket::CATEGORY_ID] = $spam_action_param;
                         }
                         break;
                 }
             }
         }
         // end spam training
         // Save properties
         if (!empty($change_fields)) {
             DAO_Ticket::updateTicket($id, $change_fields);
         }
     }
     // Reply notifications (new messages are handled by 'move' listener)
     if (!$bIsNew) {
         // Inbound Reply Event
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('ticket.reply.inbound', array('ticket_id' => $id)));
     }
     // New ticket processing
     if ($bIsNew) {
         // Auto reply
         @($autoreply_enabled = DAO_GroupSettings::get($group_id, DAO_GroupSettings::SETTING_AUTO_REPLY_ENABLED, 0));
         @($autoreply = DAO_GroupSettings::get($group_id, DAO_GroupSettings::SETTING_AUTO_REPLY, ''));
         /*
          * Send the group's autoreply if one exists, as long as this ticket isn't spam
          */
         if (!isset($options['no_autoreply']) && $autoreply_enabled && !empty($autoreply) && $enumSpamTraining != CerberusTicketSpamTraining::SPAM) {
             CerberusMail::sendTicketMessage(array('ticket_id' => $id, 'message_id' => $email_id, 'content' => str_replace(array('#ticket_id#', '#mask#', '#subject#', '#timestamp#', '#sender#', '#sender_first#', '#orig_body#'), array($id, $sMask, $sSubject, date('r'), $fromAddressInst->email, $fromAddressInst->first_name, ltrim($message->body)), $autoreply), 'is_autoreply' => true, 'dont_keep_copy' => true));
         }
     }
     // end bIsNew
     unset($message);
     // Re-open and update our date on new replies
     if (!$bIsNew) {
         DAO_Ticket::updateTicket($id, array(DAO_Ticket::UPDATED_DATE => time(), DAO_Ticket::IS_WAITING => 0, DAO_Ticket::IS_CLOSED => 0, DAO_Ticket::IS_DELETED => 0, DAO_Ticket::LAST_WROTE_ID => $fromAddressInst->id, DAO_Ticket::LAST_ACTION_CODE => CerberusTicketActionCode::TICKET_CUSTOMER_REPLY));
         // [TODO] The TICKET_CUSTOMER_REPLY should be sure of this message address not being a worker
     }
     @imap_errors();
     // Prevent errors from spilling out into STDOUT
     return $id;
 }
开发者ID:Hildy,项目名称:cerb5,代码行数:101,代码来源:Parser.php

示例7: saveContactAction

 function saveContactAction()
 {
     $active_worker = CerberusApplication::getActiveWorker();
     $db = DevblocksPlatform::getDatabaseService();
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($email = trim(DevblocksPlatform::importGPC($_REQUEST['email'], 'string', '')));
     @($first_name = trim(DevblocksPlatform::importGPC($_REQUEST['first_name'], 'string', '')));
     @($last_name = trim(DevblocksPlatform::importGPC($_REQUEST['last_name'], 'string', '')));
     @($contact_org = trim(DevblocksPlatform::importGPC($_REQUEST['contact_org'], 'string', '')));
     @($is_banned = DevblocksPlatform::importGPC($_REQUEST['is_banned'], 'integer', 0));
     @($pass = DevblocksPlatform::importGPC($_REQUEST['pass'], 'string', ''));
     @($unregister = DevblocksPlatform::importGPC($_REQUEST['unregister'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     if ($active_worker->hasPriv('core.addybook.addy.actions.update')) {
         $contact_org_id = 0;
         if (!empty($contact_org)) {
             $contact_org_id = DAO_ContactOrg::lookup($contact_org, true);
             $contact_org = DAO_ContactOrg::get($contact_org_id);
         }
         // Common fields
         $fields = array(DAO_Address::FIRST_NAME => $first_name, DAO_Address::LAST_NAME => $last_name, DAO_Address::CONTACT_ORG_ID => $contact_org_id, DAO_Address::IS_BANNED => $is_banned);
         // Are we clearing the contact's login?
         if ($unregister) {
             $fields[DAO_Address::IS_REGISTERED] = 0;
             $fields[DAO_Address::PASS] = '';
         } elseif (!empty($pass)) {
             // Are we changing their password?
             $fields[DAO_Address::IS_REGISTERED] = 1;
             $fields[DAO_Address::PASS] = md5($pass);
         }
         if ($id == 0) {
             $fields = $fields + array(DAO_Address::EMAIL => $email);
             $id = DAO_Address::create($fields);
         } else {
             DAO_Address::update($id, $fields);
         }
         // Custom field saves
         @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
         DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Address::ID, $id, $field_ids);
         /*
          * Notify anything that wants to know when Address Peek saves.
          */
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('address.peek.saved', array('address_id' => $id, 'changed_fields' => $fields)));
     }
     if (!empty($view_id)) {
         $view = C4_AbstractViewLoader::getView($view_id);
         $view->render();
     }
 }
开发者ID:Hildy,项目名称:cerb5,代码行数:50,代码来源:contacts.php

示例8: sendMailProperties

 static function sendMailProperties($properties)
 {
     $status = true;
     @($toStr = $properties['to']);
     @($cc = $properties['cc']);
     @($bcc = $properties['bcc']);
     @($subject = $properties['subject']);
     @($content = $properties['content']);
     @($files = $properties['files']);
     $mail_settings = self::getMailerDefaults();
     if (empty($properties['from_addy'])) {
         @($from_addy = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_FROM, $_SERVER['SERVER_ADMIN']));
     }
     if (empty($properties['from_personal'])) {
         @($from_personal = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_PERSONAL, ''));
     }
     if (empty($subject)) {
         $subject = '(no subject)';
     }
     // [JAS]: Replace any semi-colons with commas (people like using either)
     $toList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $toStr));
     $mail_headers = array();
     $mail_headers['X-FegCompose'] = '1';
     // Headers needed for the ticket message
     $log_headers = new Swift_Message_Headers();
     $log_headers->setCharset(LANG_CHARSET_CODE);
     $log_headers->set('To', $toList);
     $log_headers->set('From', !empty($from_personal) ? sprintf("%s <%s>", $from_personal, $from_addy) : sprintf('%s', $from_addy));
     $log_headers->set('Subject', $subject);
     $log_headers->set('Date', date('r'));
     foreach ($log_headers->getList() as $hdr => $v) {
         if (null != ($hdr_val = $log_headers->getEncoded($hdr))) {
             if (!empty($hdr_val)) {
                 $mail_headers[$hdr] = $hdr_val;
             }
         }
     }
     try {
         $mail_service = DevblocksPlatform::getMailService();
         $mailer = $mail_service->getMailer(FegMail::getMailerDefaults());
         $email = $mail_service->createMessage();
         $email->setTo($toList);
         // cc
         $ccs = array();
         if (!empty($cc) && null != ($ccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $cc)))) {
             $email->setCc($ccList);
         }
         // bcc
         if (!empty($bcc) && null != ($bccList = DevblocksPlatform::parseCsvString(str_replace(';', ',', $bcc)))) {
             $email->setBcc($bccList);
         }
         $email->setFrom(array($from => $personal));
         $email->setSubject($subject);
         $email->generateId();
         $headers = $email->getHeaders();
         $headers->addTextHeader('X-Mailer', 'Fax Email Gateway (FEG) ' . APP_VERSION . ' (Build ' . APP_BUILD . ')');
         $email->setBody($content);
         // Mime Attachments
         if (is_array($files) && !empty($files)) {
             foreach ($files['tmp_name'] as $idx => $file) {
                 if (empty($file) || empty($files['name'][$idx])) {
                     continue;
                 }
                 $email->attach(Swift_Attachment::fromPath($file)->setFilename($files['name'][$idx]));
             }
         }
         // Headers
         foreach ($email->getHeaders()->getAll() as $hdr) {
             if (null != ($hdr_val = $hdr->getFieldBody())) {
                 if (!empty($hdr_val)) {
                     $mail_headers[$hdr->getFieldName()] = $hdr_val;
                 }
             }
         }
         // [TODO] Allow separated addresses (parseRfcAddress)
         //		$mailer->log->enable();
         if (!@$mailer->send($email)) {
             throw new Exception('Mail failed to send: unknown reason');
         }
         //		$mailer->log->dump();
     } catch (Exception $e) {
         // Do Something
         $status = false;
     }
     // Give plugins a chance to note a message is imported.
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('email.send', array('properties' => $properties, 'send_status' => $status ? 2 : 1)));
     return $status;
 }
开发者ID:rmiddle,项目名称:feg,代码行数:89,代码来源:Application.class.php

示例9: create

 static function create($fields)
 {
     $db = DevblocksPlatform::getDatabaseService();
     $id = $db->GenID('ticket_comment_seq');
     $sql = sprintf("INSERT INTO ticket_comment (id) " . "VALUES (%d)", $id);
     $db->Execute($sql);
     self::update($id, $fields);
     /* This event fires after the change takes place in the db,
      * which is important if the listener needs to stack changes
      */
     if (!empty($fields[self::TICKET_ID]) && !empty($fields[self::ADDRESS_ID]) && !empty($fields[self::COMMENT])) {
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('ticket.comment.create', array('comment_id' => $id, 'ticket_id' => $fields[self::TICKET_ID], 'address_id' => $fields[self::ADDRESS_ID], 'comment' => $fields[self::COMMENT])));
     }
     return $id;
 }
开发者ID:jsjohnst,项目名称:cerb4,代码行数:16,代码来源:DAO.class.php

示例10: setCustomerAccountNumberAction

 function setCustomerAccountNumberAction()
 {
     $db = DevblocksPlatform::getDatabaseService();
     @($account_number = DevblocksPlatform::importGPC($_REQUEST['acc_num'], 'string', ''));
     @($m_id = DevblocksPlatform::importGPC($_REQUEST['m_id'], 'string', ''));
     // Now Confirm the account exists and is active
     $account = array_shift(DAO_CustomerAccount::getWhere(sprintf("%s = %d AND %s = '0' ", DAO_CustomerAccount::ACCOUNT_NUMBER, $account_number, DAO_CustomerAccount::IS_DISABLED)));
     if (!isset($account)) {
         return;
     }
     $message_obj = DAO_Message::get($m_id);
     if (!isset($message_obj)) {
         return;
     }
     $fields = get_object_vars($message_obj);
     $fields[DAO_Message::ACCOUNT_ID] = $account->id;
     $fields[DAO_Message::IMPORT_STATUS] = 0;
     // Requeue
     $m_status = DAO_Message::update($m_id, $fields);
     // Give plugins a chance to note a message is assigned
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('message.account.assign', array('account_id' => $account->id, 'message_id' => $m_id)));
     echo json_encode($fields);
 }
开发者ID:rmiddle,项目名称:feg,代码行数:24,代码来源:customer_accounts.php

示例11: sendTicketMessage


//.........这里部分代码省略.........
         // Content
         DAO_MessageContent::create($message_id, $content);
         $headers = $mail->getHeaders();
         // Headers
         foreach ($headers->getAll() as $hdr) {
             if (null != ($hdr_val = $hdr->getFieldBody())) {
                 if (!empty($hdr_val)) {
                     DAO_MessageHeader::create($message_id, $hdr->getFieldName(), CerberusParser::fixQuotePrintableString($hdr_val));
                 }
             }
         }
         // Attachments
         if (is_array($files) && !empty($files)) {
             $attachment_path = APP_STORAGE_PATH . '/attachments/';
             reset($files);
             foreach ($files['tmp_name'] as $idx => $file) {
                 if (empty($file) || empty($files['name'][$idx]) || !file_exists($file)) {
                     continue;
                 }
                 $fields = array(DAO_Attachment::MESSAGE_ID => $message_id, DAO_Attachment::DISPLAY_NAME => $files['name'][$idx], DAO_Attachment::MIME_TYPE => $files['type'][$idx], DAO_Attachment::FILE_SIZE => filesize($file));
                 $file_id = DAO_Attachment::create($fields);
                 $attachment_bucket = sprintf("%03d/", mt_rand(1, 100));
                 $attachment_file = $file_id;
                 if (!file_exists($attachment_path . $attachment_bucket)) {
                     mkdir($attachment_path . $attachment_bucket, 0775, true);
                 }
                 if (!is_writeable($attachment_path . $attachment_bucket)) {
                     echo "Can't write to bucket " . $attachment_path . $attachment_bucket . "<BR>";
                 }
                 copy($file, $attachment_path . $attachment_bucket . $attachment_file);
                 @unlink($file);
                 DAO_Attachment::update($file_id, array(DAO_Attachment::FILEPATH => $attachment_bucket . $attachment_file));
             }
         }
         // add note to message if email failed
         if ($mail_succeeded === false) {
             $fields = array(DAO_MessageNote::MESSAGE_ID => $message_id, DAO_MessageNote::CREATED => time(), DAO_MessageNote::WORKER_ID => 0, DAO_MessageNote::CONTENT => 'Exception thrown while sending email: ' . $e->getMessage(), DAO_MessageNote::TYPE => Model_MessageNote::TYPE_ERROR);
             DAO_MessageNote::create($fields);
         }
     }
     // Post-Reply Change Properties
     if (isset($properties['closed'])) {
         switch ($properties['closed']) {
             case 0:
                 // open
                 $change_fields[DAO_Ticket::IS_WAITING] = 0;
                 $change_fields[DAO_Ticket::IS_CLOSED] = 0;
                 $change_fields[DAO_Ticket::IS_DELETED] = 0;
                 $change_fields[DAO_Ticket::DUE_DATE] = 0;
                 break;
             case 1:
                 // closed
                 $change_fields[DAO_Ticket::IS_WAITING] = 0;
                 $change_fields[DAO_Ticket::IS_CLOSED] = 1;
                 $change_fields[DAO_Ticket::IS_DELETED] = 0;
                 if (isset($properties['ticket_reopen'])) {
                     @($time = intval(strtotime($properties['ticket_reopen'])));
                     $change_fields[DAO_Ticket::DUE_DATE] = $time;
                 }
                 break;
             case 2:
                 // waiting
                 $change_fields[DAO_Ticket::IS_WAITING] = 1;
                 $change_fields[DAO_Ticket::IS_CLOSED] = 0;
                 $change_fields[DAO_Ticket::IS_DELETED] = 0;
                 if (isset($properties['ticket_reopen'])) {
                     @($time = intval(strtotime($properties['ticket_reopen'])));
                     $change_fields[DAO_Ticket::DUE_DATE] = $time;
                 }
                 break;
         }
     }
     // Who should handle the followup?
     if (isset($properties['next_worker_id'])) {
         $change_fields[DAO_Ticket::NEXT_WORKER_ID] = $properties['next_worker_id'];
     }
     // Allow anybody to reply after
     if (isset($properties['unlock_date']) && !empty($properties['unlock_date'])) {
         $unlock = strtotime($properties['unlock_date']);
         if (intval($unlock) > 0) {
             $change_fields[DAO_Ticket::UNLOCK_DATE] = $unlock;
         }
     }
     // Move
     if (!empty($properties['bucket_id'])) {
         // [TODO] Use API to move, or fire event
         // [TODO] Ensure team/bucket exist
         list($team_id, $bucket_id) = CerberusApplication::translateTeamCategoryCode($properties['bucket_id']);
         $change_fields[DAO_Ticket::TEAM_ID] = $team_id;
         $change_fields[DAO_Ticket::CATEGORY_ID] = $bucket_id;
     }
     if (!empty($ticket_id) && !empty($change_fields)) {
         DAO_Ticket::updateTicket($ticket_id, $change_fields);
     }
     // Outbound Reply Event (not automated reply, etc.)
     if (!empty($worker_id)) {
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('ticket.reply.outbound', array('ticket_id' => $ticket_id, 'worker_id' => $worker_id)));
     }
 }
开发者ID:Hildy,项目名称:cerb5,代码行数:101,代码来源:Mail.php

示例12: delete

 static function delete($ids)
 {
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $db = DevblocksPlatform::getDatabaseService();
     /*
      * Notify anything that wants to know when buckets delete.
      */
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('bucket.delete', array('bucket_ids' => $ids)));
     $sql = sprintf("DELETE QUICK FROM category WHERE id IN (%s)", implode(',', $ids));
     $db->Execute($sql) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
     /* @var $rs ADORecordSet */
     // Reset any tickets using this category
     $sql = sprintf("UPDATE ticket SET category_id = 0 WHERE category_id IN (%s)", implode(',', $ids));
     $db->Execute($sql) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
     /* @var $rs ADORecordSet */
     self::clearCache();
 }
开发者ID:joegeck,项目名称:cerb4,代码行数:20,代码来源:DAO.class.php

示例13: ExportSnpp

 function ExportSnpp(Model_ExportType $export_type)
 {
     $logger = DevblocksPlatform::getConsoleLog();
     $db = DevblocksPlatform::getDatabaseService();
     @($snpp_current_hour = 0);
     @($snpp_sent_today = 0);
     $memory_limit = ini_get('memory_limit');
     if (substr($memory_limit, 0, -1) < 128) {
         @ini_set('memory_limit', '128M');
     }
     @set_time_limit(0);
     // Unlimited (if possible)
     $logger->info("[SNPP Exporter] Overloaded memory_limit to: " . ini_get('memory_limit'));
     $logger->info("[SNPP Exporter] Overloaded max_execution_time to: " . ini_get('max_execution_time'));
     $timeout = ini_get('max_execution_time');
     $runtime = microtime(true);
     $sql = sprintf("SELECT mr.id " . "FROM message_recipient mr " . "inner join customer_recipient cr on mr.recipient_id = cr.id " . "WHERE mr.send_status in (0,3,4) " . "AND cr.is_disabled = 0 " . "AND cr.export_type = %d " . "AND cr.type = 2 ", $export_type->id);
     $rs = $db->Execute($sql);
     // Loop though pending outbound emails.
     while ($row = mysql_fetch_assoc($rs)) {
         $id = $row['id'];
         $logger->info("[SNPP Exporter] Procing MR ID: " . $id);
         $message_recipient = DAO_MessageRecipient::get($id);
         $message = DAO_Message::get($message_recipient->message_id);
         $message_lines = explode('\\n', substr($message->message, 1, -1));
         $recipient = DAO_CustomerRecipient::get($message_recipient->recipient_id);
         $message_str = substr(implode("", $message_lines), 0, 160);
         // FIXME - Need to add in filter for now everything is unfiltered.
         // sendSnpp($phone_number, $message, $snpp_server="ann100sms01.answernet.com", $port=444)
         $send_status = FegSnpp::sendSnpp($recipient->address, $message_str);
         $logger->info("[SNPP Exporter] Send Status: " . ($send_status ? "Successful" : "Failure"));
         // Give plugins a chance to run export
         $eventMgr = DevblocksPlatform::getEventService();
         $eventMgr->trigger(new Model_DevblocksEvent('cron.send.snpp', array('recipient' => $recipient, 'message' => $message, 'message_lines' => $message_lines, 'message_recipient' => $message_recipient, 'send_status' => $send_status)));
         if ($send_status) {
             $snpp_current_hour++;
             $snpp_sent_today++;
         }
         $fields = array(DAO_MessageRecipient::SEND_STATUS => $send_status ? 2 : 1, DAO_MessageRecipient::CLOSED_DATE => $send_status ? time() : 0);
         DAO_MessageRecipient::update($id, $fields);
     }
     mysql_free_result($rs);
     if ($snpp_current_hour) {
         $current_fields = DAO_Stats::get(0);
         $fields = array(DAO_Stats::SNPP_CURRENT_HOUR => $current_fields->snpp_current_hour + $snpp_current_hour, DAO_Stats::SNPP_SENT_TODAY => $current_fields->snpp_sent_today + $snpp_sent_today);
         DAO_Stats::update(0, $fields);
     }
     return NULL;
 }
开发者ID:rmiddle,项目名称:feg,代码行数:49,代码来源:cron.classes.php

示例14: _handleTicketMoved

 private function _handleTicketMoved($event)
 {
     @($ticket_ids = $event->params['ticket_ids']);
     @($changed_fields = $event->params['changed_fields']);
     if (!isset($changed_fields[DAO_Ticket::TEAM_ID])) {
         return;
     }
     @($team_id = $changed_fields[DAO_Ticket::TEAM_ID]);
     @($bucket_id = $changed_fields[DAO_Ticket::CATEGORY_ID]);
     $final_moves = array();
     // If we're landing in an inbox we need to check its filters
     if (!empty($ticket_ids) && !empty($team_id) && empty($bucket_id)) {
         // moving to an inbox
         if (is_array($ticket_ids)) {
             foreach ($ticket_ids as $ticket_id) {
                 // Run the new inbox filters
                 $matches = CerberusApplication::runGroupRouting($team_id, $ticket_id);
                 // If we matched no rules, we're stuck in the destination inbox.
                 if (empty($matches)) {
                     $final_moves[] = $ticket_id;
                 } else {
                     // If more inbox rules want to move this ticket don't consider this finished
                     if (is_array($matches)) {
                         foreach ($matches as $match) {
                             if (isset($match->actions['move'])) {
                                 // any moves
                                 break;
                             }
                             $final_moves[] = $ticket_id;
                         }
                     }
                 }
             }
         }
         // Anything dropping into a non-inbox bucket is done chain-moving
     } elseif (!empty($ticket_ids) && !empty($team_id) && !empty($bucket_id)) {
         $final_moves = $ticket_ids;
     }
     // Did we have any tickets finish chain-moving?
     if (!empty($final_moves)) {
         // Trigger an inbound event for all moves
         if (is_array($final_moves)) {
             foreach ($final_moves as $ticket_id) {
                 // Inbound Reply Event
                 $eventMgr = DevblocksPlatform::getEventService();
                 $eventMgr->trigger(new Model_DevblocksEvent('ticket.reply.inbound', array('ticket_id' => $ticket_id)));
             }
         }
     }
 }
开发者ID:jsjohnst,项目名称:cerb4,代码行数:50,代码来源:listeners.classes.php

示例15: setMessageStatusAction

 function setMessageStatusAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($status = DevblocksPlatform::importGPC($_REQUEST['status'], 'integer', 0));
     @($goto_recent = DevblocksPlatform::importGPC($_REQUEST['goto_recent'], 'integer', 0));
     $message_obj = DAO_Message::get($id);
     $fields = get_object_vars($message_obj);
     $fields[DAO_Message::IMPORT_STATUS] = $status;
     $mr_status = DAO_Message::update($id, $fields);
     // Give plugins a chance to note a message is imported.
     $eventMgr = DevblocksPlatform::getEventService();
     $eventMgr->trigger(new Model_DevblocksEvent('message.status', array('message_id' => $id, 'account_id' => $message_obj->account_id, 'import_status' => $status)));
     $status_text = $translate->_('feg.message.import_status_' . $status);
     if ($status_text == "") {
         $status_text = $translate->_('feg.message_recipient.status_unknown');
     }
     echo $status_text;
 }
开发者ID:rmiddle,项目名称:feg,代码行数:20,代码来源:customer.php


注:本文中的DevblocksPlatform::getEventService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。