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


PHP DBUtil::insertObjectArray方法代码示例

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


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

示例1: addUserToGroup

    /**
     * Sets the user groups membership
     * @author:     Albert Pérez Monfort (aperezm@xtec.cat)
     * @author: 	Josep Ferràndiz (jferran6@xtec.cat)
     * @param:	Array with the id's of the groups where the user will be enroled
     * @return:	True if success and false in other case
     */
    public function addUserToGroup($args) {
        $roles = FormUtil::getPassedValue('roles', isset($args['roles']) ? $args['roles'] : null, 'POST');
        $defaultRoles = FormUtil::getPassedValue('defaultRoles', isset($args['defaultRoles']) ? $args['defaultRoles'] : null, 'POST');
        // Security check
        if (!SecurityUtil::checkPermission('IWmyrole::', "::", ACCESS_ADMIN) && $defaultRoles != 1) {
            throw new Zikula_Exception_Forbidden();
        }
        if ($defaultRoles == 1) {
            $roles = array();
            //get user default roles
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $defaultRoles = ModUtil::func('IWmain', 'user', 'userGetVar',
                                           array('uid' => $uid,
                                                 'name' => 'defaultRoles',
                                                 'module' => 'IWmyrole',
                                                 'sv' => $sv));

            //set default roles
            $userGroups = explode('$$', $defaultRoles);
            $i = 0;
            foreach ($userGroups as $group) {
                if ($group != '') {
                    $roles[$i] = $group;
                    $i++;
                }
            }
        }
        $uid = UserUtil::getVar('uid');
        $count = count($roles);
        for ($i = 0; $i < $count; $i++) {
            //Check if user belongs to change group. If not the block is not showed
            $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
            $isMember = ModUtil::func('IWmain', 'user', 'isMember',
                                       array('sv' => $sv,
                                             'gid' => $roles[$i],
                                             'uid' => $uid));
            if (!$isMember) {
                $obj[] = array('uid' => $uid,
                               'gid' => $roles[$i]);
            }
        }

        if ($count > 0) {
            if (!DBUtil::insertObjectArray($obj, 'group_membership')) {
                return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
            }
        }
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:56,代码来源:Admin.php

示例2: defaultdata

    /**
     * create the default data for the groups module
     *
     * This function is only ever called once during the lifetime of a particular
     * module instance
     *
     * @return bool false
     */
    public function defaultdata()
    {
        $records = array(
            array(  'name'        => $this->__('Users'),
                    'description' => $this->__('By default, all users are made members of this group.'),
                    'prefix'      => $this->__('usr')),
            array(  'name'        => $this->__('Administrators'),
                    'description' => $this->__('Group of administrators of this site.'),
                    'prefix'      => $this->__('adm'))
        );

        DBUtil::insertObjectArray($records, 'groups', 'gid');

        // Insert Anonymous and Admin users
        $records = array(
            // Anonymous user, member of Users group (This is required. Handling of 'unregistered' state for
            // permissions is handled separately.)
            array('gid' => '1',
                  'uid' => '1'),
            // Admin user, member of Users group (Not strictly necessary, but for completeness.)
            array('gid' => '1',
                  'uid' => '2'),
            // Admin user, member of Administrators group
            array('gid' => '2',
                  'uid' => '2')
        );

        DBUtil::insertObjectArray($records, 'group_membership', 'gid', true);
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:37,代码来源:Installer.php

示例3: resetPermissions

 public function resetPermissions()
 {
     // Delete all current permission entries.
     if (!DBUtil::truncateTable('group_perms')) {
         $this->setError(__('Error! Permission not deleted'));
         return false;
     }
     // Array of permission objects to insert.
     $perms = array();
     $perms[] = array('pid' => 1, 'gid' => 2, 'sequence' => 1, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 800, 'bond' => 0);
     $perms[] = array('pid' => 2, 'gid' => -1, 'sequence' => 2, 'realm' => 0, 'component' => 'ExtendedMenublock::', 'instance' => '1:2:', 'level' => 0, 'bond' => 0);
     $perms[] = array('pid' => 3, 'gid' => 1, 'sequence' => 3, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 300, 'bond' => 0);
     $perms[] = array('pid' => 4, 'gid' => 0, 'sequence' => 4, 'realm' => 0, 'component' => 'ExtendedMenublock::', 'instance' => '1:(1|3):', 'level' => 0, 'bond' => 0);
     $perms[] = array('pid' => 5, 'gid' => 0, 'sequence' => 5, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 200, 'bond' => 0);
     // Insert default permissions or fail.
     if (!DBUtil::insertObjectArray($perms, 'group_perms', 'pid')) {
         $this->setError(__('Error inserting permission'));
         return false;
     }
     // Success.
     return true;
 }
开发者ID:Silwereth,项目名称:core,代码行数:22,代码来源:zrc.php

示例4: importActs

 /**
  *  Crea les activitats seleccionades per a la importació
  * 
  * @param array $acts Array amb els paràmetres de la funció
  *
  * ### Paràmetres de l'array $acts:
  * integer **priId** Id de la prioritat
  * integer **sprId** Id de la subprioritat
  * integer **uniId** Id de la unitat
  * string **titol** Títol de l'activitat
  * string **tGTAF** Tipus GTAF de l'activitat
  * string **destinataris** Serialització de codis de destinataris segons la taula cataleg_auxiliar del tipus "dest"
  * string **observacions** Observacions relatives als destinataris de l'activitat
  * integer **curs** Codi coresponent a una tipologia de formació. Els diferents codis vàlids es troben a la taula cataleg_auxiliar amb tipus "curs"
  * integer **presencialitat** Codi coresponent a la presencialitat de l'activitat. Els diferents codis vàlids es troben a la taula cataleg_auxiliar amb tipus "pres"
  * integer **abast** Codi coresponent a l'abast de l'activitat (un o diversos centres). Els diferents codis vàlids es troben a la taula cataleg_auxiliar amb tipus "abast"
  * integer **hores** Durada en hores de l'activitat
  * string **objectius** Camp serialitzat amb els objectius de l'activitat
  * string **continguts** Camp serialitzat amb els continguts de l'activitat
  * string **gestio** Serialització codificada dels elements a gestionar (txt) de l'activitat i de l'entitat/servei que els gestiona (srv). Els primers es troben a la taula cataleg_gestioActivitatDefaults i els segons a cataleg_auxiliar amb el tipus "gest"
  * string **info** Informació general de l'activitat
  *                               
  * @return boolean true si la inserció ha tingut èxit, false en cas contrari
  */
 public function importActs(array $acts){
     return DBUtil::insertObjectArray($acts, 'cataleg_activitats');
 }
开发者ID:projectesIF,项目名称:Sirius,代码行数:27,代码来源:User.php

示例5: install

 /**
  * Init the module
  * @return true if init successful, false otherwise
  */
 public function install()
 {
     // create labels table
     if (!DBUtil::createTable('addressbook_labels')) {
         return false;
     }
     // insert default values
     $objArray = array();
     $objArray[] = array('id' => 1, 'name' => DataUtil::formatForStore($this->__('Work')));
     $objArray[] = array('id' => 2, 'name' => DataUtil::formatForStore($this->__('Fax')));
     $objArray[] = array('id' => 3, 'name' => DataUtil::formatForStore($this->__('Mobile')));
     $objArray[] = array('id' => 4, 'name' => DataUtil::formatForStore($this->__('Home')));
     $objArray[] = array('id' => 5, 'name' => DataUtil::formatForStore($this->__('Email')));
     $objArray[] = array('id' => 6, 'name' => DataUtil::formatForStore($this->__('URL')));
     $objArray[] = array('id' => 7, 'name' => DataUtil::formatForStore($this->__('Other')));
     DBUtil::insertObjectArray($objArray, 'addressbook_labels', 'id', true);
     // create custom field table
     if (!DBUtil::createTable('addressbook_customfields')) {
         return false;
     }
     // insert default values
     $objArray = array();
     $objArray[] = array('id' => 1, 'name' => DataUtil::formatForStore($this->__('Custom Label 1')), 'type' => 'varchar(60) default NULL', 'position' => 1);
     $objArray[] = array('id' => 2, 'name' => DataUtil::formatForStore($this->__('Custom Label 2')), 'type' => 'varchar(60) default NULL', 'position' => 2);
     $objArray[] = array('id' => 3, 'name' => DataUtil::formatForStore($this->__('Custom Label 3')), 'type' => 'varchar(60) default NULL', 'position' => 3);
     $objArray[] = array('id' => 4, 'name' => DataUtil::formatForStore($this->__('Custom Label 4')), 'type' => 'varchar(60) default NULL', 'position' => 4);
     DBUtil::insertObjectArray($objArray, 'addressbook_customfields', 'id', true);
     // create favourites table
     if (!DBUtil::createTable('addressbook_favourites')) {
         return false;
     }
     // finally create the address table
     if (!DBUtil::createTable('addressbook_address')) {
         return false;
     }
     // create our default categories
     if (!$this->_addressbook_createdefaultcategory()) {
         return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
     }
     // Set up an initial value for a module variable.
     $this->setVar('abtitle', 'Address Book');
     $this->setVar('abmetatitle', 'Address Book');
     $this->setVar('abmetadescription', 'Address book');
     $this->setVar('abmetakeyword', 'catalog, addressbook');
     $this->setVar('itemsperpage', 30);
     $this->setVar('globalprotect', 0);
     $this->setVar('allowprivate', 0);
     $this->setVar('custom_tab', '');
     $this->setVar('use_prefix', 0);
     $this->setVar('use_img', 0);
     $this->setVar('images_dir', 'userdata/Addressbook');
     $this->setVar('images_manager', 'kcfinder');
     $this->setVar('google_api_key', '');
     $this->setVar('google_zoom', 15);
     $this->setVar('enablecategorization', true);
     $this->setVar('addressbooktype', 1);
     // 1-people, 2-companies
     $this->setVar('showabcfilter', 1);
     // Register hooks
     HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
     // Register event handlers
     EventUtil::registerPersistentModuleHandler('AddressBook', 'module.content.gettypes', array('AddressBook_EventHandler_Listeners', 'getContentTypes'));
     // Initialisation successful
     return true;
 }
开发者ID:nmpetkov,项目名称:AddressBook,代码行数:69,代码来源:Installer.php

示例6: defaultdata

 protected function defaultdata()
 {
     // Set editor defaults
     $this->setVar('editors_path', 'modules/Scribite/includes');
     // xinha
     $this->setVar('xinha_language', 'en');
     $this->setVar('xinha_skin', 'blue-look');
     $this->setVar('xinha_barmode', 'reduced');
     $this->setVar('xinha_width', 'auto');
     $this->setVar('xinha_height', 'auto');
     $this->setVar('xinha_style', 'modules/Scribite/style/xinha/editor.css');
     $this->setVar('xinha_statusbar', 1);
     $this->setVar('xinha_converturls', 1);
     $this->setVar('xinha_showloading', 1);
     $this->setVar('xinha_activeplugins', 'a:2:{i:0;s:7:"GetHtml";i:1;s:12:"SmartReplace";}');
     // openwysiwyg
     // openwysiwyg deprecated @4.3.0
     //        $this->setVar('openwysiwyg_barmode', 'full');
     //        $this->setVar('openwysiwyg_width', '400');
     //        $this->setVar('openwysiwyg_height', '300');
     //        $this->setVar('nicedit_fullpanel', 0);
     // nicedit
     $this->setVar('nicedit_xhtml', 0);
     // yui
     $this->setVar('yui_type', 'Simple');
     $this->setVar('yui_width', 'auto');
     $this->setVar('yui_height', '300');
     $this->setVar('yui_dombar', true);
     $this->setVar('yui_animate', true);
     $this->setVar('yui_collapse', true);
     // markitup
     $this->setVar('markitup_width', '650px');
     $this->setVar('markitup_height', '400px');
     // TinyMCE
     $this->setVar('tinymce_language', 'en');
     $this->setVar('tinymce_style', 'modules/Scribite/style/tinymce/style.css');
     $this->setVar('tinymce_theme', 'advanced');
     $this->setVar('tinymce_width', '75%');
     $this->setVar('tinymce_height', '400');
     $this->setVar('tinymce_dateformat', '%Y-%m-%d');
     $this->setVar('tinymce_timeformat', '%H:%M:%S');
     $this->setVar('tinymce_activeplugins', '');
     // ckeditor
     $this->setVar('ckeditor_language', 'en');
     $this->setVar('ckeditor_barmode', 'Full');
     $this->setVar('ckeditor_width', '"70%"');
     $this->setVar('ckeditor_height', '300');
     // set database module defaults
     $record = $this->getDefaultModuleConfig();
     DBUtil::insertObjectArray($record, 'scribite', 'mid');
 }
开发者ID:rmaiwald,项目名称:Scribite,代码行数:51,代码来源:Installer.php

示例7: upgrade113XTablesTo220Tables


//.........这里部分代码省略.........
        $obaColumn = $dbinfoSystem['objectdata_attributes_column'];

        $limitNumRows = 100;
        $limitOffset = 0;
        $updated = true;
        $userCount = DBUtil::selectObjectCount('users_temp');
        // Pass through the users_temp table in chunks of 100
        //  * ensure unames and email addresses are lower case,
        while ($limitOffset < $userCount) {
            $userTempArray = DBUtil::selectObjectArray('users_temp', '', '', $limitOffset, $limitNumRows, '', null, null,
                array('tid', 'type', 'uname', 'email', 'pass', 'hash_method', 'dynamics', 'comment'));
            $userArray = array();
            if (!empty($userTempArray) && is_array($userTempArray)) {
                foreach ($userTempArray as $key => $userTempOpj) {
                    // type == 1: User registration pending approval (moderation)
                    if ($userTempArray[$key]['type'] == 1) {
                        $userObj = array();

                        // Ensure uname and email are lower case
                        $userObj['uname'] = mb_strtolower($userTempArray[$key]['uname']);
                        $userObj['email'] = mb_strtolower($userTempArray[$key]['email']);

                        // Convert pass to salted pass with embedded hash method, leave salt blank
                        $userObj['pass'] = $userTempArray[$key]['hash_method'] . '$$' . $userTempArray[$key]['pass'];

                        $userObj['approved_by'] = 0;
                        $userObj['activated'] = Users_Constant::ACTIVATED_PENDING_REG;

                        if (!empty($userTempArray[$key]['dynamics'])) {
                            $userObj['__ATTRIBUTES__'] = unserialize($userTempArray[$key]['dynamics']);
                        } else {
                            $userObj['__ATTRIBUTES__'] = array();
                        }

                        if (isset($userObj['dynamics']) && !empty($userObj['dynamics'])) {
                            if (DataUtil::is_serialized($userObj['dynamics'])) {
                                $dynamics = @unserialize($userObj['dynamics']);
                                if (!empty($dynamics) && is_array($dynamics)) {
                                    foreach ($dynamics as $key => $value) {
                                        $userObj['__ATTRIBUTES__'][$key] = $value;
                                    }
                                }
                            }
                        }

                        $userObj['__ATTRIBUTES__']['_Users_isVerified'] = 0;

                        if ($legalModuleActive) {
                            $userRegDateTime = new DateTime($userArray[$key]['user_regdate'], new DateTimeZone('UTC'));
                            $policyDateTimeStr = $userRegDateTime->format(DATE_ISO8601);

                            if ($termsOfUseActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_termsOfUseAccepted'] = $policyDateTimeStr;
                            }
                            if ($privacyPolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_privacyPolicyAccepted'] = $policyDateTimeStr;
                            }
                            if ($agePolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_agePolicyConfirmed'] = $policyDateTimeStr;
                            }
                        }

                        $userArray[] = $userObj;
                    } else {
                        throw new Zikula_Exception_Fatal($this->__f('Unknown users_temp record type: %1$s', array($userTempArray[$key]['type'])));
                    }
                }
            }
            if (!DBUtil::insertObjectArray($userArray, 'users', 'uid', false)) {
                $updated = false;
                break;
            }
            $limitOffset += $limitNumRows;
        }
        if (!$updated) {
            return false;
        }

        // Done upgrading. Let's lose some old fields and tables we no longer need.
        DBUtil::dropColumn('users', $usersOldFieldsDB);
        DBUtil::dropTable('users_temp');

        // Reset the system tables to the new table definitons, so the rest of the
        // system upgrade goes smoothly.
        $dbinfoSystem = $serviceManager['dbtables'];
        foreach ($dbinfo113X as $key => $value) {
            unset($dbinfoSystem[$key]);
        }
        foreach ($dbinfo220 as $key => $value) {
            $dbinfoSystem[$key] = $value;
        }
        $serviceManager['dbtables'] = $dbinfoSystem;

        // Update users table for data type change of activated field.
        if (!DBUtil::changeTable('users')) {
            return false;
        }

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

示例8: importGtafEntities


//.........这里部分代码省略.........
                $caps = array(
                    'gtafEntityId'   => 'gtafEntityId',
                    'nom'            => 'nom',
                    'tipus'          => 'tipus',
                    'gtafGroupId'    => 'gtafGroupId'
                );
                $caps_man = $caps;
                $taula = 'cataleg_gtafEntities';
                $mes = "Importació d'entitats-gtaf";
                $field_id = 'gtafEntityId';
            } else {
                $caps = array(
                    'gtafGroupId'   => 'gtafGroupId',
                    'nom'           => 'nom',
                    'resp_uid'      => 'resp_uid'
                );
                $caps_man = array(
                    'gtafGroupId'   => 'gtafGroupId',
                    'nom'           => 'nom'
                );
                $taula = 'cataleg_gtafGroups';
                $mes = "Importació de grups d'entitats-gtaf";
                $field_id = 'gtafGroupId';
            }
            // 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 {
                while (!feof($file_handle)) {
                    $line = fgetcsv($file_handle, 1024, ';', '"');
                    if ($line != '') {
                        $lines[] = $line;
                    }
                }
                fclose($file_handle);
                //
                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 {
                                $import[] = array_combine($lines[0], $line);
                                $import_id[] = $line[0];
                        }
                    } else {
                        $difs = array_diff($line, $caps);
                        $difs2 = array_diff($caps_man,$line);
                        if (count($line) != count(array_unique($line))) {
                            $importResults .= $this->__("<div>La capçalera del csv té columnes repetides.</div>");
                        } elseif (!in_array($field_id, $line)) {
                            $importResults .= $this->__("<div>Falta el camp obligatori de la clau primària (id).</div>");
                        } elseif ($line[0] != $field_id) {
                            $importResults .= $this->__("<div>El camp obligatori de la clau primària (id) ha d'ocupar el primer lloc.</div>");
                        } elseif (!empty($difs2)) {
                            $importResults .= $this->__("<div>Falten camps obligatoris.</div>");
                        } elseif (!empty($difs)) {
                            $importResults .= $this->__("div>El csv té camps incorrectes.</div>");
                        }
                    }
                }
                if (count($import_id) != count(array_unique($import_id))) $importResults .= $this->__("<div>El fitxer té alguna id repetida.</div>"); 
            }
            
            if ($importResults == '') {
                $old_reg = DBUtil::selectObjectCount($taula);
                DBUtil::deleteWhere($taula);
                $inserts = count($import);
                DBUtil::insertObjectArray($import, $taula);
                $this->registerStatus($mes);
                $this->registerStatus($this->__('La importació s\'ha realitzat correctament'));
                $this->registerStatus($this->__('Registres antics: ' . $old_reg . ' - Registres actuals: ' . $inserts));
                return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
            } else {
                $this->view->assign('case',$case);
                $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_importGtafEntities.tpl');
            }
        } elseif ($confirmed == 1){
            // shows the form
            $case = $this->request->query->get('case',false);
            $this->view->assign('case',$case);
            $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_importGtafEntities.tpl');
        } else {
            LogUtil::registerError($this->__('La petició no és vàlida'));
            return system::redirect(ModUtil::url('Cataleg', 'admin', 'gtafEntitiesGest'));
        }
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Admin.php

示例9: copyContentOfPageToPage

    public function copyContentOfPageToPage($args)
    {
        $fromPage = (int) $args['fromPageId'];
        $toPage = (int) $args['toPageId'];
        if ($fromPage <= 0 || $toPage <= 0) {
            return false;
        }
        $cloneTranslation = isset($args['cloneTranslation']) ? $args['cloneTranslation'] : true;

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

        $content = $this->GetSimplePageContent(array('pageId' => $fromPage));
        for ($i = 0; $i < count($content); $i++) {
            $contentData = $content[$i];
            $contentData['id'] = null;
            $contentData['pageId'] = $toPage;
            DBUtil::insertObject($contentData, 'content_content', 'id');
            $id = $contentData['id']; // ID of object we just inserted

            if ($cloneTranslation) {
                $translations = DBUtil::selectObjectArray('content_translatedcontent', "$translatedColumn[contentId] = $id");
                if (!($translations === false) && count($translations) > 0) {
                    foreach ($translations as &$t) {
                        $t['contentId'] = $id;
                    }
                    DBUtil::insertObjectArray($translations, 'content_translatedcontent', 'contentId', true);
                }
            }
            $searchData = DBUtil::selectObjectByID('content_searchable', $id, 'contentId');
            if ($searchData) {
                $searchData['contentId'] = $id;
                DBUtil::insertObject($searchData, 'content_searchable');
            }
        }
        Content_Util::clearCache();
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:38,代码来源:Content.php

示例10: createImport

    /**
     * Add new user accounts from the import process.
     *
     * Parameters passed in the $args array:
     * -------------------------------------
     * array $args['importvalues'] An array of information used to create new user records. Each element of the
     *                                  array should represent the minimum information to create a user record, including
     *                                  'uname', 'email', 'pass', etc.
     *
     * @param array $args All parameters passed to this function.
     *
     * @return bool True on success; false otherwise.
     */
    public function createImport($args)
    {
        // Need add access to call this function
        if (!SecurityUtil::checkPermission("{$this->name}::", '::', ACCESS_ADD)) {
            return false;
        }

        $importValues = $args['importvalues'];

        if (empty($importValues)) {
            return false;
        }

        // Prepare arrays.
        $usersArray = array();
        foreach ($importValues as $key => $value) {
            $usersArray[] = $value['uname'];
            if (!$value['activated']) {
                $importValues[$key]['activated'] = Users_Constant::ACTIVATED_PENDING_REG;
            }
        }

        $importValuesDB = $importValues;
        foreach ($importValuesDB as $key => $value) {
            $importValuesDB[$key]['pass'] = UserUtil::getHashedPassword($importValuesDB[$key]['pass']);
        }

        // execute sql to create users
        $result = DBUtil::insertObjectArray($importValuesDB, 'users', 'uid');
        if (!$result) {
            return false;
        }

        // get users. We need the users identities set them into their groups
        $usersInDB = ModUtil::apiFunc($this->name, 'admin', 'checkMultipleExistence',
                                      array('valuesarray' => $usersArray,
                                            'key' => 'uname'));
        if (!$usersInDB) {
            $this->registerError($this->__(
                'Error! The users have been created but something has failed trying to get them from the database. '
                . 'Now all these users do not have group.'));

            return false;
        }

        // get available groups
        $allGroups = ModUtil::apiFunc('Groups', 'user', 'getAll');

        // create an array with the groups identities where the user can add other users
        $allGroupsArray = array();
        foreach ($allGroups as $group) {
            if (SecurityUtil::checkPermission('Groups::', $group['name'] . '::' . $group['gid'], ACCESS_EDIT)) {
                $allGroupsArray[] = $group['gid'];
            }
        }

        $groups = array();
        // construct a sql statement with all the inserts to reduce SQL queries
        foreach ($importValues as $value) {
            $groupsArray = explode('|', $value['groups']);
            foreach ($groupsArray as $group) {
                $groups[] = array('uid' => $usersInDB[$value['uname']]['uid'], 'gid' => $group);
            }
        }

        // execute sql to create users
        $result = DBUtil::insertObjectArray($groups, 'group_membership', 'gid', true);
        if (!$result) {
            $this->registerError($this->__('Error! The users have been created but something has failed while trying to add the users to their groups. These users are not assigned to a group.'));

            return false;
        }

        // check if module Mailer is active
        $modinfo = ModUtil::getInfoFromName('Mailer');
        if ($modinfo['state'] == ModUtil::TYPE_SYSTEM) {
            $sitename  = System::getVar('sitename');
            $siteurl   = System::getBaseUrl();

            $view = Zikula_View::getInstance($this->name, false);
            $view->assign('sitename', $sitename);
            $view->assign('siteurl', $siteurl);

            foreach ($importValues as $value) {
                if ($value['activated'] != Users_Constant::ACTIVATED_PENDING_REG) {
                    $createEvent = new Zikula_Event('user.account.create', $value);
                    $this->eventManager->notify($createEvent);
//.........这里部分代码省略.........
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Admin.php

示例11: importaTaula

    /**
     * Importa, a la taula seleccionada, les dades d'un csv
     * 
     * Els registres existents s'actualitzen i els nous s'inserten
     * 
     * @return void (carrega la plantilla per importar/exportar taules)
     */
    public function importaTaula() {

        // Security check 
        $this->checkCsrfToken();
        $this->throwForbiddenUnless(SecurityUtil::checkPermission('Llicencies::', '::', ACCESS_ADMIN));
        if ($this->request->isPost()) {
            $taula = $this->request->request->get('taula_imp', false);
            $importFile = $this->request->files->get('importFile', null);
        }

        if (is_null($importFile)) {
            LogUtil::registerError(__('No s\'ha pogut processar l\'arxiu. Probablement supera la mida màxima.'));
        } else {
            $import = new CsvImporter($importFile['tmp_name'], true, null,';');

            $header = $import->getHeader();

            $check = ModUtil::apiFunc($this->name, 'admin', 'checkCSV', array('dbTable' => $taula, 'csvHeader' => $header));

            // Comprovar capçaleres del csv
            if (!$check['correcte']) {
                // Errades a l'arxiu CSV
                LogUtil::registerError($check['msg']);
            } else {
                // Obtenció del contingut del fitxer csv
                $data = $import->get();
                // Obtenció de les dades de la taula
                $tContent = DBUtil::selectFieldArray($taula, $check['clau']);
                // echo '<pre> tContent: ';print_r($tContent); echo '</pre>';

                LogUtil::registerStatus($check['msg']);
                //LogUtil::registerStatus(print_r($data,true));
                $update = array();
                $insert = array();
                foreach ($data as $row => $record) {
                    if (in_array($record[$check['clau']], $tContent)) {
                        $update[] = $record;
                    } else {
                        $insert[] = $record;
                    }
                }

                $inserts = count($insert);
                $updates = count($update);
                $ins = true;
                $upd = true;
                if ($inserts) {
                    $ins = (DBUtil::insertObjectArray($insert, $taula) && ($inserts));
                    $mi = __('S\'han afegit ' . $inserts . ' registres.');
                }
                if ($updates) {
                    $upd = (DBUtil::updateObjectArray($update, $taula, $check['clau'])) && ($updates);
                    $mu = __('S\'han actualitzat ' . $updates . ' registres.');
                }
                if (($ins) && ($upd))
                    LogUtil::registerStatus(__('La importació de dades cap a la taula:' . $taula . ' s\'ha realitzat correctament.') . " " . $mi . " " . $mu);
                else
                    LogUtil::registerError(__('No s\'han pogut modificar totes les dades de la taula: ' . $taula));
            }
        }
        $this->redirect(ModUtil::url('llicencies', 'admin', 'ieTables'));
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:69,代码来源:Admin.php

示例12: cloneContentAdditions

 private function cloneContentAdditions($oldContentId, $newContentId, $cloneTranslation)
 {
     $currentLanguage = ZLanguage::getLanguageCode();
     $dbtables = DBUtil::getTables();
     $contentSearchColumn = $dbtables['content_searchable_column'];
     $where = $contentSearchColumn['contentId'] . ' = ' . $oldContentId . ' AND ' . $contentSearchColumn['language'] . ' IN (\'' . DataUtil::formatForStore($currentLanguage) . '\', \'\')';
     $searchableData = DBUtil::selectObjectArray('content_searchable', $where);
     if (count($searchableData) > 0) {
         foreach ($searchableData as &$s) {
             $s['contentId'] = $newContentId;
         }
         DBUtil::insertObjectArray($searchableData, 'content_searchable', 'searchableId');
     }
     if (!$cloneTranslation) {
         return;
     }
     $translatedColumn = $dbtables['content_translatedcontent_column'];
     $translations = DBUtil::selectObjectArray('content_translatedcontent', "{$translatedColumn['contentId']} = {$oldContentId}");
     if (count($translations) < 1) {
         return;
     }
     foreach ($translations as &$t) {
         $t['contentId'] = $newContentId;
     }
     DBUtil::insertObjectArray($translations, 'content_translatedcontent', 'contentId', true);
     $where = $contentSearchColumn['contentId'] . ' = ' . $oldContentId . ' AND ' . $contentSearchColumn['language'] . ' NOT IN (\'' . DataUtil::formatForStore($currentLanguage) . '\', \'\')';
     $searchableData = DBUtil::selectObjectArray('content_searchable', $where);
     if (count($searchableData) > 0) {
         foreach ($searchableData as &$s) {
             $s['contentId'] = $newContentId;
         }
         DBUtil::insertObjectArray($searchableData, 'content_searchable', 'searchableId', true);
     }
 }
开发者ID:robbrandt,项目名称:Content,代码行数:34,代码来源:Content.php


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