Exemplo n.º 1
0
 public function init()
 {
     $this->addGroup("default");
     $this->addGroup("hidden");
     $e = new Daq_Form_Element("purchase", Daq_Form_Element::TYPE_HIDDEN);
     $e->setValue(1);
     $e->setRequired(true);
     $this->addElement($e, "hidden");
     $payment = new Wpjb_Payment_Factory();
     if (count($payment->getEngines()) > 1) {
         $v = array();
         $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_SELECT);
         $e->setRequired(true);
         $e->setLabel(__("Payment Method", WPJB_DOMAIN));
         foreach ($payment->getEngines() as $key => $engine) {
             /* @var $engine Wpjb_Payment_Interface */
             $engine = new $engine();
             $pTitle = $engine->getTitle();
             $e->addOption($key, $key, $pTitle);
             $v[] = $key;
         }
         $e->addValidator(new Daq_Validate_InArray($v));
         $this->addElement($e, "default");
     } else {
         $engine = current($payment->getEngines());
         $engine = new $engine();
         $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_HIDDEN);
         $e->setValue($engine->getEngine());
         $e->addValidator(new Daq_Validate_InArray(array($engine->getEngine())));
         $e->setRequired(true);
         $this->addElement($e, "hidden");
     }
 }
Exemplo n.º 2
0
 public function notifyAction()
 {
     $payment = $this->getObject();
     $payment->made_at = date("Y-m-d H:i:s");
     $paypal = Wpjb_Payment_Factory::factory($payment);
     try {
         $paypal->processTransaction($this->getRequest()->getAll());
         if ($payment->object_type == Wpjb_Model_Payment::FOR_JOB) {
             $this->_notifyJob($payment->object_id);
         } elseif ($payment->object_type == Wpjb_Model_Payment::FOR_RESUMES) {
             $this->_notifyResume($payment->object_id);
         } else {
             // wtf?
         }
         $payment->payment_paid = $this->getRequest()->post("mc_gross");
         $payment->external_id = $this->getRequest()->post("txn_id");
         $payment->is_valid = 1;
         $payment->save();
     } catch (Exception $e) {
         $payment->message = $e->getMessage();
         $payment->is_valid = 0;
         $payment->save();
     }
     exit;
     return false;
 }
Exemplo n.º 3
0
 public function run()
 {
     add_action("edit_user_profile", array(self::$_instance, "editUserProfile"));
     add_action("edit_user_profile_update", array(self::$_instance, "saveUserProfile"));
     add_filter("init", array(self::$_instance, "init"));
     add_filter("wp_title", array(self::$_instance, "injectTitle"));
     add_filter("single_post_title", array(self::$_instance, "injectTitle"));
     add_filter('rewrite_rules_array', array(self::$_instance, "rewrite"));
     add_filter('the_title', array(self::$_instance, "theTitle"), 10, 2);
     add_filter('the_content', array(self::$_instance, "theContent"));
     add_filter('wp', array(self::$_instance, "execute"));
     add_filter('redirect_canonical', array(self::$_instance, "redirectCanonical"));
     add_action('delete_user', array(self::$_instance, "removeUser"));
     add_action('admin_menu', array(self::$_instance, "addAdminMenu"));
     add_action('admin_print_scripts', array(self::$_instance, "addScripts"));
     add_action('wp_print_scripts', array(self::$_instance, "addScriptsFront"));
     add_action('admin_notices', array(self::$_instance, "adminNotices"));
     add_action('wp_dashboard_setup', array(self::$_instance, "addDashboardWidgets"));
     add_filter('query_vars', array(self::$_instance, "queryVars"));
     add_action("wp_footer", array(self::$_instance, "shutdown"));
     add_action("wp_enqueue_scripts", array(self::$_instance, "enqueueScripts"));
     add_action("admin_bar_menu", array($this, "adminBarMenu"), 1000);
     add_shortcode('wpjb_search', 'wpjb_search_form');
     $this->_init();
     $directory = $this->env("directory");
     $logo = site_url() . "/wp-content/plugins/{$directory}";
     $logo .= $this->pathRaw("admin_public") . "/wpjb-midi.gif";
     $this->getAdmin()->getView()->slot("midi_logo", $logo);
     $paymentFactory = new Wpjb_Payment_Factory();
     foreach ((array) glob($this->getBaseDir() . "/application/libraries/Payment/*.php") as $ajax) {
         $ctrl = basename($ajax, ".php");
         if (in_array($ctrl, array("Factory", "Interface"))) {
             continue;
         }
         $payment = "Wpjb_Payment_" . $ctrl;
         $payment = new $payment();
         if ($payment instanceof Wpjb_Payment_Interface) {
             $paymentFactory->register($payment);
         }
     }
     Wpjb_Utility_Registry::set("payment_factory", $paymentFactory);
 }
Exemplo n.º 4
0
 protected function _premiumRequest()
 {
     $object = Wpjb_Model_Employer::current();
     $buy = (int) $this->_request->post("purchase", 0);
     $curr = Wpjb_List_Currency::getCurrencySymbol(Wpjb_Project::getInstance()->conf("cv_access_curr"));
     $this->view->payment = $curr . number_format(Wpjb_Project::getInstance()->conf("cv_access_cost"), 2);
     $this->view->active_until = $this->_activeUntil();
     $this->view->purchase = 0;
     $this->view->form = new Wpjb_Form_Frontend_ResumesAccess();
     if (!$this->isPost()) {
         return;
     }
     if (!$this->view->form->isValid($this->getRequest()->getAll())) {
         return;
     }
     $access = new Wpjb_Model_ResumesAccess();
     $access->employer_id = Wpjb_Model_Employer::current()->getId();
     $access->extend = Wpjb_Project::getInstance()->conf("cv_extend");
     $access->created_at = date("Y-m-d H:i:s");
     $access->save();
     $payment = new Wpjb_Model_Payment();
     $payment->object_type = Wpjb_Model_Payment::FOR_RESUMES;
     $payment->object_id = $access->getId();
     $payment->user_id = $access->employer_id;
     $payment->engine = $this->view->form->getElement("payment_method")->getValue();
     $payment->payment_currency = Wpjb_Project::getInstance()->conf("cv_access_curr");
     $payment->payment_sum = Wpjb_Project::getInstance()->conf("cv_access_cost");
     $payment->payment_paid = 0;
     $payment->save();
     $paypal = Wpjb_Payment_Factory::factory($payment);
     $this->view->paypal = $paypal;
     $this->view->purchase = 1;
 }
Exemplo n.º 5
0
 public function isValid($values)
 {
     if (!$this->hasElement("listing")) {
         $listing = new Daq_Db_Query();
         $listing->select("*")->from("Wpjb_Model_Listing t")->limit(1);
         list($listing) = $listing->execute();
         $e = new Daq_Form_Element("listing");
         $e->setValue($listing->id);
         $this->addElement($e);
         $values["listing"] = $listing->id;
     }
     if (!$this->hasElement("payment_method")) {
         $payment = new Wpjb_Payment_Factory();
         $engine = new ArrayIterator($payment->getEngines());
         $engine = $engine->key();
         $e = new Daq_Form_Element("payment_method");
         $e->setValue($engine);
         $this->addElement($e);
         $values["payment_method"] = $engine;
     }
     $listing = new Wpjb_Model_Listing($values["listing"]);
     $validator = new Wpjb_Validate_Coupon($listing->currency);
     if ($this->hasElement("coupon")) {
         $this->getElement("coupon")->addValidator($validator);
     }
     $valid = parent::isValid($values);
     $discountObject = null;
     if (strlen($values['coupon']) > 0 && $valid) {
         $query = new Daq_Db_Query();
         $result = $query->select("*")->from("Wpjb_Model_Discount t")->where("code = ?", $values['coupon'])->limit(1)->execute();
         $discountObject = $result[0];
         $listing->addDiscount($discountObject);
     }
     if ($valid) {
         list($price, $discount) = $listing->calculatePrice();
         if ($discountObject) {
             $e = new Daq_Form_Element("discount_id");
             $e->setValue($discountObject->id);
             $this->addElement($e);
         }
         $e = new Daq_Form_Element("job_modified_at");
         $e->setValue(date("Y-m-d H:i:s"));
         $this->addElement($e);
         $e = new Daq_Form_Element("job_created_at");
         $e->setValue(date("Y-m-d H:i:s"));
         $this->addElement($e);
         $e = new Daq_Form_Element("job_expires_at");
         if ($listing->visible == 0) {
             $expiresAt = "9999-12-31 23:59:59";
         } else {
             $expiresAt = strtotime("now +" . $listing->visible . " days");
             $expiresAt = date("Y-m-d H:i:s", $expiresAt);
         }
         $e->setValue($expiresAt);
         $this->addElement($e);
         $e = new Daq_Form_Element("job_visible");
         $e->setValue($listing->visible);
         $this->addElement($e);
         $e = new Daq_Form_Element("job_source");
         $e->setValue(1);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_filled");
         $e->setValue(0);
         $this->addElement($e);
         $isActive = Wpjb_Project::getInstance()->getConfig("posting_moderation");
         $isActive = !(bool) $isActive;
         if ($price > 0) {
             $isActive = false;
         }
         $e = new Daq_Form_Element("is_approved");
         $e->setValue($isActive);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_active");
         $e->setValue($isActive);
         $this->addElement($e);
         $e = new Daq_Form_Element("is_featured");
         $e->setValue($listing->is_featured);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_sum");
         $e->setValue($price);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_paid");
         $e->setValue(0);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_currency");
         $e->setValue($listing->currency);
         $this->addElement($e);
         $e = new Daq_Form_Element("payment_discount");
         $e->setValue($discount);
         $this->addElement($e);
         $slug = Wpjb_Utility_Slug::generate(Wpjb_Utility_Slug::MODEL_JOB, $values['job_title']);
         $e = new Daq_Form_Element("job_slug");
         $e->setValue($slug);
         $this->addElement($e);
         $e = new Daq_Form_Element("employer_id");
         $e->setValue($this->_getEmployerId());
         $this->addElement($e);
     }
     return $valid;
 }
Exemplo n.º 6
0
 public function paymentAction()
 {
     $payment = $this->getObject();
     $button = Wpjb_Payment_Factory::factory($payment);
     $this->_setTitle(__("Payment", WPJB_DOMAIN));
     if ($payment->payment_sum == $payment->payment_paid) {
         $this->view->_flash->addInfo(__("This payment was already processed correctly.", WPJB_DOMAIN));
         return false;
     }
     if ($payment->object_type == 1) {
         $this->view->job = new Wpjb_Model_Job($payment->object_id);
     }
     $this->view->payment = $payment;
     $this->view->button = $button;
     $this->view->currency = Wpjb_List_Currency::getCurrencySymbol($payment->payment_currency);
 }
Exemplo n.º 7
0
 public function saveAction()
 {
     if (!$this->_canPost()) {
         wp_redirect($this->_stepAdd);
     }
     $this->view->current_step = 3;
     $form = new Wpjb_Form_AddJob();
     $request = $this->getRequest();
     $id = $request->session("wpjb.job_id");
     if ($id < 1) {
         if ($form->isValid($request->session("wpjb.job", array()))) {
             $paymentMethod = $form->getElement("payment_method")->getValue();
             $form->save();
             $job = $form->getObject();
             if (strlen($request->session("wpjb.job_logo_ext")) > 0) {
                 $ext = $request->session("wpjb.job_logo_ext");
                 $path1 = Wpjb_List_Path::getPath("tmp_images");
                 $path2 = Wpjb_List_Path::getPath("user_images");
                 $oldName = $path1 . "/temp_" . session_id() . "." . $ext;
                 $newName = $path2 . "/job_" . $job->getId() . "." . $ext;
                 $job->company_logo_ext = $ext;
                 $job->save();
                 rename($oldName, $newName);
             }
             if ($job->payment_sum > 0) {
                 $uid = null;
                 if (wp_get_current_user()->ID > 0) {
                     $uid = wp_get_current_user()->ID;
                 }
                 $payment = new Wpjb_Model_Payment();
                 $payment->user_id = $uid;
                 $payment->object_id = $job->getId();
                 $payment->object_type = Wpjb_Model_Payment::FOR_JOB;
                 $payment->engine = $paymentMethod;
                 $payment->payment_currency = $job->payment_currency;
                 $payment->payment_sum = $job->payment_sum;
                 $payment->payment_paid = 0;
                 $payment->save();
             }
             $request->setSessionParam("wpjb.job", null);
             $request->setSessionParam("wpjb.job_logo_ext", null);
             $request->setSessionParam("wpjb.job_id", $job->getId());
         } else {
             wp_redirect(Wpjb_Project::getInstance()->getUrl() . "/" . $this->_getRouter()->linkTo("step_add"));
         }
     } else {
         $job = new Wpjb_Model_Job($id);
     }
     if ($job->payment_sum > 0) {
         if ($job->payment_sum != $job->payment_paid) {
             $action = "payment_form";
         } else {
             $action = "payment_already_sent";
         }
     } else {
         $action = "job_online";
         if ($job->is_active && $job->is_approved) {
             $online = true;
         } else {
             $online = false;
         }
         $this->view->online = $online;
     }
     if ($action == "payment_form") {
         $payment = Wpjb_Payment_Factory::factory($job->getPayment(true));
         $this->view->payment = $payment->render();
     }
     $this->view->action = $action;
     $this->view->job = $job;
 }