2 class CharactersHasProfilesController extends AppController {
4 var $name = 'CharactersHasProfiles';
8 var $disableTokenActions = array();
15 function delete($profile_id = null) {
17 $this->Session->setFlash(__('Invalid URL.', true));
18 $this->redirect(array('controller' => 'characters', 'action'=>'index'));
21 $character = $this->CharactersHasProfile->Character->find('first', array(
22 'conditions' => array(
23 'Character.id' => $this->params['named']['character_id'],
33 if (empty($character)) {
34 $this->Session->setFlash(__('No Character', true));
35 $this->redirect(array('controller'=>'characters', 'action'=>'index'));
38 if (!$this->isOwner($character['Character'], $this->user_id)) {
39 $this->Session->setFlash(__('No Permission', true));
40 $this->redirect(array('controller'=>'characters', 'action'=>'index'));
43 $this->CharactersHasProfile->deleteAll(
45 'CharactersHasProfile.profile_id' => $profile_id,
46 'CharactersHasProfile.character_id' => $this->params['named']['character_id'],
51 $this->Session->setFlash(__('Profile deleted', true));
52 $this->redirect(array('controller'=>'characters', 'action'=>'view',$this->params['named']['character_id'] ));