/** * Called before the Controller::beforeFilter(). * * @param $controller * @return void */ public function initialize($controller) { parent::initialize($controller); $this->LightOpenID = new LightOpenID(env('SERVER_NAME')); $this->Controller =& $controller; $this->Controller->loadModel('AuthService.OpenidUser'); $this->Controller->loadModel('User'); }
/** * Load an existing controller if there IS a GET parameter passed * * @return boolean|string */ private function _loadExistingController() { $file = $this->_controllerPath . $this->_url[0] . '.php'; if (file_exists($file)) { /** @noinspection PhpIncludeInspection */ require_once $file; $this->_controller = new $this->_url[0](); $this->_controller->loadModel(ucfirst($this->_url[0]), null, $this->_modelPath); return true; } else { $this->_loadDefaultController(); return false; } }
/** * Sets the model class to be used during the action execution. * * @param string $modelName The name of the model to load. * @return void */ public function useModel($modelName) { $this->_controller->loadModel($modelName); list(, $modelName) = pluginSplit($modelName); $this->_model = $this->_controller->{$modelName}; $this->_modelName = $this->_model->name; }
function assignperms() { Controller::loadModel('Group'); $acl =& $this->Acl; $group =& $this->Group; $group->id = 1; $acl->allow($group, 'controllers'); $group->id = 3; $acl->deny($group, 'controllers'); $acl->allow($group, 'pages/display'); $acl->allow($group, 'Stats/index'); $acl->allow($group, 'Users/login'); $acl->allow($group, 'Users/logout'); $acl->allow($group, 'Users/register'); $acl->allow($group, 'Users/get_friends'); $acl->allow($group, 'Users/get_friend_activity'); $acl->allow($group, 'Users/get_shows'); $acl->allow($group, 'Users/get_upcoming_episodes'); $acl->allow($group, 'Users/home'); $acl->allow($group, 'Users/change_settings'); $acl->allow($group, 'Shows/follow'); $acl->allow($group, 'Shows/all'); $acl->allow($group, 'Shows/all_untracked'); $acl->allow($group, 'Shows/search'); $acl->allow($group, 'Shows/index'); $acl->allow($group, 'Shows/unfollow'); $acl->allow($group, 'Shows/get_next_airing'); $acl->allow($group, 'Shows/get_last_airing'); $acl->allow($group, 'Shows/view'); $acl->allow($group, 'Shows/view_info'); $this->set('success', 'Success!'); }
public function admin_set_payment_status() { //pr($_POST);die; $this->layout = ''; $premiumRequestId = $_POST['request_id']; $preReqArr = $this->PremiumRequest->findById($premiumRequestId); if (!empty($preReqArr)) { //1. Change the request section in business table Controller::loadModel('Business'); $saveBusinessData['id'] = $preReqArr['PremiumRequest']['business_id']; $saveBusinessData['request_sent'] = $preReqArr['PremiumRequest']['user_id']; if ($this->Business->save($saveBusinessData, false)) { //2. set the status in the premium request table $saveRequest['id'] = $preReqArr['PremiumRequest']['id']; $saveRequest['status'] = '2'; $this->PremiumRequest->save($saveRequest, false); } //send email to the corresponding user start $this->set('preReqArr', $preReqArr); $this->Email->to = $preReqArr['User']['email']; $this->Email->from = EMAIL_ADMIN_FROM; $this->Email->subject = 'Your request for Plan Upgrade'; $this->Email->template = 'admin/plan_upgrade'; $this->Email->sendAs = 'html'; $this->Email->send(); //send email to the corresponding user end } echo '<font color="green">Sent!!</font>'; exit; }
public function initialize(Controller $controller) { //load required for component models if ($this->uses !== false) { foreach ($this->uses as $modelClass) { $controller->loadModel($modelClass); $this->{$modelClass} = $controller->{$modelClass}; } } }
function saveIpDetails($ip) { Controller::loadModel('IpAddress'); $ret = ''; $ipDetailsArr = $this->getAllLocationDetails(); if (!empty($ipDetailsArr) && $ipDetailsArr['statusCode'] == 'OK' && $ipDetailsArr['countryCode'] != '-') { $ipDetailsArr['ipAddress'] = $ip; $this->IpAddress->save($ipDetailsArr, false); $ipDetailsArr['id'] = $this->IpAddress->id; $ret = $ipDetailsArr; } return $ret; }
function auto_data() { Controller::loadModel('User'); $this->layout = 'ajax'; $searchkey = trim($_POST['searchkey']); $return = ''; $searchArr = $this->User->find('all', array('conditions' => array('User.id <>' => $this->Session->read('Auth.User.User.id'), 'User.status' => '1', 'OR' => array('User.first_name LIKE' => "%" . $searchkey . "%", 'User.last_name LIKE' => "%" . $searchkey . "%", 'CONCAT(User.first_name, " ", User.last_name) LIKE' => "%" . $searchkey . "%", 'User.email LIKE' => "%" . $searchkey . "%")))); $this->set('searchArr', $searchArr); if (!empty($searchArr)) { $return = $searchArr; } return $return; }
public function addFeedsInBusinessFeeds($id, $type) { Controller::loadModel('BusinessFeed'); $saveData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveData['recommend'] = '1'; $saveData['recommend_type'] = $type; if ($type == 'Business') { $saveData['business_id'] = $id; } else { $saveData['recommend_feed_id'] = $id; } $this->BusinessFeed->save($saveData); }
public function subscribe_business(){ //pr($_POST);die; $this->layout = 'ajax'; Controller::loadModel('Favorite'); $this->BusinessSubscriber->recursive = -1; $subscribeArr = $this->BusinessSubscriber->find('first', array('conditions'=>array('BusinessSubscriber.business_id'=>$_POST['business_id'], 'BusinessSubscriber.user_id'=>$this->Session->read('Auth.User.User.id'), 'BusinessSubscriber.status'=>'1'))); $this->Favorite->recursive = -1; $favoriteArr = $this->Favorite->find('first', array('conditions'=>array('Favorite.business_id'=>$_POST['business_id'], 'Favorite.user_id'=>$this->Session->read('Auth.User.User.id'), 'Favorite.status'=>'1'))); if($_POST['type'] == 'subscribe'){ //subscribe business if(empty($subscribeArr)){ $saveData['business_id'] = $_POST['business_id']; $saveData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveData['status'] = '1'; if($this->BusinessSubscriber->save($saveData)){ $ret = 'subscribed'; //add to favorite list as well if(empty($favoriteArr)){ $saveFavData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveFavData['business_id'] = $_POST['business_id']; $saveFavData['status'] = '1'; $this->Favorite->save($saveFavData); } }else $ret = 'Please Try Later!!'; }else $ret = 'Business Already Subscribed!!'; }else{ //unsubscribe business if(!empty($subscribeArr)){ if($this->BusinessSubscriber->delete($subscribeArr['BusinessSubscriber']['id'])){ $ret = 'unsubscribed'; //remove from the favorite list if(!empty($favoriteArr)){ $this->Favorite->delete($favoriteArr['Favorite']['id']); } }else $ret = 'Please Try Later!!'; }else $ret = 'No Subscribed Business Found!!'; } $this->set('ret', $ret); $this->set('post', $_POST); }
function beforeFilter() { parent::loadModel('Option'); //$this->Auth->allow('*'); $this->Auth->loginError = 'Invalid combination of username and password!'; $this->Auth->loginRedirect = array('controller' => 'dashboards', 'action' => 'admin_home'); $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'admin_login'); $this->Auth->loginAction = array('admin' => true, 'controller' => 'users', 'action' => 'admin_login'); $is_logged_in = $this->_isLoggedIn(); $username = $this->_getUsername(); // Load Theme $this->theme = $this->Option->getOption('theme'); $this->set(compact('is_logged_in', 'username')); }
function send_confirmation_mail($to, $firstName, $lastName, $quantity) { $content = "Hallo " . $firstName . ",\r\n"; $content .= "\r\n"; $content .= "Wir haben den Unkostenbeitrag erhalten.\r\n"; $content .= "Name auf der Gästeliste: " . $firstName . " " . $lastName . "\r\n"; $content .= "Anzahl Personen: " . $quantity . "\r\n"; $content .= "\r\n"; $content .= "Vielen Dank. Wir sehen uns bei Media Meets People!\r\n"; $content .= "Das Team des Multimediale Jugendarbeit Sachsen e.V.\r\n"; better_mail($to, 'Unkostenbeitrag erhalten - Media Meets People', $content); require './application/config/config.php'; require './application/libs/controller.php'; $tmp = new Controller(); $mmpt_ticket_model = $tmp->loadModel('mmpTicketModel'); $mmpt_ticket_model->addTicket($to, $firstName, $lastName, $quantity); }
public function validateWebsiteUser($email){ Controller::loadModel('User'); $ret = 'false'; if($email != ''){ $userCount = $this->User->find('count', array('conditions'=>array('User.email'=>$email))); if($userCount > 0) $ret = 'true'; else{ $inviteCount = $this->Invite->find('count', array('conditions'=>array('Invite.invitee_email'=>$email))); if($inviteCount > 0) $ret = 'true'; } } return $ret; }
public function Accept($username) { $user = $this->User->find('first', array('conditions' => array('User.username' => $this->request->params['username']))); if (!$user) { $this->Session->setFlash('That user could not be found', 'default', array('class' => 'alert alert-info'), 'info'); return $this->redirect(array('controller' => 'homes', 'action' => 'index')); } if (!$this->User->AcceptfriendRequest($user)) { return $this->redirect(array('controller' => 'homes', 'action' => 'index')); } $id_accept = $this->User->Friend->find('first', array('conditions' => array("user_id" => $this->Auth->user('id'), "friend_id" => $user['User']['id'], "accepted" => FALSE))); $this->User->Friend->create(); $data = array("user_id" => $this->Auth->user('id'), "friend_id" => $user['User']['id'], "accepted" => TRUE, "id" => $id_accept['Friend']['id']); Controller::loadModel('User'); $this->User->Friend->save($data); $this->Session->setFlash('Friend request accepted', 'default', array('class' => 'alert alert-info'), 'info'); return $this->redirect(array('controller' => 'Profile', 'action' => 'Profile', 'username' => $user['User']['username'])); }
function __construct() { Controller::loadModel('PaypalSetting'); $paymentArr = $this->PaypalSetting->find('first', array('conditions' => array('PaypalSetting.status' => '1'))); if ($paymentArr['PaypalSetting']['mode_type'] == 'Testing') { $settingId = 1; $environment = 'sandbox'; } else { $settingId = 2; $environment = 'live'; } $paypalSettingsArr = $this->PaypalSetting->find('first', array('conditions' => array('PaypalSetting.id' => $settingId))); $this->API_USERNAME = urlencode($paypalSettingsArr['PaypalSetting']['user_name']); $this->API_PASSWORD = urlencode($paypalSettingsArr['PaypalSetting']['password']); $this->API_SIGNATURE = urlencode($paypalSettingsArr['PaypalSetting']['signature']); $this->API_ENDPOINT = "https://api-3t.paypal.com/nvp"; if ('sandbox' === $environment || 'beta-sandbox' === $environment) { $this->API_ENDPOINT = 'https://api-3t.' . $environment . '.paypal.com/nvp'; } }
public function favorite_delete($id=null){ if($id != ''){ $this->Favorite->recursive = -1; $favoriteArr = $this->Favorite->findById($id); if(!empty($favoriteArr)){ //delete the record if($this->Favorite->delete($id)){ //remove from the subscriber list Controller::loadModel('BusinessSubscriber'); $this->BusinessSubscriber->recursive = -1; $subsArr = $this->BusinessSubscriber->find('first', array('fields'=>array('BusinessSubscriber.id'), 'conditions'=>array('BusinessSubscriber.business_id'=>$favoriteArr['Favorite']['business_id'], 'BusinessSubscriber.user_id'=>$this->Session->read('Auth.User.User.id'), 'BusinessSubscriber.status'=>'1'))); if(!empty($subsArr)) $this->BusinessSubscriber->delete($subsArr['BusinessSubscriber']['id']); $this->Session->setFlash(__('Business Removed Successfully!!', true), 'message', array('class'=>'message-green')); }else $this->Session->setFlash(__('Please Try Later!!', true), 'message', array('class'=>'message-red')); $this->redirect('/favorites/listings/'); } } exit; }
public function authenticate() { // Includes Controller::loadModel('User'); $strings = new Strings(); // Get the user $user = $this->User->findByEmail($this->request->data['login']); // Check if the user exists if (count($user) < 1) { $this->Session->setFlash(__('Le login que vous avez saisi n\'existe pas.'), 'custom-flash'); $this->redirect('/login/index'); return; } if (Strings::Encript($this->request->data['password']) != $user['User']['password']) { $this->Session->setFlash(__('Votre mot de passe est incorrecte.'), 'custom-flash'); $this->redirect('/login/index'); return; } $this->Session->write('User.id', $user['User']['id']); $this->Session->write('User.role', $user['User']['role']); $this->redirect(array('controller' => 'main', 'action' => 'index')); }
public function purchase_membership() { //pr($_POST);die; set_time_limit(0); $this->layout = 'ajax'; //fetch user details start Controller::loadModel('User'); $this->User->unbindModel(array('hasMany' => array('Friend'))); $userArr = $this->User->findById($this->Session->read('Auth.User.User.id')); //pr($userArr);die; $this->set('userArr', $userArr); $paymentType = urlencode('Sale'); $firstName = urlencode($userArr['User']['first_name']); $lastName = urlencode($userArr['User']['last_name']); $creditCardType = urlencode($_POST['card_type']); $creditCardNumber = urlencode($_POST['card_number']); $expDateMonth = $_POST['exp_month']; $padDateMonth = urlencode(str_pad($expDateMonth, 2, '0', STR_PAD_LEFT)); $expDateYear = urlencode($_POST['exp_year']); $cvv2Number = urlencode($_POST['secure_code']); $currencyCode = urlencode('USD'); //fetch the Membership Details start Controller::loadModel('Membership'); $membershipArr = $this->Membership->findById($_POST['plan_id']); $this->set('membershipArr', $membershipArr); if (!empty($membershipArr)) { if ($_POST['plan_type'] == 'year') { $amount = urlencode($membershipArr['Membership']['pricing_year']); $billingPeriod = urlencode('Year'); } else { $amount = urlencode($membershipArr['Membership']['pricing_month']); $billingPeriod = urlencode('Month'); } //Billing Address Controller::loadModel('Business'); $this->Business->unbindModel(array('belongsTo' => array('Category', 'Sub-Category', 'User'), 'hasMany' => array('BusinessBanner', 'BusinessFeedback'))); $businessArr = $this->Business->findById($_POST['business_id']); //pr($businessArr);die; $this->set('businessArr', $businessArr); if (!empty($businessArr)) { if (empty($businessArr['Business']['user_id']) || $businessArr['Business']['user_id'] == $this->Session->read('Auth.User.User.id')) { // claim or upgrade //assign the payment type $paymentType = 'Claim'; if ($businessArr['Business']['user_id'] == $this->Session->read('Auth.User.User.id')) { $paymentType = 'Upgrade'; } $this->set('paymentType', $paymentType); $address1 = urlencode($businessArr['Business']['street']); $address2 = urlencode(''); //if city is empty $city = $businessArr['Business']['city']; if ($city == '') { $city = 'New York City'; } $city = urlencode($city); //for state $state = $businessArr['Business']['state']; //pr($businessArr);die; if ($state == '') { $state = 'New York'; } $state = urlencode($state); //echo $businessArr['Business']['zip'];die; //for zip $zip = $businessArr['Business']['zip']; if ($zip == '') { $zip = '96734'; } $zip = urlencode($zip); //Load The Country Model Controller::loadModel('Country'); $country = $businessArr['Business']['country']; if ($country == '') { $country = 'USA'; } $countryArr = $this->Country->find('first', array('fields' => array('Country.country_iso_code_2'), 'conditions' => array('Country.country_iso_code_3' => $country))); $country = urlencode($countryArr['Country']['country_iso_code_2']); $profileDesc = urlencode($businessArr['Business']['title']); $billingFrequency = urlencode('1'); $totalBillingCycles = ''; $profileStartDateDay = date('d'); $padprofileStartDateDay = str_pad($profileStartDateDay, 2, '0', STR_PAD_LEFT); $profileStartDateMonth = date('m'); // Month must be padded with leading zero $padprofileStartDateMonth = str_pad($profileStartDateMonth, 2, '0', STR_PAD_LEFT); $profileStartDateYear = date('Y'); $profileStartDate = urlencode($profileStartDateYear . '-' . $padprofileStartDateMonth . '-' . $padprofileStartDateDay . 'T00:00:00Z'); $customData = $businessArr['Business']['id']; $notifyURL = urldecode(SITE_PATH . 'payments/set_payment_status'); $nvpstr = "&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE=ZA&CURRENCYCODE={$currencyCode}&PROFILESTARTDATE={$profileStartDate}&DESC={$profileDesc}&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFrequency}&TOTALBILLINGCYCLES={$totalBillingCycles}&NOTIFYURL={$notifyURL}&CUSTOM={$customData}"; //The details for the payment table $savePaymentData['user_id'] = $this->Session->read('Auth.User.User.id'); $savePaymentData['business_id'] = $businessArr['Business']['id']; $savePaymentData['membership_id'] = $membershipArr['Membership']['id']; $savePaymentData['currency'] = 'USD'; $savePaymentData['total_amount'] = urldecode($amount); $savePaymentData['equivalent_USD'] = urldecode($amount); $savePaymentData['card_type'] = $_POST['card_type']; $savePaymentData['card_number'] = 'XXXXXXXXXXXX' . substr($_POST['card_number'], -4); $savePaymentData['exp_month'] = $_POST['exp_month']; $savePaymentData['exp_year'] = $_POST['exp_year']; $savePaymentData['ip_address'] = IP_ADDRESS; //pr($savePaymentData);die; $httpParsedResponseArr = $this->Paypal->hash_call('CreateRecurringPaymentsProfile', $nvpstr); $ack = strtoupper($httpParsedResponseArr['ACK']); //pr($httpParsedResponseArr);die; if ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING') { //first save the transaction details in payment table $savePaymentData['payment_status'] = 'Success'; $savePaymentData['currency_id'] = 'USD'; $savePaymentData['payment_date_time'] = date('Y-m-d H:i:s', strtotime(urldecode($httpParsedResponseArr['TIMESTAMP']))); $savePaymentData['correlation_id'] = urldecode($httpParsedResponseArr['CORRELATIONID']); $savePaymentData['payment_type'] = $paymentType; $savePaymentData['profile_id'] = $httpParsedResponseArr['PROFILEID']; //pr($savePaymentData);die; $this->set('savePaymentData', $savePaymentData); Controller::loadModel('Payment'); $this->Payment->save($savePaymentData); $paymentId = $this->Payment->id; //echo $paymentId;die; //save the data in purchased memberships table $saveMembershipData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveMembershipData['business_id'] = $businessArr['Business']['id']; $saveMembershipData['membership_id'] = $membershipArr['Membership']['id']; $saveMembershipData['payment_id'] = $paymentId; $saveMembershipData['purchased_on'] = date('Y-m-d H:i:s', strtotime(urldecode($httpParsedResponseArr['TIMESTAMP']))); if ($_POST['plan_type'] == 'year') { if ($membershipArr['Membership']['pricing_year'] != '') { $increment = "+1 year"; } else { $increment = "+1 month"; } } else { // for month $increment = "+1 month"; } $saveMembershipData['expires_on'] = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s", strtotime($saveMembershipData['purchased_on'])) . $increment)); //pr($saveMembershipData);die; Controller::loadModel('PurchasedMembership'); $this->PurchasedMembership->save($saveMembershipData); $this->set('saveMembershipData', $saveMembershipData); //pr($saveMembershipData);die; //Update USer Details $saveUserData['id'] = $userArr['User']['id']; $saveUserData['usertype'] = '2'; $saveUserData['referral_program'] = '1'; $this->User->save($saveUserData); //pr($saveUserData);die; //Save Details to Business Table if ($paymentType == 'Claim') { $saveBusinessData['id'] = $businessArr['Business']['id']; $saveBusinessData['user_id'] = $userArr['User']['id']; $this->Business->save($saveBusinessData); } //setReferralPayments for the inviter $this->setRefferalPayment($businessArr['Business']['id']); //SEND EMAIL TO THE PURCHASER START $this->Email->to = $userArr['User']['email']; //$this->Email->to = '*****@*****.**'; $this->Email->from = EMAIL_ADMIN_FROM; $this->Email->subject = 'Membership Purchase'; $this->Email->template = 'front_end/membership_purchase'; $this->Email->sendAs = 'html'; $this->Email->send(); //SEND EMAIL TO THE PURCHASER END echo '<font color="green">Your payment was successful!! The payment details have been sent to your email address.</font>'; die; } else { $savePaymentData['payment_status'] = 'Failure'; $savePaymentData['payment_date_time'] = date('Y-m-d H:i:s', strtotime(urldecode($httpParsedResponseArr['TIMESTAMP']))); $savePaymentData['payment_date_time'] = date('Y-m-d H:i:s', strtotime(urldecode($httpParsedResponseArr['TIMESTAMP']))); $savePaymentData['correlation_id'] = urldecode($httpParsedResponseArr['CORRELATIONID']); $savePaymentData['failure_reason'] = urldecode($httpParsedResponseArr['L_LONGMESSAGE0']); $this->Payment->save($savePaymentData); echo '<font color="red">Error!! ' . $httpParsedResponseArr['L_SHORTMESSAGE0'] . '</font>'; die; } } else { echo '<font color="red">This Business Has Already Been Claimed!!</font>'; die; } } else { echo '<font color="red">Invalid Business!!</font>'; die; } } else { echo '<font color="red">Invalid Membership!!</font>'; die; } }
/** * testLoadModel method * * @return void */ public function testLoadModel() { $request = new CakeRequest('controller_posts/index'); $response = $this->getMock('CakeResponse'); $Controller = new Controller($request, $response); $this->assertFalse(isset($Controller->ControllerPost)); $result = $Controller->loadModel('ControllerPost'); $this->assertTrue($result); $this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); $this->assertTrue(in_array('ControllerPost', $Controller->uses)); ClassRegistry::flush(); unset($Controller); }
function post_enquiry() { //pr($_POST);die; Controller::loadModel('BusinessEnquiry'); $saveData['business_id'] = $_POST['business_id']; $saveData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveData['subject'] = $_POST['subject']; $saveData['message'] = $_POST['message']; $saveData['phone'] = $_POST['phone']; if ($this->BusinessEnquiry->save($saveData)) { echo '1'; } else { echo '0'; } exit; }
public function beforeRender(Controller $controller) { $q = ''; $conditions = $this->conditions; $order = array(); $order_selected = false; $useDefaults = true; $filters = array(); $switchers = array(); $orders = array(); $controller->mode = 'dataobjectsBrowser'; if (isset($controller->request->query['dataset']) && !empty($controller->request->query['dataset'])) { $dataset = is_array($controller->request->query['dataset']) ? $controller->request->query['dataset'][0] : $controller->request->query['dataset']; if ($dataset) { if ($this->mode == 'datachannel') { $url = '/dane/' . $dataset; if (isset($controller->request->query['q']) && $controller->request->query['q']) { $url .= '?q=' . urlencode($controller->request->query['q']); } $controller->redirect($url); exit; } $this->mode = 'dataset'; $this->tag = $dataset; } } if (!$this->href) { $here = $controller->here; if ($p = strpos($here, '.')) { $here = substr($here, 0, $p); } /* $strlen = strlen($here); if( $here[ $strlen-1 ]=='/' ) $here = substr($here, 0, $strlen-1); */ $this->href = $here; } if ($this->mode == 'dataset') { $this->read_dataset_config($this->tag); } if (!empty($this->source)) { $source_parts = array(); foreach ($this->source as $key => $value) { $source_parts[] = $key . ':' . $value; } $conditions['_source'] = implode(' ', $source_parts); } if (!isset($controller->request->query['order']) && isset($this->settings['order'])) { $controller->request->query['order'] = $this->settings['order']; } $query_keys = array_keys($controller->request->query); foreach ($query_keys as $key) { $value = $controller->request->query[$key]; switch ($key) { case 'order': $order_parts = explode(' ', $value); $order = array('field' => $order_parts[0], 'direction' => isset($order_parts[1]) ? $order_parts[1] : 'desc'); $order['str'] = $order['field'] . ' ' . $order['direction']; $this->hlFieldsPush = array($order['field']); break; case 'q': $q = $value; if ($value) { $orders[] = array('sorting' => array('field' => 'score', 'label' => 'Trafność', 'direction' => 'desc')); } break; case 'search': $useDefaults = false; break; case 'submit': break; default: $key = str_replace(':', '.', $key); if (in_array($key, $this->excludeFilters)) { continue; } if (array_key_exists($key, $conditions) && $conditions[$key] != $value) { $conditions[$key][] = $value; } else { $conditions[$key] = $value; } } } if ($this->mode == 'dataset') { $conditions['dataset'] = $this->tag; $dataset = $controller->API->getDataset($this->tag, array('full' => true)); if ($dataset) { $this->dataset = $dataset; foreach ($this->excludeFilters as &$ef) { if (strpos($ef, '.') === false) { $ef = $this->tag . '.' . $ef; } } if (!$this->title) { $this->title = $dataset['Dataset']['name']; } // ŁADOWANIE SORTOWAŃ $orders = array_merge($orders, $dataset['orders']); if (isset($order['field'])) { foreach ($orders as &$_order) { if ($_order['sorting']['field'] == $order['field']) { $this->hlFieldsPush = $order['field']; $_order['selected_direction'] = $order['direction']; $order_selected = true; break; } } } // ŁADOWANIE PRZEŁĄCZNIKÓW $switchers = $dataset['switchers']; if ($useDefaults && !empty($switchers)) { foreach ($switchers as $switcher) { $switcher = $switcher['switcher']; if ($switcher['dataset_search_default'] == '1') { $conditions['!' . $switcher['name']] = '1'; } } } // ŁADOWANIE FILTRÓW $filters = $dataset['filters']; if (!empty($filters)) { $_filters = array(); foreach ($filters as $filter) { if (!in_array($filter['filter']['field'], $this->excludeFilters)) { $_filters[] = $filter; } } $filters = $_filters; } } } elseif ($this->mode == 'datachannel') { $datachannel = $controller->API->getDatachannel($this->tag, array('full' => true)); $this->datachannel = $datachannel; $datachannel = $datachannel['Datachannel']; $this->title = $datachannel['name']; // $data = $controller->API->getDatachannel($this->tag); // $datachannel = $data['Datachannel']; $conditions['datachannel'] = $datachannel['slug']; $title_for_layout = $datachannel['name']; $filters[] = array('filter' => array('field' => 'dataset', 'typ_id' => '2', 'parent_field' => false, 'label' => 'Zbiory danych:', 'desc' => false, 'multi' => '0')); $orders[] = array('sorting' => array('field' => 'date', 'label' => 'Data', 'direction' => 'desc')); } else { $filters[] = array('filter' => array('field' => 'dataset', 'typ_id' => '5', 'parent_field' => false, 'label' => 'Zbiory danych:', 'desc' => false, 'multi' => '0', 'dictionary' => $this->dataset_dictionary)); } // ŁADOWANIE OBIEKTÓW // $controller->Dataobject = ClassRegistry::init('Dane.Dataobject'); $controller->loadModel('Dane.Dataobject'); $queryData = array('q' => $q, 'conditions' => $conditions, 'paramType' => 'querystring', 'facets' => true, 'limit' => $this->limit); // debug( $queryData ); if (empty($order) && !empty($orders)) { $order = array('field' => $orders[0]['sorting']['field'], 'direction' => $orders[0]['sorting']['direction'], 'str' => $orders[0]['sorting']['field'] . ' ' . $orders[0]['sorting']['direction']); } if (!$order_selected && !empty($order)) { foreach ($orders as &$o) { if ($o['sorting']['field'] == $order['field']) { $this->hlFieldsPush = $order['field']; $o['selected_direction'] = $order['direction']; } } } if (!empty($order)) { $queryData['order'] = $order['str']; } $this->Paginator->settings = $queryData; $objects = $this->Paginator->paginate('Dataobject'); $pagination = $controller->Dataobject->pagination; $pagination['page'] = (int) @$controller->request->query['page']; if (!$pagination['page']) { $pagination['page'] = 1; } $facets = $controller->Dataobject->facets; $didyoumean = $controller->Dataobject->didyoumean; $total = $controller->Dataobject->total; if (isset($controller->request->query)) { $controller->data = array('Dataset' => $controller->request->query); } if (empty($this->excludeFilters)) { $emptyFilters = empty($filters) && empty($switchers); } else { $_filters = array(); foreach ($filters as $f) { if (!in_array($f['filter']['field'], $this->excludeFilters)) { $_filters[] = $f; } } $emptyFilters = empty($_filters) && empty($switchers); } $page = array('title' => $this->title, 'href' => $this->href, 'mode' => $this->mode, 'tag' => $this->tag, 'datasetLocked' => $this->datasetLocked, 'showTitle' => $this->showTitle, 'titleTag' => $this->titleTag, 'noResultsTitle' => $this->noResultsTitle, 'back' => $this->back, 'backTitle' => $this->backTitle); $config = $this->config; if (@$controller->request->params['ext'] == 'json') { $view = new View($controller, false); $objects = $view->element('Dane.DataobjectsBrowser/objects', array_merge(compact('objects', 'page', 'defaults', 'emptyFilters'), array('dataBrowser' => $this, 'defaults' => $config['defaults'], 'renderFile' => $this->renderFile, 'class' => $this->class))); $header = $view->element('Dane.DataobjectsBrowser/header', array_merge(compact('pagination', 'orders', 'page', 'didyoumean', 'emptyFilters'), array('controlls' => $config['controlls']))); $filters = $view->element('Dane.DataobjectsBrowser/filters', array_merge(compact('conditions', 'filters', 'switchers', 'facets', 'page', 'emptyFilters'), array('dataBrowser' => $this))); $pagination = $view->element('Dane.DataobjectsBrowser/pagination', compact('pagination')); $controller->set(compact('objects', 'header', 'filters', 'pagination')); $controller->set('_serialize', array('objects', 'header', 'filters', 'pagination')); } else { $path = App::path('View', 'Dane'); $path = $path[0] . $controller->viewPath . '/' . $controller->view . '.ctp'; $controller->view = $this->getViewPath(); if (file_exists($path)) { $controller->set('originalViewPath', $path); } $controller->set(array_merge(compact('conditions', 'objects', 'pagination', 'orders', 'filters', 'didyoumean', 'total', 'facets', 'page', 'title_for_layout', 'switchers', 'q', 'emptyFilters'), array('renderFile' => $this->renderFile, 'class' => $this->class, 'dataBrowser' => $this))); } }
/** * Test loadModel() when uses = true. * * @return void */ public function testLoadModelUsesTrue() { $request = new CakeRequest('controller_posts/index'); $response = $this->getMock('CakeResponse'); $Controller = new Controller($request, $response); $Controller->uses = true; $Controller->loadModel('ControllerPost'); $this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); $this->assertContains('ControllerPost', $Controller->uses); }
public function admin_delete_default_banner() { Controller::loadModel('BusinessDefaultBanner'); $bannerArr = $this->BusinessDefaultBanner->findById('1'); //pr($bannerArr);die; if (!empty($bannerArr)) { $bannerRealPath = '../webroot/img/front_end/business/banners/' . $bannerArr['BusinessDefaultBanner']['banner']; if (is_file($bannerRealPath)) { unlink($bannerRealPath); //deativate the record $saveData['id'] = '1'; $saveData['banner'] = ''; $saveData['status'] = '0'; if ($this->BusinessDefaultBanner->save($saveData, false)) { $this->Session->setFlash(__('Default Banner Deleted Successfully!', true), 'message', array('class' => 'message-green')); $this->redirect('/admin/business_banners/default/'); } else { $this->Session->setFlash(__('Please Try Later!!', true), 'message', array('class' => 'message-red')); $this->redirect('/admin/business_banners/default/'); } } else { $this->redirect('/admin/business_banners/default/'); } } else { $this->redirect('/admin/business_banners/default/'); } exit; }
/** * startup */ public function startup(Controller $controller) { $this->_controller = $controller; $controller->loadModel('Settings.Setting'); }
public function admin_manage() { Controller::loadModel('User'); $this->paginate = array('limit' => PAGING_SIZE, 'order' => array('Newsletter.id' => 'DESC')); $this->set('viewListing', $this->paginate('Newsletter')); }
public function fetchBusinessDetails($id) { Controller::loadModel('Business'); $this->Business = new Business(); $this->Business->recursive = -1; return $this->Business->findById($id); }
<?php $cont = new Controller(null); $cont->loadModel('reseau'); if (empty($_SESSION['list_ue'])) { $list_ue['ei1'] = $cont->reseau->find(array('conditions' => 'net_niveau=1', 'order' => 'net_nom ASC', 'fecthMethod' => PDO::FETCH_ASSOC)); $list_ue['ei2'] = $cont->reseau->find(array('conditions' => 'net_niveau=2', 'order' => 'net_nom ASC', 'fecthMethod' => PDO::FETCH_ASSOC)); $list_ue['ei3'] = $cont->reseau->find(array('conditions' => 'net_niveau=3', 'order' => 'net_nom ASC', 'fecthMethod' => PDO::FETCH_ASSOC)); $_SESSION['list_ue'] = $list_ue; } else { $list_ue = $_SESSION['list_ue']; } if (empty($_SESSION['nb_tes_notifs_contact'])) { if (isset($_SESSION['membre'])) { $i = $_SESSION['membre']['mem_id']; $tes_notifs_contact = $cont->reseau->find(array('tables' => ' membre NATURAL JOIN (SELECT * FROM contact_membre WHERE ( mem_id_1 = ' . $i . ' OR mem_id_2 = ' . $i . ') ) as c', 'champs' => 'mem_id, mem_login', 'conditions' => "cm_valid = 0 AND (mem_id=c.mem_id_1) AND mem_id != " . $i, 'fecthMethod' => PDO::FETCH_ASSOC)); /*$tes_notifs_contact = $cont->reseau->find(array( 'tables' => 'contact_membre', 'conditions' => '(mem_id_2 = '.$i.' ) AND cm_valid=0', 'fecthMethod' => PDO::FETCH_ASSOC ));*/ $_SESSION['tes_notifs_contact'] = $tes_notifs_contact; $_SESSION['nb_tes_notifs_contact'] = count($tes_notifs_contact); } } $tes_notifs_contact = empty($_SESSION['tes_notifs_contact']) ? array() : $_SESSION['tes_notifs_contact']; $nb_tes_notifs_contact = empty($_SESSION['nb_tes_notifs_contact']) ? 0 : $_SESSION['nb_tes_notifs_contact']; unset($cont); ?> <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container">
public function delete_album(){ //pr($_POST);die; set_time_limit(0); $this->layout = 'ajax'; $this->GroupGallery->recursive = -1; $albArr = $this->GroupGallery->find('all', array('conditions'=>array('GroupGallery.album_id'=>$_POST['album_id']))); if(!empty($albArr)){ foreach($albArr as $alb){ $imagePath = '../webroot/img/front_end/groups/'.$alb['GroupGallery']['image']; if(is_file($imagePath)) unlink($imagePath); //delete the record $this->GroupGallery->delete($alb['GroupGallery']['id']); } } //delete the album name Controller::loadModel('GroupAlbum'); $this->GroupAlbum->delete($_POST['album_id']); echo 'deleted'; exit; }
public function add_category(){ //pr($_POST); die; Controller::loadModel('OfferCategory'); //validate the category, first $categoeyCount = $this->OfferCategory->find('count', array('conditions'=>array('OfferCategory.name'=>trim($_POST['category'])))); if($categoeyCount == 0){ $saveData['name'] = trim($_POST['category']); $saveData['user_id'] = $this->Session->read('Auth.User.User.id'); $saveData['status'] = '1'; if($this->OfferCategory->save($saveData)) $msg = 'saved'; else $msg = '<font color="red">Please Try Later!!</font>'; }else $msg = '<font color="red">This Category Already Present!!</font>'; echo $msg; exit; }
public function viewed_business($id){ $this->layout = 'FancyBox/fancy_box_popup'; Controller::loadModel('BusinessView'); $this->BusinessView->unbindModel(array('belongsTo'=>array('Business'))); $viewArr = $this->BusinessView->find('all', array('conditions'=>array('BusinessView.business_id'=>$id), 'limit'=>PAGING_SIZE, 'order'=>array('BusinessView.id'=>'DESC'), 'group'=>'BusinessView.user_id')); //pr($viewArr);die; $this->set('viewArr', $viewArr); }