isGuest = isguest();
if ($this->isGuest) {
error(get_string('modlos_access_forbidden', 'block_modlos'), CMS_MODULE_URL);
}
$this->hasPermit = hasModlosPermit($course_id);
$this->course_id = $course_id;
$this->userid = $USER->id;
// GET eventid
$this->event_id = optional_param('eventid', '0', PARAM_INT);
$this->url_param = '?dmmy_param=';
if ($course_id>0) $this->url_param .= '&course='.$course_id;
$this->action_url = CMS_MODULE_URL.'/actions/edit_event.php'. $this->url_param;
$this->delete_url = CMS_MODULE_URL.'/actions/delete_event.php'.$this->url_param.'&eventid=';
$avatars_num = modlos_get_avatars_num($USER->id);
$max_avatars = $CFG->modlos_max_own_avatars;
if (!$this->hasPermit and $max_avatars>=0 and $avatars_num>=$max_avatars) $this->isAvatarMax = true;
if ($course_id>0) $this->course_patam = '?course='.$course_id;
}
function execute()
{
// List of Parcels
$modobj = get_records("modlos_search_parcels");
$i = 0;
foreach ($modobj as $mod) {
//$this->parcels[$i]['uuid'] = $mod->parceluuid;
$this->parcels[$i]['name'] = $mod->parcelname;
$this->parcels[$i]['regionUUID'] = $mod->regionuuid;
$this->parcels[$i]['landingpoint'] = $mod->landingpoint;
$i++;
}
// List of Owners
$this->owners = modlos_get_avatars();
// List of Creators
$this->creators = modlos_get_avatars($this->userid);
if ($this->creators==null) {
error(get_string('modlos_should_have_avatar', 'block_modlos'), CMS_MODULE_URL.'/actions/events_list.php');
}
foreach ($this->creators as $creator) {
$this->event_owner = $creator['fullname'];
break;
}
$event = array();
// Post
if (data_submitted()) {
if (!confirm_sesskey()) {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_sesskey_error', 'block_modlos');
}
$this->uid = optional_param('uid', '0', PARAM_INT);
$this->event_id = optional_param('event_id', '0', PARAM_INT);
// Delete Event
$del = optional_param('submit_delete', '', PARAM_TEXT);
if ($del!='') {
redirect($this->delete_url.$this->event_id, 'Please wait....', 0);
exit('
delete page open error!!
');
}
$parcel = explode('|', optional_param('parcel_name', '|', PARAM_TEXT));
$this->global_pos = $parcel[0];
$this->region_uuid = $parcel[1];
$owner = explode('|', optional_param('owner_name', '|', PARAM_TEXT));
$this->owner_uuid = $owner[0];
$this->event_owner = $owner[1];
$creator = explode('|', optional_param('creator_name', '|', PARAM_TEXT));
$this->creator_uuid = $creator[0];
$this->event_creator = $creator[1];
$this->event_year = optional_param('event_year','2010', PARAM_INT);
$this->event_month = optional_param('event_month', '1', PARAM_INT);
$this->event_day = optional_param('event_day', '1', PARAM_INT);
$this->event_hour = optional_param('event_hour', '0', PARAM_INT);
$this->event_minute = optional_param('event_minute','0', PARAM_INT);
$this->event_name = optional_param('event_name', '', PARAM_TEXT);
$this->event_desc = optional_param('event_desc', '', PARAM_TEXT);
$this->category = optional_param('category', '0', PARAM_INT);
$this->duration = optional_param('duration', '10', PARAM_INT);
$this->cover_charge = optional_param('cover_charge', '0', PARAM_INT);
$this->cover_amount = optional_param('cover_amount', '0', PARAM_INT);
$this->check_mature = optional_param('check_mature', '0', PARAM_INT);
if ($this->cover_charge==0) $this->cover_amount = 0;
if (!isGUID($this->region_uuid)) $this->rgion_uuid = '00000000-0000-0000-0000-000000000000';
// Error check
if (!isGUID($this->creator_uuid)) {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_event_creator_required', 'block_modlos')." (UUID)";
}
if (!isAlphabetNumericSpecial($this->event_creator)) {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_event_creator_required', 'block_modlos')." (Name)";
}
if (!isGUID($this->owner_uuid)) {
//$this->hasError = true;
//$this->errorMsg[] = get_string('modlos_event_owner_required', 'block_modlos')." (UUID)";
$this->owner_uuid = $this->creator_uuid;
}
if (!isAlphabetNumericSpecial($this->event_owner)) {
//$this->hasError = true;
//$this->errorMsg[] = get_string('modlos_event_owner_required', 'block_modlos')." (Name)";
$this->event_owner = $this->event_creator;
}
if ($this->event_name=='') {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_event_name_required', 'block_modlos');
}
if ($this->event_desc=='') {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_event_desc_required', 'block_modlos');
}
if (OPENSIM_PGONLY and $this->check_mature==1) {
$this->hasError = true;
$this->errorMsg[] = get_string('modlos_pg_only_error', 'block_modlos');
}
$event_date = mktime($this->event_hour, $this->event_minute, 0, $this->event_month, $this->event_day, $this->event_year);
if ($event_date