/** * Make the current file the default for a record. Note that the * is_image property must be true. * * @return $this */ public function makeDefault() { if ($this->is_image) { $response = $this->mp->updateDefaultImage($this); $this->guid = $response[0]; $this->message = $response[2]; } else { throw new MinistryPlatformException("File must be an image. Cannot make a non-image the default."); } return $this; }
/** * Authenticate a uniquely matched user. * * As long as there is exactly one match *and* that match * has a valid User Account, go ahead and process * authentication for them. * * @return MinistryPlatform\Blackpulp\User */ public function getUserAndAuthenticate() { if ($this->getNumberOfMatches() === 1) { $user_data = $this->matches->getTable(0); if (isset($user_data['User_GUID']) && $user_data['User_GUID'] > 0) { return $this->mp->authenticateGuid($user_data['User_GUID']); } else { throw new MinistryPlatformException("The matched contact has no User Account."); } } else { throw new MinistryPlatformException("A single user was not returned. " . "Review the getMatches() method to determine your next steps."); } }
/** * Setter for the user info * * @return self */ protected function setInfo() { $this->info = $this->mp->getUserInfo(); return $this; }
/** * Update $this->config by fetching fresh data from MinistryPlatform. * * @return Config */ public function updateConfigurationSettings() { $config = $this->mp->storedProcedure($this->stored_procedure, ['ApplicationCode' => $this->application_code]); $this->config = $config; return $this; }
/** * Error handling for Stored Procedure API calls. * * Check to see if the API call returned an error. If so, throw * an exception and prevent things form continuing on. */ protected function checkForErrors() { if (isset($this->result->NewDataSet->Table1->ErrorMessage)) { $msg = (string) $this->result->NewDataSet->Table1->ErrorMessage; $error = MinistryPlatform::SplitToArray($msg); throw new MinistryPlatformException($error[2]); } }