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


PHP MemberModel::save方法代码示例

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


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

示例1: addMember

 public static function addMember($strFirstname, $strLastname, $strUid, $strEmail, $strUsername, $arrGroups, $strLanguage)
 {
     $objMember = new \MemberModel();
     // store randomized password, so contao will always trigger the checkCredentials hook
     $time = time();
     $objMember->tstamp = $time;
     $objMember->dateAdded = $time;
     $objMember->firstname = $strFirstname;
     $objMember->lastname = $strLastname;
     $objMember->ldapUid = $strUid;
     $objMember->email = $strEmail;
     $objMember->login = true;
     $objMember->username = $strUsername;
     $objMember->password = md5($time . $strUsername);
     $objMember->groups = serialize($arrGroups);
     $objMember->language = $strLanguage;
     $objMember->save();
     if (isset($GLOBALS['TL_HOOKS']['ldapAddMember']) && is_array($GLOBALS['TL_HOOKS']['ldapAddMember'])) {
         foreach ($GLOBALS['TL_HOOKS']['ldapAddMember'] as $callback) {
             $objMember = call_user_func(array($callback[0], $callback[1]), $objMember);
         }
     }
     $objMember->save();
 }
开发者ID:heimrichhannot,项目名称:contao-ldap,代码行数:24,代码来源:LdapMemberModel.php

示例2: createNewUser

 /**
  * Create a new user and redirect
  * @param array
  */
 protected function createNewUser($arrData)
 {
     $arrData['tstamp'] = time();
     $arrData['login'] = $this->reg_allowLogin;
     $arrData['activation'] = md5(uniqid(mt_rand(), true));
     $arrData['dateAdded'] = $arrData['tstamp'];
     // Set default groups
     if (!array_key_exists('groups', $arrData)) {
         $arrData['groups'] = $this->reg_groups;
     }
     // Disable account
     $arrData['disable'] = 1;
     // Send activation e-mail
     if ($this->reg_activate) {
         $arrChunks = array();
         $strConfirmation = $this->reg_text;
         preg_match_all('/##[^#]+##/i', $strConfirmation, $arrChunks);
         foreach ($arrChunks[0] as $strChunk) {
             $strKey = substr($strChunk, 2, -2);
             switch ($strKey) {
                 case 'domain':
                     $strConfirmation = str_replace($strChunk, \Environment::get('host'), $strConfirmation);
                     break;
                 case 'link':
                     $strConfirmation = str_replace($strChunk, \Environment::get('base') . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $arrData['activation'], $strConfirmation);
                     break;
                     // HOOK: support newsletter subscriptions
                 // HOOK: support newsletter subscriptions
                 case 'channel':
                 case 'channels':
                     if (!in_array('newsletter', $this->Config->getActiveModules())) {
                         break;
                     }
                     // Make sure newsletter is an array
                     if (!is_array($arrData['newsletter'])) {
                         if ($arrData['newsletter'] != '') {
                             $arrData['newsletter'] = array($arrData['newsletter']);
                         } else {
                             $arrData['newsletter'] = array();
                         }
                     }
                     // Replace the wildcard
                     if (!empty($arrData['newsletter'])) {
                         $objChannels = \NewsletterChannelModel::findByIds($arrData['newsletter']);
                         if ($objChannels !== null) {
                             $strConfirmation = str_replace($strChunk, implode("\n", $objChannels->fetchEach('title')), $strConfirmation);
                         }
                     } else {
                         $strConfirmation = str_replace($strChunk, '', $strConfirmation);
                     }
                     break;
                 default:
                     $strConfirmation = str_replace($strChunk, $arrData[$strKey], $strConfirmation);
                     break;
             }
         }
         $objEmail = new \Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['emailSubject'], \Environment::get('host'));
         $objEmail->text = $strConfirmation;
         $objEmail->sendTo($arrData['email']);
     }
     // Make sure newsletter is an array
     if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
         $arrData['newsletter'] = array($arrData['newsletter']);
     }
     // Create the user
     $objNewUser = new \MemberModel();
     $objNewUser->setRow($arrData);
     $objNewUser->save();
     $insertId = $objNewUser->id;
     // Assign home directory
     if ($this->reg_assignDir && is_dir(TL_ROOT . '/' . $this->reg_homeDir)) {
         $this->import('Files');
         $strUserDir = $arrData['username'] ?: 'user_' . $insertId;
         // Add the user ID if the directory exists
         if (is_dir(TL_ROOT . '/' . $this->reg_homeDir . '/' . $strUserDir)) {
             $strUserDir .= '_' . $insertId;
         }
         new \Folder($this->reg_homeDir . '/' . $strUserDir);
         $objNewUser->assignDir = 1;
         $objNewUser->homeDir = $this->reg_homeDir . '/' . $strUserDir;
         $objNewUser->save();
     }
     // HOOK: send insert ID and user data
     if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
         foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($insertId, $arrData, $this);
         }
     }
     // Inform admin if no activation link is sent
     if (!$this->reg_activate) {
         $this->sendAdminNotification($insertId, $arrData);
     }
//.........这里部分代码省略.........
开发者ID:rikaix,项目名称:core,代码行数:101,代码来源:ModuleRegistration.php

示例3: createNewUser

 /**
  * Create a new user based on the given data
  * @param array
  * @return boolean
  */
 protected function createNewUser($arrProfile)
 {
     \System::loadLanguageFile('tl_member');
     $this->loadDataContainer('tl_member');
     // Call onload_callback (e.g. to check permissions)
     if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'])) {
         foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback) {
             if (is_array($callback)) {
                 $this->import($callback[0]);
                 $this->{$callback}[0]->{$callback}[1]();
             }
         }
     }
     $time = time();
     $arrData = array('tstamp' => $time, 'dateAdded' => $time, 'firstname' => $arrProfile['first_name'], 'lastname' => $arrProfile['last_name'], 'gender' => $arrProfile['gender'], 'email' => $arrProfile['email'], 'login' => 1, 'username' => 'fb_' . $arrProfile['id'], 'fblogin' => $arrProfile['id'], 'groups' => $this->reg_groups);
     $blnHasError = false;
     // Check the data
     foreach ($arrData as $k => $v) {
         if (!isset($GLOBALS['TL_DCA']['tl_member']['fields'][$k])) {
             unset($arrData[$k]);
             continue;
         }
         $arrField = $GLOBALS['TL_DCA']['tl_member']['fields'][$k];
         // Make sure that unique fields are unique
         if ($arrField['eval']['unique'] && $v != '' && !$this->Database->isUniqueValue('tl_member', $k, $v)) {
             $blnHasError = true;
             \Message::addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrField['label'][0] ?: $k));
             continue;
         }
         // Save callback
         if (is_array($arrField['save_callback'])) {
             foreach ($arrField['save_callback'] as $callback) {
                 $this->import($callback[0]);
                 try {
                     $v = $this->{$callback}[0]->{$callback}[1]($v, null);
                 } catch (\Exception $e) {
                     $blnHasError = true;
                     \Message::addError($e->getMessage());
                 }
             }
             $arrData[$k] = $v;
         }
     }
     // HOOK: parse data before it is saved
     if (isset($GLOBALS['TL_HOOKS']['validateFacebookLogin']) && is_array($GLOBALS['TL_HOOKS']['validateFacebookLogin'])) {
         foreach ($GLOBALS['TL_HOOKS']['validateFacebookLogin'] as $callback) {
             $this->import($callback[0]);
             try {
                 $arrData = $this->{$callback}[0]->{$callback}[1]($arrData, $arrProfile);
             } catch (\Exception $e) {
                 $blnHasError = true;
                 \Message::addError($e->getMessage());
             }
         }
     }
     // Return false if there is an error
     if ($blnHasError) {
         return false;
     }
     $objNewUser = new \MemberModel();
     $objNewUser->setRow($arrData);
     $objNewUser->save();
     // Assign home directory
     if ($this->reg_assignDir) {
         $objHomeDir = \FilesModel::findByUuid($this->reg_homeDir);
         if ($objHomeDir !== null) {
             $this->import('Files');
             $strUserDir = standardize($arrData['username']) ?: 'user_' . $objNewUser->id;
             // Add the user ID if the directory exists
             while (is_dir(TL_ROOT . '/' . $objHomeDir->path . '/' . $strUserDir)) {
                 $strUserDir .= '_' . $objNewUser->id;
             }
             // Create the user folder
             new \Folder($objHomeDir->path . '/' . $strUserDir);
             $objUserDir = \FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);
             // Save the folder ID
             $objNewUser->assignDir = 1;
             $objNewUser->homeDir = $objUserDir->uuid;
             $objNewUser->save();
         }
     }
     $insertId = $objNewUser->id;
     // HOOK: send insert ID and user data
     if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
         foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($insertId, $arrData, $this, $arrProfile);
         }
     }
     return true;
 }
开发者ID:codefog,项目名称:contao-facebook_login,代码行数:96,代码来源:ModuleFacebookLogin.php

示例4: createNewUser

 /**
  * Create a new user and redirect
  *
  * @param array $arrData
  */
 protected function createNewUser($arrData)
 {
     $arrData['tstamp'] = time();
     $arrData['login'] = $this->reg_allowLogin;
     $arrData['activation'] = md5(uniqid(mt_rand(), true));
     $arrData['dateAdded'] = $arrData['tstamp'];
     // Set default groups
     if (!array_key_exists('groups', $arrData)) {
         $arrData['groups'] = $this->reg_groups;
     }
     // Disable account
     $arrData['disable'] = 1;
     // Send activation e-mail
     if ($this->reg_activate) {
         // Prepare the simple token data
         $arrTokenData = $arrData;
         $arrTokenData['domain'] = \Idna::decode(\Environment::get('host'));
         $arrTokenData['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . (\Config::get('disableAlias') || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $arrData['activation'];
         $arrTokenData['channels'] = '';
         if (in_array('newsletter', \ModuleLoader::getActive())) {
             // Make sure newsletter is an array
             if (!is_array($arrData['newsletter'])) {
                 if ($arrData['newsletter'] != '') {
                     $arrData['newsletter'] = array($arrData['newsletter']);
                 } else {
                     $arrData['newsletter'] = array();
                 }
             }
             // Replace the wildcard
             if (!empty($arrData['newsletter'])) {
                 $objChannels = \NewsletterChannelModel::findByIds($arrData['newsletter']);
                 if ($objChannels !== null) {
                     $arrTokenData['channels'] = implode("\n", $objChannels->fetchEach('title'));
                 }
             }
         }
         // Backwards compatibility
         $arrTokenData['channel'] = $arrTokenData['channels'];
         $objEmail = new \Email();
         $objEmail->from = $GLOBALS['TL_ADMIN_EMAIL'];
         $objEmail->fromName = $GLOBALS['TL_ADMIN_NAME'];
         $objEmail->subject = sprintf($GLOBALS['TL_LANG']['MSC']['emailSubject'], \Idna::decode(\Environment::get('host')));
         $objEmail->text = \String::parseSimpleTokens($this->reg_text, $arrTokenData);
         $objEmail->sendTo($arrData['email']);
     }
     // Make sure newsletter is an array
     if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
         $arrData['newsletter'] = array($arrData['newsletter']);
     }
     // Create the user
     $objNewUser = new \MemberModel();
     $objNewUser->setRow($arrData);
     $objNewUser->save();
     // Assign home directory
     if ($this->reg_assignDir) {
         $objHomeDir = \FilesModel::findByUuid($this->reg_homeDir);
         if ($objHomeDir !== null) {
             $this->import('Files');
             $strUserDir = standardize($arrData['username']) ?: 'user_' . $objNewUser->id;
             // Add the user ID if the directory exists
             while (is_dir(TL_ROOT . '/' . $objHomeDir->path . '/' . $strUserDir)) {
                 $strUserDir .= '_' . $objNewUser->id;
             }
             // Create the user folder
             new \Folder($objHomeDir->path . '/' . $strUserDir);
             $objUserDir = \FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);
             // Save the folder ID
             $objNewUser->assignDir = 1;
             $objNewUser->homeDir = $objUserDir->uuid;
             $objNewUser->save();
         }
     }
     // HOOK: send insert ID and user data
     if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
         foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objNewUser->id, $arrData, $this);
         }
     }
     // Create the initial version (see #7816)
     $objVersions = new \Versions('tl_member', $objNewUser->id);
     $objVersions->setUsername($objNewUser->username);
     $objVersions->setUserId(0);
     $objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
     $objVersions->initialize();
     // Inform admin if no activation link is sent
     if (!$this->reg_activate) {
         $this->sendAdminNotification($objNewUser->id, $arrData);
     }
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     $this->reload();
 }
开发者ID:juergen83,项目名称:contao,代码行数:100,代码来源:ModuleRegistration.php

示例5: memberUpdate

 /**
  * 更新部门
  *
  * @param array $data
  * @return boolean
  */
 private function memberUpdate($info)
 {
     $model = new MemberModel();
     $result = $model->find("UserNo = '" . $info["EmployeeId"] . "'");
     if (!$result) {
         return false;
     }
     $data["UserNo"] = $info["EmployeeId"];
     $data["UserName"] = $info["Name"];
     $data["LoginName"] = $info["LoginName"];
     $data["Mobil"] = $info["Mobile"];
     $result = $model->save($data, "ID = " . $result["ID"]);
     return $result;
 }
开发者ID:kenlong,项目名称:example,代码行数:20,代码来源:ControlService.php


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