本文整理汇总了PHP中Activity::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP Activity::exists方法的具体用法?PHP Activity::exists怎么用?PHP Activity::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Activity
的用法示例。
在下文中一共展示了Activity::exists方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
<?php
include '../../inc/init.inc';
if (!$id || !is_numeric($id)) {
throw new Exception("No activity given");
}
if (!Activity::exists($id)) {
throw new Exception('Not Found');
}
$activity = Activity::find($id);
if ($activity->user_id != $res->user->id) {
throw new Exception('Not authorized');
}
$res->organizers = $activity->getOrganizers();
$list = array();
foreach ($res->user->getPotientialUserNetwork()->asArray() as $potentialUserNetwork) {
$list[] = "" <img src='" . $potentialUserNetwork->getPicture(16) . " /> " . $potentialUserNetwork->name() . " " . "(" . $potentialUserNetwork->id . ")" . """;
}
$res->memberListValues = implode('-', $activity->getOrganizers()->asID());
foreach ($res->organizers->asArray() as $memberListUnit) {
$res->memberList .= "<p>" . $memberListUnit->name() . " " . "(" . $memberListUnit->id . ")" . "</p>";
}
$res->useTemplate("Membre de votre " . $activity->name());
示例2: Exception
<?php
include '../../inc/init.inc';
if (isset($id) && is_numeric($id) && Activity::exists($id)) {
$activity = Activity::find($id);
if ($activity->user_id != $res->user->id) {
throw new Exception('Unauthorized action');
}
} else {
$activity = new Activity();
}
$activity->name = $name;
$activity->start = $start . " " . $startTime;
$activity->end = $end . " " . $endTime;
$activity->status = $status;
$activity->privacy = $privacy;
$activity->description = $description;
$activity->user_id = $res->user->id;
if ($activity->is_valid()) {
$activity->save();
if (isset($member_list_values)) {
preg_match_all('#\\(([^)]+)\\)#', $member_list_values, $organizers_ids);
Activities_User::table()->delete(array('activity_id' => $activity->id));
$organizers_ids[1][] = $activity->user_id;
foreach ($organizers_ids[1] as $organizers_id) {
if (!User::exists($organizers_id)) {
continue;
}
$activity_user = Activities_User::create(array('activity_id' => $activity->id, 'user_id' => $organizers_id));
}
}
示例3: array
<?php
include '../../inc/init.inc';
if ($id && Activity::exists($id)) {
$activity = Activity::find($id);
} else {
$res->load('activities', array('error' => "4xx"));
}
$diff1 = $activity->start->diff($activity->end);
$now = new ActiveRecord\DateTime();
$diff2 = $now->diff($activity->end);
$is_end = $activity->end->getTimestamp() - $now->getTimestamp() > 0 ? false : true;
if ($diff2->days == 0 || $diff1->days == 0) {
$res->diff = $is_end ? 100 : 99;
} else {
$res->diff = round(($diff1->days - $diff2->days) / $diff1->days * 100, 0, PHP_ROUND_HALF_DOWN);
}
$res->is_end = $is_end;
switch ($activity->status) {
case 2:
$res->status_bar = "success";
$res->is_end = true;
$res->diff = 100;
break;
case 1:
$res->status_bar = "-striped progress-info";
break;
default:
$res->status_bar = "info";
break;
}