本文整理汇总了PHP中Survey::Model方法的典型用法代码示例。如果您正苦于以下问题:PHP Survey::Model方法的具体用法?PHP Survey::Model怎么用?PHP Survey::Model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Survey
的用法示例。
在下文中一共展示了Survey::Model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasSurveyPermission
/**
* Checks if a user has a certain permission in the given survey
*
* @param $iSurveyID integer The survey ID
* @param $sPermission string Name of the permission
* @param $sCRUD string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'
* @param $iUserID integer User ID - if not given the one of the current user is used
* @return bool True if user has the permission
*/
public function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD = 'read', $iUserID = null)
{
$oSurvey = Survey::Model()->findByPk($iSurveyID);
if (!$oSurvey) {
return false;
}
// Get global correspondance for surveys rigth
$sGlobalCRUD = $sCRUD == 'create' || $sCRUD == 'delete' && $sPermission != 'survey' ? 'update' : $sCRUD;
return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
}
示例2: hasSurveyPermission
/**
* Checks if a user has a certain permission in the given survey
*
* @param $iSurveyID integer The survey ID
* @param $sPermission string Name of the permission
* @param $sCRUD string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'
* @param $iUserID integer User ID - if not given the one of the current user is used
* @return bool True if user has the permission
*/
function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD = 'read', $iUserID = null)
{
$oSurvey = Survey::Model()->findByPk($iSurveyID);
if (!$oSurvey) {
return false;
}
$iUserID = self::getUserId($iUserID);
// If you own a survey you have access to the whole survey
if ($iUserID == $oSurvey->owner_id) {
return true;
}
// Get global correspondance for surveys rigth
$sGlobalCRUD = $sCRUD == 'create' || $sCRUD == 'delete' && $sPermission != 'survey' ? 'update' : $sCRUD;
return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
}
示例3: hasSurveyPermission
/**
* Checks if a user has a certain permission in the given survey
*
* @param $iSurveyID integer The survey ID
* @param $sPermission string Name of the permission
* @param $sCRUD string The permission detail you want to check on: 'create','read','update','delete','import' or 'export'
* @param $iUserID integer User ID - if not given the one of the current user is used
* @return bool True if user has the permission
*/
public function hasSurveyPermission($iSurveyID, $sPermission, $sCRUD = 'read', $iUserID = null)
{
$oSurvey = Survey::Model()->findByPk($iSurveyID);
if (!$oSurvey) {
return false;
}
// If the user has the permission to update all other surveys he may import/export as well
if ($this->hasGlobalPermission('surveys', 'update', $iUserID) && $sPermission == 'token' && ($sCRUD == 'import' || $sCRUD == 'export')) {
$sCRUD = 'update';
}
// Get global correspondance for surveys rigth
$sGlobalCRUD = $sCRUD == 'create' || $sCRUD == 'delete' && $sPermission != 'survey' ? 'update' : $sCRUD;
return $this->hasGlobalPermission('surveys', $sGlobalCRUD, $iUserID) || $this->hasPermission($iSurveyID, 'survey', $sPermission, $sCRUD, $iUserID);
}