function render_for_ajax() { $this->anon = TRUE; if (!empty(PA::$login_user)) { $login_id = PA::$login_user->user_id; $this->anon = FALSE; } switch ($this->params["op"]) { case "add_fan": if ($this->anon) { $this->err = __("Please log in or register to add yourself as a fan!"); break; } $this->subject_type = $this->params['subject_type']; $this->subject_id = $this->params['subject_id']; // actual add of fan goes here try { $fan = new Fan(); $fan->subject_type = $this->subject_type; $fan->subject_id = $this->subject_id; $fan->user_id = PA::$login_user->user_id; $fan->user_displayname = @PA::$login_user->display_login_name ? PA::$login_user->display_login_name : PA::$login_user->login_name; $fan->user_fullname = @PA::$login_user->first_name . " " . @PA::$login_user->last_name; $fan->save(); $this->note = __("You are now a fan - thank you for participating!"); // for rivers of people $activity = 'user_add_fanof'; $extra = serialize(array('info' => PA::$login_user->login_name . ' became a fan.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id)); Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity)); } catch (PAException $e) { $this->err = __("There was a problem adding as a fan: ") . $e->getMessage(); } break; case "remove_fan": if ($this->anon) { $this->err = __("Please log in or register to remove yourself as a fan!"); break; } $this->subject_type = $this->params['subject_type']; $this->subject_id = $this->params['subject_id']; // actual removal of fan goes here try { Fan::remove(PA::$login_user->user_id, $this->subject_type, $this->subject_id); $this->note = __("You are no longer a fan - thank you for participating!"); // for rivers of people $activity = 'user_remove_fanof'; $extra = serialize(array('info' => PA::$login_user->login_name . ' is no longer a fan.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id)); Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity)); } catch (PAException $e) { $this->err = __("There was a problem removing as a fan: ") . $e->getMessage(); } break; default: // just ignore unknown ops break; } return $this->render(); }
<?php $model = $_REQUEST['model']; $action = $_REQUEST['action']; include_once MODELS_ADMIN . "/" . $model . "_model.php"; switch (strtoupper($action)) { case 'ADD': if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'save') { $objFan = new Fan(); $objFan->setProduct($_REQUEST); $objComm->redirect('index.php?model=' . $model); } break; case 'VIEW': case 'EDIT': if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Update') { $objFan = new Fan(); $objFan->setFan($_REQUEST); $objComm->redirect('index.php?model=' . $model . '&action=edit&id=' . $_REQUEST['pk_id']); } else { $objFan = new Fan(); $datum = $objFan->getFan($_REQUEST['id']); } break; default: $objFan = new Fan(); $data = $objFan->getAllFan(); break; }
public static function get($fan_id) { $fan = new Fan(); $fan->load($fan_id); return $comm; }