Exemplo n.º 1
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Metable = new MetableBehavior();
     $this->Article = Classregistry::init('MetaArticle');
     $this->Meta = Classregistry::init('Meta');
 }
Exemplo n.º 2
0
 /**
 * setUp method
 *
 * @return void
 */
 public function setUp()
 {
     parent::setUp();
     //$this->Themeable = new MetableBehavior();
     $this->Article = Classregistry::init('Article');
     $this->Template = Classregistry::init('Template');
 }
 public function edit($advanced = null)
 {
     if ($this->request->is('put') || $this->request->is('post')) {
         if (!empty($this->request->data['Afip']['tipo_factura_id'])) {
             $tipoFactId = $this->request->data['Afip']['tipo_factura_id'];
             $TipoFact = Classregistry::init('Risto.TipoFactura')->find('first', array('conditions' => array('TipoFactura.id' => $tipoFactId), 'recursive' => -1));
             $this->request->data['Restaurante']['tipofactura_name'] = $TipoFact['TipoFactura']['name'];
             $this->request->data['Printers']['default_tipo_factura_codename'] = $TipoFact['TipoFactura']['codename'];
         }
         if (TenantSettings::write($this->data)) {
             MtSites::loadConfigFiles();
             $this->Session->setFlash(__('Se han guardado los cambios de configuración'));
         } else {
             $this->Session->setFlash(__('Error al guardar los cambios de configuración'), 'Risto.flash_error');
         }
     }
     $this->request->data = TenantSettings::read();
     if (empty($this->request->data['Geo']['currency_code']) && !empty($this->request->data['Config']['currency_code'])) {
         $this->request->data['Geo']['currency_code'] = $this->request->data['Config']['currency_code'];
     }
     $printers = Classregistry::init('Printers.Printer')->find('list');
     $fiscal_printer = Classregistry::init('Printers.Printer')->read(null, Configure::read('Printers.fiscal_id'));
     $ivaResponsabilidades = Classregistry::init('Risto.IvaResponsabilidad')->find('list');
     $tipoFacturas = Classregistry::init('Risto.TipoFactura')->find('list');
     $mozos = Classregistry::init('Mesa.Mozo')->find('list', array('fields' => array('id', 'numero_y_nombre')));
     $currencyCodes = $this->currencyCodes;
     $this->set(compact('printers', 'fiscal_printer', 'ivaResponsabilidades', 'tipoFacturas', 'mozos', 'currencyCodes'));
     if ($advanced) {
         $this->render('edit_' . $advanced);
     }
 }
Exemplo n.º 4
0
 function endTest()
 {
     $folder = new Folder(TMP);
     $folder->delete(ROOT . DS . APP_DIR . DS . 'webroot' . DS . 'files' . DS . 'test_upload');
     $folder->delete(ROOT . DS . APP_DIR . DS . 'tmp' . DS . 'tests' . DS . 'path');
     Classregistry::flush();
     unset($this->TestUpload);
 }
 /**
  * beforeFilter
  *
  * @return void
  */
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Auth->allow();
     //あとで適切なものに修正
     $this->set('classUrl', 'upload');
     $this->ThemeSettingsSite = Classregistry::init('ThemeSettings.ThemeSettingsSite');
     $this->ThemeSettingsSiteValue = Classregistry::init('ThemeSettings.ThemeSettingsSiteValue');
 }
Exemplo n.º 6
0
 /**
  * Start test callback
  * 
  * @param string $method Test being executed
  * @return void
  */
 public function startTest($method)
 {
     parent::startTest($method);
     $this->BitlyApi = new MockBitlyApiBehavior();
     if ($this->__testWithMockApi) {
         Classregistry::removeObject('bitly_api_behavior');
         Classregistry::addObject('bitly_api_behavior', $this->BitlyApi);
     }
     $this->BitlyAccess = ClassRegistry::init('Bitly.BitlyAccess');
 }
 /**
  * After migration callback
  *
  * @param string $direction Direction of migration process (up or down)
  * @return bool Should process continue
  */
 public function after($direction)
 {
     if ($direction == 'up') {
         $shareModel = Classregistry::init('Share');
         $shareModel->updateAll(array('Share.active' => 0), array('Share.active' => 1));
         $userModel = Classregistry::init('User');
         $userModel->updateAll(array('User.news_update' => 'User.modified'), array('User.is_deleted' => 0));
     }
     return true;
 }
Exemplo n.º 8
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Usable = new UsableBehavior();
     $this->Model = Classregistry::init('UsedArticle');
     // not tied to an actual model file
     $this->Used = ClassRegistry::init('Users.Used');
     // not tied to an actual model file
     $this->User = ClassRegistry::init('Users.User');
     // not tied to an actual model file
 }
 /**
  * beforeFilter
  *
  * @return void
  * @author Takako Miyagawa <*****@*****.**>
  **/
 public function beforeFilter()
 {
     parent::beforeFilter();
     $this->Auth->allow();
     //権限 : あとで適切なものに修正 : システム管理社
     $this->set('classUrl', 'site');
     //このclassへ遷移させるURL
     $this->ThemeSettingsSite = Classregistry::init('ThemeSettings.ThemeSettingsSite');
     $this->Security->requireAuth(array('confirm'));
     $this->ThemeList = $this->__getThemeList();
 }
Exemplo n.º 10
0
	public function beforeFilter() {
		$this->set('title_for_layout','Massidea.org');
		$this->Nodes = Classregistry::init('Node');
		$this->Nodes->map = array('RelatedCompany' => 'RelatedCompanies');
		
		/**
		 * Setting content class
		 * 
		 * content_class is used to define how the page is viewed. Default contentWithSidebar.
		 * Should be overridden in controller if wished to use other class.
		 */
		$this->set('content_class','contentWithSidebar');
		//End of automated class load for content
	}
Exemplo n.º 11
0
 function remove($id = null)
 {
     if (!$id) {
         return;
     }
     $user_id = $this->Session->read('User.id');
     $sql = "delete from favorites where user_id = {$user_id} and tweet_id = {$id}";
     Classregistry::init('Tweet');
     $this->Tweets =& new TweetsController();
     /*Loads the class*/
     $this->Tweets->constructClasses();
     /*Loads the model associations, components, etc. of the Pages controller*/
     $this->Tweets->Tweet->query($sql);
     $this->redirect(array('controller' => 'tweets', 'action' => 'index'));
 }
Exemplo n.º 12
0
 public function lock($taskId = null, $userId = null)
 {
     $user = Classregistry::init('User');
     if (!$taskId) {
         $taskId = $this->id;
     }
     if (!$userId) {
         $userId = $user->id = $user->getUserId();
     }
     if (!$user->exists() || !$this->exists()) {
         $this->cakeError('internal');
     }
     $this->read(array('locked', 'locked_by'), $taskId);
     $this->data['Task']['locked'] = date('Y-m-d H:i:s');
     $this->data['Task']['locked_by'] = $userId;
     return $this->save();
 }
Exemplo n.º 13
0
 function getProfile($slug, $bypassAcl = false)
 {
     $this->User = Classregistry::init('User');
     $canView = false;
     $canRequest = false;
     if (!$slug) {
         $user = $this->controller->currentUser;
     } else {
         // get the user's info based on their slug
         $user = $this->User->getProfile($slug);
     }
     if (!$user) {
         $this->controller->redirect(array('controller' => 'users', 'action' => 'profile', $this->controller->currentUser['User']['slug']));
         exit;
     }
     // check if the requested user is yourself
     if ($this->controller->currentUser['User']['id'] != $user['User']['id'] && !$bypassAcl) {
         // Do permission check
         if ($this->Aacl->checkPermissions($user['User']['id'], $this->controller->currentUser['User']['id'], 'profile')) {
             $canView = true;
         } else {
             $this->controller->Session->setFlash(__('not_allowed_profile', true), 'default', array('class' => 'warning'));
         }
         // are you friends with this person
         $isFriend = $this->User->GroupsUser->isFriend($this->controller->currentUser['User']['id'], $user['User']['id']);
         if (!$isFriend) {
             if (!$this->User->GroupsUser->requestSent($this->controller->currentUser['User']['id'], $user['User']['id'])) {
                 $canRequest = true;
             }
         }
     } else {
         // These are defaults for viewing your own profile
         $canView = true;
     }
     //get gallery position data
     $galleryPosData = unserialize($user['Profile']['gallery_pos_data']);
     //pass the profile data to the view
     $this->controller->set(compact('canRequest', 'galleryPosData', 'user'));
     if ($canView) {
         return $user;
     } else {
         return false;
     }
 }
Exemplo n.º 14
0
 /**
  * Add a new faculty.
  * */
 function add()
 {
     $this->set('title_for_layout', 'Add Faculty');
     $this->RolesUser = Classregistry::init('RolesUser');
     $superadmins = $this->RolesUser->find('all', array('conditions' => array('role_id' => 1)));
     $userfac = array();
     if (!empty($this->data)) {
         $this->Faculty->create();
         $this->data['Faculty']['name'] = trim($this->data['Faculty']['name']);
         if ($this->Faculty->save($this->data)) {
             $facultyId = $this->Faculty->getLastInsertID();
             foreach ($superadmins as $sa) {
                 $userfac[] = array('user_id' => $sa['RolesUser']['user_id'], 'faculty_id' => $facultyId);
             }
             $this->UserFaculty->saveAll($userfac);
             $this->Session->setFlash(__('Faculty added!', true), 'good');
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('The faculty could not be saved. Please, try again.', true));
         }
     }
 }
Exemplo n.º 15
0
 private function __sendEmails(&$Model, $userIds, $notificationTypeId)
 {
     $Notification = Classregistry::init('Notification');
     $notificationType = $Notification->NotificationType->findById($notificationTypeId);
     App::import('Component', 'Mailer.Queue');
     $Queue = new QueueComponent();
     $Queue->initialize();
     App::import('Component', 'Libs.Tools');
     $Tools = new ToolsComponent();
     $item = $Model->find('first', array('conditions' => array($Model->escapeField('id') => $Model->id), 'fields' => array('id', $Model->displayField)));
     $messageId = $Queue->createMessage(Configure::read('Kinspir.Email.Address.no-reply'), Configure::read('Kinspir.Email.Subject.notification'), Configure::read('Kinspir.Email.Template.notification'));
     $users = $Notification->User->find('all', array('conditions' => array('User.id' => $userIds), 'fields' => array('id', 'name', 'email')));
     foreach ($users as $user) {
         $recipientId = $Queue->addRecipient($messageId, $user['User']['email']);
         $notification = $Tools->insertVars($notificationType['NotificationType']['text'], array(User::get('name'), $item[$Model->alias][$Model->displayField], null));
         $Queue->addVariable($recipientId, 'user_name', $user['User']['name']);
         $Queue->addVariable($recipientId, 'notification_content', $notification);
     }
     if ($messageId) {
         return true;
     }
     return;
 }
Exemplo n.º 16
0
 function index($pageID = 0, $registration_type = null)
 {
     App::import('Controller', 'Locations');
     $locations = new LocationsController();
     $locations->constructClasses();
     /* Step 1: set the layout for registration page and include the required CSS and JS (validation etc..) for registration page */
     $this->layout = 'default';
     /* Step 2: retrieve the required data. These data could be cached. The data is displayed in the view */
     //$this->getShowData();
     $this->set('showPages', $this->showPages);
     $this->set('showContents', $this->showContents);
     $this->set('showContentConfigurations', $this->showContentConfigurations);
     $this->set('showQuestions', $this->showQuestions);
     $this->set('showForms', $this->showForms);
     $this->set('showDiscountCodes', $this->showDiscountCodes);
     $this->set('showDelegateDiscountRules', $this->showDelegateDiscountRules);
     $this->set('showTransactionDiscountRules', $this->showTransactionDiscountRules);
     $this->set('accom_booking_details', $this->getBookingDetails('passkey'));
     $this->set('countryPhoneCodes', $locations->getCountriesPhoneCodes());
     if (Configure::read('ISAReg.linked_in_sign_in') && Configure::read('linkedInAPIKey')) {
         $this->set('linked_in_sign_in_integration', true);
     }
     if (Configure::read('ISAReg.non_linear_nav') && $this->allNavStepsComplete()) {
         $this->set('all_nav_steps_complete', TRUE);
     }
     /* Step 2a: Load up the error messages */
     $this->Util->getErrorMessages();
     //get the default country and state list from XML files
     /* Step 3: set up the display logic */
     $nNoOfContent = count($this->showContents);
     $nNoOfNavContent = count($this->showPages);
     // Step 3a: Set the default page id. This is used to redirect user back to the default page ID whenever required
     if (!$this->Session->check('User.defaultPageID')) {
         if ($nNoOfContent > 0) {
             $this->Session->write('User.defaultPageID', $this->showContents[0]['page']['id']);
         } else {
             $this->Session->write('User.defaultPageID', 0);
         }
     }
     // Step 3b: if the show is closed, then set page ID to be the last page, which is the closed page
     if (!$this->Session->check('User.closedPageID')) {
         if ($nNoOfContent > 0) {
             $this->Session->write('User.closedPageID', $this->showContents[$nNoOfContent - 1]['page']['id']);
         } else {
             $this->Session->write('User.closedPageID', 0);
         }
     }
     /* Step 3c: get the current page the user is in. If page ID is not defined, set page ID to be the 1st page. */
     if ($this->Session->check('User.PageID') && $this->Session->read('User.PageID') != 0) {
         $this->Session->write('User.PageID', $this->Session->read('User.PageID'));
     } else {
         if (count($this->showContents)) {
             $this->Session->write('User.PageID', $this->showContents[0]['page']['id']);
         } else {
             $this->Session->write('User.PageID', 0);
         }
     }
     // Determine if the user is on the second last navigated page, and the data should be saved to the webtable
     $is_last_nav_page_to_save = FALSE;
     // Or if the user is on the last navigated page and their session should be destroyed
     $is_final_nav_page = FALSE;
     $current_page_location = $this->Util->ArraySearchRecursive($this->Session->read('User.PageID'), $this->showPages, 'id');
     if ($current_page_location !== FALSE) {
         $current_page_location = current($current_page_location);
         if ($current_page_location === $nNoOfNavContent - 2) {
             $is_last_nav_page_to_save = TRUE;
         } elseif ($current_page_location === $nNoOfNavContent - 1) {
             $is_final_nav_page = TRUE;
         }
     }
     /* Step 3d: define the default registration session data if it doesnt exist yet */
     if (strtotime(date("d-m-Y H:i")) >= strtotime(Configure::read('ISAReg.show_closed_date'))) {
         $this->Session->write('User.PageID', $this->Session->read('User.closedPageID'));
     }
     /* Step 3d: redirect user to the 1st page, if they try to go to the navigated page without completing the data */
     $arrPageID = $this->Util->ArraySearchRecursive($this->Session->read('User.PageID'), $this->showPages, 'id');
     //if current pageID is navigated page
     if (is_array($arrPageID)) {
         //if current pageID is not a first navigated page or the last navigated page
         if ($arrPageID[0] > 0 && $arrPageID[0] < count($this->showPages)) {
             // If we are allowing non-linear navigation, then we will allow random completion of the form pages
             if (Configure::read('ISAReg.non_linear_nav')) {
                 // Do nothing - we are happy to let the user navigate around at will
                 // Otherwise we will enforce the proper page order
             } else {
                 // check if the first navigated page exists in the _SESSION['navPageVisited'] array, if it does not, redirect to the default page
                 if (!$this->Session->check('navPageVisited')) {
                     if ($current_page_location) {
                         $this->redirect(array('controller' => 'registrations', 'action' => 'index', $this->showContents[0]['page']['id']));
                     }
                 } else {
                     // Check that the user has visited all of the previous navigation pages - if not, then redirect them to the next one in the sequence that they must complete
                     $visited_pages = $this->Session->read('navPageVisited');
                     // Get this page id
                     $this_page_id = $this->Session->read('User.PageID');
                     // Get the previous page id
                     $previous_page_id = $this->showPages[$arrPageID[0] - 1]['Content']['id'];
                     // If this page is not in the list of navigated pages, or the previous page, redirect to the last navigated page + 1 (Unless updating profile)
                     // Or if the current page should not be displayed
                     $page_should_display = $this->pageShouldDisplay($this->Session->read("User.NavPages.{$arrPageID[0]}.Content"));
                     if (!$page_should_display || !$this->Session->check('User.updateProfile') && (!in_array($this_page_id, $visited_pages) && !in_array($previous_page_id, $visited_pages))) {
                         $last_navigated_page = $this->Util->ArraySearchRecursive(end($visited_pages), $this->showPages, 'id');
                         $next_required_page_index = $last_navigated_page[0] + 1;
                         $next_required_page_id = $this->showPages[$next_required_page_index]['Content']['id'];
                         $this->redirect(array('controller' => 'registrations', 'action' => 'index', $next_required_page_id));
                     }
                 }
             }
             //if the current page is the last navigated page, delete the Session as we dont want user to be able to go back to previous page as their registration data has been saved already
             if ($is_final_nav_page) {
                 // If we are allowing non-linear navigation, then we must check that the registration is complete
                 if (Configure::read('ISAReg.non_linear_nav')) {
                     if ($this->Session->read('navPageVisited')) {
                         $all_pages_complete = $this->allNavStepsComplete();
                     } else {
                         $this->redirect(array('controller' => 'registrations', 'action' => 'index', $this->showContents[0]['page']['id']));
                     }
                     // If not then we will redirect the user back to the first one that has not been completed
                     if (!$all_pages_complete) {
                         $last_navigated_page = $this->Util->ArraySearchRecursive(end($visited_pages), $this->showPages, 'id');
                         $next_required_page_index = $last_navigated_page[0] + 1;
                         $next_required_page_id = $this->showPages[$next_required_page_index]['Content']['id'];
                         $this->redirect(array('controller' => 'registrations', 'action' => 'index', $next_required_page_id));
                     }
                 }
                 // Update the RegStatus of the registration and send the confirmation email if last step was successful, as we are already in the last navigated page
                 if ($this->Session->read('User.Data.Registration.StepCompleted') == 1) {
                     $reg_status = self::REG_COMPLETE;
                     if ($this->Session->read('User.updateProfile')) {
                         $reg_status = self::REG_UPDATED;
                     }
                     $this->Session->write('User.Data.Registration.RegStatus', $reg_status);
                     $this->Session->write('User.Data.Registration.Downloaded', 0);
                     $this->saveDataToWebDB($this->Session->read('User'));
                     // Process any uploaded files
                     if ($this->Session->read('User.file_uploads')) {
                         $this->processFileUploads();
                     }
                     $attachments = array();
                     // Invoice + Confirmation
                     $pdf_invoice_path = null;
                     if (Configure::read('ISAReg.invoice_enable') == 1 && $this->Session->read('User.Data.Registration.PaymentProcessed') == 1) {
                         $pdf_invoice_path = $this->Pdf->generate('invoice_' . $this->Session->read('User.Data.Registration.FullCardNumber') . '.pdf', 'email' . DS . 'html' . DS . 'invoice_pdf', array('data' => $this->Session->read('User.Data')));
                         $invoice_delivery_method = Configure::read('ISAReg.invoice_delivery_method');
                         $invoice_delivery_method_definitions = array(0 => 'CONFIRMATION EMAIL', 1 => 'INVOICE EMAIL');
                         if ($invoice_delivery_method_definitions[$invoice_delivery_method] == 'INVOICE EMAIL') {
                             //debug($this->Session->read('User.Data'));
                             $this->sendInvoiceEmail($this->Session->read('User.Data'), $pdf_invoice_path);
                             $pdf_invoice_path = null;
                         } else {
                             $attachments[] = $pdf_invoice_path;
                         }
                         // remove the pdf-view instance from the registry so that only registration-contoller-view inside the repository
                         Classregistry::removeObject('view');
                     }
                     /* 20141223: Add new configuration option not to send confirmation email, client will be sending this from their end */
                     if (is_null(Configure::read('ISAReg.sendConfirmationEmail')) || Configure::read('ISAReg.sendConfirmationEmail')) {
                         $this->sendConfirmationEmail($this->Session->read('User.Data'), $attachments);
                     } elseif (Configure::read('ISAReg.sendColleagueConfirmationEmail') === true) {
                         $this->sendConfirmationEmail($this->Session->read('User.Data'), $attachments, false, true);
                     }
                 }
                 $this->set('userData', $this->Session->read('User.Data'));
                 // Set the uplad result to the session if there is one
                 if ($this->Session->read('User.file_uploads_result')) {
                     $this->set('uploadResult', $this->Session->read('User.file_uploads_result'));
                 }
                 //User was successfully saved to the Web Table && Payment is processed && Confirmationed Email sent so we need to delete the Session
                 //$this->deleteSessionData(array('navPageVisited', 'User.Data', 'User.updateProfile', 'User.prepopProfile', 'User.file_uploads_result'));
             }
         }
     }
     $i = 0;
     foreach ($this->showPages as $key) {
         if ($this->Session->read('User.PageID') == $key['Content']['id']) {
             $this->Session->write('User.currentPageIndex', $i);
             break;
         } else {
             $this->Session->write('User.currentPageIndex', 0);
         }
         $i++;
     }
     //Step 3e: Set up the registration type
     if (isset($registration_type) && $registration_type != null) {
         $this->set('registration_type', $registration_type);
         $this->Session->write('User.RegistrationType', $registration_type);
     }
     /* Step 4: save user's response data */
     if (!empty($this->data)) {
         // Perform server-side validation of the data submitted from this page
         $page_id = $this->Session->read('User.PageID');
         // If we are going back, we don't need to validate the page
         if (isset($this->data['Registration']['prevPage']) && $this->data['Registration']['prevPage']) {
             $page_valid = TRUE;
             // If we came from the create event profile form we need to suppress the serverside validation for the first nav page before the user has completed the whole form
         } elseif (!$this->Session->read('navPageVisited') && isset($this->data['CreateEventProfile']) && $current_page_location === 0) {
             $page_valid = TRUE;
             unset($this->data['CreateEventProfile']);
         } else {
             $reg_type = 'default';
             if ($this->Session->read('User.RegistrationType')) {
                 $reg_type = $this->Session->read('User.RegistrationType');
             }
             $validate_questions = NULL;
             if (isset($this->showQuestions[$reg_type])) {
                 $validate_questions = $this->showQuestions[$reg_type];
             }
             $this->Validator->init($this->showContents, $this->showContentConfigurations, $this->showForms, $validate_questions, $this->data);
             $page_valid = $this->Validator->validatePage($page_id);
         }
         if ($page_valid === TRUE) {
             // Discard any file upload refs we may still have in the data as we don't need those any more
             unset($this->data['Registration']['files']);
             // Check for any pre-existing data to prepop or update
             $prepop_data = false;
             if (isset($this->data['Registration']['prepopProfile']) && $this->data['Registration']['prepopProfile']) {
                 $prepop_data = true;
             }
             $existing_reg_data = false;
             if (isset($this->data['Registration']['updateProfile']) && $this->data['Registration']['updateProfile']) {
                 $existing_reg_data = true;
             }
             // If we have either prepop or existing data then attempt to use that data
             if ($prepop_data || $existing_reg_data) {
                 $users_data = $this->getPrepopulateData($this->data);
                 if ($users_data) {
                     $user_data_found = $this->checkPrepopUser($users_data);
                     switch ($user_data_found) {
                         case self::CHECK_USER_REG_FOUND:
                             $this->set('updateProfile', 1);
                             $this->Session->write('User.UserData', $users_data);
                             if (!$this->Session->check('User.updateProfile')) {
                                 $this->Session->write('User.updateProfile', 1);
                             }
                             $this->redirect(array('controller' => 'registrations', 'action' => 'verifyUser'));
                             break;
                         case self::CHECK_USER_PREPOP_FOUND:
                             $this->set('prepopProfile', 1);
                             $this->Session->write('User.UserData', $users_data);
                             if (!$this->Session->check('User.prepopProfile')) {
                                 $this->Session->write('User.prepopProfile', 1);
                             }
                             $this->redirect(array('controller' => 'registrations', 'action' => 'verifyUser'));
                             break;
                             // case self::CHECK_USER_NO_DATA_FOUND: not required - fall through to default action
                         // case self::CHECK_USER_NO_DATA_FOUND: not required - fall through to default action
                         default:
                             if (!($this->Session->check('User.prepopProfile') || $this->Session->check('User.updateProfile'))) {
                                 $this->Session->write('errorFound', 1);
                                 $this->Session->write('errorMessage', Configure::read('prepopulationErrorMessage'));
                             }
                     }
                 }
             }
             /******** RETRIEVE PASSWORD ***********/
             //user wants to retrieve password. We need to validate user 1st, if not found, return error message, else redirect to the 1st form page with retrievePassword = 1 and the found data
             if (isset($this->data['Registration']['retrievePassword']) && $this->data['Registration']['retrievePassword'] == 1) {
                 //echo 'Retrieving User Password<br>';
                 //debug($this->data);
                 $userData = $this->retrievePassword($this->data);
                 //debug($userData);
                 if (!empty($userData)) {
                     $this->set('retrievePassword', 1);
                 }
             }
             /******** SEND INVITATION EMAIL ***********/
             //send colleague email. Registration confirmed email is only sent when data is successfully saved into DB
             if (isset($this->data['Registration']['sendColleagueEmail']) && $this->data['Registration']['sendColleagueEmail'] == 1) {
                 $this->sendInvitationEmail($this->data);
                 $this->set('sendInvitationEmail', 1);
             }
             /******** RESEND CONFIRMATION EMAIL ***********/
             //Resend Confirmation Email to User
             if (isset($this->data['Registration']['resendConfirmationEmail']) && $this->data['Registration']['resendConfirmationEmail'] == 1) {
                 $this->resendConfirmationEmail($this->data);
                 $this->set('resendConfirmationEmailDone', 1);
             }
             $update_profile_and_exit = FALSE;
             if (isset($this->data['Registration']['UpdateProfileAndExit']) && $this->data['Registration']['UpdateProfileAndExit'] == 1) {
                 $update_profile_and_exit = TRUE;
             }
             $save_and_exit = FALSE;
             if (isset($this->data['Registration']['SaveAndExit']) && $this->data['Registration']['SaveAndExit'] == 1) {
                 $save_and_exit = TRUE;
             }
             /******** SAVE REGISTRATION FORM DATA TO SESSION OR WEB TABLE ***********/
             // Save the form data only if the user has navigated forward
             if (!isset($this->data['Registration']['prevPage']) || !$this->data['Registration']['prevPage']) {
                 if (!Configure::read('ISAReg.save_data_every_step')) {
                     //save navigated form data to session if the current page is the navigated page
                     if (is_array($arrPageID)) {
                         $this->saveFormDataToSession($this->data);
                     }
                 } else {
                     if (is_array($arrPageID)) {
                         $this->saveFormDataToSession($this->data);
                         $this->calculateDiscount();
                         $this->saveDataToWebDB($this->Session->read('User'));
                         // The calculation of discount to multiple guest must occur after the fullcard number generation.
                         // If the save discount is required immediate after the step, then another save should be triggered.s
                         if (isset($this->data['Registration']['SaveDiscountImmediate']) && $this->data['Registration']['SaveDiscountImmediate'] == 1) {
                             $this->calculateDiscount();
                             $this->saveDataToWebDB($this->Session->read('User'));
                         }
                         $this->saveDataToWebDBDone = 1;
                     }
                 }
                 /******** SAVE REGISTRATION FORM DATA TO WEB TABLE ***********/
                 if (!(isset($this->saveDataToWebDBDone) && $this->saveDataToWebDBDone == 1)) {
                     if (isset($this->data['Registration']['saveDataToWebTable']) && $this->data['Registration']['saveDataToWebTable'] == 1 || isset($this->data['Registration']['savePaymentData']) && $this->data['Registration']['savePaymentData'] == 1 || $is_last_nav_page_to_save && !Configure::read('ISAReg.non_linear_nav') || $update_profile_and_exit || $save_and_exit) {
                         $this->calculateDiscount();
                         $this->saveDataToWebDB($this->Session->read('User'));
                         if (isset($this->data['Registration']['SaveDiscountImmediate']) && $this->data['Registration']['SaveDiscountImmediate'] == 1) {
                             $this->calculateDiscount();
                             $this->saveDataToWebDB($this->Session->read('User'));
                         }
                     }
                 }
             } else {
                 // Else if the user has navigated back then clean out any payment data we might have
                 $payment_data = array('savePaymentData', 'PaymentType', 'CardType', 'CardHolder', 'CardNumber', 'CardExpMonth', 'CardExpYear', 'CardCVV');
                 foreach ($payment_data as $payment_data_item) {
                     unset($this->data['Registration'][$payment_data_item]);
                     $this->Session->delete('User.Data.Registration.' . $payment_data_item);
                 }
             }
             /******** NAVIGATED WHEN NEXT OR BACK BUTTON IS CLICKED ***********/
             //if data been save successfully, redirect to the next available page if next button was clicked
             //or go back to the previous page if back button was clicked. Otherwise, redirect back to the current page.
             if (!$this->Session->read('errorFound')) {
                 //go to next page
                 $next_page = FALSE;
                 if (isset($this->data['Registration']['nextPage']) && $this->data['Registration']['nextPage'] == 1) {
                     $next_page = TRUE;
                     $this->addNavPageVisited($this->Session->read('User.PageID'));
                 }
                 if (Configure::read('ISAReg.non_linear_nav') && $this->allNavStepsComplete()) {
                     $this->set('all_nav_steps_complete', TRUE);
                 }
                 if ($next_page || $update_profile_and_exit || $save_and_exit) {
                     // If we have non-linear navigation enabled then we will reload the same page after saving
                     if (Configure::read('ISAReg.non_linear_nav') && !$save_and_exit) {
                         // Do nothing
                         // Otherwise we will load the next page
                     } else {
                         $next_page_id = $this->getNextPageId();
                         $this->Session->write('User.PageID', $next_page_id);
                         $this->redirect(array('controller' => 'registrations', 'action' => 'index', $next_page_id));
                     }
                 }
                 //go to previous page
                 if (isset($this->data['Registration']['prevPage']) && $this->data['Registration']['prevPage'] == 1) {
                     $previous_page_id = $this->getPreviousPageId();
                     $this->Session->write('User.PageID', $previous_page_id);
                     $this->redirect(array('controller' => 'registrations', 'action' => 'index', $previous_page_id));
                 }
             } else {
                 $this->redirect(array('controller' => 'registrations', 'action' => 'index', $pageID));
             }
             // Handle any validation errors found
         } else {
             $this->Session->write('errorFound', 1);
             $this->Session->write('errorMessage.validation', $page_valid);
         }
     }
     // If we get here but have no $_POST data and the REQUEST_METHOD is POST and we have content length, then the user attempted to upload something that was too big and the server refused to process it
     // The result is that the same page is loaded again
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         $this->Session->write('errorFound', 1);
         if (!class_exists('RpgUtil')) {
             App::import('Lib', 'RpgUtil');
         }
         $error_message = sprintf('The total size of the data you tried to submit (Including uploaded files) was too big: %sMB<br />', RpgUtil::convertMbToBytes($_SERVER['CONTENT_LENGTH']));
         $error_message .= 'The maximum total size you can submit is ' . ini_get('post_max_size') . 'B - please try again.';
         $this->Session->write('errorMessage', $error_message);
     }
 }
Exemplo n.º 17
0
	function __construct() {
		$this->Nodes = Classregistry::init('Node');
	}
 function endTest()
 {
     Classregistry::flush();
 }
Exemplo n.º 19
0
 function setup(&$Model, $config = array())
 {
     $this->SbmRanking = Classregistry::init('Sbmranking.SbmRanking');
     $this->SbmPastRanking = Classregistry::init('Sbmranking.SbmPastRanking');
     $this->config = Configure::read('sbmranking');
 }
Exemplo n.º 20
0
 /**
  * testBeforeAndAfterCallbacks
  *
  * @return void
  */
 public function testBeforeAndAfterCallbacks()
 {
     $this->Model = Classregistry::init('Article2');
     $options = array('userId' => '47ea303a-3b2c-4251-b313-4816c0a800fa', 'modelId' => '1', 'modelName' => 'Article', 'defaultTitle' => 'Specified default title', 'data' => array('Comment' => array('body' => "Comment Test successful Captn!", 'title' => 'Not the Default title')), 'permalink' => 'http://testing.something.com');
     $this->Model->commentAdd(0, $options);
     $this->assertEqual($this->Model->callbackData['beforeComment']['Comment']['title'], 'Changed in beforeComment!');
     $this->assertEqual($this->Model->callbackData['afterComment']['Comment']['body'], 'Changed in afterComment!');
 }
Exemplo n.º 21
0
 function testGetByDepartments()
 {
     $this->UserFaculty = Classregistry::init('UserFaculty');
     $this->Course = ClassRegistry::init('Course');
     $this->Department = ClassRegistry::init('Department');
     $expected = array("1" => "MECH 328 - Mechanical Engineering Design Project", "2" => "APSC 201 - Technical Communication", "3" => "CPSC 101 - Connecting with Computer Science", "4" => "CPSC 404 - Advanced Software Engineering");
     $empty = null;
     // super admin: user id 1, should see all courses
     $dep = array(array('Department' => array('id' => 1)), array('Department' => array('id' => 2)), array('Department' => array('id' => 3)));
     $course = $this->Course->getByDepartments($dep, 'list');
     $this->assertEqual($course, $expected);
     // if no departments in array, should return nothing
     $course = $this->Course->getByDepartments(array(), 'all');
     $this->assertEqual($course, $empty);
 }
Exemplo n.º 22
0
 private function assignToNextReviewer($worksheetId, $reviewOrder)
 {
     Classregistry::init('Worksheet')->id = $worksheetId;
     if ($reviewOrder == '4') {
         //third review is also done
         Classregistry::init('Worksheet')->saveField('statusId', '6');
         Classregistry::init('Worksheet')->saveField('assignedToId', null);
         return;
     }
     //blindly assignto 2nd reviewer...will get overwritten later appropriately
     Classregistry::init('Worksheet')->saveField('statusId', '4');
     if ($reviewOrder == '3') {
         //check the status and assign to third reviewer
         $firstTwoReviews = $this->Review->find('list', array('fields' => array('reviewOrder', 'letterCode'), 'conditions' => array('worksheetId' => $worksheetId, 'invalidReview' => false)));
         if ($firstTwoReviews['1'] == $firstTwoReviews['2']) {
             Classregistry::init('Worksheet')->saveField('statusId', '6');
             Classregistry::init('Worksheet')->saveField('assignedToId', null);
             //no need to assign to third reviewer
             // make the worksheet statusId as '6'
             return;
         } else {
             //worksheet pending third review
             Classregistry::init('Worksheet')->saveField('statusId', '5');
             //assign to third reviewer
         }
     }
     $nextReview = $this->Review->find('first', array('conditions' => array('worksheetId' => $worksheetId, 'invalidReview' => false, 'statusCode' => '1', 'reviewOrder' => $reviewOrder)));
     if ($nextReview) {
         $this->Review->id = $nextReview['Review']['id'];
         $this->Review->saveField('assignedDate', date("Y-m-d H:i:s", time()));
         $this->Review->saveField('statusCode', '2');
         // set worksheet status id to the next one
         //debug($nextReview);exit;
         Classregistry::init('Worksheet')->saveField('assignedToId', $nextReview['Review']['reviewerId']);
     } else {
         Classregistry::init('Worksheet')->saveField('assignedToId', null);
     }
 }
Exemplo n.º 23
0
 /**
  * Setup the theme for the site
  *
  * Gets the current theme set in db and sets if up
  */
 function setupTheme()
 {
     $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeStart');
     if (isset($event['setupThemeStart'][$this->Controller->plugin])) {
         if (is_string($event['setupThemeStart'][$this->Controller->plugin])) {
             $this->Controller->theme = $event['setupThemeStart'][$this->Controller->plugin];
             return true;
         } else {
             if ($event['setupThemeStart'][$this->Controller->plugin] === false) {
                 return false;
             }
         }
     }
     $this->Controller->layout = 'front';
     if (isset($this->Controller->params['admin']) && $this->Controller->params['admin']) {
         $this->Controller->layout = 'admin';
     }
     $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeLayout', array('layout' => $this->Controller->layout, 'params' => $this->Controller->params));
     if (isset($event['setupThemeLayout'][$this->Controller->plugin])) {
         if (is_string($event['setupThemeLayout'][$this->Controller->plugin])) {
             $this->Controller->layout = $event['setupThemeLayout'][$this->Controller->plugin];
         }
     }
     if (!($theme = Cache::read('currentTheme'))) {
         $theme = ClassRegistry::init('Management.Theme')->getCurrentTheme();
     }
     if (!isset($theme['Theme']['name'])) {
         $theme['Theme'] = array();
     } else {
         $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeSelector', array('theme' => $theme['Theme'], 'params' => $this->Controller->params));
         if (isset($event['setupThemeSelector'][$this->Controller->plugin])) {
             if (is_array($event['setupThemeSelector'][$this->Controller->plugin])) {
                 $theme['Theme'] = $event['setupThemeSelector'][$this->Controller->plugin];
                 if (!isset($theme['Theme']['name'])) {
                     $this->cakeError('eventError', array('message' => 'The theme is invalid.', 'event' => $event));
                 }
             }
         }
     }
     $this->Controller->theme = $theme['Theme']['name'];
     Configure::write('Theme', $theme['Theme']);
     $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeRoutes', array('params' => $this->Controller->params));
     if (isset($event['setupThemeRoutes'][$this->Controller->plugin]) && !$event['setupThemeRoutes'][$this->Controller->plugin]) {
         return false;
     }
     $routes = Cache::read('routes', 'core');
     if (empty($routes)) {
         $routes = Classregistry::init('Management.Route')->getRoutes();
     }
     $currentRoute = Router::currentRoute();
     if (!empty($routes) && is_object($currentRoute)) {
         foreach ($routes as $route) {
             if ($route['Route']['url'] == $currentRoute->template && !empty($route['Route']['theme'])) {
                 $this->Controller->theme = $route['Route']['theme'];
             }
         }
     }
     $event = $this->Controller->Event->trigger($this->Controller->plugin . '.setupThemeEnd', array('theme' => $this->Controller->theme, 'params' => $this->Controller->params));
     if (isset($event['setupThemeEnd'][$this->Controller->plugin])) {
         if (is_string($event['setupThemeEnd'][$this->Controller->plugin])) {
             $this->Controller->theme = $event['setupThemeEnd'][$this->Controller->plugin];
         }
     }
 }
Exemplo n.º 24
0
 /**
  * Start test
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     $this->Model = Classregistry::init('Article');
     $this->Model->Comment->bindModel(array('belongsTo' => array('User')));
 }
Exemplo n.º 25
0
 private function __getUserAros()
 {
     $aros = Classregistry::init('Aro')->find('all', array('conditions' => array('Aro.model' => 'User', 'Aro.foreign_key' => User::get('id')), 'fields' => array('Aro.id', 'Aro.model', 'Aro.foreign_key')));
     $this->userAros = Set::extract('/Aro/id', $aros);
 }
Exemplo n.º 26
0
<?php

Cache::config('core', array('engine' => 'File', 'duration' => 3600, 'probability' => 100, 'prefix' => '', 'lock' => false, 'serialize' => true, 'path' => CACHE . 'core'));
Router::parseExtensions('rss');
Router::parseExtensions('vcf');
Router::parseExtensions('json');
/**
 * redirect to the installer if there is nothing
 */
if (!file_exists(APP . 'config' . DS . 'database.php')) {
    Configure::write('Session.save', 'php');
    Router::connect('/', array('plugin' => 'installer', 'controller' => 'install', 'action' => 'index'));
} else {
    $routes = Cache::read('routes', 'core');
    if (!$routes) {
        $routes = Classregistry::init('Management.Route')->getRoutes();
        if (empty($routes)) {
            //something is broken
            // @todo -c Implement .some error message or something
        }
    }
    if (!empty($routes)) {
        foreach ($routes as $route) {
            if (false) {
                debugRoute($route);
                continue;
            }
            Router::connect($route['Route']['url'], $route['Route']['values'], $route['Route']['regex']);
        }
    }
}
Exemplo n.º 27
0
 /**
  * Get course data by departments
  *
  * @param array  $departments array of departments
  * @param string $findType    find type
  *
  * @return course data
  */
 function getByDepartments($departments, $findType)
 {
     $this->CourseDepartment = Classregistry::init('CourseDepartment');
     $courses = array();
     foreach ($departments as $department) {
         $dp_id = $department['Department']['id'];
         $cd = $this->CourseDepartment->find('all', array('conditions' => array('department_id' => $dp_id)));
         foreach ($cd as $course) {
             array_push($courses, $course['CourseDepartment']['course_id']);
         }
     }
     $ret = $this->find($findType, array('conditions' => array('Course.id' => $courses)));
     return $ret;
 }
Exemplo n.º 28
0
 public function beforeRender(Controller $Controller)
 {
     parent::beforeRender($Controller);
     if ($Controller->layout == 'ajax') {
         return;
     }
     if (!empty($Controller->viewVars['error']) && $Controller->viewVars['error'] instanceof Exception) {
         $error = $Controller->viewVars['error'];
         unset($Controller->viewVars['error']);
     }
     $layout = array_values($Controller->viewVars);
     $theme = current(Set::extract('/Layout/theme_id', $layout));
     $layout = current(Set::extract('/Layout/layout', $layout));
     if (!empty($error)) {
         $Controller->viewVars['error'] = $error;
         $layout = 'error';
     }
     if ($layout) {
         Configure::write('Themes.default_layout', $layout);
     }
     $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeStart');
     if (isset($event['setupThemeStart'][$Controller->plugin])) {
         if (is_string($event['setupThemeStart'][$Controller->plugin])) {
             $Controller->theme = $event['setupThemeStart'][$Controller->plugin];
             return true;
         } else {
             if ($event['setupThemeStart'][$Controller->plugin] === false) {
                 return false;
             }
         }
     }
     $Controller->layout = Configure::read('Themes.default_layout');
     $theme = Cache::read('currentTheme');
     if ($theme === false) {
         $theme = ClassRegistry::init('Themes.Theme')->getCurrentTheme();
     }
     if (!empty($theme['Theme']['default_layout'])) {
         $Controller->layout = $theme['Theme']['default_layout'];
     }
     if (isset($Controller->request->params['admin']) && $Controller->request->params['admin']) {
         $Controller->layout = Configure::read('Themes.default_layout_admin');
     }
     $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeLayout', array('layout' => $Controller->layout, 'params' => $Controller->request->params));
     if (isset($event['setupThemeLayout'][$Controller->plugin]) && is_string($event['setupThemeLayout'][$Controller->plugin])) {
         $Controller->layout = $event['setupThemeLayout'][$Controller->plugin];
     }
     if (!isset($theme['Theme']['name'])) {
         $theme['Theme'] = array('name' => null);
     } else {
         $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeSelector', array('theme' => $theme['Theme'], 'params' => $Controller->request->params));
         if (isset($event['setupThemeSelector'][$Controller->plugin])) {
             if (is_array($event['setupThemeSelector'][$Controller->plugin])) {
                 $theme['Theme'] = $event['setupThemeSelector'][$Controller->plugin];
                 if (!isset($theme['Theme']['name'])) {
                     $this->cakeError('eventError', array('message' => 'The theme is invalid.', 'event' => $event));
                 }
             }
         }
     }
     $Controller->theme = $theme['Theme']['name'];
     Configure::write('Theme', $theme['Theme']);
     $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeRoutes', array('params' => $Controller->request->params));
     if (isset($event['setupThemeRoutes'][$Controller->plugin]) && !$event['setupThemeRoutes'][$Controller->plugin]) {
         return false;
     }
     if (empty($routes)) {
         $routes = Classregistry::init('Routes.Route')->getRoutes();
     }
     $currentRoute = Router::currentRoute(Configure::read('CORE.current_route'));
     if (!empty($routes) && is_object($currentRoute)) {
         foreach ($routes as $route) {
             if ($route['Route']['url'] == $currentRoute->template) {
                 if (!empty($route['Route']['theme'])) {
                     $Controller->theme = $route['Route']['theme'];
                 }
                 if (!empty($route['Route']['layout'])) {
                     $Controller->layout = $route['Route']['layout'];
                 }
             }
         }
     }
     $event = $Controller->Event->trigger($Controller->plugin . '.setupThemeEnd', array('theme' => $Controller->theme, 'params' => $Controller->request->params));
     if (isset($event['setupThemeEnd'][$Controller->plugin])) {
         if (is_string($event['setupThemeEnd'][$Controller->plugin])) {
             $Controller->theme = $event['setupThemeEnd'][$Controller->plugin];
         }
     }
     return true;
 }
Exemplo n.º 29
0
 /**
  * Main execution method.  Handles redirecting of invalid users, and processing
  * of login form data.
  *
  * @param object $controller A reference to the instantiating controller object
  * @return boolean
  * @access public
  */
 function startup(&$controller)
 {
     $this->__checkCookie();
     // see if user has the RememberMe cookie
     $isErrorOrTests = strtolower($controller->name) == 'cakeerror' || strtolower($controller->name) == 'tests' && Configure::read() > 0;
     if ($isErrorOrTests) {
         return true;
     }
     $methods = array_flip($controller->methods);
     $action = strtolower($controller->params['action']);
     $isMissingAction = $controller->scaffold === false && !isset($methods[$action]);
     if ($isMissingAction) {
         return true;
     }
     if (!$this->__setDefaults()) {
         return false;
     }
     $this->data = $controller->data = $this->hashPasswords($controller->data);
     $url = array();
     if (!empty($controller->name) && !empty($controller->action)) {
         $url = array('controller' => strtolower($controller->name), 'action' => $controller->action);
     }
     $url = Router::normalize($url);
     $loginAction = Router::normalize($this->loginAction);
     $allowedActions = array_map('strtolower', $this->allowedActions);
     $isAllowed = $this->allowedActions == array('*') || in_array($action, $allowedActions);
     // row-level acl begin
     if ($this->user()) {
         $aros = Classregistry::init('Aro')->find('all', array('conditions' => array('Aro.model' => $this->userModel, 'Aro.foreign_key' => $this->user('id')), 'fields' => array('Aro.id', 'Aro.model', 'Aro.foreign_key')));
         $this->userAros = Set::extract('/Aro/id', $aros);
     }
     // row-level acl end
     if ($loginAction != $url && $isAllowed) {
         return true;
     }
     if ($loginAction == $url) {
         $model =& $this->getModel();
         if (empty($controller->data) || !isset($controller->data[$model->alias])) {
             if (!$this->Session->check('Auth.redirect') && !$this->loginRedirect && env('HTTP_REFERER')) {
                 $this->Session->write('Auth.redirect', $controller->referer(null, true));
             }
             return false;
         }
         $isValid = !empty($controller->data[$model->alias][$this->fields['username']]) && !empty($controller->data[$model->alias][$this->fields['password']]);
         if ($isValid) {
             $username = $controller->data[$model->alias][$this->fields['username']];
             $password = $controller->data[$model->alias][$this->fields['password']];
             $data = array($model->alias . '.' . $this->fields['username'] => $username, $model->alias . '.' . $this->fields['password'] => $password);
             if ($this->login($data)) {
                 if ($this->autoRedirect) {
                     $controller->redirect($this->redirect(), null, true);
                 }
                 return true;
             }
         }
         $this->Session->setFlash($this->loginError, $this->flashElement, array(), 'auth');
         $controller->data[$model->alias][$this->fields['password']] = null;
         return false;
     } else {
         if (!$this->user()) {
             if (!$this->RequestHandler->isAjax()) {
                 $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth');
                 if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
                     $query = $controller->params['url'];
                     unset($query['url'], $query['ext']);
                     $url .= Router::queryString($query, array());
                 }
                 $this->Session->write('Auth.redirect', $url);
                 $controller->redirect($loginAction);
                 return false;
             } elseif (!empty($this->ajaxLogin)) {
                 $controller->viewPath = 'elements';
                 echo $controller->render($this->ajaxLogin, $this->RequestHandler->ajaxLayout);
                 $this->_stop();
                 return false;
             } else {
                 $controller->redirect(null, 403);
             }
         }
     }
     if (!$this->authorize) {
         return true;
     }
     extract($this->__authType());
     switch ($type) {
         case 'controller':
             $this->object =& $controller;
             break;
         case 'crud':
         case 'actions':
             if (isset($controller->Acl)) {
                 $this->Acl =& $controller->Acl;
             } else {
                 trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING);
             }
             break;
         case 'acl':
             if (isset($controller->Acl)) {
                 $this->Acl =& $controller->Acl;
             } else {
                 trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING);
             }
         case 'model':
             $object = null;
             if (!isset($object)) {
                 $hasModel = isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass});
                 $isUses = !empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]});
                 if ($hasModel) {
                     $object = $controller->modelClass;
                 } elseif ($isUses) {
                     $object = $controller->uses[0];
                 }
             }
             $type = array('model' => $object);
             if (isset($this->Acl)) {
                 $type = array('acl' => $object);
             }
             break;
     }
     if ($this->isAuthorized($type)) {
         return true;
     }
     $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth');
     $controller->redirect($controller->referer(), null, true);
     return false;
 }
Exemplo n.º 30
0
 function endTest()
 {
     Classregistry::flush();
     unset($this->TestUpload);
 }