function execute()
 {
     $context = $this->getContext();
     $controller = $context->getController();
     $request = $context->getRequest();
     $user = $context->getUser();
     //削除処理を行う
     $target_user_community_id = $request->getParameter('id');
     $acs_user_info_row = $user->getAttribute('acs_user_info_row');
     $file_id = $request->getParameter('file_id');
     $open_level_code = $request->getParameter('open_level_code');
     if (!$this->get_execute_privilege()) {
         $controller->forward(SECURE_MODULE, SECURE_ACTION);
         return;
     }
     // ファイル情報取得
     $file_obj = ACSFile::get_file_info_instance($file_id);
     //ファイル情報テーブルのデータ削除
     ACSDB::_do_query("BEGIN");
     $ret = ACSCommunityImageFileModel::delete_community_image_with_open_level($file_obj, $open_level_code);
     if (!$ret) {
         ACSDB::_do_query("ROLLBACK");
         print "ERROR: Delete image failed. :image_file";
     } else {
         $row = ACSCommunityImageFileModel::get_file_id_with_open_level($file_obj->get_owner_community_id());
         if ($row == NULL || $file_id != $row['file_id_ol05'] && $file_id != $row['file_id_ol02'] && $file_id != $row['file_id_ol01']) {
             // ファイルごと削除
             $ret = $file_obj->delete_file();
         }
         if (!$ret) {
             ACSDB::_do_query("ROLLBACK");
             print "ERROR: Delete image failed. :image_file";
         } else {
             ACSDB::_do_query("COMMIT");
         }
     }
     //表示
     $image_change_url = $this->getControllerPath('User', 'EditProfileImage');
     $image_change_url .= '&id=' . $target_user_community_id;
     header("Location: {$image_change_url}");
     return View::INPUT;
 }
Esempio n. 2
0
 /**
  * image_urlをopen_level別に取得する
  *
  * @param user_community_id ユーザのコミュニティID
  * @param open_level_code_row 公開レベルコードの行
  * @param view_mode 表示モード : NULL, thumb, rss
  * @return 成功(true) / 失敗(false)
  */
 static function get_image_url_with_open_level($user_community_id, $open_level_code_row, $view_mode = '')
 {
     $row = ACSCommunityImageFileModel::get_file_id_with_open_level($user_community_id);
     $image_url = array();
     for ($i = 0; $i < count($open_level_code_row); $i++) {
         if ($row && $row['file_id_ol' . $open_level_code_row[$i]] != '') {
             $image_url[$i] = SCRIPT_PATH . '?';
             $image_url[$i] .= MODULE_ACCESSOR . '=User';
             $image_url[$i] .= '&' . ACTION_ACCESSOR . '=EditProfileImageDisp';
             $image_url[$i] .= '&id=' . $user_community_id;
             $image_url[$i] .= '&mode=' . $view_mode;
             $image_url[$i] .= '&open_level_code=' . $open_level_code_row[$i];
         } else {
             $image_url[$i] = ACSUser::get_default_image_url($view_mode);
         }
     }
     return $image_url;
 }
 /**
  * 該当の公開範囲のファイルIDを取得する
  *
  * @param $community_id コミュニティID
  * @param $open_level_code 公開範囲
  * @return 該当の公開範囲のファイルID
  */
 static function get_file_id_for_open_level($community_id, $open_level_code)
 {
     if (!$community_id) {
         return null;
     }
     if (!$open_level_code) {
         return null;
     }
     $row = ACSCommunityImageFileModel::get_file_id_with_open_level($community_id);
     $match_file_id = $row['file_id_ol' . $open_level_code];
     if (!$match_file_id) {
         return NULL;
     }
     $match_count = 0;
     if ($match_file_id == $row['file_id_ol05']) {
         $match_count++;
     }
     if ($match_file_id == $row['file_id_ol02']) {
         $match_count++;
     }
     if ($match_file_id == $row['file_id_ol01']) {
         $match_count++;
     }
     if ($match_count == 1) {
         return $match_file_id;
     }
     return NULL;
 }