public function index() { $accreditation_types = ClassRegistry::Init('Eventure.AccreditationType')->find('all'); $events = ClassRegistry::Init('Eventure.Event')->find('all'); $data = $this->paginate(); foreach ($data as $k => $v) { $data[$k]['Attendee'] = get_as_obj(ClassRegistry::init('Eventure.Attendee')->findById($v['Checkin']['attendee_id']), 'Attendee'); $acc = get_as_obj(ClassRegistry::init('Eventure.Accreditation')->findById($v['Checkin']['accreditation_id']), 'Accreditation'); $data[$k]['Accreditation'] = $acc; } // $this->set(compact('data', 'events', 'accreditation_types', 'attendees')); }
public function view($id = null) { // Find all accreditations for this event $acc = ClassRegistry::Init('Eventure.Accreditation')->findAllByEventId($id); $m = ClassRegistry::init('Eventure.Accreditation'); foreach ($acc as &$a) { $a['Attendees'] = ClassRegistry::Init('Eventure.AttendeesAccreditation')->findAllByAccreditationId($a['Accreditation']['id']); } $total_attendees = $total_checkins = 0; foreach ($acc as $x) { $total_attendees += sizeof($x['Attendees']); $total_checkins += sizeof($x['Checkin']); } $event = $this->Event->read(null, $id); $all_accreditations = $m->find('all'); $this->set(compact('event', 'acc', 'total_attendees', 'total_checkins', 'all_accreditations')); }
/** * __call method * * @param mixed $method Method Called. * @param mixed $params Passed Parameters. * * @return boolean */ function __call($method, $params) { if (!empty($params[0]) && ($model = ClassRegistry::Init($params[0]))) { if (is_callable(array($model, $method))) { unset($params[0]); return call_user_func_array(array($model, $method), $params); } } return false; }
function ShareYahoo($text, $userID, $linktext, $linkurl) { App::import('Vendor', 'Yahoo', array('file' => 'yahoo/Yahoo.inc')); $Setting = ClassRegistry::Init("Setting"); $settings = $Setting->find('first'); $settings = $settings['Setting']; $hasSession = YahooSession::hasSession($settings['yahoo_consumer_key'], $settings['yahoo_consumer_secret'], $settings['yahoo_app_id']); if ($hasSession != FALSE) { $session = YahooSession::requireSession($settings['yahoo_consumer_key'], $settings['yahoo_consumer_secret'], $settings['yahoo_app_id']); $user = $session->getSessionedUser(); // create an unique hash of the update data using md5 $suid = md5($text . $linktext . $linkurl . time()); // insert the update... $user->insertUpdate($suid, $text, $linkurl, $linktext); return true; } return false; }
function ResizeImageContentCloud($source, $destination_path, $model_id, $model_name, $type = "original", $mime_type, $width, $height, $resizeType = 'cropResize') { $ext = pathinfo($source, PATHINFO_EXTENSION); $Content = ClassRegistry::Init("Content"); $data = $Content->find("first", array("conditions" => array("Content.model_id" => $model_id, "Content.model" => $model_name, "LOWER(Content.type)" => strtolower($type)))); if (!empty($data)) { $Contents["Content"]["id"] = $data["Content"]["id"]; } $Contents["Content"]["model"] = $model_name; $Contents["Content"]["model_id"] = $model_id; $Contents["Content"]["host"] = $this->awsHost; $Contents["Content"]["mime_type"] = $mime_type; $Contents["Content"]["cloud"] = "1"; App::import('Vendor', 'upload', array('file' => 'class.upload.php')); $img = new upload($source); $img->file_new_name_body = $model_id . "_" . $type; if ($resizeType == 'cropResize') { $img->image_resize = true; $img->image_ratio_crop = true; $img->image_y = $height; $img->image_x = $width; } else { if ($resizeType == 'resizeMaxWidth') { $img->image_resize = true; $img->image_ratio_y = true; $img->image_x = $width; } } $img->process($destination_path); $Contents["Content"]["type"] = $type; $Contents["Content"]["url"] = "contents/{$model_name}/{$model_id}/{$model_id}_{$type}.{$ext}"; $Contents["Content"]["path"] = "contents/{$model_name}/{$model_id}/{$model_id}_{$type}.{$ext}"; if ($img->processed) { $file_source = $destination_path . $model_id . "_" . $type . "." . $ext; if ($this->UploadToCloud($file_source, $model_id, $model_name, $type, $mime_type, $ext)) { unlink($file_source); $Content->create(); $Content->save($Contents); return true; } else { return false; } } else { return false; } }