This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 
<?php

defined('C5_EXECUTE') or die("Access Denied.");

class Concrete5_Model_PermissionAssignment {

    protected $pk; // permissionkey
    protected $permissionObject;
    
    public function setPermissionObject($po) {
        $this->permissionObject = $po;
    }
    
    public function getPermissionObject() {
        return $this->permissionObject;
    }
    
    public function setPermissionKeyObject($pk) {
        $this->pk = $pk;
    }
    
    public function getPermissionKeyToolsURL($task = false) {
        if (!$task) {
            $task = 'save_permission';
        }
        $uh = Loader::helper('concrete/urls');
        $class = substr(get_class($this), 0, strrpos(get_class($this), 'PermissionAssignment'));
        $handle = Loader::helper('text')->uncamelcase($class);
        if ($handle) {
            $akc = PermissionKeyCategory::getByHandle($handle);
        } else {
            $akc = PermissionKeyCategory::getByID($this->pk->getPermissionKeyCategoryID());
        }
        $url = $uh->getToolsURL('permissions/categories/' . $akc->getPermissionKeyCategoryHandle(), $akc->getPackageHandle());
        $token = Loader::helper('validation/token')->getParameter($task);
        $url .= '?' . $token . '&task=' . $task . '&pkID=' . $this->pk->getPermissionKeyID();
        return $url;
    }
    
    public function clearPermissionAssignment() {
        $db = Loader::db();
        $db->Execute('update PermissionAssignments set paID = 0 where pkID = ?', array($this->pk->getPermissionKeyID()));
    }
    
    public function assignPermissionAccess(PermissionAccess $pa) {
        $db = Loader::db();
        $db->Replace('PermissionAssignments', array('paID' => $pa->getPermissionAccessID(), 'pkID' => $this->pk->getPermissionKeyID()), array('pkID'), true);
        $pa->markAsInUse();
    }

    public function getPermissionAccessObject() {
        $db = Loader::db();
        $paID = $db->GetOne('select paID from PermissionAssignments where pkID = ?', array($this->pk->getPermissionKeyID()));
        return PermissionAccess::getByID($paID, $this->pk);
    }
    
}