function action_create_from_url($input) { Services_Exception_Disabled::check('page_content_fetch'); Services_Exception_Denied::checkGlobal('edit_article'); $id = null; $title = null; $url = $input->url->url(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && $url) { $lib = TikiLib::lib('pagecontent'); $data = $lib->grabContent($url); if (!$data) { throw new Services_Exception_FieldError($input->errorfield->text() ?: 'url', tr('Content could not be loaded.')); } $data['content'] = trim($data['content']) == '' ? $data['content'] : '~np~' . $data['content'] . '~/np~'; $data['description'] = ''; $data['author'] = ''; $topicId = $input->topicId->int(); $articleType = $input->type->text(); $title = $data['title']; $hash = md5($data['title'] . $data['description'] . $data['content']); $id = TikiDb::get()->table('tiki_articles')->fetchOne('articleId', array('linkto' => $url)) ?: 0; if (!$id) { $tikilib = TikiLib::lib('tiki'); $publication = $tikilib->now; $expire = $publication + 3600 * 24 * 365; $rating = 10; $artlib = TikiLib::lib('art'); $id = $artlib->replace_article($title, $data['author'], $topicId, 'n', '', 0, '', '', $data['description'], $data['content'], $publication, $expire, $GLOBALS['user'], $id, 0, 0, $articleType, '', '', $url, '', '', $rating, 'n', '', '', '', '', 'y', true); } } $db = TikiDb::get(); $topics = $db->table('tiki_topics')->fetchMap('topicId', 'name', array(), -1, -1, 'name_asc'); $types = $db->table('tiki_article_types')->fetchColumn('type', array()); return ['title' => tr('Create article from URL'), 'url' => $url, 'id' => $id, 'articleTitle' => $title, 'topics' => $topics, 'types' => $types]; }
function setUp() { global $user; Services_Exception_Disabled::check('conditions_enabled'); if (!$user) { throw new Services_Exception_Denied(tr('Authentication required.')); } }
function setUp() { $this->utilities = new Services_Workspace_Utilities(); Services_Exception_Disabled::check('workspace_ui'); Services_Exception_Disabled::check('feature_perspective'); Services_Exception_Disabled::check('namespace_enabled'); Services_Exception_Disabled::check('feature_categories'); }
function setUp() { Services_Exception_Disabled::check('feature_mailin'); $perms = Perms::get(); if (!$perms->admin_mailin) { throw new Services_Exception_Denied(tr('Reserved for administrators.')); } }
function setUp() { global $user; Services_Exception_Disabled::check('feature_friends'); if (!$user) { throw new Services_Exception_Denied(tr('Must be registered')); } $this->lib = TikiLib::lib('social'); }
function action_translate($input) { Services_Exception_Disabled::check('feature_machine_translation'); global $prefs; $content = $input->content->rawhtml_unsafe(); if (!empty($input->lang->text())) { $lang = $input->lang->text(); } else { $lang = $prefs['language']; } $factory = new Multilingual_MachineTranslation(); $impl = $factory->getDetectImplementation($lang); $content = $impl->translateText($content); return array('content' => $content, 'target' => $lang); }
function action_save_structure($input) { Services_Exception_Disabled::check('feature_wiki_structure'); $data = json_decode($input->data->text()); if ($data) { global $structlib; include_once 'lib/structures/structlib.php'; $structlib->reorder_structure($data); $params = json_decode($input->params->text()); $_GET = array(); // self_link and query objects used by get_toc adds all this request data to the action links $_POST = array(); $html = $structlib->get_toc($params->page_ref_id, $params->order, $params->showdesc, $params->numbering, $params->numberPrefix, $params->type, $params->page, $params->maxdepth, $params->structurePageName); } return array('html' => $html); }
/** * Translations in the database will be merged with the other translations in language.php. Note that after writing translations to language.php they are removed from the database. * @param $input * @return language.php file */ function action_write_to_language_php($input) { //check preference Services_Exception_Disabled::check('lang_use_db'); //check permissions $perms = Perms::get('tiki'); if (!$perms->tiki_p_edit_languages) { throw new Services_Exception_Denied(tr('Permission denied')); } //get language from input $language = $input->language->text(); //prepare language list -> seems useless... $langLib = TikiLib::lib('language'); $db_languages = $langLib->getDbTranslatedLanguages(); $db_languages = $langLib->format_language_list($db_languages); //get count of available translations in the database $db_translation_count = $this->getDbTranslationCount($language); //check if lang directory is writable for the selected language $langIsWritable = $this->checkLangIsWritable($language); if ($langIsWritable === false) { throw new Services_Exception_Denied(tr('lang/$language directory is not writable')); } //get the language file string so that it can be displayed $langDir = $this->getLanguageDirectory($language); $langFile = $langDir . 'language.php'; $confirm = $input->confirm->int(); if ($confirm) { //set export language $export_language = new LanguageTranslations($language); //write to language.php try { $stats = $export_language->writeLanguageFile(); } catch (Exception $e) { //TODO: this is messy $smarty->assign('msg', $e->getMessage()); $smarty->display('error.tpl'); die; } //TODO: expose expmsg properly $expmsg = sprintf(tra('Wrote %d new strings and updated %d to lang/%s/language.php'), $stats['new'], $stats['modif'], $export_language->lang); } return array('title' => tr('Write to language.php'), 'language' => $language, 'db_languages' => $db_languages, 'db_translation_count' => $db_translation_count, 'langIsWritable' => $langIsWritable, 'langFile' => $langFile); }
function action_save_structure($input) { Services_Exception_Disabled::check('feature_wiki_structure'); $data = json_decode($input->data->text()); if ($data) { $structlib = TikiLib::lib('struct'); $structlib->reorder_structure($data); $params = json_decode($input->params->text()); $_GET = array(); // self_link and query objects used by get_toc adds all this request data to the action links $_POST = array(); $html = $structlib->get_toc($params->page_ref_id, $params->order, $params->showdesc, $params->numbering, $params->numberPrefix, $params->type, $params->page, $params->maxdepth, $params->structurePageName); //Empty structure caches to refresh structure data in menu module. Seems better to empty cache for any possible subnodes, might make it a bit slow $cachelib = TikiLib::lib('cache'); $structurePages = array(); $structurePages = $structlib->s_get_structure_pages($params->page_ref_id); foreach ($structurePages as &$value) { $cachetype = 'structure_' . $value["page_ref_id"] . '_'; $cachelib->empty_type_cache($cachetype); } unset($value); } return array('html' => $html); }
function setUp() { Services_Exception_Disabled::check('suite_jitsi_provision'); }
function setUp() { Services_Exception_Disabled::check('wikiplugin_list'); Services_Exception_Disabled::check('wikiplugin_customsearch'); Services_Exception_Disabled::check('feature_search'); }
function setUp() { Services_Exception_Disabled::check('feature_kaltura'); }
function action_clearone($input) { Services_Exception_Disabled::check('monitor_individual_clear'); global $user; $relationlib = TikiLib::lib('relation'); $searchlib = TikiLib::lib('unifiedsearch'); $activity = $input->activity->int(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && $activity) { $relationlib->add_relation('tiki.monitor.cleared', 'user', $user, 'activity', $activity); $searchlib->invalidateObject('activity', $activity); $searchlib->processUpdateQueue(); } }
function setUp() { Services_Exception_Disabled::check('feature_search'); Services_Exception_Denied::checkGlobal('tiki_p_admin'); }
function setUp() { Services_Exception_Disabled::check('calendar_fullcalendar'); }
function action_clone_item($input) { global $prefs; Services_Exception_Disabled::check('tracker_clone_item'); $trackerId = $input->trackerId->int(); $definition = Tracker_Definition::get($trackerId); if (!$definition) { throw new Services_Exception_NotFound(); } $itemId = $input->itemId->int(); if (!$itemId) { throw new Services_Exception_Denied(tr('No item to clone')); } $itemObject = Tracker_Item::fromId($itemId); if (!$itemObject->canView()) { throw new Services_Exception_Denied(tr('Item to clone not visible')); } $newItem = Tracker_Item::newItem($trackerId); if (!$newItem->canModify()) { throw new Services_Exception_Denied(tr('Not allowed to create new items')); } $itemObject->asNew(); $itemData = $itemObject->getData($input); $id = 0; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $transaction = TikiLib::lib('tiki')->begin(); $id = $this->utilities->insertItem($definition, $itemData); foreach ($definition->getFields() as $field) { $handler = $definition->getFieldFactory()->getHandler($field, $itemData); if (method_exists($handler, 'handleClone')) { $handler->handleClone(); } } $itemObject = Tracker_Item::fromId($id); $trklib = TikiLib::lib('trk'); foreach ($trklib->get_child_items($itemId) as $info) { $childItem = Tracker_Item::fromId($info['itemId']); if ($childItem->canView()) { $childItem->asNew(); $data = $childItem->getData(); $data['fields'][$info['field']] = $id; $childDefinition = $childItem->getDefinition(); // handle specific cloning actions foreach ($childDefinition->getFields() as $field) { $handler = $childDefinition->getFieldFactory()->getHandler($field, $data); if (method_exists($handler, 'handleClone')) { $newData = $handler->handleClone(); $data['fields'][$field['permName']] = $newData['value']; } } $new = $this->utilities->insertItem($childDefinition, $data); } } $transaction->commit(); } return array('trackerId' => $trackerId, 'itemId' => $itemId, 'created' => $id, 'data' => $itemData['fields'], 'fields' => $itemObject->prepareInput(new JitFilter(array()))); }
function setUp() { $this->lib = TikiLib::lib('unifiedsearch'); Services_Exception_Disabled::check('wikiplugin_activitystream'); }
function setUp() { global $prefs; Services_Exception_Disabled::check('trackerfield_showtikiorg'); }
function setUp() { Services_Exception_Disabled::check('vimeo_upload'); $this->utilities = new Services_File_Utilities(); }
function setUp() { Services_Exception_Disabled::check('feature_forums'); $this->lib = TikiLib::lib('comments'); $this->access = TikiLib::lib('access'); }
function setUp() { Services_Exception_Disabled::check('feature_wiki'); Services_Exception_Disabled::check('feature_wiki_structure'); }
function action_clone_item($input) { global $prefs; Services_Exception_Disabled::check('tracker_clone_item'); $trackerId = $input->trackerId->int(); $definition = Tracker_Definition::get($trackerId); if (!$definition) { throw new Services_Exception_NotFound(); } $itemId = $input->itemId->int(); if (!$itemId) { throw new Services_Exception_Denied(tr('No item to clone')); } $itemObject = Tracker_Item::fromId($itemId); if (!$itemObject->canView()) { throw new Services_Exception_Denied(tr('Item to clone not visible')); } $newItem = Tracker_Item::newItem($trackerId); if (!$newItem->canModify()) { throw new Services_Exception_Denied(tr('Not allowed to create new items')); } global $prefs; if ($prefs['feature_jquery_validation'] === 'y') { $_REQUEST['itemId'] = 0; // let the validation code know this will be a new item $validationjs = TikiLib::lib('validators')->generateTrackerValidateJS($definition->getFields()); TikiLib::lib('header')->add_jq_onready('$("#cloneItemForm' . $trackerId . '").validate({' . $validationjs . $this->get_validation_options()); } $itemObject->asNew(); $itemData = $itemObject->getData($input); $id = 0; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $transaction = TikiLib::lib('tiki')->begin(); $id = $this->utilities->insertItem($definition, $itemData); foreach ($definition->getFields() as $field) { $handler = $definition->getFieldFactory()->getHandler($field, $itemData); if (method_exists($handler, 'handleClone')) { $handler->handleClone(); } } $itemObject = Tracker_Item::fromId($id); foreach (TikiLib::lib('trk')->get_child_items($itemId) as $info) { $childItem = Tracker_Item::fromId($info['itemId']); if ($childItem->canView()) { $childItem->asNew(); $data = $childItem->getData(); $data['fields'][$info['field']] = $id; $childDefinition = $childItem->getDefinition(); // handle specific cloning actions foreach ($childDefinition->getFields() as $field) { $handler = $childDefinition->getFieldFactory()->getHandler($field, $data); if (method_exists($handler, 'handleClone')) { $newData = $handler->handleClone(); $data['fields'][$field['permName']] = $newData['value']; } } $new = $this->utilities->insertItem($childDefinition, $data); } } $transaction->commit(); } return array('title' => tr('Duplicate Item'), 'trackerId' => $trackerId, 'itemId' => $itemId, 'created' => $id, 'data' => $itemData['fields'], 'fields' => $itemObject->prepareInput(new JitFilter(array()))); }
function setUp() { Services_Exception_Disabled::check('feature_calendar'); }
function setUp() { Services_Exception_Disabled::check('payment_feature', 'wikiplugin_addtocart'); }
function action_email_wikipage($input) { Services_Exception_Disabled::check('feature_wiki'); Services_Exception_Denied::checkGlobal('admin_users'); $check = Services_Exception_BadRequest::checkAccess(); //first pass - show confirm popup if (!empty($check['ticket'])) { $users = $input->asArray('checked'); if (count($users) > 0) { //provide redirect if js is not enabled $referer = Services_Utilities_Controller::noJsPath(); return ['title' => tra('Send wiki page content by email to selected users'), 'confirmAction' => $input->action->word(), 'confirmController' => 'user', 'customMsg' => tra('For these selected users:'), 'items' => $users, 'extra' => ['referer' => $referer], 'ticket' => $check['ticket'], 'modal' => '1', 'confirm' => 'y']; } else { throw new Services_Exception(tra('No users were selected. Please select one or more users.'), 409); } //after confirm submit - perform action and return success feedback } elseif ($check === true && $_SERVER['REQUEST_METHOD'] === 'POST') { $wikiTpl = $input['wikiTpl']; $tikilib = TikiLib::lib('tiki'); $pageinfo = $tikilib->get_page_info($wikiTpl); if (!$pageinfo) { throw new Services_Exception_NotFound(tra('Page not found')); } if (empty($pageinfo['description'])) { throw new Services_Exception(tra('The page does not have a description, which is mandatory to perform this action.')); } $bcc = $input['bcc']; include_once 'lib/webmail/tikimaillib.php'; $mail = new TikiMail(); if (!empty($bcc)) { if (!validate_email($bcc)) { throw new Services_Exception(tra('Invalid bcc email address.')); } $mail->setBcc($bcc); $bccmsg = tr('and blind copied to %0', $bcc); } $foo = parse_url($_SERVER['REQUEST_URI']); $machine = $tikilib->httpPrefix(true) . dirname($foo['path']); $machine = preg_replace('!/$!', '', $machine); // just in case global $smarty, $user; $smarty->assign_by_ref('mail_machine', $machine); $users = json_decode($input['items'], true); $logslib = TikiLib::lib('logs'); foreach ($users as $mail_user) { $smarty->assign_by_ref('user', $mail_user); $mail->setUser($mail_user); $mail->setSubject($pageinfo['description']); $text = $smarty->fetch('wiki:' . $wikiTpl); if (empty($text)) { throw new Services_Exception(tra('The template page has no text or it cannot be extracted.')); } $mail->setHtml($text); if (!$mail->send($this->lib->get_user_email($mail_user))) { $errormsg = tra('Unable to send mail'); if (Perms::get()->admin) { $mailerrors = print_r($mail->errors, true); $errormsg .= $mailerrors; } throw new Services_Exception($errormsg); } else { if (!empty($bcc)) { $logmsg = sprintf(tra('Mail sent to user %s'), $mail_user); } $logmsg = !empty($bccmsg) ? $logmsg . ' ' . $bccmsg : $logmsg; if (!empty($msg)) { $logslib->add_log('adminusers', $logmsg, $user); } } $smarty->assign_by_ref('user', $user); } //return to page //if javascript is not enabled $extra = json_decode($input['extra'], true); if (!empty($extra['referer'])) { $this->access->redirect($extra['referer'], tra('Page sent'), null, 'feedback'); } $msg = count($users) === 1 ? tr('The page %0 has been emailed to the following user:'******'The page %0 has been emailed to the following users:', $wikiTpl); $toMsg = !empty($bcc) ? tr('And blind copied to %0.', $bcc) : ''; return ['extra' => 'post', 'feedback' => ['ajaxtype' => 'feedback', 'ajaxheading' => tra('Success'), 'ajaxitems' => $users, 'ajaxmsg' => $msg, 'ajaxtoMsg' => $toMsg, 'modal' => '1']]; } }
function setUp() { Services_Exception_Disabled::check('feature_search'); Services_Exception_Disabled::check('storedsearch_enabled'); Services_Exception_Denied::checkAuth(); }
function action_preview($input) { Services_Exception_Disabled::check('feature_warn_on_edit'); global $user, $prefs, $page; $tikilib = TikiLib::lib('tiki'); $autoSaveIdParts = explode(':', $input->autoSaveId->text()); // user, section, object id foreach ($autoSaveIdParts as &$part) { $part = urldecode($part); } $page = $autoSaveIdParts[2]; // plugins use global $page for approval if (!Perms::get('wiki page', $page)->edit || $user != $tikilib->get_semaphore_user($page)) { return ''; } $info = $tikilib->get_page_info($page, false); if (empty($info)) { $info = array('data' => ''); } $info['is_html'] = $input->allowHtml->int(); if (!isset($info['wysiwyg']) && isset($_SESSION['wysiwyg'])) { $info['wysiwyg'] = $_SESSION['wysiwyg']; } $options = array('is_html' => $info['is_html'], 'preview_mode' => true, 'process_wiki_paragraphs' => $prefs['wysiwyg_htmltowiki'] === 'y' || $info['wysiwyg'] == 'n', 'page' => $page); if (count($autoSaveIdParts) === 3 && !empty($user) && $user === $autoSaveIdParts[0] && $autoSaveIdParts[1] === 'wiki_page') { $editlib = TikiLib::lib('edit'); $smarty = TikiLib::lib('smarty'); $wikilib = TikiLib::lib('wiki'); $smarty->assign('inPage', $input->inPage->int() ? true : false); if ($input->inPage->int()) { $diffstyle = $input->diff_style->text(); if (!$diffstyle) { // use previously set diff_style $diffstyle = getCookie('preview_diff_style', 'preview', ''); } $data = $editlib->partialParseWysiwygToWiki(TikiLib::lib('autosave')->get_autosave($input->editor_id->text(), $input->autoSaveId->text())); TikiLib::lib('smarty')->assign('diff_style', $diffstyle); if ($diffstyle) { if (!empty($info['created'])) { $info = $tikilib->get_page_info($page); // get page with data this time } if ($input->hdr->int()) { // TODO refactor with code in editpage if ($input->hdr->int() === 0) { list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], 1); $real_len = $real_start; $real_start = 0; } else { list($real_start, $real_len) = $tikilib->get_wiki_section($info['data'], $input->hdr->int()); } $info['data'] = substr($info['data'], $real_start, $real_len); } require_once 'lib/diff/difflib.php'; if ($info['is_html'] == 1) { $diffold = $tikilib->htmldecode($info['data']); } else { $diffold = $info['data']; } if ($info['is_html']) { $diffnew = $tikilib->htmldecode($data); } else { $diffnew = $data; } if ($diffstyle === 'htmldiff') { $diffnew = $tikilib->parse_data($diffnew, $options); $diffold = $tikilib->parse_data($diffold, $options); } $data = diff2($diffold, $diffnew, $diffstyle); $smarty->assign_by_ref('diffdata', $data); $smarty->assign('translation_mode', 'y'); $data = $smarty->fetch('pagehistory.tpl'); } else { $data = $tikilib->parse_data($data, $options); } $parsed = $data; } else { // popup window TikiLib::lib('header')->add_js(' function get_new_preview() { $("body").css("opacity", 0.6); location.reload(true); } $(window).on("load", function(){ if (typeof opener != "undefined") { opener.ajaxPreviewWindow = this; } }).on("unload", function(){ if (typeof opener.ajaxPreviewWindow != "undefined") { opener.ajaxPreviewWindow = null; } }); '); $smarty->assign('headtitle', tra('Preview')); $data = '<div id="c1c2"><div id="wrapper"><div id="col1"><div id="tiki-center" class="wikitext">'; if (TikiLib::lib('autosave')->has_autosave($input->editor_id->text(), $input->autoSaveId->text())) { $parserlib = TikiLib::lib('parser'); $data .= $parserlib->parse_data($editlib->partialParseWysiwygToWiki(TikiLib::lib('autosave')->get_autosave($input->editor_id->text(), $input->autoSaveId->text())), $options); } else { if ($autoSaveIdParts[1] == 'wiki_page') { $canBeRefreshed = false; $data .= $wikilib->get_parse($autoSaveIdParts[2], $canBeRefreshed); } } $data .= '</div></div></div></div>'; $smarty->assign_by_ref('mid_data', $data); $smarty->assign('mid', ''); $parsed = $smarty->fetch("tiki_full.tpl"); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'; // to fool Services_Broker into putputting full page } if ($prefs['feature_wiki_footnotes']) { $footnote = $input->footnote->text(); if ($footnote) { $footnote = $tikilib->parse_data($footnote); } else { $footnote = $wikilib->get_footnote($user, $page); } } return array('parsed' => $parsed, 'parsed_footnote' => $footnote); } }
function setUp() { global $prefs; Services_Exception_Disabled::check('bigbluebutton_feature'); }
function setUp() { Services_Exception_Disabled::check('feature_ajax'); Services_Exception_Disabled::check('ajax_autosave'); Services_Exception_Disabled::check('feature_warn_on_edit'); }
function setUp() { Services_Exception_Denied::checkAuth(); Services_Exception_Disabled::check('mustread_enabled'); }