/** * Generate a fake member account * * @param array $values Generator form values * @return string Progress message */ public function generateSingle(array $values) { /* Create Member */ $member = new \IPS\Member(); $member->name = $values['__generator_message'] = $this->generator->userName(); $password = isset($values['password']) ? $member->name : $this->generator->password(); $member->email = $this->generator->email(); $member->members_pass_salt = $member->generateSalt(); $member->members_pass_hash = $member->encryptedPassword($password); $member->allow_admin_mails = 0; $member->member_group_id = $values['member_group']; $member->members_bitoptions['view_sigs'] = TRUE; if ($values['profile_photo']) { $photoUrl = new \IPS\Http\Url($this->generator->photoUrl()); $response = $photoUrl->request()->get(); $filename = preg_replace("/(.+?)(\\?|\$)/", "\$1", mb_substr((string) $photoUrl, mb_strrpos((string) $photoUrl, '/') + 1)); $photoFile = \IPS\File::create('core_Profile', $filename, $response); $member->pp_photo_type = 'custom'; $member->pp_main_photo = NULL; $member->pp_main_photo = (string) $photoFile; $thumbnail = $photoFile->thumbnail('core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE, TRUE); $member->pp_thumb_photo = (string) $thumbnail; } $member->save(); $this->map(static::$activeRecordClass, $member->member_id); return \IPS\Member::loggedIn()->language()->addToStack(static::$message, true, array('sprintf' => array($member->name))); }
/** * [Node] Format form values from add/edit form for save * * @param array $values Values from the form * @return array */ public function processForm($values) { if (!$this->id) { $this->save(); \IPS\File::claimAttachments('custom-markers-new', $this->id); } if (isset($values['marker_parent_id']) and (!empty($values['marker_parent_id']) or $values['marker_parent_id'] === 0)) { $this->parent_id = $values['marker_parent_id']->id; } foreach (array('marker_description', 'marker_name', 'marker_location', 'marker_lat', 'marker_lon') as $val) { if (isset($values[$val])) { $key = str_replace('marker_', '', $val); $this->{$key} = $values[$val]; } } parent::processForm($values); }