/** * feed_get_actions */ function feed_get_actions($pListHash) { global $gBitDb; $whereSql = ''; $bindVars = 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, 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 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\n\t\t\t ORDER BY MAX(lal.last_modified) DESC"; $res = $gBitDb->query($query, $bindVars, $pListHash['max_records']); $conjugationQuery = "SELECT * FROM feed_conjugation"; $overrides = $gBitDb->getAssoc($conjugationQuery); $actions = array(); //loop through directed actions while ($action = $res->fetchRow()) { if (!empty($action['content_id'])) { //indicates that this isn't a direct action, more of a "status update" ex. "Ronald is pleased with his artwork" if ($content = LibertyContent::getLibertyObject($action['content_id'])) { $contentType = $content->getContentType(); $action['real_log'] = BitUser::getDisplayNameFromHash(empty($pListHash['no_link_user']), $action) . ' '; if (!empty($overrides[strtolower($contentType)])) { $action['real_log'] .= $overrides[$contentType]['conjugation_phrase']; if ($overrides[$contentType]['is_target_linked'] == 'y') { $action['real_log'] .= ' <a href="' . $content->getDisplayUrl() . '">' . $content->getTitle() . '</a>'; } if (!empty($overrides[$contentType]['feed_icon_url'])) { $action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url']; } } else { $action['real_log'] .= tra('edited') . ' <a href="' . $content->getDisplayUrl() . '">' . $content->getTitle() . '</a>'; } } else { unset($action); //invalid content_id } if (empty($action['feed_icon_url'])) { $action['feed_icon_url'] = FEED_PKG_URL . 'icons/pixelmixerbasic/pencil_16.png'; } $actions[] = $action; } } return $actions; }
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; }
/** * 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; }
/** * 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; }
/** * 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; }
if (empty($title) && $images) { $moduleTitle = ''; if (!empty($module_params['sort_mode'])) { if ($module_params['sort_mode'] == 'random') { $moduleTitle = 'Random'; } elseif ($module_params['sort_mode'] == 'created') { $moduleTitle = 'Recent'; } elseif ($module_params['sort_mode'] == 'hits') { $moduleTitle = 'Popular'; } } else { $moduleTitle = 'Random'; } $moduleTitle .= ' Images'; $moduleTitle = tra($moduleTitle); if (!empty($listHash['user_id'])) { $moduleTitle .= ' ' . tra('by') . ' ' . BitUser::getDisplayNameFromHash(TRUE, current($images)); } elseif (!empty($listHash['recent_users'])) { $moduleTitle .= ' ' . tra('by') . ' <a href="' . USERS_PKG_URL . '">' . tra('New Users') . '</a>'; } $listHash['sort_mode'] = $sort_mode; $_template->tpl_vars['moduleTitle'] = new Smarty_variable($moduleTitle); } else { $_template->tpl_vars['moduleTitle'] = new Smarty_variable($title); } $_template->tpl_vars['imageSort'] = new Smarty_variable($sort_mode); $_template->tpl_vars['modImages'] = new Smarty_variable($images); $_template->tpl_vars['module_params'] = new Smarty_variable($module_params); $_template->tpl_vars['maxlen'] = new Smarty_variable(isset($module_params["maxlen"])); $_template->tpl_vars['maxlendesc'] = new Smarty_variable(isset($module_params["maxlendesc"])); }
/** * getTitle * * @param array $pHash * @access public * @return get the users display name */ public static function getTitleFromHash(&$pHash, $pDefault = TRUE) { return BitUser::getDisplayNameFromHash(FALSE, $pHash); }
function send_order_email($pOrdersId, $pEmailRecipient = NULL, $pFormat = NULL) { global $currencies, $order_totals, $gBitCustomer; $language_page_directory = DIR_WS_LANGUAGES . $gBitCustomer->getLanguage() . '/'; require_once BITCOMMERCE_PKG_PATH . $language_page_directory . 'checkout_process.php'; require_once BITCOMMERCE_PKG_PATH . './includes/functions/functions_customers.php'; if (empty($pEmailRecipient)) { $pEmailRecipient = $this->customer['email_address']; } if ($this->email_low_stock != '' and SEND_LOWSTOCK_EMAIL == '1') { // send an email $email_low_stock = SEND_EXTRA_LOW_STOCK_EMAIL_TITLE . "\n\n" . $this->email_low_stock; zen_mail('', SEND_EXTRA_LOW_STOCK_EMAILS_TO, EMAIL_TEXT_SUBJECT_LOWSTOCK, $email_low_stock, STORE_OWNER, EMAIL_FROM, array('EMAIL_MESSAGE_HTML' => nl2br($email_low_stock)), 'low_stock', '', $pFormat); } // lets start with the email confirmation // make an array to store the html version $emailVars = array(); $emailVars['order'] = $this; //intro area if (!empty($this->customer['firstname'])) { $customerName = $this->customer['firstname'] . ' ' . $this->customer['lastname']; } else { $customerName = BitUser::getDisplayNameFromHash(FALSE, $this->customer); } $email_order = EMAIL_TEXT_HEADER . EMAIL_TEXT_FROM . STORE_NAME . "\n\n" . $customerName . "\n\n" . EMAIL_THANKS_FOR_SHOPPING . "\n\n" . EMAIL_DETAILS_FOLLOW . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $pOrdersId . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $pOrdersId, 'SSL', false) . "\n\n"; $emailVars['EMAIL_TEXT_HEADER'] = EMAIL_TEXT_HEADER; $emailVars['EMAIL_TEXT_FROM'] = EMAIL_TEXT_FROM; $emailVars['INTRO_STORE_NAME'] = STORE_NAME; $emailVars['EMAIL_THANKS_FOR_SHOPPING'] = EMAIL_THANKS_FOR_SHOPPING; $emailVars['EMAIL_DETAILS_FOLLOW'] = EMAIL_DETAILS_FOLLOW; $emailVars['INTRO_ORDER_NUM_TITLE'] = EMAIL_TEXT_ORDER_NUMBER; $emailVars['INTRO_ORDER_NUMBER'] = $pOrdersId; $emailVars['INTRO_DATE_TITLE'] = EMAIL_TEXT_DATE_ORDERED; $emailVars['INTRO_DATE_ORDERED'] = strftime(DATE_FORMAT_LONG); $emailVars['INTRO_URL_TEXT'] = EMAIL_TEXT_INVOICE_URL_CLICK; $emailVars['INTRO_URL_VALUE'] = zen_href_link(FILENAME_ACCOUNT_HISTORY_INFO, 'order_id=' . $pOrdersId, 'SSL', false); //comments area if (!empty($this->info['comments'])) { $email_order .= zen_db_output($this->info['comments']) . "\n\n"; $emailVars['ORDER_COMMENTS'] = zen_db_output($this->info['comments']); } else { $emailVars['ORDER_COMMENTS'] = ''; } //products area $email_order .= EMAIL_TEXT_PRODUCTS . "\n" . EMAIL_SEPARATOR . "\n"; foreach (array_keys($this->contents) as $productsKey) { $email_order .= $this->contents[$productsKey]['products_quantity'] . ' x ' . $this->contents[$productsKey]['name'] . ($this->contents[$productsKey]['model'] != '' ? ' (' . $this->contents[$productsKey]['model'] . ') ' : '') . ' = ' . $currencies->display_price($this->contents[$productsKey]['final_price'], $this->contents[$productsKey]['tax'], $this->contents[$productsKey]['products_quantity'], $this->getField('currency'), $this->getField('currency_value')) . ($this->contents[$productsKey]['onetime_charges'] != 0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->contents[$productsKey]['onetime_charges'], $this->contents[$productsKey]['tax'], 1) : ''); foreach (array_keys($this->contents[$productsKey]['attributes']) as $j) { $optionValues = zen_get_option_value((int) $this->contents[$productsKey]['attributes'][$j]['options_id'], (int) $this->contents[$productsKey]['attributes'][$j]['options_values_id']); $email_order .= "\n + " . $optionValues['products_options_name'] . ' ' . zen_decode_specialchars($this->contents[$productsKey]['attributes'][$j]['value']); } $email_order .= "\n\n"; } $email_order .= EMAIL_SEPARATOR . "\n"; $emailVars['PRODUCTS_TITLE'] = EMAIL_TEXT_PRODUCTS; if (!empty($this->products_ordered_html)) { $emailVars['PRODUCTS_DETAIL'] = '<table class="product-details" border="0" width="100%" cellspacing="0" cellpadding="2">' . $this->products_ordered_html . '</table>'; } //order totals area $html_ot = '<td class="order-totals-text alignright" width="100%">' . ' ' . '</td><td class="order-totals-num alignright" nowrap="nowrap">' . '---------' . '</td></tr><tr>'; for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) { $email_order .= strip_tags($order_totals[$i]['title']) . ' ' . strip_tags($order_totals[$i]['text']) . "\n"; $html_ot .= '<td class="order-totals-text" align="right" width="100%">' . $order_totals[$i]['title'] . '</td><td class="order-totals-num" align="right" nowrap="nowrap">' . $order_totals[$i]['text'] . '</td></tr><tr>'; } $emailVars['ORDER_TOTALS'] = '<table border="0" width="100%" cellspacing="0" cellpadding="2">' . $html_ot . '</table>'; //addresses area: Delivery $emailVars['HEADING_ADDRESS_INFORMATION'] = tra('Address Information'); $emailVars['ADDRESS_DELIVERY_TITLE'] = EMAIL_TEXT_DELIVERY_ADDRESS; $emailVars['ADDRESS_DELIVERY_DETAIL'] = $this->content_type != 'virtual' ? zen_address_label($this->customer['user_id'], $this->delivery, true, '', "<br />") : 'n/a'; $emailVars['SHIPPING_METHOD_TITLE'] = HEADING_SHIPPING_METHOD; $emailVars['SHIPPING_METHOD_DETAIL'] = zen_not_null($this->info['shipping_method']) ? $this->info['shipping_method'] : 'n/a'; if ($this->content_type != 'virtual') { $email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . zen_address_format($this->delivery['format_id'], $this->delivery, FALSE, '', "\n") . "\n\n"; } //addresses area: Billing $email_order .= "\n" . EMAIL_TEXT_BILLING_ADDRESS . "\n" . EMAIL_SEPARATOR . "\n" . zen_address_format($this->billing['format_id'], $this->billing, FALSE, '', "\n") . "\n\n"; $emailVars['ADDRESS_BILLING_TITLE'] = EMAIL_TEXT_BILLING_ADDRESS; $emailVars['ADDRESS_BILLING_DETAIL'] = zen_address_label($this->customer['user_id'], $this->billing, true, '', "<br />"); $emailVars['PAYMENT_METHOD_TITLE'] = $emailVars['PAYMENT_METHOD_DETAIL'] = $emailVars['PAYMENT_METHOD_FOOTER'] = ''; if (!empty($_SESSION['payment']) && is_object($GLOBALS[$_SESSION['payment']])) { $email_order .= EMAIL_TEXT_PAYMENT_METHOD . "\n" . EMAIL_SEPARATOR . "\n"; $payment_class = $_SESSION['payment']; $email_order .= $GLOBALS[$payment_class]->title . "\n\n"; if (!empty($GLOBALS[$payment_class]->email_footer)) { $email_order .= $GLOBALS[$payment_class]->email_footer . "\n\n"; } $emailVars['PAYMENT_METHOD_TITLE'] = EMAIL_TEXT_PAYMENT_METHOD; $emailVars['PAYMENT_METHOD_DETAIL'] = $GLOBALS[$payment_class]->title; $emailVars['PAYMENT_METHOD_FOOTER'] = !empty($GLOBALS[$payment_class]->email_footer) ? $GLOBALS[$payment_class]->email_footer : ''; } // include disclaimer $email_order .= "\n-----\n" . sprintf(EMAIL_DISCLAIMER, STORE_OWNER_EMAIL_ADDRESS) . "\n\n"; // include copyright $email_order .= "\n-----\n" . EMAIL_FOOTER_COPYRIGHT . "\n\n"; while (strstr($email_order, ' ')) { $email_order = str_replace(' ', ' ', $email_order); } $emailVars['EMAIL_FIRST_NAME'] = $this->getFirstName(); // $emailVars['EMAIL_LAST_NAME'] = $this->customer['lastname']; // $emailVars['EMAIL_TEXT_HEADER'] = EMAIL_TEXT_HEADER; $emailVars['EXTRA_INFO'] = ''; zen_mail($customerName, $pEmailRecipient, EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $pOrdersId, $email_order, STORE_NAME, EMAIL_FROM, $emailVars, 'checkout', '', $pFormat); // send additional emails if (SEND_EXTRA_ORDER_EMAILS_TO != '') { $extra_info = email_collect_extra_info('', '', $customerName, $this->customer['email_address'], $this->customer['telephone']); $emailVars['EXTRA_INFO'] = $extra_info['HTML']; zen_mail('', SEND_EXTRA_ORDER_EMAILS_TO, tra('[NEW ORDER]') . ' ' . EMAIL_TEXT_SUBJECT . EMAIL_ORDER_NUMBER_SUBJECT . $pOrdersId, $email_order . $extra_info['TEXT'], STORE_NAME, EMAIL_FROM, $emailVars, 'checkout_extra', '', $pFormat); } }