本文整理汇总了PHP中ActivityModel类的典型用法代码示例。如果您正苦于以下问题:PHP ActivityModel类的具体用法?PHP ActivityModel怎么用?PHP ActivityModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActivityModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: homeAction
public function homeAction()
{
// action body
// echo $_COOKIE["account"];
// print_r( $this->cookie);
$imgpath = $_SERVER['DOCUMENT_ROOT'] . "/WebOne/public/image/head/";
$id = $_SESSION["userinfo"][0][id];
// print_r($_SESSION["userinfo"][0]);
$userinfo = new userinfoModel();
$db = $userinfo->getAdapter();
$user = $db->query('SELECT * FROM userinfo where userid=?', $id)->fetchAll()[0];
$activitys = new ActivityModel();
$db1 = $activitys->getAdapter();
$hotactivity = $db1->query('select * from activity order by nums desc limit 0,1')->fetchAll()[0];
$questions = new QuestionModel();
$db2 = $questions->getAdapter();
$hotquestion = $db2->query('select * from question order by answernum desc limit 0,1')->fetchAll()[0];
if (file_exists($imgpath . $id . ".jpg")) {
$this->view->path = $baseUrl . "/WebOne/public/image/head/" . $id . ".jpg";
} else {
$this->view->path = $baseUrl . "/WebOne/public/image/initial.jpg";
}
$userid = $hotquestion[userid];
$Usertable = new UserModel();
$db3 = $Usertable->getAdapter();
$name = $db3->query('select name from User where id=?', $userid)->fetchAll()[0][name];
$this->view->user = $user;
$this->view->info = $_SESSION["userinfo"];
$this->view->activity = $hotactivity;
$this->view->question = $hotquestion;
$this->view->name = $name;
}
示例2: informNotifications
/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $Sender The object calling this method.
*/
public static function informNotifications($Sender)
{
$Session = Gdn::session();
if (!$Session->isValid()) {
return;
}
$ActivityModel = new ActivityModel();
// Get five pending notifications.
$Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
// If we're in the middle of a visit only get very recent notifications.
$Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
$Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
$ActivityIDs = array_column($Activities, 'ActivityID');
$ActivityModel->setNotified($ActivityIDs);
$Sender->EventArguments['Activities'] =& $Activities;
$Sender->fireEvent('InformNotifications');
foreach ($Activities as $Activity) {
if ($Activity['Photo']) {
$UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
} else {
$UserPhoto = '';
}
$Excerpt = Gdn_Format::plainText($Activity['Story']);
$ActivityClass = ' Activity-' . $Activity['ActivityType'];
$Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
}
}
示例3: Award
/**
* Award a badge to a user and record some activity
*
* @param int $BadgeID
* @param int $UserID This is the user that should get the award
* @param int $InsertUserID This is the user that gave the award
* @param string $Reason This is the reason the giver gave with the award
*/
public function Award($BadgeID, $UserID, $InsertUserID = NULL, $Reason = '')
{
$Badge = Yaga::BadgeModel()->GetByID($BadgeID);
if (!empty($Badge)) {
if (!$this->Exists($UserID, $BadgeID)) {
$this->SQL->Insert('BadgeAward', array('BadgeID' => $BadgeID, 'UserID' => $UserID, 'InsertUserID' => $InsertUserID, 'Reason' => $Reason, 'DateInserted' => date(DATE_ISO8601)));
// Record the points for this badge
UserModel::GivePoints($UserID, $Badge->AwardValue, 'Badge');
// Increment the user's badge count
$this->SQL->Update('User')->Set('CountBadges', 'CountBadges + 1', FALSE)->Where('UserID', $UserID)->Put();
if (is_null($InsertUserID)) {
$InsertUserID = Gdn::Session()->UserID;
}
// Record some activity
$ActivityModel = new ActivityModel();
$Activity = array('ActivityType' => 'BadgeAward', 'ActivityUserID' => $UserID, 'RegardingUserID' => $InsertUserID, 'Photo' => $Badge->Photo, 'RecordType' => 'Badge', 'RecordID' => $BadgeID, 'Route' => '/badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), 'HeadlineFormat' => T('Yaga.Badge.EarnedHeadlineFormat'), 'Data' => array('Name' => $Badge->Name), 'Story' => $Badge->Description);
// Create a public record
$ActivityModel->Queue($Activity, FALSE);
// TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Route'));
// Notify the user of the award
$Activity['NotifyUserID'] = $UserID;
$ActivityModel->Queue($Activity, 'BadgeAward', array('Force' => TRUE));
// Actually save the activity
$ActivityModel->SaveQueue();
$this->EventArguments['UserID'] = $UserID;
$this->FireEvent('AfterBadgeAward');
}
}
}
示例4: getData
public function getData($Limit = false)
{
if (!$Limit) {
$Limit = $this->Limit;
}
$ActivityModel = new ActivityModel();
$Data = $ActivityModel->getWhere(array('NotifyUserID' => ActivityModel::NOTIFY_PUBLIC), '', '', $Limit, 0);
$this->ActivityData = $Data;
}
示例5: GetData
public function GetData($Limit = FALSE)
{
if (!$Limit) {
$Limit = $this->Limit;
}
$ActivityModel = new ActivityModel();
$Data = $ActivityModel->GetWhere(array('NotifyUserID' => ActivityModel::NOTIFY_PUBLIC), 0, $Limit);
$this->ActivityData = $Data;
}
示例6: Index
/**
* This determines if the current user can react on this item with this action
*
* @param string $Type valid options are 'discussion', 'comment', and 'activity'
* @param int $ID
* @param int $ActionID
* @throws Gdn_UserException
*/
public function Index($Type, $ID, $ActionID)
{
$Type = strtolower($Type);
$Action = $this->ActionModel->GetByID($ActionID);
// Make sure the action exists and the user is allowed to react
if (!$Action) {
throw new Gdn_UserException(T('Yaga.Action.Invalid'));
}
if (!Gdn::Session()->CheckPermission($Action->Permission)) {
throw PermissionException();
}
switch ($Type) {
case 'discussion':
$Model = new DiscussionModel();
$AnchorID = '#Discussion_';
break;
case 'comment':
$Model = new CommentModel();
$AnchorID = '#Comment_';
break;
case 'activity':
$Model = new ActivityModel();
$AnchorID = '#Activity_';
break;
default:
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
break;
}
$Item = $Model->GetID($ID);
if ($Item) {
$Anchor = $AnchorID . $ID . ' .ReactMenu';
} else {
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetID'));
}
$UserID = Gdn::Session()->UserID;
switch ($Type) {
case 'comment':
case 'discussion':
$ItemOwnerID = $Item->InsertUserID;
break;
case 'activity':
$ItemOwnerID = $Item['RegardingUserID'];
break;
default:
throw new Gdn_UserException(T('Yaga.Action.InvalidTargetType'));
break;
}
if ($ItemOwnerID == $UserID) {
throw new Gdn_UserException(T('Yaga.Error.ReactToOwn'));
}
// It has passed through the gauntlet
$this->ReactionModel->Set($ID, $Type, $ItemOwnerID, $UserID, $ActionID);
$this->JsonTarget($Anchor, RenderReactionList($ID, $Type, FALSE), 'ReplaceWith');
// Don't render anything
$this->Render('Blank', 'Utility', 'Dashboard');
}
示例7: AddActivity
public function AddActivity()
{
// Build the story for the activity.
$Header = $this->GetImportHeader();
$PorterVersion = GetValue('Vanilla Export', $Header, T('unknown'));
$SourceData = GetValue('Source', $Header, T('unknown'));
$Story = sprintf(T('Vanilla Export: %s, Source: %s'), $PorterVersion, $SourceData);
$ActivityModel = new ActivityModel();
$ActivityModel->Add(Gdn::Session()->UserID, 'Import', $Story);
return TRUE;
}
示例8: addActivity
/**
*
*
* @return bool
* @throws Gdn_UserException
*/
public function addActivity()
{
// Build the story for the activity.
$Header = $this->getImportHeader();
$PorterVersion = val('Vanilla Export', $Header, t('unknown'));
$SourceData = val('Source', $Header, t('unknown'));
$Story = sprintf(t('Vanilla Export: %s, Source: %s'), $PorterVersion, $SourceData);
$ActivityModel = new ActivityModel();
$ActivityModel->add(Gdn::session()->UserID, 'Import', $Story);
return true;
}
示例9: lists
public function lists()
{
$page = intval(Input::get('page', 1));
$start_time = Input::get('start_time', '');
$expire = Input::get('expire', '');
$args = ['start_time' => $start_time, 'expire' => $expire];
$model = new ActivityModel();
$count = $model->getCount($args);
$rows = $model->getRows($page, $args);
$page_size = Pagination::getPageSize($count);
return View::make('activity.lists', ['rows' => $rows, 'page' => $page, 'page_size' => $page_size, 'params' => $args]);
}
示例10: post
public function post($data = [])
{
if (empty($data)) {
throw new Exception('Some data is needed to be posted.');
} else {
$activity = new ActivityModel();
if (array_key_exists('user_id', $data)) {
$activity->setUserId($data['user_id']);
}
if (array_key_exists('exercise_name', $data)) {
$activity->setExerciseName($data['exercise_name']);
}
if (array_key_exists('exercise_duration', $data)) {
$activity->setExerciseDuration($data['exercise_duration']);
}
if (array_key_exists('exercise_calories', $data)) {
$activity->setExerciseCalories($data['exercise_calories']);
}
if (array_key_exists('exercise_distance', $data)) {
$activity->setExerciseDistance($data['exercise_distance']);
}
if (array_key_exists('exercise_timestamp', $data)) {
$activity->setExerciseTimestamp($data['exercise_timestamp']);
}
if ($activity->save()) {
return true;
} else {
return false;
}
}
}
示例11: report_build
/**
* Builds a report using the passed parameters, and displays the result
* using the report show view
*
* @param Array $params
*/
public function report_build($params)
{
$formdata = (object) $params;
$this->_data->range = IntervalModel::get_range_total($formdata);
$this->_data->intervals = IntervalModel::get_between($formdata);
$this->_data->incidences = ActivityModel::find_all_incidences($formdata->user);
new UserReportShowView($this->_data);
}
示例12: GetData
public function GetData($Limit = 5, $RoleID = '')
{
if (!is_array($RoleID) && $RoleID != '') {
$RoleID = array($RoleID);
}
$ActivityModel = new ActivityModel();
if (is_array($RoleID)) {
$Data = $ActivityModel->GetForRole($RoleID, 0, $Limit);
} else {
$Data = $ActivityModel->Get('', 0, $Limit);
}
$this->ActivityData = $Data;
if (!is_array($RoleID)) {
$RoleID = array();
}
$this->_RoleID = $RoleID;
}
示例13: Post
public function Post($Notify = FALSE, $UserID = FALSE)
{
if (is_numeric($Notify)) {
$UserID = $Notify;
$Notify = FALSE;
}
if (!$UserID) {
$UserID = Gdn::Session()->UserID;
}
switch ($Notify) {
case 'mods':
$this->Permission('Garden.Moderation.Manage');
$NotifyUserID = ActivityModel::NOTIFY_MODS;
break;
case 'admins':
$this->Permission('Garden.Settings.Manage');
$NotifyUserID = ActivityModel::NOTIFY_ADMINS;
break;
default:
$this->Permission('Garden.Profiles.Edit');
$NotifyUserID = ActivityModel::NOTIFY_PUBLIC;
break;
}
$Activities = array();
if ($this->Form->IsPostBack()) {
$Data = $this->Form->FormValues();
$Data = $this->ActivityModel->FilterForm($Data);
$Data['Format'] = C('Garden.InputFormatter');
if ($UserID != Gdn::Session()->UserID) {
// This is a wall post.
$Activity = array('ActivityType' => 'WallPost', 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::Session()->UserID, 'HeadlineFormat' => T('HeadlineFormat.WallPost', '{RegardingUserID,you} → {ActivityUserID,you}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format']);
} else {
// This is a status update.
$Activity = array('ActivityType' => 'Status', 'HeadlineFormat' => T('HeadlineFormat.Status', '{ActivityUserID,user}'), 'Story' => $Data['Comment'], 'Format' => $Data['Format'], 'NotifyUserID' => $NotifyUserID);
$this->SetJson('StatusMessage', Gdn_Format::Display($Data['Comment']));
}
$Activity = $this->ActivityModel->Save($Activity, FALSE, array('CheckSpam' => TRUE));
if ($Activity == SPAM) {
$this->StatusMessage = T('Your post has been flagged for moderation.');
$this->Render('Blank', 'Utility');
return;
}
if ($Activity) {
if ($UserID == Gdn::Session()->UserID && $NotifyUserID == ActivityModel::NOTIFY_PUBLIC) {
Gdn::UserModel()->SetField(Gdn::Session()->UserID, 'About', Gdn_Format::PlainText($Activity['Story'], $Activity['Format']));
}
$Activities = array($Activity);
ActivityModel::JoinUsers($Activities);
$this->ActivityModel->CalculateData($Activities);
}
}
if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
Redirect($this->Request->Get('Target', '/activity'));
}
$this->SetData('Activities', $Activities);
$this->Render('Activities');
}
示例14: createNewModels
/**
* 将消息和用户关联
* @param ActivityModel $p_msgModel 消息模型
* @param array $p_queryWhere 用户的筛选方案
* @return int 关联个数
*/
public static function createNewModels($p_msgModel, $p_queryWhere = array())
{
$userIDs = DBModel::instance('user')->where($p_queryWhere)->selectValues('id');
$tmpData = array();
$tmpData['msgID'] = $p_msgModel->getId();
$tmpData['readStatus'] = READ_STATUS::UNREAD;
$tmpData['createTime'] = date('Y-m-d H:i:s');
$tmpData['modifyTime'] = date('Y-m-d H:i:s');
$dbFac = static::newDBModel();
foreach ($userIDs as $userID) {
$tmpData['userID'] = $userID;
$dbFac->insert($tmpData);
}
//推送
if (count($userIDs) > 0) {
$p_where = array();
$p_where['joinList'] = array();
$p_where['joinList'][] = array('relationActivityUser t2', array('t2.userID = t1.userID', 't2.msgID' => $p_msgID, 't2.readStatus' => READ_STATUS::UNREAD));
DeviceController::pushSingleMessage($p_where, $p_msgModel->getTitle(), $p_msgModel->getDescription(), $customtype = null, $customvalue = null, $tag_name = null);
}
return count($userIDs);
}
示例15: InformNotifications
/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $Sender The object calling this method.
*/
public static function InformNotifications($Sender)
{
$Session = Gdn::Session();
if (!$Session->IsValid()) {
return;
}
$ActivityModel = new ActivityModel();
// Get five pending notifications.
$Where = array('NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
// If we're in the middle of a visit only get very recent notifications.
$Where['DateInserted >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes'));
$Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray();
$ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID');
$ActivityModel->SetNotified($ActivityIDs);
foreach ($Activities as $Activity) {
if ($Activity['Photo']) {
$UserPhoto = Anchor(Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
} else {
$UserPhoto = '';
}
$Excerpt = Gdn_Format::Display($Activity['Story']);
$Sender->InformMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . ($UserPhoto == '' ? '' : ' HasIcon'));
}
}