function sendQueue($pQueueMixed) { global $gBitSmarty, $gBitSystem, $gBitLanguage; static $body = array(); if (is_array($pQueueMixed)) { $pick = $pQueueMixed; } elseif (is_numeric($pQueueMixed)) { $pick = $this->mDb->GetRow("SELECT * FROM `" . BIT_DB_PREFIX . "mail_queue` mq WHERE `mail_queue_id` = ? " . $this->mDb->SQLForUpdate(), array($pQueueMixed)); } if (!empty($pick)) { $startTime = microtime(TRUE); $this->mDb->query("UPDATE `" . BIT_DB_PREFIX . "mail_queue` SET `begin_date`=? WHERE `mail_queue_id` = ? ", array(time(), $pick['mail_queue_id'])); if (!empty($pick['user_id'])) { $userHash = $this->mDb->getRow("SELECT * FROM `" . BIT_DB_PREFIX . "users_users` WHERE `user_id`=?", array($pick['user_id'])); $pick['full_name'] = BitUser::getDisplayName(FALSE, $userHash); } else { $pick['full_name'] = NULL; } if (!isset($body[$pick['content_id']])) { $gBitSmarty->assign('sending', TRUE); // We only support sending of newsletters currently $content = new BitNewsletterEdition(NULL, $pick['content_id']); if ($content->load()) { $body[$pick['content_id']]['body'] = $content->render(); $body[$pick['content_id']]['subject'] = $content->getTitle(); $body[$pick['content_id']]['reply_to'] = $content->getField('reply_to', $gBitSystem->getConfig('site_sender_email', $_SERVER['SERVER_ADMIN'])); $body[$pick['content_id']]['object'] = $content; } else { bit_error_log($this->mErrors); } // $content[$pick['content_id']] = LibertyBase::getLibertyObject(); } print "[ {$pick['mail_queue_id']} ] {$pick['content_id']} TO: {$pick['email']}\t"; $unsub = $this->getUnsubscription($pick['email'], $pick['nl_content_id']); if (!empty($unsub)) { print " SKIPPED (unsubscribed) <br/>\n"; $this->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "mail_queue` WHERE `mail_queue_id`=?", array($pick['mail_queue_id'])); } elseif (!empty($body[$pick['content_id']])) { $pick['url_code'] = md5($pick['content_id'] . $pick['email'] . $pick['queue_date']); $unsub = ''; if ($body[$pick['content_id']]['object']->mNewsletter->getField('unsub_msg')) { $gBitSmarty->assign('url_code', $pick['url_code']); } $gBitSystem->preDisplay(''); $gBitSmarty->assign('sending', TRUE); $gBitSmarty->assign('unsubMessage', $unsub); $gBitSmarty->assign('trackCode', $pick['url_code']); $gBitSmarty->assign('mid', 'bitpackage:newsletters/view_edition.tpl'); $htmlBody = $gBitSmarty->fetch('bitpackage:newsletters/mail_edition.tpl'); $htmlBody = bit_add_clickthrough($htmlBody, $pick['url_code']); $mailer = new PHPMailer(); if ($gBitSystem->getConfig('bitmailer_errors_to')) { $mailer->Sender = $gBitSystem->getConfig('bitmailer_errors_to'); $mailer->addCustomHeader("Errors-To: " . $gBitSystem->getConfig('bitmailer_errors_to')); } $mailer->From = $gBitSystem->getConfig('bitmailer_sender_email', $gBitSystem->getConfig('site_sender_email', $_SERVER['SERVER_ADMIN'])); $mailer->FromName = $gBitSystem->getConfig('bitmailer_from', $gBitSystem->getConfig('site_title')); $mailer->Host = $gBitSystem->getConfig('bitmailer_servers', $gBitSystem->getConfig('kernel_server_name', '127.0.0.1')); $mailer->Mailer = $gBitSystem->getConfig('bitmailer_protocol', 'smtp'); // Alternative to IsSMTP() $mailer->CharSet = 'UTF-8'; if ($gBitSystem->getConfig('bitmailer_smtp_username')) { $mailer->SMTPAuth = TRUE; $mailer->Username = $gBitSystem->getConfig('bitmailer_smtp_username'); } if ($gBitSystem->getConfig('bitmailer_smtp_password')) { $mailer->Password = $gBitSystem->getConfig('bitmailer_smtp_password'); } $mailer->WordWrap = $gBitSystem->getConfig('bitmailer_word_wrap', 75); if (!$mailer->SetLanguage($gBitLanguage->getLanguage(), UTIL_PKG_PATH . 'phpmailer/language/')) { $mailer->SetLanguage('en'); } $mailer->ClearReplyTos(); $mailer->AddReplyTo($body[$pick['content_id']]['reply_to'], $gBitSystem->getConfig('bitmailer_from')); $mailer->Body = $htmlBody; $mailer->Subject = $body[$pick['content_id']]['subject']; $mailer->IsHTML(TRUE); $mailer->AltBody = ''; $mailer->AddAddress($pick['email'], $pick["full_name"]); if ($mailer->Send()) { print " SENT " . round(microtime(TRUE) - $startTime, 2) . " secs<br/>\n"; flush(); $updateQuery = "UPDATE `" . BIT_DB_PREFIX . "mail_queue` SET `sent_date`=?,`url_code`=? WHERE `content_id`=? AND `email`=?"; $this->mDb->query($updateQuery, array(time(), $pick['url_code'], $pick['content_id'], $pick['email'])); } else { $updateQuery = "UPDATE `" . BIT_DB_PREFIX . "mail_queue` SET `mail_error`=?,`sent_date`=? WHERE `content_id`=? AND `email`=?"; $this->mDb->query($updateQuery, array($mailer->ErrorInfo, time(), $pick['content_id'], $pick['email'])); $pick['error'] = $mailer->ErrorInfo; $this->logError($pick); } } } }
function bituser_api_handler($pMethod, $pRequest) { global $gApi, $gBitSystem, $gBitSmarty, $gBitUser; switch ($pMethod) { case 'POST': // case 'PUT': $newUser = new BitUser(); if ($newUser->register($pRequest)) { $gApi->outputJson(200, $newUser->mInfo); } else { $gApi->outputJson(HttpStatusCodes::HTTP_CONFLICT, $newUser->mErrors); } break; case 'GET': $gApi->verifyAuthorization(); $gContent =& $gBitUser; $gContent->verifyViewPermission(); $gApi->outputJson(HttpStatusCodes::HTTP_OK, $gContent->mInfo); break; case 'DELETE': $gApi->verifyAuthorization(); if ($gContent->hasAdminPermission()) { // if( is_a( $gContent, 'BitUser' ) && $gContent->isValid() ) { $gContent->verifyExpungePermission(); // } } break; } $gBitSystem->display('bitpackage:api/api_json_output.tpl'); }
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; }
/** * load Load the data from the database * * @access public * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function load() { if ($this->verifyId($this->mEnergyMeasuresId) || $this->verifyId($this->mContentId)) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization $lookupColumn = $this->verifyId($this->mEnergyMeasuresId) ? 'energymeasure_id' : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mEnergyMeasuresId) ? $this->mEnergyMeasuresId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "\n\t\t\t\tSELECT energymeasures.*, lc.*,\n\t\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\n\t\t\t\t\tlfp.storage_path AS `image_attachment_path` \n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "energymeasures_data` energymeasures\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = energymeasures.`content_id` ) \n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON( la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y' )\n\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lfp ON( lfp.`file_id` = la.`foreign_id` )\n\t\t\t\t\t{$joinSql}\n\t\t\t\tWHERE energymeasures.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mEnergyMeasuresId = $result->fields['energymeasure_id']; $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo); $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['parsed_data'] = $this->parseData(); $this->mInfo['thumbnail_urls'] = $this->getThumbnailUrls($this->mInfo); LibertyMime::load(); } } return count($this->mInfo); }
/** * If this object constructed with a valid Id then load from the DB * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure */ public function load() { if ($this->verifyId($this->mId) || $this->verifyId($this->mContentId)) { $lookupColumn = $this->verifyId($this->mId) ? $this->mChildIdName : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mId) ? $this->mId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "\n\t\t\t\tSELECT data.*, lc.*,\n\t\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name\n\t\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . $this->mFormTbl . "` data\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = data.`content_id`)\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\n\t\t\t\t\t{$joinSql}\n\t\t\t\tWHERE (data.`{$lookupColumn}` = ?)\n\t\t\t\t\t{$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mId = $result->fields[$this->mChildIdName]; $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_name'] = BitUser::getTitle($this->mInfo); $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['edit_url'] = $this->getEditUrl(); $this->mInfo['remove_url'] = $this->getRemoveUrl(); $this->mInfo['parsed_data'] = $this->parseData(); parent::load(); } } return count($this->mInfo); }
/** * load Load the data from the database * * @access public * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function load() { if ($this->verifyId($this->mSampleId) || $this->verifyId($this->mContentId)) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization $lookupColumn = $this->verifyId($this->mSampleId) ? 'sample_id' : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mSampleId) ? $this->mSampleId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "\n\t\t\t\tSELECT sample.*, lc.*,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name\n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "sample_data` sample\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = sample.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tWHERE sample.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mSampleId = $result->fields['sample_id']; $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo); $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['parsed_data'] = $this->parseData(); LibertyMime::load(); } } return count($this->mInfo); }
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 smarty_function_displayname($pParams, &$gBitSmarty) { global $gBitUser; if (!empty($pParams['hash'])) { if (is_array($pParams['hash'])) { $hash = array_merge($pParams, $pParams['hash']); unset($hash['hash']); // if the hash only has a user_id, we need to look up the user if (@BitBase::verifyId($hash['user_id']) && empty($hash['user']) && empty($hash['email']) && empty($hash['login'])) { $lookupHash['user_id'] = $hash['user_id']; } } else { // We were probably just passed the 'login' due to legacy code which has yet to be converted if (strpos('@', $pParams['hash'])) { $lookupHash['email'] = $hash; } elseif (is_numeric($pParams['hash'])) { $lookupHash['user_id'] = $hash; } else { $lookupHash['login'] = $hash; } } } elseif (!empty($pParams['user_id'])) { $lookupHash['user_id'] = $pParams['user_id']; } elseif (!empty($pParams['email'])) { $lookupHash['email'] = $pParams['email']; } elseif (!empty($pParams['login'])) { $lookupHash['login'] = $pParams['login']; } elseif (!empty($pParams['user'])) { $lookupHash['login'] = $pParams['user']; } elseif (empty($pParams)) { global $gBitUser; $hash = $gBitUser->mInfo; } if (!empty($lookupHash)) { $hash = $gBitUser->getUserInfo($lookupHash); } if (!empty($hash)) { $displayName = BitUser::getDisplayNameFromHash(empty($pParams['nolink']), $hash); } else { // Now we're really in trouble. We don't even have a user_id to work with $displayName = "Unknown"; } return $displayName; }
$item->title = "[NEW] " . $item->title; } } 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);
<?php /** * @version $Header$ * @package blogs * @subpackage modules */ /** * required setup */ include_once BLOGS_PKG_PATH . 'BitBlog.php'; //require_once( USERS_PKG_PATH.'BitUser.php' ); global $gQueryUserId, $module_rows, $moduleParams; $listHash['max_records'] = $module_rows; $listHash['sort_mode'] = !empty($moduleParams['module_params']['sort_mode']) ? $moduleParams['module_params']['sort_mode'] : 'created_desc'; BitUser::userCollection($moduleParams['module_params'], $listHash); $blog = new BitBlog(); if ($modBlogs = $blog->getList($listHash)) { foreach (array_keys($modBlogs) as $b) { $modBlogs[$b]['post'] = $blog->getPost(array('blog_id' => $modBlogs[$b]['blog_id'])); } $_template->tpl_vars['modBlogs'] = new Smarty_variable($modBlogs); } $moduleTitle = !empty($moduleParams['title']) ? $moduleParams['title'] : 'Blog Roll'; $_template->tpl_vars['moduleTitle'] = new Smarty_variable($moduleTitle);
* @subpackage functions */ // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // 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. // assign next step in installation process $gBitSmarty->assign('next_step', $step); if (!empty($_REQUEST['admin_submit'])) { $mail = $errors = array(); if (empty($_REQUEST['login'])) { $errors['login'] = "******"; } if (empty($_REQUEST['email'])) { $errors['email'] = "You must specify an email address."; } else { BitUser::verifyAnonEmail($_REQUEST['email'], $errors); } if ($_REQUEST['password'] != $_REQUEST['pass_confirm']) { $errors['password'] = "******"; $_REQUEST['password'] = ''; } elseif (strlen($_REQUEST['password']) < 4) { $errors['password'] = "******"; $_REQUEST['password'] = ''; } if (empty($errors)) { $app = '_done'; $gBitSmarty->assign('next_step', $step + 1); $gBitSmarty->assign('pass_disp', preg_replace('/./i', '•', $_REQUEST['password'])); // do a mailer check as well - we need to remove trailing options for the sendmail_path check if (!empty($_REQUEST['testemail'])) { if (($mail_path = trim(preg_replace("#\\s+\\-[a-zA-Z]+.*\$#", "", ini_get('sendmail_path')))) && is_file($mail_path)) {
$page_cnt = 1; 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
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 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; }
<?php /** * @version $Header$ * @package blogs * @subpackage modules */ /** * required setup */ include_once BLOGS_PKG_PATH . 'BitBlog.php'; //require_once( USERS_PKG_PATH.'BitUser.php' ); global $gQueryUserId, $moduleParams; //$params = $moduleParams['module_params']; $listHash['max_records'] = $moduleParams['module_rows']; $listHash['sort_mode'] = 'last_modified_desc'; BitUser::userCollection($moduleParams, $listHash); $blog = new BitBlog(); $ranking = $blog->getList($listHash); $_template->tpl_vars['modLastModifiedBlogs'] = new Smarty_variable($ranking);
function getOverallUserRating($pUserId) { $ret = array(); if (@BitUser::verifyId($pUserId) && $pUserId > 0) { global $gBitSystem; $bindVars = array($pUserId); $query = "SELECT sth.`rating`, COUNT( sth.`rating`) AS `rating_count`, SUM( sth.`weight` ) AS `weight`\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_content` lc\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content_history` lch ON( lch.`content_id`=lc.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "stars_history` sth ON( sth.`content_id`=lc.`content_id` )\n\t\t\t\tWHERE sth.`version` != 0 AND lch.`user_id`=?\n\t\t\t\tGROUP BY sth.`rating`"; $summary = $this->mDb->getAll($query, $bindVars); list($rating, $rating_count) = $this->calculateRatingFromSummary($summary); $ret['stars_rating'] = $rating; $ret['stars_rating_count'] = $rating_count; $normalized_rating = $this->normalizeRating($rating); $ret['stars_pixels'] = $normalized_rating * $gBitSystem->getConfig('stars_icon_width', 22); $ret['stars_load'] = TRUE; } return $ret; }
/** * Get a list of action log entries * * @param array $pListHash List options * @access public * @return List of entries on success, FALSE on failure */ function getActionLogs(&$pListHash) { LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $selectSql = $joinSql = $orderSql = $whereSql = ''; if (!empty($pListHash['find'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " UPPER( lal.`log_message` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } if (!empty($pListHash['find_title'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " UPPER( lal.`title` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find_log']) . '%'; } if (!empty($pListHash['user_id'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " lal.`user_id` = ? "; $bindVars[] = $pListHash['user_id']; } if (!empty($pListHash['content_id'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " lal.`content_id` = ? "; $bindVars[] = $pListHash['content_id']; } if (!empty($pListHash['sort_mode'])) { if (preg_match("/^last_modified|^title/", $pListHash['sort_mode'])) { $pListHash['sort_mode'] = "lal." . $pListHash['sort_mode']; } $orderSql = " ORDER BY " . $this->convertSortMode($pListHash['sort_mode']) . " "; } $query = "\n\t\t\tSELECT lal.*,\n\t\t\t\tlc.`content_type_guid`, lc.`created`, lct.`content_name`, lct.`content_name_plural`,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name\n\t\t\tFROM `" . BIT_DB_PREFIX . "liberty_action_log` lal\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = lal.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lct.`content_type_guid` = lc.`content_type_guid` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lal.`user_id` )\n\t\t\t{$whereSql} {$orderSql}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); while ($aux = $result->fetchRow()) { $aux['user'] = $aux['modifier_user']; $aux['editor'] = isset($aux['modifier_real_name']) ? $aux['modifier_real_name'] : $aux['modifier_user']; $aux['display_name'] = BitUser::getDisplayNameFromHash(NULL, $aux); $ret[] = $aux; } $query = "SELECT COUNT( lal.`user_id` ) FROM `" . BIT_DB_PREFIX . "liberty_action_log` lal {$whereSql}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return $ret; }
/** * load Load the data from the database * * @access public * @return boolean TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function load() { if ($this->verifyId($this->mTicketId) || $this->verifyId($this->mContentId)) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization $lookupColumn = $this->verifyId($this->mTicketId) ? 'ticket_id' : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mTicketId) ? $this->mTicketId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "\n\t\t\t\tSELECT t.*, lc.*,\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\n\t\t\t\tlcm.`title` AS milestone_title\n\t\t\t\t{$selectSql}\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "tickets` t\n\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = t.`content_id` ) {$joinSql}\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lcm ON( lc.`content_id` = t.`milestone_id` )\n\t\t\t\tWHERE t.`{$lookupColumn}`=? {$whereSql}"; $attrQuery = "SELECT ta.*, tf.`def_id`, tf.`field_id`, tf.`field_value`, td.`title` AS def_title\n FROM `" . BIT_DB_PREFIX . "ticket_attributes` ta\n LEFT JOIN `" . BIT_DB_PREFIX . "ticket_field_values` tf ON( ta.`field_id` = tf.`field_id` )\n\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "ticket_field_defs` td ON( tf.`def_id` = td.`def_id` )\n WHERE ta.`ticket_id`=?"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mTicketId = $result->fields['ticket_id']; $this->mMilestone['milestone_id'] = $result->fields['milestone_id']; $this->mMilestone['title'] = $result->fields['milestone_title']; $this->mInfo['creator'] = !empty($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = !empty($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_name'] = BitUser::getTitleFromHash($this->mInfo); $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['parsed_data'] = $this->parseData(); $attrResult = $this->mDb->query($attrQuery, array($this->mTicketId)); while ($row = $attrResult->fetchRow()) { $this->mAttributes[$row["def_id"]] = $row; } LibertyMime::load(); } } return count($this->mInfo); }
function subscribe($pSubscribeHash) { // $notify = FALSE, $remind = FALSE ) { $ret = FALSE; if ($this->isValid()) { global $gBitSystem; global $gBitSmarty; global $gBitUser; // Check for duplicates $all_subs = $this->getSubscribers(TRUE); $duplicate = FALSE; foreach ($all_subs as $sub) { if ($sub['email'] == $pSubscribeHash['email']) { $duplicate = TRUE; $urlCode = $sub['sub_code']; } elseif (!empty($pSubscribeHash['user_id']) && $sub['user_id'] == $pSubscribeHash['user_id']) { } } $urlCode = !$duplicate ? md5(BitUser::genPass()) : $urlCode; $now = date("U"); // Generate a code and store it and send an email with the // URL to confirm the subscription put valid as 'n' if (!$duplicate) { if (@BitBase::verifyId($pSubscribeHash['user_id'])) { // we have user_id subscribing, use the id, NULL the email $subUserId = $pSubscribeHash['user_id']; $subEmail = NULL; } else { // we have user_id subscribing, use the id, NULL the email $subUserId = NULL; $subEmail = $pSubscribeHash['email']; } $query = "insert into `" . BIT_DB_PREFIX . "mail_subscriptions` (`content_id`, `user_id`, `email`,`sub_code`,`is_valid`,`subscribed_date`) VALUES (?,?,?,?,?,?)"; $result = $this->mDb->query($query, array($this->mContentId, $subUserId, $subEmail, $urlCode, 'n', (int) $now)); } if (!empty($pSubscribeHash['notify']) && $this->getField('validate_addr') == 'y' || !empty($pSubscribeHash['remind'])) { // Generate a code and store it and send an email with the $gBitSmarty->assign('sub_code', $urlCode); $mail_data = $gBitSmarty->fetch('bitpackage:newsletters/confirm_newsletter_subscription.tpl'); @mail($email, tra('Newsletter subscription information at') . ' ' . $gBitSystem->getConfig("bitmailer_from"), $mail_data, "From: " . $gBitSystem->getConfig("sender_email") . "\r\nContent-type: text/plain;charset=utf-8\r\n"); } $ret = TRUE; } return $ret; }
/** * Get list of all treasury galleries * * @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 gallery title - case insensitive * @param $pListHash[max_records] maximum number of rows to return * @param $pListHash[offset] number of results data is offset by * @param $pListHash[title] gallery name * @param $pListHash[parent_id] gallery parent_id * @param $pListHash[get_sub_tree] get the subtree to every gallery * @access public * @return List of galleries **/ function getList(&$pListHash) { global $gBitDbType, $gBitSystem, $gBitUser; LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $selectSql = $joinSql = $orderSql = $whereSql = ''; if (@BitBase::verifyId($pListHash['root_structure_id'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " ls.`root_structure_id`=? "; $bindVars[] = $pListHash['root_structure_id']; } if (!empty($pListHash['get_sub_tree'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " ls.`structure_id`=ls.`root_structure_id` "; } if (!empty($pListHash['find'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " UPPER( lc.`title` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } if (isset($pListHash['parent_id'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= ' ls.`parent_id` = ? '; $bindVars[] = $pListHash['parent_id']; } if (!empty($pListHash['sort_mode'])) { $orderSql .= " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } else { // default sort mode makes list look nice $orderSql .= " ORDER BY ls.`root_structure_id`, ls.`structure_id` ASC"; } // update query with service sql $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); // get the number of files in this gallery if ($gBitDbType != 'mysql' && $gBitDbType != 'mysqli') { $subselect = ", (\n\t\t\t\tSELECT COUNT( trm.`item_content_id` )\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_map` trm\n\t\t\t\tWHERE trm.`gallery_content_id`=trg.`content_id`\n\t\t\t) AS item_count"; } else { $subselect = ""; } // don't fetch trg.`is_private` for list, because it conflicts with gks.is_private // and it's not used on list anyway $query = "\n\t\t\tSELECT trg.`content_id`, trg.`structure_id`,\n\t\t\tls.`root_structure_id`, ls.`parent_id`,\n\t\t\tlc.`title`, lc.`data`, lc.`user_id`, lc.`content_type_guid`, lc.`created`, lc.`format_guid`, lch.`hits`,\n\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$subselect} {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_gallery` trg\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trg.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lc.`content_id` = lch.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = trg.`structure_id` )\n\t\t\t\t{$joinSql}\n\t\t\t{$whereSql}\n\t\t\t{$orderSql}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); if (!empty($pListHash['get_sub_tree'])) { $struct = new LibertyStructure(); } while ($aux = $result->fetchRow()) { $hasUserPerm = TRUE; // check to see if we have premissions to do someing specific with this gallery if (!empty($pListHash['content_permission'])) { $gal = new TreasuryGallery(NULL, $aux['content_id']); if (!$gal->hasUserPermission($pListHash['content_permission'])) { $hasUserPerm = FALSE; } } if ($hasUserPerm) { $content_ids[] = $aux['content_id']; $aux['user'] = $aux['creator_user']; $aux['real_name'] = isset($aux['creator_real_name']) ? $aux['creator_real_name'] : $aux['creator_user']; $aux['editor'] = isset($aux['modifier_real_name']) ? $aux['modifier_real_name'] : $aux['modifier_user']; $aux['display_name'] = BitUser::getDisplayNameFromHash(FALSE, $aux); $aux['display_url'] = self::getDisplayUrlFromHash($aux); $aux['display_link'] = $this->getDisplayLink($aux['title'], $aux); $aux['thumbnail_url'] = liberty_fetch_thumbnails(array('storage_path' => $this->getGalleryThumbBaseUrl($aux['content_id']), 'mime_image' => FALSE)); // deal with the parsing $parseHash['format_guid'] = $aux['format_guid']; $parseHash['content_id'] = $aux['content_id']; $parseHash['user_id'] = $aux['user_id']; $parseHash['data'] = $aux['data']; $aux['parsed_data'] = $this->parseData($parseHash); // sucky additional query to fetch item number without subselect if ($gBitDbType == 'mysql' || $gBitDbType == 'mysqli') { $item_count_query = "SELECT COUNT( trm.`item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` trm WHERE trm.`gallery_content_id`=?"; $aux['item_count'] = $this->mDb->getOne($item_count_query, array($aux['content_id'])); } if (!empty($pListHash['get_sub_tree'])) { $aux['subtree'] = $struct->getSubTree($aux['structure_id']); } $ret[$aux['content_id']] = $aux; } } $query = "SELECT COUNT( lc.`title` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_gallery` trg\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trg.`content_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = trg.`structure_id` )\n\t\t\t{$joinSql} {$whereSql}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return $ret; }
/** * removes user and associated private data * * @access public * @return always FALSE??? * TODO: fix return */ function expunge($pExpungeContent = NULL) { global $gBitSystem, $gBitUser; $this->clearFromCache(); if ($this->isValid()) { $this->StartTrans(); if ($this->mUserId == $gBitUser->mUserId) { $this->mDb->RollbackTrans(); $gBitSystem->fatalError(tra('You cannot delete yourself')); } elseif ($this->mUserId != ANONYMOUS_USER_ID) { $userTables = array('users_roles_map'); foreach ($userTables as $table) { $query = "DELETE FROM `" . BIT_DB_PREFIX . $table . "` WHERE `user_id` = ?"; $result = $this->mDb->query($query, array($this->mUserId)); } if (parent::expunge($pExpungeContent)) { $this->CompleteTrans(); return TRUE; } else { $this->mDb->RollbackTrans(); } } else { $this->mDb->RollbackTrans(); $gBitSystem->fatalError(tra('The anonymous user cannot be deleted')); } } return FALSE; }
/** * get list of all pigeonholes * @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 * @param $pListHash[title] pigeonhole name * @param $pListHash[parent_id] pigeonhole parent_id, optional * @param $pListHash[root_structure_id] only load the pigoenhole this root_structure_id is part of * @param $pListHash[load_only_root] only load top most items * @param $pListHash[parent_content_id] all the sons of the pigeonhole parent content_id , optional * @param $pListHash[load_also_root] if parent_content_id is set load also the father, optionnal * @return array of pigeonholes in 'data' and count of pigeonholes in 'cant' * @access public **/ function getList(&$pListHash) { global $gBitSystem, $gBitUser, $gBitDbType; LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $where = $order = $join = $select = ''; if (@BitBase::verifyId($pListHash['root_structure_id'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " ls.`root_structure_id`=? "; $bindVars[] = $pListHash['root_structure_id']; } if (!empty($pListHash['load_only_root'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " ls.`structure_id`=ls.`root_structure_id` "; } if (!empty($pListHash['find'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= " UPPER( lc.`title` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } if (!empty($pListHash['title'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' lc.`title` = ?'; $bindVars[] = $pListHash['title']; } if ($gBitSystem->isFeatureActive('pigeonholes_allow_forbid_insertion') && !empty($pListHash['insertable'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' lcp.`pref_value` IS NULL OR lcp.`pref_value` != \'on\' '; $join .= ' LEFT JOIN `' . BIT_DB_PREFIX . 'liberty_content_prefs` lcp ON (lc.`content_id` = lcp.`content_id` AND lcp.`pref_name` = \'no_insert\') '; $select .= ' , lcp.`pref_value` AS no_insert '; } if (isset($pListHash['parent_id'])) { $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' ls.`parent_id` = ? '; $bindVars[] = $pListHash['parent_id']; } if (!empty($pListHash['parent_content_id'])) { $join .= 'INNER JOIN `' . BIT_DB_PREFIX . 'liberty_structures` lsf ON (ls.`parent_id` = lsf.`structure_id`'; if (!empty($pListHash['load_also_root'])) { $join .= ' OR ls.`structure_id`= lsf.`structure_id`'; } $join .= ')'; $where .= empty($where) ? ' WHERE ' : ' AND '; $where .= ' lsf.`content_id` = ? '; $bindVars[] = $pListHash['parent_content_id']; } if (!empty($pListHash['sort_mode'])) { $order .= " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } else { // default sort mode makes list look nice $order .= " ORDER BY ls.`root_structure_id`, ls.`structure_id` ASC"; } // only use subselect for old crappy mysql if ($gBitDbType != 'mysql') { $subselect = ", (\n\t\t\t\tSELECT COUNT( pm.`content_id` )\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm\n\t\t\t\tWHERE pm.`parent_id`=pig.`content_id`\n\t\t\t) AS members_count"; } else { $subselect = ""; } $query = "SELECT pig.*, ls.`root_structure_id`, ls.`parent_id`, lc.`title`, lc.`data`, lc.`user_id`, lc.`content_type_guid`, lc.`format_guid`,\n\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$select} {$subselect}\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where} {$order}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); while ($aux = $result->fetchRow()) { //$content_ids[] = $aux['content_id']; $aux['user'] = $aux['creator_user']; $aux['real_name'] = isset($aux['creator_real_name']) ? $aux['creator_real_name'] : $aux['creator_user']; $aux['display_name'] = BitUser::getDisplayNameFromHash(FALSE, $aux); $aux['editor'] = isset($aux['modifier_real_name']) ? $aux['modifier_real_name'] : $aux['modifier_user']; $aux['display_link'] = Pigeonholes::getDisplayLink($aux['title'], $aux); // get member count for mysql - haha if ($gBitDbType == 'mysql') { $aux['members_count'] = $this->mDb->getOne("SELECT COUNT( pm.`content_id` ) FROM `" . BIT_DB_PREFIX . "pigeonhole_members` pm WHERE pm.`parent_id`=?", array($aux['content_id'])); } if (!empty($pListHash['parse_data']) && !empty($aux['data'])) { $aux['parsed_data'] = $this->parseData($aux['data'], $aux['format_guid']); } if (!empty($pListHash['force_extras']) || !empty($pListHash['load_extras']) && $aux['structure_id'] == @$pListHash['structure_id']) { $aux['path'] = $this->getPigeonholePath($aux['structure_id']); $aux['display_path'] = Pigeonholes::getDisplayPath($aux['path']); // Move all the members data into the right place $memberListHash = array('content_id' => $aux['content_id'], 'content_type_guid' => !empty($pListHash['content_type_guid']) ? $pListHash['content_type_guid'] : NULL, 'max_records' => !empty($pListHash['members_max_records']) ? $pListHash['members_max_records'] : NULL, 'list_page' => !empty($pListHash['members_list_page']) ? $pListHash['members_list_page'] : NULL, 'sort_mode' => !empty($pListHash['members_sort_mode']) ? $pListHash['members_sort_mode'] : NULL, 'find' => !empty($pListHash['members_find']) ? $pListHash['members_find'] : NULL); $aux['members'] = $this->getMemberList($memberListHash); $aux['listInfo'] = $memberListHash['listInfo']; //$aux['members_count'] = count( $aux['members'] ); if ($gBitSystem->getConfig('pigeonholes_list_style') == 'table') { $this->alphabetiseMembers($aux['members']); } } $ret[$aux['structure_id']] = $aux; } $query = "SELECT COUNT( lc.`title` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "pigeonholes` pig\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = pig.`content_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON ( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON ( uuc.`user_id` = lc.`user_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_structures` ls ON ( ls.`structure_id` = pig.`structure_id` )\n\t\t\t{$join} {$where}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return $ret; }
function sendTrackbacks($pTrackbacks) { $ret = array(); if ($this->isValid() && !empty($pTrackbacks)) { // Split to get each URI $tracks = explode(',', $pTrackbacks); //Build uri for post $parts = parse_url($_SERVER['REQUEST_URI']); $uri = httpPrefix() . str_replace('post', 'view_post', $parts['path']) . '?post_id=' . $this->mPostId . '&blog_id=' . $this->mInfo['blog_id']; include_once UTIL_PKG_PATH . 'Snoopy.class.inc'; $snoopy = new Snoopy(); foreach ($tracks as $track) { @($fp = fopen($track, 'r')); if ($fp) { $data = ''; while (!feof($fp)) { $data .= fread($fp, 32767); } fclose($fp); preg_match("/trackback:ping=(\"|\\'|\\s*)(.+)(\"|\\'\\s)/", $data, $reqs); if (!isset($reqs[2])) { return $ret; } @($fp = fopen($reqs[2], 'r')); if ($fp) { fclose($fp); $submit_url = $reqs[2]; $submit_vars["url"] = $uri; $submit_vars["blog_name"] = $this->mInfo['blogtitle']; $submit_vars["title"] = $this->mInfo['title'] ? $this->mInfo['title'] : date("d/m/Y [h:i]", $this->mInfo['created']); $submit_vars["title"] .= ' ' . tra('by') . ' ' . BitUser::getDisplayNameFromHash(FALSE, $this->mInfo); $submit_vars["excerpt"] = substr($post_info['data'], 0, 200); $snoopy->submit($submit_url, $submit_vars); $back = $snoopy->results; if (!strstr('<error>1</error>', $back)) { $ret[] = $track; } } } } } return $ret; }
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(); } } } }
} else { // check if we want to use the cache file $cacheFile = TEMP_PKG_PATH . RSS_PKG_NAME . '/' . BLOGS_PKG_NAME . (!empty($_REQUEST['user_id']) ? "_" . $_REQUEST['user_id'] : "") . (!empty($_REQUEST['group_id']) ? "_" . $_REQUEST['group_id'] : "") . (!empty($_REQUEST['role_id']) ? "_" . $_REQUEST['role_id'] : "") . (!empty($_REQUEST['blog_id']) ? "_" . $_REQUEST['blog_id'] : "") . '_' . $cacheFileTail; $rss->useCached($rss_version_name, $cacheFile, $gBitSystem->getConfig('rssfeed_cache_time')); $blogPost = new BitBlogPost(); $listHash['sort_mode'] = 'last_modified_desc'; $listHash['max_records'] = $gBitSystem->getConfig('blogs_rss_max_records', 10); $listHash['parse_data'] = TRUE; $listHash['full_data'] = TRUE; if (!empty($_REQUEST['user_id'])) { if ($gBitSystem->getConfig('user_class', 'BitPermUser') == 'RolePermUser') { require_once USERS_PKG_PATH . 'RoleUser.php'; } else { require_once USERS_PKG_PATH . 'BitUser.php'; } $blogUser = new BitUser(); $userData = $blogUser->getUserInfo(array('user_id' => $_REQUEST['user_id'])); // dont try and fool me if (!empty($userData)) { $userName = $userData['real_name'] ? $userData['real_name'] : $userData['login']; $rss->title = $userName . " at " . $gBitSystem->getConfig('site_title'); $listHash['user_id'] = $_REQUEST['user_id']; } } else { if (!empty($_REQUEST['group_id'])) { require_once USERS_PKG_PATH . 'BitPermUser.php'; $permUser = new BitPermUser(); $groupData = $permUser->getGroupInfo($_REQUEST['group_id']); // dont try and fool me if (!empty($groupData)) { $groupName = $groupData['group_name'];
$_REQUEST['topic_id'] = !empty($_REQUEST['topic_id']) ? $_REQUEST['topic_id'] : NULL; $_REQUEST['type_id'] = !empty($_REQUEST['type_id']) ? $_REQUEST['type_id'] : NULL; $_template->tpl_vars['futures'] = new Smarty_variable($gContent->getFutureList($listHash)); } else { $_REQUEST['status_id'] = ARTICLE_STATUS_APPROVED; $_REQUEST['max_records'] = $gBitSystem->getConfig('articles_max_list'); } if (!empty($_REQUEST['topic'])) { $_template->tpl_vars['topic'] = new Smarty_variable($_REQUEST['topic']); } if (!empty($moduleParams)) { $listHash = array_merge($_REQUEST, $moduleParams['module_params']); $listHash['max_records'] = $module_rows; //$listHash['parse_data'] = TRUE; //$listHash['load_comments'] = TRUE; } else { $listHash = $_REQUEST; } BitUser::userCollection($_REQUEST, $listHash); $articles = $gContent->getList($listHash); $_template->tpl_vars['gContent'] = new Smarty_variable($gContent); $_template->tpl_vars['articles'] = new Smarty_variable($articles); $_template->tpl_vars['listInfo'] = new Smarty_variable($listHash['listInfo']); // show only descriptions on listing page $_template->tpl_vars['showDescriptionsOnly'] = new Smarty_variable(TRUE); // display submissions if we have the perm to approve them if ($gBitUser->hasPermission('p_articles_approve_submission') || $gBitSystem->isFeatureActive('articles_auto_approve') && $gBitUser->isRegistered()) { $listHash = array('status_id' => ARTICLE_STATUS_PENDING); $submissions = $gContent->getList($listHash); $_template->tpl_vars['submissions'] = new Smarty_variable($submissions); }
/** * themes_content_list * * @param array $pContent * @param array $pListHash * @access public * @return void */ function themes_content_list($pContent, $pListHash) { global $gBitSystem, $gBitSmarty, $gBitThemes, $gBitUser, $gQueryUser; // users_themes='u' is for all users content if ($gBitSystem->getConfig('users_themes') == 'u') { if ($gBitSystem->isFeatureActive('users_preferences') && !empty($pListHash['user_id'])) { if ($pListHash['user_id'] == $gBitUser->mUserId) { // small optimization to reduce checking when we are looking at our own content, which is frequent if ($userStyle = $gBitUser->getPreference('theme')) { $theme = $userStyle; } } else { $theme = BitUser::getUserPreference('theme', NULL, $pListHash['user_id']); } } } if (!empty($theme) && $theme != DEFAULT_THEME) { $gBitThemes->setStyle($theme); if (!is_object($gQueryUser)) { $userClass = $gBitSystem->getConfig('user_class', 'BitPermUser'); require_once USERS_PKG_PATH . $userClass . '.php'; $gQueryUser = new $userClass($pListHash['user_id']); $gQueryUser->load(); $gBitSmarty->assignByRef('gQueryUser', $gQueryUser); } } }
$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 data_spytext($data, $params) { global $gLibertySystem; global $gBitUser; extract($params, EXTR_SKIP); if (empty($data)) { // If there is NO data to display - why do anything - get out of here return " "; } // **************** Elvis has left the building! $isSpy = $gBitUser->isAdmin() ? TRUE : FALSE; // Admin should always see SpyText $isRealSpy = FALSE; // So Admin does not see EVERY Alert if (isset($spy)) { // Is the current user on the Spy List $spyArray = explode("|", trim(strtolower($spy))); // spy's allowed to see the message foreach ($spyArray as $i) { if ($i == strtolower($gBitUser->getTitle())) { $isSpy = TRUE; $isRealSpy = TRUE; } } } if (isset($agency)) { // Is the current user in one of the Spy Agencies $spyArray = explode("|", trim(strtolower($agency))); // create an array from the string $groups = $gBitUser->getGroups(); foreach ($spyArray as $i) { foreach ($groups as $g) { if (trim(strtolower($g['group_name'])) == $i) { $isSpy = TRUE; $isRealSpy = TRUE; } } } } if (!$isSpy) { // The current user is NOT a Spy - get out of here return " "; } // **************** Elvis has left the building! $addToBox = isset($to) ? TRUE : FALSE; if ($addToBox) { $toLine = 'To the Spy: '; // Set Default $agencyLine = 'To the Agency: '; // Set Default $senderLine = 'From Your Source: '; // Set Default $header = explode("|", $to); $toLine = isset($header[0]) && ($header[0] != '*' && $header[0] != 'TRUE') ? $header[0] . ' ' : $toLine; $agencyLine = isset($header[1]) && $header[1] != '*' ? $header[1] . ' ' : $agencyLine; $senderLine = isset($header[2]) && $header[2] != '*' ? $header[2] . ' ' : $senderLine; $addToLine = FALSE; if (isset($spy)) { // Provide a Listing of all spys tested $spyArray = explode("|", $spy); // Strip Out the | character natcasesort($spyArray); // Sort it foreach ($spyArray as $i) { if ($gBitUser->userExists(array('login' => $i))) { $toLine = $addToLine ? $toLine . ', ' : $toLine; // misses the first and last Spy $toLine = $toLine . BitUser::getDisplayName(TRUE, array('login' => $i)); $addToLine = True; } } $toLine = '<tr><td style="vertical-align: top;">' . $toLine . '</td></tr>'; } $addAgencyLine = FALSE; if (isset($agency)) { // Provide a Listing of all agencies tested $agency_array = explode("|", $agency); // Strip Out the | character natcasesort($agency_array); // Sort it $listHash = array('sort_mode' => 'group_name_asc'); $groups = $gBitUser->getAllGroups($listHash); foreach ($agency_array as $i) { // TODO - Remove all Non-valid groups - ($i == $i) if ($groupId = $gBitUser->groupExists($i)) { $validGroups[$groupId] = $i; $agencyLine = $addAgencyLine ? $agencyLine . ', ' : $agencyLine; // misses the first and last Agency $agencyLine = $agencyLine . '<strong>' . $i . '</strong>'; $addAgencyLine = True; } else { $k = key($agency_array); unset($agency_array[$k]); } } $agencyLine = '<tr><td style="vertical-align: top;">' . $agencyLine . '</td></tr>'; } $addSenderLine = FALSE; if (isset($sender)) { // Provide a Listing of all senders tested $spyArray = explode("|", $sender); // Strip Out the | character natcasesort($spyArray); // Sort it foreach ($spyArray as $i) { // TODO - Remove All Non-valid users - ($i == $i) if ($gBitUser->userExists(array('login' => $i))) { $senderLine = $addSenderLine ? $senderLine . ', ' : $senderLine; // misses the first and last Spy $senderLine = $senderLine . BitUser::getDisplayName(TRUE, array('login' => $i)); $addSenderLine = TRUE; } } $senderLine = '<tr><td style="vertical-align: top;">' . $senderLine . '</td></tr>'; } $spyId = 'spydata' . microtime() * 1000000; $toHeader = '<div>' . '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . '<tr>' . '<td width=42%><hr></td>' . '<td style="text-align:center">' . '<a title="Expand/Contract for Addresses" href="javascript:flip(' . $spyId . ')">Address</a>' . '</td>' . '<td width=42%><hr></td>' . '</tr>' . '</table>' . '</div>'; $addToBox = $addToBox && ($addToLine || ($addAgencyLine || $addSenderLine)) ? TRUE : FALSE; if ($addToBox) { $toBox = '<div>'; // Wrap's Arround Everything in toBox $toBox = $toBox . $toHeader . '<div style="display:none;" id="' . $spyId . '"><table border="1">'; $toBox = $addToLine ? $toBox . $toLine : $toBox; // Drop toLine if nothing on it $toBox = $addAgencyLine ? $toBox . $agencyLine : $toBox; // Drop agencyLine if nothing on it $toBox = $addSenderLine ? $toBox . $senderLine : $toBox; // Drop fromLine if nothing on it $toBox = $toBox . '</table></div>'; $toBox = $toBox . '</div>'; } } $spyId = 'spydata' . microtime() * 1000000; $hidden = isset($hidden) ? TRUE : FALSE; if ($hidden) { $useIcon = isset($icon) ? TRUE : FALSE; if ($useIcon) { if (trim(strtoupper($icon)) == 'TRUE') { $spyLink = '<a href="javascript:flip(' . $spyId . ')"><img src="' . LIBERTY_PKG_URL . 'icons/spy.gif"></img></a>'; } // Default // --------------------------> TODO - Need to set with Content Id No's if (!isset($spyLink)) { $spyLink = '<a href="javascript:flip(' . $spyId . ')"><img src="' . $icon . '"></img></a>'; // Last Choice - A URL } else { $spyLink = '<a href="javascript:flip(' . $spyId . ')"><img src="' . LIBERTY_PKG_URL . 'icons/spy.gif"></img></a>'; // Default } // Place the default last } else { // It's not linked to an Icon - so - It needs Title Bar $width = isset($width) ? $width : '20'; $width = (100 - $width) / 2 . '%'; $title = isset($title) ? $title : 'A Hidden Message'; $spyLink = '<div>' . '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . '<tr>' . '<td width=' . $width . '><hr></td>' . '<td style="text-align:center">' . '<a title="Expand/Contract for Hidden Text" href="javascript:flip(' . $spyId . ')">' . $title . '</a>' . '</td>' . '<td width=' . $width . '><hr></td>' . '</tr>' . '</table>' . '</div>'; } } $ret = $hidden ? $spyLink . '<div class="help box" style="display:none;" id="' . $spyId . '">' : ''; $ret = $addToBox ? $ret . $toBox : $ret; $ret = $ret . '<div class="help box" style="text-align:left;">' . $data . '</div>'; $ret = $hidden ? $ret . '</div>' : $ret; // I'm NOT Sure if this should be include or not - especially the way I have it set up // I have reduced the number of Alerts that an Admin would recieve - Only Hidden Messages $spyAlert = FALSE; if (isset($alert)) { if (strtoupper(trim($alert)) == 'TRUE') { $spyAlert = TRUE; $spyMsg = $isRealSpy ? 'Wake Up *UserName*!\\nThere is a message on this page for you.\\nUse your Secret Decoder Ring!' : ''; } else { $spyAlert = TRUE; $spyMsg = $alert; } } if ($gBitUser->isAdmin() && $hidden) { $spyMsg = '*UserName*\\nThere is Hidden SpyText on this page.'; $spyAlert = TRUE; } if ($spyAlert) { $spyArray = explode("*", $spyMsg); // Process the *UserName* for ($i = 0; $i <= count($spyArray) - 1; $i++) { $spyArray[$i] = trim(strtoupper($spyArray[$i])) == 'USERNAME' ? $gBitUser->getTitle() : $spyArray[$i]; } $spyMsg = implode(" ", $spyArray); echo "<script>window.alert(\"" . $spyMsg . "\");</script>"; } return $ret; }