Exemple #1
0
 function insertPost($post_data, $tags, $image)
 {
     $this->db->trans_start();
     // try to write the post text data
     if (!$this->db->insert('post', $post_data)) {
         $result->error = 'Error while writing tribble data.';
         log_message('error', 'Error while writing post data.');
     } else {
         log_message('debug', 'Post data writen');
     }
     // get the post id from the last insert
     $post_id = $this->db->insert_id();
     $tagdata['tag_content'] = $tags;
     $tagdata['tag_post_id'] = $post_id;
     // try to write the tag data
     if (!$this->db->insert('tag', $tagdata)) {
         $result->error = 'Error while writing tag data.';
         log_message('error', 'Error while writing post tag data.');
     } else {
         log_message('debug', 'tag data writen');
     }
     // get the image data
     $imagedata['image_post_id'] = $post_id;
     $imagedata['image_path'] = $image['path'];
     // try to write the image data
     if (!$this->db->insert('image', $imagedata)) {
         $result->error = 'Error while writing image data.';
         log_message('error', 'Error while writing post image data.');
     } else {
         log_message('debug', 'image data was writen');
     }
     // store the image palette
     if (!($colors = GetImagePalette($this->config->item('app_path') . $imagedata['image_path'], $post_id))) {
         log_message('error', 'Error while obtaining post palette data.');
     } else {
         log_message('debug', 'palette data was obtained');
     }
     foreach ($colors as $color) {
         if (!$this->db->insert('palette', $color)) {
             log_message('error', 'Error while post palette data: ' . $color['HEX']);
         } else {
             log_message('debug', 'palette data writen.');
         }
     }
     $likedata['like_post_id'] = $post_id;
     $likedata['like_user_id'] = $post_data['post_user_id'];
     if (!$this->db->insert('like', $likedata)) {
         $result->error = "Error while writing like data";
         log_message('error', 'Error while post like data.');
     } else {
         log_message('debug', 'like data writen');
     }
     $this->db->trans_complete();
     if ($this->db->trans_status() === FALSE) {
         return false;
     } else {
         return $post_id;
     }
 }
Exemple #2
0
 public function updatepalette_get()
 {
     // load the memcached driver
     $this->load->driver('cache');
     // load the posts model
     $this->load->model('Meta_API_model', 'mMeta');
     $limit = $this->get('limit');
     if (!$limit) {
         $limit = 28;
     }
     // create the final array
     // get the data from the database
     if ($images = $this->mMeta->getImagePaths()) {
         foreach ($images as $image) {
             $full_path = $this->config->item('app_path') . $image->image_path;
             // var_dump($full_path);
             $this->mMeta->transferPalette(GetImagePalette($full_path, $image->post_id));
         }
     }
 }