public static function clean_map($properties) { $avoid = array('_', 'Converse+by+John+Varvatos'); foreach (get_object_vars($properties) as $prop => $val) { if ($prop === 'brands') { asort($properties->{$prop}); } else { rsort($properties->{$prop}); } foreach ($properties->{$prop} as $k => $v) { if (in_array($v, $avoid)) { unset($properties->{$prop}[$k]); } else { $properties->{$prop}[$k] = Helper::translate($properties->{$prop}[$k]); // $properties->{$prop}[$k] = array('t' => $t, 'u' => $u); // $properties->{$prop}[$k] = strtolower( str_replace(array('+', '-'), ' ', $properties->{$prop}[$k])); } } } return $properties; }
protected function onUnauthorizedAccess() { /** * Check if the unautorizedacces is a result of the user no longer being logged in. * If so, redirect the user to the login page and after login return the user to the page they tried to open. * If not, show the unautorizedacces message. */ if (Yii::app()->user->isGuest) { Yii::app()->user->loginRequired(); } else { $mod = $this->module !== null ? $this->module->id : ""; $access = $mod . ucfirst($this->id) . ucfirst($this->action->id); $error["code"] = "403"; $error["title"] = Helper::translate('srbac', 'You are not authorized for this action'); $error["message"] = Helper::translate('srbac', 'Error while trying to access') . ' ' . $mod . "/" . $this->id . "/" . $this->action->id . "."; //You may change the view for unauthorized access if (Yii::app()->request->isAjaxRequest) { $this->renderPartial(Yii::app()->getModule('srbac')->notAuthorizedView, array("error" => $error)); } else { $this->render(Yii::app()->getModule('srbac')->notAuthorizedView, array("error" => $error)); } return false; } }
echo SHtml::link($model->name, array('show', 'id' => $model->name)); ?> </td> <td><?php echo SHtml::encode(AuthItem::$TYPES[$model->type]); ?> </td> <td> <?php echo SHtml::link(Helper::translate('srbac', 'Update'), array('update', 'id' => $model->name)); ?> <?php if ($model->name != Yii::app()->getModule('srbac')->superUser) { ?> <?php echo SHtml::linkButton(Helper::translate('srbac', 'Delete'), array('submit' => '', 'params' => array('command' => 'delete', 'id' => $model->name), 'confirm' => "Are you sure to delete #{$model->name}?")); ?> <?php } ?> </td> </tr> <?php } ?> </table> <br/> <?php $this->widget('CLinkPager', array('pages' => $pages)); ?>
<?php echo SHtml::ajaxLink(SHtml::image($this->module->getIconsPath() . '/delete.png', "Delete All Auth Items of controller " . $controller, array('border' => 0, 'title' => Helper::translate('srbac', 'Delete All Auth Items of controller') . ' ' . $controller)), array('scan', 'module' => $module, 'controller' => $controller, 'delete' => true), array('type' => 'POST', 'update' => '#controllerActions', 'beforeSend' => 'function(){ $("#controllerActions").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#controllerActions").removeClass("srbacLoading"); }'), array('name' => 'buttonDelete_' . $n)); ?> </td> </tr> <?php } ?> </table> </td> <td width="60%" style="vertical-align: top"> <table class="srbacDataGrid" width="50%" style="float:left"> <tr> <th width="70%"><?php echo Helper::translate('srbac', 'Auth items'); ?> </th> </tr> <tr> <td valign="top"> <div id="controllerActions"></div> </td> </tr> </table> </td> </table> </div>
if ($error) { ?> <div> <?php echo Helper::translate('srbac', 'There is an error in your configuration'); ?> <?php $disabled = array('disabled' => true); ?> </div> <?php } ?> <?php echo SHtml::hiddenField("action", "Install"); ?> <?php echo SHtml::checkBox("demo", false, $disabled); echo Helper::translate('srbac', 'Create demo authItems?'); ?> <br /> <?php echo SHtml::submitButton(Helper::translate('srbac', 'Install'), $disabled); ?> </div> <?php echo SHtml::endForm(); ?> </div>
public function actionSaveAllowed() { if (!Helper::isAlwaysAllowedFileWritable()) { echo Helper::translate("srbac", "The always allowed file is not writable by the server") . "<br />"; echo "File : " . $this->module->getAlwaysAllowedFile(); return; } $allowed = array(); foreach ($_POST as $controller) { foreach ($controller as $action) { //Delete items $auth = AuthItem::model()->findByPk($action); if ($auth !== null) { $auth->delete(); } $allowed[] = $action; } } $handle = fopen($this->module->getAlwaysAllowedFile(), "wb"); fwrite($handle, "<?php \n return array(\n\t'" . implode("',\n\t'", $allowed) . "'\n);\n?>"); fclose($handle); $this->renderPartial("saveAllowed", array("allowed" => $allowed)); }
* @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * Srbac main administration page * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem * @since 1.0.2 */ ?> <div class="marginBottom"> <div class="iconSet"> <div class="iconBox"> <?php echo SHtml::link(SHtml::image($this->module->getIconsPath() . '/manageAuth.png', Helper::translate('srbac', 'Managing auth items'), array('class' => 'icon', 'title' => Helper::translate('srbac', 'Managing auth items'), 'border' => 0)) . " " . ($this->module->iconText ? Helper::translate('srbac', 'Managing auth items') : ""), array('authitem/manage')); ?> </div> <div class="iconBox"> <?php echo SHtml::link(SHtml::image($this->module->getIconsPath() . '/usersAssign.png', Helper::translate('srbac', 'Assign to users'), array('class' => 'icon', 'title' => Helper::translate('srbac', 'Assign to users'), 'border' => 0)) . " " . ($this->module->iconText ? Helper::translate('srbac', 'Assign to users') : ""), array('authitem/assign')); ?> </div> <div class="iconBox"> <?php echo SHtml::link(SHtml::image($this->module->getIconsPath() . '/users.png', Helper::translate('srbac', 'User\'s assignments'), array('class' => 'icon', 'title' => Helper::translate('srbac', 'User\'s assignments'), 'border' => 0)) . " " . ($this->module->iconText ? Helper::translate('srbac', 'User\'s assignments') : ""), array('authitem/assignments')); ?> </div> </div> <div class="reset"></div> </div>
/** * success.php * * @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * The successful installation view. * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem.install * @since 1.0.0 */ ?> <h3><?php echo Helper::translate('srbac', 'Install Srbac'); ?> </h3> <div> <?php echo Helper::translate('srbac', 'Srbac installed successfuly'); ?> </div> <div> <?php echo SHtml::link(Helper::translate('srbac', 'Srbac frontpage'), array('frontpage')); ?> </div>
$this->renderPartial('tabViews/taskAjax', array('model' => $model, 'userid' => $userid, 'data' => $data, 'message' => $message)); ?> </div> </td> </tr> <tr valign="top"> <td><?php echo SHtml::activeDropDownList(Assignments::model(), 'itemname', SHtml::listData(AuthItem::model()->findAll($criteria), 'name', 'name'), array('size' => $this->module->listBoxNumberOfLines, 'class' => 'dropdown', 'ajax' => array('type' => 'POST', 'url' => array('getOpers'), 'update' => '#operations', 'beforeSend' => 'function(){ $("#loadMessTask").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#loadMessTask").removeClass("srbacLoading"); }'))); ?> <div> <?php echo Helper::translate("srbac", "Clever Assigning"); ?> : <?php echo SHtml::checkBox("clever", Yii::app()->getGlobalState("cleverAssigning")); ?> </div> </td> </tr> </table> <br /> <div class="message" id="loadMessTask"> <?php echo $message; ?>
<?php /** * create.php * * @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * The create new auth item view. * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem.manage * @since 1.0.0 */ ?> <div class="title"><?php echo Helper::translate('srbac', 'Create New Item'); ?> </div> <?php echo $this->renderPartial('manage/_form', array('model' => $model, 'update' => false), false, true);
</td> <td> <?php echo SHtml::ajaxLink(SHtml::image($this->module->getIconsPath() . '/update.png', Helper::translate('srbac', 'Update'), array('border' => 0, 'title' => Helper::translate('srbac', 'Update'))), array('update', 'id' => $model->name), array('type' => 'POST', 'update' => '#preview', 'beforeSend' => 'function(){ $("#preview").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#preview").removeClass("srbacLoading"); }')); ?> </td> <td> <?php if ($model->name != Helper::findModule('srbac')->superUser) { ?> <?php echo SHtml::ajaxLink(SHtml::image($this->module->getIconsPath() . '/delete.png', Helper::translate('srbac', 'Delete'), array('border' => 0, 'title' => Helper::translate('srbac', 'Delete'))), array('confirm', 'id' => $model->name), array('type' => 'POST', 'update' => '#preview', 'beforeSend' => 'function(){ $("#preview").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#preview").removeClass("srbacLoading"); }')); } ?> </td> </tr> <?php } ?> </table> <?php echo SHtml::endForm(); ?>
protected function afterSave() { parent::afterSave(); if ($this->oldName != $this->name) { $this->model()->updateByPk($this->oldName, array("name" => $this->name)); $criteria = new CDbCriteria(); $criteria->condition = "itemname='" . $this->oldName . "'"; Assignments::model()->updateAll(array('itemname' => $this->name), $criteria); $criteria->condition = "parent='" . $this->oldName . "'"; ItemChildren::model()->updateAll(array('parent' => $this->name), $criteria); $criteria->condition = "child='" . $this->oldName . "'"; ItemChildren::model()->updateAll(array('child' => $this->name), $criteria); Yii::app()->user->setFlash('updateName', Helper::translate('srbac', 'Updating list')); } }
<?php /** * unauthorized.php * * @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * Default page shown when a not authorized user tries to access a page * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem * @since 1.0.2 */ ?> <h2 style="color:red"> <?php echo Helper::translate('srbac', "Error:") . $error["code"] . " '" . $error["title"] . "'"; ?> </h2> <p> <?php echo $error["message"]; ?> </p>
<div class="srbac"> <?php echo SHtml::beginForm(); ?> <?php echo SHtml::errorSummary($model); ?> <table width="100%"> <tr><th colspan="2"><?php echo Helper::translate('srbac', 'Assign Tasks to Roles'); ?> </th></tr> <tr> <th width="50%"> <?php echo SHtml::label(Helper::translate('srbac', "Role"), 'role'); ?> </th> <td width="50%" rowspan="2"> <div id="tasks"> <?php $this->renderPartial('tabViews/roleAjax', array('model' => $model, 'userid' => $userid, 'data' => $data, 'message' => $message)); ?> </div> </td> </tr> <tr valign="top"> <td><?php echo SHtml::activeDropDownList(AuthItem::model(), 'name[0]', SHtml::listData(AuthItem::model()->findAll($criteria), 'name', 'name'), array('size' => $this->module->listBoxNumberOfLines, 'class' => 'dropdown', 'ajax' => array('type' => 'POST', 'url' => array('getTasks'), 'update' => '#tasks', 'beforeSend' => 'function(){ $("#loadMessRole").addClass("srbacLoading"); }', 'complete' => 'function(){
<h1>Assignments of user : '******'</h1> <table class="srbacDataGrid" width="100%"> <tr> <th class="roles"><?php echo Helper::translate('srbac', 'Roles'); ?> </th> <th class="tasks"><?php echo Helper::translate('srbac', 'Tasks'); ?> </th> <th class="operations"><?php echo Helper::translate('srbac', 'Operations'); ?> </th> </tr> <tr> <td valign="top" colspan="3"> <table class="roles"> <?php foreach ($data as $i => $roles) { ?> <tr> <td><b><?php echo $i; ?> </b> <?php
<?php } ?> </td> </tr> </table> <?php } if ($notRemoved) { ?> <table class="srbacDataGrid" style="width:50%"> <tr> <th style="background-color: red;color: white"> <?php echo "</b>" . Helper::translate("srbac", "authItems not removed") . "</b>"; ?> : </th> </tr> <tr> <td> <?php foreach ($notRemoved as $item) { ?> <?php echo " " . $item . "<br >"; ?> <?php } ?>
echo SHtml::encode($model->getAttributeLabel('data')); ?> </th> <td><?php echo SHtml::encode($model->data); ?> </td> </tr> </table> <div class="simple"> <?php if ($delete) { ?> <?php echo Helper::translate('srbac', 'Really delete'); ?> <?php echo $model->name; ?> ? <?php echo SHtml::ajaxButton(Helper::translate('srbac', 'Yes'), array('delete', 'id' => $model->name), array('type' => 'POST', 'update' => '#preview'), array('id' => 'deleteButton')); ?> <?php } ?> </div> </div> </div> <?php }
* @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem.tabViews * @since 1.0.0 */ ?> <div class="wrapper wrapper-white"> <div class="row"> <table width="100%"> <tr> <th><?php echo Helper::translate('srbac', 'Assigned Operations'); ?> </th> <th> </th> <th><?php echo Helper::translate('srbac', 'Not Assigned Operations'); ?> </th> </tr> <tr><td width="45%"> <?php echo SHtml::activeDropDownList($model, 'name[revoke]', SHtml::listData($data['taskAssignedOpers'], 'name', 'name'), array('size' => $this->module->listBoxNumberOfLines, 'multiple' => 'multiple', 'class' => 'dropdown')); ?> </td> <td width="10%" align="center"> <?php $ajax = array('type' => 'POST', 'update' => '#operations', 'beforeSend' => 'function(){ $("#loadMessTask").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#loadMessTask").removeClass("srbacLoading"); }');
}'), array('name' => 'buttonClear', 'onclick' => "\$(this).css('font-weight', 'bold');\$(this).siblings().css('font-weight', 'normal');")); ?> </div> <br /> <?php } ?> <div id="wizard"> <table class="srbacDataGrid" align="center"> <tr> <th width="50%"><?php echo Helper::translate("srbac", "Auth items"); ?> </th> <th><?php echo Helper::translate('srbac', 'Actions'); ?> </th> </tr> <tr> <td style="vertical-align: top;text-align: center"> <div id="list"> <?php echo $this->renderPartial('manage/list', array('models' => $models, 'pages' => $pages, 'sort' => $sort)); ?> </div> </td> <td style="vertical-align: top;text-align: center"> <div id="preview"> </div>
/** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array('itemname' => Helper::translate('srbac', 'Itemname'), 'userid' => Helper::translate('srbac', 'User id'), 'bizrule' => Helper::translate('srbac', 'Bizrule'), 'data' => Helper::translate('srbac', 'Data')); }
echo SHtml::ajaxButton(Helper::translate('srbac', 'Delete'), array("deleteObsolete"), array('type' => 'POST', 'update' => '#obsoleteList', 'beforeSend' => 'function(){ $("#wiobsoleteListzard").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#obsoleteList").removeClass("srbacLoading"); }'), array('name' => 'buttonSave')); ?> </div> <?php echo SHtml::endForm(); ?> </div> </td> </tr> </table> </div> <?php } else { ?> <table class="srbacDataGrid" style="width:50%"> <tr> <th> <?php echo Helper::translate("srbac", "No authItems that don't belong to a controller were found"); ?> </th> </tr> </table> <?php }
* The assigning roles to users listboxes * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem.tabViews * @since 1.0.0 */ ?> <table width="100%"> <tr> <th><?php echo Helper::translate('srbac', 'Assigned Roles'); ?> </th> <th> </th> <th><?php echo Helper::translate('srbac', 'Not Assigned Roles'); ?> </th> </tr> <tr><td width="45%"> <?php echo SHtml::activeDropDownList($model, 'name[revoke]', SHtml::listData($data['userAssignedRoles'], 'name', 'name'), array('size' => $this->module->listBoxNumberOfLines, 'multiple' => 'multiple', 'class' => 'dropdown')); ?> </td> <td width="10%" align="center"> <?php $ajax = array('type' => 'POST', 'update' => '#roles', 'beforeSend' => 'function(){ $("#loadMess").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#loadMess").removeClass("srbacLoading"); }');
* saveAllowed.php * * @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * The view that displays the items that are saved in the alwaysAllowed file * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem * @since 1.1.0 */ ?> <div> <?php echo Helper::translate("srbac", "The following authItems are saved in the always allowed file"); ?> <?php echo ":" . $this->module->getAlwaysAllowedFile(); ?> </div> <br /> <?php foreach ($allowed as $item) { ?> <div style="text-align:left;font-weight:bold"> <?php echo $item . "<br />"; ?> </div> <?php
//$cont[$n+3]["title"] = str_replace("Controller", "", $title); //$cont[$n+3]["content"] = SHtml::checkBoxList($title, $select, $data); $cont["tab_" . $n] = array("title" => str_replace("Controller", "", $title), "content" => SHtml::checkBoxList($title, $select, $data)); } } echo SHtml::form(); ?> <div class="vertTab"> <?php Helper::publishCss($this->module->css); $this->widget('system.web.widgets.CTabView', array('tabs' => $cont, 'cssFile' => $this->module->getCssUrl())); ?> </div> <div class="action"> <?php echo SHtml::ajaxSubmitButton(Helper::translate("srbac", "Save"), array('saveAllowed'), array('type' => 'POST', 'update' => '#wizard', 'beforeSend' => 'function(){ $("#wizard").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#wizard").removeClass("srbacLoading"); }'), array('name' => 'buttonSave')); ?> </div> <?php echo SHtml::endForm(); ?> <!--Adjust tabview height---> <script type="text/javascript"> var tabsHeight = $(".tabs").height(); if(tabsHeight > 260){ $(".view").height(tabsHeight-16); } else {
public function getMessage() { if ($this->_message != "") { return Helper::translate("srbac", $this->_message); } else { return ""; } }
$this->renderPartial($this->module->header); } ?> <div class="simple"> <?php $this->renderPartial("frontpage"); ?> <?php echo SHtml::beginForm(); ?> <?php echo SHtml::activeDropDownList($this->module->getUserModel(), $this->module->userid, SHtml::listData($this->module->getUserModel()->findAll(), $this->module->userid, $this->module->username), array('size' => 1, 'class' => 'dropdown', 'ajax' => array('type' => 'POST', 'url' => array('showAssignments'), 'update' => '#assignments', 'beforeSend' => 'function(){ $("#assignments").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#assignments").removeClass("srbacLoading"); }'), 'prompt' => Helper::translate('srbac', 'select user'))); ?> <?php echo SHtml::endForm(); ?> </div> <?php } else { ?> <?php $url = Yii::app()->urlManager->createUrl("srbac/authitem/showAssignments", array("id" => $id)); ?> <?php Yii::import("srbac.components.Helper"); ?> <?php
* The assigning task to roles listboxes * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem.tabViews * @since 1.0.0 */ ?> <table width="100%"> <tr> <th><?php echo Helper::translate('srbac', 'Assigned Tasks'); ?> </th> <th> </th> <th><?php echo Helper::translate('srbac', 'Not Assigned Tasks'); ?> </th> </tr> <tr><td width="45%"> <?php echo SHtml::activeDropDownList($model, 'name[revoke]', SHtml::listData($data["roleAssignedTasks"], 'name', 'name'), array('size' => $this->module->listBoxNumberOfLines, 'multiple' => 'multiple', 'class' => 'dropdown')); ?> </td> <td width="10%" align="center"> <?php $ajax = array('type' => 'POST', 'update' => '#tasks', 'beforeSend' => 'function(){ $("#loadMessRole").addClass("srbacLoading"); }', 'complete' => 'function(){ $("#loadMessRole").removeClass("srbacLoading"); }');
* @author Spyros Soldatos <*****@*****.**> * @link http://code.google.com/p/srbac/ */ /** * The Assign tabview view * * @author Spyros Soldatos <*****@*****.**> * @package srbac.views.authitem * @since 1.0.0 */ $this->breadcrumbs = array('Srbac Assign'); if ($this->module->getShowHeader()) { $this->renderPartial($this->module->header); } ?> <div> <?php $this->renderPartial("frontpage"); $tabs = array('tab1' => array('title' => Helper::translate('srbac', 'Users'), 'view' => 'tabViews/roleToUser'), 'tab2' => array('title' => Helper::translate('srbac', 'Roles'), 'view' => 'tabViews/taskToRole'), 'tab3' => array('title' => Helper::translate('srbac', 'Tasks'), 'view' => 'tabViews/operationToTask')); ?> <div class="horTab"> <?php Helper::publishCss($this->module->css); $this->widget('system.web.widgets.CTabView', array('tabs' => $tabs, 'viewData' => array('model' => $model, 'userid' => $userid, 'message' => $message, 'data' => $data), 'cssFile' => $this->module->getCssUrl())); ?> </div> </div> <?php if ($this->module->getShowFooter()) { $this->renderPartial($this->module->footer); }
?> </div> <div class="simple"> <?php echo SHtml::activeLabelEx($model, 'data'); ?> <?php echo SHtml::activeTextField($model, 'data', $model->name == Helper::findModule('srbac')->superUser ? array('disabled' => 'disabled', 'size' => 30) : array('size' => 30)); ?> </div> <?php echo SHtml::hiddenField("oldName", $model->name); ?> <div class="action"> <?php echo SHtml::ajaxSubmitButton($update ? Helper::translate('srbac', 'Save') : Helper::translate('srbac', 'Create'), $update ? array('update', 'id' => $model->name) : array('create'), array('type' => 'POST', 'update' => '#preview'), array('name' => 'saveButton2')); ?> </div> <div id="mess" class="message" style="visibility:hidden"> $message </div> <?php echo SHtml::endForm(); ?> </div><!-- srbacForm --> <script language="javascript"> <?php echo SHtml::ajax(array('type' => 'POST', 'url' => array('manage'), 'update' => '#list')); ?> </script>
<div class="srbac"> <?php echo SHtml::beginForm(); ?> <?php echo SHtml::errorSummary($model); ?> <table width="100%"> <tr><th colspan="2"><?php echo Helper::translate('srbac', 'Assign Roles to Users'); ?> </th></tr> <tr> <th width="50%"> <?php echo SHtml::label(Helper::translate('srbac', "User"), 'user'); ?> </th> <td width="50%" rowspan="2"> <div id="roles"> <?php $this->renderPartial('tabViews/userAjax', array('model' => $model, 'userid' => $userid, 'data' => $data, 'message' => $message)); ?> </div> </td> </tr> <tr valign="top"> <td><?php $criteria = new CDbCriteria(); $criteria->order = $this->module->username; echo SHtml::activeDropDownList($this->module->getUserModel(), $this->module->userid, SHtml::listData($this->module->getUserModel()->findAll($criteria), $this->module->userid, $this->module->username), array('size' => $this->module->listBoxNumberOfLines, 'class' => 'dropdown', 'ajax' => array('type' => 'POST', 'url' => array('getRoles'), 'update' => '#roles', 'beforeSend' => 'function(){