function onSubmit($vals) { loader_import('cms.Workspace.Message'); $msg = new WorkspaceMessage(); if (!$vals['response_id']) { $vals['response_id'] = '0'; } $res = $msg->send($vals['subject'], $vals['body'], explode(',', $vals['recipients']), array(), $vals['response_id'], $vals['priority'], session_username()); if (!$res) { echo '<p>Error: ' . $msg->error . '</p>'; } session_set('sitellite_alert', intl_get('Your message has been sent.')); header('Location: ' . site_prefix() . '/index/cms-cpanel-action?_msg=sent'); exit; }
* * Transition is one of: * - add * - edit * * Action is one of: * - null: Document was added * - modify: Ordinary modifications (source and store) * - replace: A change was approved, overwriting the live version * - republish: A change was made as a draft, requiring approval * - update: Update to a draft that was republished */ loader_import('cms.Workspace.Message'); loader_import('cms.Versioning.Rex'); loader_import('multilingual.Translation'); $msg = new WorkspaceMessage(); $rex = new Rex($parameters['collection']); $tr = new Translation($parameters['collection']); if ($parameters['transition'] == 'add') { // 1. find the associated translator(s) and email them $users = db_shift_array('select username from sitellite_user where team = ? and role = "translator"', $parameters['data']['sitellite_team']); $url = sprintf('%s/index/multilingual-translate-form?_collection=%s&_key=%s', site_prefix(), $parameters['collection'], $parameters['key']); $msg->send(intl_get('New Translation Notice'), template_simple('services_translation_new.spt', array('url' => $url, 'changelog' => $parameters['changelog'], 'collection' => $rex->info['Collection']['display'], 'key' => $parameters['key'])), $users); } else { // 1. expire the translations $tr->expire($parameters['key']); // 2. find the associated translator(s) and email them $users = db_shift_array('select username from sitellite_user where team = ? and role = "translator"', $parameters['data']['sitellite_team']); $url = sprintf('%s/index/multilingual-translate-form?_collection=%s&_key=%s', site_prefix(), $parameters['collection'], $parameters['key']); $msg->send(intl_get('Translation Update Notice'), template_simple('services_translation_update.spt', array('url' => $url, 'changelog' => $parameters['changelog'], 'collection' => $rex->info['Collection']['display'], 'key' => $parameters['key'])), $users); }
/** * Replacement for mail() in Sitellite, using Sitellite's internal messaging * system instead. The first parameter is a username instead of an email address, * and the fourth is a sender's username instead of a From header. * * @access public * @param string * @param string * @param string * @param string * @return boolean */ function sitellite_mail($to_user, $subject, $body, $from_user = '') { loader_import('cms.Workspace.Message'); $msg = new WorkspaceMessage(); return $msg->send($subject, $body, $to_user, array(), 0, 'normal', $from_user); }
} else { foreach ($from_user as $u) { if (in_array($u->user, $list)) { $from_user = $u->user; break; } } } // remove self, add $res->from_user foreach ($list as $k => $v) { if ($v == $from_user) { unset($list[$k]); } } $list = array_unique($list); $id = $wmsg->send($subject, $body, $list, $attachments, $message_id, $priority, $from_user); if (!$id) { echo $wmsg->error . "\n"; } else { $pop3->removeMessage($number); } break; /* task * * comment(taskid,comment,user) * taskid => from subject * comment => body or parts w/ disposition != attachment * * attach(taskid,type,name,summary,body,mime,user) * taskid => from subject * type => always 'document'
* made. The only way you can undo changes in a service is by * using the cms.Versioning.Rex API if the collection in question * supports versioning (not all do). Also, you can, if necessary, * create further modifications to the document, also via the * Rex API. * * Transition is one of: * - add * - edit * * Action is one of: * - null: Document was added * - modify: Ordinary modifications (source and store) * - replace: A change was approved, overwriting the live version * - republish: A change was made as a draft, requiring approval * - update: Update to a draft that was republished */ loader_import('cms.Workspace.Message'); loader_import('cms.Versioning.Rex'); $msg = new WorkspaceMessage(); $rex = new Rex($parameters['collection']); if ($parameters['data']['sitellite_status'] == 'pending') { // find the associated editor(s) and email them $users = db_shift_array('select username from sitellite_user where team = ? and role = "editor"', $parameters['data']['sitellite_team']); $url = sprintf('%s/index/cms-edit-form?_collection=%s&_key=%s', site_prefix(), $parameters['collection'], $parameters['key']); $msg->send(intl_get('Pending Document Notice'), template_simple('services_notice_pending.spt', array('url' => $url, 'changelog' => $parameters['changelog'], 'collection' => $rex->info['Collection']['display'], 'key' => $parameters['key'])), $users); } elseif ($parameters['data']['sitellite_status'] == 'rejected') { // find the associated writer and email them $url = sprintf('%s/index/cms-edit-form?_collection=%s&_key=%s', site_prefix(), $parameters['collection'], $parameters['key']); $msg->send(intl_get('Rejected Document Notice'), template_simple('services_notice_rejected.spt', array('url' => $url, 'changelog' => $parameters['changelog'], 'collection' => $rex->info['Collection']['display'], 'key' => $parameters['key'])), $parameters['data']['sitellite_owner']); }
$from_user = $from_user->user; if (!in_array($from_user, $list)) { continue; // can't send if you didn't receive } } else { foreach ($from_user as $u) { if (in_array($u->user, $list)) { $from_user = $u->user; break; } } } // remove self, add $res->from_user foreach ($list as $k => $v) { if ($v == $from_user) { unset($list[$k]); } } $list = array_unique($list); // - subject based on subject of M{id} $subject = Workspace::createResponseSubject($res->subject); // send message $res = $m->send($subject, $body, $list, array(), $msg_id, 'normal', $from_user); if (!$res) { echo $m->error . NEWLINE; } } // end foreach $j->enable_logging = false; $j->Disconnect();