当前位置: 首页>>代码示例>>PHP>>正文


PHP Activity::exists方法代码示例

本文整理汇总了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[] = "&quot; <img src='" . $potentialUserNetwork->getPicture(16) . " /> " . $potentialUserNetwork->name() . "&nbsp;" . "(" . $potentialUserNetwork->id . ")" . "&quot;";
}
$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());
开发者ID:Osin,项目名称:Intranet,代码行数:23,代码来源:activity.manage.organizers.php

示例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));
        }
    }
开发者ID:Osin,项目名称:Intranet,代码行数:31,代码来源:action.activity.update.php

示例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;
}
开发者ID:Osin,项目名称:Intranet,代码行数:31,代码来源:activity.php


注:本文中的Activity::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。