本文整理汇总了PHP中Rule::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::model方法的具体用法?PHP Rule::model怎么用?PHP Rule::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* fourth sequence
* Method untuk meload data rule berdasarkan primary key
*/
private function loadModel($id)
{
$model = Rule::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: actionGetRule
public function actionGetRule()
{
$keyword = $_GET['q'];
$models = Rule::model()->findAll(array('condition' => 'rule_name LIKE :keyword', 'params' => array(':keyword' => '%' . $keyword . '%'), 'order' => 'rule_name', 'limit' => 5));
$suggest = array();
foreach ($models as $model) {
$suggest[] = array('id' => $model->id_rule . '-' . $model->point, 'text' => $model->rule_name);
}
echo CJSON::encode($suggest);
}
示例3: hasAccess
/**
* This utility says if a user can execute certain rules over an object.
*
* @param User $user
* @param string $rule_name
* @param string $obj_type
* @param number $obj_id
* @return boolean Returns true if the user has access, false otherwise.
*/
public static function hasAccess($user, $rule_name, $obj_type = null, $obj_id = null)
{
$ret_val = false;
if (isset($user) && isset($rule_name)) {
/* rule */
$rule = Rule::model()->findByAttributes(array('name' => $rule_name));
/* does it exist? */
if (isset($rule)) {
$perms_attr['rule_id'] = $rule->id;
$perms_attr['object_type'] = isset($obj_type) ? $obj_type : null;
$perms_attr['object_id'] = isset($obj_id) ? $obj_id : null;
$perms = Permission::model()->findAllByAttributes($perms_attr);
if (isset($perms)) {
foreach ($perms as $p) {
if ($p->subject_type == 'users' && $p->subject_id == $user->id) {
$ret_val = true;
break;
}
}
if (!$ret_val) {
foreach ($perms as $p) {
if ($p->subject_type == 'groups' && $user->isInGroup($p->subject_id)) {
$ret_val = true;
break;
}
}
}
}
}
}
return $ret_val;
}