本文整理汇总了PHP中ModUtil::dbInfoLoad方法的典型用法代码示例。如果您正苦于以下问题:PHP ModUtil::dbInfoLoad方法的具体用法?PHP ModUtil::dbInfoLoad怎么用?PHP ModUtil::dbInfoLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModUtil
的用法示例。
在下文中一共展示了ModUtil::dbInfoLoad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Search
*
* do the actual search and display the results
*
* @return output the search results
*/
public function search($args)
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
return true;
}
$minlen = 3;
$maxlen = 30;
if (strlen($args['q']) < $minlen || strlen($args['q']) > $maxlen) {
return LogUtil::registerStatus($this->__f('The comments can only be searched for words that are longer than %1$s and less than %2$s characters!', array($minlen, $maxlen)));
}
ModUtil::dbInfoLoad('Search');
$tables = DBUtil::getTables();
// ezcomments tables
$ezcommentstable = $tables['EZComments'];
$ezcommentscolumn = $tables['EZComments_column'];
// our own tables
$searchTable = $tables['search_result'];
$searchColumn = $tables['search_result_column'];
// where
$where = Search_Api_User::construct_where($args, array($ezcommentscolumn['subject'], $ezcommentscolumn['comment']));
$where .= " AND " . $ezcommentscolumn['url'] . " != ''";
$sessionId = session_id();
$insertSql = "INSERT INTO {$searchTable}\n ({$searchColumn['title']},\n {$searchColumn['text']},\n {$searchColumn['extra']},\n {$searchColumn['module']},\n {$searchColumn['created']},\n {$searchColumn['session']})\n VALUES\n ";
$comments = DBUtil::selectObjectArray('EZComments', $where);
foreach ($comments as $comment) {
$sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($comment['subject']) . '\', ' . '\'' . DataUtil::formatForStore($comment['comment']) . '\', ' . '\'' . DataUtil::formatForStore($comment['url']) . '\', ' . '\'' . 'EZComments' . '\', ' . '\'' . DataUtil::formatForStore($comment['date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
}
return true;
}
示例2: search
/**
* Performs the actual search processing.
*/
public function search($args)
{
ModUtil::dbInfoLoad('Search');
$dbtables = DBUtil::getTables();
$pageTable = $dbtables['content_page'];
$pageColumn = $dbtables['content_page_column'];
$contentTable = $dbtables['content_content'];
$contentColumn = $dbtables['content_content_column'];
$contentSearchTable = $dbtables['content_searchable'];
$contentSearchColumn = $dbtables['content_searchable_column'];
$translatedPageTable = $dbtables['content_translatedpage'];
$translatedPageColumn = $dbtables['content_translatedpage_column'];
$sessionId = session_id();
// check whether we need to search also in translated content
$multilingual = System::getVar('multilingual');
$currentLanguage = ZLanguage::getLanguageCode();
$searchWhereClauses = array();
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')';
if ($multilingual) {
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')';
}
$searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')';
// add default filters
$whereClauses = array();
$whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')';
$whereClauses[] = $pageColumn['active'] . ' = 1';
$whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())";
$whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())";
$whereClauses[] = $contentColumn['active'] . ' = 1';
$whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1');
$titleFields = $pageColumn['title'];
$additionalJoins = '';
if ($multilingual) {
// if searching in non-default languages, we need the translated title
$titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle';
// join also the translation table if required
$additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'";
// prevent content snippets in other languages
$whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\'';
}
$where = implode(' AND ', $whereClauses);
$sql = "\n SELECT DISTINCT {$titleFields},\n {$contentSearchColumn['text']} AS description,\n {$pageColumn['id']} AS pageId,\n {$pageColumn['cr_date']} AS createdDate\n FROM {$pageTable}\n JOIN {$contentTable}\n ON {$contentColumn['pageId']} = {$pageColumn['id']}\n JOIN {$contentSearchTable}\n ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n {$additionalJoins}\n WHERE {$where}\n ";
$result = DBUtil::executeSQL($sql);
if (!$result) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
$objectArray = DBUtil::marshallObjects($result);
foreach ($objectArray as $object) {
$pageTitle = $object['page_title'];
if ($object['translatedTitle'] != '') {
$pageTitle = $object['translatedTitle'];
}
$searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId);
if (!\DBUtil::insertObject($searchItemData, 'search_result')) {
return \LogUtil::registerError($this->__('Error! Could not save the search results.'));
}
}
return true;
}
示例3: search
/**
* Search plugin main function
**/
public function search($args)
{
if (!SecurityUtil::checkPermission('Feeds::', '::', ACCESS_READ)) {
return true;
}
ModUtil::dbInfoLoad('Search');
$pntable = DBUtil::getTables();
$feedscolumn = $pntable['feeds_column'];
$searchTable = $pntable['search_result'];
$searchColumn = $pntable['search_result_column'];
$where = search_construct_where($args,
array($feedscolumn['name']),
null);
$sessionId = session_id();
// define the permission filter to apply
$permFilter = array(array('realm' => 0,
'component_left' => 'Feeds',
'instance_left' => 'fid',
'instance_right' => '',
'level' => ACCESS_READ));
// get the result set
$objArray = DBUtil::selectObjectArray('feeds', $where, 'fid', 1, -1, '', $permFilter);
if ($objArray === false) {
return LogUtil::registerError($this->__('Error! Could not load items.'));
}
$insertSql =
"INSERT INTO $searchTable
($searchColumn[title],
$searchColumn[text],
$searchColumn[extra],
$searchColumn[created],
$searchColumn[module],
$searchColumn[session])
VALUES ";
// Process the result set and insert into search result table
foreach ($objArray as $obj) {
$sql = $insertSql . '('
. '\'' . DataUtil::formatForStore($obj['name']) . '\', '
. '\'' . '\', '
. '\'' . DataUtil::formatForStore($obj['fid']) . '\', '
. '\'' . DataUtil::formatForStore($obj['cr_date']) . '\', '
. '\'' . 'Feeds' . '\', '
. '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError(__('Error! Could not load items.', $dom));
}
}
return true;
}
示例4: smarty_function_selectmodobject
/**
* render plugin for fetching a particular module object
*
* Examples
* {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
* {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
* {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
*
* Parameters:
* module Name of the module storing the desired object (in DBObject mode)
* objecttype Name of object type (in DBObject mode)
* recordClass Class name of an doctrine record. (in Doctrine mode)
* id Identifier of desired object
* prefix Optional prefix for class names (defaults to PN) (in DBObject mode)
* assign Name of the returned object
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_selectmodobject($params, Zikula_View $view)
{
if (isset($params['recordClass']) && !empty($params['recordClass'])) {
$doctrineMode = true;
} else {
// DBObject checks
if (!isset($params['module']) || empty($params['module'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
}
if (!isset($params['objecttype']) || empty($params['objecttype'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
}
if (!isset($params['prefix'])) {
$params['prefix'] = 'PN';
}
$doctrineMode = false;
}
if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
}
if (!isset($params['assign']) || empty($params['assign'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
}
// load object depending on mode: doctrine or dbobject
if (!$doctrineMode) {
if (!ModUtil::available($params['module'])) {
$view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
}
ModUtil::dbInfoLoad($params['module']);
$classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
if (!class_exists($classname) && System::isLegacyMode()) {
// BC check for PNObject old style.
// load the object class corresponding to $params['objecttype']
if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) {
z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module']))));
}
}
// intantiate object model
$object = new $class();
$idField = $object->getIDField();
// assign object data
// this performs a new database select operation
// while the result will be saved within the object, we assign it to a local variable for convenience
$objectData = $object->get(intval($params['id']), $idField);
if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
$objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
if ($objectData === false) {
$view->trigger_error(__('Sorry! No such item found.'));
}
}
$view->assign($params['assign'], $objectData);
}
示例5: smarty_function_selectmodobject
/**
* render plugin for fetching a particular module object
*
* Examples
* {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
* {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
* {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
*
* Parameters:
* module Name of the module storing the desired object (in DBObject mode)
* objecttype Name of object type (in DBObject mode)
* recordClass Class name of an doctrine record. (in Doctrine mode)
* id Identifier of desired object
* prefix Optional prefix for class names (defaults to PN) (in DBObject mode)
* assign Name of the returned object
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_selectmodobject($params, Zikula_View $view)
{
if (isset($params['recordClass']) && !empty($params['recordClass'])) {
$doctrineMode = true;
} else {
// DBObject checks
if (!isset($params['module']) || empty($params['module'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
}
if (!isset($params['objecttype']) || empty($params['objecttype'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
}
if (!isset($params['prefix'])) {
$params['prefix'] = 'PN';
}
$doctrineMode = false;
}
if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
}
if (!isset($params['assign']) || empty($params['assign'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
}
// load object depending on mode: doctrine or dbobject
if (!$doctrineMode) {
if (!ModUtil::available($params['module'])) {
$view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
}
ModUtil::dbInfoLoad($params['module']);
$class = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
// intantiate object model
$object = new $class();
$idField = $object->getIDField();
// assign object data
// this performs a new database select operation
// while the result will be saved within the object, we assign it to a local variable for convenience
$objectData = $object->get(intval($params['id']), $idField);
if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
if ($params['recordClass'] instanceof \Doctrine_Record) {
$objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
if ($objectData === false) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
/** @var $em Doctrine\ORM\EntityManager */
$em = \ServiceUtil::get('doctrine.entitymanager');
$result = $em->getRepository($params['recordClass'])->find($params['id']);
$objectData = $result->toArray();
}
}
$view->assign($params['assign'], $objectData);
}
示例6: getContent
public function getContent()
{
ModUtil::dbInfoLoad('Content');
$dbtables = DBUtil::getTables();
$query = "SELECT " . $dbtables['content_page_column']['id'] . " , " . $dbtables['content_page_column']['title'] . ", " . $dbtables['content_page_column']['views'] . " \n \tFROM " . $dbtables['content_page'] . "\n\tWHERE " . $dbtables['content_page_column']['views'] . " >= 0 AND " . $dbtables['content_page_column']['active'] . " >= 0 ORDER BY " . $dbtables['content_page_column']['views'] . " DESC LIMIT 25";
$dbresult = DBUtil::executeSQL($query);
$views = DBUtil::marshallObjects($dbresult);
$view = Zikula_View::getInstance('Content');
$view->assign('views', $views);
return $view->fetch('content_widget_top25.tpl');
}
示例7: hookAreaDelete
/**
* Listener for installer.subscriberarea.uninstalled
*
* @param Zikula_Event $event
*
* @return void
*/
public static function hookAreaDelete(Zikula_Event $event)
{
$areaId = $event['areaid'];
// Database information
ModUtil::dbInfoLoad('EZComments');
$tables = DBUtil::getTables();
$columns = $tables['EZComments_column'];
// Get items
$where = "WHERE {$columns['areaid']} = '" . DataUtil::formatForStore($areaId) . "'";
DBUtil::deleteWhere('EZComments', $where);
}
示例8: pendingContent
public static function pendingContent(Zikula_Event $event)
{
$dom = ZLanguage::getModuleDomain('News');
ModUtil::dbInfoLoad('News');
$dbtables = DBUtil::getTables();
$columns = $dbtables['news_column'];
$count = DBUtil::selectObjectCount('news', "WHERE $columns[published_status]=2");
if ($count > 0) {
$collection = new Zikula_Collection_Container('News');
$collection->add(new Zikula_Provider_AggregateItem('submission', _n('News article', 'News articles', $count, $dom), $count, 'admin', 'view', array('news_status'=>2)));
$event->getSubject()->add($collection);
}
}
示例9: search
/**
* Search plugin main function
**/
public function search($args)
{
ModUtil::dbInfoLoad('Search');
$dbtables = DBUtil::getTables();
$searchTable = $dbtables['search_result'];
$searchColumn = $dbtables['search_result_column'];
$pageTable = $dbtables['content_page'];
$pageColumn = $dbtables['content_page_column'];
$contentTable = $dbtables['content_content'];
$contentColumn = $dbtables['content_content_column'];
$contentSearchTable = $dbtables['content_searchable'];
$contentSearchColumn = $dbtables['content_searchable_column'];
$sessionId = session_id();
$where = Search_Api_User::construct_where($args,
array($contentSearchColumn['text']), null);
$wheretitle = Search_Api_User::construct_where($args,
array($pageColumn['title']), $pageColumn['language']);
// Direct SQL way of searching in titles and searchable content items
// for Pages and Content items that are visible/active
// Optimization and conversion into DBUtil calls should be done
$sql = "INSERT INTO $searchTable
($searchColumn[title],
$searchColumn[text],
$searchColumn[module],
$searchColumn[extra],
$searchColumn[created],
$searchColumn[session])
SELECT DISTINCT $pageColumn[title],
$contentSearchColumn[text],
'Content',
$pageColumn[id],
$pageColumn[cr_date] AS createdDate,
'" . DataUtil::formatForStore($sessionId) . "'
FROM $pageTable
JOIN $contentTable
ON $contentColumn[pageId] = $pageColumn[id]
JOIN $contentSearchTable
ON $contentSearchColumn[contentId] = $contentColumn[id]
WHERE ($where or $wheretitle) AND $pageColumn[active] = 1 AND ($pageColumn[activeFrom] IS NULL OR $pageColumn[activeFrom] <= NOW()) AND ($pageColumn[activeTo] IS NULL OR $pageColumn[activeTo] >= NOW()) AND $contentColumn[active] = 1 AND $contentColumn[visiblefor] " . (UserUtil::isLoggedIn() ? '<=1' : '>=1');
$dbresult = DBUtil::executeSQL($sql);
if (!$dbresult) {
return LogUtil::registerError($this->__('Error! Could not load any Content pages or items.'));
}
return true;
}
示例10: search
/**
* Search plugin main function
**/
public function search($args)
{
if (!SecurityUtil::checkPermission('News::', '::', ACCESS_READ)) {
return true;
}
ModUtil::dbInfoLoad('Search');
$tables = DBUtil::getTables();
$newsColumn = $tables['news_column'];
$where = Search_Api_User::construct_where($args,
array($newsColumn['title'],
$newsColumn['hometext'],
$newsColumn['bodytext']),
$newsColumn['language']);
// Only search in published articles that are currently visible
$where .= " AND ({$newsColumn['published_status']} = '0')";
$date = DateUtil::getDatetime();
$where .= " AND ('$date' >= {$newsColumn['from']} AND ({$newsColumn['to']} IS NULL OR '$date' <= {$newsColumn['to']}))";
$sessionId = session_id();
ModUtil::loadApi('News', 'user');
$permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
$articles = DBUtil::selectObjectArrayFilter('news', $where, null, null, null, '', $permChecker, null);
foreach ($articles as $article)
{
$item = array(
'title' => $article['title'],
'text' => $article['hometext'],
'extra' => $article['sid'],
'created' => $article['from'],
'module' => 'News',
'session' => $sessionId
);
$insertResult = DBUtil::insertObject($item, 'search_result');
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load any articles.'));
}
}
return true;
}
示例11: EZComments_migrateapi_pnComments
/**
* Do the migration
*
* With this function, the actual migration is done.
*
* @return boolean true on sucessful migration, false else
*/
function EZComments_migrateapi_pnComments()
{
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
if (!ModUtil::available('pnComments')) {
return LogUtil::RegisterError('pnComments not available');
}
ModUtil::dbInfoLoad('pnComments');
$comments = DBUtil::SelectObjectArray('pncomments');
$counter = 0;
foreach ($comments as $c) {
$obj = array('modname' => $c['module'], 'objectid' => $c['objectid'], 'comment' => $c['text'], 'replyto' => -1, 'subject' => $c['subject'], 'uid' => $c['uid'], 'date' => $c['date'] . ' 00:00:00');
if (!DBUtil::insertObject($obj, 'EZComments')) {
return LogUtil::registerError('error inserting comments in ezcomments table');
}
$counter++;
}
return LogUtil::registerStatus("Migrated: {$counter} comments successfully.");
}
示例12: EZComments_migrateapi_reviews
/**
* Do the migration
*
* With this function, the actual migration is done.
*
* @return boolean true on sucessful migration, false else
* @since 0.6
*/
function EZComments_migrateapi_reviews()
{
// Security check
if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
return LogUtil::registerError('Reviews migration: Not Admin');
}
// Get datbase setup
ModUtil::dbInfoLoad('Reviews', 'EZComments/migrateapi/Reviews', true);
$tables = DBUtil::getTables();
$Commentstable = $tables['reviews_comments'];
$Commentscolumn = $tables['reviews_comments_column'];
if (version_compare(PN_VERSION_NUM, '1', '>=')) {
EZComments_get76xcolumns_reviews($Commentstable, $Commentscolumn);
}
if (is_null($Commentstable) || is_null($Commentscolumn)) {
return LogUtil::registerError('Reviews migration: Comments tables not found');
}
$Usertable = $tables['users'];
$Usercolumn = $tables['users_column'];
// note: there's nothing we can do with the score......
$sql = "SELECT {$Commentscolumn['cid']},\n {$Commentscolumn['rid']},\n {$Commentscolumn['date']}, \n {$Usercolumn['uid']}, \n {$Commentscolumn['comments']},\n {$Commentscolumn['score']}\n FROM {$Commentstable}\n LEFT JOIN {$Usertable}\n ON {$Commentscolumn['userid']} = {$Usercolumn['uname']}";
$result = DBUtil::executeSQL($sql);
if ($result == false) {
return LogUtil::registerError('Reviews migration: DB Error');
}
// loop through the old comments and insert them one by one into the DB
$items = DBUtil::marshalObjects($result, array('cid', 'rid', 'date', 'uid', 'comment', 'score'));
foreach ($items as $item) {
// set the correct user id for anonymous users
if (empty($item['uid'])) {
$item['uid'] = 1;
}
$id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'Reviews', 'objectid' => DataUtil::formatForStore($item['rid']), 'url' => ModUtil::url('Reviews', 'user', 'display', array('id' => $item['rid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date']));
if (!$id) {
return LogUtil::registerError('Reviews migration: Error creating comment');
}
}
// activate the ezcomments hook for the Reviews module
ModUtil::apiFunc('Modules', 'admin', 'enablehooks', array('callermodname' => 'Reviews', 'hookmodname' => 'EZComments'));
return LogUtil::registerStatus('Reviews migration successful');
}
示例13: Admin_Messages_searchapi_search
/**
* Get all admin messages items that match the criteria
*
* @author Mark West, Jorn Wildt
* @param bool args['activeonly'] only show active items
* @return bool true/false on success/failure
*/
function Admin_Messages_searchapi_search($args)
{
$dom = ZLanguage::getModuleDomain('Admin_Messages');
// Security check
if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_READ)) {
return true;
}
// get the db and table info
ModUtil::dbInfoLoad('Search');
$pntable = DBUtil::getTables();
$messagestable = $pntable['message'];
$messagescolumn = $pntable['message_column'];
$searchTable =& $pntable['search_result'];
$searchColumn =& $pntable['search_result_column'];
// form the where clause
$where = '';
if (!ModUtil::getVar('Admin_Messages', 'allowsearchinactive') || isset($args['activeonly']) && (bool) $args['activeonly']) {
$where .= " {$messagescolumn['active']} = 1 AND ";
}
$where .= " ({$messagescolumn['date']}+{$messagescolumn['expire']} > '" . time() . "' OR {$messagescolumn['expire']} = 0) AND";
$where .= search_construct_where($args, array($messagescolumn['title'], $messagescolumn['content']), $messagescolumn['language']);
$sessionId = session_id();
$sql = "\nSELECT\n {$messagescolumn['mid']} as mid,\n {$messagescolumn['title']} as title,\n {$messagescolumn['content']} as text,\n {$messagescolumn['date']} as date\nFROM {$messagestable}\nWHERE {$where}";
$result = DBUtil::executeSQL($sql);
if (!$result) {
return LogUtil::registerError(__('Error! Could not load data.'));
}
$insertSql = "INSERT INTO {$searchTable}\n ({$searchColumn['title']},\n {$searchColumn['text']},\n {$searchColumn['module']},\n {$searchColumn['created']},\n {$searchColumn['session']})\nVALUES ";
// Process the result set and insert into search result table
for (; !$result->EOF; $result->MoveNext()) {
$message = $result->GetRowAssoc(2);
if (SecurityUtil::checkPermission('Admin_Messages::', "{$message['title']}::{$message['mid']}", ACCESS_READ)) {
$sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($message['title']) . '\', ' . '\'' . DataUtil::formatForStore($message['text']) . '\', ' . '\'' . 'Admin_Messages' . '\', ' . '\'' . DataUtil::formatForStore(DateUtil::getDatetime($message['date'])) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
$insertResult = DBUtil::executeSQL($sql);
if (!$insertResult) {
return LogUtil::registerError(__('Error! Could not load data.', $dom));
}
}
}
return true;
}
示例14: getUsers
/**
* Performs a user search based on the user name fragment entered so far.
*
* Parameters passed via POST:
* ---------------------------
* string fragment A partial user name entered by the user.
*
* @return string Zikula_Response_Ajax_Plain with list of users matching the criteria.
*/
public function getUsers()
{
$this->checkAjaxToken();
$view = Zikula_View::getInstance($this->name);
if (SecurityUtil::checkPermission('Users::', '::', ACCESS_MODERATE)) {
$fragment = $this->request->query->get('fragment', $this->request->request->get('fragment'));
ModUtil::dbInfoLoad($this->name);
$tables = DBUtil::getTables();
$usersColumn = $tables['users_column'];
$where = 'WHERE ' . $usersColumn['uname'] . ' REGEXP \'(' . DataUtil::formatForStore($fragment) . ')\'';
$results = DBUtil::selectObjectArray('users', $where);
$view->assign('results', $results);
}
$output = $view->fetch('users_ajax_getusers.tpl');
return new Zikula_Response_Ajax_Plain($output);
}
示例15: getContent
public function getContent()
{
ModUtil::dbInfoLoad('EZComments');
$dbtables = DBUtil::getTables();
$query = "SELECT " . $dbtables['EZComments_column']['date'] . " , DATE_FORMAT( " . $dbtables['EZComments_column']['date'] . ", '%Y-%m-%d' ) AS dateval, COUNT( DATE_FORMAT( " . $dbtables['EZComments_column']['date'] . ", '%Y-%m-%d' ) ) AS datetotal \n \tFROM " . $dbtables['EZComments'] . "\n\tWHERE " . $dbtables['EZComments_column']['date'] . " >= ( CURDATE( ) - INTERVAL 1 MONTH ) GROUP BY dateval ORDER BY " . $dbtables['EZComments_column']['date'] . " ASC";
$dbresult = DBUtil::executeSQL($query);
$results = DBUtil::marshallObjects($dbresult);
foreach ($results as $key => $result) {
$comments[$result['dateval']] = $result['datetotal'];
}
$date = new DateTime();
$date->sub(new DateInterval('P30D'));
for ($i = 0; $i < 30; $i++) {
$date->add(new DateInterval('P1D'));
if (isset($comments[$date->format('Y-m-d')])) {
$days[$date->format('Y-m-d')] = $comments[$date->format('Y-m-d')];
} else {
$days[$date->format('Y-m-d')] = 0;
}
}
$view = Zikula_View::getInstance('EZComments');
$view->assign('days', $days);
return $view->fetch('ezcomments_widget_month.tpl');
}