protected function takeChildFromDOM($child) { $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; switch ($absoluteNodeName) { case $this->lookupNamespace('app') . ':' . 'draft': $draft = new Draft(); $draft->transferFromDOM($child); $this->_draft = $draft; break; default: parent::takeChildFromDOM($child); break; } }
public static function destroy($id) { self::check_logged_in(); $hero = new Hero(array('id' => $id)); $yhteys = new Yhteys(array('hero_id' => $id)); $draftids = Yhteys::findDraftID($id); $yhteys->destroy(); while ($draftids != NULL) { $draft = new Draft(array('id' => $draftids->draft_id)); $draft->destroy(); $draftids = Yhteys::findDraftID($id); } $hero->destroy(); Redirect::to('/hero', array('message' => 'Hero on poistettu onnistuneesti!')); }
/** * Executes special page rendering and data processing * * @param $sub Mixed: MediaWiki supplied sub-page path * @throws PermissionsError */ public function execute($sub) { $out = $this->getOutput(); $user = $this->getUser(); $request = $this->getRequest(); // Begin output $this->setHeaders(); // Make sure the user is logged in if (!$user->isLoggedIn()) { throw new PermissionsError('read'); } // Handle discarding $draft = Draft::newFromID($request->getIntOrNull('discard')); if ($draft->exists()) { // Discard draft $draft->discard(); // Redirect to the article editor or view if returnto was set $section = $request->getIntOrNull('section'); $urlSection = $section !== null ? "§ion={$section}" : ''; switch ($request->getText('returnto')) { case 'edit': $title = Title::newFromDBKey($draft->getTitle()); $out->redirect(wfExpandURL($title->getEditURL() . $urlSection)); break; case 'view': $title = Title::newFromDBKey($draft->getTitle()); $out->redirect(wfExpandURL($title->getFullURL() . $urlSection)); break; } } // Show list of drafts, or a message that there are none if (Drafts::display() == 0) { $out->addWikiMsg('drafts-view-nonesaved'); } }
public function destroy($id) { if ($deleted = Draft::whereId($id)->delete()) { return Response::json(['success' => 'Draft successfully deleted'], 200); } else { return Response::json(['flash' => 'Server error'], 500); } }
function index() { list($params, $id) = $this->parse_params(func_get_args()); $theme = new Theme(); $themes = $theme->read(true); if ($this->method == 'post' && isset($_POST['theme'])) { $t = $_POST['theme']; if (isset($themes[$t])) { $d = new Draft(); $d->where('draft', 1)->update('draft', 0); $d->where('path', $t)->get(); $d->path = $t; $d->draft = 1; if (isset($_POST['refresh'])) { $d->init_draft_nav($_POST['refresh']); } $d->save(); $this->redirect('/drafts'); } else { // error } } else { if ($this->method == 'delete' && isset($_POST['theme'])) { $d = new Draft(); $d->where('path', $_POST['theme'])->get(); if ($d->exists()) { $d->delete(); } exit; } } $final = array(); $d = new Draft(); $drafts = $d->get_iterated(); foreach ($drafts as $d) { if (isset($themes[$d->path])) { $final[] = array('id' => $d->id, 'theme' => $themes[$d->path], 'published' => (bool) $d->current, 'active' => (bool) $d->draft, 'created_on' => (int) $d->created_on, 'modified_on' => (int) $d->modified_on); } } $this->set_response_data($final); }
public function form_urls() { if ($this->urls) { return $this->urls; } $d = new Draft(); $context = defined('DRAFT_CONTEXT') ? DRAFT_CONTEXT : false; $path = ''; if (!$context) { $d->where('current', 1)->get(); $path = $d->path; } else { if (is_numeric(DRAFT_CONTEXT)) { $d->get_by_id(DRAFT_CONTEXT); $path = $d->path; } else { $path = DRAFT_CONTEXT; } } list($this->urls, $this->url_data, , $this->segments) = $d->setup_urls(FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR); return $this->urls; }
public function execute() { if ($this->getUser()->isAnon()) { $this->dieUsage('You must be logged in to save drafts.', 'notloggedin'); } $params = $this->extractRequestParams(); $draft = Draft::newFromID($params['id']); $draft->setToken($params['drafttoken']); $draft->setTitle(Title::newFromText($params['title'])); $draft->setSection($params['section'] == '' ? null : $params['section']); $draft->setStartTime($params['starttime']); $draft->setEditTime($params['edittime']); $draft->setSaveTime(wfTimestampNow()); $draft->setScrollTop($params['scrolltop']); $draft->setText($params['text']); $draft->setSummary($params['summary']); $draft->setMinorEdit($params['minoredit']); $draft->save(); $this->getResult()->addValue(null, $this->getModuleName(), array('id' => $draft->getID())); }
/** * Executes special page rendering and data processing * * @param $sub Mixed: MediaWiki supplied sub-page path */ public function execute($sub) { global $wgRequest, $wgOut, $wgUser; // Begin output $this->setHeaders(); // Make sure the user is logged in if (!$wgUser->isLoggedIn()) { // If not, let them know they need to $wgOut->loginToUse(); // Continue return true; } // Handle discarding $draft = Draft::newFromID($wgRequest->getIntOrNull('discard')); if ($draft->exists()) { // Discard draft $draft->discard(); // Redirect to the article editor or view if returnto was set $section = $wgRequest->getIntOrNull('section'); $urlSection = $section !== null ? "§ion={$section}" : ''; switch ($wgRequest->getText('returnto')) { case 'edit': $title = Title::newFromDBKey($draft->getTitle()); $wgOut->redirect(wfExpandURL($title->getEditURL() . $urlSection)); break; case 'view': $title = Title::newFromDBKey($draft->getTitle()); $wgOut->redirect(wfExpandURL($title->getFullURL() . $urlSection)); break; } } // Show list of drafts, or a message that there are none if (Drafts::display() == 0) { $wgOut->addHTML(wfMsgHTML('drafts-view-nonesaved')); } }
} break; case 'create': if ($id = Canned::create($_POST, $errors)) { $msg = 'Canned response added successfully'; $_REQUEST['a'] = null; //Upload attachments if ($_FILES['attachments'] && ($c = Canned::lookup($id)) && ($files = AttachmentFile::format($_FILES['attachments']))) { $c->attachments->upload($files); } // Attach inline attachments from the editor if (isset($_POST['draft_id']) && ($draft = Draft::lookup($_POST['draft_id']))) { $c->attachments->upload($draft->getAttachmentIds($_POST['response']), true); } // Delete this user's drafts for new canned-responses Draft::deleteForNamespace('canned', $thisstaff->getId()); } elseif (!$errors['err']) { $errors['err'] = 'Unable to add canned response. Correct error(s) below and try again.'; } break; case 'mass_process': if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { $errors['err'] = 'You must select at least one canned response'; } else { $count = count($_POST['ids']); switch (strtolower($_POST['a'])) { case 'enable': $sql = 'UPDATE ' . CANNED_TABLE . ' SET isenabled=1 ' . ' WHERE canned_id IN (' . implode(',', db_input($_POST['ids'])) . ')'; if (db_query($sql) && ($num = db_affected_rows())) { if ($num == $count) { $msg = 'Selected canned responses enabled';
function sendDraft($p) { $email = XML_RPC_decode($p->getParam(0)); $password = XML_RPC_decode($p->getParam(1)); $auth = authenticate($email, $password); if (is_object($auth)) { return $auth; } $issue_id = XML_RPC_decode($p->getParam(2)); $draft_id = XML_RPC_decode($p->getParam(3)); $draft = Draft::getDraftBySequence($issue_id, $draft_id); createFakeCookie($email, Issue::getProjectID($issue_id)); if (count($draft) < 1 || !is_array($draft)) { return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Draft #" . $draft_id . " does not exist for issue #{$issue_id}"); } $res = Draft::send($draft["emd_id"]); if ($res == 1) { return new XML_RPC_Response(XML_RPC_Encode("Draft #" . $draft_id . " sent successfully.\n")); } else { return new XML_RPC_Response(0, $XML_RPC_erruser + 1, "Error sending Draft #" . $draft_id . "\n"); } }
function add($vars, &$errors) { $inst = self::lookup(self::create($vars, $errors)); // Inline images (attached to the draft) if ($inst) { $inst->attachments->upload(Draft::getAttachmentIds($inst->getBody()), true); } return $inst; }
/** * Loads data from the I18N_DIR for the target language into the * database. This is intended to be done at the time of installation; * however, care should be taken in this process to ensure that the * process could be repeated if an administrator wanted to change the * system language and reload the data. */ function loadDefaultData() { # notrans -- do not translate the contents of this array $models = array('department.yaml' => 'Dept::create', 'sla.yaml' => 'SLA::create', 'form.yaml' => 'DynamicForm::create', 'list.yaml' => 'DynamicList::create', 'help_topic.yaml' => 'Topic::create', 'filter.yaml' => 'Filter::create', 'team.yaml' => 'Team::create', 'organization.yaml' => 'Organization::__create', 'ticket_status.yaml' => 'TicketStatus::__create', 'group.yaml' => 'Group::create', 'file.yaml' => 'AttachmentFile::create', 'sequence.yaml' => 'Sequence::__create'); $errors = array(); foreach ($models as $yaml => $m) { if ($objects = $this->getTemplate($yaml)->getData()) { foreach ($objects as $o) { if ($m && is_callable($m)) { @call_user_func_array($m, array($o, &$errors)); } // TODO: Add a warning to the success page for errors // found here $errors = array(); } } } // Priorities $priorities = $this->getTemplate('priority.yaml')->getData(); foreach ($priorities as $name => $info) { $sql = 'INSERT INTO ' . PRIORITY_TABLE . ' SET priority=' . db_input($name) . ', priority_id=' . db_input($info['priority_id']) . ', priority_desc=' . db_input($info['priority_desc']) . ', priority_color=' . db_input($info['priority_color']) . ', priority_urgency=' . db_input($info['priority_urgency']); db_query($sql); } // Configuration require_once INCLUDE_DIR . 'class.config.php'; if (($tpl = $this->getTemplate('config.yaml')) && ($data = $tpl->getData())) { foreach ($data as $section => $items) { $_config = new Config($section); foreach ($items as $key => $value) { $_config->set($key, $value); } } } // Load core config $_config = new OsticketConfig(); // Determine reasonable default max_file_size $max_size = Format::filesize2bytes(strtoupper(ini_get('upload_max_filesize'))); $val = (int) $max_size / 2; $po2 = 1; while ($po2 < $val) { $po2 <<= 1; } $_config->set('max_file_size', $po2); // Pages and content foreach (array('landing', 'thank-you', 'offline', 'registration-staff', 'pwreset-staff', 'banner-staff', 'registration-client', 'pwreset-client', 'banner-client', 'registration-confirm', 'registration-thanks', 'access-link') as $type) { $tpl = $this->getTemplate("templates/page/{$type}.yaml"); if (!($page = $tpl->getData())) { continue; } $sql = 'INSERT INTO ' . PAGE_TABLE . ' SET type=' . db_input($type) . ', name=' . db_input($page['name']) . ', body=' . db_input($page['body']) . ', lang=' . db_input($tpl->getLang()) . ', notes=' . db_input($page['notes']) . ', created=NOW(), updated=NOW(), isactive=1'; if (db_query($sql) && ($id = db_insert_id()) && in_array($type, array('landing', 'thank-you', 'offline'))) { $_config->set("{$type}_page_id", $id); } } // Default Language $_config->set('system_language', $this->langs[0]); // content_id defaults to the `id` field value db_query('UPDATE ' . PAGE_TABLE . ' SET content_id=id'); // Canned response examples if (($tpl = $this->getTemplate('templates/premade.yaml')) && ($canned = $tpl->getData())) { foreach ($canned as $c) { if (($id = Canned::create($c, $errors)) && isset($c['attachments'])) { $premade = Canned::lookup($id); foreach ($c['attachments'] as $a) { $premade->attachments->save($a, false); } } } } // Email templates // TODO: Lookup tpl_id if ($objects = $this->getTemplate('email_template_group.yaml')->getData()) { foreach ($objects as $o) { $o['lang_id'] = $this->langs[0]; $tpl = EmailTemplateGroup::create($o, $errors); } } // This shouldn't be necessary $tpl = EmailTemplateGroup::lookup(1); foreach ($tpl::$all_names as $name => $info) { if (($tp = $this->getTemplate("templates/email/{$name}.yaml")) && ($t = $tp->getData())) { $t['tpl_id'] = $tpl->getId(); $t['code_name'] = $name; $id = EmailTemplate::create($t, $errors); if ($id && ($template = EmailTemplate::lookup($id)) && ($ids = Draft::getAttachmentIds($t['body']))) { $template->attachments->upload($ids, true); } } } }
if (!$_POST['email_id'] || !($email = Email::lookup($_POST['email_id']))) { $errors['email_id'] = __('Select from email address'); } if (!$_POST['email'] || !Validator::is_email($_POST['email'])) { $errors['email'] = __('To email address required'); } if (!$_POST['subj']) { $errors['subj'] = __('Subject required'); } if (!$_POST['message']) { $errors['message'] = __('Message required'); } if (!$errors && $email) { if ($email->send($_POST['email'], $_POST['subj'], Format::sanitize($_POST['message']), null, array('reply-tag' => false))) { $msg = Format::htmlchars(sprintf(__('Test email sent successfully to <%s>'), $_POST['email'])); Draft::deleteForNamespace('email.diag'); } else { $errors['err'] = __('Error sending email - try again.'); } } elseif ($errors['err']) { $errors['err'] = __('Error sending email - try again.'); } } $info = Format::htmlchars($errors && $_POST ? $_POST : $info); $nav->setTabActive('emails'); $ost->addExtraHeader('<meta name="tip-namespace" content="emails.diagnostic" />', "\$('#content').data('tipNamespace', '" . $tip_namespace . "');"); require STAFFINC_DIR . 'header.inc.php'; ?> <form action="emailtest.php" method="post" id="save"> <?php csrf_token();
} elseif($cfg->isCaptchaEnabled()) { if(!$_POST['captcha']) $errors['captcha']=__('Enter text shown on the image'); elseif(strcmp($_SESSION['captcha'], md5(strtoupper($_POST['captcha'])))) $errors['captcha']=__('Invalid - try again!'); } $tform = TicketForm::objects()->one()->getForm($vars); $messageField = $tform->getField('message'); $attachments = $messageField->getWidget()->getAttachments(); if (!$errors && $messageField->isAttachmentsEnabled()) $vars['cannedattachments'] = $attachments->getClean(); // Drop the draft.. If there are validation errors, the content // submitted will be displayed back to the user Draft::deleteForNamespace('ticket.client.'.substr(session_id(), -12)); //Ticket::create...checks for errors.. if(($ticket=Ticket::create($vars, $errors, SOURCE))){ $msg=__('Support ticket request created'); // Drop session-backed form data unset($_SESSION[':form-data']); //Logged in...simply view the newly created ticket. if($thisclient && $thisclient->isValid()) { session_write_close(); session_regenerate_id(); @header('Location: tickets.php?id='.$ticket->getId()); } }else{ $errors['err']=$errors['err']?$errors['err']:__('Unable to create a ticket. Please correct errors below and try again!'); } }
private function draftActivity() { $sql = "SELECT\n {{%email_draft}}.*,\n iss_summary,\n sta_color\n FROM\n {{%email_draft}},\n {{%issue}},\n {{%status}}\n WHERE\n iss_sta_id = sta_id AND\n emd_iss_id = iss_id AND\n iss_prj_id = ? AND\n"; $params = array($this->prj_id); $this->createWhereClause($sql, $params, 'emd_updated_date', 'emd_usr_id'); $res = DB_Helper::getInstance()->getAll($sql, $params); $this->processResult($res, 'emd_updated_date', 'emd_iss_id'); foreach ($res as &$draft) { if (!empty($draft['emd_unknown_user'])) { $draft['from'] = $draft['emd_unknown_user']; } else { $draft['from'] = User::getFromHeader($draft['emd_usr_id']); } list($draft['to']) = Draft::getEmailRecipients($draft['emd_id']); if (empty($draft['to'])) { $draft['to'] = 'Notification List'; } } return $res; }
public function destroy_draft($dummy) { $selected = Input::get('selected'); $draft = Draft::whereIn('id', $selected)->delete(); return Response::json(array('success' => 'The selected drafts have been successfully destroyed.')); }
/** * Selects a draft from the table and returns the contents. * * @param string $id The ID of this draft. * @return A string containing the note. */ function getDraft($id) { $info = Draft::getDetails($id); if (!Issue::canAccess($info['emd_iss_id'], $GLOBALS['usr_id'])) { return ''; } if (empty($_GET['ec_id'])) { return $info['emd_body']; } return Link_Filter::processText(Auth::getCurrentProject(), nl2br(htmlspecialchars($info['emd_body']))); }
} elseif ($cat == 'update_draft') { $res = Draft::update($issue_id, $_POST['draft_id'], $_POST['to'], $_POST['cc'], $_POST['subject'], $_POST['message'], $_POST['parent_id']); $tpl->assign('draft_result', $res); } // enter the time tracking entry about this new email if ($cat == 'save_draft' || $cat == 'update_draft') { if (!empty($_POST['time_spent'])) { $date = (array) $_POST['date']; $ttc_id = Time_Tracking::getCategoryId($prj_id, 'Email Discussion'); $time_spent = (int) $_POST['time_spent']; $summary = 'Time entry inserted when saving an email draft.'; Time_Tracking::addTimeEntry($issue_id, $ttc_id, $time_spent, $date, $summary); } } if ($cat == 'view_draft') { $draft = Draft::getDetails($_GET['id']); $email = array('sup_subject' => $draft['emd_subject'], 'seb_body' => $draft['emd_body'], 'sup_from' => $draft['to'], 'cc' => implode('; ', $draft['cc'])); // try to guess the correct email account to be associated with this email if (!empty($draft['emd_sup_id'])) { $_GET['ema_id'] = Email_Account::getAccountByEmail($draft['emd_sup_id']); } else { // if we are not replying to an existing message, just get the first email account you can find... $_GET['ema_id'] = Email_Account::getEmailAccount(); } $tpl->assign(array('draft_id' => $_GET['id'], 'email' => $email, 'parent_email_id' => $draft['emd_sup_id'], 'draft_status' => $draft['emd_status'])); if ($draft['emd_status'] != 'pending') { $tpl->assign('read_only', 1); } } elseif ($cat == 'create_draft') { $tpl->assign('hide_email_buttons', 'yes'); } else {
Route::get('dashboard/emails/{id}/forward', 'EmailController@forward'); Route::resource('dashboard/emails-resource/sent', 'SentEmailResourceController'); Route::get('dashboard/emails-custom/share/{id}', 'SentEmailCustomController@share'); Route::get('dashboard/emails-custom/pdf/{id}', 'SentEmailCustomController@pdf'); Route::get('dashboard/emails/drafts', 'EmailController@drafts'); Route::get('dashboard/emails/drafts/{id}/edit', 'EmailController@edit_draft'); Route::resource('dashboard/emails-resource/drafts', 'DraftResourceController'); Route::get('dashboard/emails/trash', 'EmailController@trash'); Route::resource('dashboard/emails-resource/trash', 'TrashResourceController'); Route::get('email/backend-show/{id}', function ($id) { if ($email = Email::find($id)) { } return View::make('backend.emails.send_templates.backend-show', ['email_body' => $email->email_body, 'email_id' => $id]); }); Route::get('draft/backend-show/{id}', function ($id) { if ($email = Draft::find($id)) { } return View::make('backend.emails.send_templates.backend-draft-show', ['email_body' => $email->email_body, 'email_id' => $id]); }); /*****************PAGES*******************/ Route::get('dashboard/pages', 'PageController@index'); Route::get('dashboard/pages/trash', 'PageController@deleted_pages'); Route::get('dashboard/pages/create', 'PageController@create'); Route::get('dashboard/pages/{id}/edit', 'PageController@edit'); Route::get('dashboard/pages/{id}/delete', 'PageController@delete'); Route::get('dashboard/pages/{id}/restore', 'PageController@restore'); Route::get('dashboard/pages/{id}/destroy', 'PageController@destroy'); /*****************TAGS************************************/ Route::get('dashboard/tags', 'TagController@index'); Route::get('dashboard/tags/create', 'TagController@create'); Route::get('dashboard/tags/{id}/edit', 'TagController@edit');
if(!$errors) { //Everything checked out...do the magic. $vars = array( 'userId' => $thisclient->getId(), 'poster' => (string) $thisclient->getName(), 'message' => $_POST['message']); $vars['cannedattachments'] = $attachments->getClean(); if (isset($_POST['draft_id'])) $vars['draft_id'] = $_POST['draft_id']; if(($msgid=$ticket->postMessage($vars, 'Web'))) { $msg=__('Message Posted Successfully'); // Cleanup drafts for the ticket. If not closed, only clean // for this staff. Else clean all drafts for the ticket. Draft::deleteForNamespace('ticket.client.' . $ticket->getId()); // Drop attachments $attachments->reset(); $tform->setSource(array()); } else { $errors['err']=__('Unable to post the message. Try again'); } } elseif(!$errors['err']) { $errors['err']=__('Error(s) occurred. Please try again'); } break; default: $errors['err']=__('Unknown action'); } $ticket->reload();
public static function listDrafts(&$title = null, $user = null) { global $wgOut, $wgRequest, $wgUser, $wgLang; //added twice? $wgOut->addScript('<style type="text/css" media="all">/*<![CDATA[*/ @import "' . wfGetPad('/extensions/min/f/extensions/Drafts/Drafts.css?rev=') . WH_SITEREV . '"; /*]]>*/</style>'); // Get draftID $currentDraft = Draft::newFromID($wgRequest->getIntOrNull('draft')); //based on user preference $adv = $wgUser->getOption('defaulteditor', '') == 'advanced' ? '&advanced=true' : ''; // Output HTML for list of drafts $drafts = Draft::getDrafts($title, $user); if (count($drafts) > 0) { global $egDraftsLifeSpan; // Internationalization wfLoadExtensionMessages('Drafts'); // Add a summary, on Special:Drafts only if (!$title || $title->getNamespace() == NS_SPECIAL) { $wgOut->wrapWikiMsg('<div class="mw-drafts-summary">$1</div>', array('drafts-view-summary', $wgLang->formatNum($egDraftsLifeSpan))); } // Build XML $wgOut->addHTML(Xml::openElement('table', array('cellpadding' => 5, 'cellspacing' => 0, 'border' => 0, 'id' => 'drafts-list-table', 'class' => 'section_text', 'style' => 'margin-top:15px'))); $wgOut->addHTML(Xml::openElement('tr')); $wgOut->addHTML(Xml::element('th', array('align' => 'left', 'nowrap' => 'nowrap', 'style' => 'text-align:center;'), wfMsg('drafts-view-article'))); $wgOut->addHTML(Xml::element('th', array('align' => 'left', 'nowrap' => 'nowrap', 'style' => 'text-align:center;'), wfMsg('drafts-view-saved'))); $wgOut->addHTML(Xml::element('th', array(), wfMsg('edit'))); $wgOut->addHTML(Xml::element('th', array(), wfMsg('discard'))); $wgOut->addHTML(Xml::closeElement('tr')); // Add existing drafts for this page and user $index = 0; foreach ($drafts as $draft) { // Get article title text $htmlTitle = $draft->getTitle()->getEscapedText(); // Build Article Load link if ($draft->getHTML5()) { $params = 'h5e=true&draft=' . urlencode($draft->getID()); if ($draft->getTitle()->getArticleID() == 0) { $params .= "&create-new-article=true"; } $urlLoad = $draft->getTitle()->getFullUrl($params); } else { $urlLoad = $draft->getTitle()->getFullUrl('action=edit' . $adv . '&draft=' . urlencode($draft->getID())); } // Build discard link $urlDiscard = sprintf('%s?discard=%s&token=%s', SpecialPage::getTitleFor('Drafts')->getFullUrl(), urlencode($draft->getID()), urlencode($wgUser->editToken())); // If in edit mode, return to editor if ($wgRequest->getText('action') == 'edit' || $wgRequest->getText('action') == 'submit') { $urlDiscard .= '&returnto=' . urlencode('edit'); } // Append section to titles and links if ($draft->getSection() !== null) { // Detect section name $lines = explode("\n", $draft->getText()); // If there is any content in the section if (count($lines) > 0) { $htmlTitle .= '#' . htmlspecialchars(trim(trim(substr($lines[0], 0, 255), '='))); } // Modify article link and title $urlLoad .= '§ion=' . urlencode($draft->getSection()); $urlDiscard .= '§ion=' . urlencode($draft->getSection()); } // Build XML if ($index % 2 == 1) { $wgOut->addHTML(Xml::openElement('tr', array('style' => 'background: #eee;'))); } else { $wgOut->addHTML(Xml::openElement('tr', array('style' => ''))); } $wgOut->addHTML(Xml::openElement('td', array('align' => 'left', 'class' => 'draftpage'))); $wgOut->addHTML(Xml::element('a', array('href' => $urlLoad, 'style' => 'font-weight:' . ($currentDraft->getID() == $draft->getID() ? 'bold' : 'normal')), $htmlTitle)); $wgOut->addHTML(Xml::closeElement('td')); $wgOut->addHTML(Xml::element('td', array('align' => 'left', 'nowrap' => 'nowrap', 'class' => 'draftsaved'), $wgLang->timeanddate($draft->getSaveTime(), true))); // edit link $wgOut->addHTML(Xml::openElement('td', array('align' => 'left', 'nowrap' => 'nowrap', 'class' => 'draftedit'))); $wgOut->addHTML(Xml::element('a', array('href' => $urlLoad), wfMsg('edit'))); $wgOut->addHTML(Xml::closeElement('td')); $wgOut->addHTML(Xml::openElement('td', array('align' => 'left', 'nowrap' => 'nowrap', 'class' => 'draftdiscard'))); $wgOut->addHTML(Xml::element('a', array('href' => $urlDiscard, 'onclick' => "if( true || !wgAjaxSaveDraft.insync ) return confirm('" . Xml::escapeJsString(wfMsgHTML('drafts-discard-warn', $draft->getTitle()->getText())) . "')"), wfMsg('drafts-view-discard'))); $wgOut->addHTML(Xml::closeElement('td')); $wgOut->addHTML(Xml::closeElement('tr')); $index++; } $wgOut->addHTML(Xml::closeElement('table')); // Return number of drafts return count($drafts); } return 0; }
/** * save the proposal as a draft */ public function create_draft() { $draft = new Draft; $draft->proposal = $this->id; $draft->title = $this->title; $draft->content = $this->content; $draft->reason = $this->reason; if (Login::$member) { $draft->author = Login::$member->id; } else { // admin $draft->author = null; } $draft->create(); }
function add($vars, &$errors) { if (!($id = self::create($vars, $errors))) { return false; } if ($faq = self::lookup($id)) { $faq->updateTopics($vars['topics']); if ($_FILES['attachments'] && ($files = AttachmentFile::format($_FILES['attachments']))) { $faq->attachments->upload($files); } // Inline images (attached to the draft) if (isset($vars['draft_id']) && $vars['draft_id']) { if ($draft = Draft::lookup($vars['draft_id'])) { $faq->attachments->upload($draft->getAttachmentIds(), true); } } $faq->reload(); } return $faq; }
/** * @param int $issue_id * @param int $draft_id * @return string * @access protected */ public function sendDraft($issue_id, $draft_id) { $draft = Draft::getDraftBySequence($issue_id, $draft_id); AuthCookie::setProjectCookie(Issue::getProjectID($issue_id)); if (count($draft) < 1 || !is_array($draft)) { throw new RemoteApiException('Draft #' . $draft_id . " does not exist for issue #{$issue_id}"); } $res = Draft::send($draft['emd_id']); if ($res == 1) { return "Draft #{$draft_id} sent successfully.\n"; } throw new RemoteApiException('Error sending Draft #' . $draft_id . "\n"); }
function PurgeDrafts() { require_once INCLUDE_DIR . 'class.draft.php'; Draft::cleanup(); }
function publish($draft_id = false) { if (!$draft_id) { $this->error('400', 'Draft ID parameter not present.'); return; } if ($this->method === 'post') { $draft = new Draft(); $draft->where('id', $draft_id)->get(); if ($draft->exists()) { $draft->where('current', 1)->update('current', 0); $draft->live_data = $draft->data; $draft->current = 1; $draft->save(); $guid = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $draft->path . DIRECTORY_SEPARATOR . 'koken.guid'; if (file_exists($guid)) { $s = new Setting(); $s->where('name', 'uuid')->get(); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, KOKEN_STORE_URL . '/register?uuid=' . $s->value . '&theme=' . trim(file_get_contents($guid))); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $r = curl_exec($curl); curl_close($curl); } exit; } else { $this->error('404', "Draft not found."); return; } } else { $this->error('400', 'This endpoint only accepts tokenized POST requests.'); return; } }
/** * Converts a note to a draft or an email * * @param int $note_id The id of the note * @param string $target What the note should be converted too (email, etc) * @param bool $authorize_sender If $authorize_sender If the sender should be added to authorized senders list. * @return int */ public static function convertNote($note_id, $target, $authorize_sender = false) { $issue_id = self::getIssueID($note_id); $email_account_id = Email_Account::getEmailAccount(); $blocked_message = self::getBlockedMessage($note_id); $unknown_user = self::getUnknownUser($note_id); $structure = Mime_Helper::decode($blocked_message, true, true); $body = $structure->body; $sender_email = strtolower(Mail_Helper::getEmailAddress($structure->headers['from'])); $current_usr_id = Auth::getUserID(); if ($target == 'email') { if (Mime_Helper::hasAttachments($structure)) { $has_attachments = 1; } else { $has_attachments = 0; } list($blocked_message, $headers) = Mail_Helper::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers); $t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_Helper::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$blocked_message, 'has_attachment' => $has_attachments, 'headers' => $headers); // need to check for a possible customer association if (!empty($structure->headers['from'])) { $details = Email_Account::getDetails($email_account_id); // check from the associated project if we need to lookup any customers by this email address if (CRM::hasCustomerIntegration($details['ema_prj_id'])) { $crm = CRM::getInstance($details['ema_prj_id']); // check for any customer contact association try { $contact = $crm->getContactByEmail($sender_email); $issue_contract = $crm->getContract(Issue::getContractID($issue_id)); if ($contact->canAccessContract($issue_contract)) { $t['customer_id'] = $issue_contract->getCustomerID(); } } catch (CRMException $e) { } } } if (empty($t['customer_id'])) { $update_type = 'staff response'; $t['customer_id'] = null; } else { $update_type = 'customer action'; } $res = Support::insertEmail($t, $structure, $sup_id); if ($res != -1) { Support::extractAttachments($issue_id, $structure); // notifications about new emails are always external $internal_only = false; // special case when emails are bounced back, so we don't want to notify the customer about those if (Notification::isBounceMessage($sender_email)) { $internal_only = true; } Notification::notifyNewEmail($current_usr_id, $issue_id, $t, $internal_only, false, '', $sup_id); Issue::markAsUpdated($issue_id, $update_type); self::remove($note_id, false); History::add($issue_id, $current_usr_id, 'note_converted_email', 'Note converted to e-mail (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id))); // now add sender as an authorized replier if ($authorize_sender) { Authorized_Replier::manualInsert($issue_id, @$structure->headers['from']); } } return $res; } // save message as a draft $res = Draft::saveEmail($issue_id, $structure->headers['to'], $structure->headers['cc'], $structure->headers['subject'], $body, false, $unknown_user); // remove the note, if the draft was created successfully if ($res) { self::remove($note_id, false); $usr_id = $current_usr_id; History::add($issue_id, $usr_id, 'note_converted_draft', 'Note converted to draft (from: {from}) by {user}', array('from' => @$structure->headers['from'], 'user' => User::getFullName($current_usr_id))); } return $res; }
switch ($_POST['a']) { case 'open': $ticket = null; if (!$thisstaff || !$thisstaff->canCreateTickets()) { $errors['err'] = sprintf('%s %s', sprintf(__('You do not have permission %s.'), __('to create tickets')), __('Contact admin for such access')); } else { $vars = $_POST; $vars['uid'] = $user ? $user->getId() : 0; $vars['cannedattachments'] = $response_form->getField('attachments')->getClean(); if ($ticket = Ticket::open($vars, $errors)) { $msg = __('Ticket created successfully'); $_REQUEST['a'] = null; if (!$ticket->checkStaffAccess($thisstaff) || $ticket->isClosed()) { $ticket = null; } Draft::deleteForNamespace('ticket.staff%', $thisstaff->getId()); // Drop files from the response attachments widget $response_form->setSource(array()); $response_form->getField('attachments')->reset(); unset($_SESSION[':form-data']); } elseif (!$errors['err']) { $errors['err'] = __('Unable to create the ticket. Correct the error(s) and try again'); } } break; } } if (!$errors) { $thisstaff->resetStats(); } //We'll need to reflect any changes just made!
function lookup($id) { return $id && is_numeric($id) && ($d = new Draft($id)) && $d->getId() == $id ? $d : null; }
function deleteDrafts() { Draft::deleteForNamespace('ticket.%.' . $this->getId()); }