当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::getTables方法代码示例

本文整理汇总了PHP中DBUtil::getTables方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::getTables方法的具体用法?PHP DBUtil::getTables怎么用?PHP DBUtil::getTables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil::getTables方法的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;
 }
开发者ID:rmaiwald,项目名称:EZComments,代码行数:40,代码来源:Search.php

示例2: install

 public function install()
 {
     if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     // set content of the files .htaccess and .locked
     $htaccessContent = "# Avoid direct web access to folder files\r\nOrder deny,allow\r\nDeny from all\r\n";
     $lockedContent = "# Avoid direct web access with the file file.php\r\n";
     // Create module table
     if (!DBUtil::createTable('Files')) {
         return false;
     }
     //Create indexes
     $pntable = DBUtil::getTables();
     $c = $pntable['Files_column'];
     DBUtil::createIndex($c['userId'], 'Files', 'userId');
     // create security files
     FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.htaccess', $htaccessContent, true);
     FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/.locked', $lockedContent, true);
     FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.htaccess', $htaccessContent, true);
     FileUtil::writeFile(ModUtil::getVar('Files', 'folderPath') . '/' . ModUtil::getVar('Files', 'usersFolder') . '/.locked', $lockedContent, true);
     //Create module vars
     ModUtil::setVar('Files', 'showHideFiles', '0');
     ModUtil::setVar('Files', 'allowedExtensions', 'gif,png,jpg,odt,doc,pdf,zip');
     ModUtil::setVar('Files', 'defaultQuota', 1);
     ModUtil::setVar('Files', 'groupsQuota', 's:0:"";');
     ModUtil::setVar('Files', 'filesMaxSize', '1000000');
     ModUtil::setVar('Files', 'maxWidth', '250');
     ModUtil::setVar('Files', 'maxHeight', '250');
     ModUtil::setVar('Files', 'editableExtensions', 'php,htm,html,htaccess,css,js,tpl');
     // Set up module hook
     ModUtil::registerHook('item', 'display', 'GUI', 'Files', 'user', 'Files');
     return true;
 }
开发者ID:hardtoneselector,项目名称:Files,代码行数:34,代码来源:Installer.php

示例3: display

 function display()
 {
     $prevpage = null;
     $nextpage = null;
     $page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId));
     $tables = DBUtil::getTables();
     $pageTable = $tables['content_page'];
     $pageColumn = $tables['content_page_column'];
     $options = array('makeTree' => true);
     $options['orderBy'] = 'position';
     $options['orderDir'] = 'desc';
     $options['pageSize'] = 1;
     $options['filter']['superParentId'] = $page['parentPageId'];
     if ($page['position'] > 0) {
         $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} < {$page['position']}";
         $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
         if (count($pages) > 0) {
             $prevpage = $pages[0];
         }
     }
     if (isset($page['position']) && $page['position'] >= 0) {
         $options['orderDir'] = 'asc';
         $options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} > {$page['position']}";
         $pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
         if (count($pages) > 0) {
             $nextpage = $pages[0];
         }
     }
     $this->view->assign('loggedin', UserUtil::isLoggedIn());
     $this->view->assign('prevpage', $prevpage);
     $this->view->assign('nextpage', $nextpage);
     return $this->view->fetch($this->getTemplate());
 }
开发者ID:robbrandt,项目名称:Content,代码行数:33,代码来源:PageNavigation.php

示例4: getModuleConfig

 public function getModuleConfig($args)
 {
     if (!isset($args['modulename'])) {
         $args['modulename'] = ModUtil::getName();
     }
     $modconfig = array();
     if ($args['modulename'] == 'list') {
         $modconfig = DBUtil::selectObjectArray('scribite', '', 'modname');
     } else {
         $dbtables = DBUtil::getTables();
         $scribitecolumn = $dbtables['scribite_column'];
         $where = "{$scribitecolumn['modname']} = '" . $args['modulename'] . "'";
         $item = DBUtil::selectObjectArray('scribite', $where);
         if ($item == false) {
             return;
         }
         $modconfig['mid'] = $item[0]['mid'];
         $modconfig['modulename'] = $item[0]['modname'];
         if (!is_int($item[0]['modfuncs'])) {
             $modconfig['modfuncs'] = unserialize($item[0]['modfuncs']);
         }
         if (!is_int($item[0]['modareas'])) {
             $modconfig['modareas'] = unserialize($item[0]['modareas']);
         }
         $modconfig['modeditor'] = $item[0]['modeditor'];
     }
     return $modconfig;
 }
开发者ID:rmaiwald,项目名称:Scribite,代码行数:28,代码来源:User.php

示例5: EZComments_migrateapi_pnFlashGames

/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.2
 */
function EZComments_migrateapi_pnFlashGames()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('pnFlashGames comments migration: Not Admin');
    }
    // Get datbase setup
    $tables = DBUtil::getTables();
    $Commentstable = $tables['pnFlashGames_comments'];
    $Commentscolumn = $tables['pnFlashGames_comments_column'];
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    $sql = "SELECT {$Commentscolumn['gid']},\n                   {$Commentscolumn['uname']},\n                   {$Commentscolumn['date']},\n                   {$Commentscolumn['comment']},\n                   {$Usercolumn['uid']}\n             FROM  {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['uname']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('pnFlashGames migration: DB Error: ' . $sql . ' -- ' . mysql_error());
    }
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('gid', 'uname', 'date', 'comment', 'uid'));
    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' => 'pnFlashGames', 'objectid' => DataUtil::formatForStore($item['gid']), 'url' => ModUtil::url('pnFlashGames', 'user', 'display', array('id' => $item['gid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('pnFlashGames migration: Error creating comment');
        }
    }
    return LogUtil::registerStatus('pnFlashGames migration successful');
}
开发者ID:rmaiwald,项目名称:EZComments,代码行数:39,代码来源:pnFlashGames.php

示例6: upgrade

    /**
     * Update the IWdocmanager module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {
        $table = DBUtil::getTables();
        switch ($oldversion) {
            case '0.0.1';
                $table = DBUtil::getTables();
                $c = $table['IWdocmanager_column'];
                $c1 = $table['IWdocmanager_categories_column'];
                // used in agora module upgrade in order to calc the number of document in each category
                $categories = DBUtil::selectObjectArray('IWdocmanager_categories', '', '', '-1', '-1', 'categoryId');
                foreach ($categories as $category) {
                    $where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 1 AND $c[versioned] <= 0";
                    $number = DBUtil::selectObjectCount('IWdocmanager', $where);

                    $where = "$c[categoryId] = $category[categoryId] AND $c[validated] = 0 AND $c[versioned] <= 0";
                    $number1 = DBUtil::selectObjectCount('IWdocmanager', $where);
                    
                    $where = "$c1[categoryId] = $category[categoryId]";
                    $item = array('nDocuments' => $number,
                        'nDocumentsNV' => $number1
                    );

                    DBUtil::updateObject($item, 'IWdocmanager_categories', $where);
                }
            case '1.0.0':
            // future versions
        }
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:33,代码来源:Installer.php

示例7: Install

    public function Install() {
        // Checks if module IWmain is installed. If not returns error
        $modid = ModUtil::getIdFromName('IWmain');
        $modinfo = ModUtil::getInfo($modid);

        if ($modinfo['state'] != 3) {
            return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module before installing it.'));
        }

        // Check if the version needed is correct
        $versionNeeded = '2.0';
        if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
            return false;
        }

        // create module tables
        $tables = array('IWstats', 'IWstats_summary');
        foreach ($tables as $table) {
            if (!DBUtil::createTable($table)) {
                return false;
            }
        }

        // create several indexes for IWstats table
        $table = DBUtil::getTables();
        $c = $table['IWstats_column'];
        if (!DBUtil::createIndex($c['moduleid'], 'IWstats', 'moduleid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['uid'], 'IWstats', 'uid')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ip'], 'IWstats', 'ip')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipForward'], 'IWstats', 'ipForward')) {
            return false;
        }
        if (!DBUtil::createIndex($c['ipClient'], 'IWstats', 'ipClient')) {
            return false;
        }
        if (!DBUtil::createIndex($c['userAgent'], 'IWstats', 'userAgent')) {
            return false;
        }
        if (!DBUtil::createIndex($c['isadmin'], 'IWstats', 'isadmin')) {
            return false;
        }

        // Set up config variables
        $this->setVar('skippedIps', '')
                ->setVar('modulesSkipped', '')
                ->setVar('deleteFromDays', 90)
                ->setVar('keepDays', 90);

        // create the system init hook
        EventUtil::registerPersistentModuleHandler('IWstats', 'core.postinit', array('IWstats_Listeners', 'coreinit'));

        // Initialisation successful
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:60,代码来源:Installer.php

示例8: 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;
 }
开发者ID:robbrandt,项目名称:Content,代码行数:62,代码来源:Search.php

示例9: userOnline

 /**
  * @param int args[uid]     userid
  */
 public function userOnline($args)
 {
     $uid = $args['uid'];
     $tables = DBUtil::getTables();
     $columns = $tables['session_info_column'];
     $where = "{$columns['uid']} = '" . DataUtil::formatForStore($uid) . "'";
     return DBUtil::selectObject('session_info', $where);
 }
开发者ID:rmaiwald,项目名称:MUBoard,代码行数:11,代码来源:Selection.php

示例10: 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;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:61,代码来源:Search.php

示例11: display

    /**
     * Display the output of the online block.
     *
     * @param array $blockinfo A blockinfo structure.
     *
     * @todo Move sql queries to calls to relevant API's.
     *
     * @return string|void The output.
     */
    public function display($blockinfo)
    {
        if (!SecurityUtil::checkPermission('Onlineblock::', $blockinfo['bid'].'::', ACCESS_READ)) {
            return;
        }

        if ($this->view->getCaching()) {
            // Here we use the user id as the cache id since the block shows user based
            // information; username and number of private messages.
            $uid = UserUtil::getVar('uid');
            $cacheid = $blockinfo['bkey'].'/bid'.$blockinfo['bid'].'/'.($uid ? $uid : 'guest');
            // We use an individual cache with a lifetime specified on the block configuration.
            $this->view->setCaching(Zikula_View::CACHE_INDIVIDUAL)
                       ->setCacheLifetime($blockinfo['refresh'])
                       ->setCacheId($cacheid);

            // check out if the contents are cached.
            // If this is the case, we do not need to make DB queries.
            if ($this->view->is_cached('users_block_online.tpl')) {
                $blockinfo['content'] = $this->view->fetch('users_block_online.tpl');

                return BlockUtil::themeBlock($blockinfo);
            }
        }

        $table = DBUtil::getTables();

        $sessioninfocolumn = $table['session_info_column'];
        $activetime = strftime('%Y-%m-%d %H:%M:%S', time() - (System::getVar('secinactivemins') * 60));

        $where = "WHERE $sessioninfocolumn[lastused] > '$activetime' AND $sessioninfocolumn[uid] > 0";
        $numusers = DBUtil::selectObjectCount('session_info', $where, 'uid', true);

        $where = "WHERE $sessioninfocolumn[lastused] > '$activetime' AND $sessioninfocolumn[uid] = '0'";
        $numguests = DBUtil::selectObjectCount('session_info', $where, 'ipaddr', true);

        $msgmodule = System::getVar('messagemodule', '');

        if ($msgmodule && SecurityUtil::checkPermission($msgmodule.'::', '::', ACCESS_READ) && UserUtil::isLoggedIn()) {
            // check if message module is available and add the necessary info
            if (ModUtil::available($msgmodule)) {
                $this->view->assign('messages', ModUtil::apiFunc($msgmodule, 'user', 'getmessagecount'));
            } else {
                $this->view->assign('messages', array());
            }
        }

        $this->view->assign('registerallowed', $this->getVar('reg_allowreg'))
                   ->assign('userscount', $numusers)
                   ->assign('guestcount', $numguests)
                   ->assign('msgmodule', $msgmodule);

        $blockinfo['content'] = $this->view->fetch('users_block_online.tpl');

        return BlockUtil::themeBlock($blockinfo);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:65,代码来源:Online.php

示例12: 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');
 }
开发者ID:robbrandt,项目名称:Dashboard,代码行数:11,代码来源:Top25.php

示例13: 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);
 }
开发者ID:rmaiwald,项目名称:EZComments,代码行数:18,代码来源:EventHandlers.php

示例14: EZComments_migrateapi_news

/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.2
 */
function EZComments_migrateapi_news()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('News migration: Not Admin');
    }
    // Get datbase setup
    $tables = DBUtil::getTables();
    $EZCommentstable = $tables['EZComments'];
    $EZCommentscolumn = $tables['EZComments_column'];
    $Commentstable = $tables['comments'];
    $Commentscolumn = $tables['comments_column'];
    if (version_compare(PN_VERSION_NUM, '1', '>=')) {
        EZComments_get76xcolumns_news($Commentstable, $Commentscolumn);
    }
    if (is_null($Commentstable) || is_null($Commentscolumn)) {
        return LogUtil::registerError('News migration: Comments tables not found');
    }
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    $sql = "SELECT {$Commentscolumn['tid']},\n                   {$Commentscolumn['sid']},\n                   {$Commentscolumn['date']}, \n                   {$Usercolumn['uid']},\n                   {$Commentscolumn['comment']},\n                   {$Commentscolumn['subject']},\n                   {$Commentscolumn['pid']}\n              FROM {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['name']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('News migration: DB Error');
    }
    // array to rebuild the patents
    $comments = array(0 => array('newid' => -1));
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('tid', 'sid', 'date', 'uid', 'comment', 'subject', 'replyto'));
    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' => 'News', 'objectid' => DataUtil::formatForStore($item['sid']), 'url' => ModUtil::url('News', 'user', 'display', array('sid' => $item['sid'])), 'comment' => $item['comment'], 'subject' => $item['subject'], 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('News migration: Error creating comment');
        }
        $comments[$item['tid']] = array('newid' => $id, 'pid' => $item['replyto']);
    }
    // rebuild the links to the parents
    $tids = array_keys($comments);
    foreach ($tids as $tid) {
        if ($tid != 0) {
            $v = $comments[$tid];
            $sql = "UPDATE {$EZCommentstable}\n                       SET {$EZCommentscolumn['replyto']} = '" . $comments[$v['pid']]['newid'] . "'\n                     WHERE {$EZCommentscolumn['id']} = '{$v['newid']}'";
            $result = DBUtil::executeSQL($sql);
        }
    }
    // activate the ezcomments hook for the news module
    ModUtil::apiFunc('Modules', 'admin', 'enablehooks', array('callermodname' => 'News', 'hookmodname' => 'EZComments'));
    return LogUtil::registerStatus('News migration successful');
}
开发者ID:rmaiwald,项目名称:EZComments,代码行数:61,代码来源:news.php

示例15: resetagreement

    /**
     * Reset the agreement to the terms of use for a specific group of users, or all users.
     *
     * Parameters passed in the $args array:
     * -------------------------------------
     * int $args['gid'] The group id; -1 = none, 0 = all groups.
     *
     * @param array $args All arguments passed to the function.
     *
     * @return bool True if successfully reset, otherwise false.
     *
     * @throws Zikula_Exception_Forbidden Thrown if the user does not have the appropriate access level for the function.
     *
     * @throws Zikula_Exception_Fatal Thrown in cases where expected data is not present or not in an expected form.
     */
    public function resetagreement($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('legal::', '::', ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden();
        }

        if (!isset($args['gid']) || $args['gid'] == -1) {
            throw new Zikula_Exception_Fatal();
        }

        // Get database setup
        $pntable = DBUtil::getTables();
        $userscolumn = $pntable['users_column'];

        if ($args['gid']==0) {
            //all users
            // creative usage of DBUtil
            $object = array('activated' => 2);
            $where = "WHERE $userscolumn[uid] NOT IN (1,2)";
            DBUtil::updateObject($object, 'users', $where, 'uid');
        } else {
            // single group

            // get the group incl members
            $grp = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $args['gid']));
            if ($grp==false) {
                return false;
            }

            // remove anonymous from members array
            if (array_key_exists(1, $grp['members'])) {
                unset($grp['members'][1]);
            }

            // remove admin from members array
            if (array_key_exists(2, $grp['members'])) {
                unset($grp['members'][2]);
            }

            // return if group is empty
            if (count($grp['members'])==0) {
                return false;
            }
            $members = '(' . implode(array_keys($grp['members']), ',') . ')';

            // creative usage of DBUtil
            $object = array('activated' => 2);
            $where = "WHERE $userscolumn[uid] IN $members";
            DBUtil::updateObject($object, 'users', $where, 'uid');
        }
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:68,代码来源:Admin.php


注:本文中的DBUtil::getTables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。