Exemple #1
0
 function save($send_confirmation_email = false)
 {
     $db = DB::connect(DB_CONNECTION_STRING);
     //Check if it exists, the do an update or insert
     $exists = false;
     if ($this->user_id != 0) {
         $sql = "select user_id from user where user_id = " . $this->user_id;
         $results = $db->query($sql);
         if (sizeof($results) != 0) {
             $exists = true;
         }
     }
     if (!$exists) {
         $this->add();
     } else {
         $this->update();
     }
     //Send email
     if ($send_confirmation_email == true) {
         $smarty = new Smarty();
         $smarty->force_compile = true;
         $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
         $smarty->assign("email", $this->email);
         $smarty->assign("postcode", clean_postcode($this->postcode));
         $smarty->assign("url", BASE_URL . "/confirmed.php?cid=" . $this->confirm_id);
         //Get the email text
         $email_text = $smarty->fetch('confirm_email_text.tpl');
         //Send the email
         send_text_email($this->email, EMAIL_FROM_NAME, EMAIL_FROM_ADDRESS, "Please confirm your planning alert", $email_text);
     }
 }
 function bind()
 {
     $form_action = $_SERVER['PHP_SELF'];
     //smarty
     $smarty = new Smarty();
     $smarty->force_compile = true;
     $smarty->compile_dir = SMARTY_COMPILE_DIRECTORY;
     $smarty->assign("stats", stats::get_stats());
     $smarty->assign("menu_item", "signup");
     $smarty->assign("page_title", "Confirmed");
     $smarty->assign("form_action", $form_action);
     $smarty->assign("postcode", clean_postcode($this->postcode));
     $smarty->assign("alert_area_size", $this->alert_area_size);
     //Render
     $smarty->display('confirmed.tpl');
 }
 public function guess_search_type($query)
 {
     $return_type = "text";
     $return_value = null;
     $return_display = null;
     if (is_postcode($query)) {
         $return_type = "postcode";
         $return_display = clean_postcode($query);
     } else {
         if (is_partial_postcode($query)) {
             $return_type = "partial postcode";
             $return_display = strtoupper($query);
         } else {
             //party name
             $search = factory::create("search");
             $result = $search->search("party", array(array("name", "=", $query), array("country_id", "=", $this->country_id)));
             if (count($result) == 1) {
                 $return_type = "party";
                 $return_value = $result[0]->party_id;
                 $return_display = $result[0]->name;
             } else {
                 //TODO: match a place name
             }
         }
     }
     return array("type" => $return_type, "value" => $return_value, "display" => $return_display);
 }