function getThumbnailUrl($pSize = 'avatar', $pInfoHash = NULL) { $rootUser = new BitUser(NULL, $this->mInfo['root_id']); $rootUser->load(); $thumbnailUrl = $rootUser->getThumbnailUrl($pSize); if (empty($thumbnailUrl)) { $thumbnailUrl = USERS_PKG_URL . 'icons/silhouette.png'; } return $thumbnailUrl; }
function data_quote($pData, $pParams) { global $gLibertySystem, $gBitSmarty, $gBitSystem; if (empty($pParams['format_guid'])) { // default should be set - if not, we'll use tikiwiki - can't use PLUGIN_GUID_TIKIWIKI since it might not be defined. $pParams['format_guid'] = $gBitSystem->getConfig('default_format', 'tikiwiki'); } $rendererHash = array(); $rendererHash['content_id'] = 0; $rendererHash['format_guid'] = $pParams['format_guid']; $rendererHash['data'] = trim($pData); $formatGuid = $rendererHash['format_guid']; $ret = ""; if ($func = $gLibertySystem->getPluginFunction($formatGuid, 'load_function')) { $ret = $func($rendererHash, $this); } $quote = array(); $user = empty($pParams['user']) ? NULL : $pParams['user']; if (!empty($pParams['comment_id'])) { if ($gBitSystem->getActivePackage() == 'boards') { $c = new BitBoardPost(preg_replace('/[^0-9]/', '', $pParams['comment_id'])); } else { $c = new LibertyComment(preg_replace('/[^0-9]/', '', $pParams['comment_id'])); } if (empty($c->mInfo['title'])) { $c->mInfo['title'] = "#" . $c->mCommentId; } $quote['cite_url'] = $c->getDisplayUrl(); $quote['title'] = $c->mInfo['title']; $quote['created'] = $c->mInfo['created']; if (empty($user)) { $user = $c->mInfo['login']; } } $quote['login'] = $user; if (!empty($user)) { $u = new BitUser(); $u->load(TRUE, $user); $quote['user_url'] = $u->getDisplayUrl(); $quote['user_display_name'] = $u->mInfo['display_name']; } $quote['ret'] = $ret; $gBitSmarty->assign("quote", $quote); $repl = $gBitSmarty->fetch("bitpackage:liberty/plugins/data_quote.tpl"); return $repl; }
/** * postMessage * * @param array $pParamHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function postMessage($pParamHash) { global $gBitSmarty, $gBitUser, $gBitSystem; if ($this->verifyMessage($pParamHash)) { $this->mDb->associateInsert(BIT_DB_PREFIX . "messages", $pParamHash['message_store']); // we need to load the user this message is being sent to that we can check if the user should be notified by email $queryUser = new BitUser($pParamHash['userInfo']['user_id']); $queryUser->load(); if ($queryUser->getPreference('messages_min_priority') && $queryUser->getPreference('messages_min_priority') <= $pParamHash['message_store']['priority']) { if (!empty($pParamHash['userInfo']['email'])) { $gBitSmarty->assign('msgHash', $pParamHash['message_store']); $gBitSmarty->assign('from', stripslashes($gBitUser->getDisplayName())); @mail($pParamHash['userInfo']['email'], tra('New message arrived from ') . $gBitSystem->getConfig('kernel_server_name', $_SERVER["SERVER_NAME"]), $gBitSmarty->fetch('bitpackage:messages/message_notification.tpl'), "From: " . $gBitSystem->getConfig('site_sender_email') . "\r\nContent-type: text/plain;charset=utf-8\r\n"); } } } return count($this->mErrors) == 0; }
function data_blog($data, $params) { // No change in the parameters with Clyde global $gLibertySystem, $gBitSmarty, $gBitSystem, $gBitUser; $display_result = ""; if ($gBitSystem->isPackageActive('blogs') && $gBitUser->hasPermission('p_blogs_view')) { // The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATABLOG]; require_once BLOGS_PKG_PATH . 'BitBlog.php'; require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php'; $module_params = $params; if (isset($module_params['id'])) { $gBitSmarty->assign('blog_id', $module_params['id']); } $blogPost = new BitBlogPost(); $sortOptions = array("publish_date_desc", "publish_date_asc", "last_modified_asc", "last_modified_desc", "created_asc", "created_desc", "random"); if (!empty($module_params['sort_mode']) && in_array($module_params['sort_mode'], $sortOptions)) { $sort_mode = $module_params['sort_mode']; } else { $sort_mode = 'publish_date_desc'; } $getHash = array(); if (isset($module_params['user'])) { $getHash['user'] = $module_params['user']; } if (isset($module_params['id'])) { $getHash['blog_id'] = $module_params['id']; } if (isset($module_params['group_id'])) { $getHash['group_id'] = $module_params['group_id']; } if (isset($module_params['role_id'])) { $getHash['role_id'] = $module_params['role_id']; } // handle draft posts $getHash['enforce_status'] = TRUE; // @TODO enable lists that include draft posts // the current tpl configuration doesnt allow us to support draft lists right now // there is an object reference problem in liberty::service_content_body_inc.tpl // if the object reference problem in the above mentions tpl is patched then use this if to enable drafts // if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){ if (FALSE) { // if we are getting drafts then get future posts too $getHash['show_future'] = TRUE; $getHash['min_status_id'] = -6; $getHash['max_status_id'] = -4; $getHash['min_owner_status_id'] = -6; // limit by user $getHash['user_id'] = $gBitUser->mUserId; } else { $getHash['min_owner_status_id'] = 0; } $getHash['sort_mode'] = $sort_mode; $getHash['parse_data'] = TRUE; $getHash['max_records'] = empty($module_params['max']) ? 1 : $module_params['max']; $getHash['load_num_comments'] = TRUE; $getHash['page'] = !empty($module_params['page']) ? $module_params['page'] : 1; $getHash['offset'] = !empty($module_params['offset']) ? $module_params['offset'] : 0; $blogPosts = $blogPost->getList($getHash); $display_format = empty($module_params['format']) ? 'simple_title_list' : $module_params['format']; switch ($display_format) { case 'full': $display_result = '<div class="blogs">'; if ($gBitSystem->isPackageActive('rss')) { if (isset($module_params['user'])) { $rssUser = new BitUser(); $rssUser->load(false, $module_params['user']); $rssUserId = $rssUser->getField('user_id'); } $rssPath = BLOGS_PKG_URL . 'blogs_rss.php?' . (isset($module_params['id']) ? 'blog_id=' . $module_params['id'] : "") . (isset($module_params['id']) && isset($rssUserId) ? "&" : "") . (isset($rssUserId) ? 'user_id=' . $rssUserId : "") . (isset($rssUserId) && isset($module_params['group_id']) ? "&" : "") . (isset($module_params['group_id']) ? 'group_id=' . $module_params['group_id'] : "") . (isset($rssUserId) && isset($module_params['role_id']) ? "&" : "") . (isset($module_params['role_id']) ? 'role_id=' . $module_params['role_id'] : ""); // something like this would be better, calling smarty directly so translation can also be called -wjames5 // $rssIcon = smarty_function_biticon( array('ipackage'=>"rss", 'iname'="rss-16x16", 'iexplain'=>"RSS feed"), &$gBitSmarty ); $display_result .= '<div class="floaticon"><a title="RSS feed" href="' . $rssPath . '"><img src="' . BIT_ROOT_URL . 'rss/icons/rss-16x16.png" alt="RSS feed" title="RSS feed" class="icon" /></a></div>'; } $gBitSmarty->assign('showDescriptionsOnly', TRUE); foreach ($blogPosts['data'] as $aPost) { $gBitSmarty->assign('aPost', $aPost); $display_result .= $gBitSmarty->fetch('bitpackage:blogs/blog_list_post.tpl'); } $display_result .= '</div>'; $display_result = eregi_replace("\n", "", $display_result); break; case 'list': default: $display_result = "<ul>"; foreach ($blogPosts['data'] as $post) { $link = $blogPost->getDisplayLink($post['title'], $post); $display_result .= "<li>{$link}</li>\n"; } $display_result .= "</ul>\n"; break; } } else { $display_result = '<div class=error>' . tra('Blogs Package Deactivated.') . '</div>'; } return $display_result; }
function topica_users_register(&$pObject) { global $gBitSystem; if ($gBitSystem->isPackageActive('topica')) { $topica = new LibertyTopica($pObject->mContentId); $topica->load(); if (isset($topica->mInfo['first_name']) || isset($topica->mInfo['last_name'])) { $prefs = array('prefs' => 'y', 'real_name' => ($topica->mInfo['first_name'] ? $topica->mInfo['first_name'] . " " : "") . ($topica->mInfo['last_name'] ? $topica->mInfo['last_name'] : "")); require_once USERS_PKG_PATH . 'BitUser.php'; $tempUser = new BitUser($pObject->mUserId); $tempUser->load(TRUE); $tempUser->store($prefs); } if (isset($topica->mInfo['pump'])) { if ($topica->mInfo['pump'] == 'y') { $topica->pumpTopica(); } } } }
if (!empty($feed['th_sticky'])) { $item->title = "[!] " . $item->title; } if (!empty($feed['th_locked'])) { $item->title = "[#] " . $item->title; } $item->link = 'http://' . $_SERVER['HTTP_HOST'] . $feed['url']; $data = BitBoard::getBoard($feed['llc_content_id']); $item->description = $data['data']; //TODO allow proper sort order //$item->date = ( int )$feed['event_date']; $item->date = (int) $feed['llc_last_modified']; $user = new BitUser($feed['llc_user_id']); break; } $user->load(); $item->author = $user->getDisplayName(); //$gBitUser->getDisplayName( FALSE, array( 'user_id' => $feed['modifier_user_id'] ) ); $item->authorEmail = $user->mInfo['email']; $item->descriptionTruncSize = $gBitSystem->getConfig('rssfeed_truncate', 1000); $item->descriptionHtmlSyndicated = FALSE; /* var_dump($item); echo "</pre>"; die(); //*/ // pass the item on to the rss feed creator $rss->addItem($item); } // finally we are ready to serve the data echo $rss->saveFeed($rss_version_name, $cacheFile);
while (!$gv_page->EOF) { if ($gv_page->fields['order_id'] == $_GET['order']) { break; } $page_cnt++; $gv_page->MoveNext(); } $_GET['page'] = round($page_cnt / MAX_DISPLAY_SEARCH_RESULTS); zen_redirect(zen_href_link_admin(FILENAME_GV_QUEUE, 'gid=' . $gv_id . '&page=' . $_GET['page'])); } // eof: find gv for a particular order and set page if ($_GET['action'] == 'confirmrelease' && BitBase::verifyId($_GET['gid'])) { $gv = $gBitDb->getRow("select release_flag from " . TABLE_COUPON_GV_QUEUE . " where unique_id=?", array($_GET['gid'])); if ($gv['release_flag'] == 'N' && ($gv = $gBitDb->getRow("select customer_id, amount, order_id from " . TABLE_COUPON_GV_QUEUE . " where unique_id=?", array($_GET['gid'])))) { $fromUser = new BitUser($gv['customer_id']); $fromUser->load(); if ($couponCode = CommerceVoucher::customerSendCoupon($fromUser, array('email' => $fromUser->getField('email'), 'to_name' => $fromUser->getDisplayName()), $gv['amount'])) { $gBitSmarty->assign('gvAmount', $currencies->format($gv['amount'])); //send the message $textMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_purchase_email_text.tpl'); $htmlMessage = $gBitSmarty->fetch('bitpackage:bitcommerce/gv_purchase_email_html.tpl'); zen_mail($fromUser->getDisplayName(), $fromUser->getField('email'), TEXT_REDEEM_GV_SUBJECT . TEXT_REDEEM_GV_SUBJECT_ORDER . $gv['order_id'], $textMessage, STORE_NAME, EMAIL_FROM, $htmlMessage, 'gv_queue'); $gBitDb->Execute("update " . TABLE_COUPON_GV_QUEUE . "\n\t\t\t\t\t\t set `release_flag`= 'Y'\n\t\t\t\t\t\t where `unique_id`='" . $_GET['gid'] . "'"); } bit_redirect(BITCOMMERCE_PKG_URL . 'admin/gv_queue.php'); } } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS;
/** * load * * @param boolean $pFull Load all permissions * @param string $pUserName User login name * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function load($pFull = FALSE, $pUserName = NULL) { if (BitUser::load($pFull, $pUserName)) { if ($pFull) { unset($this->mPerms); $this->loadRoles(); $this->loadPermissions(); } } return $this->mUserId != NULL; }
function feed_get_status($pListHash) { global $gBitDb; $whereSql = ''; $bindVars = array(); $statuses = array(); BitBase::prepGetList($pListHash); if (!empty($pListHash['user_id'])) { $whereSql = " WHERE lal.user_id = ? "; $bindVars[] = $pListHash['user_id']; } else { $whereSql = "WHERE 1=1 "; } $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, lc.data, uu.login, uu.real_name, uu.email\n\t\t\t FROM liberty_action_log lal\n\t\t\t INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id)\n\t\t\t INNER JOIN liberty_comments lcs ON (lcs.content_id = lc.content_id)\n\t\t\t INNER JOIN users_users uu ON (uu.user_id=lal.user_id)\n\t\t\t {$whereSql} AND lc.content_type_guid = 'feedstatus'\n\t\t\t GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message,lc.data\n\t\t\t ORDER BY MAX(lal.last_modified) DESC"; $res = $gBitDb->query($query, $bindVars, $pListHash['max_records']); $user = new BitUser($pListHash['user_id']); $user->load(); while ($status = $res->fetchRow()) { $avatarUrl = $user->getThumbnailUrl(); if (empty($avatarUrl)) { $avatarUrl = USERS_PKG_URI . "icons/silhouette.png"; } $status['feed_icon_url'] = $avatarUrl; $comment = new LibertyComment(NULL, $status['content_id']); $replies = $comment->getComments($status['content_id'], null, null, 'commentDate_asc'); $status['replies'] = $replies; foreach ($status['replies'] as &$reply) { $replyUser = new BitUser($reply['user_id']); $replyUser->load(); $replyAvatarUrl = $replyUser->getThumbnailUrl(); if (empty($replyAvatarUrl)) { $replyAvatarUrl = USERS_PKG_URI . "icons/silhouette.png"; } $reply['feed_icon_url'] = $replyAvatarUrl; } //after loading up the thumbnails in the prior array layout for ease, we break up the array to split long comment threads $MAX_SHOWN_REPLIES = 3; if (count($status['replies']) > $MAX_SHOWN_REPLIES) { $maxIteration = count($status['replies']) - $MAX_SHOWN_REPLIES; $i = 0; foreach ($status['replies'] as $excess) { if ($i < $maxIteration) { $status['replies_excess'][$excess['content_id']] = $excess; //use content_id to index for consistency with normal replies array unset($status['replies'][$excess['content_id']]); //remove from the normal replies array } else { break; } $i++; } } $statuses[] = $status; } return $statuses; }
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']; } //assign it in an array as a single item list $aContent = array($dataHash); $gBitSmarty->assign_by_ref('listcontent', $aContent); //format include is for the inline service of including a map in other content when geo-located //we exit right away if thats all we need if (isset($_REQUEST['format']) && $_REQUEST['format'] == "include") { //use Mochikit - prototype sucks $gBitThemes->loadAjax('mochikit', array('Base.js', 'Iter.js', 'Async.js', 'DOM.js', 'DateTime.js', 'Style.js')); //if the format is include then this is called internally as an iframe so we hide the rest of the layout $gHideModules = TRUE; $gBitSmarty->assign('simple_map', TRUE); //this disables marker clicking since infowindow would only contain the data thats already on display $gBitSystem->mOnload[] = 'BitMap.DisplaySimple();';
/** * store Any method named Store inherently implies data will be written to the database * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash * This is the ONLY method that should be called in order to store( create or update )an suggestion! * It is very smart and will figure out what to do for you. It should be considered a black box. * * @param array $pParamHash hash of values that will be used to store the page * @access public * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function store(&$pParamHash) { if ($this->verify($pParamHash) && LibertyMime::store($pParamHash)) { $this->mDb->StartTrans(); $table = BIT_DB_PREFIX . "suggestion_data"; if ($this->mSuggestionId) { $locId = array("suggestion_id" => $pParamHash['suggestion_id']); $result = $this->mDb->associateUpdate($table, $pParamHash['suggestion_store'], $locId); } else { $pParamHash['suggestion_store']['content_id'] = $pParamHash['content_id']; if (@$this->verifyId($pParamHash['suggestion_id'])) { // if pParamHash['suggestion_id'] is set, some is requesting a particular suggestion_id. Use with caution! $pParamHash['suggestion_store']['suggestion_id'] = $pParamHash['suggestion_id']; } else { $pParamHash['suggestion_store']['suggestion_id'] = $this->mDb->GenID('suggestion_data_id_seq'); } $this->mSuggestionId = $pParamHash['suggestion_id'] = $pParamHash['suggestion_store']['suggestion_id']; if ($result = $this->mDb->associateInsert($table, $pParamHash['suggestion_store'])) { // send an email notification to subscribers // load up creator user in case user_id was forced and is not the same as gBitUser $user = new BitUser($pParamHash['user_id']); $user->load(); $userName = $user->getDisplayName(); $userEmail = $user->getField('email'); // Draft the message body: $body = "/----- " . tra('A new suggestion was submitted.') . " -----/\n\n" . "Submitted by: \n" . $userName . "\n" . $userEmail . "\n\n" . "Title: \n" . $pParamHash['title'] . "\n\n" . "Megawatt Hours / Year: \n" . $pParamHash['suggestion_store']['mwh'] . "\n\n" . "Description: \n" . $pParamHash['edit'] . "\n\n" . "Sources: \n" . $pParamHash['suggestion_store']['sources']; $msgHash = array('subject' => tra('New Suggestion') . ': ' . $pParamHash['title'], 'alt_message' => $body); global $gSwitchboardSystem; // register the sender to be able to access it $gSwitchboardSystem->registerSender(SUGGESTION_PKG_TITLE, 'new suggestion'); // fire a notification $gSwitchboardSystem->sendEvent(SUGGESTION_PKG_TITLE, 'new suggestion', $pParamHash['content_id'], $msgHash); // cheating by accessing directly - remove the sender because access should be restricted unset($gSwitchboardSystem->mSenders[SUGGESTION_PKG_TITLE]); } } // $this->storeRefs( $pParamHash ); $this->mDb->CompleteTrans(); $this->load(); } else { $this->mErrors['store'] = 'Failed to save this suggestion.'; } return count($this->mErrors) == 0; }
function modWarn($message) { global $gBitSystem, $gBitUser; if (empty($message)) { $gBitSystem->fatalError("No Warning Message Given. <br />A post cannot be warned without a message"); } $data['is_warned'] = 1; $data['warned_message'] = $message; $this->setMetaData($data); if ($gBitSystem->isPackageActive('messages')) { require_once MESSAGES_PKG_PATH . 'Messages.php'; $u = new BitUser($this->mInfo['user_id']); $u->load(); $userInfo = $u->mInfo; $pm = new Messages(); $message = "Your post \"" . $this->mInfo['title'] . "\" [http://" . $_SERVER['HTTP_HOST'] . $this->getContactUrl() . "] has been warned with the following message:\n{$message}\n"; $msgHash = array('to_login' => $userInfo['login'], 'to' => $userInfo['real_name'], 'subject' => tra('Warned Post') . ': ' . $this->mInfo['title'], 'priority' => 4); $pm->postMessage($msgHash); } }