public function executeReturn(sfWebRequest $request)
 {
     //--------------------------------------------------------------------------
     // if txn_id is posted, we can assume that PDT (Payment Data Transfer) is
     // inactive and return method has been set to 2
     // PDT is not tested yet and requires additional investigation
     //--------------------------------------------------------------------------
     if ($request->getPostParameter('txn_id')) {
         //--------------------------------------------------------------------------
         // instanciate application specific Paypal Interface
         //--------------------------------------------------------------------------
         $pp_class = sfConfig::get('app_es_paypal_plugin_handler', 'esPaypalHandler');
         $pp = new $pp_class();
         //--------------------------------------------------------------------------
         // handle data posted by Paypal (store as transaction)
         //--------------------------------------------------------------------------
         $transaction = $pp->handleReturn($request->getPostParameters());
         $this->data = $request->getPostParameters();
         $this->relatedEntity = $pp->getRelatedEntity();
         $this->transaction = $transaction;
     } else {
         $this->data = $request->getGetParameters();
     }
     $this->handleReturn($this->data);
 }
Beispiel #2
0
 public function save(sfWebRequest $request)
 {
     $options = base64_decode($request->getParameter("options"));
     $options = unserialize($options);
     $options = array_merge(array('save_to' => null, 'target_vars' => true), $options);
     $state = $request->getParameter("state");
     $url = $request->getParameter("image");
     $extension = $request->getParameter("type");
     if ($state != "fetched") {
         throw new sfException("Unknown pixlr state: {$state}");
     }
     if (substr($url, 0, strlen(sfPixlrTools::PIXLR_URL)) != sfPixlrTools::PIXLR_URL) {
         throw new sfException("Unrecognized url: {$url}");
     }
     if ($options['target_vars']) {
         $target_parts = explode("#", $options['target'], 2);
         $options['target'] = $target_parts[0] . (strpos($options['target'], "?") === FALSE ? "?" : "&") . http_build_query($request->getGetParameters(), '', '&');
         if (isset($target_parts[1])) {
             $options['target'] .= "#" . $target_parts[1];
         }
     }
     if ($options['save_to']) {
         $full_path = sfConfig::get('app_pixlr_upload_dir', sfConfig::get('sf_upload_dir'));
         if (is_string($options['save_to'])) {
             $options['save_to'] = preg_replace('/(^|[\\/\\\\]??)([\\.\\s]+)($|[\\/\\\\])/', '/', $options['save_to']);
             $full_path .= "/" . $options['save_to'];
         }
         $name = $this->getUniqueFilename($request->getParameter("title") . "." . $extension, $full_path);
         $this->copyFromUrl($url, "{$full_path}/{$name}");
     }
     //$this->redirect($options['target']);
 }
Beispiel #3
0
 public function executeSelect(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         // steps 1-3 requests & restart
         $this->setLayout(false);
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         $agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
         if ($data = $agent->executeStep()) {
             $partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step';
             $html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step'), NULL), 'back_qs' => $data['back_qs'], 'data' => $data['data'], 'results_so_far' => $data['results_so_far'], 'search_params' => $agent->getSearchParameters()));
         } else {
             /*
              * Would only get here if LWS DB is incomplete.
              * In this case we need to use the query string to retrieve the relevant
              * data set from teh DB and then fill in the missing values.
              * 
              * Do not throw 404 from Ajax request, 
              * just send error messgae back to user.
              * 
              * !! I should log the query string in these cases to facilitate
              * updating of DB.
              */
             $html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>";
         }
         $response = $this->getResponse();
         $response->addCacheControlHttpHeader('no-cache');
         $response->setContentType('text/html');
         $response->sendHttpHeaders();
         return $this->renderText($html);
     } else {
         // ONLY FOR VOLTS/LAST STEP, or graceful degradation for non JavaScript enabled browsers
         $this->manuf_slug = LWS::getManufSlug($request->getParameter('manuf_id'));
         $this->manuf = LWS::unslugify($this->manuf_slug, true);
         $template = 'Filter' . ucfirst($request->getParameter('step')) . 'Step';
         $this->selection = $request->getParameter($request->getParameter('step'));
         $agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
         /*
          * $agent would not return data only if LWS DB is incomplete.
          * Sequence of steps dictate that once LWS DB is complete,
          * server should throw a 404.  User may have be url surfing.
          * 
          * !!! be sure to update DB if necessary.
          */
         $this->forward404Unless($this->data = $agent->executeStep());
         if ($request->getParameter('step') == 'volts') {
             $this->redirect("@part?cat_slug=circuit-breakers&manuf_slug={$this->manuf_slug}&part_no=" . LWS::encode($this->data[0]['part']['part_no']));
         } else {
             // remove unecessary ajax 'back a step' query string from end of data array
             unset($this->data['back_qs']);
             $this->results_so_far = $this->data['results_so_far'];
             $this->data = $this->data['data'];
             $this->search_params = $agent->getSearchParameters();
             $response = $this->getResponse();
             $response->setTitle("{$this->manuf} Circuit Breakers Selection Process");
             $response->setSlot('body_class', 'cb_manuf');
             return $template;
         }
     }
 }
 /**
  * Показываем вики в обвязке EasyFinance
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $wikiURL = $request->getParameter('wikiURL');
     $querySrting = http_build_query($request->getGetParameters());
     $this->setVar('wikiURL', "{$wikiURL}?{$querySrting}");
     $this->setLayout('layoutClear');
     return sfView::SUCCESS;
 }
 /**
  * Executes verify action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeVerify(sfWebRequest $request)
 {
     if (false === ($properties = $this->verify($request->getGetParameters()))) {
         $this->getUser()->setFlash('sf_openid.error', 'Can\'t verify your OpenID');
     } else {
         $this->getUser()->setFlash('sf_openid.success', 'You\'ve successfully logged in');
         $this->processSregProperties($properties);
     }
     $this->redirect($this->generateUrl('sf_openid_consumer_login'));
 }
Beispiel #6
0
 public function executeTransition_for(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $lParams = $request->getGetParameters();
     $lDeal = DealTable::getInstance()->find($lParams['deal_id']);
     $lError = "";
     if ($lDeal->canTransitionFor($lParams['event'])) {
         $lDeal->transitionFor($lParams['event']);
     } else {
         $lError = "Cannot transition for: " . $lParams['event'];
     }
     return $this->redirect('deal/index');
 }
 public function executeConvert(sfWebRequest $request)
 {
     // Check for additional get parameters
     if (count(array_diff(array_keys($request->getGetParameters()), sfConfig::get('app_convert_' . $request->getRequestFormat() . '_params')))) {
         return $this->setError(1200);
     }
     // Check for missing parameters
     if (!$request->hasParameter('amnt') || !$request->hasParameter('from') || !$request->hasParameter('to')) {
         return $this->setError(1100);
     }
     $currency = Doctrine::getTable('Currency');
     /* @var $currency Doctrine_Table */
     $this->from = $currency->findOneByCode($request->getParameter('from'));
     $this->to = $currency->findOneByCode($request->getParameter('to'));
     $this->amount = $request->getParameter('amnt');
     // Check for recognised currencies
     if (!$this->from instanceof Currency || !$this->to instanceof Currency) {
         return $this->setError(2000);
     }
     // Check the currencies are not the same
     if ($this->from == $this->to) {
         return $this->setError(1300);
     }
     // Check if amount contains >2 decimal digits.
     if (!is_numeric($this->amount) || strlen(substr(strrchr($this->amount, '.'), 1)) > sfConfig::get('app_convert_decimal_amount')) {
         return $this->setError(2100);
     }
     // Find cached currency rate
     $currency_rate = Doctrine::getTable('CurrencyRate')->getCurrencyRate($this->from, $this->to);
     /* @var $currency_rate CurrencyRate */
     // Check if currency rate needs updating
     if ($currency_rate->isNew() || $currency_rate->isOutdated()) {
         $currency_rate->setRate($this->getMoneyConverterRate());
         if (!$currency_rate->getRate()) {
             // Fallback functionality for rates not surved by themoneyconverter
             $currency_rate->setRate($this->getBloombergRate());
         }
         if ($currency_rate->getRate() > 0) {
             $currency_rate->setUpdatedAt(date('Y-m-d H:i:s'));
             $currency_rate->save();
         } else {
             return $this->setError(3200);
         }
     }
     // We want to be precise for currencies like ZWD where rates are often miniscule, but for other currencies 5 dp is fine
     $this->rate = $currency_rate->getRate() < 1.0E-5 ? number_format($currency_rate->getRate(), sfConfig::get('app_convert_decimal_stored')) : round($currency_rate->getRate(), sfConfig::get('app_convert_decimal_result'));
     $this->result = sprintf('%0.' . sfConfig::get('app_convert_decimal_result') . 'f', $this->amount * $this->rate);
     $this->at = $currency_rate->getDateTimeObject('updated_at')->format('d F Y H:i');
 }
Beispiel #8
0
 /**
  *
  * @param sfWebRequest $request 
  * @return WSRequestParameters
  */
 public function extractParameters(sfWebRequest $request)
 {
     $webRequestParameters = new WSRequestParameters();
     $logger = Logger::getLogger('core.webservices');
     $requestMethod = $request->getMethod();
     $contentType = $request->getContentType();
     $logger->debug("HTTP Method: {$requestMethod}, Content-Type: {$contentType}");
     $requestParameters = $request->getRequestParameters();
     $logger->debug("Request Parameters: " . print_r($requestParameters, true));
     if (!isset($requestParameters['ws_method'])) {
         throw new WebServiceException('Web service method is not specified', 400);
     }
     $webServiceMethod = $requestParameters['ws_method'];
     $methodParameters = array();
     // Checking for deprecated method of sending parameters using an http header
     $header = $request->getHttpHeader('ohrm_ws_method_parameters');
     if (!empty($header)) {
         $methodParameters = json_decode($header, true);
         if (!is_array($methodParameters)) {
             throw new WebServiceException("header ohrm_ws_method_parameters should be json encoded", 400);
         }
     } else {
         // get request parameters in URL (eg: /empNumber/11) after removing the default parameters
         $methodParameters = array_diff_key($requestParameters, array_flip(array('action', 'module', 'ws_method', '_sf_route')));
         // Merge with GET parameters
         $methodParameters = array_merge($methodParameters, $request->getGetParameters());
         // Check for JSON encoded body
         if ($contentType === 'application/json') {
             $postParams = json_decode(file_get_contents('php://input'), true);
             $methodParameters = array_merge($methodParameters, $postParams);
         } else {
             if ($requestMethod === 'POST') {
                 $methodParameters = array_merge($methodParameters, $request->getPostParameters());
             }
         }
     }
     //        $arrayName = $this->getArrayNameForFunction($function);
     //        if(!array_key_exists($arrayName, $methodParameters)) {
     //            throw new WebServiceException('Required array name not provided', 404);
     //        }
     $webRequestParameters->setRequestMethod($requestMethod);
     $webRequestParameters->setMethod($webServiceMethod);
     $webRequestParameters->setParameters($methodParameters);
     //        $webRequestParameters->setAppId($authenticationParamerters['app_id']);
     //        $webRequestParameters->setAppToken($authenticationParamerters['app_token']);
     //        $webRequestParameters->setSessionToken($authenticationParamerters['session_token']);
     return $webRequestParameters;
 }
 public function executeView(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $this->params = $request->getGetParameters();
     $this->course = false;
     if (isset($this->params['course']) && isset($this->params['catalog'])) {
         $eschool = GcrEschoolTable::getEschool($this->params['catalog'], true);
         if ($eschool) {
             $course = $eschool->getCourse($this->params['course']);
             if ($course) {
                 $this->course = $course;
             }
         }
     }
     $this->getResponse()->setTitle('Courses');
     sfConfig::set('sf_escaping_strategy', false);
 }
 public function executeList(sfWebRequest $request)
 {
     $requested_dir = urldecode($request->getParameter('dir'));
     $relative_dir = $this->isPathSecured($this->root_path, $this->web_path . '/' . $requested_dir) ? $requested_dir : $this->root_dir;
     // browser dir relative to sf_web_dir
     $this->relative_dir = $relative_dir;
     // User dispay dir
     $this->display_dir = preg_replace('`^(' . $this->root_dir . ')`', '', $relative_dir);
     // browser parent dir
     $this->parent_dir = $this->relative_dir != $this->root_dir ? dirname($this->relative_dir) : '';
     // system path for current dir
     $this->path = $this->web_path . $relative_dir;
     // list of sub-directories in current dir
     $this->dirs = $this->getDirectories($this->path);
     // list of files in current dir
     $this->files = $this->getFiles($this->path);
     $this->current_route = $this->getContext()->getRouting()->getCurrentRouteName();
     $this->current_params = $request->getGetParameters();
     // forms
     $this->upload_form = new sfMediaBrowserUploadForm(array('directory' => $relative_dir));
     $this->dir_form = new sfMediaBrowserDirectoryForm(array('directory' => $relative_dir));
 }
 public function executeList(sfWebRequest $request)
 {
     $display_dir = preg_replace('`^(' . $this->root_dir . ')`', '', $this->requested_dir);
     // dir relative to root_dir
     $this->relative_dir = $this->requested_dir;
     // dir relative to /web
     $this->relative_url = $this->root_dir . $this->requested_dir;
     // User dispay dir
     $this->display_dir = $display_dir ? $display_dir : '/';
     // browser parent dir
     $this->parent_dir = dirname($this->relative_dir) && dirname($this->relative_dir) != $this->relative_dir ? dirname($this->relative_dir) : null;
     // system path for current dir
     $this->path = $this->root_path . $this->requested_dir;
     // list of sub-directories in current dir
     $this->dirs = $this->getDirectories($this->path);
     // list of files in current dir
     $this->files = $this->getFiles($this->path);
     $this->current_route = $this->getContext()->getRouting()->getCurrentRouteName();
     $this->current_params = $request->getGetParameters();
     // forms
     $this->upload_form = new sfMediaBrowserUploadForm(array('directory' => $this->display_dir));
     $this->dir_form = new sfMediaBrowserDirectoryForm(array('directory' => $this->display_dir));
 }
 public function executeGetUserStorageFile(sfWebRequest $request)
 {
     global $CFG;
     $get_params = $request->getGetParameters();
     $signed_request = new GcrSignedRequest($get_params);
     if (!$signed_request->validateSignature()) {
         $CFG->current_app->gcError('Signature Invalid', 'gcpageaccessdenied');
     }
     $file = $get_params[GcrStorageAccessS3::FILE_GET_PARAMETER];
     if ($file) {
         if (!isset($get_params['app'])) {
             $app = $CFG->current_app->getInstitution();
         } else {
             $app = GcrInstitutionTable::getApp($get_params['app']);
         }
         $s3_storage = new GcrStorageAccessS3($app);
         if (!$s3_storage->isPublicObject($file)) {
             $CFG->current_app->requireLogin();
             $current_user = $CFG->current_app->getCurrentUser();
             $role_manager = $current_user->getRoleManager();
             if (isset($get_params['course_id']) && !$role_manager->hasPrivilege('EschoolAdmin')) {
                 // make sure the current user has access to this course
                 $flag = false;
                 $mdl_course = $CFG->current_app->getCourse($get_params['course_id']);
                 if ($mdl_course) {
                     // For new course instances, we want to maintain access to
                     // Cloud Storage URLs with course id signed to parent course.
                     $course_collection = $mdl_course->getCourseCollection();
                     if ($course_collection) {
                         foreach ($course_collection->getCourses() as $course_instance) {
                             if ($role_manager->hasCourseAccess($course_instance)) {
                                 $flag = true;
                                 break;
                             }
                         }
                     } else {
                         $flag = $role_manager->hasCourseAccess($mdl_course);
                     }
                 } else {
                     $CFG->current_app->gcError('course_id parameter ' . $get_params['course_id'] . 'does not exist', 'gcdatabaseerror');
                 }
                 if (!$flag) {
                     $CFG->current_app->gcError('User Does Not Have Course Access', 'gcpageaccessdenied');
                 }
             }
         }
         $url = $s3_storage->getObjectUrl($file);
     } else {
         $url = $CFG->current_app->getUrl();
     }
     $this->redirect($url);
 }
 public function executeCronUpdateCoursesCount(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $this->params = $request->getGetParameters();
     $platform_short_name = $CFG->current_app->getShortName();
     $product_type = isset($this->params['type']) ? $this->params['type'] : "";
     // gets all available schools
     $eschool_array = array();
     $catalog_courses_count = array();
     foreach ($CFG->current_app->getMnetEschools() as $eschool) {
         //if (GcrEschoolTable::authorizeEschoolAccess($eschool, true)) {
         $eschool_array[$eschool->getFullName()] = $eschool;
         //}
     }
     ksort($eschool_array);
     // gets catalog-wise courses count
     foreach ($eschool_array as $eschool) {
         $catalog_courses_count[$eschool->getShortName()] = $this->getHTMLCoursesCount($eschool->getShortName());
     }
     // gets all products list
     $all_products = GcrProductsTable::getAllProducts($platform_short_name, $product_type);
     $all_products_details = array();
     foreach ($all_products as $product) {
         $all_products_details[$product->getShortName()]["id"] = $product->getId();
         $all_products_details[$product->getShortName()]["product_type_id"] = $product->getProductTypeId();
         $all_products_details[$product->getShortName()]["short_name"] = $product->getShortName();
         $all_products_details[$product->getShortName()]["institution_short_name"] = $product->getInstitutionShortName();
         $all_products_details[$product->getShortName()]["catalog_short_name"] = $product->getCatalogShortName();
         $all_products_details[$product->getShortName()]["platform_short_name"] = $product->getPlatformShortName();
         if ($product->getProductTypeId() == 2 || $product->getProductTypeId() == 3) {
             $is_exist = GcrInstitutionCatalogCoursesTable::checkIsExist($product->getInstitutionShortName(), $product->getCatalogShortName(), $product->getPlatformShortName());
             $ctlg_crses_count = isset($catalog_courses_count[$product->getCatalogShortName()]) ? $catalog_courses_count[$product->getCatalogShortName()] : 0;
             if ($is_exist == 0) {
                 $cron_obj = new GcrInstitutionCatalogCourses();
                 $cron_obj->setPlatformShortName($product->getPlatformShortName());
                 $cron_obj->setInstitutionShortName($product->getInstitutionShortName());
                 $cron_obj->setCatalogShortName($product->getCatalogShortName());
                 $cron_obj->setProductTypeId($product->getProductTypeId());
                 $cron_obj->setCoursesCount($ctlg_crses_count);
                 $cron_obj->save();
             } else {
                 Doctrine_Query::create()->update('GcrInstitutionCatalogCourses')->set('courses_count', '?', $ctlg_crses_count)->where('institution_short_name = ?', $product->getInstitutionShortName())->andWhere('platform_short_name = ?', $product->getPlatformShortName())->andWhere('catalog_short_name = ?', $product->getCatalogShortName())->andWhere('product_type_id = ?', $product->getProductTypeId())->execute();
             }
         } else {
             if ($product->getProductTypeId() == 1) {
                 $institution_name = $product->getInstitutionShortName();
                 $mhr_institution_obj = $CFG->current_app->selectFromMhrTable('institution', 'name', $institution_name, true);
                 if ($mhr_institution_obj) {
                     $mhr_institution = new GcrMhrInstitution($mhr_institution_obj, $CFG->current_app);
                     $current_eschools = array();
                     $eschools = $mhr_institution->getEschools();
                     if ($eschools) {
                         foreach ($eschools as $eschool) {
                             $current_eschools[$eschool->getShortName()] = $eschool->getFullName();
                         }
                     }
                     asort($current_eschools);
                     foreach ($current_eschools as $current_eschool_key => $current_eschool_val) {
                         if (stripos(strtolower($current_eschool_val), "(*)") === false && stripos(strtolower($current_eschool_val), "(\$)") === false) {
                             $params = array();
                             $params["start_index"] = 0;
                             $params["mode"] = "Eschool";
                             $params["mode_id"] = $current_eschool_key;
                             $this->course_list = new GcrCourseList($params, $CFG->current_app);
                             $catalog_courses_count[$current_eschool_key] = $this->course_list->getCoursesCount();
                             $is_exist = GcrInstitutionCatalogCoursesTable::checkIsExist($product->getInstitutionShortName(), $current_eschool_key, $product->getPlatformShortName());
                             $ctlg_crses_count = isset($catalog_courses_count[$current_eschool_key]) ? $catalog_courses_count[$current_eschool_key] : 0;
                             if ($is_exist == 0) {
                                 $cron_obj = new GcrInstitutionCatalogCourses();
                                 $cron_obj->setPlatformShortName($product->getPlatformShortName());
                                 $cron_obj->setInstitutionShortName($product->getInstitutionShortName());
                                 $cron_obj->setCatalogShortName($current_eschool_key);
                                 $cron_obj->setProductTypeId($product->getProductTypeId());
                                 $cron_obj->setCoursesCount($ctlg_crses_count);
                                 $cron_obj->save();
                             } else {
                                 Doctrine_Query::create()->update('GcrInstitutionCatalogCourses')->set('courses_count', '?', $ctlg_crses_count)->where('institution_short_name = ?', $product->getInstitutionShortName())->andWhere('platform_short_name = ?', $product->getPlatformShortName())->andWhere('catalog_short_name = ?', $current_eschool_key)->andWhere('product_type_id = ?', $product->getProductTypeId())->execute();
                             }
                         }
                     }
                 }
             }
         }
     }
     /* 		print "<pre>";
     		print_r($catalog_courses_count);
     		//print_r($all_products_details);
     		print "</pre>"; */
     echo "<br>Completed<br>";
     exit;
 }
 /**
  * executes subscriptions list mahara
  *
  * @param sfWebRequest $request_object
  * @param returns products details along with courses.
  * gets values from get method
  */
 public function executeSubscriptions(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $this->params = $request->getGetParameters();
     $this->course = false;
     $this->current_app_short_name = $CFG->current_app->getShortName();
     // gets all available schools
     /* 		$eschool_array = array();
     		$catalog_courses_count = array();
     		foreach($CFG->current_app->getMnetEschools() as $eschool) {
     			//if (GcrEschoolTable::authorizeEschoolAccess($eschool, true)) {
     				$eschool_array[$eschool->getFullName()] = $eschool;
     			//}
     		} 
     		ksort($eschool_array);
     		// gets catalog-wise courses count
     		foreach($eschool_array as $eschool) {
     			//$catalog_courses_count[$eschool->getShortName()] = $eschool->getFullName();
     			$ctlg_courses_list = $this->getHTMLCoursesCount($eschool->getShortName());
     			$catalog_courses_count[$eschool->getShortName()] = $ctlg_courses_list;
     		}
     		$this->catalog_courses_count = $catalog_courses_count; */
     // gets subscriptions products
     $products = GcrProductsTable::getProductLibraries($this->current_app_short_name);
     //$ins_prod_orders = GcrInstitutionProductOrdersTable::get_orders("lcrcconline", "microsoft", 6);
     $products_list = array();
     $products_list_institution = array();
     $products_details = array();
     foreach ($products as $product) {
         $products_list[$product->getShortName()] = $product->getFullName();
         $products_list_institution[$product->getShortName()] = $product->getInstitutionShortName();
         $products_details[$product->getShortName()]["id"] = $product->getId();
         $products_details[$product->getShortName()]["short_name"] = $product->getShortName();
         $products_details[$product->getShortName()]["full_name"] = $product->getFullName();
         $products_details[$product->getShortName()]["institution_short_name"] = $product->getInstitutionShortName();
         $products_details[$product->getShortName()]["description"] = $product->getDescription();
         $products_details[$product->getShortName()]["cost"] = $product->getCost();
         $products_details[$product->getShortName()]["pricing_html"] = $product->getPricingHtml();
         $products_details[$product->getShortName()]["icon"] = $product->getIcon();
     }
     $this->libraries_list = $products_list;
     $this->products_list_institution = $products_list_institution;
     $this->products_details = $products_details;
     $this->getResponse()->setTitle('Subscriptions');
     sfConfig::set('sf_escaping_strategy', false);
 }
 public function executeSubscriptions(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireMahara();
     $this->params = $request->getGetParameters();
     $this->course = false;
     if (isset($this->params['course']) && isset($this->params['catalog'])) {
         $eschool = GcrEschoolTable::getEschool($this->params['catalog'], true);
         if ($eschool) {
             $course = $eschool->getCourse($this->params['course']);
             if ($course) {
                 $this->course = $course;
             }
         }
     }
     $eschool_array = array();
     $catalog_courses_count = array();
     foreach ($CFG->current_app->getMnetEschools() as $eschool) {
         if (GcrEschoolTable::authorizeEschoolAccess($eschool, true)) {
             $eschool_array[$eschool->getFullName()] = $eschool;
         }
     }
     ksort($eschool_array);
     foreach ($eschool_array as $eschool) {
         //$catalog_courses_count[$eschool->getShortName()] = $eschool->getFullName();
         $catalog_courses_count[$eschool->getShortName()] = $this->getHTMLCoursesCount($eschool->getShortName());
     }
     $this->catalog_courses_count = $catalog_courses_count;
     $products = GcrProductsTable::getProductLibraries();
     $products_list = array();
     $products_details = array();
     foreach ($products as $product) {
         $products_list[$product->getShortName()] = $product->getFullName();
         $products_details[$product->getShortName()]["id"] = $product->getId();
         $products_details[$product->getShortName()]["short_name"] = $product->getShortName();
         $products_details[$product->getShortName()]["full_name"] = $product->getFullName();
         $products_details[$product->getShortName()]["description"] = $product->getDescription();
         $products_details[$product->getShortName()]["cost"] = $product->getCost();
         $products_details[$product->getShortName()]["pricing_html"] = $product->getPricingHtml();
         $products_details[$product->getShortName()]["icon"] = $product->getIcon();
     }
     $this->libraries_list = $products_list;
     $this->products_details = $products_details;
     $this->getResponse()->setTitle('Courses');
     sfConfig::set('sf_escaping_strategy', false);
 }
Beispiel #16
0
 /**
  * AJAX
  * Saves all changes made to a person
  * CODE: person_create
  * CODE: person_save_roles
  */
 public function executeSave(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     # validate person
     $person = PersonPeer::retrieveByPK($request->getParameter('person_id'));
     if (!$person instanceof Person) {
         return $this->renderText('Data is invalid! Please refresh and try again!');
     }
     $saved_values = array();
     $errors = array();
     $form = new PersonForm($person, null, false);
     # email list
     $params = $request->getGetParameters();
     $ids = array();
     foreach ($params as $name => $value) {
         if (substr($name, 0, 11) == 'email_list_') {
             $ids[] = (int) substr($name, 11);
         }
     }
     $validator = new sfValidatorPropelChoice(array('model' => 'EmailList', 'column' => 'id', 'required' => false, 'multiple' => true, 'empty_value' => array()));
     $err = false;
     try {
         $ids = $validator->clean($ids);
     } catch (sfValidatorError $e) {
         $errors[] = 'Couldn\'t save mailing list. Please refresh and try again';
         $err = true;
     }
     if (!$err) {
         $c = new Criteria();
         $c->add(EmailListPersonPeer::PERSON_ID, $person->getId());
         EmailListPersonPeer::doDelete($c);
         foreach ($ids as $id) {
             if ($request->getParameter('email_list_' . $id) == 1) {
                 $email_list_person = new EmailListPerson();
                 $email_list_person->setListId($id);
                 $email_list_person->setPersonId($person->getId());
                 $email_list_person->save();
                 $saved_values['email_list_' . $id] = 1;
             } else {
                 $saved_values['email_list_' . $id] = 0;
             }
         }
     }
     $request_params = array_intersect_key($request->getGetParameters(), $form->getWidgetSchema()->getFields());
     $params = array_merge($person->toArray(BasePeer::TYPE_FIELDNAME), $request->getGetParameters());
     $params = array_intersect_key($params, $form->getWidgetSchema()->getFields());
     $form->bind($params);
     if (!$form->isValid()) {
         foreach ($form->getErrorSchema()->getErrors() as $field => $e) {
             $errors[] = $e->__toString();
         }
     } else {
         $form->save();
         foreach ($request_params as $field => $v) {
             $saved_values[$field] = $form->getValue($field);
         }
     }
     /*
     # email blocked
         if ($request->hasParameter('email_blocked')) {
         $v = $form->getValidator('email_blocked');
         try {
         $email_blocked = $v->clean($request->getParameter('email_blocked'));
         $person->setEmailBlocked($email_blocked == 1 ? 1 : 0);
         $saved_values['email_blocked'] = $person->getEmailBlocked();
         }catch(sfValidatorError $e) {
         $errors[] = $e->__toString();
         }
         }
     # email text only
         if ($request->hasParameter('email_text_only')) {
         $email_text_only = $request->getParameter('email_text_only');
         $person->setEmailTextOnly($email_text_only == 1 ? 1 : 0);
         $saved_values['email_text_only'] = $person->getEmailTextOnly();
         }
     # email
         if ($request->hasParameter('email')) {
         $validator = new sfValidatorEmail(array('required' => true), array('invalid' => 'Email address is invalid: %value%', 'required' => 'Email address is invalid'));
         $err = false;
         try {
         $email = $validator->clean($request->getParameter('email'));
         }catch(sfValidatorError $e) {
         $errors[] = $e->__toString();
         $err = true;
         }
         if (!$err) {
         $person->setEmail($email);
         $saved_values['email'] = $email;
         }
         }
     # city
         $person->setCity($saved_values['city'] = $request->getParameter('city'));
     # county
         $person->setCounty($saved_values['county'] = $request->getParameter('county'));
     # state
         $person->setState($saved_values['state'] = $request->getParameter('state'));
     $person->save();
     */
     # roles
     if ($request->hasParameter('roles')) {
         if ($this->getUser()->hasCredential(array('Administrator'), false) == true) {
             $roles = $request->getParameter('roles');
             $validator = new sfValidatorPropelChoice(array('model' => 'Role', 'column' => 'id', 'required' => false, 'multiple' => true, 'empty_value' => array()));
             $err = false;
             try {
                 $roles = $validator->clean($roles);
             } catch (sfValidatorError $e) {
                 $errors[] = 'Couldn\'t save roles. Please refresh and try again';
                 $err = true;
             }
             if (!$err) {
                 $c = new Criteria();
                 $c->add(PersonRolePeer::PERSON_ID, $person->getId());
                 PersonRolePeer::doDelete($c);
                 foreach ($roles as $role) {
                     $person_role = new PersonRole();
                     $person_role->setPersonId($person->getId());
                     //            if($s_role->getId()==$role){
                     //              $role=$a_role->getId();
                     //            }
                     $person_role->setRoleId($role);
                     $person_role->save();
                 }
                 $saved_values['roles'] = $roles;
             }
         } else {
             $errors[] = 'You don\'t have permission to edit person roles!';
         }
     }
     $this->errors = $errors;
     $this->saved_values = $saved_values;
 }
 public function executeTBloqueada(sfWebRequest $request)
 {
     $params = $request->getGetParameters();
     $this->order = Doctrine::getTable('PaymentOrder')->findOneByOrderId($params['o']);
     unset($params['o']);
     $this->params_raw = http_build_query($params);
 }
Beispiel #18
0
 public function executeSearch(sfWebRequest $request)
 {
     $parameters = $request->getGetParameters();
     if (isset($parameters['target'])) {
         $this->forward400IfInvalidTargetForSearchAPI($parameters);
     }
     $activityData = $this->timeline->searchActivityDataByAPIRequestDataAndMemberId($request->getGetParameters(), $this->getUser()->getMemberId());
     $activitySearchData = $activityData->getData();
     //一回も投稿していない
     if (empty($activitySearchData)) {
         return $this->renderJSON(array('status' => 'success', 'data' => array()));
     }
     $responseData = $this->timeline->createActivityDataByActivityDataAndViewerMemberIdForSearchAPI($activityData, $this->getUser()->getMemberId());
     $responseData = $this->timeline->addPublicFlagByActivityDataForSearchAPIByActivityData($responseData, $activityData);
     $responseData = $this->timeline->embedImageUrlToContentForSearchAPI($responseData);
     return $this->renderJSON(array('status' => 'success', 'data' => $responseData));
 }
Beispiel #19
0
 public function executeProcessConfigForm(sfWebRequest $request)
 {
     $data = $request->getGetParameters();
     $config = new Config();
     if ($data['cid'] == '-1') {
         // New Config
         $config->setModelId($data['mid']);
         $config->save();
         foreach ($data as $field => $value) {
             if ($field != 'cid' && $field != 'mid') {
                 $fv = new FieldValue();
                 $fv->setConfigId($config->getId());
                 $fv->setFieldId(intval($field));
                 $fv->setValue($value);
                 //echo intval($field)."\n";
                 $fv->save();
             }
         }
     } else {
         $config = ConfigPeer::retrieveByPK($data['cid']);
         foreach ($data as $field => $value) {
             if ($field != 'cid' && $field != 'mid') {
                 $c = new Criteria();
                 $c->add(FieldValuePeer::FIELD_ID, intval($field));
                 $c->add(FieldValuePeer::CONFIG_ID, $config->getId());
                 $fv = FieldValuePeer::doSelectOne($c);
                 if (!is_object($fv)) {
                     $fv = new FieldValue();
                     $fv->setConfigId($config->getId());
                     $fv->setFieldId(intval($field));
                 }
                 $fv->setValue($value);
                 //echo intval($fv->getValue())."#";
                 //print_r($fv, FALSE);
                 $fv->save();
             }
         }
     }
     $this->res = $config->getId();
 }
Beispiel #20
0
 public function executeSelect(sfWebRequest $request)
 {
     if ($request->isXmlHttpRequest()) {
         sfProjectConfiguration::getActive()->loadHelpers('Partial');
         $this->setLayout(false);
         $response = $this->getResponse();
         $response->addCacheControlHttpHeader('no-cache');
         $response->setContentType('text/html');
         $response->sendHttpHeaders();
         // might have to pass sfUser instance to TSA here
         $agent = new TransformerSelectionAgent($request->getGetParameters());
         if ($data = $agent->executeStep()) {
             $partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step';
             $html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step')), 'data' => $data, 'back_qs' => $agent->getBackQs()));
         } else {
             // Must be nothing in the DB.  This should not occur unless we goofed.
             $html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>";
         }
         return $this->renderText($html);
     } else {
         // graceful degradation block for non JS users
         $response = $this->getResponse();
         $response->setTitle('Electrical Transformers Selection Tool - ' . sfConfig::get('app_biz_name'));
         $response->setSlot('body_id', 'tr_select');
         if ($request->getParameter('step', NULL)) {
             /*
              * User has started making selections.
              * GET parameter 'step' always refers to the previous step for the current request.
              * FilerOutputStep is simply the landing page results
              */
             $step = $request->getParameter('step');
             $template = 'Filter' . ucfirst($step) . 'Step';
             $this->selection = $request->getParameter($step);
             if ($step == 'output') {
                 /*
                  * Both voltage values must be present, so ...
                  * Store the selected order of voltage selections in user session. This will allow
                  * the script rendering the landing page to determine what order to display the
                  * voltages since it cannot be determined from a DB query using part no. only. (As of 12/3/2010)
                  * 
                  * NOTE: removed _volts from query parameters in selection tool
                  */
                 $iv = rawurldecode($request->getParameter('input'));
                 $ov = rawurldecode($request->getParameter('output'));
                 $d_kva = $request->getParameter('kva');
                 $d_phase = $request->getParameter('phase');
                 $this->getUser()->setAttribute('tr_volt_order', "{$iv}:{$ov}");
                 $response->setSlot('body_class', 'results');
                 $response->addMeta('description', "LiveWire's Electrical Transformer Tool Results: KVA = {$d_kva}, Phase = {$d_phase}, Input Volts = {$iv}, Output Volts = {$ov}");
             }
             $agent = new TransformerSelectionAgent($request->getGetParameters());
             if ($this->data = $agent->executeStep()) {
                 $this->found_new = false;
                 $this->found_rebuilt = false;
                 $this->img_src = sfConfig::get('app_parts_img_dir') . 'default.png';
                 // search for any available image in any of the returned parts
                 foreach ($this->data as $idx => $arr) {
                     if (!empty($arr['part']['img'])) {
                         $this->img_src = sfConfig::get('app_parts_img_dir') . strtolower(LWS::encode($arr['part']['part_no'])) . '.jpg';
                     }
                     /*
                      * LWS business model dictates that ONLY 1 refurbished transformer will be
                      * returned for any combination of selection values. Per adam, 8/19/2010.
                      */
                     // clean this up by removing the rebuilt part data into its own data structure
                     if (isset($arr['part']) && $arr['part']['manuf_slug'] == 'rebuilt') {
                         $this->found_rebuilt = true;
                         $this->rebuilt_idx = $idx;
                     } else {
                         $this->found_new = true;
                     }
                 }
                 return $template;
             } else {
                 /**
                  * I get here only if there is some sort of MySQL Error for the current step, 
                  * OR the current step returned an empty result set for the users current selections.
                  * Based on our database, and the SQL queries a user should never get here because
                  * of an empty result set.  So maybe put a 'technical difficulties' message here 
                  * or something...
                  */
                 //return sfView::ERROR;
                 $this->forward404();
             }
         } else {
             // user has made no selections and is on step 1
             $response->addMeta('description', "Easily find your Electrical Transformer with LiveWire Supply's Transformer tool. Enter KVA, Phase, Primary and Secondary Voltages. 800-390-3299");
             return sfView::SUCCESS;
         }
     }
 }
 /**
  * executes paypal subscription form
  *
  * @param sfWebRequest $request_object
  * @param returns paypal form.
  * gets values from get method
  */
 public function executeSubscriptionPurchase(sfWebRequest $request)
 {
     global $CFG;
     $bill_cycle = "Month";
     $this->params = $request->getGetParameters();
     $this->form = new GcrPurchaseForm();
     // sets institution, product short names and product type
     $this->form->setDefaults(array('purchase_type' => 'subscription', 'purchase_type_id' => $this->params["institution"] . "~" . $this->params["type"], 'purchase_type_eschool_id' => $CFG->current_app->getShortName(), 'bill_cycle' => $bill_cycle, 'purchase_token' => GcrEschoolTable::generateRandomString()));
     // set up object which hold info about the purchase item to display on form
     $this->purchaseObject = new StdClass();
     $this->hydratePurchaseObject($this->purchaseObject, 'subscription', $this->params["institution"] . "~" . $this->params["type"], $CFG->current_app->getShortName(), $bill_cycle);
     $this->getResponse()->setTitle('Subscription Purchase');
 }
Beispiel #22
0
 public function executeSet_state(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     $lParams = $request->getGetParameters();
     $lDeal = DealTable::getInstance()->find($lParams['deal_id']);
     $lPrevState = $lDeal->getState();
     $lError = "";
     if ($lDeal->canTransitionTo($lParams['state'])) {
         $lDeal->transitionTo($lParams['state']);
     } else {
         $lError = "Cannot transition to: " . $lParams['state'];
     }
     return $this->renderText(json_encode(array('success' => empty($lError), 'error' => $lError, 'html' => $this->getPartial('deals/deal_table_row_content', array('pDeal' => $lDeal)), 'state' => $lPrevState, 'classes' => $lDeal->getCssClasses())));
 }
 public function executeGetUserData(sfWebRequest $request)
 {
     $this->authorizeUser();
     $params = $request->getGetParameters();
     $sOrder = intval($params['iSortCol_0']);
     if ($params['bSortable_' . $sOrder] != "true") {
         $sOrder = 0;
     }
     $search_string = false;
     if (isset($params['sSearch']) && strlen($params['sSearch']) > 2) {
         $search_string = $params['sSearch'];
         $s = '%' . strtolower($search_string) . '%';
         $sql_params = array($s, $s, $s, $s);
     }
     $aaData = array();
     $mhr_users = array();
     $totalDisplayRecords = 0;
     if ($search_string) {
         foreach (GcrInstitutionTable::getInstitutions() as $institution) {
             $institution_name = '<a href="' . $institution->getAppUrl() . '" target="_blank">' . $institution->getFullName() . '</a>';
             $sql = 'select * from ' . $institution->getShortName() . '.mhr_usr ' . 'where deleted < 1 and id > 1 and (lower(firstname) like ? or lower(lastname) like ? or lower(email) like ? or lower(username) like ?)';
             $mhr_users = $institution->gcQuery($sql, $sql_params);
             if ($mhr_users && count($mhr_users) > 0) {
                 foreach ($mhr_users as $mhr_user) {
                     $fullname = trim($mhr_user->lastname) . ', ' . trim($mhr_user->firstname);
                     $fullname_url = '<a href="' . $institution->getAppUrl() . 'user/view?id=' . $mhr_user->id . '" target="_blank">' . trim($mhr_user->lastname) . ', ' . trim($mhr_user->firstname) . '</a>';
                     $username = trim($mhr_user->username);
                     $username_url = '<a href="/account/view?eschool=' . $institution->getShortName() . '&user='******'" target="_blank">' . $username . '</a>';
                     $email = trim($mhr_user->email);
                     $user_data = array($fullname_url, $username_url, $email, $institution_name, $mhr_user->lastaccess);
                     switch ($sOrder) {
                         case 1:
                             $key = $username;
                             break;
                         case 2:
                             $key = $email;
                             break;
                         case 3:
                             $key = $institution_name;
                             break;
                         case 4:
                             $key = $mhr_user->lastaccess;
                             break;
                         default:
                             $key = $fullname;
                     }
                     $aaData[strtolower($key)] = $user_data;
                 }
             }
         }
         $totalDisplayRecords = count($aaData);
         ksort($aaData);
         $aaData = array_values($aaData);
         if ($params['sSortDir_0'] == 'desc') {
             $aaData = array_reverse($aaData);
         }
         if (isset($params['iDisplayStart']) && $params['iDisplayLength'] != '-1') {
             $aaData = array_slice($aaData, $params['iDisplayStart'], $params['iDisplayLength']);
         }
     }
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     $output = array("sEcho" => intval($params['sEcho']), "iTotalRecords" => count($aaData), "iTotalDisplayRecords" => $totalDisplayRecords, "aaData" => $aaData);
     return $this->renderText(json_encode($output));
 }
 public function getGetParameters($isStripNullbyte = true)
 {
     if ($isStripNullbyte) {
         return opToolkit::stripNullByteDeep(parent::getGetParameters());
     } else {
         return parent::getGetParameters();
     }
 }
Beispiel #25
0
 public function executeStructureReportsToPDF(sfWebRequest $request)
 {
     $this->params = $request->getGetParameters();
     $this->generateStructureReports($this->params);
     $this->setLayout('cleanLayout');
 }