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 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); } }
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; } }
/** * 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; }
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; }
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";
* @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.'));
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; }
function translation_content_edit(&$pObject, &$pParamHash) { global $gBitLanguage, $gBitSmarty, $gBitUser; $trans = new LibertyTranslations($pObject->mContentId); $translationId = NULL; $translations = $trans->getContentTranslations(); foreach ($gBitLanguage->mLanguageList as $lang_code => $language) { $translationsList[$lang_code] = $language; if (!empty($translations[$lang_code]['content_id'])) { $translationsList[$lang_code]['content_id'] = $translations[$lang_code]['content_id']; $translationsList[$lang_code]['title'] = $translations[$lang_code]['title']; $translationId = $translations[$lang_code]['translation_id']; } } $gBitSmarty->assign('translationsList', $translationsList); $gBitSmarty->assign('translationId', $translationId); if (@BitBase::verifyId($_REQUEST['i18n']['from_id'])) { // load the content we're translating from $transObject = LibertyBase::getLibertyObject($_REQUEST['i18n']['from_id']); $gBitSmarty->assignByRef("translateFrom", $transObject); // attempt google translation if (!empty($_REQUEST['i18n']['google']) && !empty($transObject->mInfo['data'])) { // temporarily replace \n with a string $nl = 'nlnlnlnlnl'; // initiate some variables $transObject->mInfo['google_guess'] = ''; // we need to split the strings into small chunks due to url length limitations $strings = str_split($transObject->mInfo['data'], 1500); foreach ($strings as $string) { $requestUrl = "http://translate.google.com/translate_t?ie=UTF-8&oe=UTF-8&text=" . urlencode(preg_replace('/[\\n]/', $nl, $string)) . "&langpair=en|{$_REQUEST['i18n']['lang_code']}"; if ($handle = fopen($requestUrl, "r")) { $data = ''; while (!feof($handle)) { $data .= fread($handle, 8192); } fclose($handle); preg_match_all("!<div id=result_box[^>]*>([^<]*)</div>.*!", $data, $matches); if (isset($matches[1][0])) { $transObject->mInfo['google_guess'] .= preg_replace("/" . preg_quote($nl, "/") . "/", "\n", $matches[1][0]); } } } die; } } }
<?php /** * @version $Header$ * @package liberty * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; $staticContent = new LibertyContent(); $gContent = LibertyBase::getLibertyObject($_REQUEST['parent_id'], !empty($_REQUEST['parent_guid']) ? $_REQUEST['parent_guid'] : NULL); $XMLContent = ""; if (!$gContent->hasUserPermission('p_liberty_post_comments', TRUE, TRUE)) { $statusCode = 401; $XMLContent = tra("You do not have the required permissions to post new comments"); } elseif ($gContent->isCommentable()) { /** * If we are receiving ajax comments request make sure our results also * know we are using ajax comments. This is an insurance measure that if * the originating content forced on ajax comments (even if off system * wide) that the return results continue to use ajax comments. Don't take * this out under penalty of death. */ $gBitSystem->setConfig('comments_ajax', 'y'); $commentsParentId = $_REQUEST['parent_id']; $comments_return_url = $_REQUEST['comments_return_url']; include_once LIBERTY_PKG_PATH . 'comments_inc.php'; if (isset($_REQUEST['post_comment_submit'])) { if ($storeComment->loadComment()) {
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();
$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);
<?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']; }
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 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; }
/** * 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')); } }
<?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()); } } }
/** * 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.")); } }
/** * 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; }
/** * 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; }
$gBitSystem->verifyPackage('group'); //if the request is from the search field redirect us to the list - otherwise do what we do if (isset($_REQUEST['find'])) { header("location: " . GROUP_PKG_URI . "search.php?find=" . $_REQUEST['find']); die; } // verify the user can add stuff to a group if (!$gBitUser->isRegistered()) { $gBitSystem->fatalPermission(NULL, 'Sorry, but you must be registered and belong to any group to submit content to it.'); } // verify someone has bothered to submit something if (empty($_REQUEST['submit_content_id'])) { $gBitSystem->fatalError("You have not specified anything to submit to a group."); } // verify the thing to be added is valid $linkContent = LibertyBase::getLibertyObject($_REQUEST['submit_content_id']); $linkContent->load(); if (!$linkContent->isValid()) { $gBitSystem->fatalError("The content you are trying to submit to a group is invalid."); } // verify edit permission of the content to be submitted to the group if (!$linkContent->hasUpdatePermission()) { $gBitSystem->fatalError("You do not have sufficient permission to submit this content to a group."); } require_once GROUP_PKG_PATH . 'lookup_group_inc.php'; // Now check permissions to access this page if ($gContent->isValid()) { $gContent->verifyViewPermission(); // check permission, and content types allowed - also checks validity of group - but lets ignore that and offer the user some options if they don't request a group $gContent->verifyLinkContentPermission($linkContent); } else {
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; }
/** * 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']);
/** * @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'];
<?php require_once '../kernel/setup_inc.php'; require_once 'ModerationSystem.php'; // Are we trying to look at a single moderation? if (!empty($_REQUEST['moderation_id'])) { // if an action is requested do that if (!empty($_REQUEST['transition'])) { $gModerationSystem->setModerationReply($_REQUEST['moderation_id'], $_REQUEST['transition'], empty($_REQUEST['reply']) ? NULL : $_REQUEST['reply']); bit_redirect(MODERATION_PKG_URL . 'index.php'); } $moderation = $gModerationSystem->getModeration($_REQUEST['moderation_id']); // Do we have a valid moderation if (!empty($moderation)) { // Verify that the user can see this moderation if ($gBitUser->isAdmin() || $moderation['source_user_id'] == $gBitUser->mUserId || !empty($moderation['moderator_user_id']) && $moderation['moderator_user_id'] == $gBitUser->mUserId || !empty($moderation['moderation_group_id']) && $gBitUser->isInGroup($moderation['moderation_group_id']) || (($obj = LibertyBase::getLibertyObject($moderation['content_id'])) && ($obj->mType['content_type_guid'] == 'bitcomment' && !empty($moderation['moderator_perm_name']) && $obj->getRootObj()->hasUserPermission($moderation['moderator_perm_name'])) || $obj->mType['content_type_guid'] != 'bitcomment' && !empty($moderation['moderator_perm_name']) && $obj->hasUserPermission($moderation['moderator_perm_name']))) { // Assign the moderation $gBitSmarty->assign('moderation', $moderation); // Check which way it is going if ($moderation['source_user_id'] != $gBitUser->mUserId) { // Display the template $gBitSystem->display('bitpackage:moderation/moderate.tpl', 'Moderate Request', array('display_mode' => 'display')); } else { // No need for the source user. $gBitSystem->display('bitpackage:moderation/request.tpl', 'My Request', array('display_mode' => 'display')); } die; } else { $gBitSystem->setHttpStatus(403); $gBitSystem->fatalError(tra("You don't have permission to see this moderation.")); }