コード例 #1
0
 public function move_to_drafts($dummy)
 {
     $rules = array('subject' => 'required|max:128', 'emailbody' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json(array('validation' => $validator->messages()->toArray()));
     } else {
         $draft = new Draft();
         $draft->subject = Input::get('subject');
         $draft->message = Input::get('emailbody');
         $draft->save();
         return Response::json(array('success' => 'Email successfully moved to drafts. You can access it by navigating to the drafts tab.'));
     }
 }
コード例 #2
0
 public static function store()
 {
     self::check_logged_in();
     $user_logged_in = self::get_user_logged_in();
     $params = $_POST;
     $attributes = array('name' => $params['name'], 'laatija_id' => $user_logged_in->id, 'hero1' => $params['hero1'], 'hero2' => $params['hero2'], 'hero3' => $params['hero3'], 'hero4' => $params['hero4'], 'hero5' => $params['hero5'], 'vaikeus' => $params['vaikeus'], 'suunnitelma' => $params['suunnitelma']);
     $draft = new Draft($attributes);
     $errors = $draft->errors();
     if (count($errors) == 0) {
         $draft->save();
         Redirect::to('/drafts' . $draft->id, array('message' => 'Drafti on lisätty arkistoon!'));
     } else {
         $heroes = Hero::all();
         View::make('drafts/new.html', array('errors' => $errors, 'attributes' => $attributes, 'heroes' => $heroes));
     }
 }
コード例 #3
0
 function index()
 {
     list($params, $id) = $this->parse_params(func_get_args());
     $theme = new Theme();
     $themes = $theme->read(true);
     if ($this->method == 'post' && isset($_POST['theme'])) {
         $t = $_POST['theme'];
         if (isset($themes[$t])) {
             $d = new Draft();
             $d->where('draft', 1)->update('draft', 0);
             $d->where('path', $t)->get();
             $d->path = $t;
             $d->draft = 1;
             if (isset($_POST['refresh'])) {
                 $d->init_draft_nav($_POST['refresh']);
             }
             $d->save();
             $this->redirect('/drafts');
         } else {
             // error
         }
     } else {
         if ($this->method == 'delete' && isset($_POST['theme'])) {
             $d = new Draft();
             $d->where('path', $_POST['theme'])->get();
             if ($d->exists()) {
                 $d->delete();
             }
             exit;
         }
     }
     $final = array();
     $d = new Draft();
     $drafts = $d->get_iterated();
     foreach ($drafts as $d) {
         if (isset($themes[$d->path])) {
             $final[] = array('id' => $d->id, 'theme' => $themes[$d->path], 'published' => (bool) $d->current, 'active' => (bool) $d->draft, 'created_on' => (int) $d->created_on, 'modified_on' => (int) $d->modified_on);
         }
     }
     $this->set_response_data($final);
 }
コード例 #4
0
ファイル: sites.php プロジェクト: Caldis/htdocs
 function publish($draft_id = false)
 {
     if (!$draft_id) {
         $this->error('400', 'Draft ID parameter not present.');
         return;
     }
     if ($this->method === 'post') {
         $draft = new Draft();
         $draft->where('id', $draft_id)->get();
         if ($draft->exists()) {
             $draft->where('current', 1)->update('current', 0);
             $draft->live_data = $draft->data;
             $draft->current = 1;
             $draft->save();
             $guid = FCPATH . 'storage' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $draft->path . DIRECTORY_SEPARATOR . 'koken.guid';
             if (file_exists($guid)) {
                 $s = new Setting();
                 $s->where('name', 'uuid')->get();
                 $curl = curl_init();
                 curl_setopt($curl, CURLOPT_URL, KOKEN_STORE_URL . '/register?uuid=' . $s->value . '&theme=' . trim(file_get_contents($guid)));
                 curl_setopt($curl, CURLOPT_HEADER, 0);
                 curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
                 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                 $r = curl_exec($curl);
                 curl_close($curl);
             }
             exit;
         } else {
             $this->error('404', "Draft not found.");
             return;
         }
     } else {
         $this->error('400', 'This endpoint only accepts tokenized POST requests.');
         return;
     }
 }
コード例 #5
0
 public function sendMessage()
 {
     $recipient = Input::get('recipient');
     $subject = Input::get('subject');
     $message = Input::get('message');
     $submit_type = Input::get('submit_type');
     $now = new DateTime();
     $validation = Validator::make(['recipient' => Input::get('recipient'), 'subject' => Input::get('subject'), 'message' => Input::get('message')], ['recipient' => 'required', 'subject' => 'required|max:40|min:4', 'message' => 'required|max:120|min:10']);
     if ($validation->fails()) {
         return 'Error Happend';
     } else {
         try {
             if ($submit_type == "Send") {
                 $inbox = new Inbox();
                 $inbox->sender_id = Auth::id();
                 $inbox->receiver_id = $recipient;
                 $inbox->unread = 1;
                 $inbox->subject = $subject;
                 $inbox->message = $message;
                 $inbox->time = $now;
                 $inbox->save();
                 return Redirect::route('home');
             } elseif ($submit_type == "Draft") {
                 $draft = new Draft();
                 $draft->creator_id = Auth::id();
                 $draft->send_to_id = $recipient;
                 $draft->subject = $subject;
                 $draft->message = $message;
                 $draft->time = $now;
                 $draft->save();
                 return Redirect::route('home');
             }
         } catch (Exception $e) {
             echo $e;
         }
     }
 }