public function setUp(){
$this->model = new $this->modelName;
}
+
+ public function getPerms($request){
+ return array('view', 'add', 'change', 'delete');
+ }
protected function setInlines(&$instance=null){
$il = $this->inlines();
'form'=>$form,
'inlineInstances'=>$this->inlineInstances,
'lapp'=>$lapp,
+ 'perms'=>$this->getPerms($request),
'lmodel'=>$lmodel,
);
return IPF_Shortcuts::RenderToResponse('admin/change.html', $context, $request);
$this->ListItemsQuery();
$this->qe = $this->q->execute();
$this->ListItemsHeader();
- //print_r($this->qe->getTable()->getIdentifier());
$context = array(
'page_title'=>$this->modelName.' List',
'header'=>$this->header,
'classname'=>$this->modelName,
'objects'=>$this->qe,
'classname'=>$this->modelName,
+ 'perms'=>$this->getPerms($request),
);
return IPF_Shortcuts::RenderToResponse('admin/items.html', $context, $request);
}
{/foreach}
<div class="submit-row">
- <p class="float-left"><a href="{url 'IPF_Admin_Views_DeleteItem', array($lapp, $lmodel, $object.id)}" class="deletelink">Delete</a></p>
+ {if array_search('delete',$perms)!==false}<p class="float-left"><a href="{url 'IPF_Admin_Views_DeleteItem', array($lapp, $lmodel, $object.id)}" class="deletelink">Delete</a></p>{/if}
<input type="submit" value="Save" class="default" />
</div>
</form>
{foreach $app.models as $model}
<tr>
<th><a href="{url 'IPF_Admin_Views_ListItems', array($app.path, $model.path)}">{$model.name}</a></th>
- <td><a class="addlink" href="{url 'IPF_Admin_Views_AddItem', array($app.path, $model.path)}">{trans 'Add'}</a></td>
- <td><a class="changelink" href="{url 'IPF_Admin_Views_ListItems', array($app.path, $model.path)}">{trans 'Change'}</a></td>
+ <td>{if array_search('add',$model['perms'])!==false}<a class="addlink" href="{url 'IPF_Admin_Views_AddItem', array($app.path, $model.path)}">{trans 'Add'}</a>{/if}</td>
+ <td>{if array_search('change',$model['perms'])!==false}<a class="changelink" href="{url 'IPF_Admin_Views_ListItems', array($app.path, $model.path)}">{trans 'Change'}</a>{/if}</td>
</tr>
{/foreach}
</table>
<div id="ipfcontent">
<h1>{$page_title}</h1>
- <ul class="object-tools"><li><a href="add/" class="addlink">Add {$classname}</a></li></ul>
+ <ul class="object-tools">{if array_search('add',$perms)!==false}<li><a href="add/" class="addlink">Add {$classname}</a></li>{/if}</ul>
<div id="changelist">
<table>
<thead>
$models = new IPF_Template_ContextVars();
$models_found = false;
foreach($app->modelList() as $m){
- if (IPF_Admin_Model::isModelRegister($m)){
- $models[] = new IPF_Template_ContextVars(array('name'=>$m, 'path'=>strtolower($m)));
- $models_found = true;
+
+ $ma = IPF_Admin_Model::getModelAdmin($m);
+ if ($ma!==null){
+ $perms = $ma->getPerms($request);
+ if (array_search('view', $perms)!==false){
+ $models[] = new IPF_Template_ContextVars(array(
+ 'name'=>$m,
+ 'path'=>strtolower($m),
+ 'perms'=>$perms,
+ ));
+ $models_found = true;
+ }
}
}
if ($models_found){
{
return array('UPLOAD_URL' => IPF::get('upload_url'));
}
+
+function IPF_Context_Current($request)
+{
+ return array('CURRENT_URL' => IPF_HTTP_URL::getAction());
+}