예제 #1
0
 /**
  * On enable set roles
  *
  * @param string $pluginid
  */
 public static function onEnable($pluginid)
 {
     $removeIds = array();
     foreach (RolePersistence::getAssignedPluginRoles($pluginid) as $role) {
         // Lets assume nobody changed root
         if ($role->roleid != 1) {
             // Add for delete
             $removeIds[] = $role->roleid;
         }
     }
     // Remove role assignment
     RolePersistence::deleteAssignedPluginRoles($pluginid, $removeIds);
 }
 /**
  *
  **/
 public static function onEnable($pluginId)
 {
     # TODO performance - use cache on success ?
     $role_persistence = new RolePersistence();
     $plugin_roles = $role_persistence->getAssignedPluginRoles($pluginId);
     $role_names = array_map(function ($role) {
         return $role->getRolename();
     }, $plugin_roles);
     if (!in_array('Nobody', $role_names)) {
         $message = _('Das OAuth-Plugin ist aktiviert, aber nicht für die Rolle "Nobody" freigegeben.');
         $details = array();
         $details[] = _('Dies behindert die Kommunikation externer Applikationen mit dem System.');
         $details[] = sprintf(_('Klicken Sie <a href="%s">hier</a>, um die Rollenzuweisung zu bearbeiten.'), URLHelper::getLink('dispatch.php/admin/role/assign_plugin_role/' . $pluginId));
         PageLayout::postMessage(Messagebox::info($message, $details));
     }
 }
예제 #3
0
 public function hosts_action()
 {
     //init
     LernmarktplatzHost::thisOne();
     $this->hosts = LernmarktplatzHost::findAll();
     foreach ($this->hosts as $host) {
         if (strpos($host['public_key'], "\r") !== false) {
             $host['public_key'] = str_replace("\r", "", $host['public_key']);
             $host->store();
         }
     }
     if (!function_exists("curl_init")) {
         PageLayout::postMessage(MessageBox::error(_("Ihr PHP hat kein aktiviertes cURL-Modul.")));
     }
     $plugin = PluginManager::getInstance()->getPluginInfo(get_class($this->plugin));
     $plugin_roles = RolePersistence::getAssignedPluginRoles($plugin['id']);
     $nobody_allowed = false;
     foreach ($plugin_roles as $role) {
         if (strtolower($role->rolename) === "nobody") {
             $nobody_allowed = true;
         }
     }
     if (!$nobody_allowed) {
         PageLayout::postMessage(MessageBox::error(_("Dieses Plugin ist nicht für nobody freigegeben. Damit kann sich dieser Marktplatz nicht mit anderen Stud.IP verbinden.")));
     }
     //zufällig einen Host nach Neuigkeiten fragen:
     if (count($this->hosts) > 1) {
         $index = rand(0, count($this->hosts) - 1);
         while ($this->hosts[$index]->isMe()) {
             $index++;
             if ($index >= count($this->hosts)) {
                 $index = 0;
             }
         }
         $this->askForHosts($this->hosts[$index]);
     }
 }
예제 #4
0
파일: role.php 프로젝트: ratbird/hope
 /**
  * Check role access permission for the given plugin.
  *
  * @param array     plugin meta data
  * @param integer   role id of role
  */
 private function check_role_access($plugin, $role_id)
 {
     $plugin_roles = RolePersistence::getAssignedPluginRoles($plugin['id']);
     foreach ($plugin_roles as $plugin_role) {
         if ($plugin_role->getRoleid() == $role_id) {
             return true;
         }
     }
     return false;
 }