/** * Checks if invoicing address in basket is complete to meet mandatory requirement * * @return boolean */ public function storeInvoicingDefaultAddress() { $invoicing_fields = array('first_name', 'last_name', 'payer_business_name', 'address_street', 'address_city', 'address_state', 'address_zip', 'address_country', 'contact_phone', 'vat_number'); // Not yet possible since not same reference as CBuser::getUserDataInstance (CBLib bug #5014): $user = Application::User( $this->user_id ); $user = CBuser::getUserDataInstance($this->user_id); $comprofiler = new ComprofilerTable($this->_db); $comprofiler->id = $this->user_id; $profile_prefix = 'cb_subs_inv_'; $anythingToStore = false; foreach ($invoicing_fields as $k) { if ($this->{$k} != '') { $ak = $profile_prefix . $k; $comprofiler->{$ak} = $this->{$k}; $user->{$ak} = $this->{$k}; $anythingToStore = true; } } if ($anythingToStore) { return $comprofiler->store(); } else { return true; } }
/** * Checks if invoicing address in basket is complete to meet mandatory requirement * * @return boolean */ public function storeInvoicingDefaultAddress( ) { $invoicing_fields = array( 'first_name', 'last_name', 'payer_business_name', 'address_street', 'address_city', 'address_state', 'address_zip', 'address_country', 'contact_phone', 'vat_number' ); $comprofiler = new ComprofilerTable( $this->_db ); $comprofiler->id = $this->user_id; $profile_prefix = 'cb_subs_inv_'; $anythingToStore = false; foreach ( $invoicing_fields as $k ) { if ( $this->$k != '' ) { $ak = $profile_prefix . $k; $comprofiler->$ak = $this->$k; $anythingToStore = true; } } if ( $anythingToStore ) { return $comprofiler->store(); } else { return true; } }
/** * Deletes this record (no checks) * * @param int $oid Key id of row to delete (otherwise it's the one of $this) * @param bool $cbUserOnly True: delete CB user only, False: delete CB and CMS user * @return boolean */ public function delete($oid = null, $cbUserOnly = false) { global $_CB_framework, $_PLUGINS; $k = $this->_tbl_key; if ($oid) { $this->{$k} = (int) $oid; } $_PLUGINS->loadPluginGroup('user'); $_PLUGINS->trigger('onBeforeDeleteUser', array($this)); if ($_PLUGINS->is_errors()) { $this->setError($_PLUGINS->getErrorMSG()); return false; } else { deleteAvatar($this->avatar); $reports = new UserReportTable(); $reports->deleteUserReports($this->id); $views = new UserViewTable(); $views->deleteUserViews($this->id); if (!$cbUserOnly) { $cmsUser = $_CB_framework->_getCmsUserObject($this->id); try { $cmsUser->delete($this->id); } catch (\RuntimeException $e) { $this->setError($e->getMessage()); return false; } } if (!parent::delete($oid)) { return false; } $query = 'DELETE' . "\n FROM " . $this->_db->NameQuote('#__session') . "\n WHERE " . $this->_db->NameQuote('userid') . " = " . (int) $this->id; $this->_db->setQuery($query); $this->_db->query(); $_PLUGINS->trigger('onAfterDeleteUser', array($this, true)); } return true; }