Skip to content

Instantly share code, notes, and snippets.

<?php
class SetRoleCommand extends CConsoleCommand
{
public function actionIndex($role, $userId)
{
$auth = Yii::app()->authManager;
$roles = $auth->getRoles();
if (!array_key_exists($role, $roles)) {
$auth->createRole($role);
@rinatio
rinatio / gist:3873386
Created October 11, 2012 15:59 — forked from mattheworiordan/gist:1037984
Backbone patch to defer update method requests when new create requests are not complete on a model
(function() {
Backbone.Model.prototype._save = Backbone.Model.prototype.save;
Backbone.Model.prototype.save = function (attrs, options) {
var that = this;
if (!options) {
options = {};
}
if (this.savingNewRecord) {
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well