Beispiel #1
0
 public function add()
 {
     $redirect = null;
     $view = null;
     $url = isset($this->db_clean->url) ? $this->db_clean->url : null;
     $title = isset($this->db_clean->title) ? $this->db_clean->title : null;
     $options = array('url' => $url, 'title' => $title);
     // If label id was passed, use it.
     if (isset($this->clean->label_id) && is_numeric($this->clean->label_id)) {
         $options['label_id'] = $this->clean->label_id;
     }
     // If notes are present, use them
     if (isset($this->db_clean->notes) && !empty($this->db_clean->notes)) {
         $options['notes'] = $this->db_clean->notes;
     }
     // Add mark
     $user_mark = parent::addMark($options);
     // Set some info
     if (!isset($user_mark->mark_id)) {
         $this->data['no_header'] = true;
         $this->data['no_footer'] = true;
         $this->data['errors'] = $user_mark;
         $view = 'marks/error';
     } else {
         $this->data['mark'] = $user_mark;
         $redirect = '/mark/info/' . $user_mark->mark_id . '?bookmarklet=true';
     }
     // Figure what to do here (api, redirect or generate view)
     $this->figureView($view, $redirect);
 }
Beispiel #2
0
 public function user()
 {
     $email = isset($this->db_clean->email) ? $this->db_clean->email : null;
     $password = isset($this->clean->password) ? $this->clean->password : null;
     $this->data['success'] = false;
     $this->load->model('users_model', 'user');
     $user = $this->user->create(array('email' => $email, 'password' => $password, 'active' => '1'));
     // If good
     // Add user data to session
     // Set user id
     // Add defualt marks
     // Set redirect to /marks
     // Set default marks (can't really do this)
     if (isset($user->user_id)) {
         $this->sessionAddUser($user);
         // Set user id
         $this->user_id = $user->user_id;
         // Now add default marks to user account
         $default_marks = $this->config->item('new_account_links');
         if (!empty($default_marks)) {
             foreach ($default_marks as $title => $arr) {
                 $title = $this->db->escape_str($title);
                 $url = $this->db->escape_str($arr['url']);
                 $label_id = $this->db->escape_str($arr['label_id']);
                 $res = parent::addMark(array('url' => $url, 'title' => $title, 'label_id' => $label_id));
             }
         }
         // set redirect path
         $redirect = '/marks';
         $this->data['success'] = true;
         $this->data['email'] = $email;
     } else {
         $redirect = '/register';
         $this->setFlashMessage($user);
         foreach ($user as $error_code => $message) {
             $this->data['message'] = $message;
         }
     }
     // Redirect for web view or print for ajax call
     $this->figureView(null, $redirect);
 }