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


PHP DBUtil::selectFieldArray方法代码示例

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


在下文中一共展示了DBUtil::selectFieldArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

    /**
     * Update the IWwebbox module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {

        // Update z_blocs table

        $c = "UPDATE blocks SET bkey = 'Webbox' WHERE bkey = 'webbox'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }

        //Array de noms
        $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWwebbox'", '', false, '');

        $newVarsNames = Array('url', 'width', 'height', 'scrolls', 'widthunit');

        $newVars = Array('url' => 'http://phobos.xtec.cat/intraweb',
            'width' => '100',
            'height' => '600',
            'scrolls' => '1',
            'widthunit' => '%');    

        // Delete unneeded vars
        $del = array_diff($oldVarsNames, $newVarsNames);
        foreach ($del as $i) {
            $this->delVar($i);
        }

        // Add new vars
        $add = array_diff($newVarsNames, $oldVarsNames);
        foreach ($add as $i) {
            $this->setVar($i, $newVars[$i]);
        }

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

示例2: mediashare_mediahandlerapi_getMediaHandlers

function mediashare_mediahandlerapi_getMediaHandlers()
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    $pntable = pnDBGetTables();
    // Get handlers
    if (!($result = DBUtil::selectFieldArray('mediashare_mediahandlers', 'handler', '', '', true, 'title'))) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.getMediaHandlers', 'Could not load the handlers.'), $dom));
    }
    $handlers = array();
    foreach ($result as $title => $handler) {
        $handlers[] = array('handler' => $handler, 'title' => $title, 'mediaTypes' => array());
    }
    $handlersTable = $pntable['mediashare_mediahandlers'];
    $handlersColumn = $pntable['mediashare_mediahandlers_column'];
    // Get media types per handler
    foreach (array_keys($handlers) as $k) {
        $handler = DataUtil::formatForStore($handlers[$k]['handler']);
        $sql = "SELECT {$handlersColumn['mimeType']},\r\n                       {$handlersColumn['fileType']},\r\n                       {$handlersColumn['foundMimeType']},\r\n                       {$handlersColumn['foundFileType']},\r\n\t\t\t\t\t\t\t\t\t\t\t {$handlersColumn['active']},\r\n\t\t\t\t\t\t\t\t\t\t\t {$handlersColumn['id']}\r\n                  FROM {$handlersTable}\r\n                 WHERE {$handlersColumn['handler']} = '{$handler}'";
        $result = DBUtil::executeSQL($sql);
        if ($result === false) {
            return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.getMediaHandlers', "Could not load the types for the handler '{$handler}'."), $dom));
        }
        $colArray = array('mimeType', 'fileType', 'foundMimeType', 'foundFileType', 'active', 'id');
        $handlers[$k]['mediaTypes'] = DBUtil::marshallObjects($result, $colArray);
    }
    return $handlers;
}
开发者ID:ro0f,项目名称:Mediashare,代码行数:27,代码来源:pnmediahandlerapi.php

示例3: upgrade

    /**
     * Update the IWbookings module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    function upgrade($oldversion) {

        //Array de noms
        $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWbookings'", '', false, '');

        $newVarsNames = Array('group', 'weeks', 'month_panel', 'weekends', 'eraseold', 'showcolors', 'NTPtime');

        $newVars = Array('group' => '',
            'weeks' => '1',
            'month_panel' => '0',
            'weekends' => '0',
            'eraseold' => '1',
            'showcolors' => '0',
            'NTPtime' => '0');

        // Delete unneeded vars
        $del = array_diff($oldVarsNames, $newVarsNames);
        foreach ($del as $i) {
            $this->delVar($i);
        }

        // Add new vars
        $add = array_diff($newVarsNames, $oldVarsNames);
        foreach ($add as $i) {
            $this->setVar($i, $newVars[$i]);
        }

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

示例4: getModalitats

 public function getModalitats() {
     //Verificar permisos
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_READ));
     $rs = DBUtil::selectFieldArray('llicencies_modalitat', 'descripcio', '', 'id_mod', false, 'id_mod');
     foreach ($rs as $key => &$value) {
         $value = $key."-".$value;
     }
     return $rs;
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:9,代码来源:User.php

示例5: getUserID

 /**
  * Return a random user-id.
  *
  * @return The resulting random user-id.
  */
 public static function getUserID()
 {
     $fa = DBUtil::selectFieldArray('users', 'uid');
     $pos = self::getInteger(0, count($fa));
     return $fa[$pos];
 }
开发者ID:planetenkiller,项目名称:core,代码行数:11,代码来源:RandomUtil.php

示例6: getSystemAttributes

 /**
  * Retrieve a list of attributes defined in the system.
  *
  * @param string $sort The column to sort by (optional) (default='attribute_name').
  *
  * @return the system attributes field array
  */
 public static function getSystemAttributes($sort = 'attribute_name')
 {
     $dbtables = DBUtil::getTables();
     $table = $dbtables['objectdata_attributes'];
     $column = $dbtables['objectdata_attributes_column'];
     // ensure module was successfully loaded
     if (!$table) {
         return false;
     }
     $atrs = DBUtil::selectFieldArray('objectdata_attributes', 'attribute_name', '', 'attribute_name', true);
     return $atrs;
 }
开发者ID:Silwereth,项目名称:core,代码行数:19,代码来源:ObjectUtil.php

示例7: getVar

 /**
  * The getVar method gets a module variable.
  *
  * If the name parameter is included then method returns the
  * module variable value.
  * if the name parameter is ommitted then method returns a multi
  * dimentional array of the keys and values for the module vars.
  *
  * @param string  $modname The name of the module or pseudo-module (e.g., 'Users', 'ZConfig', '/EventHandlers').
  * @param string  $name    The name of the variable.
  * @param boolean $default The value to return if the requested modvar is not set.
  *
  * @return string|array If the name parameter is included then method returns
  *          string - module variable value
  *          if the name parameter is ommitted then method returns
  *          array - multi dimentional array of the keys
  *                  and values for the module vars.
  */
 public static function getVar($modname, $name = '', $default = false)
 {
     // if we don't know the modname then lets assume it is the current
     // active module
     if (!isset($modname)) {
         $modname = self::getName();
     }
     // if we haven't got vars for this module (or pseudo-module) yet then lets get them
     if (!array_key_exists($modname, self::$modvars)) {
         // A query out to the database should only be needed if the system is upgrading. Use the installing flag to determine this.
         if (System::isUpgrading()) {
             $tables = DBUtil::getTables();
             $col = $tables['module_vars_column'];
             $where = "WHERE {$col['modname']} = '" . DataUtil::formatForStore($modname) . "'";
             // The following line is not a mistake. A sort string containing one space is used to disable the default sort for DBUtil::selectFieldArray().
             $sort = ' ';
             $results = DBUtil::selectFieldArray('module_vars', 'value', $where, $sort, false, 'name');
             if (is_array($results)) {
                 if (!empty($results)) {
                     foreach ($results as $k => $v) {
                         // ref #2045 vars are being stored with 0/1 unserialised.
                         if (array_key_exists($k, $GLOBALS['ZConfig']['System'])) {
                             self::$modvars[$modname][$k] = $GLOBALS['ZConfig']['System'][$k];
                         } elseif ($v == '0' || $v == '1') {
                             self::$modvars[$modname][$k] = $v;
                         } else {
                             self::$modvars[$modname][$k] = unserialize($v);
                         }
                     }
                 }
             }
             // TODO - There should probably be an exception thrown here if $results === false
         } else {
             // Prevent a re-query for the same module in the future, where the module does not define any module variables.
             self::$modvars[$modname] = array();
         }
     }
     // if they didn't pass a variable name then return every variable
     // for the specified module as an associative array.
     // array('var1' => value1, 'var2' => value2)
     if (empty($name) && array_key_exists($modname, self::$modvars)) {
         return self::$modvars[$modname];
     }
     // since they passed a variable name then only return the value for
     // that variable
     if (isset(self::$modvars[$modname]) && array_key_exists($name, self::$modvars[$modname])) {
         return self::$modvars[$modname][$name];
     }
     // we don't know the required module var but we established all known
     // module vars for this module so the requested one can't exist.
     // we return the default (which itself defaults to false)
     return $default;
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:71,代码来源:ModUtil.php

示例8: getcommentingusers

    /**
     * Get all users who have commented on the site so far
     *
     * @author Mark West
     * @return array users who've commented so far
     */
    public function getcommentingusers()
    {
        // Security check
        if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_OVERVIEW)) {
            return array();
        }

        // Get database columns
        $tables  = DBUtil::getTables();
        $columns = $tables['EZComments_column'];

        $where = "$columns[status] = 0";
        $items = DBUtil::selectFieldArray('EZComments', 'uid', $where, '', true);

        return $items;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:22,代码来源:User.php

示例9: upgrade

    /**
     * Update the IWagendas module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {
        // Update z_blocs table
        $c = "UPDATE blocks SET bkey = 'Calendar' WHERE bkey = 'calendar'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }

        $c = "UPDATE blocks SET bkey = 'Next' WHERE bkey = 'next'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }
    
        //Array de noms
        $oldVarsNames = DBUtil::selectFieldArray('module_vars', 'name', "`modname` = 'IWagendas'", '', false, '');

        $newVarsNames = Array('inicicurs', 'calendariescolar', 'comentaris', 'festiussempre', 'altresfestius',
            'informacions', 'periodes', 'llegenda', 'infos', 'vista', 'colors', 'maxnotes', 'adjuntspersonals',
            'caducadies', 'urladjunts', 'msgUsersRespDefault', 'msgUsersDefault', 'allowGCalendar');

        $newVars = Array('inicicurs' => date('Y'),
            'calendariescolar' => 0,
            'comentaris' => '',
            'festiussempre' => '',
            'altresfestius' => '30',
            'informacions' => '1',
            'periodes' => '',
            'llegenda' => 0,
            'infos' => 0,
            'vista' => -1,
            'colors' => 'DBD4A6|555555|FFCC66|FFFFFF|E1EBFF|669ACC|FFFFFF|FFFFFF|FF8484|FFFFFF|DBD4A6|66FF66|3F6F3E|FFFFCC|BBBBBB|000000',
            'maxnotes' => '300',
            'adjuntspersonals' => '0',
            'caducadies' => '30',
            'urladjunts' => 'agendas',
            'msgUsersRespDefault' => __('You has been added to a new agenda as moderator. You can access the agenda throught the main menu. <br><br>The administrator'),
            'msgUsersDefault' => __('You has been added to a new agenda. You can access the agenda throught the main menu. <br><br>The administrator'),
            'allowGCalendar' => '0');

        // Delete unneeded vars
        $del = array_diff($oldVarsNames, $newVarsNames);
        foreach ($del as $i) {
            $this->delVar($i);
        }

        // Add new vars
        $add = array_diff($newVarsNames, $oldVarsNames);
        foreach ($add as $i) {
            $this->setVar($i, $newVars[$i]);
        }

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

示例10: getMonthsWithNews

    /**
     * Get all months and years with news. Used by archive overview
     * @author Philipp Niethammer
     * @return array Array of dates (one per month)
     */
    public function getMonthsWithNews($args)
    {
        // Security check
        if (!SecurityUtil::checkPermission('News::', '::', ACCESS_OVERVIEW)) {
            return false;
        }

        $tables = DBUtil::getTables();
        $news_column = $tables['news_column'];

        // TODO: Check syntax for other Databases (i.e. Postgres doesn't know YEAR_MONTH)
        $order = "GROUP BY EXTRACT(YEAR_MONTH FROM $news_column[from]) ORDER BY $news_column[from] DESC";

        $date = DateUtil::getDatetime();
        $where = "($news_column[from] < '$date' AND $news_column[published_status] = '0')";
        $dates = DBUtil::selectFieldArray('news', 'from', $where, $order);

        return $dates;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:24,代码来源:User.php

示例11: importaCentres

    /**
     * Importa centres a partir d'un csv a la base de dades de Sirius
     * 
     * Els centres ja existents (codi) els actualitza (informació addicional) i afegeix els nous
     * 
     * @return void Retorna a la funció *modulesetings* amb els missatges d'execució
     */
    public function importaCentres() {
        if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }
        // get input values. Check for direct function call first because calling function might be either get or post
        if (isset($args) && is_array($args) && !empty($args)) {
            $confirmed = isset($args['confirmed']) ? $args['confirmed'] : false;
        } elseif (isset($args) && !is_array($args)) {
            throw new Zikula_Exception_Fatal(LogUtil::getErrorMsgArgs());
        } elseif ($this->request->isGet()) {
            $confirmed = false;
        } elseif ($this->request->isPost()) {
            $this->checkCsrfToken();
            $confirmed = $this->request->request->get('confirmed', false);
        }
        if ($confirmed) {
            // get other import values
            $importFile = $this->request->files->get('importFile', isset($args['importFile']) ? $args['importFile'] : null);

            $fileName = $importFile['name'];
            $importResults = '';
            if ($fileName == '') {
                $importResults = $this->__("No heu triat cap fitxer.");
            } elseif (FileUtil::getExtension($fileName) != 'csv') {
                $importResults = $this->__("L'extensió del fitxer ha de ser csv.");
            } elseif (!$file_handle = fopen($importFile['tmp_name'], 'r')) {
                $importResults = $this->__("No s'ha pogut llegir el fitxer csv.");
            } else {
                $caps = array(
                    'CODI_ENTITAT'      => 'CODI_ENTITAT',
                    'CODI_TIPUS_ENTITAT'=> 'CODI_TIPUS_ENTITAT',
                    'NOM_ENTITAT'       => 'NOM_ENTITAT',
                    'NOM_LOCALITAT'     => 'NOM_LOCALITAT',
                    'NOM_DT'            => 'NOM_DT',
                    'CODI_DT'           => 'CODI_DT',
                    'NOM_TIPUS_ENTITAT' => 'NOM_TIPUS_ENTITAT'
                );
                while (!feof($file_handle)) {
                    $line = fgetcsv($file_handle, 1024, ';', '"');
                    if ($line != '') {
                        $lines[] = $line;
                    }
                }
                fclose($file_handle);
                //
                $centres = DBUtil::selectFieldArray('cataleg_centres', 'CODI_ENTITAT');
                $updateCentres = array();
                $insertCentres = array();
                foreach ($lines as $line_num => $line) {
                    if ($line_num != 0) {
                        if (count($lines[0]) != count($line)) {
                            $importResults .= $this->__("<div>Hi ha registres amb un número de camps incorrecte.</div>");
                        } else {
                            if (in_array($line[0], $centres)) {
                                $updateCentres[] = array_combine($lines[0], $line);
                            } else {
                                $insertCentres[] = array_combine($lines[0], $line);
                            }
                        }
                    } else {
                        $difs = array_diff($line, $caps);
                        if (count($line) != count(array_unique($line))) {
                            $importResults = $this->__("La capçalera del csv té columnes repetides.");
                        } elseif (!in_array('CODI_ENTITAT', $line)) {
                            $importResults = $this->__("El csv ha de tenir obligatòriament el camp CODI_ENTITAT.");
                        } elseif ($line[0] != 'CODI_ENTITAT') {
                            $importResults = $this->__("El camp obligatori CODI_ENTITAT ha d'ocupar el primer lloc.");
                        } elseif (!empty($difs)) {
                            $importResults = $this->__("<div>El csv té camps incorrectes.</div>");
                        }
                    }
                }
            }
            
            if ($importResults == '') {
                $inserts = count($insertCentres);
                $updates = count($updateCentres);
                DBUtil::insertObjectArray($insertCentres, 'cataleg_centres');
                DBUtil::updateObjectArray($updateCentres, 'cataleg_centres', 'CODI_ENTITAT');
                // the users have been imported successfully
                $this->registerStatus($this->__('Els centres s\'han importat correctament'));
                $this->registerStatus($this->__('Centres actualitzats: ' . $updates . ' - Centres nous: ' . $inserts));
                //$this->redirect(ModUtil::url($this->name, 'admin', 'modulesettings'));
                return system::redirect(ModUtil::url('Cataleg', 'admin', 'modulesettings'));
            }
        }
        // shows the form
        $post_max_size = ini_get('post_max_size');
        return $this->view->assign('importResults', isset($importResults) ? $importResults : '')
                        ->assign('post_max_size', $post_max_size)
                        ->fetch('admin/Cataleg_admin_importaCentres.tpl');
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:99,代码来源:Admin.php

示例12: mediashare_userapi_getFirstItemIdInAlbum

function mediashare_userapi_getFirstItemIdInAlbum($args)
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_READ)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Argument check
    if (!isset($args['albumId'])) {
        return LogUtil::registerError(__f('Missing [%1$s] in \'%2$s\'', array('albumId', 'userapi.getFirstItemIdInAlbum'), $dom));
    }
    $albumId = (int) $args['albumId'];
    $pntable = pnDBGetTables();
    $mediaColumn = $pntable['mediashare_media_column'];
    $where = "{$mediaColumn['parentAlbumId']} = '{$albumId}'";
    $orderby = "{$mediaColumn['createdDate']} DESC";
    $media = DBUtil::selectFieldArray('mediashare_media', 'id', $where, $orderby);
    if ($media === false) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('userapi.getFirstItemInAlbum', 'Could not retrieve the album information.'), $dom));
    }
    if (!$media) {
        return true;
    }
    return $media[0];
}
开发者ID:ro0f,项目名称:Mediashare,代码行数:25,代码来源:pnuserapi.php

示例13: upgrade

    /**
     * Update the IWforums module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @author Josep Ferràndiz Farré (jferran6@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {
         switch (true) {
            case ($oldversion < '3.0.0'):
                //ADD new fields to tables
                $c = "ALTER TABLE `IWforums_msg` ADD `iw_onTop` TINYINT (4) NOT NULL DEFAULT '0'";
                if (!DBUtil::executeSQL($c)) {
                    return false;
                }

                //Array de noms
                $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWforums'", '', false, '');

                $newVarsNames = Array('urladjunts', 'avatarsVisible', 'smiliesActive');

                $newVars = Array('urladjunts' => 'forums',
                    'avatarsVisible' => 1,
                    'smiliesActive' => 1);

                // Delete unneeded vars
                $del = array_diff($oldVarsNames, $newVarsNames);
                foreach ($del as $i) {
                    $this->delVar($i);
                }

                // Add new vars
                $add = array_diff($newVarsNames, $oldVarsNames);
                foreach ($add as $i) {
                    $this->setVar($i, $newVars[$i]);
                }
                
            case ($oldversion == '3.0.0'):                
                $sql = "ALTER TABLE `IWforums_definition` ADD `longDescriu` LONGTEXT NOT NULL Default ''";
                $connection = Doctrine_Manager::getInstance()->getConnection('default');
                $stmt = $connection->prepare($sql);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    LogUtil::registerError($e->getMessage());
                    return false;
                }   
                $this->setVar('restyledTheme', '1');
                HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
                
            case ($oldversion == '3.0.1'):                
                $connection = $this->entityManager->getConnection();
                $sqlStatements = array();
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `subscriptionMode` TINYINT(4) DEFAULT '1'";
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `subscribers` LONGTEXT";
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `noSubscribers` LONGTEXT";
                foreach ($sqlStatements as $sql) {
                    $stmt = $connection->prepare($sql);
                    try {
                        $stmt->execute();
                    } catch (Exception $e) {
                        
                    }
                }                
            }
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:67,代码来源:Installer.php

示例14: _generateCategoryFilter

 /**
  * Build a list of objects which are mapped to the specified categories.
  *
  * @param string  $tablename      Treated table reference.
  * @param string  $categoryFilter The category list to use for filtering.
  * @param boolean $returnArray    Whether or not to return an array (optional) (default=false).
  *
  * @return mixed The resulting string or array.
  */
 private static function _generateCategoryFilter($tablename, $categoryFilter, $returnArray = false)
 {
     if (!$categoryFilter) {
         return '';
     }
     if (!ModUtil::dbInfoLoad('ZikulaCategoriesModule')) {
         return '';
     }
     // check the meta data
     if (isset($categoryFilter['__META__']['module'])) {
         $modname = $categoryFilter['__META__']['module'];
     } else {
         $modname = ModUtil::getName();
     }
     // check operator to use
     // when it's AND, the where contains subqueries
     if (isset($categoryFilter['__META__']['operator']) && in_array(strtolower($categoryFilter['__META__']['operator']), array('and', 'or'))) {
         $op = strtoupper($categoryFilter['__META__']['operator']);
     } else {
         $op = 'OR';
     }
     unset($categoryFilter['__META__']);
     // get the properties IDs in the category register
     $propids = CategoryRegistryUtil::getRegisteredModuleCategoriesIds($modname, $tablename);
     // build the where clause
     $n = 1;
     // subquery counter
     $catmapobjtbl = 'categories_mapobj';
     $where = array();
     foreach ($categoryFilter as $property => $category) {
         $prefix = '';
         if ($op == 'AND') {
             $prefix = "table{$n}.";
         }
         // this allows to have an array of categories IDs
         if (is_array($category)) {
             $wherecat = array();
             foreach ($category as $cat) {
                 $wherecat[] = "{$prefix}category_id='" . DataUtil::formatForStore($cat) . "'";
             }
             $wherecat = '(' . implode(' OR ', $wherecat) . ')';
             // if there's only one category ID
         } else {
             $wherecat = "{$prefix}category_id='" . DataUtil::formatForStore($category) . "'";
         }
         // process the where depending of the operator
         if ($op == 'AND') {
             $where[] = "obj_id IN (SELECT {$prefix}obj_id FROM {$catmapobjtbl} table{$n} WHERE {$prefix}reg_id = '" . DataUtil::formatForStore($propids[$property]) . "' AND {$wherecat})";
         } else {
             $where[] = "(reg_id='" . DataUtil::formatForStore($propids[$property]) . "' AND {$wherecat})";
         }
         $n++;
     }
     $where = "tablename='" . DataUtil::formatForStore($tablename) . "' AND (" . implode(" {$op} ", $where) . ')';
     // perform the query
     $objIds = DBUtil::selectFieldArray('categories_mapobj', 'obj_id', $where);
     // this ensures that we return an empty set if no objects are mapped to the requested categories
     if (!$objIds) {
         $objIds[] = -1;
     }
     if ($returnArray) {
         return $objIds;
     }
     return implode(',', $objIds);
 }
开发者ID:rmaiwald,项目名称:core,代码行数:74,代码来源:DBUtil.php

示例15: getAuthInfo

 /**
  * Get auth info.
  *
  * @param integer $user User Id.
  *
  * @return array Two element array of user and group permissions.
  */
 public static function getAuthInfo($user = null)
 {
     // Table columns we use - ModUtil::dbInfoLoad is done in pnInit
     $dbtable = DBUtil::getTables();
     $groupmembershipcolumn = $dbtable['group_membership_column'];
     $grouppermcolumn = $dbtable['group_perms_column'];
     // Empty arrays
     $groupperms = array();
     $uids[] = -1;
     // Get user ID
     if (!isset($user)) {
         if (!UserUtil::isLoggedIn()) {
             // Unregistered UID
             $uids[] = 0;
             $vars['Active User'] = 'unregistered';
         } else {
             $uids[] = UserUtil::getVar('uid');
             $vars['Active User'] = UserUtil::getVar('uid');
         }
     } else {
         $uids[] = $user;
         $vars['Active User'] = $user;
     }
     $uids = implode(',', $uids);
     // Get all groups that user is in
     $where = "WHERE {$groupmembershipcolumn['uid']} IN (" . DataUtil::formatForStore($uids) . ')';
     $fldArray = DBUtil::selectFieldArray('group_membership', 'gid', $where);
     if ($fldArray === false) {
         return $groupperms;
     }
     static $usergroups = array();
     if (!$usergroups) {
         $usergroups[] = -1;
         if (!UserUtil::isLoggedIn()) {
             $usergroups[] = 0;
             // Unregistered GID
         }
     }
     $allgroups = array_merge($usergroups, $fldArray);
     $allgroups = implode(',', $allgroups);
     // Get all group permissions
     $where = "WHERE {$grouppermcolumn['gid']} IN (" . DataUtil::formatForStore($allgroups) . ')';
     $orderBy = "ORDER BY {$grouppermcolumn['sequence']}";
     $objArray = DBUtil::selectObjectArray('group_perms', $where, $orderBy);
     if (!$objArray) {
         return $groupperms;
     }
     foreach ($objArray as $obj) {
         $component = self::_fixsecuritystring($obj['component']);
         $instance = self::_fixsecuritystring($obj['instance']);
         $level = self::_fixsecuritystring($obj['level']);
         // Search/replace of special names
         preg_match_all('/<([^>]+)>/', $instance, $res);
         $size = count($res[1]);
         for ($i = 0; $i < $size; $i++) {
             $instance = preg_replace('/<([^>]+)>/', $vars[$res[1][$i]], $instance, 1);
         }
         $groupperms[] = array('component' => $component, 'instance' => $instance, 'level' => $level);
     }
     // we've now got the permissions info
     $GLOBALS['authinfogathered'][$user] = 1;
     return $groupperms;
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:70,代码来源:SecurityUtil.php


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