--- /dev/null
+<?php
+/**
+ * ¥×¥í¥Õ¥£¡¼¥ë¼Ì¿¿¥¢¥Ã¥×¥í¡¼¥É
+ * UploadImageAction.class.php
+ *
+ * @author $Author: w-ota $
+ * @version $Revision: 1.6 $
+ * @import ACSFile.class.php
+ * @import ACSCommunityImageFileModel.class.php
+ * @import ACSFileInfoModel.class.php
+ */
+//require_once(ACS_CLASS_DIR . 'ACSFile.class.php');
+//require_once(ACS_CLASS_DIR . 'ACSCommunityImageFileModel.class.php');
+//require_once(ACS_CLASS_DIR . 'ACSFileInfoModel.class.php');
+
+class UploadProfileImageAction extends BaseAction
+{
+ function execute () {
+ $context = $this->getContext();
+ $controller = $context->getController();
+ $request = $context->getRequest();
+ $user = $context->getUser();
+
+ $target_user_community_id = $request->getParameter('community_id');
+ $image_new_mode = $request->getParameter('image_new_mode');
+ $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+ $file_id = $request->getParameter('file_id');
+
+ if (!$this->get_execute_privilege()) {
+ $controller->forward(SECURE_MODULE, SECURE_ACTION);
+ return;
+ }
+
+ //Äɲäȹ¹¿·¤Îʬ´ô ver1.1
+ // $image_new_mode¥Õ¥é¥°
+ // file_info¥Æ¡¼¥Ö¥ë¤Ø¤ÎÄɲÃtrue¤Þ¤¿¤Ï¹¹¿·false
+ if($image_new_mode){
+ // ¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ(¿·µ¬¤Î¾ì¹ç)
+ $file_obj = ACSFile::get_upload_file_info_instance($_FILES['new_file'],$target_user_community_id,$acs_user_info_row['user_community_id']);
+ } else {
+ // ¥Õ¥¡¥¤¥ë¾ðÊó¼èÆÀ(¹¹¿·¤Î¾ì¹ç)
+ $file_obj = ACSFile::get_upload_file_info_instance(
+ $_FILES['new_file'],$target_user_community_id,$acs_user_info_row['user_community_id'],
+ $file_id);
+ }
+
+ //¥Õ¥¡¥¤¥ë¤Î¼ïÎà¥Á¥§¥Ã¥¯
+ $image_check = $file_obj->is_image_file();
+ if (!$image_check) {
+ print "ERROR: This file is not image-format.";
+ }
+
+ /* ¥Õ¥¡¥¤¥ë¥¢¥Ã¥×¥í¡¼¥É½èÍý */
+
+ // ¥Õ¥¡¥¤¥ë¤ÎÊݸ
+ $ret = $file_obj->save_upload_file('PROFILE');
+
+ ACSDB::_do_query("BEGIN");
+ if($image_new_mode){
+ $ret = $file_obj->add_file();
+ } else {
+ $ret = ACSFileInfoModel::update_all_file_info($file_obj);
+ }
+
+ if (!$ret) {
+ ACSDB::_do_query("ROLLBACK");
+ print "ERROR: Upload image-file failed.:file_info";
+ } else if($image_new_mode) {
+ //community_image_file¥Æ¡¼¥Ö¥ë¤Ø¤ÎÄɲÃ
+ $ret = ACSCommunityImageFileModel::insert_community_image($file_obj);
+ if (!$ret) {
+ ACSDB::_do_query("ROLLBACK");
+ print "ERROR: Upload image-file failed.:image_file";
+ } else {
+ ACSDB::_do_query("COMMIT"); //Äɲå⡼¥É¤Î¥³¥ß¥Ã¥È
+ }
+ } else {
+ ACSDB::_do_query("COMMIT"); //¹¹¿·¥â¡¼¥É¤Î¥³¥ß¥Ã¥È
+ }
+
+ /* ɽ¼¨¥¢¥¯¥·¥ç¥ó¸Æ¤Ó½Ð¤· */
+ $image_change_url = $this->getControllerPath('Community','EditProfileImage');
+ $image_change_url .= '&community_id=' . $target_user_community_id;
+
+ header("Location: $image_change_url");
+ }
+
+ function getRequestMethods () {
+ return Request::POST;
+ }
+
+ function isSecure () {
+ return false;
+ }
+
+ function getCredential () {
+ return array('COMMUNITY_ADMIN');
+ }
+
+ function get_execute_privilege () {
+ $context = $this->getContext();
+ $user = $context->getUser();
+
+ // ¥³¥ß¥å¥Ë¥Æ¥£´ÉÍý¼Ô¤ÏOK
+ if ($user->hasCredential('COMMUNITY_ADMIN')) {
+ return true;
+ }
+ return false;
+ }
+
+}
+?>