/** * getList * * @param array $pListHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function getList(&$pListHash, $pStructureId = NULL) { LibertyContent::prepGetList($pListHash); $ret = $bindVars = array(); $selectSql = $joinSql = $whereSql = ""; if (@BitBase::verifyId($pListHash['gallery_content_id'])) { $whereSql = " WHERE trm.`gallery_content_id` = ? "; $bindVars[] = $pListHash['gallery_content_id']; } if (@BitBase::verifyId($pListHash['user_id'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " lc.`user_id` = ? "; $bindVars[] = $pListHash['user_id']; } if (!empty($pListHash['title']) && is_string($pListHash['title'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " trm.`item_content_id` = lc.`content_id` AND UPPER( lc.`title` ) = ?"; $bindVars[] = strtoupper($pListHash['title']); } if (!empty($pListHash['max_age']) && is_numeric($pListHash['max_age'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " lc.`created` > ? "; $bindVars[] = $pListHash['max_age']; } if (!empty($pListHash['sort_mode'])) { $orderSql = " ORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']) . " "; } else { $orderSql = " ORDER BY trm.`item_position` ASC "; } // only join attachments table when we need it for sorting if (strstr($pListHash['sort_mode'], 'la.hits') !== FALSE) { $joinSql .= " LEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON ( la.`content_id` = lc.`content_id` ) "; } $this->getServicesSql('content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $ret = array(); $query = "\n\t\t\tSELECT\n\t\t\t\tlct.`content_name`,\n\t\t\t\tuu.`login`, uu.`real_name`,\n\t\t\t\tlc.`content_id`, lc.`last_modified`, lc.`user_id`, lc.`title`, lc.`content_type_guid`, lc.`created`, lc.`data`,\n\t\t\t\tlch.`hits` {$selectSql}\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_map` trm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trm.`item_content_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( uu.`user_id` = lc.`user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lch.`content_id` = lc.`content_id` )\n\t\t\t{$joinSql} {$whereSql} {$orderSql}"; $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); while ($aux = $result->fetchRow()) { $item = new TreasuryItem($aux['content_id']); $item->load(); $ret[] = $item; } $query = "SELECT COUNT( trm.`item_content_id` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "treasury_map` trm\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = trm.`item_content_id` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content_types` lct ON ( lc.`content_type_guid` = lct.`content_type_guid` )\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "users_users` uu ON ( uu.`user_id` = lc.`user_id` )\n\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content_hits` lch ON ( lch.`content_id` = lc.`content_id` )\n\t\t\t{$joinSql} {$whereSql}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); LibertyContent::postGetList($pListHash); return count($this->mErrors) == 0 ? $ret : FALSE; }
<?php /** * @version $Header$ * * @author xing <*****@*****.**> * @package treasury * @copyright 2003-2006 bitweaver * @license LGPL {@link http://www.gnu.org/licenses/lgpl.html} **/ /** * Setup */ global $gContent; if (!@BitBase::verifyId($_REQUEST['content_id'])) { header("Location:" . TREASURY_PKG_URL); } else { $gContent = new TreasuryItem(NULL, $_REQUEST['content_id']); $gContent->load($_REQUEST); } $gBitSmarty->assignByRef('gContent', $gContent);
/** * expunge a gallery * * @param array $pParamHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pForceDeleteItems = FALSE) { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // get all items that are part of the sub tree require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure(); $tree = $struct->getSubTree($this->mStructureId); // include the current id as well - needed when there are no sub-galleries $galleryContentIds[] = $this->mContentId; foreach ($tree as $node) { $galleryContentIds[] = $node['content_id']; } $galleryContentIds = array_unique($galleryContentIds); // Create Item Object require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $itemObject = new TreasuryItem(); // Go through all galleries we want to remove foreach ($galleryContentIds as $gid) { // make sure the gallery is fully loaded $this->mContentId = $gid; $this->load(); $itemContentIds = $this->mDb->getCol("SELECT `item_content_id` FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?", array($gid)); $itemContentIds = array_unique($itemContentIds); // Delete items in galleries foreach ($itemContentIds as $iid) { if ($pForceDeleteItems) { // Remove item even if it exists in other galleries $count = 1; } else { // Only delete item if it doesn't exist in other galleries $count = $this->mDb->getOne("SELECT COUNT( `item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `item_content_id`=?", array($iid)); } // Only delete item if it doesn't exist in other galleries if ($count == 1) { $itemObject->mContentId = $iid; $itemObject->load(); if (!$itemObject->expunge()) { $this->mErrors['expunge'][] = $itemObject->mErrors; } } } // Next, we remove any icons if they exist if ($thumbdir = $this->getGalleryThumbBaseUrl()) { @unlink_r(BIT_ROOT_PATH . $thumbdir); } // Now that all the items are gone, we can start nuking gallery entries // remove gallery preferences $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_prefs` WHERE `content_id`=?"; $result = $this->mDb->query($query, array($this->mContentId)); // Remove map entries $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Remove gallery entry $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_gallery` WHERE `content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Let liberty remove all the content entries for this gallery if (!LibertyContent::expunge()) { $errors = TRUE; } // Finally nuke the structure in liberty_structures $struct->removeStructureNode($this->mStructureId, FALSE); } if (empty($errors)) { $this->mDb->CompleteTrans(); $ret = TRUE; } else { $this->mDb->RollbackTrans(); $ret = FALSE; } } return $ret; }
function data_file($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; if (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('treasury')) { require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $item = new TreasuryItem(); $item->mContentId = $item->getContentIdFromAttachmentId($pParams['id']); if ($item->load()) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumburl = $item->getField('source_url'); } elseif ($item->getField('thumbnail_url')) { $thumburl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium']; } // check if we have a valid thumbnail if (!empty($thumburl)) { $wrapper = liberty_plugins_wrapper_style($pParams); $description = !empty($wrapper['description']) ? $wrapper['description'] : $item->getField('data', tra('Image')); // set up image first $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumburl . '"' . ' />'; if ($item->getField('file_size')) { $ret .= '<br />' . $item->getField('title') . "<br /><small>(" . $item->getField('mime_type') . " " . smarty_modifier_display_bytes($item->getField('file_size')) . ")</small>"; } if (!empty($description) && !empty($pParams['output']) && ($pParams['output'] == 'desc' || $pParams['output'] == 'description')) { $ret = $description; $nowrapper = TRUE; } else { $ret .= !empty($wrapper['description']) ? '<br />' . $wrapper['description'] : ''; } // use specified link as href. insert default link to source only when // source not already displayed if (!empty($pParams['link']) && $pParams['link'] == 'false') { } elseif (!empty($pParams['link'])) { if (strstr($pParams['link'], $_SERVER["SERVER_NAME"]) || !strstr($pParams['link'], '//')) { $class = ''; } else { $class = 'class="external"'; } $ret = '<a ' . $class . ' href="' . trim($pParams['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['download']) && $item->getField('display_url')) { $ret = '<a href="' . trim($item->getField('display_url')) . '">' . $ret . '</a>'; } elseif (!empty($pParams['download']) && ($pParams['download'] = 'direct')) { $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>'; } elseif (!empty($pParams['download']) && $item->getField('download_url')) { $ret = '<a href="' . trim($item->getField('download_url')) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { $ret = '<a href="' . trim($item->getField('source_url')) . '">' . $ret . '</a>'; } // finally, wrap the output. if (empty($nowrapper)) { $ret = '<!-- ~np~ --><' . $wrapper['wrapper'] . ' class="' . (isset($wrapper) && !empty($wrapper['class']) ? $wrapper['class'] : "att-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . '</' . $wrapper['wrapper'] . '><!-- ~/np~ -->'; } } else { $ret = tra("There was a problem getting an image for the file."); } } else { $ret = tra("The attachment id given is not valid."); } } else { $ret = tra("The attachment id given is not valid."); } return $ret; }
$galleryItem->load(); $title = $galleryItem->getTitle(); if ($galleryItem->expunge()) { $feedback['success'] .= "<li>{$title}</li>"; } } } } if (!empty($feedback['success'])) { $feedback['success'] = tra('The following items were successfully deleted') . ':<ul>' . $feedback['success'] . '</ul>'; } } else { $gBitSystem->setBrowserTitle('Confirm removal of ' . $gContent->mInfo['title']); foreach ($_REQUEST['del_content_ids'] as $cid) { $item = new TreasuryItem(NULL, $cid); $itemInfo = $item->load(); $formHash['input'][] = '<input type="hidden" name="del_content_ids[]" value="' . $cid . '"/>' . "<strong>{$item->mInfo['title']}</strong> - {$item->mInfo['mime_type']} - {$item->mInfo['file_size']} bytes"; } $formHash['action'] = 'remove'; $formHash['structure_id'] = $_REQUEST['structure_id']; $msgHash = array('label' => tra('Remove Files'), 'warning' => tra('This will permanently remove these files.')); $gBitSystem->confirmDialog($formHash, $msgHash); } } // used to display the newly updated version of an image if (!empty($_REQUEST['refresh'])) { $gBitSmarty->assign('refresh', '?refresh=' . time()); } // services $displayHash = array('perm_name' => 'p_treasury_view_gallery'); $gContent->invokeServices('content_display_function', $displayHash);