本文整理汇总了PHP中AppController::_getComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP AppController::_getComponent方法的具体用法?PHP AppController::_getComponent怎么用?PHP AppController::_getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppController
的用法示例。
在下文中一共展示了AppController::_getComponent方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preview
function preview()
{
$id = $this->_arg('mailing_list');
if (!$id) {
$this->Session->setFlash(sprintf(__('Invalid %s', true), __('mailing list', true)), 'default', array('class' => 'info'));
$this->redirect(array('action' => 'index'));
}
$this->MailingList->contain(array('Affiliate', 'Subscription' => array('conditions' => array('subscribed' => 0))));
$mailingList = $this->MailingList->read(null, $id);
if (!$mailingList) {
$this->Session->setFlash(sprintf(__('Invalid %s', true), __('mailing list', true)), 'default', array('class' => 'info'));
$this->redirect(array('action' => 'index'));
}
$this->Configuration->loadAffiliate($mailingList['MailingList']['affiliate_id']);
$affiliates = $this->_applicableAffiliateIDs(true);
$this->set(compact('mailingList', 'affiliates'));
// Handle the rule controlling mailing list membership
$rule_obj = AppController::_getComponent('Rule', '', $this, true);
if (!$rule_obj->init($mailingList['MailingList']['rule'])) {
$this->Session->setFlash(sprintf(__('Failed to parse the rule: %s', true), $rule_obj->parse_error), 'default', array('class' => 'error'));
$this->redirect(array('action' => 'view', 'mailing_list' => $id));
}
$people = $rule_obj->query($mailingList['MailingList']['affiliate_id']);
if ($people === null) {
$this->Session->setFlash(__('The syntax of the mailing list rule is valid, but it is not possible to build a query which will return the expected results. See the "rules engine" help for suggestions.', true), 'default', array('class' => 'error'));
$this->redirect(array('action' => 'view', 'mailing_list' => $id));
}
if (!empty($people)) {
$unsubscribed_ids = Set::extract('/MailingList/Subscription/person_id', $mailingList);
$people = array_diff($people, $unsubscribed_ids);
$this->paginate = array('Person' => array('conditions' => array('Person.id' => $people), 'contain' => array(), 'fields' => array('Person.id', 'Person.first_name', 'Person.last_name'), 'order' => array('Person.first_name', 'Person.last_name'), 'limit' => 100));
}
$this->set('people', $this->paginate('Person'));
}
示例2: set
function set($one, $two = null)
{
if (array_key_exists('EventType', $one)) {
$this->event_obj = AppController::_getComponent('EventType', $one['EventType']['type']);
}
$data = parent::set($one, $two);
if (array_key_exists('EventType', $one)) {
unset($this->event_obj);
}
return $data;
}
示例3: beforeDelete
function beforeDelete()
{
if (Configure::read('feature.badges')) {
$this->contain(array());
$data = $this->read(null, $this->id);
$badge_obj = AppController::_getComponent('Badge');
if (!$badge_obj->update('team', array('team_id' => $data['TeamsPerson']['team_id'], 'person_id' => $data['TeamsPerson']['person_id'], 'role' => null))) {
return false;
}
}
return true;
}
示例4: beforeValidate
function beforeValidate()
{
if (array_key_exists('schedule_type', $this->data['Division'])) {
$league_obj = AppController::_getComponent('LeagueType', $this->data['Division']['schedule_type']);
$this->validate = array_merge($this->validate, $league_obj->schedulingFieldsValidation());
}
if (!Configure::read('scoring.allstars')) {
unset($this->validate['allstars']);
}
if (!Configure::read('scoring.most_spirited')) {
unset($this->validate['most_spirited']);
}
return true;
}
示例5: _handleRuleSearch
function _handleRuleSearch($params, $url)
{
$affiliates = $this->_applicableAffiliates();
$this->set(compact('url', 'affiliates'));
unset($url['rule']);
// If a rule has been submitted through the form, ignore whatever might be saved in the URL
if (array_key_exists('rule', $params)) {
unset($params['rule64']);
}
if (array_key_exists('rule64', $params)) {
// Base 64 input must have a length that's a multiple of 4, add = to pad it out
while (strlen($params['rule64']) % 4) {
$params['rule64'] .= '=';
}
// Encoding can include + signs, which get converted to spaces. Put them back...
$params['rule64'] = str_replace(' ', '+', $params['rule64']);
// Base 64 decode to recover the original input
$params['rule'] = base64_decode($params['rule64']);
}
if (array_key_exists('rule', $params)) {
// Handle the rule
$rule_obj = AppController::_getComponent('Rule', '', $this, true);
if (!$rule_obj->init($params['rule'])) {
$this->set('error', sprintf(__('Failed to parse the rule: %s', true), $rule_obj->parse_error));
return;
}
if (!array_key_exists('rule64', $params)) {
// Base 64 encode the rule for easy URL manipulation, trim any = from the end
$url['rule64'] = base64_encode($params['rule']);
$url['rule64'] = trim($url['rule64'], '=');
}
$this->set(compact('url', 'params'));
$people = $rule_obj->query($params['affiliate_id']);
if ($people === null) {
$this->set('error', __('The syntax of the rule is valid, but it is not possible to build a query which will return the expected results. See the "rules engine" help for suggestions.', true));
return;
}
if (!empty($people)) {
$conditions = array('Person.id' => $people);
if (array_key_exists('affiliate_id', $params)) {
$conditions[] = array('OR' => array("AffiliatePerson.affiliate_id" => $params['affiliate_id'], 'group_id' => GROUP_ADMIN));
}
if ($this->params['url']['ext'] == 'csv') {
Configure::write('debug', 0);
$user_model = $this->Auth->authenticate->name;
$id_field = $this->Auth->authenticate->primaryKey;
$config = new DATABASE_CONFIG();
$prefix = $this->Auth->authenticate->tablePrefix;
if ($this->Auth->authenticate->useDbConfig != 'default') {
$config_name = $this->Auth->authenticate->useDbConfig;
$config = $config->{$config_name};
$prefix = "{$config['database']}.{$prefix}";
}
$this->set('people', $this->Person->find('all', array('conditions' => $conditions, 'contain' => 'Related', 'fields' => array('DISTINCT Person.id', 'Person.*', "{$user_model}.*"), 'order' => array('Person.last_name', 'Person.first_name', 'Person.id'), 'joins' => array(array('table' => "{$prefix}{$this->Auth->authenticate->useTable}", 'alias' => $this->Auth->authenticate->name, 'type' => 'LEFT', 'foreignKey' => false, 'conditions' => "{$user_model}.{$id_field} = Person.user_id"), array('table' => "{$this->Person->tablePrefix}affiliates_people", 'alias' => 'AffiliatePerson', 'type' => 'LEFT', 'foreignKey' => false, 'conditions' => 'AffiliatePerson.person_id = Person.id'), array('table' => "{$this->Person->tablePrefix}groups_people", 'alias' => 'GroupPerson', 'type' => 'LEFT', 'foreignKey' => false, 'conditions' => 'GroupPerson.person_id = Person.id')))));
$this->set('download_file_name', 'Search results');
$this->render('rule_search');
} else {
$this->_mergePaginationParams();
$this->paginate = array('Person' => array('conditions' => $conditions, 'contain' => array(), 'fields' => array('DISTINCT Person.id', 'Person.first_name', 'Person.last_name'), 'limit' => Configure::read('feature.items_per_page'), 'joins' => array(array('table' => "{$this->Person->tablePrefix}affiliates_people", 'alias' => 'AffiliatePerson', 'type' => 'LEFT', 'foreignKey' => false, 'conditions' => 'AffiliatePerson.person_id = Person.id'), array('table' => "{$this->Person->tablePrefix}groups_people", 'alias' => 'GroupPerson', 'type' => 'LEFT', 'foreignKey' => false, 'conditions' => 'GroupPerson.person_id = Person.id'))));
$this->set('people', $this->paginate('Person'));
}
} else {
$this->set('error', __('No matches found!', true));
}
}
}
示例6: send
function send()
{
$id = $this->_arg('newsletter');
if (!$id) {
$this->Session->setFlash(sprintf(__('Invalid %s', true), __('newsletter', true)), 'default', array('class' => 'info'));
$this->redirect(array('action' => 'index'));
}
$execute = $this->_arg('execute');
$test = $this->_arg('test');
$this->set(compact('execute', 'test'));
if ($execute) {
// Read the newsletter, including lists of who has received it
// and who has unsubscribed from this mailing list
$this->Newsletter->contain(array('Delivery', 'MailingList' => array('Affiliate', 'Subscription' => array('conditions' => array('subscribed' => 0)))));
$newsletter = $this->Newsletter->read(null, $id);
if (!$newsletter) {
$this->Session->setFlash(sprintf(__('Invalid %s', true), __('newsletter', true)), 'default', array('class' => 'info'));
$this->redirect(array('action' => 'index'));
}
$this->Configuration->loadAffiliate($newsletter['MailingList']['affiliate_id']);
// Handle the rule controlling mailing list membership
$rule_obj = AppController::_getComponent('Rule', '', $this, true);
if (!$rule_obj->init($newsletter['MailingList']['rule'])) {
$this->Session->setFlash(sprintf(__('Failed to parse the rule: %s', true), $rule_obj->parse_error), 'default', array('class' => 'error'));
$this->redirect(array('action' => 'view', 'newsletter' => $id));
}
$people = $rule_obj->query($newsletter['MailingList']['affiliate_id']);
if ($people === null) {
$this->Session->setFlash(__('The syntax of the mailing list rule is valid, but it is not possible to build a query which will return the expected results. See the "rules engine" help for suggestions.', true), 'default', array('class' => 'error'));
$this->redirect(array('action' => 'view', 'newsletter' => $id));
}
if (!empty($people)) {
$sent_ids = Set::extract('/Delivery/person_id', $newsletter);
$unsubscribed_ids = Set::extract('/MailingList/Subscription/person_id', $newsletter);
$people = array_diff($people, $sent_ids, $unsubscribed_ids);
$user_model = $this->Auth->authenticate->name;
$people = $this->Person->find('all', array('contain' => array($user_model), 'conditions' => array('Person.id' => $people), 'limit' => $newsletter['Newsletter']['batch_size'], 'order' => array('Person.first_name', 'Person.last_name', 'Person.id')));
}
if (empty($people)) {
$this->Session->setFlash(__('Finished sending newsletters', true), 'default', array('class' => 'success'));
$this->redirect(array('action' => 'delivery', 'newsletter' => $id));
}
if (!$this->Lock->lock('newsletter', $newsletter['MailingList']['affiliate_id'], 'newsletter delivery')) {
$this->redirect(array('action' => 'view', 'newsletter' => $id));
}
$delay = $newsletter['Newsletter']['delay'] * MINUTE;
$this->set(compact('delay'));
} else {
$this->Newsletter->contain(array('MailingList' => 'Affiliate'));
$newsletter = $this->Newsletter->read(null, $id);
if (!$newsletter) {
$this->Session->setFlash(sprintf(__('Invalid %s', true), __('newsletter', true)), 'default', array('class' => 'info'));
$this->Lock->unlock();
$this->redirect(array('action' => 'index'));
}
$this->Configuration->loadAffiliate($newsletter['MailingList']['affiliate_id']);
if ($test) {
$this->Person->contain($this->Auth->authenticate->name);
$person = $this->Person->read(null, $this->UserCache->currentId());
$people = array($person);
} else {
$this->set(compact('newsletter'));
$this->Lock->unlock();
return;
}
}
$emails = array_keys($this->_extractEmails($people, true));
$this->set(compact('newsletter', 'people', 'emails'));
$params = array('from' => $newsletter['Newsletter']['from'], 'subject' => $newsletter['Newsletter']['subject'], 'sendAs' => 'html', 'template' => 'newsletter', 'header' => array('Auto-Submitted' => 'auto-generated', 'X-Auto-Response-Suppress' => 'OOF', 'Precedence' => 'list'), 'attachments' => Configure::read('email.newsletter_attachments'));
if ($newsletter['Newsletter']['personalize'] || $test) {
foreach ($people as $person) {
$params['to'] = $person;
$code = $this->_hash($person['Person']['id'], $newsletter['MailingList']['id']);
$this->set(compact('person', 'code'));
if ($newsletter['MailingList']['opt_out']) {
$url = Router::url(array('controller' => 'mailing_lists', 'action' => 'unsubscribe', 'list' => $newsletter['MailingList']['id'], 'person' => $person['Person']['id'], 'code' => $code), true);
$params['header']['List-Unsubscribe'] = "<{$url}>";
}
$this->_sendMail($params);
if ($execute) {
// Update the activity log
$this->Newsletter->Delivery->create();
$this->Newsletter->Delivery->save(array('type' => 'newsletter', 'newsletter_id' => $id, 'person_id' => $person['Person']['id']));
}
}
} else {
$params['bcc'] = $people;
if (!empty($newsletter['Newsletter']['to'])) {
$params['to'] = $newsletter['Newsletter']['to'];
} else {
$params['to'] = $newsletter['Newsletter']['from'];
}
if (!empty($newsletter['Newsletter']['replyto'])) {
$params['replyTo'] = $newsletter['Newsletter']['replyto'];
}
if ($newsletter['MailingList']['opt_out']) {
$url = Router::url(array('controller' => 'mailing_lists', 'action' => 'unsubscribe', 'list' => $newsletter['MailingList']['id']), true);
$params['header']['List-Unsubscribe'] = "<{$url}>";
}
$this->_sendMail($params);
//.........这里部分代码省略.........
示例7: afterSave
function afterSave()
{
if (!empty($this->data['Game']['game_slot_id'])) {
$this->GameSlot->id = $this->data['Game']['game_slot_id'];
if (!$this->GameSlot->saveField('assigned', true)) {
return false;
}
}
if (Configure::read('feature.badges') && $this->_is_finalized($this->data)) {
$badge_obj = AppController::_getComponent('Badge');
if (!$badge_obj->update('game', $this->data)) {
return false;
}
}
}
示例8: initRule
/**
* Create a rule object and initialize it with a configuration string
*
* @param mixed $rule The name of the rule
* @param mixed $config The configuration string
* @return mixed The created rule object on success, false otherwise
*
*/
function initRule($rule, $config)
{
$rule_obj = AppController::_getComponent('Rule', $rule, $this->_controller, true);
if ($rule_obj) {
if ($rule_obj->init($config)) {
return $rule_obj;
}
}
$this->log("Failed to initialize rule component {$rule} with {$config}.", 'rules');
if (!empty($rule_obj->parse_error)) {
$this->log($rule_obj->parse_error, 'rules');
}
$this->parse_error = $rule_obj->parse_error;
return null;
}
示例9: _canAdd
function _canAdd($person, $team, $role = null, $status = null, $strict = true, $text_reason = false, $absolute_url = false)
{
if (in_array($person['Person']['status'], array('inactive', 'locked'))) {
return __('Your account is currently inactive. You must contact an administrator to reactivate it before you can be added to a team.', true);
}
if ($person['Person']['status'] != 'active') {
return __('New players must be approved by an administrator before they can be added to a team; this normally happens within one business day.', true);
}
if (array_key_exists('complete', $person['Person']) && !$person['Person']['complete']) {
return __('This person has not yet completed their profile. Please contact them directly to have them complete their profile.', true);
}
// Maybe use the rules engine to decide if this person can be added to this roster
if (array_key_exists('roster_rule', $team['Division']) && !empty($team['Division']['roster_rule'])) {
if (!isset($this->can_add_rule_obj)) {
$this->can_add_rule_obj = AppController::_getComponent('Rule', '', $this, true);
if (!$this->can_add_rule_obj->init($team['Division']['roster_rule'])) {
return sprintf(__('Failed to parse the rule: %s', true), $this->can_add_rule_obj->parse_error);
}
}
if (!array_key_exists('Registration', $person['Person']) || !array_key_exists('Team', $person['Person']) || !array_key_exists('Waiver', $person['Person'])) {
// Get everything from the user record that the rule might need
$person = array('Person' => $this->UserCache->read('Person', $person['Person']['id']), 'Team' => $this->UserCache->read('Teams', $person['Person']['id']), 'Registration' => $this->UserCache->read('RegistrationsReserved', $person['Person']['id']), 'Waiver' => $this->UserCache->read('Waivers', $person['Person']['id']));
}
if (!$this->can_add_rule_obj->evaluate($team['Division']['League']['affiliate_id'], $person, $team, $strict, $text_reason, true, $absolute_url)) {
switch ($this->can_add_rule_obj->reason_type) {
case REASON_TYPE_PLAYER_ACTIVE:
$prolog = 'To be added to this team, this person must first';
break;
case REASON_TYPE_PLAYER_PASSIVE:
$prolog = 'This person';
break;
case REASON_TYPE_TEAM:
$prolog = 'This team';
break;
}
return __($prolog, true) . ' ' . $this->can_add_rule_obj->reason . '.';
}
}
if ($role !== null && $status != ROSTER_INVITED && $status != ROSTER_REQUESTED) {
$roster_role_options = $this->_rosterRoleOptions(null, $team, $person['Person']['id']);
if (!array_key_exists($role, $roster_role_options)) {
return __('You are not allowed to invite someone to that role.', true);
}
}
return true;
}
示例10: _unregisterDependencies
function _unregisterDependencies($person_id)
{
// Get everything from the user record that the decisions below might need
$person = array('Person' => $this->_controller->UserCache->read('Person', $person_id), 'Team' => $this->_controller->UserCache->read('Teams', $person_id), 'Preregistration' => $this->_controller->UserCache->read('Preregistrations', $person_id), 'Registration' => array_merge($this->_controller->UserCache->read('RegistrationsPaid', $person_id), $this->_controller->UserCache->read('RegistrationsUnpaid', $person_id)), 'Upload' => $this->_controller->UserCache->read('Documents', $person_id), 'Affiliate' => $this->_controller->UserCache->read('Affiliates', $person_id), 'Waiver' => $this->_controller->UserCache->read('Waivers', $person_id));
$unregistered = false;
// Pull out the list of unpaid registrations; these are the ones that might be removed
$unpaid = array();
foreach (Configure::read('registration_none_paid') as $payment) {
$unpaid = array_merge($unpaid, Set::extract("/Registration[payment={$payment}]/..", $person['Registration']));
}
$rule_obj = AppController::_getComponent('Rule');
foreach ($unpaid as $key => $registration) {
$person['Registration'] = Set::extract("/Registration[id!={$registration['Registration']['id']}]/..", $person['Registration']);
// Check the registration rule, if any
$can_register = false;
foreach ($registration['Event']['Price'] as $price) {
if (strtotime($price['close']) > time() && (empty($price['register_rule']) || $rule_obj->init($price['register_rule']) && $rule_obj->evaluate($registration['Event']['affiliate_id'], $person))) {
$can_register = true;
break;
}
}
if (!$can_register) {
$event_obj = $this->_controller->_getComponent('EventType', $registration['Event']['EventType']['type'], $this->_controller);
if (in_array($registration['Registration']['payment'], Configure::read('registration_paid'))) {
$event_obj->unpaid($registration, $registration);
}
if (in_array($registration['Registration']['payment'], Configure::read('registration_reserved'))) {
$event_obj->unreserve($registration, $registration);
}
$event_obj->unregister($registration, $registration, false);
$unregistered = true;
}
// Refresh the list
$person['Registration'] = array_merge($this->_controller->UserCache->read('RegistrationsPaid', $person_id), $this->_controller->UserCache->read('RegistrationsUnpaid', $person_id));
}
return $unregistered;
}
示例11: rule
function rule($check)
{
// $check array is passed using the form field name as the key
// have to extract the value to make the function generic
$value = current(array_values($check));
$key = current(array_keys($check));
$rule_obj = AppController::_getComponent('Rule');
if (!$rule_obj->init($value)) {
return $rule_obj->parse_error;
}
return true;
}
示例12: test
/**
* Test whether a user is allowed to register for something
*
* @param mixed $person_id Person id
* @param mixed $event Event id
* @param mixed $options Options controlling the returned data
* 'ignore_date': If true, ignore open and close dates (default false)
* 'strict': If false, allow things with prerequisites that are not yet filled but can easily be (default true)
* 'waiting' If true, ignore the cap to allow waiting list registrations (default false)
* 'all_rules': If true, test tries all price points instead of exiting as soon as an allowed one is found (default false)
* 'for_edit': If true, we are editing a registration, so skip tests related to already being registered (default false)
* 'simple_output': If true, output messages are consolidated into a single string (default false)
* @return mixed True if the user can register for the event
*/
function test($person_id, $event, $options = array())
{
extract(array_merge(array('ignore_date' => false, 'strict' => true, 'waiting' => false, 'all_rules' => false, 'for_edit' => false, 'simple_output' => false), $options));
if (!isset($this->Html)) {
App::import('helper', 'Html');
$this->Html = new HtmlHelper();
}
// Get everything from the user record that the decisions below might need
if ($person_id != $this->person_id) {
$this->person_id = $person_id;
$this->person = array('Person' => $this->_controller->UserCache->read('Person', $person_id), 'Group' => $this->_controller->UserCache->read('GroupIDs', $person_id), 'Team' => $this->_controller->UserCache->read('AllTeams', $person_id), 'Preregistration' => $this->_controller->UserCache->read('Preregistrations', $person_id), 'Registration' => array_merge($this->_controller->UserCache->read('RegistrationsPaid', $person_id), $this->_controller->UserCache->read('RegistrationsUnpaid', $person_id)), 'Upload' => $this->_controller->UserCache->read('Documents', $person_id), 'Affiliate' => $this->_controller->UserCache->read('Affiliates', $person_id), 'Waiver' => $this->_controller->UserCache->read('Waivers', $person_id));
$this->person_duplicates = null;
}
// If we're editing a registration, remove it from the user's list,
// as it only causes problems with rules in the CanRegister test
if ($for_edit && !empty($event['Registration'])) {
$this->person['Registration'] = Set::extract("/Registration[id!={$event['Registration']['id']}]/..", $this->person['Registration']);
}
// Pull out the registration record(s) for the current event, if any.
$registrations = Set::extract("/Event[id={$event['Event']['id']}]/..", $this->person['Registration']);
$is_registered = !empty($registrations);
// Find the registration cap and how many are already registered.
$conditions = array('Registration.event_id' => $event['Event']['id'], 'Registration.payment' => Configure::read('registration_reserved'));
if ($event['Event']['cap_female'] != -2) {
$conditions['Person.gender'] = $this->person['Person']['gender'];
}
$cap = Event::cap($event['Event']['cap_male'], $event['Event']['cap_female'], $this->person['Person']['gender']);
if (!isset($this->_controller->Event)) {
$this->_controller->Event = ClassRegistry::init('Event');
}
if ($cap != -1) {
$this->_controller->Event->Registration->contain('Person');
$paid = $this->_controller->Event->Registration->find('count', array('conditions' => $conditions));
}
// Check whether this user is considered active for the purposes of registration
$is_active = $this->person['Person']['status'] == 'active';
// If the user is not yet approved, we may let them register but not pay
if ($this->person['Person']['status'] == 'new' && Configure::read('registration.allow_tentative')) {
if ($this->person_duplicates === null) {
if (!isset($this->_controller->Person)) {
$this->_controller->Person = ClassRegistry::init('Person');
}
$this->person_duplicates = $this->_controller->Person->findDuplicates($this->person);
}
if (empty($this->person_duplicates)) {
$is_active = true;
}
}
// Now, we determine whether they are allowed to register
$continue = true;
$messages = array();
// TODO: Eliminate hard-coded event types
if (array_key_exists('EventType', $event)) {
$event_type = $event['EventType'];
} else {
$event_type = $event['Event']['EventType'];
}
if (!in_array(GROUP_PLAYER, $this->person['Group']) && in_array($event_type['type'], array('membership', 'individual'))) {
$messages[] = array('text' => __('Only players are allowed to register for this type of event.', true), 'class' => 'warning-message');
$continue = false;
}
if ($continue && in_array($this->person['Person']['status'], array('inactive', 'locked'))) {
$messages[] = array('text' => __('Your account is currently inactive, please contact an administrator to reactivate it.', true), 'class' => 'warning-message');
$continue = false;
}
// First, some tests based on whether the person has already registered for this.
if ($continue && $is_registered && !$for_edit) {
if ($registrations[0]['Registration']['payment'] == 'Paid') {
$messages[] = array('text' => __('You have already registered and paid for this event.', true), 'class' => 'open');
} else {
if (Configure::read('feature.waiting_list') && $registrations[0]['Registration']['payment'] == 'Waiting') {
$messages[] = array('text' => __('You have already been added to the waiting list for this event.', true), 'class' => 'open');
} else {
// An unpaid registration might have been pre-empted by someone who paid.
// TODO: After a while, all such items will have been taken care of elsewhere
// and this whole block can go away.
if ($registrations[0]['Registration']['payment'] == 'Unpaid' && $cap > 0 && $paid >= $cap) {
if (Configure::read('feature.waiting_list')) {
// Move this, and any other Unpaid registrations for this event
$conditions = array('Registration.event_id' => $event['Event']['id'], 'Registration.payment' => 'Unpaid');
if ($event['Event']['cap_female'] != -2) {
$conditions['Person.gender'] = $this->person['Person']['gender'];
}
if (Configure::read('registration.delete_unpaid')) {
$event_obj = $this->_controller->_getComponent('EventType', $event['EventType']['type'], $this->_controller);
$this->_controller->Event->Registration->contain('Person');
//.........这里部分代码省略.........
示例13: recalculateRatings
function recalculateRatings($id = null)
{
if ($id) {
$conditions = array('League.id' => $id);
} else {
$conditions = array('League.is_open' => true);
}
// Find any leagues that are currently open, and possibly recalculate ratings
$leagues = $this->find('all', array('conditions' => $conditions, 'contain' => array('Division' => array('Team')), 'order' => 'League.open'));
foreach ($leagues as $key => $league) {
AppModel::_reindexInner($league['Division'], 'Team', 'id');
// Find all games played by teams that are in this league
$games = $this->readFinalizedGames($league);
foreach ($league['Division'] as $dkey => $division) {
$ratings_obj = AppController::_getComponent('Ratings', $division['rating_calculator']);
$leagues[$key]['Division'][$dkey]['updates'] = $ratings_obj->recalculateRatings($league, $division, $games, true);
}
}
return $leagues;
}