Exemplo n.º 1
0
 /**
  * @param $name
  * @param $title
  * @param $data
  * @param null $parse
  * @return bool
  */
 function replace_user_module($name, $title, $data, $parse = NULL)
 {
     global $prefs;
     if (!empty($name) && !empty($data)) {
         $query = "delete from `tiki_user_modules` where `name`=?";
         $result = $this->query($query, array($name), -1, -1, false);
         $query = "insert into `tiki_user_modules`(`name`,`title`,`data`, `parse`) values(?,?,?,?)";
         //BEGIN wikiLingo integration
         if ($prefs['feature_wikilingo'] == 'y') {
             $this->query("DELETE FROM `tiki_output` WHERE `objectType` = ? AND `entityId` = ?", array("userModule", $name));
             switch (strtolower($parse)) {
                 case 'wikilingo':
                     $this->query("INSERT INTO `tiki_output` (`objectType`, `entityId`, `version`) VALUES  (?, ?, ?)", array("userModule", $name, 1));
                     $parse = 'y';
             }
         }
         //END wikiLingo integration
         $result = $this->query($query, array($name, $title, $data, $parse));
         $cachelib = TikiLib::lib('cache');
         $cachelib->invalidate("user_modules_{$name}");
         $wikilib = TikiLib::lib('wiki');
         $converter = new convertToTiki9();
         $converter->saveObjectStatus($name, 'tiki_user_modules', 'new9.0+');
         return true;
     }
 }
/**
 * @param $installer
 */
function upgrade_999999991_decode_pages_sources_tiki($installer)
{
    global $user_overrider_prefs, $systemConfiguration;
    set_time_limit(60 * 60);
    // Set maximum execution time to 1 hour since this runs on all pages
    include_once 'tiki-setup.php';
    $categlib = TikiLib::lib('categ');
    $wikilib = TikiLib::lib('wiki');
    $converter = new convertToTiki9();
    $converter->convertPages();
    $converter->convertModules();
}
function upgrade_999999991_decode_pages_sources_tiki($installer)
{
    set_time_limit(60 * 60);
    // Set maximum execution time to 1 hour since this runs on all pages
    include_once 'tiki-setup_base.php';
    include_once 'lib/categories/categlib.php';
    // needed for cat_jail fn in list_pages()
    include_once 'lib/wiki/wikilib.php';
    $converter = new convertToTiki9();
    $converter->convertPages();
    $converter->convertModules();
}
Exemplo n.º 4
0
 /**
  * @param $name
  * @param $title
  * @param $data
  * @param null $parse
  * @return bool
  */
 function replace_user_module($name, $title, $data, $parse = NULL)
 {
     if (!empty($name) && !empty($data)) {
         $query = "delete from `tiki_user_modules` where `name`=?";
         $result = $this->query($query, array($name), -1, -1, false);
         $query = "insert into `tiki_user_modules`(`name`,`title`,`data`, `parse`) values(?,?,?,?)";
         $result = $this->query($query, array($name, $title, $data, $parse));
         global $cachelib;
         require_once "lib/cache/cachelib.php";
         $cachelib->invalidate("user_modules_{$name}");
         require_once "lib/wiki/wikilib.php";
         $converter = new convertToTiki9();
         $converter->saveObjectStatus($name, 'tiki_user_modules', 'new9.0+');
         return true;
     }
 }
Exemplo n.º 5
0
 /** Update a wiki page
 		@param array $hash- lock_it,contributions, contributors
 		@param int $saveLastModif - modification time - pass null for now, unless importing a Wiki page
 	 **/
 function update_page($pageName, $edit_data, $edit_comment, $edit_user, $edit_ip, $edit_description = null, $edit_minor = 0, $lang = '', $is_html = null, $hash = null, $saveLastModif = null, $wysiwyg = '', $wiki_authors_style = '')
 {
     global $prefs;
     $histlib = TikiLib::lib('hist');
     if (!$edit_user) {
         $edit_user = '******';
     }
     $this->invalidate_cache($pageName);
     // Collect pages before modifying edit_data (see update of links below)
     $pages = $this->get_pages($edit_data, true);
     $this->check_alias($edit_data, $pageName);
     if (!$this->page_exists($pageName)) {
         return false;
     }
     // Get this page information
     $info = $this->get_page_info($pageName);
     if ($edit_description === null) {
         $edit_description = $info['description'];
     }
     // Use largest version +1 in history table rather than tiki_page because versions used to be bugged
     // tiki_history is also bugged as not all changes get stored in the history, like minor changes
     // and changes that do not modify the body of the page. Both numbers are wrong, but the largest of
     // them both is right.
     $old_version = max($info["version"], $histlib->get_page_latest_version($pageName));
     $user = $info["user"] ? $info["user"] : '******';
     $data = $info["data"];
     $willDoHistory = $prefs['feature_wiki_history_full'] == 'y' || $data != $edit_data || $info['description'] != $edit_description || $info["comment"] != $edit_comment;
     $version = $old_version + ($willDoHistory ? 1 : 0);
     if ($is_html === null) {
         $html = $info['is_html'];
     } else {
         $html = $is_html ? 1 : 0;
     }
     if ($wysiwyg == '') {
         $wysiwyg = $info['wysiwyg'];
     }
     if ($wysiwyg == 'y' && $html != 1 && $prefs['wysiwyg_htmltowiki'] != 'y') {
         // correct for html only wysiwyg
         $html = 1;
     }
     $parserlib = TikiLib::lib('parser');
     $edit_data = $parserlib->process_save_plugins($edit_data, array('type' => 'wiki page', 'itemId' => $pageName, 'user' => $user));
     if ($html == 1 && $prefs['feature_purifier'] != 'n') {
         $parserlib->isHtmlPurifying = true;
         $parserlib->isEditMode = true;
         $noparsed = array();
         $parserlib->plugins_remove($edit_data, $noparsed);
         require_once 'lib/htmlpurifier_tiki/HTMLPurifier.tiki.php';
         $edit_data = HTMLPurifier($edit_data);
         $parserlib->plugins_replace($edit_data, $noparsed, true);
         $parserlib->isHtmlPurifying = false;
         $parserlib->isEditMode = false;
     }
     if (is_null($saveLastModif)) {
         $saveLastModif = $this->now;
     }
     $queryData = array('description' => $edit_description, 'data' => $edit_data, 'comment' => $edit_comment, 'lastModif' => (int) $saveLastModif, 'version' => $version, 'version_minor' => $edit_minor, 'user' => $edit_user, 'ip' => $edit_ip, 'page_size' => strlen($edit_data), 'is_html' => $html, 'wysiwyg' => $wysiwyg, 'wiki_authors_style' => $wiki_authors_style, 'lang' => $lang);
     if ($hash !== null) {
         if (!empty($hash['lock_it']) && ($hash['lock_it'] == 'y' || $hash['lock_it'] == 'on')) {
             $queryData['flag'] = 'L';
             $queryData['lockedby'] = $user;
         } else {
             if (empty($hash['lock_it']) || $hash['lock_it'] == 'n') {
                 $queryData['flag'] = '';
                 $queryData['lockedby'] = '';
             }
         }
     }
     if ($prefs['wiki_comments_allow_per_page'] != 'n') {
         if (!empty($hash['comments_enabled']) && $hash['comments_enabled'] == 'y') {
             $queryData['comments_enabled'] = 'y';
         } else {
             if (empty($hash['comments_enabled']) || $hash['comments_enabled'] == 'n') {
                 $queryData['comments_enabled'] = 'n';
             }
         }
     }
     if (empty($hash['contributions'])) {
         $hash['contributions'] = '';
     }
     if (empty($hash['contributors'])) {
         $hash2 = '';
     } else {
         foreach ($hash['contributors'] as $c) {
             $hash3['contributor'] = $c;
             $hash2[] = $hash3;
         }
     }
     $this->table('tiki_pages')->update($queryData, array('pageName' => $pageName));
     // Synchronize object comment
     if ($prefs['feature_wiki_description'] == 'y') {
         $query = 'update `tiki_objects` set `description`=? where `itemId`=? and `type`=?';
         $this->query($query, array($edit_description, $pageName, 'wiki page'));
     }
     //update status, page storage was updated in tiki 9 to be non html encoded
     $wikilib = TikiLib::lib('wiki');
     $converter = new convertToTiki9();
     $converter->saveObjectStatus($this->getOne("SELECT page_id FROM tiki_pages WHERE pageName = ?", array($pageName)), 'tiki_pages');
     // Parse edit_data updating the list of links from this page
     $this->clear_links($pageName);
     // Pages collected above
     foreach ($pages as $page => $types) {
         $this->replace_link($pageName, $page, $types);
     }
     if (strtolower($pageName) != 'sandbox' && !$edit_minor) {
         $maxversions = $prefs['maxVersions'];
         if ($maxversions && ($nb = $histlib->get_nb_history($pageName)) > $maxversions) {
             // Select only versions older than keep_versions days
             $keep = $prefs['keep_versions'];
             $oktodel = $saveLastModif - $keep * 24 * 3600 + 1;
             $history = $this->table('tiki_history');
             $result = $history->fetchColumn('version', array('pageName' => $pageName, 'lastModif' => $history->lesserThan($oktodel)), $nb - $maxversions, 0, array('lastModif' => 'ASC'));
             foreach ($result as $toRemove) {
                 $histlib->remove_version($pageName, $toRemove);
             }
         }
     }
     // This if no longer checks for minor-ness of the change; sendWikiEmailNotification does that.
     if ($willDoHistory) {
         $this->replicate_page_to_history($pageName);
         if (strtolower($pageName) != 'sandbox') {
             if ($prefs['feature_contribution'] == 'y') {
                 // transfer page contributions to the history
                 $contributionlib = TikiLib::lib('contribution');
                 $history = $this->table('tiki_history');
                 $historyId = $history->fetchOne($history->max('historyId'), array('pageName' => $pageName, 'version' => (int) $old_version));
                 $contributionlib->change_assigned_contributions($pageName, 'wiki page', $historyId, 'history', '', $pageName . '/' . $old_version, "tiki-pagehistory.php?page={$pageName}&preview={$old_version}");
             }
         }
         include_once 'lib/diff/difflib.php';
         if (strtolower($pageName) != 'sandbox') {
             $logslib = TikiLib::lib('logs');
             $bytes = diff2($data, $edit_data, 'bytes');
             $logslib->add_action('Updated', $pageName, 'wiki page', $bytes, $edit_user, $edit_ip, '', $this->now, $hash['contributions'], $hash2);
             if ($prefs['feature_contribution'] == 'y') {
                 $contributionlib = TikiLib::lib('contribution');
                 $contributionlib->assign_contributions($hash['contributions'], $pageName, 'wiki page', $edit_description, $pageName, "tiki-index.php?page=" . urlencode($pageName));
             }
         }
         if ($prefs['feature_multilingual'] == 'y' && $lang) {
             // Need to update the translated objects table when an object's language changes.
             $this->table('tiki_translated_objects')->update(array('lang' => $lang), array('type' => 'wiki page', 'objId' => $info['page_id']));
         }
         if ($prefs['wiki_watch_minor'] != 'n' || !$edit_minor) {
             //  Deal with mail notifications.
             include_once 'lib/notifications/notificationemaillib.php';
             $histlib = TikiLib::lib('hist');
             $old = $histlib->get_version($pageName, $old_version);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = self::httpPrefix(true) . dirname($foo["path"]);
             $diff = diff2($old["data"], $edit_data, "unidiff");
             sendWikiEmailNotification('wiki_page_changed', $pageName, $edit_user, $edit_comment, $old_version, $edit_data, $machine, $diff, $edit_minor, $hash['contributions'], 0, 0, $lang);
         }
     }
     $tx = $this->begin();
     TikiLib::events()->trigger('tiki.wiki.update', array('type' => 'wiki page', 'object' => $pageName, 'namespace' => $wikilib->get_namespace($pageName), 'reply_action' => 'comment', 'user' => $GLOBALS['user'], 'page_id' => $info['page_id'], 'version' => $version, 'data' => $edit_data, 'old_data' => $info['data']));
     $tx->commit();
 }
Exemplo n.º 6
0
	function get_page_from_history($page,$version,$fetchdata=false)
	{
		require_once("lib/wiki/wikilib.php");
		$converter = new convertToTiki9();
		$converter->convertPageHistoryFromPageAndVersion($page, $version);

		if ($fetchdata==true) {
			if ($version > 0)
				$query = "select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `data`, `comment`, `is_html` from `tiki_history` where `pageName`=? and `version`=?";				
			else
				$query = "select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `data`, `comment`, `is_html` from `tiki_pages` where `pageName`=?";
		} else {
			if ($version > 0)
				$query = "select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `comment`, `is_html` from `tiki_history` where `pageName`=? and `version`=?";
			else
				$query = "select `pageName`, `description`, `version`, `lastModif`, `user`, `ip`, `comment`, `is_html` from `tiki_pages` where `pageName`=?";
		}
		if ($version > 0)
			$result = $this->query($query, array($page,$version));
		else
			$result = $this->query($query, array($page));
			
		$ret = array();

		while ($res = $result->fetchRow()) {
			$aux = array();

			$aux["version"] = $res["version"];
			$aux["lastModif"] = $res["lastModif"];
			$aux["user"] = $res["user"];
			$aux["ip"] = $res["ip"];
			if ($fetchdata==true) $aux["data"] = $res["data"];
			$aux["pageName"] = $res["pageName"];
			$aux["description"] = $res["description"];
			$aux["comment"] = $res["comment"];
			$aux["is_html"] = $res["is_html"];
			//$aux["percent"] = levenshtein($res["data"],$actual);
			$ret[] = $aux;
		}

		return empty($ret)?$ret: $ret[0];
	}