本文整理汇总了PHP中TaskPermission类的典型用法代码示例。如果您正苦于以下问题:PHP TaskPermission类的具体用法?PHP TaskPermission怎么用?PHP TaskPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
if (Loader::helper('validation/token')->validate('save_permissions')) {
$fs = FileSet::getGlobal();
$tp = new TaskPermission();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('file_set');
foreach ($permissions as $pk) {
$pk->setPermissionObject($fs);
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
$this->redirect('/dashboard/system/permissions/files', 'updated');
}
} else {
$this->error->add(Loader::helper("validation/token")->getErrorMessage());
}
}
示例2: restore_backup
public function restore_backup()
{
$tp = new TaskPermission();
if (!$tp->canBackup()) {
return false;
}
$file = $this->post('backup_file');
$db = Loader::db();
chmod(DIR_FILES_BACKUPS . '/' . $file, 0666);
$str_restSql = file_get_contents(DIR_FILES_BACKUPS . '/' . $file);
if (!$str_restSql) {
$this->set("error", array("There was an error trying to restore the database. This file was empty."));
$this->view();
return false;
}
$crypt = Loader::helper('encryption');
if (!preg_match('/INSERT/m', $str_restSql) && !preg_match('/CREATE/m', $str_restSql)) {
$str_restSql = $crypt->decrypt($str_restSql);
}
$arr_sqlStmts = explode("\n\n", $str_restSql);
foreach ($arr_sqlStmts as $str_stmt) {
if (trim($str_stmt) != "") {
$res_restoration = $db->execute($str_stmt);
if (!$res_restoration) {
$this->set("error", array("There was an error trying to restore the database. In query {$str_stmt}"));
return;
}
}
}
$this->set("message", "Restoration Sucessful");
//reset perms for security!
chmod(DIR_FILES_BACKUPS . '/' . $file, 00);
Cache::flush();
$this->view();
}
示例3: prepare_remote_upgrade
public function prepare_remote_upgrade($remoteMPID = 0){
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
Loader::model('marketplace_remote_item');
$mri = MarketplaceRemoteItem::getByID($remoteMPID);
if (!is_object($mri)) {
$this->set('error', array(t('Invalid marketplace item ID.')));
return;
}
$local = Package::getbyHandle($mri->getHandle());
if (!is_object($local) || $local->isPackageInstalled() == false) {
$this->set('error', array(Package::E_PACKAGE_NOT_FOUND));
return;
}
$r = $mri->downloadUpdate();
if ($r != false) {
if (!is_array($r)) {
$this->set('error', array($r));
} else {
$errors = Package::mapError($r);
$this->set('error', $errors);
}
} else {
$this->redirect('/dashboard/extend/update', 'do_update', $mri->getHandle());
}
}
}
示例4: save
public function save()
{
if (Loader::helper('validation/token')->validate('save_permissions')) {
$tp = new TaskPermission();
if ($tp->canAccessTaskPermissions()) {
$permissions = PermissionKey::getList('sitemap');
$permissions = array_merge($permissions, PermissionKey::getList('marketplace_newsflow'));
$permissions = array_merge($permissions, PermissionKey::getList('admin'));
foreach ($permissions as $pk) {
$paID = $_POST['pkID'][$pk->getPermissionKeyID()];
$pt = $pk->getPermissionAssignmentObject();
$pt->clearPermissionAssignment();
if ($paID > 0) {
$pa = PermissionAccess::getByID($paID, $pk);
if (is_object($pa)) {
$pt->assignPermissionAccess($pa);
}
}
}
$this->redirect('/dashboard/system/permissions/tasks', 'updated');
}
} else {
$this->error->add(Loader::helper("validation/token")->getErrorMessage());
}
}
示例5: view
public function view()
{
$this->set('latest_version', Config::get('APP_VERSION_LATEST'));
$tp = new TaskPermission();
$updates = 0;
$local = array();
$remote = array();
if ($tp->canInstallPackages()) {
$local = Package::getLocalUpgradeablePackages();
$remote = Package::getRemotelyUpgradeablePackages();
}
// now we strip out any dupes for the total
$updates = 0;
$localHandles = array();
foreach ($local as $_pkg) {
$updates++;
$localHandles[] = $_pkg->getPackageHandle();
}
foreach ($remote as $_pkg) {
if (!in_array($_pkg->getPackageHandle(), $localHandles)) {
$updates++;
}
}
$this->set('updates', $updates);
}
示例6: view
public function view()
{
$this->set('latest_version', \Concrete\Core\Updater\Update::getLatestAvailableVersionNumber());
$tp = new \TaskPermission();
$updates = 0;
$local = array();
$remote = array();
if ($tp->canInstallPackages()) {
$local = Package::getLocalUpgradeablePackages();
$remote = Package::getRemotelyUpgradeablePackages();
}
// now we strip out any dupes for the total
$updates = 0;
$localHandles = array();
foreach ($local as $_pkg) {
$updates++;
$localHandles[] = $_pkg->getPackageHandle();
}
foreach ($remote as $_pkg) {
if (!in_array($_pkg->getPackageHandle(), $localHandles)) {
$updates++;
}
}
$this->set('updates', $updates);
}
示例7: connect_complete
public function connect_complete() {
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
if (!$_POST['csToken']) {
$this->set('error', array(t('An unexpected error occurred when connecting your site to the marketplace.')));
} else {
Config::save('MARKETPLACE_SITE_TOKEN', $_POST['csToken']);
Config::save('MARKETPLACE_SITE_URL_TOKEN', $_POST['csURLToken']);
print '<script type="text/javascript">parent.window.location.href=\'' . View::url('/dashboard/install', 'view', 'community_connect_success') . '\';</script>';
exit;
}
} else {
$this->set('error', array(t('You do not have permission to connect this site to the marketplace.')));
}
}
示例8: save
public function save($post)
{
// clear all selected permissions
$tps = array();
foreach ($post['tpID'] as $tpID) {
$tp = TaskPermission::getByID($tpID);
$tps[] = $tp;
$tp->clearPermissions();
}
foreach ($post['selectedEntity'] as $e) {
if ($e != '') {
$o1 = explode('_', $e);
if ($o1[0] == 'uID') {
$obj = UserInfo::getByID($o1[1]);
} else {
$obj = Group::getByID($o1[1]);
}
foreach ($tps as $tp) {
if ($post[$e . '_' . $tp->getTaskPermissionID()] == 1) {
$tp->addAccess($obj);
}
}
}
}
}
示例9: run
public function run()
{
$db = Loader::db();
$cnt = $db->GetOne('select count(*) from TaskPermissions where tpHandle = ?', array('delete_user'));
if ($cnt < 1) {
$g3 = Group::getByID(ADMIN_GROUP_ID);
$tip = TaskPermission::addTask('delete_user', t('Delete Users'), false);
if (is_object($g3)) {
$tip->addAccess($g3);
}
}
Loader::model('single_page');
$sp = Page::getByPath('/dashboard/settings/multilingual');
if ($sp->isError()) {
$d1a = SinglePage::add('/dashboard/settings/multilingual');
$d1a->update(array('cName' => t('Multilingual Setup')));
}
$sp = Page::getByPath('/dashboard/composer');
if ($sp->isError()) {
$d2 = SinglePage::add('/dashboard/composer');
$d2->update(array('cName' => t('Composer Beta'), 'cDescription' => t('Write for your site.')));
}
$sp = Page::getByPath('/dashboard/composer/write');
if ($sp->isError()) {
$d3 = SinglePage::add('/dashboard/composer/write');
}
$sp = Page::getByPath('/dashboard/composer/drafts');
if ($sp->isError()) {
$d4 = SinglePage::add('/dashboard/composer/drafts');
}
$sp = Page::getByPath('/dashboard/pages/types/composer');
if ($sp->isError()) {
$d5 = SinglePage::add('/dashboard/pages/types/composer');
}
}
示例10: save_task_permissions
public function save_task_permissions()
{
if (!$this->token->validate("update_permissions")) {
$this->set('error', array($this->token->getErrorMessage()));
return;
}
$tp = new TaskPermission();
if (!$tp->canAccessTaskPermissions()) {
$this->set('error', array(t('You do not have permission to modify these items.')));
return;
}
$post = $this->post();
$h = Loader::helper('concrete/dashboard/task_permissions');
$h->save($post);
$this->redirect('/dashboard/settings/', 'set_permissions', 'task_permissions_saved');
}
示例11: run
public function run()
{
$db = Loader::db();
$columns = $db->MetaColumns('Pages');
if (!isset($columns['CISSYSTEMPAGE'])) {
$db->Execute('alter table Pages add column cIsSystemPage tinyint(1) not null default 0');
$db->Execute('alter table Pages add index (cIsSystemPage)');
}
$columns = $db->MetaColumns('Pages');
if (!isset($columns['CISACTIVE'])) {
$db->Execute('alter table Pages add column cIsActive tinyint(1) not null default 1');
$db->Execute('alter table Pages add index (cIsActive)');
$db->Execute('update Pages set cIsActive = 1');
}
$columns = $db->MetaColumns('PageSearchIndex');
if (!isset($columns['CREQUIRESREINDEX'])) {
$db->Execute('alter table PageSearchIndex add column cRequiresReindex tinyint(1) not null default 0');
$db->Execute('alter table PageSearchIndex add index (cRequiresReindex)');
}
// install version job
Loader::model("job");
Job::installByHandle('remove_old_page_versions');
// flag system pages appropriately
Page::rescanSystemPages();
// add a newsflow task permission
$db = Loader::db();
$cnt = $db->GetOne('select count(*) from TaskPermissions where tpHandle = ?', array('view_newsflow'));
if ($cnt < 1) {
$g3 = Group::getByID(ADMIN_GROUP_ID);
$tip = TaskPermission::addTask('view_newsflow', t('View Newsflow'), false);
if (is_object($g3)) {
$tip->addAccess($g3);
}
}
// Install new block types
$this->installBlockTypes();
// install stacks, trash and drafts
$this->installSinglePages();
// move the old dashboard
$newDashPage = Page::getByPath('/dashboard/welcome');
if (!is_object($newDashPage) || $newDashPage->isError()) {
$dashboard = Page::getByPath('/dashboard');
$dashboard->moveToTrash();
// install new dashboard + page types
$this->installDashboard();
$this->migrateOldDashboard();
}
Loader::model('system/captcha/library');
$scl = SystemCaptchaLibrary::getByHandle('securimage');
if (!is_object($scl)) {
$scl = SystemCaptchaLibrary::add('securimage', t('SecurImage (Default)'));
$scl->activate();
}
Config::save('SEEN_INTRODUCTION', 1);
}
示例12: install
public function install($btHandle = null) {
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
try {
$resp = BlockType::installBlockType($btHandle);
if ($resp != '') {
$this->error->add($resp);
} else {
$this->set('message', t('Block Type Installed.'));
}
} catch(Exception $e) {
$this->error->add($e);
$this->set('error', $this->error);
}
} else {
$this->error->add(t('You do not have permission to install custom block types or add-ons.'));
$this->set('error', $this->error);
}
$this->view();
}
示例13: testForErrors
public function testForErrors() {
if ($this->object->isMasterCollection()) {
$canEditMaster = TaskPermission::getByHandle('access_page_defaults')->can();
if (!($canEditMaster && $_SESSION['mcEditID'] == $this->object->getCollectionID())) {
return COLLECTION_FORBIDDEN;
}
} else {
if ((!$this->canViewPage()) && (!$this->object->getCollectionPointerExternalLink() != '')) {
return COLLECTION_FORBIDDEN;
}
}
}
示例14: view
public function view()
{
$tp = new TaskPermission();
if ($tp->canBackup()) {
$fh = Loader::helper('file');
$arr_bckups = @$fh->getDirectoryContents(DIR_FILES_BACKUPS);
$arr_backupfileinfo = array();
if (count($arr_bckups) > 0) {
foreach ($arr_bckups as $bkupfile) {
// This will ignore files that do not match the created backup pattern of including a timestamp in the filename
if (preg_match("/_([\\d]{10,})/", $bkupfile, $timestamp)) {
$arr_backupfileinfo[] = array("file" => $bkupfile, "date" => date("Y-m-d H:i:s", $timestamp[1]));
}
}
// The whole reason this file's overriden - sort these backups chronologically
uasort($arr_backupfileinfo, function ($a, $b) {
return strcmp($b['date'], $a['date']);
});
$this->set('backups', $arr_backupfileinfo);
}
}
}
示例15: run
public function run()
{
$db = Loader::db();
$cnt = $db->GetOne('select count(*) from TaskPermissions where tpHandle = ?', array('install_packages'));
if ($cnt < 1) {
$g3 = Group::getByID(ADMIN_GROUP_ID);
$tip = TaskPermission::addTask('install_packages', t('Install Packages and Connect to the Marketplace'), false);
if (is_object($g3)) {
$tip->addAccess($g3);
}
}
// ensure we have a proper ocID
$db->Execute("alter table Files modify column ocID int unsigned not null default 0");
}