function wikiplugin_addfreetag($data, $params)
{
	global $user;
	$object = current_object();

	if (isset($params['object']) && false !== strpos($params['object'], ':')) {
		list($object['type'], $object['object']) = explode(':', $params['object'], 2);
	}
	if ($object['type'] == 'wiki page' && !ctype_digit($object['object'])) {
		$identifier = 'wp_addfreetag_' . str_replace(array(':',' '), array('_',''), TikiLib::lib('tiki')->get_page_id_from_name($params['object']));
	} else {
		$identifier = 'wp_addfreetag_' . str_replace(array(':',' '), array('_',''), $params['object']);
	}

	if ($object['type'] == 'trackeritem') {
		$permobject = TikiLib::lib('trk')->get_tracker_for_item($object['object']);
		$permobjecttype = 'tracker';
	} else {
		$permobject = $object['object'];
		$permobjecttype = $object['type'];
	}
	if (! TikiLib::lib('tiki')->user_has_perm_on_object($user, $permobject, $permobjecttype, 'tiki_p_freetags_tag')) {
		return '';
	}
	if (!empty($_POST[$identifier])) {
		$_POST[$identifier] = '"' . str_replace('"', '', $_POST[$identifier]) . '"';
		TikiLib::lib('freetag')->tag_object($user, $object['object'], $object['type'], $_POST[$identifier]);
		if ($object['type'] == 'trackeritem') {
			// need to update tracker field as well
			$definition = Tracker_Definition::get($permobject);
			if ($field = $definition->getFreetagField()) {
				$currenttags = TikiLib::lib('freetag')->get_tags_on_object($object['object'], 'trackeritem');
				$taglist = '';	
				foreach ($currenttags['data'] as $tag) {
					if (strstr($tag['tag'], ' ')) {
						$taglist .= '"'.$tag['tag'] . '" ';
					} else {
						$taglist .= $tag['tag'] . ' ';
					}
				}
				// taglist will have slashes
				TikiLib::lib('trk')->modify_field($object['object'], $field, stripslashes($taglist));
			}
		} 
		require_once 'lib/search/refresh-functions.php';
		refresh_index($object['type'], $object['object']);
		$url = $_SERVER['REQUEST_URI'];
		header("Location: $url");
		die;
	}

	$smarty = TikiLib::lib('smarty');
	$smarty->assign('wp_addfreetag', $identifier); 
	return $smarty->fetch('wiki-plugins/wikiplugin_addfreetag.tpl');
}
示例#2
0
 function flag_revision($pageName, $version, $flag, $value)
 {
     global $prefs;
     $attributelib = TikiLib::lib('attribute');
     $histlib = TikiLib::lib('hist');
     if ($version_info = $histlib->get_version($pageName, $version)) {
         $tx = TikiDb::get()->begin();
         if ($prefs['feature_actionlog'] == 'y') {
             $logslib = TikiLib::lib('logs');
             $logslib->add_action(self::ACTION, $pageName, 'wiki page', "flag={$flag}&version={$version}&value={$value}");
         }
         $attribute = $this->get_attribute_for_flag($flag);
         $attributelib->set_attribute('wiki history', $version_info['historyId'], $attribute, $value);
         require_once 'lib/search/refresh-functions.php';
         refresh_index('pages', $pageName);
         refresh_index('pages', "{$pageName}~~latest");
         $tx->commit();
         return true;
     } else {
         return false;
     }
 }
示例#3
0
 public function replace_tracker($trackerId, $name, $description, $options, $descriptionIsParsed)
 {
     $trackers = $this->trackers();
     $data = array('name' => $name, 'description' => $description, 'descriptionIsParsed' => $descriptionIsParsed, 'lastModif' => $this->now);
     $logOption = 'Updated';
     if ($trackerId) {
         $conditions = array('trackerId' => (int) $trackerId);
         if ($trackers->fetchCount($conditions)) {
             $trackers->update($data, $conditions);
         } else {
             $data['trackerId'] = (int) $trackerId;
             $data['items'] = 0;
             $data['created'] = $this->now;
             $trackers->insert($data);
             $logOption = 'Created';
         }
     } else {
         $data['created'] = $this->now;
         $trackerId = $trackers->insert($data);
     }
     $optionTable = $this->options();
     $optionTable->deleteMultiple(array('trackerId' => (int) $trackerId));
     foreach ($options as $kopt => $opt) {
         $this->replace_tracker_option((int) $trackerId, $kopt, $opt);
     }
     $definition = Tracker_Definition::get($trackerId);
     $ratingId = $definition->getRateField();
     if (isset($options['useRatings']) && $options['useRatings'] == 'y') {
         if (!$ratingId) {
             $ratingId = 0;
         }
         $ratingoptions = isset($options['ratingOptions']) ? $options['ratingOptions'] : '';
         $showratings = isset($options['showRatings']) ? $options['showRatings'] : 'n';
         $this->replace_tracker_field($trackerId, $ratingId, 'Rating', 's', '-', '-', $showratings, 'y', 'n', '-', 0, $ratingoptions);
     }
     $this->clear_tracker_cache($trackerId);
     $this->update_tracker_summary(array('trackerId' => $trackerId));
     if ($logOption) {
         $logslib = TikiLib::lib('logs');
         $logslib->add_action($logOption, $trackerId, 'tracker', array('name' => $data['name']));
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('trackers', $trackerId);
     if ($descriptionIsParsed == 'y') {
         $tikilib = TikiLib::lib('tiki');
         $tikilib->object_post_save(array('type' => 'tracker', 'object' => $trackerId, 'href' => "tiki-view_tracker.php?trackerId={$trackerId}", 'description' => $description), array('content' => $description));
     }
     return $trackerId;
 }
示例#4
0
/**
 * @param $page
 */
function refresh_index_wiki($page)
{
    refresh_index('pages', $page);
}
示例#5
0
 /**
  * @param $parent
  * @param $categId
  * @param $name
  * @param $description
  * @param $childrenType
  * @param $viewableChildren
  * @param $allowSites
  * @param $showCount
  * @param $editorGroup
  * @return mixed
  */
 function dir_replace_category($parent, $categId, $name, $description, $childrenType, $viewableChildren, $allowSites, $showCount, $editorGroup)
 {
     if ($categId) {
         $query = "update `tiki_directory_categories` set `name`=?, `parent`=?, `description`=?, `childrenType`=?, `viewableChildren`=?, `allowSites`=?, `showCount`=?, `editorGroup`=?  where `categId`=?";
         $this->query($query, array($name, (int) $parent, $description, $childrenType, (int) $viewableChildren, $allowSites, $showCount, $editorGroup, (int) $categId));
     } else {
         $query = "insert into `tiki_directory_categories`(`parent`,`hits`,`name`,`description`,`childrenType`,`viewableChildren`,`allowSites`,`showCount`,`editorGroup`,`sites`) values(?,?,?,?,?,?,?,?,?,?)";
         $this->query($query, array((int) $parent, 0, $name, $description, $childrenType, (int) $viewableChildren, $allowSites, $showCount, $editorGroup, 0));
         $categId = $this->getOne("select max(`categId`) from `tiki_directory_categories` where `name`=?", array($name));
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('directory_categories', $categId);
     return $categId;
 }
示例#6
0
 /**
  * @param $galleryId
  * @param $name
  * @param $description
  * @param $theme
  * @param $user
  * @param $maxRows
  * @param $rowImages
  * @param $thumbSizeX
  * @param $thumbSizeY
  * @param $public
  * @param string $visible
  * @param string $sortorder
  * @param string $sortdirection
  * @param string $galleryimage
  * @param $parentgallery
  * @param string $showname
  * @param string $showimageid
  * @param string $showdescription
  * @param string $showcreated
  * @param string $showuser
  * @param string $showhits
  * @param string $showxysize
  * @param string $showfilesize
  * @param string $showfilename
  * @param string $defaultscale
  * @param string $geographic
  * @param string $showcategories
  * @return mixed
  */
 function replace_gallery($galleryId, $name, $description, $theme, $user, $maxRows, $rowImages, $thumbSizeX, $thumbSizeY, $public, $visible = 'y', $sortorder = 'created', $sortdirection = 'desc', $galleryimage = 'first', $parentgallery = -1, $showname = 'y', $showimageid = 'n', $showdescription = 'n', $showcreated = 'n', $showuser = '******', $showhits = 'y', $showxysize = 'y', $showfilesize = 'n', $showfilename = 'n', $defaultscale = 'o', $geographic = 'n', $showcategories = 'n')
 {
     global $prefs;
     // if the user is admin or the user is the same user and the gallery exists then replace if not then
     // create the gallary if the name is unused.
     $name = strip_tags($name);
     $description = strip_tags($description);
     // check if the gallery already exists. if yes: do update, if no: update it
     if ($galleryId < 1) {
         $galleryId = $this->getOne("select `galleryId` from `tiki_galleries` where `name`=? and `parentgallery`=?", array($name, $parentgallery));
     }
     if ($galleryId > 0) {
         $query = "update `tiki_galleries` set `name`=?,`visible`=?, `geographic`=?,`maxRows`=? , `rowImages`=?,\n\t\t\t\t\t\t\t`thumbSizeX`=?, `thumbSizeY`=?, `description`=?, `theme`=?,\n\t\t\t\t\t\t\t`lastModif`=?, `public`=?, `sortorder`=?, `sortdirection`=?, `galleryimage`=?,\n\t\t\t\t\t\t\t`parentgallery`=?,`showname`=?,`showimageid`=?,`showdescription`=?,`showcategories`=?,\n\t\t\t\t\t\t\t`showcreated`=?,`showuser`=?,`showhits`=?,`showxysize`=?,`showfilesize`=?,\n\t\t\t\t\t\t\t`showfilename`=?,`defaultscale`=?, `user`=?\n\t\t\t\t\t\t\t\twhere `galleryId`=?";
         $result = $this->query($query, array($name, $visible, $geographic, (int) $maxRows, (int) $rowImages, (int) $thumbSizeX, (int) $thumbSizeY, $description, $theme, (int) $this->now, $public, $sortorder, $sortdirection, $galleryimage, (int) $parentgallery, $showname, $showimageid, $showdescription, $showcategories, $showcreated, $showuser, $showhits, $showxysize, $showfilesize, $showfilename, $defaultscale, $user, (int) $galleryId));
     } else {
         // Create a new record
         $query = "insert into\n\t\t\t\t\t\t\t`tiki_galleries`(`name`,`description`,`theme`,`created`,`user`,`lastModif`,`maxRows`,`rowImages`,`thumbSizeX`,`thumbSizeY`,`public`,`hits`,`visible`,`sortorder`,`sortdirection`,`galleryimage`,`parentgallery`,`showname`,`showimageid`,`showdescription`,`showcategories`,`showcreated`,`showuser`,`showhits`,`showxysize`,`showfilesize`,`showfilename`,`defaultscale`,`geographic`)\n\t\t\t\t\t\t\tvalues (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
         $bindvars = array($name, $description, $theme, (int) $this->now, $user, (int) $this->now, (int) $maxRows, (int) $rowImages, (int) $thumbSizeX, (int) $thumbSizeY, $public, 0, $visible, $sortorder, $sortdirection, $galleryimage, (int) $parentgallery, $showname, $showimageid, $showdescription, $showcategories, $showcreated, $showuser, $showhits, $showxysize, $showfilesize, $showfilename, $defaultscale, $geographic);
         $result = $this->query($query, $bindvars);
         $galleryId = $this->getOne("select max(`galleryId`) from `tiki_galleries` where `name`=? and `created`=?", array($name, (int) $this->now));
         TikiLib::events()->trigger('tiki.imagegallery.create', array('type' => 'imagegallery', 'object' => $id, 'user' => $user));
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('galleries', $galleryId);
     return $galleryId;
 }
示例#7
0
文件: tikilib.php 项目: rjsmelo/tiki
 /**
  * @param $type
  * @param $object
  * @param bool $process
  * @return bool
  */
 function refresh_index($type, $object, $process = true)
 {
     require_once 'lib/search/refresh-functions.php';
     return refresh_index($type, $object, $process);
 }
示例#8
0
	private function uncategorize_user_tracker_item($user, $group)
	{
		global $tikilib;
		$userid = $this->get_user_id($user);
		$tracker = $this->get_usertracker($userid);

		if ( $tracker && $tracker['usersTrackerId'] ) {
			$trklib = TikiLib::lib('trk');
			$categlib = TikiLib::lib('categ');
			$itemid = $trklib->get_item_id($tracker['usersTrackerId'], $tracker['usersFieldId'], $user);
			$cat = $categlib->get_object_categories('trackeritem', $itemid);
			$categId = $categlib->get_category_id($group);
			if (!$categId) {
				return false;
			}
			$cat = array_diff($cat, array($categId));
			$trklib->categorized_item($tracker["usersTrackerId"], $itemid, '', $cat, array(), true);
			require_once('lib/search/refresh-functions.php');
			refresh_index('trackeritem', $itemid);
		}
	}
 function reindex_all_files_for_search_text()
 {
     $query = "select fileId, filename, filesize, filetype, data, path, galleryId from `tiki_files` where `archiveId`=?";
     $result = $this->query($query, array(0));
     $rows = array();
     while ($row = $result->fetchRow()) {
         $rows[] = $row;
     }
     foreach ($rows as $row) {
         $search_text = $this->get_search_text_for_data($row['data'], $row['path'], $row['filetype'], $row['galleryId']);
         if ($search_text !== false) {
             $query = "update `tiki_files` set `search_data`=? where `fileId`=?";
             $result = $this->query($query, array($search_text, $row['fileId']));
         }
     }
     include_once "lib/search/refresh-functions.php";
     refresh_index('files');
 }
示例#10
0
function rebuild_index($pContentType, $pUnindexedOnly = false)
{
    global $gBitSystem, $gLibertySystem;
    $arguments = array();
    $whereClause = "";
    ini_set("max_execution_time", "3000");
    if (!$pUnindexedOnly) {
        delete_index_content_type($pContentType);
    }
    $query = "SELECT `content_id`, `content_type_guid` FROM `" . BIT_DB_PREFIX . "liberty_content`";
    if (!empty($pContentType) && $pContentType != "pages") {
        $whereClause = " WHERE `content_type_guid` = ?";
        $arguments[] = $pContentType;
    }
    if ($pUnindexedOnly) {
        if (empty($whereClause)) {
            $whereClause = " WHERE ";
        } else {
            $whereClause .= " AND ";
        }
        $whereClause .= "`content_id` NOT IN (SELECT DISTINCT `content_id` FROM `" . BIT_DB_PREFIX . "search_index`)";
    }
    $orderBy = " ORDER BY `content_type_guid` ";
    $result = $gBitSystem->mDb->query($query . $whereClause . $orderBy, $arguments);
    $count = 0;
    if ($result) {
        $count = $result->RecordCount();
        while ($res = $result->fetchRow()) {
            if (isset($gLibertySystem->mContentTypes[$res["content_type_guid"]])) {
                $type = $gLibertySystem->mContentTypes[$res["content_type_guid"]];
                require_once constant(strtoupper($type['handler_package']) . '_PKG_PATH') . $type['handler_file'];
                $obj = new $type['handler_class'](NULL, $res["content_id"]);
                refresh_index($obj);
                unset($obj);
            }
        }
    }
    return $count;
}
示例#11
0
文件: artlib.php 项目: ameoba32/tiki
 function replace_article($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $user, $articleId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating = 0, $isfloat = 'n', $emails = '', $from = '', $list_image_x = '', $list_image_y = '', $ispublished = 'y', $fromurl = false)
 {
     $tikilib = TikiLib::lib('tiki');
     $smarty = TikiLib::lib('smarty');
     if ($expireDate < $publishDate) {
         $expireDate = $publishDate;
     }
     $hash = md5($title . $heading . $body);
     if (empty($imgdata) || $useImage === 'n') {
         // remove image data if not using it
         $imgdata = '';
     }
     $query = 'select `name` from `tiki_topics` where `topicId` = ?';
     $topicName = $this->getOne($query, array($topicId));
     $size = $body ? mb_strlen($body) : mb_strlen($heading);
     $info = array('title' => $title, 'authorName' => $authorName, 'topicId' => (int) $topicId, 'topicName' => $topicName, 'size' => (int) $size, 'useImage' => $useImage, 'image_name' => $imgname, 'image_type' => $imgtype, 'image_size' => (int) $imgsize, 'image_data' => $imgdata, 'isfloat' => $isfloat, 'image_x' => (int) $image_x, 'image_y' => (int) $image_y, 'list_image_x' => (int) $list_image_x, 'list_image_y' => (int) $list_image_y, 'heading' => $heading, 'body' => $body, 'publishDate' => (int) $publishDate, 'expireDate' => (int) $expireDate, 'created' => (int) $this->now, 'author' => $user, 'type' => $type, 'rating' => (double) $rating, 'topline' => $topline, 'subtitle' => $subtitle, 'linkto' => $linkto, 'image_caption' => $image_caption, 'lang' => $lang, 'ispublished' => $ispublished);
     $article_table = $this->table('tiki_articles');
     if ($articleId) {
         $oldArticle = $this->get_article($articleId);
         $article_table->update($info, array('articleId' => (int) $articleId));
         // Clear article image cache because image may just have been changed
         $this->delete_image_cache('article', $articleId);
         $event = 'article_edited';
         $nots = $tikilib->get_event_watches('article_edited', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_edited', $topicId);
         $smarty->assign('mail_action', 'Edit');
         $smarty->assign('mail_old_title', $oldArticle['title']);
         $smarty->assign('mail_old_publish_date', $oldArticle['publishDate']);
         $smarty->assign('mail_old_expiration_date', $oldArticle['expireDate']);
         $smarty->assign('mail_old_data', $oldArticle['heading'] . "\n----------------------\n" . $oldArticle['body']);
     } else {
         $articleId = $article_table->insert($info);
         global $prefs;
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'article_new');
         }
         $event = 'article_submitted';
         $nots = $tikilib->get_event_watches('article_submitted', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_created', $topicId);
         $smarty->assign('mail_action', 'New');
         // Create tracker item as well if feature is enabled
         if (!$fromurl && $prefs['tracker_article_tracker'] == 'y' && ($trackerId = $prefs['tracker_article_trackerId'])) {
             $trklib = TikiLib::lib('trk');
             $definition = Tracker_Definition::get($trackerId);
             if ($fieldId = $definition->getArticleField()) {
                 $addit = array();
                 $addit[] = array('fieldId' => $fieldId, 'type' => 'articles', 'value' => $articleId);
                 $itemId = $trklib->replace_item($trackerId, 0, array('data' => $addit));
                 TikiLib::lib('relation')->add_relation('tiki.article.attach', 'trackeritem', $itemId, 'article', $articleId);
             }
         }
     }
     $nots3 = array();
     foreach ($nots as $n) {
         $nots3[] = $n['email'];
     }
     foreach ($nots2 as $n) {
         if (!in_array($n['email'], $nots3)) {
             $nots[] = $n;
         }
     }
     if (is_array($emails) && (empty($from) || $from == $prefs['sender_email'])) {
         foreach ($emails as $n) {
             if (!in_array($n, $nots3)) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
         }
     }
     global $prefs;
     if ($prefs['user_article_watch_editor'] != "y") {
         for ($i = count($nots) - 1; $i >= 0; --$i) {
             if ($nots[$i]['user'] == $user) {
                 unset($nots[$i]);
                 break;
             }
         }
     }
     if (!isset($_SERVER['SERVER_NAME'])) {
         $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
     }
     if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
         $reportsManager = Reports_Factory::build('Reports_Manager');
         $reportsManager->addToCache($nots, array('event' => $event, 'articleId' => $articleId, 'articleTitle' => $title, 'authorName' => $authorName, 'user' => $user));
     }
     if (count($nots) || is_array($emails)) {
         include_once 'lib/notifications/notificationemaillib.php';
         $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
         $smarty->assign('mail_title', $title);
         $smarty->assign('mail_postid', $articleId);
         $smarty->assign('mail_user', $user);
         $smarty->assign('mail_current_publish_date', $publishDate);
         $smarty->assign('mail_current_expiration_date', $expireDate);
         $smarty->assign('mail_current_data', $heading . "\n----------------------\n" . $body);
         sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl');
         if (is_array($emails) && !empty($from) && $from != $prefs['sender_email']) {
             $nots = array();
             foreach ($emails as $n) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
             sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl', $from);
         }
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('articles', $articleId);
     $tikilib = TikiLib::lib('tiki');
     $tikilib->object_post_save(array('type' => 'article', 'object' => $articleId, 'description' => substr($heading, 0, 200), 'name' => $title, 'href' => "tiki-read_article.php?articleId={$articleId}"), array('content' => $body . "\n" . $heading));
     return $articleId;
 }
示例#12
0
 function removeFriend($user, $oldFriend)
 {
     $follow = $this->getRelation('follow', $user, $oldFriend);
     $followInvert = $this->getRelation('follow.invert', $user, $oldFriend);
     $request = $this->getRelation('request', $user, $oldFriend);
     $requestInvert = $this->getRelation('request.invert', $user, $oldFriend);
     if ($follow) {
         $this->relationlib->remove_relation($follow);
         if ($this->networkType == 'friend') {
             // Friendship breakups are bidirectional, not follow ones
             $this->relationlib->remove_relation($followInvert);
         }
         require_once 'lib/search/refresh-functions.php';
         refresh_index('user', $user);
         refresh_index('user', $oldFriend);
         return true;
     } elseif ($request || $requestInvert) {
         $this->relationlib->remove_relation($request);
         $this->relationlib->remove_relation($requestInvert);
         require_once 'lib/search/refresh-functions.php';
         refresh_index('user', $user);
         refresh_index('user', $oldFriend);
         return true;
     } else {
         return false;
     }
 }
 function replace_tracker($trackerId, $name, $description, $options)
 {
     $explicit = $options['useExplicitNames'] == "y" ? true : false;
     $createNewTracker = $trackerId == false;
     if (!$explicit || $this->check_table_name($name, $trackerId == true)) {
         if ($explicit && $trackerId) {
             $oldName = $this->get_table_id($trackerId, $explicit);
         } elseif (!$explicit) {
             // TODO code to change from (explicit/non explicit)
         }
         // -------------------
         if ($trackerId) {
             $query = "update `tiki_trackers` set `name`=?,`description`=?,`lastModif`=? where `trackerId`=?";
             $this->query($query, array($name, $description, (int) $this->now, (int) $trackerId));
         } else {
             $this->getOne("delete from `tiki_trackers` where `name`=?", array($name), false);
             $query = "insert into `tiki_trackers`(`name`,`description`,`created`,`lastModif`) values(?,?,?,?)";
             $this->query($query, array($name, $description, (int) $this->now, (int) $this->now));
             $trackerId = $this->getOne("select max(`trackerId`) from `tiki_trackers` where `name`=? and `created`=?", array($name, (int) $this->now));
         }
         $this->query("delete from `tiki_tracker_options` where `trackerId`=?", array((int) $trackerId));
         $rating = false;
         foreach ($options as $kopt => $opt) {
             $this->query("insert into `tiki_tracker_options`(`trackerId`,`name`,`value`) values(?,?,?)", array((int) $trackerId, $kopt, $opt));
             if ($kopt == 'useRatings' and $opt == 'y') {
                 $rating = true;
             } elseif ($kopt == 'ratingOptions') {
                 $ratingoptions = $opt;
             } elseif ($kopt == 'showRatings') {
                 $showratings = $opt;
             }
         }
         // -------------------
         // creation de la table des items
         // si elle n'existe pas deja.
         if ($createNewTracker && $trackerId) {
             $dsn = null;
             $this->create_value_table($trackerId, $explicit, $dsn);
         } elseif ($explicit) {
             $query = "alter table {$oldName} rename to " . $this->EXPLICIT_PREFIX . $name;
             $this->query($query);
         }
         // -------------------
         $ratingId = $this->get_field_id($trackerId, 'Rating');
         if ($rating) {
             if (!$ratingId) {
                 $ratingId = 0;
             }
             if (!isset($ratingoptions)) {
                 $ratingoptions = '';
             }
             if (!isset($showratings)) {
                 $showratings = 'n';
             }
             $this->replace_tracker_field($trackerId, $ratingId, 'Rating', 's', '-', '-', $showratings, 'y', '-', '-', 0, $ratingoptions);
         } else {
             $this->query('delete from `tiki_tracker_fields` where `fieldId`=?', array((int) $ratingId));
         }
         // -------------------
         global $prefs;
         if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
             require_once 'lib/search/refresh-functions.php';
             refresh_index('trackers', $trackerId);
         }
         // -------------------
         return $trackerId;
         // -------------------
     }
     return false;
 }
示例#14
0
 function post_new_comment($objectId, $parentId, $userName, $title, $data, &$message_id, $in_reply_to = '', $type = 'n', $summary = '', $smiley = '', $contributions = '', $anonymous_name = '')
 {
     if (!$userName) {
         $_SESSION["lastPost"] = $this->now;
     }
     if (!isset($_SERVER['REMOTE_ADDR'])) {
         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     }
     // Check for banned userName or banned IP or IP in banned range
     // Check for duplicates.
     $title = strip_tags($title);
     if (!$userName) {
         if ($anonymous_name) {
             $userName = $anonymous_name . ' ' . tra('(not registered)');
         } else {
             $userName = tra('Anonymous');
         }
     } else {
         if ($this->getOne("select count(*) from \n\t\t\t`tiki_user_postings` where `user`=?", array($userName), false)) {
             $query = "update `tiki_user_postings` " . "set `last`=?, `posts` = `posts` + 1 where `user`=?";
             $this->query($query, array((int) $this->now, $userName));
         } else {
             $posts = $this->getOne("select count(*) " . "from `tiki_comments` where `userName`=?", array($userName), false);
             if (!$posts) {
                 $posts = 1;
             }
             $query = "insert into \n\t\t    `tiki_user_postings`(`user`,`first`,`last`,`posts`) \n\t\t    values( ?, ?, ?, ? )";
             $this->query($query, array($userName, (int) $this->now, (int) $this->now, (int) $posts));
         }
         // Calculate max
         $max = $this->getOne("select max(`posts`) from `tiki_user_postings`", array());
         $min = $this->getOne("select min(`posts`) from `tiki_user_postings`", array());
         if ($min == 0) {
             $min = 1;
         }
         $ids = $this->getOne("select count(*) from `tiki_user_postings`", array());
         $tot = $this->getOne("select sum(`posts`) from `tiki_user_postings`", array());
         $average = $tot / $ids;
         $range1 = ($min + $average) / 2;
         $range2 = ($max + $average) / 2;
         $posts = $this->getOne("select `posts` " . "from `tiki_user_postings` where `user`=?", array($userName), false);
         if ($posts == $max) {
             $level = 5;
         } elseif ($posts > $range2) {
             $level = 4;
         } elseif ($posts > $average) {
             $level = 3;
         } elseif ($posts > $range1) {
             $level = 2;
         } else {
             $level = 1;
         }
         $query = "update `tiki_user_postings` " . "set `level`=? where `user`=?";
         $this->query($query, array($level, $userName));
     }
     $hash = md5($title . $data);
     $query = "select `threadId` from `tiki_comments` where `hash`=?";
     $result = $this->query($query, array($hash));
     // print( "<pre>result:" );
     // print_r( $result );
     // print( "</pre>" );
     // Check if we were passed a message-id.
     if (!$message_id) {
         // Construct a message id via proctological
         // extraction.  -rlpowell
         $message_id = $userName . "-" . $parentId . "-" . substr($hash, 0, 10) . "@" . $_SERVER["SERVER_NAME"];
     }
     // Break out the type and object parameters.
     $object = explode(":", $objectId, 2);
     // If this post was not already found.
     if (!$result->numRows()) {
         $query = "insert into\n\t\t`tiki_comments`(`objectType`, `object`,\n\t\t\t`commentDate`, `userName`, `title`, `data`, `votes`,\n\t\t\t`points`, `hash`, `parentId`, `average`, `hits`,\n\t\t\t`type`, `summary`, `smiley`, `user_ip`,\n\t\t\t`message_id`, `in_reply_to`)\n\t\tvalues ( ?, ?, ?, ?, ?, ?,\n\t\t\t0, 0, ?, ?, 0, 0, ?, ?, \n\t\t\t?, ?, ?, ?)";
         $result = $this->query($query, array($object[0], (string) $object[1], (int) $this->now, $userName, $title, $data, $hash, (int) $parentId, $type, $summary, $smiley, $_SERVER["REMOTE_ADDR"], $message_id, (string) $in_reply_to));
     }
     $threadId = $this->getOne("select `threadId` from\n\t\t`tiki_comments` where `hash`=?", array($hash));
     /* Force an index refresh of the data */
     include_once "lib/search/refresh-functions.php";
     refresh_index_comments($threadId);
     global $prefs;
     if ($prefs['feature_actionlog'] == 'y') {
         global $logslib;
         include_once 'lib/logs/logslib.php';
         global $tikilib;
         if ($parentId == 0) {
             $l = strlen($data);
         } else {
             $l = $tikilib->strlen_quoted($data);
         }
         if ($object[0] == 'forum') {
             $logslib->add_action($parentId == 0 ? 'Posted' : 'Replied', $object[1], $object[0], 'comments_parentId=' . $threadId . '&amp;add=' . $l, '', '', '', '', $contributions);
         } else {
             $logslib->add_action($parentId == 0 ? 'Posted' : 'Replied', $object[1], 'comment', 'type=' . $object[0] . '&amp;add=' . $l . '#threadId' . $threadId, '', '', '', '', $contributions);
         }
     }
     if ($prefs['feature_contribution'] == 'y') {
         global $contributionlib;
         include_once 'lib/contribution/contributionlib.php';
         $contributionlib->assign_contributions($contributions, $threadId, 'comment', $title, '', '');
     }
     if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
         require_once 'lib/search/refresh-functions.php';
         refresh_index('comments', $threadId);
     }
     $this->update_comment_links($data, $object[0], $threadId);
     return $threadId;
     //return $return_result;
 }
示例#15
0
 /**
  * Re-indexes the forum posts within a specified forum
  * @param $forumId
  */
 private function index_posts_by_forum($forumId)
 {
     $topics = $this->get_forum_topics($forumId);
     foreach ($topics as $topic) {
         if ($element === end($array)) {
             //if element is the last in the array, then run the process.
             refresh_index('forum post', $topic['threadId'], true);
         } else {
             refresh_index('forum post', $topic['threadId'], false);
             //don't run the process right away (re: false), wait until last element
         }
     }
 }
function wikiplugin_addrelation($data, $params)
{
	if (isset($params['source_object']) && false !== strpos($params['source_object'], ':')) {
		list($source_object['type'], $source_object['object']) = explode(':', $params['source_object'], 2);
	} else {
		$source_object = current_object();
	}
	if (isset($params['target_object']) && false !== strpos($params['target_object'], ':')) {
		list($target_object['type'], $target_object['object']) = explode(':', $params['target_object'], 2);
	} else {
		$target_object = current_object(); 
	}
	if ($source_object == $target_object) {
		return tra('Source and target object cannot be the same');
	}
	if (!isset($params['qualifier'])) {
		return WikiParser_PluginOutput::argumentError(array('qualifier'));
	} else {
		$qualifier = $params['qualifier'];
	}
	if (!empty($params['label_add'])) {
		$labeladd = $params['label_add'];	
	} else {
		$labeladd = tra('Add Relation');
	}
	if (!empty($params['label_remove'])) {
		$labelremove = $params['label_remove'];
	} else {
		$labelremove = tra('Remove Relation');
	}
	if (!empty($params['label_added'])) {
		$labeladded = $params['label_added'];
	} else {
		$labeladded = tra('Relation Added');
	}
	if (!empty($params['button_id'])) {
		$id = 'wp_addrelation_' . $params['button_id'];
	} else {
		$id = 'wp_addrelation_0';
	}
	$relationlib = TikiLib::lib('relation');

	if (isset($_POST[$id])) {
		if ($_POST[$id] == 'y') {
			$relationlib->add_relation($qualifier, $source_object['type'], $source_object['object'], $target_object['type'], $target_object['object']);	
		} elseif ($_POST[$id] == 'n') {
			$relation_id = $relationlib->add_relation($qualifier, $source_object['type'], $source_object['object'], $target_object['type'], $target_object['object']);
			$relationlib->remove_relation($relation_id);
		}
		require_once 'lib/search/refresh-functions.php';
		refresh_index($source_object['type'], $source_object['object']);
		refresh_index($target_object['type'], $target_object['object']);
	}
	$relationsfromsource = $relationlib->get_relations_from($source_object['type'], $source_object['object'], $qualifier);
	$relationexists = false;
	foreach ($relationsfromsource as $r) {
		if ($r['itemId'] == $target_object['object'] && $r['type'] == $target_object['type']) {
			$relationexists = true;
			break;
		}
	}

	$smarty = TikiLib::lib('smarty');
	$smarty->assign('wp_addrelation_id', $id);
	$smarty->assign('wp_addrelation_action', $relationexists ? 'n' : 'y');
	$smarty->assign('label_add', $labeladd);
	$smarty->assign('label_added', $labeladded);
	$smarty->assign('label_remove', $labelremove);
	return $smarty->fetch('wiki-plugins/wikiplugin_addrelation.tpl');
}
示例#17
0
 function reindex_all_files_for_search_text()
 {
     $files = $this->table('tiki_files');
     $rows = $files->fetchAll(array('fileId', 'filename', 'filesize', 'filetype', 'data', 'path', 'galleryId'), array('archiveId' => 0));
     foreach ($rows as $row) {
         $search_text = $this->get_search_text_for_data($row['data'], $row['path'], $row['filetype'], $row['galleryId']);
         if ($search_text !== false) {
             $files->update(array('search_data' => $search_text), array('fileId' => $row['fileId']));
         }
     }
     include_once "lib/search/refresh-functions.php";
     refresh_index('files');
 }
示例#18
0
文件: freetags.php 项目: rjsmelo/tiki
         $userid = $userlib->get_user_id($user);
     }
     if (empty($user) && $prefs['feature_antibot'] == 'y' && !$captchalib->validate()) {
         $smarty->assign('freetag_error', $captchalib->getErrors());
         $smarty->assign_by_ref('freetag_msg', $_POST['addtags']);
     } elseif ($object = current_object()) {
         $freetaglib->tag_object($userid, $object['object'], $object['type'], $_POST['addtags']);
         require_once 'lib/search/refresh-functions.php';
         refresh_index($object['type'], $object['object']);
     }
 }
 if (($tiki_p_admin == 'y' || $tiki_p_unassign_freetags == 'y') && isset($_REQUEST['delTag'])) {
     if ($object = current_object()) {
         $freetaglib->delete_object_tag($object['object'], $object['type'], $_REQUEST['delTag']);
         require_once 'lib/search/refresh-functions.php';
         refresh_index($object['type'], $object['object']);
     }
     $url = $tikilib->httpPrefix() . preg_replace('/[?&]delTag=' . preg_quote(urlencode($_REQUEST['delTag']), '/') . '/', '', $_SERVER['REQUEST_URI']);
     header("Location: {$url}");
     die;
 }
 if ($object = current_object()) {
     $tags = $freetaglib->get_tags_on_object($object['object'], $object['type']);
 } else {
     $tags = array();
 }
 $smarty->assign('freetags', $tags);
 if ($tiki_p_freetags_tag == 'y' && $prefs['freetags_multilingual'] == 'y') {
     $ft_lang = null;
     $ft_multi = false;
     if (!empty($tags['data'])) {
示例#19
0
    /**
     * importSQLForum importSQLForum will import the forum data from the specified SQL file and
     *  the specified forum ID, and append it to the end of the data in the
     *  destination forum. Datestamps will be retained.
     *
     * @param string $dbType
     * @param string $dbPrefix
     * @param string $sqlFile
     * @param string $fF SQL file
     * @param mixed $tF
     * @access public
     * @return int number of posts
     */
    function importSQLForum($dbType, $dbPrefix, $sqlFile, $fF, $tF)
    {
        $fHash = array();
        $row = array();
        $hash = array();
        // If part of a thread, this is the new parent threadId.
        // Select the table for the main forum information.
        if ($dbType == 'TikiWiki') {
            $table = 'comments';
            $ftable = $dbPrefix . $table;
            $ftable2 = $dbPrefix . 'forums';
        } else {
            return -1;
        }
        // Parse the SQL file and grab all posts for the source forum.
        $fHash = $this->parseSQL($dbType, $dbPrefix, $table, $sqlFile, $fF);
        $fPosts = count($fHash);
        $fPosts2 = $fPosts;
        // In order to accommodate out of order posts and still keep integrity
        // with threads, if a record has a parent ID (meaning it is part of a
        // thread), then when looping through the array, stick it on the end
        // and continue with the next one.
        for ($count = 0; $count < $fPosts2; $count++) {
            $row = array_shift($fHash);
            $pid = 0;
            if ($row['parentId'] != 0 && !$hash[$row['parentId']]) {
                array_push($fHash, $row);
                $fPosts2++;
                continue;
            } else {
                if ($row['parentId'] != 0) {
                    $pid = $hash[$row['parentId']];
                }
            }
            if ($dbType == 'TikiWiki') {
                $query = 'insert into
								`tiki_comments` (`objectType`, `object`, `commentDate`,
								`userName`, `title`, `data`, `votes`, `points`, `hash`,
								`parentId`, `average`, `hits`, `type`, `summary`, `user_ip`,
								`message_id`, `in_reply_to`)
								values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
                $result = $this->query($query, array('forum', $tF, $row["commentDate"], $row["userName"], $row["title"], $row["data"], (int) $row["votes"], $row["points"], $row["hash"], $pid, $row["average"], (int) $row["hits"], $row["type"], $row["summary"], $row["user_ip"], $row["message_id"], $row["in_reply_to"]));
                $abbb = $this->getOne("SELECT LAST_INSERT_ID() from {$ftable}");
                if (!$abbb) {
                    $abbb = $this->getOne("SELECT max(tableId) from {$ftable}");
                }
                $hash[$row['threadId']] = $abbb;
            } else {
                die("Only TikiWiki is supported at this time.\n");
            }
        }
        // Update forum counters.
        $query = "select count(*) from `tiki_comments` where `objectType` = 'forum' and `object` = ?";
        $tComments = $this->getOne($query, array((int) $tF));
        $query = "select count(*) from `tiki_comments` where `objectType` = 'forum' and `object` = ? and `parentId` = 0";
        $tThreads = $this->getOne($query, array((int) $tF));
        $query = 'update `tiki_forums` set `comments` = ?, `threads` = ? where `forumId` = ?';
        $result = $this->query($query, array((int) $tComments, (int) $tThreads, (int) $tF));
        // Force an index refresh on comments table.
        include_once 'lib/search/refresh-functions.php';
        refresh_index_forums();
        refresh_index('comments');
        return $fPosts;
    }
示例#20
0
 function action_process($input)
 {
     $id = $input->id->int();
     $userid = $input->userid->int();
     $username = $input->username->text();
     $fieldId = $input->fieldId->int();
     $command = $input->command->word();
     $svntag = $input->svntag->text();
     $item = Tracker_Item::fromId($id);
     if (!$item->canViewField($fieldId)) {
         throw new Services_Exception_Denied();
     }
     $field = TikiLib::lib('trk')->get_tracker_field($fieldId);
     $options = json_decode($field['options']);
     if (!is_object($options) && is_array($field['options_array'])) {
         // Support Tiki 11
         $options = new stdClass();
         $options->domain = $field['options_array'][0];
         $options->remoteShellUser = $field['options_array'][1];
         $options->publicKey = $field['options_array'][2];
         $options->privateKey = $field['options_array'][3];
     }
     $domain = $options->domain;
     $conn = ssh2_connect($domain, 22);
     $conntry = ssh2_auth_pubkey_file($conn, $options->remoteShellUser, $options->publicKey, $options->privateKey);
     if (!$conntry) {
         $ret['status'] = 'DISCO';
         return $ret;
     }
     $infostring = "info -i {$id} -U {$userid}";
     $infostream = ssh2_exec($conn, $infostring);
     stream_set_blocking($infostream, TRUE);
     $infooutput = stream_get_contents($infostream);
     $ret['debugoutput'] = $infooutput;
     if (strpos($infooutput, 'MAINTENANCE: ') !== false) {
         $maintpos = strpos($infooutput, 'MAINTENANCE: ');
         $maintreason = substr($infooutput, $maintpos + 13);
         $maintreason = substr($maintreason, 0, strpos($maintreason, '"'));
         $ret['maintreason'] = $maintreason;
         $ret['status'] = 'MAINT';
         return $ret;
     }
     $versionpos = strpos($infooutput, 'VERSION: ');
     $version = substr($infooutput, $versionpos + 9);
     $version = substr($version, 0, strpos($version, PHP_EOL));
     $version = trim($version);
     $ret['version'] = $version;
     $statuspos = strpos($infooutput, 'STATUS: ');
     $status = substr($infooutput, $statuspos + 8, 5);
     $status = trim($status);
     if (!$status || $status == 'FAIL') {
         $ret['status'] = 'FAIL';
     } else {
         $ret['status'] = $status;
         $sitepos = strpos($infooutput, 'SITE: ');
         $site = substr($infooutput, $sitepos + 6);
         $site = substr($site, 0, strpos($site, ' '));
         $ret['showurl'] = $site;
         $ret['showlogurl'] = $site . '/info.txt';
         $ret['snapshoturl'] = $site . '/snapshots/';
         if ($site && $ret['status'] == 'ACTIV') {
             $value = 'active ' . substr($site, 0, strpos($site, '.'));
             // the 'active' is useful for filtering on
             TikiLib::lib('trk')->modify_field($id, $fieldId, $value);
             require_once 'lib/search/refresh-functions.php';
             refresh_index('trackeritem', $id);
         } elseif ($ret['status'] == 'NONE') {
             $value = 'none';
             TikiLib::lib('trk')->modify_field($id, $fieldId, $value);
             require_once 'lib/search/refresh-functions.php';
             refresh_index('trackeritem', $id);
         }
     }
     if (!empty($command)) {
         if (($command == 'update' || $command == 'reset' || $command == 'destroy') && !TikiLib::lib('user')->user_has_permission($user, 'tiki_p_admin') && $user != $creator) {
             throw new Services_Exception_Denied();
         }
         if (empty($svntag)) {
             $fullstring = "{$command} -u {$creator} -i {$id} -U {$userid}";
         } else {
             $fullstring = "{$command} -t {$svntag} -u {$username} -i {$id} -U {$userid}";
         }
         $stream = ssh2_exec($conn, $fullstring);
         stream_set_blocking($stream, TRUE);
         $output = stream_get_contents($stream);
         fclose($stream);
         $ret['debugoutput'] = $fullstring . "\n" . $output;
         if ($command == 'snapshot') {
             $ret['status'] = 'SNAPS';
         } else {
             if ($command == 'destroy') {
                 $ret['status'] = 'DESTR';
             } else {
                 if ($command == 'create' || $command == 'update') {
                     $ret['status'] = 'BUILD';
                 } else {
                     if ($command == 'reset') {
                         if (strpos('ERROR', $fullstring) !== false) {
                             $ret['status'] = 'RENOK';
                         } else {
                             $ret['status'] = 'RESOK';
                         }
                     }
                 }
             }
         }
     }
     $ret['debugoutput'] = '-' . $status . '- ' . $ret['debugoutput'];
     $cachelib = TikiLib::lib('cache');
     $cacheKey = 'STO-' . $options->domain . '-' . $fieldId . "-" . $id;
     $cachelib->invalidate($cacheKey);
     return $ret;
 }
示例#21
0
 function replace_faq($faqId, $title, $description, $canSuggest)
 {
     // Check the name
     if ($faqId) {
         $query = 'update `tiki_faqs` set `title`=?,`description`=? ,`canSuggest`=? where `faqId`=?';
         $result = $this->query($query, array($title, $description, $canSuggest, (int) $faqId));
     } else {
         $query = 'delete from `tiki_faqs` where `title`=?';
         $result = $this->query($query, array($title), -1, -1, false);
         $query = 'insert into `tiki_faqs`(`title`,`description`,`created`,`hits`,`canSuggest`) values(?,?,?,?,?)';
         $result = $this->query($query, array($title, $description, (int) $this->now, 0, $canSuggest));
         $faqId = $this->getOne('select max(`faqId`) from `tiki_faqs` where `title`=? and `created`=?', array($title, (int) $this->now));
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('faqs', $faqId);
     return $faqId;
 }
示例#22
0
 function replace_article($title, $authorName, $topicId, $useImage, $imgname, $imgsize, $imgtype, $imgdata, $heading, $body, $publishDate, $expireDate, $user, $articleId, $image_x, $image_y, $type, $topline, $subtitle, $linkto, $image_caption, $lang, $rating = 0, $isfloat = 'n', $emails = '', $from = '', $list_image_x = '', $list_image_y = '', $ispublished = 'y')
 {
     global $smarty, $tikilib;
     if ($expireDate < $publishDate) {
         $expireDate = $publishDate;
     }
     $hash = md5($title . $heading . $body);
     if (empty($imgdata) || $useImage === 'n') {
         // remove image data if not using it
         $imgdata = '';
     }
     $query = 'select `name` from `tiki_topics` where `topicId` = ?';
     $topicName = $this->getOne($query, array($topicId));
     $size = $body ? mb_strlen($body) : mb_strlen($heading);
     if ($articleId) {
         $oldArticle = $this->get_article($articleId);
         $query = 'update `tiki_articles` set `title` = ?, `authorName` = ?, `topicId` = ?, `topicName` = ?, `size` = ?, `useImage` = ?, `image_name` = ?, ';
         $query .= ' `image_type` = ?, `image_size` = ?, `image_data` = ?, `isfloat` = ?, `image_x` = ?, `image_y` = ?, `list_image_x` = ?, `list_image_y` = ?, `heading` = ?, `body` = ?, ';
         $query .= ' `publishDate` = ?, `expireDate` = ?, `created` = ?, `author` = ?, `type` = ?, `rating` = ?, `topline`=?, `subtitle`=?, `linkto`=?, ';
         $query .= ' `image_caption`=?, `lang`=?, `ispublished`=? where `articleId` = ?';
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $topicName, (int) $size, $useImage, $imgname, $imgtype, (int) $imgsize, $imgdata, $isfloat, (int) $image_x, (int) $image_y, (int) $list_image_x, (int) $list_image_y, $heading, $body, (int) $publishDate, (int) $expireDate, (int) $this->now, $user, $type, (double) $rating, $topline, $subtitle, $linkto, $image_caption, $lang, $ispublished, (int) $articleId));
         // Clear article image cache because image may just have been changed
         $this->delete_image_cache('article', $articleId);
         $event = 'article_edited';
         $nots = $tikilib->get_event_watches('article_edited', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_edited', $topicId);
         $smarty->assign('mail_action', 'Edit');
         $smarty->assign('mail_old_title', $oldArticle['title']);
         $smarty->assign('mail_old_publish_date', $oldArticle['publishDate']);
         $smarty->assign('mail_old_expiration_date', $oldArticle['expireDate']);
         $smarty->assign('mail_old_data', $oldArticle['heading'] . "\n----------------------\n" . $oldArticle['body']);
     } else {
         // Insert the article
         $query = 'insert into `tiki_articles` (`title`, `authorName`, `topicId`, `useImage`, `image_name`, `image_size`, `image_type`, `image_data`, ';
         $query .= ' `publishDate`, `expireDate`, `created`, `heading`, `body`, `hash`, `author`, `nbreads`, `votes`, `points`, `size`, `topicName`, ';
         $query .= ' `image_x`, `image_y`, `list_image_x`, `list_image_y`, `type`, `rating`, `isfloat`,`topline`, `subtitle`, `linkto`,`image_caption`, `lang`, `ispublished`) ';
         $query .= ' values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
         $result = $this->query($query, array($title, $authorName, (int) $topicId, $useImage, $imgname, (int) $imgsize, $imgtype, $imgdata, (int) $publishDate, (int) $expireDate, (int) $this->now, $heading, $body, $hash, $user, 0, 0, 0, (int) $size, $topicName, (int) $image_x, (int) $image_y, (int) $list_image_x, (int) $list_image_y, $type, (double) $rating, $isfloat, $topline, $subtitle, $linkto, $image_caption, $lang, $ispublished));
         $query2 = 'select max(`articleId`) from `tiki_articles` where `created` = ? and `title`=? and `hash`=?';
         $articleId = $this->getOne($query2, array((int) $this->now, $title, $hash));
         global $prefs;
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'article_new');
         }
         $event = 'article_submitted';
         $nots = $tikilib->get_event_watches('article_submitted', '*');
         $nots2 = $tikilib->get_event_watches('topic_article_created', $topicId);
         $smarty->assign('mail_action', 'New');
     }
     $nots3 = array();
     foreach ($nots as $n) {
         $nots3[] = $n['email'];
     }
     foreach ($nots2 as $n) {
         if (!in_array($n['email'], $nots3)) {
             $nots[] = $n;
         }
     }
     if (is_array($emails) && (empty($from) || $from == $prefs['sender_email'])) {
         foreach ($emails as $n) {
             if (!in_array($n, $nots3)) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
         }
     }
     global $prefs;
     if ($prefs['user_article_watch_editor'] != "y") {
         for ($i = count($nots) - 1; $i >= 0; --$i) {
             if ($nots[$i]['user'] == $user) {
                 unset($nots[$i]);
                 break;
             }
         }
     }
     if (!isset($_SERVER['SERVER_NAME'])) {
         $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST'];
     }
     if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
         $reportsManager = Reports_Factory::build('Reports_Manager');
         $reportsManager->addToCache($nots, array('event' => $event, 'articleId' => $articleId, 'articleTitle' => $title, 'authorName' => $authorName, 'user' => $user));
     }
     if (count($nots) || is_array($emails)) {
         include_once 'lib/notifications/notificationemaillib.php';
         $smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
         $smarty->assign('mail_title', $title);
         $smarty->assign('mail_postid', $articleId);
         $smarty->assign('mail_user', $user);
         $smarty->assign('mail_current_publish_date', $publishDate);
         $smarty->assign('mail_current_expiration_date', $expireDate);
         $smarty->assign('mail_current_data', $heading . "\n----------------------\n" . $body);
         $smarty->assign('mail_heading', $heading);
         $smarty->assign('mail_body', $body);
         sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl');
         if (is_array($emails) && !empty($from) && $from != $prefs['sender_email']) {
             $nots = array();
             foreach ($emails as $n) {
                 $nots[] = array('email' => $n, 'language' => $prefs['site_language']);
             }
             sendEmailNotification($nots, 'watch', 'user_watch_article_post_subject.tpl', $_SERVER['SERVER_NAME'], 'user_watch_article_post.tpl', $from);
         }
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('articles', $articleId);
     global $tikilib;
     $tikilib->object_post_save(array('type' => 'article', 'object' => $articleId, 'description' => substr($heading, 0, 200), 'name' => $title, 'href' => "tiki-read_article.php?articleId={$articleId}"), array('content' => $body . "\n" . $heading));
     return $articleId;
 }
示例#23
0
 function deleteActivity($id)
 {
     $info = $this->streamTable()->delete(array('activityId' => $id));
     require_once 'lib/search/refresh-functions.php';
     refresh_index('activity', $id);
 }
示例#24
0
} else {
    $_REQUEST["categId"] = 0;
    $info["name"] = '';
    $info["description"] = '';
}
if (isset($_REQUEST["removeObject"])) {
    $access->check_authenticity();
    $category = $categlib->get_category($_REQUEST["parentId"]);
    $categorizedObject = $categlib->get_categorized_object_via_category_object_id($_REQUEST["removeObject"]);
    $categlib->remove_object_from_category($_REQUEST["removeObject"], $_REQUEST["parentId"]);
    // Notify the users watching this category.
    $values = array("categoryId" => $_REQUEST["parentId"], "categoryName" => $category['name'], "categoryPath" => $categlib->get_category_path_string_with_root($_REQUEST["parentId"]), "description" => $category['description'], "parentId" => $category['parentId'], "parentName" => $categlib->get_category_name($category['parentId']), "action" => "object leaved category", "objectName" => $categorizedObject['name'], "objectType" => $categorizedObject['type'], "objectUrl" => $categorizedObject['href']);
    $categlib->notify($values);
    // update search index if required
    require_once 'lib/search/refresh-functions.php';
    refresh_index($categorizedObject['type'], $categorizedObject['itemId']);
}
if (isset($_REQUEST["removeCat"]) && ($info = $categlib->get_category($_REQUEST['removeCat']))) {
    $access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['removeCat']);
    $access->check_authenticity(tra('Click here to delete the category:') . ' ' . $info['name']);
    $categlib->remove_category($_REQUEST["removeCat"]);
}
if (isset($_REQUEST["save"]) && isset($_REQUEST["name"]) && strlen($_REQUEST["name"]) > 0) {
    check_ticket('admin-categories');
    // Save
    if ($_REQUEST["categId"]) {
        if ($_REQUEST['parentId'] == $_REQUEST['categId']) {
            $smarty->assign('msg', tra("Category can`t be parent of itself"));
            $smarty->display("error.tpl");
            die;
        }
示例#25
0
 /**
  * Updates a blog post
  *
  * @param int $postId
  * @param int $blogId
  * @param string $data
  * @param string $excerpt
  * @param string $user
  * @param string $title
  * @param string $contributions
  * @param string $priv
  * @param bool $is_wysiwyg
  * @access public
  * @return void
  */
 function update_post($postId, $blogId, $data, $excerpt, $user, $title = '', $contributions = '', $priv = 'n', $created = 0, $is_wysiwyg = FALSE)
 {
     global $prefs;
     $tikilib = TikiLib::lib('tiki');
     if ($is_wysiwyg) {
         $data = TikiFilter::get('purifier')->filter($data);
         $excerpt = TikiFilter::get('purifier')->filter($excerpt);
     }
     $wysiwyg = $is_wysiwyg == TRUE ? 'y' : 'n';
     if ($prefs['feature_blog_edit_publish_date'] == 'y') {
         if (!$created) {
             $created = $tikilib->now;
         }
         $query = "update `tiki_blog_posts` set `blogId`=?,`data`=?,`excerpt`=?,`created`=?,`user`=?,`title`=?, `priv`=?, `wysiwyg`=? where `postId`=?";
         $result = $this->query($query, array($blogId, $data, $excerpt, $created, $user, $title, $priv, $wysiwyg, $postId));
     } else {
         $query = "update `tiki_blog_posts` set `blogId`=?,`data`=?,`excerpt`=?,`user`=?,`title`=?, `priv`=?, `wysiwyg`=? where `postId`=?";
         $result = $this->query($query, array($blogId, $data, $excerpt, $user, $title, $priv, $wysiwyg, $postId));
     }
     if ($prefs['feature_actionlog'] == 'y') {
         $logslib = TikiLib::lib('logs');
         $logslib->add_action('Updated', $blogId, 'blog', "blogId={$blogId}&amp;postId={$postId}#postId{$postId}", '', '', '', '', $contributions);
     }
     require_once 'lib/search/refresh-functions.php';
     refresh_index('blog_posts', $postId);
     $tikilib->object_post_save(array('type' => 'blog post', 'object' => $postId), array('content' => $data));
 }
示例#26
0
 /**
  * Perform actions with file metadata stored in the database
  *
  * @param		numeric		$fileId					fileId of the file in the file gallery
  * @param		string		$action					action to perform regarding metadata
  *
  * The following actions are handled:
  * 		'get_array'			Get file metadata from database column or, if that is empty, extract metadata from the
  * 							file, update the database and return an array of the data.
  *
  * 		'refresh'			Extract metadata from the file and update database - nothing is returned
  *
  * @return 		array		$metadata				array of metadata is returned is action is 'get_array'
  */
 function metadataAction($fileId, $action = 'get_array')
 {
     //get the tiki_files table
     $filesTable = $this->table('tiki_files');
     if ($action == 'get_array') {
         //get metadata for the file from the database
         $metacol = $filesTable->fetchColumn('metadata', array('fileId' => $fileId));
     }
     //if metadata field is empty, or if a refresh, extract from the file
     if ($action == 'get_array' && empty($metacol[0]) || $action == 'refresh') {
         //preparing parameters
         $path = $filesTable->fetchColumn('path', array('fileId' => $fileId));
         if (!empty($path[0])) {
             global $prefs;
             $file = $prefs['fgal_use_dir'] . $path[0];
             $ispath = true;
         } else {
             $file = $filesTable->fetchColumn('data', array('fileId' => $fileId));
             $file = $file[0];
             $ispath = false;
         }
         //extract metadata
         $metadata = $this->extractMetadataJson($file, $ispath);
         //update database for newly extracted metadata
         $filesTable->update(array('metadata' => $metadata), array('fileId' => $fileId));
         // update search index
         require_once 'lib/search/refresh-functions.php';
         refresh_index('files', $fileId);
     } else {
         $metadata = $metacol[0];
     }
     if ($action == 'get_array') {
         //return metadata as an array
         return json_decode($metadata, true);
     }
 }
示例#27
0
 private function update_index($type, $threadId, $parentId = null)
 {
     require_once 'lib/search/refresh-functions.php';
     global $prefs;
     if ($type == 'forum') {
         $type = 'forum post';
         $root = $this->find_root($parentId ? $parentId : $threadId);
         refresh_index($type, $root);
         if ($prefs['unified_forum_deepindexing'] != 'y') {
             if ($threadId != $root) {
                 refresh_index($type, $threadId);
             }
             if ($parentId && $parentId != $root && $parentId != $threadId) {
                 refresh_index($type, $parentId);
             }
         }
         return $type;
     } else {
         refresh_index('comments', $threadId);
         return $type . ' comment';
     }
 }
示例#28
0
 /** Update a wiki page
 	 @param array $hash- lock_it,contributions, contributors
 	 **/
 function update_page($pageName, $edit_data, $edit_comment, $edit_user, $edit_ip, $description = '', $minor = false, $lang = '', $is_html = false, $hash = null, $saveLastModif = null, $wysiwyg = '', $wiki_authors_style)
 {
     global $smarty, $prefs, $dbTiki, $histlib, $quantifylib;
     include_once "lib/wiki/histlib.php";
     include_once "lib/commentslib.php";
     $commentslib = new Comments($dbTiki);
     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);
     if (!$this->page_exists($pageName)) {
         return false;
     }
     // Get this page information
     $info = $this->get_page_info($pageName);
     // 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) + 1);
     $lastModif = $info["lastModif"];
     $user = $info["user"];
     if (!$user) {
         $user = '******';
     }
     $ip = $info["ip"];
     $comment = $info["comment"];
     $data = $info["data"];
     // WARNING: POTENTIAL BUG
     // The line below is not consistent with the rest of Tiki
     // (I commented it out so it can be further examined by CVS change control)
     //$pageName=addslashes($pageName);
     // But this should work (comment added by redflo):
     $version = $old_version + 1;
     if ($prefs['quantify_changes'] == 'y' && $prefs['feature_multilingual'] == 'y') {
         include_once 'lib/wiki/quantifylib.php';
         $quantifylib->recordChangeSize($info['page_id'], $version, $info['data'], $edit_data);
     }
     $html = $is_html ? 1 : 0;
     if ($html && $prefs['feature_purifier'] != 'n') {
         require "HTMLPurifier.auto.php";
         $purifier = new HTMLPurifier();
         $edit_data = $purifier->purify($edit_data);
     }
     $mid = '';
     if (is_null($saveLastModif)) {
         $saveLastModif = $this->now;
     }
     $bindvars = array($description, $edit_data, $edit_comment, (int) $saveLastModif, $version, $edit_user, $edit_ip, (int) strlen($data), $html, $wysiwyg, $wiki_authors_style);
     if ($lang) {
         $mid .= ', `lang`=? ';
         $bindvars[] = $lang;
     }
     if (!empty($hash['lock_it']) && ($hash['lock_it'] == 'y' || $hash['lock_it'] == 'on')) {
         $mid .= ', `flag`=?, `lockedby`=? ';
         $bindvars[] = 'L';
         $bindvars[] = $user;
     } else {
         if (empty($hash['lock_it']) || $hash['lock_it'] == 'n') {
             $mid .= ', `flag`=?, `lockedby`=? ';
             $bindvars[] = '';
             $bindvars[] = '';
         }
     }
     if (empty($hash['contributions'])) {
         $hash['contributions'] = '';
     }
     if (empty($hash['contributors'])) {
         $hash2 = '';
     } else {
         foreach ($hash['contributors'] as $c) {
             $hash3['contributor'] = $c;
             $hash2[] = $hash3;
         }
     }
     $bindvars[] = $pageName;
     $query = "update `tiki_pages` set `description`=?, `data`=?, `comment`=?, `lastModif`=?, `version`=?, `user`=?, `ip`=?, `page_size`=?, `is_html`=?, `wysiwyg`=?, `wiki_authors_style`=?  {$mid} where `pageName`=?";
     $result = $this->query($query, $bindvars);
     // Parse edit_data updating the list of links from this page
     $this->clear_links($pageName);
     // Pages collected above
     foreach ($pages as $page) {
         $this->replace_link($pageName, $page);
     }
     if (strtolower($pageName) != 'sandbox' && !$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;
             $query = "select `pageName` ,`version`, `historyId` from `tiki_history` where `pageName`=? and `lastModif`<=? order by `lastModif` asc";
             $result = $this->query($query, array($pageName, $oktodel), $nb - $maxversions);
             $toelim = $result->numRows();
             while ($res = $result->fetchRow()) {
                 $page = $res["pageName"];
                 $version = $res["version"];
                 $query = "delete from `tiki_history` where `pageName`=? and `version`=?";
                 $this->query($query, array($pageName, $version));
                 if ($prefs['feature_contribution'] == 'y') {
                     global $contributionlib;
                     include_once 'lib/contribution/contributionlib.php';
                     $contributionlib->remove_history($res['historyId']);
                 }
             }
         }
     }
     // This if no longer checks for minor-ness of the change; sendWikiEmailNotification does that.
     if ($prefs['feature_wiki_history_full'] == 'y' || $data != $edit_data || $description != $info["description"] || $comment != $edit_comment) {
         if (strtolower($pageName) != 'sandbox') {
             $query = "insert into `tiki_history`(`pageName`, `version`, `lastModif`, `user`, `ip`, `comment`, `data`, `description`)\n\t\t    values(?,?,?,?,?,?,?,?)";
             # echo "<pre>";print_r(get_defined_vars());echo "</pre>";die();
             $result = $this->query($query, array($pageName, (int) $old_version, (int) $lastModif, $user, $ip, $comment, $data, $description));
             if ($prefs['feature_contribution'] == 'y') {
                 // transfer page contributions to the history
                 global $contributionlib;
                 include_once 'lib/contribution/contributionlib.php';
                 $query = 'select max(`historyId`) from `tiki_history`where `pageName`=? and `version`=?';
                 $historyId = $this->getOne($query, array($pageName, (int) $old_version));
                 $contributionlib->change_assigned_contributions($pageName, 'wiki page', $historyId, 'history', '', $pageName . '/' . $old_version, "tiki-pagehistory.php?page={$pageName}&preview={$old_version}");
             }
             /* the following doesn't work because tiki dies if the above query fails
             		if (!$result) {
             			$query2 = "delete from `tiki_history` where `pageName`=? and `version`=?";
             			$result = $this->query($query2,array($pageName,(int) $version));
             			$result = $this->query($query,array($pageName,(int) $version,(int) $lastModif,$user,$ip,$comment,$data,$description));
             		}
             		*/
         }
         if (strtolower($pageName) != 'sandbox') {
             global $logslib;
             include_once 'lib/logs/logslib.php';
             include_once 'lib/diff/difflib.php';
             $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') {
                 global $contributionlib;
                 include_once 'lib/contribution/contributionlib.php';
                 $contributionlib->assign_contributions($hash['contributions'], $pageName, 'wiki page', $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->query("UPDATE tiki_translated_objects SET lang = ? WHERE objId = ? AND type = 'wiki page'", array($lang, $info['page_id']));
         }
         if ($prefs['feature_user_watches'] == 'y' && $prefs['wiki_watch_minor'] != 'n') {
             //  Deal with mail notifications.
             include_once 'lib/notifications/notificationemaillib.php';
             global $histlib;
             include_once "lib/wiki/histlib.php";
             $old = $histlib->get_version($pageName, $old_version);
             $foo = parse_url($_SERVER["REQUEST_URI"]);
             $machine = $this->httpPrefix() . dirname($foo["path"]);
             require_once 'lib/diff/difflib.php';
             $diff = diff2($old["data"], $edit_data, "unidiff");
             sendWikiEmailNotification('wiki_page_changed', $pageName, $edit_user, $edit_comment, $old_version, $edit_data, $machine, $diff, $minor, $hash['contributions']);
         }
         $query = "delete from `tiki_page_drafts` where `user`=? and `pageName`=?";
         $this->query($query, array($GLOBALS['user'], $pageName));
         if ($prefs['feature_score'] == 'y') {
             $this->score_event($user, 'wiki_edit');
         }
     }
     if ($prefs['feature_search'] == 'y' && $prefs['feature_search_fulltext'] != 'y' && $prefs['search_refresh_index_mode'] == 'normal') {
         require_once 'lib/search/refresh-functions.php';
         refresh_index('pages', $pageName);
     }
 }
示例#29
0
//smarty is not there - we need setup
require_once 'tiki-setup.php';
$access = TikiLib::lib('access');
$access->check_script($_SERVER["SCRIPT_NAME"], basename(__FILE__));
global $prefs;
global $tiki_p_freetags_tag;
if ($prefs['feature_freetags'] == 'y' and $tiki_p_freetags_tag == 'y') {
    $freetaglib = TikiLib::lib('freetag');
    if (isset($_REQUEST['freetag_string'])) {
        $tag_string = $_REQUEST['freetag_string'];
    } else {
        $tag_string = '';
    }
    global $user;
    if (!isset($cat_desc)) {
        $cat_desc = '';
    }
    if (!isset($cat_name)) {
        $cat_name = '';
    }
    if (!isset($cat_href)) {
        $cat_href = '';
    }
    if (!isset($cat_lang)) {
        $cat_lang = null;
    }
    $freetaglib->add_object($cat_type, $cat_objid, FALSE, $cat_desc, $cat_name, $cat_href);
    $freetaglib->update_tags($user, $cat_objid, $cat_type, $tag_string, false, $cat_lang);
    require_once 'lib/search/refresh-functions.php';
    refresh_index($cat_type, $cat_objid);
}
示例#30
0
文件: categlib.php 项目: rjsmelo/tiki
 function uncategorize($catObjectId, $categId)
 {
     global $prefs;
     $query = "delete from `tiki_category_objects` where `catObjectId`=? and `categId`=?";
     $result = $this->query($query, array((int) $catObjectId, (int) $categId), -1, -1, false);
     $cachelib = TikiLib::lib('cache');
     if ($prefs['categories_cache_refresh_on_object_cat'] != "n") {
         $cachelib->empty_type_cache("allcategs");
     }
     $info = TikiLib::lib('object')->get_object_via_objectid($catObjectId);
     if ($prefs['feature_actionlog'] == 'y') {
         $logslib = TikiLib::lib('logs');
         $logslib->add_action('Uncategorized', $info['itemId'], $info['type'], "categId={$categId}");
     }
     TikiLib::events()->trigger('tiki.object.categorized', array('object' => $info['itemId'], 'type' => $info['type'], 'added' => array(), 'removed' => array($categId)));
     require_once 'lib/search/refresh-functions.php';
     refresh_index($info['type'], $info['itemId']);
 }