本文整理汇总了PHP中Activity::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::model方法的具体用法?PHP Activity::model怎么用?PHP Activity::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeDelete
protected function beforeDelete()
{
// ToDo: Handle this via event of User Module
if ($this->object_model == 'User') {
$user = User::model()->findByPk($this->user_id);
$activity = Activity::model()->contentContainer($user)->findByAttributes(array('type' => "ActivityUserFollowsUser", 'object_id' => $this->object_id));
if ($activity !== null) {
$activity->delete();
}
}
return parent::beforeDelete();
}
示例2: onIntegrityCheck
/**
* On run of integrity check command, validate all module data
*
* @param CEvent $event
*/
public static function onIntegrityCheck($event)
{
$integrityChecker = $event->sender;
$integrityChecker->showTestHeadline("Validating Activity Module (" . Activity::model()->count() . " entries)");
// Loop over all comments
foreach (Activity::model()->findAll() as $a) {
if ($a->object_model != "" && $a->object_id != "" && $a->getUnderlyingObject() === null) {
$integrityChecker->showFix("Deleting activity id " . $a->id . " without existing target!");
if (!$integrityChecker->simulate) {
$a->delete();
}
}
}
}
示例3: actionRestrank
/**
* 福袋领取单
* GET /api/activity/luckybag/rank
*/
public function actionRestrank()
{
$this->checkRestAuth();
// 活动
$criteria = new CDbCriteria();
$criteria->compare('code', '2015ACODEFORGREETINGFROMWEIXIN');
$criteria->compare('archived', 1);
$activities = Activity::model()->findAll($criteria);
if (count($activities) == 0) {
return $this->sendResponse(400, "no code");
}
// 已领的奖品
$criteria = new CDbCriteria();
$criteria->compare('activity_id', $activities[0]->id);
$criteria->compare('archived', 1);
$criteria->addCondition('open_id IS NOT NULL');
$criteria->order = 'achieved_time desc';
$criteria->limit = 100;
$prizes = Coupon::model()->findAll($criteria);
$openIds = array();
foreach ($prizes as $prize) {
array_push($openIds, $prize->open_id);
}
// 获奖人
$criteria = new CDbCriteria();
$criteria->addInCondition('open_id', $openIds);
$result = Luckybag::model()->findAll($criteria);
$winners = $this->JSONArrayMapper($result);
/*
$idx = 0;
foreach ($winners as $winner) {
foreach ($prizes as $prize) {
if ($winner['openId'] == $prize->open_id) {
$winners[$idx]['prize'] = $prize->code;
}
}
$idx++;
}*/
echo CJSON::encode($winners);
}
示例4: actionLoad
/**
* Create a content and activity records for each `Question`
* extend_search/admin/load&module=questionanswer&model=Question
*/
public function actionLoad()
{
$module = Yii::app()->request->getParam('module');
$model_str = Yii::app()->request->getParam('model');
$model = new $model_str();
echo "Creating content and activity records for " . $module . " -> " . $model_str;
// Loop through all
foreach ($model::model()->findAll() as $record) {
if (empty(Activity::model()->findByAttributes(array('object_model' => $model_str, 'object_id' => $record->id)))) {
// Create activity record
$sql = "INSERT INTO activity (type,module,object_model,object_id,created_at,created_by,updated_at,updated_by)\n VALUES (:type,:module,:object_model,:object_id,:created_at,:user_id,:updated_at,:user_id);";
$parameters = array(":type" => $model_str . "Created", ":module" => $module, ":object_model" => 'Question', ":object_id" => $record->id, ":user_id" => $record->created_by, ":created_at" => $record->created_at, ":updated_at" => $record->updated_at);
Yii::app()->db->createCommand($sql)->execute($parameters);
}
// Create content record
if (!$record->content) {
$sql = "INSERT INTO content (guid,object_model,object_id,visibility,sticked,archived,space_id,user_id,created_at,created_by,updated_at,updated_by)\n VALUES (:guid, :object_model, :object_id, 1, 0, '0', NULL, :user_id, :created_at, :user_id, :updated_at, :user_id);";
$parameters = array(":guid" => UUID::v4(), ":object_model" => $model_str, ":object_id" => $record->id, ":user_id" => $record->created_by, ":created_at" => $record->created_at, ":updated_at" => $record->updated_at);
Yii::app()->db->createCommand($sql)->execute($parameters);
}
}
}
示例5: actionIndex
/**
* Index action
*/
public function actionIndex()
{
$this->render('index', array('activities' => Activity::model()->getMyActivity()));
}
示例6: actionPpkOutputChart
public function actionPpkOutputChart($id, $ppkId)
{
$activity = Activity::model()->findByPk($id);
$ppk = Ppk::model()->findByPk($ppkId);
$packageAccounts = PackageAccount::model()->findAllByAttributes(array('activity_code' => "{$activity->code}", 'ppk_code' => "{$ppk->code}"));
$outputLists = array();
if ($packageAccounts) {
foreach ($packageAccounts as $packageAccount) {
$output = $packageAccount->output->name;
if (!in_array($output, $outputLists, true)) {
array_push($outputLists, $output);
}
}
}
$outputIdLists = array();
if ($packageAccounts) {
foreach ($packageAccounts as $packageAccount) {
$outputId = $packageAccount->output->id;
if (!in_array($outputId, $outputIdLists, true)) {
array_push($outputIdLists, $outputId);
}
}
}
$outputCodes = array();
if ($packageAccounts) {
foreach ($packageAccounts as $packageAccount) {
$code = $packageAccount->output_code;
if (!in_array($code, $outputCodes, true)) {
array_push($outputCodes, $code);
}
}
}
$limits = array();
for ($i = 0; $i < count($outputLists); $i++) {
$accounts = PackageAccount::model()->findAllByAttributes(array('output_code' => $outputCodes[$i], 'ppk_code' => $ppk->code));
$limit = 0;
if ($accounts) {
foreach ($accounts as $account) {
$limit += $account->limit;
}
array_push($limits, $limit);
}
}
$realizations = array();
for ($i = 0; $i < count($outputLists); $i++) {
$accounts = PackageAccount::model()->findAllByAttributes(array('output_code' => $outputCodes[$i], 'ppk_code' => $ppk->code));
$realization = 0;
if ($accounts) {
foreach ($accounts as $account) {
$realization += $account->getTotal($account->code)['realization'];
}
array_push($realizations, $realization);
}
}
$rests = array();
for ($i = 0; $i < count($outputLists); $i++) {
$accounts = PackageAccount::model()->findAllByAttributes(array('output_code' => $outputCodes[$i], 'ppk_code' => $ppk->code));
$rest = 0;
if ($accounts) {
foreach ($accounts as $account) {
$rest += $account->getTotal($account->code)['restMoney'];
}
array_push($rests, $rest);
}
}
$rates = array();
for ($i = 0; $i < count($outputLists); $i++) {
$accounts = PackageAccount::model()->findAllByAttributes(array('output_code' => $outputCodes[$i], 'ppk_code' => $ppk->code));
$realization = 0;
$limit = 0;
if ($accounts) {
foreach ($accounts as $account) {
$realization += $account->getTotal($account->code)['realization'];
$limit += $account->limit;
}
$rate = $realization / $limit;
array_push($rates, $rate);
} else {
array_push($rates, 0);
}
}
$this->render('ppkOutputChart', array('ppk' => $ppk, 'outputLists' => $outputLists, 'id' => $outputIdLists, 'limits' => $limits, 'realizations' => $realizations, 'rests' => $rests, 'rates' => $rates));
}
示例7: beforeDelete
/**
* Before Delete, remove LikeCount (Cache) of target object.
* Remove activity
*/
protected function beforeDelete()
{
Yii::app()->cache->delete('likes_' . $this->object_model . "_" . $this->object_id);
// Delete Activity
// Currently we need to delete this manually, because the activity object is NOT bound to the Like
// Instead is it bound to the Like Target (This should changed)
$activity = Activity::model()->findByAttributes(array('type' => 'Interest', 'module' => 'like', 'object_model' => $this->object_model, 'object_id' => $this->object_id, 'created_by' => $this->created_by));
if ($activity) {
$activity->delete();
}
Notification::remove('Interest', $this->id);
return parent::beforeDelete();
}
示例8: actionRestmigrate
/**
* 迁移
* GET /api/migrate
*/
public function actionRestmigrate()
{
$criteria = new CDbCriteria();
$criteria->compare('archived', 1);
$criteria->compare('type', 0);
$criteria->order = 'created_time asc';
$activities = Activity::model()->findAll($criteria);
foreach ($activities as $activity) {
// 创建reply
$reply = new Autoreply();
$reply->name = $activity->code;
$reply->type = 0;
$reply->reply = $activity->reply;
if (!$reply->save()) {
return $this->sendResponse(500, 'failed to save reply');
}
// 创建keywords
$keywords = split(',', $activity->code);
$count = 0;
foreach ($keywords as $keywordStr) {
$criteria = new CDbCriteria();
$criteria->compare('word', $keywordStr);
$criteria->compare('archived', 1);
if (Keyword::model()->count($criteria) == 0) {
$keyword = new Keyword();
$keyword->word = $keywordStr;
$keyword->reply_id = $reply->id;
$keyword->save();
}
}
$activity->archived = 0;
$activity->save();
sleep(1);
}
echo 'migrated';
}
示例9: array
<?php
echo $form->fileFieldRow($model, 'file', array('class' => 'span5', 'maxlength' => 256, 'labelOptions' => array('label' => false)));
?>
<p>File excel yang digunakan adalah file d_kmpnen yang sudah difilter jumlah barisnya</p>
<div class="form-actions">
<?php
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Import'));
?>
</div>
<?php
$this->endWidget();
?>
</div>
<div class="panel-header">
<a href="<?php
echo yii::app()->baseUrl;
?>
/component/exportError" class="btn btn-primary"><i class="fa fa fa-download"></i> Export Error</a>
</div>
<div class="panel-body">
<h2>Daftar Error Import Karena Sudah Terealisasi</h2>
<?php
$this->widget('bootstrap.widgets.TbGridView', array('id' => 'component-error-grid', 'dataProvider' => $componentError->search(), 'filter' => $componentError, 'columns' => array(array('header' => 'No', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), array('name' => 'satker_code', 'value' => 'isset($data->satker->name)?$data->satker->name:"Not set"', 'filter' => Satker::model()->getSatkerOptions()), array('name' => 'activity_code', 'value' => 'isset($data->activity->name)?$data->activity->name:"Not set"', 'filter' => Activity::model()->getActivityOptions()), array('name' => 'output_code', 'value' => 'isset($data->outputCode->name)?$data->outputCode->name:$data->output_code', 'filter' => Output::model()->getOutputOptions()), array('name' => 'suboutput_code', 'value' => 'isset($data->suboutputCode->name)?$data->suboutputCode->name:$data->suboutput_code', 'filter' => Suboutput::model()->getSuboutputOptions()), 'code', 'name', array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{view}'))));
?>
</div>
</div>
示例10: getActivityOptions
public function getActivityOptions()
{
$models = Activity::model()->findAll();
$options = array();
foreach ($models as $model) {
$options[$model->code] = "[{$model->code}] | {$model->name}";
}
return $options;
}
示例11: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Activity the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Activity::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例12: actionExport
/**
* Export Data to Excel
*/
public function actionExport()
{
/** Get model */
$models = Activity::model()->findAll();
/** Error reporting */
$this->excelErrorReport();
/** PHPExcel_IOFactory */
$objReader = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$path = Yii::app()->basePath . '/../export/activity.xlsx';
$pathExport = Yii::app()->basePath . '/../files/master-kegiatan.xlsx';
$objPHPExcel = $objReader->load($path);
$objPHPExcel->setActiveSheetIndex(0);
/* " Add new data to template" */
$this->exportExcel($objPHPExcel, $models);
/** Export to excel* */
$this->excel($objPHPExcel, $pathExport);
readfile($pathExport);
unlink($pathExport);
exit;
}
示例13: actionRestachieve
/**
* 通过活动编码和OpenId获得优惠券
* GET /api/coupon/achieve
*/
public function actionRestachieve()
{
$this->checkRestAuth();
// 检查参数
if (!isset($_GET['code']) || !isset($_GET['openId'])) {
return $this->sendResponse(400, 'missed parameters');
}
$openId = $_GET['openId'];
// 结果对象
$result = array('activities' => array(), 'coupons' => array());
// 判断活动当前状态
$criteria = new CDbCriteria();
$criteria->compare('code', $_GET['code']);
$criteria->compare('archived', 1);
$criteria->limit = 1;
$criteria->order = 'created_time desc';
$activities = Activity::model()->findAll($criteria);
$activity;
// 找不到
if (count($activities) != 1) {
echo CJSON::encode($result);
return;
} else {
$result['activities'] = $activities;
$activity = $activities[0];
// 暂停状态
if ($activity->enabled == 0) {
echo CJSON::encode($result);
return;
}
}
// 先判断是否已领取
$criteria = new CDbCriteria();
$criteria->compare('archived', 1);
$criteria->compare('open_id', $openId);
$criteria->order = 'achieved_time desc';
$criteria->limit = 1;
$achieves = array();
$isRestricted = false;
if (intval($activity->restrict_days) > 0) {
// 如果已经领过优惠券,且不符合该活动有N天限制,不可以领取
$achieves = Coupon::model()->findAll($criteria);
if (count($achieves) > 0) {
if (time() - strtotime($achieves[0]->achieved_time) < intval($activity->restrict_days) * 60 * 60 * 24) {
$isRestricted = true;
}
}
}
$criteria->compare('activity_id', $activity->id);
$achieves = Coupon::model()->findAll($criteria);
$result['coupons'] = $achieves;
// 判断是否还可以继续领取
if ($isRestricted || count($achieves) > 0) {
echo CJSON::encode($result);
return;
}
// 再判断有没有优惠券
$criteria = new CDbCriteria();
$criteria->compare('archived', 1);
$criteria->addCondition('achieved_time IS NULL');
$criteria->addCondition('open_id IS NULL');
$criteria->compare('activity_id', $activity->id);
$criteria->limit = 10;
$coupons = Coupon::model()->findAll($criteria);
if (count($coupons) == 0) {
echo CJSON::encode($result);
return;
}
// 随机获得优惠券
$total = count($coupons);
$offset = 0;
if ($total > 1) {
$offset = (int) ($total * rand(0, 1));
if ($offset != 0) {
$offset -= 1;
}
if ($offset >= $total) {
$offset = 0;
}
}
// 写入领取记录
$coupon = $coupons[$offset];
// 再次判断记录是否被领
$checkCoupon = Coupon::model()->findByPk($coupon->id);
if ($checkCoupon->open_id != null || $coupon->achieved_time != null) {
echo CJSON::encode($result);
return;
}
$coupon->open_id = $openId;
$coupon->achieved_time = new CDbExpression('NOW()');
if ($coupon->save()) {
array_push($result['coupons'], $coupon);
echo CJSON::encode($result);
} else {
echo CJSON::encode($result);
}
//.........这里部分代码省略.........
示例14: checkMaster
/**
* Check completeness data of master
* @return boolean
*/
public function checkMaster()
{
$complete = false;
$ppk = Ppk::model()->exists();
$satker = Satker::model()->exists();
$activity = Activity::model()->exists();
$output = Output::model()->exists();
$suboutput = Suboutput::model()->exists();
$component = Component::model()->exists();
$subcomponent = Subcomponent::model()->exists();
$account = Account::model()->exists();
$province = Province::model()->exists();
$city = City::model()->exists();
if ($ppk && $satker && $activity && $output && $suboutput & $component && $subcomponent && $account && $province && $city) {
$complete = TRUE;
}
return $complete;
}
示例15: actionRestremove
/**
* 删除活动信息
* DELETE /api/activity/{activityId}
*/
public function actionRestremove()
{
$this->checkRestAuth();
$activity = Activity::model()->findByPk($_GET['activityId']);
if ($activity == null || $activity->archived == 0) {
return $this->sendResponse(404, 'activity is not found');
}
$activity->archived = 0;
$activity->code = $activity->code . '-removed-' . $activity->id;
// 删除以后 编码需要释放
$criteria = new CDbCriteria();
$criteria->compare('archived', 1);
$criteria->addCondition('achieved_time IS NULL');
$criteria->addCondition('open_id IS NULL');
$criteria->compare('activity_id', $activity->id);
$criteria->order = 'achieved_time desc';
$coupns = Coupon::model()->findAll($criteria);
foreach ($coupns as $coupon) {
$coupon->archived = 0;
if (!$coupon->save()) {
return $this->sendResponse(200, 'failed to update coupon.');
}
}
if ($activity->save()) {
$this->sendResponse(200, 'removed.');
} else {
$this->sendResponse(500, 'failed to remove.');
}
}