/**
  * approve a comment - so set its status to 1 
  **/
 public function approve()
 {
     $comment = new CmsComment(Request::get("id"));
     if ($comment->update_attributes(array("status" => 1))) {
         Session::add_message("Comment approved");
     }
     $this->redirect_to(array("action" => "index"));
 }
 /**
  * protected function that handles the actual db authentication check on first login
  * now also logs data regarding who has logged in
  * @return String url to redirect to
  **/
 protected function process_login()
 {
     $auth = new WaxAuthDb(array("db_table" => $this->model_name, "session_key" => "wildfire_user_cookie"));
     if ($auth->verify($_POST['username'], $_POST['password'])) {
         $log = new WildfireLog();
         $log->action = "login";
         $log->user = $auth->get_user();
         $log->time = date("Y-m-d H:i:s");
         $log->save();
         if ($this->authorised_redirect) {
             return $this->authorised_redirect;
         } else {
             return 'index';
         }
     } else {
         Session::add_message("Sorry, we can't find that username and password. Try again.");
         return $this->unauthorised_redirect;
     }
 }
 /**
  * Save
  * @param string $model 
  * @return boolean or redirect on success, sets message on success
  */
 protected function save($model, $redirect_to = false, $success = "Successfully Saved")
 {
     if ($model->is_posted()) {
         $id = $model->id;
         if (!$model->author_id && !$_POST[$this->model_name]['author_id']) {
             $model->author_id = $this->current_user->id;
         }
         if ($model->update_attributes($_POST[$this->model_name])) {
             //clear cache - rely on filename format of $id_
             foreach (File::scandir(CACHE_DIR) as $file) {
                 if (($pos = strpos($file, $model->id . '_')) == 0 && $pos !== false) {
                     unlink(CACHE_DIR . $file);
                 }
             }
             if ($redirect_to == "edit") {
                 $redirect_to = "edit/" . $id;
             } elseif ($this->allow_crops) {
                 $redirect_to = "crop/" . $id;
             } elseif (!$redirect_to) {
                 $redirect_to = "index";
             }
             Session::add_message($this->display_name . " " . $success);
             $this->redirect_to($redirect_to);
         }
     }
     return false;
 }
 public function create()
 {
     $this->display_action_name = 'Create';
     $model = $this->model;
     $this->model = new Campaign();
     $this->model->ClientID = $this->cm_conf['campaign_monitor_ClientID'];
     Session::unset_var('user_errors');
     //remove old errors;
     if ($this->model->is_posted()) {
         $this->model = $this->model->handle_post();
         $errors = "";
         if (count($this->model->errors)) {
             $errors .= "<br />" . implode("<br />", $this->model->errors);
         }
         if (strlen($errors) > 0) {
             $errors .= ":";
             foreach ($this->model->errors as $k => $val) {
                 $errors .= $val . "<br />";
             }
             Session::add_message('There was an error creating you campaign.' . $errors);
         } else {
             Session::add_message('Your campaign has been created!');
             $this->redirect_to('/admin/email');
         }
     }
     $lists = $model->GetLists();
     $this->mail_lists = array_merge(array('' => array('ListID' => '', 'Name' => 'None')), $lists->rowset);
     $segments = $model->GetSegments();
     $this->segments = array_merge(array('' => array('ListID' => '', 'Name' => 'None')), $segments->rowset);
     $cont = new CmsContent("published");
     $this->contents = $cont->all();
     $this->form = $this->render_partial("form");
 }
Example #5
0
 /**
  * delete model record
  */
 public function delete()
 {
     $id = WaxUrl::get("id");
     if (!$id) {
         $id = $this->route_array[0];
     }
     if ($id) {
         /*updated to new methods*/
         $field = $this->model->primary_key;
         $model = $this->model->clear()->filter($field . '=' . $id)->first()->limit(false)->delete();
         Session::add_message("Item successfully deleted");
         $this->redirect_to("/" . WaxUrl::get("controller") . "/index");
     }
 }
 /**
  * get the other language model for a master - creates one if it doesn't exist
  *
  * @param string $master 
  * @param integer $lang_id 
  * @return WaxModel - new language model
  */
 private function get_language_model($master, $lang_id)
 {
     $model = new $this->model_class();
     if ($lang_model = $model->filter(array('preview_master_id' => $master->primval, 'language' => $lang_id))->first()) {
         return $lang_model;
     } else {
         Session::add_message("A {$this->languages[$lang_id]} version of this content has been created. The {$this->languages[0]} content was copied into it for convenience.");
         //if a lang entry doesn't exist create one
         foreach ($master->columns as $col => $params) {
             if ($master->{$col}) {
                 $copy_attributes[$col] = $master->{$col};
             }
         }
         $copy_attributes = array_diff_key($copy_attributes, array($master->primary_key => false, 'revisions' => false));
         //take out ID and revisions
         $lang = new $this->model_class();
         $lang->save();
         $lang->set_attributes($copy_attributes);
         $lang->status = 5;
         $lang->url = $master->url;
         $lang->master = $master->primval;
         $lang->language = $lang_id;
         $lang->save();
         return $lang;
     }
 }