Beispiel #1
0
 private function execute(\Orm\Model $obj)
 {
     // 親記事削除時
     if (empty($this->_conditions['type'])) {
         // delete member_watch_content
         self::delete_member_watch_content($obj, $this->_conditions);
     }
     $notices = \Site_Model::get4relation('\\Notice\\Model_Notice', $this->_conditions, $obj);
     foreach ($notices as $notice) {
         // 親記事削除時
         if (empty($this->_conditions['type'])) {
             $notice->delete();
         } else {
             // delete notice_member_from
             if (self::delete_notice_member_from($notice->id, $obj->member_id)) {
                 $parent_content_member_id = \Site_Model::get_value4table_and_id($notice->foreign_table, $notice->foreign_id, 'member_id');
                 if (!\Notice\Model_NoticeMemberFrom::get_count4notice_id($notice->id, $parent_content_member_id)) {
                     $notice->delete();
                 }
             }
         }
     }
     // 親記事削除時
     if (empty($this->_conditions['type'])) {
         $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']);
         $foreign_id = $obj->id;
         $notices = \Notice\Model_Notice::get4parent_data($foreign_table, $foreign_id);
         foreach ($notices as $notice) {
             $notice->delete();
         }
     } else {
         $type = \Util_Array::get_first_key($this->_conditions['type']);
         // comment 削除時
         if ($type == \Notice\Site_Util::get_notice_type('comment')) {
             $foreign_table = \Util_Array::get_first_key($this->_conditions['foreign_table']) . '_comment';
             $foreign_id = $obj->id;
             $notices = \Notice\Model_Notice::get4foreign_data($foreign_table, $foreign_id);
             foreach ($notices as $notice) {
                 $notice->delete();
             }
         }
     }
 }
Beispiel #2
0
 public function get_file_objects_from_related_model($model_objs, $image_names_posted = array())
 {
     $files = array();
     if (!$model_objs) {
         return $files;
     }
     $key = Util_Array::get_first_key($model_objs);
     $table = $model_objs[$key]->table();
     $need_member_id_tables = array('album_image');
     if (in_array($table, $need_member_id_tables) && !$this->options['member_id']) {
         throw new \FuelException('Need member_id.');
     }
     $file_cate = $model_objs[$key]->get_image_prefix();
     $cache_size = conf('upload.types.img.types.' . $file_cate . '.sizes.thumbnail');
     foreach ($model_objs as $model_obj) {
         $file_name = $this->remove_filename_prefix($model_obj->file_name);
         if (!($file = $this->get_file_object($file_name))) {
             continue;
         }
         $file_obj = Model_File::get4name($model_obj->file_name);
         $file->is_tmp = false;
         $file->name_prefix = $this->options['filename_prefix'];
         $file->id = (int) $model_obj->id;
         $file->original_name = $file_obj->original_filename;
         $file->thumbnail_uri = Site_Upload::get_uploaded_file_path($model_obj->file_name, $cache_size, 'img', false, true);
         $file->description = $model_obj->name;
         if (isset($image_names_posted[$model_obj->id]) && strlen($image_names_posted[$model_obj->id])) {
             $file->description = $image_names_posted[$model_obj->id];
         }
         if (!empty($this->options['accept_sizes'])) {
             $file->accept_sizes = $this->options['accept_sizes'];
         }
         $files[] = $file;
     }
     return $files;
 }
Beispiel #3
0
 public static function get_file_objects($model_objs, $parent_id, $is_admin = null, $member_id = null, $type = 'img', $with_accept_sizes = false)
 {
     if (!($key = Util_Array::get_first_key($model_objs))) {
         return array();
     }
     $file_cate = $model_objs[$key]->get_image_prefix();
     $options = self::get_upload_handler_options($member_id, $is_admin, false, $file_cate, $parent_id, true, $type, $with_accept_sizes);
     $uploadhandler = new \MyUploadHandler($options, false);
     return $uploadhandler->get_file_objects_from_related_model($model_objs, \Input::post($type == 'img' ? 'image_description' : 'file_description'));
 }