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


PHP settings::saveDefaultSettings方法代码示例

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


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

示例1: addUser

 public static function addUser($frm_submitted)
 {
     global $obj_db;
     $str_query = 'SELECT * FROM users WHERE username = "' . (!empty($frm_submitted['username']) ? $frm_submitted['username'] : $frm_submitted['email']) . '"';
     $obj_result = mysqli_query($obj_db, $str_query);
     $arr_user = mysqli_fetch_array($obj_result, MYSQLI_ASSOC);
     if ($obj_result !== false && !empty($arr_user) && $arr_user !== false) {
         if (SHOW_USERNAME_IN_FORM && !empty($frm_submitted['username'])) {
             return 'Username already exists';
         } else {
             return 'Username (emailaddress) already exists';
         }
     }
     $str_query = 'SELECT * FROM users WHERE email = "' . $frm_submitted['email'] . '"';
     $obj_result2 = mysqli_query($obj_db, $str_query);
     $arr_user2 = mysqli_fetch_array($obj_result2, MYSQLI_ASSOC);
     if ($obj_result2 !== false && !empty($arr_user2) && $arr_user2 !== false) {
         return 'Emailaddress already exists';
     }
     // generate random password
     $password = Utils::generatePassword();
     $bln_insert = false;
     if (User::isSuperAdmin()) {
         $usertype = 'admin';
         $admin_group = $_SESSION['calendar-uid']['uid'];
         $bln_insert = true;
     } else {
         if (User::isAdmin()) {
             $usertype = 'user';
             $admin_group = $_SESSION['calendar-uid']['uid'];
             $bln_insert = true;
         }
     }
     if ($bln_insert) {
         $send_activation_mail = Settings::getSetting('send_activation_mail', $admin_group);
         $bln_send_activation_mail = $send_activation_mail == 'on';
         $str_query = 'INSERT INTO users ( `firstname` ,`infix` ,`lastname` ,`username`,`password` ,`email` ,`registration_date` ,' . '`birth_date`, `active`, `ip`, `country`, `country_code`, `usertype`, `admin_group`) VALUES (' . '"' . $frm_submitted['firstname'] . '",' . '"' . $frm_submitted['infix'] . '",' . '"' . $frm_submitted['lastname'] . '",' . '"' . (isset($frm_submitted['username']) && !empty($frm_submitted['username']) ? $frm_submitted['username'] : $frm_submitted['email']) . '",' . '"' . self::getPasswordHashcode($password) . '",' . '"' . $frm_submitted['email'] . '",' . 'NOW(),' . '"",' . ($bln_send_activation_mail ? '0, ' : '1,') . '"",' . '"",' . '"",' . '"' . $usertype . '",' . $admin_group . ')';
         $res = mysqli_query($obj_db, $str_query);
         $int_user_id = mysqli_insert_id($obj_db);
         $hash_code = self::getUserHashcode($int_user_id);
         if ($bln_send_activation_mail) {
             $str_query = 'UPDATE `users` SET user_hash = "' . $hash_code . '" ' . ' WHERE `user_id` = ' . $int_user_id;
             $res2 = mysqli_query($obj_db, $str_query);
         }
         if ($res !== false) {
             $admin_mail = '';
             if (defined('ADMIN_EMAILADDRESS')) {
                 $admin_mail = ADMIN_EMAILADDRESS;
             }
             if (User::isSuperAdmin()) {
                 $bln_send = Utils::sendMail('add_admin', $frm_submitted['email'], $password, $frm_submitted);
                 if ($frm_submitted['copy_to_admin'] && !empty($admin_mail)) {
                     Utils::sendMail('copy_to_admin_admin_created', $admin_mail, $password, $frm_submitted);
                 }
                 // insert default settings
                 settings::saveDefaultSettings($int_user_id);
             } else {
                 if (User::isAdmin()) {
                     $bln_send = Utils::sendMail('add_user', $frm_submitted['email'], $password, $frm_submitted, $int_user_id, $hash_code);
                     if ($frm_submitted['copy_to_admin'] && !empty($admin_mail)) {
                         Utils::sendMail('copy_to_admin_user_created', $admin_mail, $password, $frm_submitted);
                     }
                 }
             }
             if ($bln_send) {
                 if (defined('SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER') && SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER) {
                     return array('insert' => true, 'mail' => 'send', 'password' => $password);
                 } else {
                     return array('insert' => true, 'mail' => 'send');
                 }
             } else {
                 if (defined('SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER') && SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER) {
                     return array('insert' => true, 'mail' => 'notsend', 'password' => $password);
                 } else {
                     return array('insert' => true, 'mail' => 'notsend');
                 }
             }
         } else {
             return array('insert' => false, 'mail' => 'notsend');
         }
     } else {
         return array('insert' => false, 'mail' => 'notsend', 'error' => 'You have no admin rights!');
     }
 }
开发者ID:ramant15,项目名称:ektimo,代码行数:84,代码来源:users.class.php


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