OSDN Git Service

add ACS webapp, sql, htdocs
[acs/acs.git] / webapp / modules / User / actions / DiaryCalendarAction.class.php
diff --git a/webapp/modules/User/actions/DiaryCalendarAction.class.php b/webapp/modules/User/actions/DiaryCalendarAction.class.php
new file mode 100644 (file)
index 0000000..ea1e928
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/**
+ * ¥«¥ì¥ó¥À¡¼ºîÀ®¡¡Action¥¯¥é¥¹
+ * 
+ * DiaryCalendarAction.class.php
+ * @package  acs/webapp/module/User/Action
+ * @author   akitsu
+ * @since    PHP 4.0
+ */
+// $Id: DiaryCalendarAction.class.php,v 1.6 2006/11/20 08:44:25 w-ota Exp $
+
+class DiaryCalendarAction extends BaseAction
+{
+       function execute() {
+
+               $context = &$this->getContext();
+               $user = $context->getUser();
+               $request = $context->getRequest();
+
+               $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+                       // ÂоݤȤʤë¥æ¡¼¥¶¥³¥ß¥å¥Ë¥Æ¥£ID¤ò¼èÆÀ
+               $user_community_id = $request->ACSgetParameter('id');
+               if ($user_community_id == null || $user_community_id == '') {
+                       $user_community_id = $request->getAttribute("id");
+               }
+
+               // ¥æ¡¼¥¶¾ðÊó
+               $target_user_info_row = ACSUser::get_user_info_row_by_user_community_id($user_community_id);
+
+               $top_page_url = $this->getControllerPath("User", 'Diary') . '&id=' .$user_community_id;
+               
+               $year = $request->ACSgetParameter('year');   // ǯ
+               $month = $request->ACSgetParameter('month'); // ·î
+
+               if (!checkdate($month, 1, $year)) {
+                       $date_array = getdate(); // ¸½ºß¤ÎÆüÉÕ¾ðÊó
+                       $year = $date_array["year"];
+                       $month = $date_array["mon"];
+               }
+
+               //ɽ¼¨·î($year/$month)¤Ë³ºÅö¤¹¤ë¥Ç¡¼¥¿¤ò¸¡º÷¤Ë¹Ô¤¯
+               $diary_row_array = ACSDiary::get_diary_row_array_by_year_month($user_community_id, $year, $month);
+               // ¿®ÍêºÑ¤ß¥³¥ß¥å¥Ë¥Æ¥£¾ðÊó¤ÎÄɲÃ
+               foreach ($diary_row_array as $index => $diary_row) {
+                       if ($diary_row['open_level_name'] == ACSMsg::get_mst('open_level_master','D05')) {
+                               $diary_row_array[$index]['trusted_community_row_array'] = ACSDiary::get_diary_trusted_community_row_array($diary_row['diary_id']);
+                       }
+               }
+               //---- ¥¢¥¯¥»¥¹À©¸æ ----//
+               $acs_user_info_row = $user->getAttribute('acs_user_info_row');
+               foreach ($diary_row_array as $index => $diary_row) {
+                       // ¿®ÍêºÑ¤ß¥³¥ß¥å¥Ë¥Æ¥£(¥Þ¥¤¥Õ¥ì¥ó¥º¥°¥ë¡¼¥×)¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«
+                       if ($diary_row['open_level_name'] == ACSMsg::get_mst('open_level_master','D05')) {
+                               if (count($diary_row['trusted_community_row_array'])
+                                       && $diary_row['trusted_community_row_array'][0]['community_type_name'] == ACSMsg::get_mst('community_type_master','D20')) {
+                                       $diary_row_array[$index]['trusted_community_flag'] = 0;
+                               } else {
+                                       $diary_row_array[$index]['trusted_community_flag'] = 1;
+                               }
+                       }
+               }
+               $role_array = ACSAccessControl::get_user_community_role_array($acs_user_info_row, $target_user_info_row);
+               $diary_row_array = ACSAccessControl::get_valid_row_array_for_user_community($acs_user_info_row, $role_array, $diary_row_array);
+
+               //----------------------//
+               // ¥¯¥é¥¹¤ò½é´ü²½
+               // calendar(³«»ÏÍËÆü, Åö·î°Ê³°¤ÎÆüÉÕ¤òɽ¼¨¤¹¤ë¤«¤É¤¦¤«) ¤Î·Á¤Ç»ØÄꤷ¤Þ¤¹¡£
+               // ¢¨³«»ÏÍËÆü¡Ê0-ÆüÍË ¤«¤é 6-ÅÚÍË¡Ë¡¢Åö·î°Ê³°¤ÎÆüÉÕ¤òɽ¼¨¡Ê0-No, 1-Yes¡Ë
+               $calendar_obj = new calendar(0, 0);     // É½¼¨·î°Ê³°¤ÎÆüÉÕ¤òɽ¼¨¤·¤Ê¤¤¤³¤È¤Ç¶¦Ä̤µ¤»¤ë
+
+               // ¥ê¥ó¥¯¤òÀßÄê
+               $calendar_obj->clear_link();
+               if($diary_row_array){
+                       // ¥ê¥ó¥¯¤Î¤¢¤ë´Ö¡¢·«¤êÊÖ¤·
+                       foreach ($diary_row_array as $index => $diary_row) {
+                               if($diary_row){
+                                       $link_date = substr($diary_row['post_date'],8,2);
+                                       if(substr($link_date,0,1) == '0'){
+                                               $link_date = substr($link_date,1,1);
+                                       }
+                                       $calendar_obj->set_link($link_date, $top_page_url ."&year=$year&month=$month&day=$link_date", ACSMsg::get_msg('User', 'DiaryCalendarAction.class.php' ,'M001'));
+                               }
+                       }
+               }
+
+               // »ØÄê·î¤Î¥«¥ì¥ó¥À¡¼ÉÁ²è
+               // show_calendar(ǯ, ·î, Æü) ¤Î·Á¤Ç»ØÄꤷ¤Þ¤¹¡£
+               // ¢¨Æü¤Ï¾Êά²Äǽ¤Ç¤¹¡£»ØÄꤹ¤ë¤È¤½¤ÎÆü¤¬ÂÀ»ú¤Çɽ¼¨¤µ¤ì¤Þ¤¹¡£
+               $calendar_obj->set_str_url($top_page_url);
+               $new_calendar_html = $calendar_obj->show_calendar($year, $month); // Ç¯¤È·î¤ò»ØÄꤷ¤Æ¥«¥ì¥ó¥À¡¼¤òɽ¼¨
+
+               $request->setAttribute('new_calendar_html', $new_calendar_html);
+
+               return View::INPUT;
+       }
+       
+       function isSecure () {
+               return false;
+       }
+       
+       function getCredential () {
+               return array('USER_PAGE_OWNER');
+       }
+}
+
+?>