function data_include($data, $params) { $ret = "<p>Please enter a valid 'page_name', 'page_id' or 'content_id' to include in this page.</p>"; // load page by page_id if (isset($params['page_id']) && is_numeric($params['page_id'])) { require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage($params['page_id']); if ($wp->load()) { $ret = $wp->parseData($wp->mInfo); } // load page by content_id } elseif (isset($params['content_id']) && is_numeric($params['content_id'])) { if ($obj = LibertyBase::getLibertyObject($params['content_id'])) { $ret = $obj->parseData(); } // load page by page_name } elseif (isset($params['page_name'])) { $ret = "page_name isn't working yet, please use page_id or content_id"; } // if $ret is empty, we need to make sure there is at least a space that we get rid of the {} if (empty($ret)) { $ret = ' '; } return $ret; }
function data_addjstabs($data, $params) { global $gBitSmarty; $gBitSmarty->loadPlugin('smarty_block_jstab'); $gBitSmarty->loadPlugin('smarty_block_jstabs'); extract($params, EXTR_SKIP); $id = 1000000 * microtime(); $html = ''; $good = false; for ($i = 1; $i <= 99; $i++) { if (isset(${'tab' . $i})) { if (is_numeric(${'tab' . $i})) { if ($obj = LibertyBase::getLibertyObject(${'tab' . $i})) { $params['title'] = $obj->getTitle(); $html .= smarty_block_jstab($params, $obj->mInfo['parsed_data'], $gBitSmarty, ''); $good = True; } } else { $good = false; } } } if (!$good) { $html = tra("The plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'"); } if (!empty($html)) { return smarty_block_jstabs(array(), $html, $gBitSmarty, ''); } else { return $html; } }
function modcomments_content_store(&$pObject, &$pParamHash) { global $gBitSystem, $gBitUser, $gModerationSystem; if ($pObject->mType['content_type_guid'] == 'bitcomment') { // load up root content since we don't have one $rootContent = LibertyBase::getLibertyObject($pParamHash['root_id']); // hold comments for moderation - requires moderation package is installed if ($gBitSystem->isPackageActive('moderation') && empty($_REQUEST['post_comment_id']) && !($rootContent->isOwner() || $gBitUser->isAdmin()) && ($gBitSystem->isFeatureActive('comments_moderate_all') || ($gBitSystem->isFeatureActive('comments_allow_moderation') || $gBitSystem->isFeatureActive('comments_allow_owner_moderation')) && $rootContent->getPreference('moderate_comments'))) { // if we are enforcing moderation on the comment then change the status_id $pObject->storeStatus(-1); // prep info what we'll store in the moderation ticket $modMsg = tra("A comment has been submitted to ") . $rootContent->getContentTypeName() . " " . $rootContent->getTitle(); $modDataHash = array('display_url' => $pObject->getDisplayUrl()); if ($gBitSystem->isFeatureActive('comments_allow_owner_moderation')) { $modUserId = $rootContent->mInfo['user_id']; } else { $modUserId = 2; //assign it to admin rather than the owner so as to prevent content owner from accessing if they should not be able to } // register it for moderation $pendingModeration = $gModerationSystem->requestModeration('liberty', 'comment_post', $modUserId, NULL, 'p_liberty_edit_comments', $pObject->mContentId, $modMsg, MODERATION_PENDING, $modDataHash); } } elseif ($gBitSystem->isPackageActive('moderation') && ($gBitSystem->isFeatureActive('comments_allow_owner_moderation') && $pObject->hasUpdatePermission() || $gBitSystem->isFeatureActive('comments_allow_moderation') && ($gBitUser->isAdmin() || $pObject->hasUserPermission('p_liberty_edit_comments')))) { $pObject->storePreference('moderate_comments', !empty($pParamHash['moderate_comments']) && $pParamHash['moderate_comments'] == 'y' ? $pParamHash['moderate_comments'] : NULL); } }
/** * given a content_type_guid this will return an object of the proper type * * @param the content type to be loaded */ function getLibertyClass($pContentTypeGuid) { // We can abuse getLibertyObject to do the work $ret = LibertyBase::getLibertyObject('1', $pContentTypeGuid, FALSE); // Make sure we don't have a content_id set though. unset($ret->mContentId); return $ret; }
/** * get list of all rated content * * @param $pListHash contains array of items used to limit search results * @param $pListHash[sort_mode] column and orientation by which search results are sorted * @param $pListHash[find] search for a pigeonhole title - case insensitive * @param $pListHash[max_records] maximum number of rows to return * @param $pListHash[offset] number of results data is offset by * @access public * @return array of rated content **/ function getList(&$pListHash) { global $gBitSystem, $gBitUser, $gLibertySystem; $ret = $bindVars = array(); $where = $join = $select = ''; // set custom sorting before we call prepGetList() if (!empty($pListHash['sort_mode'])) { $order = " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } else { // set a default sort_mode $order = " ORDER BY sts.`rating` DESC"; } LibertyBase::prepGetList($pListHash); if (!empty($pListHash['user_id'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " sth.`user_id`=? "; $bindVars[] = $pListHash['user_id']; $select .= ", sth.`rating` AS `user_rating`"; $join .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "stars_history` sth ON( sts.`content_id` = sth.`content_id` ) "; $order = " ORDER BY sth.`rating` DESC"; } if (!empty($pListHash['find'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " UPPER( lc.`title` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } $query = "\n\t\t\tSELECT sts.*, lch.`hits`, lch.`last_hit`, lc.`event_time`, lc.`title`,\n\t\t\tlc.`last_modified`, lc.`content_type_guid`, lc.`ip`, lc.`created` {$select}\n\t\t\tFROM `" . BIT_DB_PREFIX . "stars` sts\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = sts.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t{$join} {$where} {$order}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); $stars = $gBitSystem->getConfig('stars_used_in_display', 5); $pixels = $stars * $gBitSystem->getConfig('stars_icon_width', 22); while ($aux = $result->fetchRow()) { $type =& $gLibertySystem->mContentTypes[$aux['content_type_guid']]; if (empty($type['content_object'])) { include_once $gBitSystem->mPackages[$type['handler_package']]['path'] . $type['handler_file']; $type['content_object'] = new $type['handler_class'](); } if (!empty($gBitSystem->mPackages[$type['handler_package']])) { $aux['display_link'] = $type['content_object']->getDisplayLink($aux['title'], $aux); $aux['title'] = $type['content_object']->getTitleFromHash($aux); $aux['display_url'] = $type['content_object']->getDisplayUrl($aux); $aux['stars_pixels'] = $aux['rating'] * $pixels / 100; } $ret[] = $aux; } $query = "\n\t\t\tSELECT COUNT( sts.`content_id` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "stars` sts\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = sts.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t{$join} {$where}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return $ret; }
/** * getList * * @param array $pListHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function getList(&$pListHash) { global $gLibertySystem; if (empty($pListHash['sort_mode'])) { $pListHash['sort_mode'] = 'tagpos_asc'; } LibertyBase::prepGetList($pListHash); $bindvars = array(); if (!empty($pListHash['find'])) { $findesc = '%' . $pListHash['find'] . '%'; $mid = " WHERE (`tagname` LIKE ?)"; $bindvars[] = $findesc; if (!empty($pListHash['format_guid'])) { $mid = " AND `format_guid`=?"; $bindvars[] = $pListHash['format_guid']; } } elseif (!empty($pListHash['format_guid'])) { $mid = " WHERE `format_guid`=?"; $bindvars[] = $pListHash['format_guid']; } else { $mid = ''; } $query = "SELECT * FROM `" . BIT_DB_PREFIX . "quicktags` {$mid} ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $result = $this->mDb->query($query, $bindvars, $pListHash['max_records'], $pListHash['offset']); $tmp = array(); while ($res = $result->fetchRow()) { $res['iconpath'] = $res['tagicon']; $tmp[] = $res; } $ret = array(); foreach ($gLibertySystem->mPlugins as $plugin) { if ($plugin['plugin_type'] == 'format') { foreach ($tmp as $qt) { if ($qt['format_guid'] == $plugin['plugin_guid']) { $ret[$plugin['plugin_guid']][] = $qt; } } } } $pListHash["cant"] = $this->mDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "quicktags` {$mid}", $bindvars); LibertyContent::postGetList($pListHash); return $ret; }
function data_addtabs($data, $params) { extract($params, EXTR_SKIP); $id = 1000000 * microtime(); $ret = '<div class="tabpane" id="id_' . $id . '">'; $good = false; for ($i = 1; $i <= 99; $i++) { if (isset(${'tab' . $i})) { if (is_numeric(${'tab' . $i})) { if ($obj = LibertyBase::getLibertyObject(${'tab' . $i})) { $ret .= '<div class="tabpage"><h4 id="tab_' . $id . '_' . $i . '" class="tab">' . $obj->getTitle() . '</h4>' . $obj->mInfo['parsed_data'] . '</div>'; $good = True; } } else { $good = false; } } } $ret .= "</div><script type=\"text/javascript\">//<![CDATA[\nsetupAllTabs()\n//]]></script>"; if (!$good) { $ret = tra("The plugin AddTabs requires valid parameters. Numeric content id numbers can use the parameter names 'tab1' thru 'tab99'"); } return $ret; }
/** * Sets the reply for a given request and triggers * the callback to the package. */ function setModerationReply($pRequestId, $pStatus, $pReply = NULL) { global $gBitSystem, $gBitUser; // Load the information $moderationInfo = $this->getModeration($pRequestId); if (!empty($moderationInfo)) { $isValidUser = FALSE; // Validate that the current user is a moderator if ($gBitUser->isAdmin() || $gBitUser->mUserId == $moderationInfo['moderator_user_id'] || $gBitUser->isInGroup($moderationInfo['moderator_group_id'])) { $isValidUser = TRUE; // if those checks fail then lets bother loading up the object and checking the perm if we have one } elseif (!empty($moderationInfo['moderator_perm_name']) && ($obj = LibertyBase::getLibertyObject($moderationInfo['content_id'])) && ($obj->mType['content_type_guid'] == 'bitcomment' && $obj->getRootObj()->hasUserPermission($moderationInfo['moderator_perm_name'])) || $obj->mType['content_type_guid'] != 'bitcomment' && $obj->hasUserPermission($moderationInfo['moderator_perm_name'])) { $isValidUser = TRUE; } if ($isValidUser) { // Some shorthands for current state $pkg = $moderationInfo['package']; $type = $moderationInfo['type']; $state = $moderationInfo['status']; // Validate that we are making a valid transition if (is_array($moderationInfo['transitions']) && in_array($pStatus, $moderationInfo['transitions']) || $pStatus == $moderationInfo['transitions']) { $moderationInfo['last_status'] = $state; $moderationInfo['status'] = $pStatus; if (!empty($pReply)) { $moderationInfo['reply'] = $pReply; } // We start the transaction now so that the update // to status is bundled with package updates $this->mDb->StartTrans(); // TODO: Set the send_email flag based on user // preferences here. Should be able // to set preferences for both ones for which I // am the moderator as well as ones for which // I am the source_user_id $moderationInfo['send_email'] = TRUE; // Set who is responsible next before the callback. if ($moderationInfo['responsible'] == MODERATION_NEEDED) { $moderationInfo['next_responsible'] = MODERATION_GIVEN; } else { $moderationInfo['next_responsible'] = MODERATION_NEEDED; } // Make the callback and check the reply from the package. $result = $this->mPackages[$pkg]['callback']($moderationInfo); // Do we need to send a message about this event? if (!empty($moderationInfo['send_email'])) { // TODO: Make a call to switchboard here } if ($result == TRUE) { // Do the SQL dance $table = BIT_DB_PREFIX . "moderation"; $locId = array('moderation_id' => $moderationInfo['moderation_id']); unset($moderationInfo['moderation_id']); if ($moderationInfo['status'] == MODERATION_DELETE) { $this->mDb->query("DELETE FROM `" . $table . "` WHERE moderation_id = ? ", $locId); } else { $update['reply'] = $moderationInfo['reply']; $update['status'] = $moderationInfo['status']; $update['last_status'] = $moderationInfo['last_status']; $update['responsible'] = $moderationInfo['next_responsible']; $this->mDb->associateUpdate($table, $update, $locId); } // Now notify any observers if (!empty($this->mObserved) && !empty($this->mObserved[$moderationInfo['package']])) { foreach ($this->mObserved[$moderationInfo['package']] as $observer => $callback) { $callback($moderationInfo); } } $this->mDb->CompleteTrans(); } else { // Just in case rollback any changes. $this->mDb->RollbackTrans(); $gBitSystem->fatalError(tra("Error with moderation:") . $result); } } else { $gBitSystem->fatalError(tra("Attempt to change to an invalid state for moderation: ") . $pRequestId . tra(" currently in: ") . $state . tra(" going to: ") . $pStatus); } } else { $gBitSystem->setHttpStatus(403); $gBitSystem->fatalError(tra("Unable to set moderation reply. You are not a moderator for this moderation request.")); } } else { $gBitSystem->setHttpStatus(404); $gBitSystem->fatalError(tra("Unable to set moderation reply. Moderation with id: ") . $pRequestId . tra(" could not be found.")); } }
/** * Liberty override to stuff content_status_id and prepares parameters with default values for any getList function * @param pParamHash hash of parameters for any getList() function * @return the link to display the page. */ public static function prepGetList(&$pListHash) { global $gBitUser; if ($gBitUser->isAdmin()) { $pListHash['min_content_status_id'] = -9999; } elseif (!empty($this) && is_object($this) && $this->hasAdminPermission()) { $pListHash['min_content_status_id'] = -999; } elseif (!empty($this) && is_object($this) && $this->hasUpdatePermission()) { $pListHash['min_content_status_id'] = -99; } else { $pListHash['min_content_status_id'] = 1; } if (empty($pListHash['query_cache_time'])) { $pListHash['query_cache_time'] = 0; } // if sort_mode is not set then use last_modified_desc if (!empty($pListHash['sort_mode'])) { if (is_string($pListHash['sort_mode']) && strpos($pListHash['sort_mode'], 'hits_') === 0) { // if sort mode is hits_*, then assume liberty content $pListHash['sort_mode'] = 'lch.' . $pListHash['sort_mode']; } elseif (is_array($pListHash['sort_mode'])) { foreach ($pListHash['sort_mode'] as $key => $mode) { if (strpos($mode, 'hits_') === 0) { $pListHash['sort_mode'][$key] = 'lch.' . $mode; } } } } else { // if sort_mode is not set then use last_modified_desc $pListHash['sort_mode'] = 'last_modified_desc'; } // Users without permission can only see their own content listing if ($gBitUser->isRegistered() && !$gBitUser->hasPermission('p_liberty_list_content')) { $pListHash['user_id'] = $gBitUser->mUserId; } return parent::prepGetList($pListHash); }
function getList(&$pListHash) { global $gBitUser, $gBitSystem, $gBitSmarty, $gLibertySystem; if (empty($_REQUEST["sort_mode"])) { $pListHash['sort_mode'] = 'shout_time_desc'; } LibertyBase::prepGetList($pListHash); $bindvars = array(); $mid = ''; if (!empty($pListHash['find'])) { $mid = " WHERE (UPPER(`shout_message`) like ?)"; $bindvars = array('%' . strtoupper($pListHash['find']) . '%'); } if (!empty($pListHash['user_id'])) { $mid .= empty($mid) ? ' WHERE ' : ' AND '; $mid .= " `shout_user_id` = ?"; array_push($bindvars, $pListHash['user_id']); } if (!empty($pListHash['to_user_id'])) { $mid .= empty($mid) ? ' WHERE ' : ' AND '; $mid .= " `to_user_id` = ?"; array_push($bindvars, $pListHash['to_user_id']); } $query = "\n\t\t\tSELECT * FROM `" . BIT_DB_PREFIX . "shoutbox` sh\n\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uus ON (sh.`shout_user_id`=uus.`user_id`) {$mid}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $result = $this->mDb->query($query, $bindvars, $pListHash['max_records'], $pListHash['offset']); $ret = array(); while ($res = $result->fetchRow()) { if (!$res["shout_user_id"]) { $res["shout_user_id"] = tra('Anonymous'); } // get cached version if we have it if (!$this->mCache->isCached($res['shout_id'], filemtime(__FILE__))) { // convert ampersands and other stuff to xhtml compliant entities $res["shout_message"] = htmlspecialchars($res["shout_message"]); if ($gBitSystem->isFeatureActive('shoutbox_autolink')) { $hostname = ''; if ($gBitSystem->getConfig('shoutbox_autolink') == 'm') { //moderated URL's $hostname = $gBitSystem->getConfig('kernel_server_name') ? $gBitSystem->getConfig('kernel_server_name') : $_SERVER['HTTP_HOST']; } // we replace urls starting with http(s)|ftp(s) to active links $res["shout_message"] = preg_replace("/((http|ftp)+(s)?:\\/\\/[^<>\\s]*" . $hostname . "[^<>\\s]*)/i", "<a href=\"\\0\">\\0</a>", $res["shout_message"]); // we replace also urls starting with www. only to active links $res["shout_message"] = preg_replace("/(?<!http|ftp)(?<!s)(?<!:\\/\\/)(www\\." . $hostname . "[^ )\\s\r\n]*)/i", "<a href=\"http://\\0\">\\0</a>", $res["shout_message"]); // we replace also urls longer than 30 chars with translantable string as link description instead the URL itself to prevent breaking the layout in some browsers (e.g. Konqueror) $res["shout_message"] = preg_replace("/(<a href=\")((http|ftp)+(s)?:\\/\\/[^\"]+)(\">)([^<]){30,}<\\/a>/i", "<a href=\"\\2\">[" . tra('Link') . "]</a>", $res["shout_message"]); } if ($gBitSystem->isFeatureActive('shoutbox_smileys') && $gBitSystem->isPackageActive('smileys') && $gLibertySystem->isPluginActive('filtersmileys')) { if ($filterfunc = $gLibertySystem->getPluginFunction('filtersmileys', 'postparse_function')) { // note that we've already done the htmlspecialchars thing // things like :-)) need to preceed :-) $smileys = array('--->' => 'arrow', '-->' => 'arrow', ':-O' => 'surprised', '8-)' => 'cool', ':-|' => 'neutral', ':-/' => 'confused', ':-\\' => 'confused', ':-S' => 'confused', ';-)' => 'wink', ':-))))' => 'mrgreen', ':-)))' => 'lol', ':-))' => 'biggrin', ':-)' => 'smile', ':-((' => 'cry', ':-(' => 'sad', ':-P' => 'razz', '>:->' => 'twisted', '>:-(' => 'evil', '>:-|' => 'mad', '(?)' => 'question', '(!)' => 'exclaim'); foreach ($smileys as $str => $smiley) { $res['shout_message'] = str_replace($str, "(:{$smiley}:)", $res['shout_message']); } $filterfunc($res['shout_message'], $res); } } // if not in html tag (e.g. autolink), place after every '*;' the empty span too to prevent e.g. '&&...' $res["shout_message"] = preg_replace_callback('/(\\s*)([^>]+)(<|$)/', function ($m) { return $m[1] . str_replace(';', ';<span></span>', $m[2]) . $m[3]; }, $res["shout_message"]); // if not in tag or on a space or doesn't contain a html entity we split all plain text strings longer than 25 chars using the empty span tag again $wrap_at = 25; $res["shout_message"] = preg_replace_callback('/(\\s*)([^\\;>\\s]{' . $wrap_at . ',})([^&]<|$)/', function ($m) { return $m[1] . wordwrap($m[2], '".$wrap_at."', '<span></span>', 1) . $m[3]; }, $res["shout_message"]); $this->mCache->writeCacheFile($res['shout_id'], $res['shout_message']); } $res['shout_message'] = $this->mCache->readCacheFile($res['shout_id']); // work out permissions $res['is_editable'] = $gBitUser->isRegistered() && ($gBitUser->hasPermission('p_shoutbox_admin') || $gBitUser->getUserId() == $res['shout_user_id']); $res['is_deletable'] = $gBitUser->isRegistered() && ($gBitUser->hasPermission('p_shoutbox_admin') || $gBitUser->getUserId() == $res['shout_user_id'] || $gBitUser->getUserId() == $res['to_user_id']); $ret[] = $res; } $query_cant = "SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "shoutbox` {$mid}"; $pListHash["cant"] = $this->mDb->getOne($query_cant, $bindvars); LibertyBase::postGetList($pListHash); return $ret; }
if ($conPage = LibertyBase::getLibertyObject($conId)) { if (empty($downloadTitle)) { $downloadTitle = $conPage->mInfo['title']; } $pdata = "\n<C:page:" . $conPage->mInfo['title'] . ">\n<br/>\n"; $pdata .= $conPage->getPreview(); $pdata = utf8_decode($pdata); $pdflib->add_linkdestination($conPage->mInfo['title']); $pdflib->insert_html($pdata); $pdflib->ezNewPage(); } } } else { $linkDest = array(); foreach ($convertpages as $conId) { if ($conPage = LibertyBase::getLibertyObject($conId)) { if (empty($downloadTitle)) { $downloadTitle = $conPage->mInfo['title']; } $pdata .= "\n<C:page:" . $conPage->mInfo['title'] . ">\n<br/>\n"; $pdata .= $conPage->getPreview(); array_push($linkDest, $conPage->mInfo['title']); /* $wikiPage = new BitPage(); $wikiPage->findByPageName($page); $wikiPage->load(); $info = $wikiPage->mInfo; //$info = $wikilib->get_page_info($page); $data .= "\n<C:page:$page>\n<br/>\n";
<?php /** * @version $Header$ * * Copyright (c) 2008 bitweaver.org * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details * @author Will <*****@*****.**> * * @package gmap * @subpackage functions */ if ($gBitSystem->isPackageActive('geo') && $gBitSystem->isPackageActive('gmap') && $gBitSystem->isFeatureActive('gmap_api_key')) { //BUG: this include causes gContent to be set which messes some things up in the gmap tpls. $content = LibertyBase::getLibertyObject($_REQUEST['content_id']); $content->load(TRUE); $content->verifyViewPermission(); $dataHash = $content->mInfo; // because content mInfo does not hand over the same info as contentList as below we need to complete the hash $dataHash['display_url'] = !empty($dataHash['display_url']) ? $dataHash['display_url'] : $content->getDisplayUrl(); $dataHash['creator_user_id'] = !empty($dataHash['creator_user_id']) ? $dataHash['creator_user_id'] : $dataHash['user_id']; $dataHash['content_name'] = !empty($dataHash['content_name']) ? $dataHash['content_name'] : $content->getContentTypeName(); $dataHash['gmap_zoom'] = $content->getPreference('gmap_zoom'); // $dataHash['real_name'] = !empty($dataHash['real_name'])?$dataHash['real_name']:$dataHash['creator_user']; $dataHash['creator_real_name'] = !empty($dataHash['creator_real_name']) ? $dataHash['creator_real_name'] : $dataHash['real_name']; if (empty($dataHash['modifier_real_name'])) { $modUser = new BitUser($dataHash['modifier_user_id']); $modUser->load(); $dataHash['modifier_real_name'] = $modUser->mInfo['real_name']; }
* @package treasury * @copyright 2003-2006 bitweaver * @license LGPL {@link http://www.gnu.org/licenses/lgpl.html} **/ /** * Setup */ require_once '../kernel/setup_inc.php'; require_once LIBERTY_PKG_PATH . 'LibertyMime.php'; // fetch the attachment details if (@(!BitBase::verifyId($_REQUEST['attachment_id'])) || !($attachment = LibertyMime::loadAttachment($_REQUEST['attachment_id'], $_REQUEST))) { $gBitSystem->fatalError(tra("The Attachment ID given is not valid")); } $gBitSmarty->assign('attachment', $attachment); // first we need to check the permissions of the content the attachment belongs to since they inherit them if ($gContent = LibertyBase::getLibertyObject($attachment['content_id'])) { $gContent->verifyViewPermission(); $gBitSmarty->assign('gContent', $gContent); if ($download_function = $gLibertySystem->getPluginFunction($attachment['attachment_plugin_guid'], 'download_function', 'mime')) { if ($download_function($attachment)) { LibertyMime::addDownloadHit($attachment['attachment_id']); die; } else { if (!empty($attachment['errors'])) { $msg = ''; foreach ($attachment['errors'] as $error) { $msg .= $error . '<br />'; } $gBitSystem->fatalError(tra($msg)); } else { $gBitSystem->fatalError(tra('There was an undetermined problem trying to prepare the file for download.'));
/** * exportHtml * * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function exportHtml() { $ret = array(); $toc = array(); $this->getContentArray($this->mStructureId, $toc); if (count($toc)) { foreach ($toc as $conId) { if ($viewContent = LibertyBase::getLibertyObject($conId)) { $ret[] = array('type' => $viewContent->mContentTypeGuid, 'landscape' => FALSE, 'url' => $viewContent->getDisplayUrl(), 'content_id' => $viewContent->mContentId); } } } return $ret; }
/** * @version $Header$ * @package liberty * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; global $gBitSmarty, $gContent; $error = NULL; if (!isset($_FILES['upload'])) { $error = tra("No upload submitted."); } elseif (!empty($_REQUEST['liberty_attachments']['content_id'])) { // if we have a content id then we just load up that if (!($gContent = LibertyBase::getLibertyObject($_REQUEST['liberty_attachments']['content_id']))) { // if there is something wrong with the content id spit back an error $error = tra("You are attempting to upload a file to a content item that does not exist."); } } elseif (isset($_REQUEST['liberty_attachments']['content_type_guid'])) { /* if we don't have a content id then we assume this is new content and we need to create a draft. * we'll pass a new content_id back to the edit form so it can make the right association later on save. */ // if we are creating new content the status must be enforced, so status recognition must be enabled if (!$gBitSystem->isFeatureActive("liberty_display_status")) { $error = tra("You must save the content to upload an attachment."); } elseif (!isset($gLibertySystem->mContentTypes[$_REQUEST['liberty_attachments']['content_type_guid']])) { $error = tra("You are attempting to upload a file to an invalid content type"); } else { // load up the requested content type handler class $contentType = $_REQUEST['liberty_attachments']['content_type_guid'];
/** * linkContent * * @access public * @return if errors **/ function linkContent($pParamHash) { if ($this->isValid() && isset($pParamHash['content_id']) && $this->verifyId($pParamHash['content_id'])) { if ($this->mDb->getOne("SELECT `group_content_id` FROM `" . BIT_DB_PREFIX . "groups_content_cnxn_map` WHERE `group_content_id`=? AND `to_content_id`=?", array($this->mContentId, $pParamHash['content_id']))) { $query = "UPDATE `" . BIT_DB_PREFIX . "groups_content_cnxn_map` SET `to_title`= ? WHERE `group_content_id` = ? AND `to_content_id` = ? "; } else { $query = "INSERT INTO `" . BIT_DB_PREFIX . "groups_content_cnxn_map` ( `to_title`, `group_content_id`, `to_content_id` ) VALUES (?,?,?)"; } if (isset($pParamHash['title'])) { $toTitle = $pParamHash['title']; } else { $toContent = LibertyBase::getLibertyObject($pParamHash['content_id']); $toContent->load(); $toTitle = $toContent->getTitle(); } $result = $this->mDb->query($query, array($toTitle, $this->mContentId, $pParamHash['content_id'])); } return count($this->mErrors) == 0; }
<?php /** * @version $Header$ * @package bitweaver */ global $moduleParams, $gContent, $gBitSmarty; $gContent = NULL; if (!empty($moduleParams)) { extract($moduleParams); } $lookupHash['content_id'] = !empty($module_params['content_id']) ? $module_params['content_id'] : NULL; if ($gContent = LibertyBase::getLibertyObject($lookupHash['content_id'])) { if (!$gContent->hasViewPermission()) { // no perm then get rid of the content object $gContent = NULL; } else { // deal with the parsing $parseHash['format_guid'] = $gContent->mInfo['format_guid']; $parseHash['content_id'] = $gContent->mInfo['content_id']; $parseHash['user_id'] = $gContent->mInfo['user_id']; $parseHash['data'] = $gContent->mInfo['data']; $gContent->mInfo['parsed_data'] = $gContent->parseData($parseHash); if (!empty($moduleParams['title'])) { $gContent->mInfo['title'] = $moduleParams['title']; } if (isset($moduleParams['content_type_guid'])) { $gBitSmarty->assign("contentType", $gContent->getContentTypeName()); } } }
function getList(&$pListHash) { global $gBitUser; // ====================== Private Messages ====================== if (empty($pListHash['sort_mode'])) { $pListHash['sort_mode'] = 'msg_date_desc'; } LibertyBase::prepGetList($pListHash); $ret = $bindVars = array(); $whereSql = ''; $bindVars[] = $gBitUser->mUserId; if (!empty($pListHash['priority'])) { $whereSql .= " AND mm.`priority`=? "; $bindVars[] = $pListHash['priority']; } if (!empty($pListHash['flag']) && !empty($pListHash['flagval'])) { $whereSql .= " AND mm.`{$pListHash['flag']}`=? "; $bindVars[] = $pListHash['flagval']; } if (!empty($pListHash['find'])) { $whereSql .= " AND( UPPER( mm.`subject` ) LIKE ? OR UPPER( mm.`body` ) LIKE ? ) "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } $query = "\n\t\t\tSELECT\n\t\t\t\tuu.`login`, uu.`real_name`, uu.`user_id`,\n\t\t\t\tmm.*\n\t\t\tFROM `" . BIT_DB_PREFIX . "messages` mm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON( mm.`from_user_id`=uu.`user_id` )\n\t\t\tWHERE mm.`to_user_id`=? {$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $normalMessages = $this->mDb->getAll($query, $bindVars); // Get the total count of private messages $query = "SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "messages` mm WHERE mm.`to_user_id`=? {$whereSql}"; $cant = $this->mDb->getOne($query, $bindVars); // ====================== Broadcast Messages ====================== //array_unshift( $bindVars, $gBitUser->mUserId, ROOT_USER_ID, $gBitUser->mUserId ); $bindVars = array($gBitUser->mUserId, ROOT_USER_ID, $gBitUser->mUserId); $whereSql = ''; if (!empty($pListHash['priority'])) { $whereSql .= " AND mm.`priority`=? "; $bindVars[] = $pListHash['priority']; } if (!empty($pListHash['flag']) && !empty($pListHash['flagval'])) { $whereSql .= " AND msm.`{$pListHash['flag']}`=? "; $bindVars[] = $pListHash['flagval']; } if (!empty($pListHash['find'])) { $whereSql .= " AND( UPPER( mm.`subject` ) LIKE ? OR UPPER( mm.`body` ) LIKE ? ) "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } $query = "\n\t\t\tSELECT\n\t\t\t\tuu.`login`, uu.`real_name`, uu.`user_id`, mm.`msg_id` as `msg_id_foo`,\n\t\t\t\tmsm.*,\n\t\t\t\tmm.`msg_to`, mm.`msg_cc`, mm.`msg_bcc`, mm.`subject`, mm.`body`, mm.`hash`, mm.`msg_date`, mm.`priority`\n\t\t\tFROM `" . BIT_DB_PREFIX . "messages` mm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON (mm.`from_user_id` = uu.`user_id`)\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "messages_system_map` msm ON (mm.`msg_id` = msm.`msg_id` AND msm.`to_user_id` = ?)\n\t\t\tWHERE mm.`to_user_id`=? AND mm.`group_id` IN (SELECT `group_id` FROM `" . BIT_DB_PREFIX . "users_groups_map` WHERE `user_id` = ?) {$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $result = $this->mDb->query($query, $bindVars); $systemMessages = array(); while ($aux = $result->fetchRow()) { $aux['is_broadcast_message'] = TRUE; $aux['msg_id'] = $aux['msg_id_foo']; // Due to the left outer join this madness is neccessary unset($aux['msg_id_foo']); if ($aux['is_hidden'] != 'y') { $systemMessages[] = $aux; } } $query = "\n\t\t\tSELECT COUNT(mm.`msg_id`)\n\t\t\tFROM `" . BIT_DB_PREFIX . "messages` mm\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "messages_system_map` msm ON (mm.`msg_id` = msm.`msg_id` AND msm.`to_user_id` = ?)\n\t\t\tWHERE mm.`to_user_id`=? AND mm.`group_id` IN (SELECT `group_id` FROM `" . BIT_DB_PREFIX . "users_groups_map` WHERE `user_id` = ?) {$whereSql}"; $cant2 = $this->mDb->getOne($query, $bindVars); // ====================== insane message mergin and sorting ====================== $sort_mode = $pListHash['sort_mode']; $ret = array(); $normalMessageCount = count($normalMessages); $systemMessageCount = count($systemMessages); $normalMsg = $systemMsg = NULL; if (strpos($sort_mode, '_asc') !== FALSE) { $sortType = '_asc'; $sortKey = substr($sort_mode, 0, strlen($sort_mode) - 4); } else { $sortType = '_desc'; $sortKey = substr($sort_mode, 0, strlen($sort_mode) - 5); } while ($normalMessageCount > 0 || $systemMessageCount > 0) { if (!$normalMsg && $normalMessageCount > 0) { $normalMsg = array_shift($normalMessages); } if (!$systemMsg && $systemMessageCount > 0) { $systemMsg = array_shift($systemMessages); } if ($normalMessageCount == 0) { $ret[] = $systemMsg; $systemMsg = NULL; $systemMessageCount--; } elseif ($systemMessageCount == 0) { $ret[] = $normalMsg; $normalMsg = NULL; $normalMessageCount--; } elseif ($sortType == '_asc') { if ($normalMsg[$sortKey] < $systemMsg[$sortKey]) { $ret[] = $normalMsg; $normalMsg = NULL; $normalMessageCount--; } else { $ret[] = $systemMsg; $systemMsg = NULL; $systemMessageCount--; } } else { if ($normalMsg[$sortKey] > $systemMsg[$sortKey]) { $ret[] = $normalMsg; $normalMsg = NULL; $normalMessageCount--; } else { $ret[] = $systemMsg; $systemMsg = NULL; $systemMessageCount--; } } } // set some default values foreach ($ret as $key => $msg) { $msg['len'] = strlen($msg['body']); if (empty($msg['is_read'])) { $msg['is_read'] = 'n'; } if (empty($msg['subject'])) { $msg['subject'] = tra('none'); } $ret[$key] = $msg; } $pListHash["cant"] = $cant + $cant2; LibertyBase::postGetList($pListHash); return $ret; }
/** * expunge removes user and associated private data * * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pExpungeContent = NULL) { global $gBitSystem; $this->StartTrans(); if (!empty($pExpungeContent)) { if ($pExpungeContent == 'all') { if ($userContent = $this->mDb->getAssoc("SELECT content_id, content_type_guid FROM `" . BIT_DB_PREFIX . "liberty_content` WHERE `user_id`=? AND `content_type_guid` != 'bituser'", array($this->mUserId))) { foreach ($userContent as $contentId => $contentTypeGuid) { if ($delContent = LibertyBase::getLibertyObject($contentId, $contentTypeGuid)) { $delContent->expunge(); } } } } } if ($this->mUserId != ANONYMOUS_USER_ID) { $this->purgeImage('avatar'); $this->purgeImage('portrait'); $this->purgeImage('logo'); $this->invokeServices('users_expunge_function'); $userTables = array('users_cnxn', 'users_watches', 'users_favorites_map', 'users_users'); foreach ($userTables as $table) { $query = "DELETE FROM `" . BIT_DB_PREFIX . $table . "` WHERE `user_id` = ?"; $result = $this->mDb->query($query, array($this->mUserId)); } parent::expunge(); $logHash['action_log']['title'] = $this->mInfo['login']; $this->mLogs['user_del'] = 'User deleted'; $this->storeActionLog($logHash); $this->CompleteTrans(); return TRUE; } else { $this->mDb->RollbackTrans(); $gBitSystem->fatalError(tra('The anonymous user cannot be deleted')); } }
function data_attachment($pData, $pParams, $pCommonObject, $pParseHash) { require_once LIBERTY_PKG_PATH . 'LibertyMime.php'; // at a minimum, return blank string (not empty) so we still replace the tag $ret = ' '; // The Manditory Parameter is missing. we are not gonna trow an error, and // just return empty since many sites use the old style required second // "closing" empty tag if (empty($pParams['id'])) { return $ret; } if (!($att = $pCommonObject->getAttachment($pParams['id'], $pParams))) { $ret = tra("The attachment id given is not valid."); return $ret; } global $gBitSmarty, $gLibertySystem, $gContent; // convert parameters into display properties $wrapper = liberty_plugins_wrapper_style($pParams); // work out custom display_url if there is one if (@BitBase::verifyId($pParams['page_id'])) { // link to page by page_id // avoid endless loops require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage($pParams['page_id']); if ($wp->load()) { $wrapper['display_url'] = $wp->getDisplayUrl(); } } elseif (@BitBase::verifyId($pParams['content_id'])) { // link to any content by content_id if ($obj = LibertyBase::getLibertyObject($pParams['content_id'])) { $wrapper['display_url'] = $obj->getDisplayUrl(); } } elseif (!empty($pParams['page_name'])) { // link to page by page_name require_once WIKI_PKG_PATH . 'BitPage.php'; $wp = new BitPage(); $wrapper['display_url'] = $wp->getDisplayUrl($pParams['page_name']); } elseif (!empty($pParams['link']) && $pParams['link'] == 'false') { // no link } elseif (!empty($pParams['link'])) { // Allow the use of icon, avatar, small, medium and large to link to certain size of image directly if (!empty($att['thumnail_url'][$pParams['link']])) { $pParams['link'] = $att['thumnail_url'][$pParams['link']]; // Allow the use of 'original' to link to original file directly } elseif ($pParams['link'] == 'original' && !empty($att['source_url'])) { $pParams['link'] = $att['source_url']; // Allow the use of 'download' to link to download link. this will allow us to count downloads } elseif ($pParams['link'] == 'download' && !empty($att['download_url'])) { $pParams['link'] = $att['download_url']; // Adjust class name if we are leaving this server } elseif (!strstr($pParams['link'], $_SERVER["SERVER_NAME"]) && strstr($pParams['link'], '//')) { $wrapper['href_class'] = 'class="external"'; } $wrapper['display_url'] = $pParams['link']; } elseif (!empty($att['display_url'])) { $wrapper['display_url'] = $att['display_url']; } if (!empty($wrapper['description'])) { $parseHash['content_id'] = $pParseHash['content_id']; $parseHash['user_id'] = $pParseHash['user_id']; $parseHash['no_cache'] = TRUE; $parseHash['data'] = $wrapper['description']; $wrapper['description_parsed'] = $pCommonObject->parseData($parseHash); } // pass stuff to the template $gBitSmarty->assign('attachment', $att); $gBitSmarty->assign('wrapper', $wrapper); $gBitSmarty->assign('thumbsize', !empty($pParams['size']) && ($pParams['size'] == 'original' || !empty($att['thumbnail_url'][$pParams['size']])) ? $pParams['size'] : 'medium'); //Carry only these attributes to the image tags $width = !empty($pParams['width']) ? $pParams['width'] : ''; $gBitSmarty->assign('width', $width); $height = !empty($pParams['height']) ? $pParams['height'] : ''; $gBitSmarty->assign('height', $height); $mimehandler = !empty($wrapper['output']) && $wrapper['output'] == 'thumbnail' ? LIBERTY_DEFAULT_MIME_HANDLER : $att['attachment_plugin_guid']; $ret = $gBitSmarty->fetch($gLibertySystem->getMimeTemplate('attachment', $mimehandler)); return $ret; }
$moduleTitle = !empty($moduleParams['title']) ? $moduleParams['title'] : 'Recent Activity'; $userId = NULL; if (!empty($gQueryUser->mUserId)) { $userId = $gQueryUser->mUserId; } $listHash = array('user_id' => $userId, 'max_records' => $moduleParams['module_rows']); if (!empty($params['full'])) { $listHash['parse'] = TRUE; } $listHash['full'] = !empty($params['full']) ? $params['full'] : TRUE; $listHash['thumb_size'] = !empty($params['thumb_size']) ? $params['thumb_size'] : 'avatar'; $listHash['show_date'] = !empty($params['show_date']) ? $params['show_date'] : TRUE; if (!empty($params['root_content_type_guid'])) { $listHash['root_content_type_guid'] = $params['root_content_type_guid']; } $gBitSmarty->assign('moduleTitle', $moduleTitle); $lcom = new LibertyComment(); $modLastComments = $lcom->getList($listHash); $keys = array_keys($modLastComments); foreach ($keys as $k) { if ($modLastComments[$k]['parent_content_type_guid'] == 'feedstatus') { //if comment is a reply to a status, use the poster as the object, otherwise our thumbnail will be of the content we commented on (the other user,status) $user = new BitUser($modLastComments[$k]['user_id']); $user->load(); $modLastComments[$k]['object'] = $user; } else { //If a comment on a piece of content, use piece of content as object in question $modLastComments[$k]['object'] = LibertyBase::getLibertyObject($modLastComments[$k]['root_id'], $modLastComments[$k]['root_content_type_guid']); } } $gBitSmarty->assign('modLastComments', $modLastComments);
function LibertyGeo($pContentId = NULL) { parent::__construct(); $this->mContentId = $pContentId; }
/** * A universal helper to bookmark any content object for a user * Currently only accessible through ajax/json * Those wishing for a non-js implementation feel free to modify * * @package users */ /** * required setup */ require_once '../kernel/setup_inc.php'; $statusCode = 205; $error = TRUE; $msg = ""; if ($gBitUser->isRegistered()) { if (!empty($_REQUEST['content_id']) && ($gContent = LibertyBase::getLibertyObject($_REQUEST['content_id']))) { // verify user has access to view this content $gContent->load(); if ($gContent->hasViewPermission()) { if ($gContent->hasService(CONTENT_SERVICE_USERS_FAVS)) { // default action is to add the favorite $_REQUEST['action'] = empty($_REQUEST['action']) ? 'add' : $_REQUEST['action']; // add or remove switch ($_REQUEST['action']) { case 'add': $gBitUser->storeFavorite($_REQUEST['content_id']); $bookmarkState = 1; $msg = tra('This content has been added to your favorites'); break; case 'remove': $gBitUser->expungeFavorite($_REQUEST['content_id']);
public static function has_permission($pContentType = NULL) { global $gBitUser, $gLibertySystem; if (!empty($pContentType)) { $object = LibertyBase::getLibertyObject(1, $pContentType, FALSE); if (!empty($object)) { // Note that we can't do verify access here because // we are using a generic object but we can at least get a // basic permission check here. return $object->hasViewPermission(FALSE); } } return FALSE; }
function getRootObj() { if (!is_object($this->mRootObj) && !empty($this->mInfo['root_id'])) { if ($obj = LibertyBase::getLibertyObject($this->mInfo['root_id'])) { $this->mRootObj = $obj; } } return $this->mRootObj; }
function LibertyItag($pAttachementId = NULL) { LibertyBase::LibertyBase(); $this->mAttachementId = $pAttachementId; }
function LibertyTopica($pContentId = NULL) { LibertyBase::LibertyBase(); $this->mContentId = (int) $pContentId; }
require_once 'kernel/setup_inc.php'; // $gBitSystem->loadLayout() needs ACTIVE_PACKAGE if (!$gBitSystem->isDatabaseValid()) { install_error(); } elseif (!defined('ACTIVE_PACKAGE')) { $bit_index = $gBitSystem->getConfig('bit_index'); if (in_array($bit_index, array_keys($gBitSystem->mPackages)) && defined(strtoupper($bit_index) . '_PKG_PATH')) { define('ACTIVE_PACKAGE', constant(strtoupper($bit_index) . '_PKG_NAME')); $gBitSystem->mActivePackage = $bit_index; } else { define('ACTIVE_PACKAGE', KERNEL_PKG_NAME); unset($bit_index); } } if (!empty($_REQUEST['content_id'])) { if ($obj = LibertyBase::getLibertyObject($_REQUEST['content_id'])) { $url = $obj->getDisplayUrl(); if (!empty($_REQUEST['highlight'])) { if (preg_match('/\\?/', $url)) { $url .= '&'; } else { $url .= '?'; } $url .= 'highlight=' . $_REQUEST['highlight']; } bit_redirect($url); } } elseif (!empty($_REQUEST['structure_id'])) { include LIBERTY_PKG_PATH . 'display_structure_inc.php'; die; }
/** * During initialisation, be sure to call our base constructors **/ function __construct($pContentId = NULL) { $this->mContentId = $pContentId; parent::__construct(); }
foreach ($reorder as $conId => $sortVal) { $newOrder[$conId] = $sortPos; $sortPos += 10; } } if (!empty($gContent->mItems)) { foreach (array_keys($gContent->mItems) as $itemConId) { if ($gContent->mItems[$itemConId]->getField('is_favorite') && empty($favoriteCon[$itemConId])) { $gBitUser->expungeFavorite($itemConId); } elseif (!$gContent->mItems[$itemConId]->getField('is_favorite') && !empty($favoriteCon[$itemConId])) { $gBitUser->storeFavorite($itemConId); } } } foreach ($_REQUEST['imagePosition'] as $contentId => $newPos) { if ($galleryItem = LibertyBase::getLibertyObject($contentId)) { $galleryItem->load(); if (isset($batchCon[$contentId])) { if (!empty($_REQUEST['batch_command'])) { @(list($batchCommand, $batchParam) = @explode(':', $_REQUEST['batch_command'])); switch ($batchCommand) { case 'delete': $galleryItem->expunge(); $galleryItem = NULL; break; case 'remove': $parents = $galleryItem->getParentGalleries(); if ($galleryItem->isContentType(FISHEYEGALLERY_CONTENT_TYPE_GUID) || count($parents) > 1) { $gContent->removeItem($contentId); } else { $galleryItem->expunge();