function send_confirmation_emails() { $slot_entity = get_entity_by_id($this->request_array['slot_id']); $dir = new directory_service(); $dir->search_by_attribute('ds_username', $this->event->get_value('contact_username'), array('ds_email', 'ds_fullname', 'ds_phone')); $to = $dir->get_first_value('ds_email'); $subject = 'Event Registration: ' . $this->get_value('name') . ' for ' . $this->event->get_value('name'); $body = $this->get_value('name') . ' has registered for ' . $this->event->get_value('name') . "\n\n"; $body .= 'Name: ' . $this->get_value('name') . "\n"; $body .= "E-mail Address: " . $this->get_value('email') . "\n"; $body .= 'Date: ' . prettify_mysql_datetime($this->request_array['date'], 'm/d/Y') . "\n"; if ($this->include_time_in_email) { $time = $this->event->get_value('datetime'); $time_parts = explode(' ', $time); if ($time_parts[1] != '00:00:00') { $body .= 'Time: ' . prettify_mysql_datetime($time, 'g:i a') . "\n"; } } $location = $this->event->get_value('location'); if (!empty($location)) { $body .= 'Location: ' . $location . "\n"; } $slot = $slot_entity['name']; $body .= 'Slot: ' . $slot . "\n\n"; // to person who should get registration mail($to, $subject, $body, "From: " . strip_tags($this->get_value('email'))); // to person who filled out email mail(strip_tags($this->get_value('email')), $subject, $body, "From: " . strip_tags($to)); }
/** Removes entity with id = $id and all relationships with that id from the database. * * Specifically, deletes the entry from the entity table and all sub-tables. * Also deletes all relationships where entity_a or entity_b = id * * @todo add logging of expungements so that these important actions are traceable * * @param integer $id The ID of the entity to delete * @param integer $user_id The ID of the reason user who is deleting the item * @return array the entity and all relationships of the entity just deleted */ function reason_expunge_entity( $id, $user_id ) { $testmode = false; if(empty($user_id) || !is_numeric($user_id) || $user_id < 1 ) { trigger_error('Expungement without providing a Reason user id is deprecated. Future releases of Reason will not allow entities to be expunged without providing a user id'); } // get all entity information before deleting it $id = (integer) $id; if(empty($id) || $id < 1) { trigger_error('ID passed to reason_expunge_entity() not a positive integer. Unable to expunge.'); return false; } $entity = get_entity_by_id( $id, false ); if(empty($entity['id'])) { trigger_error('Entity id '.$id.' does not exisit; unable to expunge.'); return false; } $sqler = new SQLER; $archives = array(); $q = "SELECT r.entity_b, r.type, ar.name FROM relationship AS r, allowable_relationship AS ar WHERE r.entity_a = $id AND r.type = ar.id"; $r = db_query( $q, 'Unable to retrieve entity left relationships for expungement' ); while( $row = mysql_fetch_array( $r, MYSQL_ASSOC ) ) { $entity[ 'left_relationships' ][] = $row; // this is an archive - mark it for deletion. if( strpos( $row[ 'name' ], 'archive' ) !== false ) $archives[] = $row[ 'entity_b' ]; } $q = "SELECT entity_a, type FROM relationship WHERE entity_b = $id"; $r = db_query( $q, 'Unable to retrieve entity right relationships for expungement' ); while( $row = mysql_fetch_array( $r, MYSQL_ASSOC ) ) $entity[ 'right_relationships' ][] = $row; // call custom deletion action $type = get_entity_by_id( $entity[ 'type' ] ); if( $type[ 'custom_deleter' ] ) reason_include_once( 'content_deleters/'.$type['custom_deleter'] ); // delete from entity table $q = "DELETE FROM entity WHERE id = $id"; if( $testmode ) echo $q.'<br /><br />'; else db_query( $q, 'Unable to delete entity from entity table.' ); // delete from sub tables $tables = get_entity_tables_by_type( $entity['type'] ); foreach( $tables as $table ) { if( $table != 'entity' ) { if( $testmode ) echo '$sqler->delete_one( "'.htmlspecialchars($table).'",'.$id.' )<br /><br />'; else $sqler->delete_one( $table, $id ); } } // delete relationships $q = "DELETE FROM relationship WHERE entity_a = $id OR entity_b = $id"; if( $testmode ) echo $q.'<br /><br />'; else db_query( $q, 'Unable to delete relationships of entity '.$id ); // delete all archived entities foreach( $archives AS $archive ) reason_expunge_entity( $archive, $user_id ); // If the recently-expunged entity is live or pending and has a unique_name, let's refresh_reason_unique_names if (!empty($entity['unique_name']) && ( !empty($entity['state']) && (($entity['state'] == 'Pending') || ($entity['state'] == 'Live')))) { reason_refresh_unique_names(); } return $entity; } //
/** * Delete the registrant indicated in the delete_registrant request value * * @param object $event event entity * @return void */ function delete_registrant($event) { $slot = get_entity_by_id($this->request['slot_id']); $registrants = explode(';', $slot['registrant_data']); $changed = false; foreach($registrants as $key=>$registrant) { if(md5($registrant) == $this->request['delete_registrant']) { $old_data[] = $registrants[$key]; unset($registrants[$key]); $changed = true; } } if($changed) { $values = array ( 'registrant_data' => implode(';', $registrants)); $update_user = $this->user_is_slot_admin($event); if(empty($update_user)) $update_user = get_user_id('event_agent'); $successful_update = reason_update_entity( $this->request['slot_id'], $update_user, $values ); if($successful_update) { // redirect on successful delete $link = carl_make_redirect(array('delete_registrant' => '')); header("Location: " . $link ); exit; } else { $this->slot_registration_admin_messages .= '<h4>Sorry</h4><p>Deletion unsuccesful. The Web Services group has been notified of this error - please try again later.</p>'; $this->send_slot_deletion_error_message($event, print_r($old_data, true) ); } } else $this->slot_registration_admin_messages .= '<h4>Sorry</h4><p>Could not find registrant to delete - most likely they were already deleted.</p>'; }
/** * returns a specific value for the entity or false if the field doesn't exist * @param string $col name of the field to grab * @return mixed */ function get_value_refresh($col) { $this->refresh_values(); if (empty($this->_values)) { $this->_values = get_entity_by_id($this->_id); } if (!empty($this->_values[$col]) or isset($this->_values[$col]) and strlen($this->_values[$col]) > 0) { return $this->_values[$col]; } elseif (!array_key_exists($col, $this->_values)) { trigger_error('"' . $col . '" field not retrieved from database'); } return false; }
/** * Show an image thumbnail * * Note that this function does not return XHTML; instead it directly outputs it * via echo statements. If you want returned XHTML, use get_show_image_html(). * * @param mixed $image An image object, image ID, or array of image values * @param boolean $die_without_thumbnail Echo nothing if no thumb available? (default behavior * is to make link to full-sized image if no thumb available) * @param boolean $show_popup_link Wrap image in link that pops up image popup? * @param boolean $show_description Place the image description (i.e. short caption) below the image? * @param string $other_text Text to use instead of image description * @param boolean $textonly True sets function into textonly mode, which instead of outputting * image markup outputs a text description linking to image * @param boolean $show_author Output the value of the author field below the description? * @param string $link_with_url Wrap the image in a link to this URL instead of to image popup * @return void * * @todo Make a better image markup library! */ function show_image($image, $die_without_thumbnail = false, $show_popup_link = true, $show_description = true, $other_text = '', $textonly = false, $show_author = false, $link_with_url = '') { if (is_array($image)) { $id = $image['id']; } elseif (is_object($image)) { if ('reasonSizedImage' == get_class($image)) { $sizedImageObject = $image; $image_entity = $sizedImageObject->get_entity(); $values = $image_entity->get_values(); $id = $image_entity->id(); $image = $values; } else { $values = $image->get_values(); $id = $image->id(); $image = $values; } } else { $id = $image; $image = get_entity_by_id($id); } if (isset($sizedImageObject)) { $tn = true; $width = $sizedImageObject->get_image_width(); $height = $sizedImageObject->get_image_height(); $image_path = $sizedImageObject->get_file_system_path_and_file_of_dest(); $mod_time = filemtime($image_path); $image_url = $sizedImageObject->get_URL() . '?cb=' . $mod_time; } else { $tn_name = reason_get_image_filename($id, 'tn'); $fs_name = reason_get_image_filename($id); if (file_exists(PHOTOSTOCK . $tn_name)) { $tn = true; $image_name = $tn_name; } elseif (file_exists(PHOTOSTOCK . $fs_name)) { if ($die_without_thumbnail) { return; } $tn = false; $image_name = $fs_name; } else { trigger_error('No thumbail or full sized image found for image id ' . $id); return; } $image_path = PHOTOSTOCK . $image_name; list($width, $height) = getimagesize($image_path); $mod_time = filemtime($image_path); $image_url = WEB_PHOTOSTOCK . $image_name . '?cb=' . $mod_time; } if (file_exists($image_path)) { $full_image_exists = file_exists(PHOTOSTOCK . reason_get_image_filename($id)); if (!$image['description']) { if ($image['keywords']) { $image['description'] = $image['keywords']; } else { $image['description'] = $image['name']; } } $window_width = $image['width'] < 340 ? 340 : 40 + $image['width']; $window_height = 170 + $image['height']; // formerly 130 // 96 works on Mac IE 5 if (empty($link_with_url)) { if (empty($textonly)) { $pre_link = "<a onmouseover=\"window.status = 'view larger image'; return true;\" onmouseout=\"window.status = ''; return true;\" onclick=\"this.href='javascript:void(window.open(\\'" . REASON_IMAGE_VIEWER . "?id=" . $image['id'] . "\\', \\'PopupImage\\', \\'menubar,scrollbars,resizable,width=" . $window_width . ",height=" . $window_height . "\\'))'\" href=\"" . WEB_PHOTOSTOCK . reason_get_image_filename($id) . "?cb=" . filemtime($image_path) . "\">"; } else { $pre_link = '<a href="' . WEB_PHOTOSTOCK . reason_get_image_filename($id) . '?cb=' . filemtime(PHOTOSTOCK . $image_name) . '">'; } } else { $pre_link = '<a href="' . $link_with_url . '">'; } if (empty($textonly)) { echo '<div class="tnImage">'; if (($tn and $show_popup_link and $full_image_exists) || $tn && !empty($link_with_url)) { echo $pre_link; } // show photo echo '<img src="' . $image_url . '" width="' . $width . '" height="' . $height . '" alt="' . reason_htmlspecialchars($image['description']) . '" class="thumbnail" border="0"/>'; if (($tn and $show_popup_link and $full_image_exists) || $tn && !empty($link_with_url)) { echo '</a>'; } echo '</div>'; } if ($show_description) { $desc =& $image['description']; if (empty($textonly)) { echo '<div class="tnDesc smallText">'; } else { echo '<div class="tnDesc">'; } if ($tn and $show_popup_link and $full_image_exists) { echo $pre_link . $desc . '</a>'; } else { echo $desc; } echo '</div>'; } if ($other_text) { if (empty($textonly)) { echo '<div class="tnDesc smallText">'; } else { echo '<div class="tnDesc">'; } if ($tn and $show_popup_link and $full_image_exists) { echo $pre_link . $other_text . '</a>'; } else { echo $other_text; } echo '</div>'; } if ($show_author and !empty($image['author'])) { echo '<div class="tnAuthor smallText">Photo: ' . $image['author'] . '</div>'; } } }