add is_editing_allowed function to OC_Calendar_Share

This commit is contained in:
Georg Ehrke 2012-02-22 10:41:16 +01:00
parent d20b8399c3
commit 48f42176cd
1 changed files with 17 additions and 0 deletions

View File

@ -181,4 +181,21 @@ class OC_Calendar_Share{
}
return $active_where;
}
/*
* @brief: checks the permission for editing an event
* @param: (string) $share - userid (if $sharetype == user) / groupid (if $sharetype == group) / token (if $sharetype == public)
* @param: (string) $id - id of the calendar / event
* @param: (string) $type - use const self::CALENDAR or self::EVENT
* @return (bool)
*/
public static function is_editing_allowed($share, $id, $type){
$group_where = self::group_sql(OC_Group::getUserGroups($share));
$permission_where = self::permission_sql('rw');
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*calendar_share_' . $type . ' WHERE ((share = ? AND sharetype = "user") ' . $group_where . ') ' . $permission_where . ')');
$result = $stmt->execute(array($share));
if($result->numRows() == 1){
return true;
}
return false;
}
}