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; }
/** * Note, this queries both the pkgID found on the PermissionKeys table AND any permission keys of a special type * installed by that package, and any in categories by that package. */ public static function getListByPackage($pkg) { $db = Loader::db(); $kina[] = '-1'; $kinb = $db->GetCol('select pkCategoryID from PermissionKeyCategories where pkgID = ?', $pkg->getPackageID()); if (is_array($kinb)) { $kina = array_merge($kina, $kinb); } $kinstr = implode(',', $kina); $r = $db->Execute('select pkID, pkCategoryID from PermissionKeys where (pkgID = ? or pkCategoryID in (' . $kinstr . ')) order by pkID asc', array($pkg->getPackageID())); while ($row = $r->FetchRow()) { $pkc = PermissionKeyCategory::getByID($row['pkCategoryID']); $pk = $pkc->getPermissionKeyByID($row['pkID']); $list[] = $pk; } $r->Close(); return $list; }
public static function add($pkCategoryHandle, $pkg = false) { $db = Loader::db(); if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } $db->Execute('insert into PermissionKeyCategories (pkCategoryHandle, pkgID) values (?, ?)', array($pkCategoryHandle, $pkgID)); $id = $db->Insert_ID(); Cache::delete('permission_key_categories', false); return PermissionKeyCategory::getByID($id); }
/** * Adds an permission key. */ public function add($pkCategoryHandle, $pkHandle, $pkName, $pkDescription, $pkCanTriggerWorkflow, $pkHasCustomClass, $pkg = false) { $vn = Loader::helper('validation/numbers'); $txt = Loader::helper('text'); $pkgID = 0; $db = Loader::db(); if (is_object($pkg)) { $pkgID = $pkg->getPackageID(); } if ($pkCanTriggerWorkflow) { $pkCanTriggerWorkflow = 1; } else { $pkCanTriggerWorkflow = 0; } if ($pkHasCustomClass) { $pkHasCustomClass = 1; } else { $$pkHasCustomClass = 0; } $pkCategoryID = $db->GetOne("select pkCategoryID from PermissionKeyCategories where pkCategoryHandle = ?", $pkCategoryHandle); $a = array($pkHandle, $pkName, $pkDescription, $pkCategoryID, $pkCanTriggerWorkflow, $pkHasCustomClass, $pkgID); $r = $db->query("insert into PermissionKeys (pkHandle, pkName, pkDescription, pkCategoryID, pkCanTriggerWorkflow, pkHasCustomClass, pkgID) values (?, ?, ?, ?, ?, ?, ?)", $a); $category = PermissionKeyCategory::getByID($pkCategoryID); if ($r) { $pkID = $db->Insert_ID(); $ak = self::load($pkID); return $ak; } }