summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-04-25 11:40:40 +0200
committermichael pereira2011-04-25 11:40:40 +0200
commite2d929c54a0d951c9bae51df7df5178bf9f0066f (patch)
tree142a271540cb0467350c91d1818340b0b09c8b7f
parentauto-close removed, handled by fbgui now (diff)
downloadpbs2-e2d929c54a0d951c9bae51df7df5178bf9f0066f.tar.gz
pbs2-e2d929c54a0d951c9bae51df7df5178bf9f0066f.tar.xz
pbs2-e2d929c54a0d951c9bae51df7df5178bf9f0066f.zip
config fertig
-rw-r--r--application/controllers/ResourceController.php90
-rw-r--r--application/models/BootOsUserMapper.php146
-rw-r--r--application/models/Config.php1
-rw-r--r--application/models/ConfigMapper.php19
-rw-r--r--application/models/HomeTypeMapper.php12
-rw-r--r--application/models/Person.php10
-rw-r--r--application/models/PersonMapper.php6
-rw-r--r--application/modules/user/controllers/AuthController.php2
-rw-r--r--application/modules/user/controllers/BootmenuController.php16
-rw-r--r--application/modules/user/controllers/BootosController.php4
-rw-r--r--application/modules/user/controllers/ConfigController.php321
-rw-r--r--application/modules/user/forms/BootmenuEntries.php5
-rw-r--r--application/modules/user/forms/Bootos.php3
-rw-r--r--application/modules/user/forms/BootosUser.php161
-rw-r--r--application/modules/user/forms/Config.php24
-rw-r--r--application/modules/user/views/scripts/config/adduser.phtml4
-rw-r--r--application/modules/user/views/scripts/config/edituser.phtml4
-rw-r--r--application/modules/user/views/scripts/config/index.phtml129
-rw-r--r--application/modules/user/views/scripts/config/showconfig.phtml84
-rw-r--r--library/Pbs/NewConfig.php70
-rw-r--r--setup/pbs-newdata.sql8
-rw-r--r--setup/pbs.sql1
22 files changed, 979 insertions, 141 deletions
diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php
index 6344a6e..d48867a 100644
--- a/application/controllers/ResourceController.php
+++ b/application/controllers/ResourceController.php
@@ -53,13 +53,13 @@ class ResourceController extends Zend_Controller_Action
$bootmenuentry = new Application_Model_BootMenuEntries();
$bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper();
- $bootosMapper = new Application_Model_BootOsMapper();
+ $bootmenuMapper = new Application_Model_BootMenuMapper();
$bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry);
$session->setBootosID($bootmenuentry->getBootosID())
->setBootmenuentryID($bootmenuentry->getID())
->setTime(time())
- ->setMembershipID($bootosMapper->find($bootmenuentry->getBootosID())->getMembershipID())
+ ->setMembershipID($bootmenuMapper->find($bootmenuentry->getBootmenuID())->getMembershipID())
->setIp($_SERVER['REMOTE_ADDR'])
->setAlphasessionID('0');
@@ -126,7 +126,8 @@ class ResourceController extends Zend_Controller_Action
$bootos->setCreated(time());
$bootos->setPublic('-1');
$bootosID = $bootosMapper->save($bootos);
-
+ $bootos->setID($bootosID);
+
$initpath = "../resources/bootos/".$bootosID."/initramfs/";
$kernelpath = "../resources/bootos/".$bootosID."/kernel/";
$configpath = "../resources/bootos/".$bootosID."/config/";
@@ -137,12 +138,15 @@ class ResourceController extends Zend_Controller_Action
if($_FILES['config']['name'] != ''){
move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
+
}
- if($_FILES['config']['name'] != ''){
+ if($_FILES['kernel']['name'] != ''){
move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
}
- if($_FILES['config']['name'] != ''){
+ if($_FILES['init']['name'] != ''){
move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
+ $newconfig = new Pbs_NewConfig();
+ $newconfig->createDefaultConfig($bootos);
}
header('HTTP/1.0 201 Bootos created');
@@ -205,11 +209,11 @@ class ResourceController extends Zend_Controller_Action
$bootos->setSource($_SERVER['REMOTE_ADDR']);
move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
}
- if($_FILES['config']['name'] != ''){
+ if($_FILES['kernel']['name'] != ''){
$bootos->setSource($_SERVER['REMOTE_ADDR']);
move_uploaded_file($_FILES['kernel']['tmp_name'], $kernelpath."kernel");
}
- if($_FILES['config']['name'] != ''){
+ if($_FILES['init']['name'] != ''){
$bootos->setSource($_SERVER['REMOTE_ADDR']);
move_uploaded_file($_FILES['init']['tmp_name'], $initpath."initramfs");
}
@@ -381,40 +385,60 @@ class ResourceController extends Zend_Controller_Action
header('Pragma: no-cache');
header('Expires: 0');
- if($this->thisSession->getMembershipID() != null){
- if($configID == null)
- $configID = 'default';
- $path_userconf = "../resources/config/$bootosID/".$this->thisSession->getMembershipID()."/$configID/";
-
- if(!is_dir($path_userconf)){
-
+ if($configID == null){
+ chdir("../resources/bootos/$bootosID/config/");
+ passthru( "cat default.tgz");
+ }else{
+
+ $bootosuserMapper = new Application_Model_BootOsUserMapper();
+ $bootosuser = $bootosuserMapper->findBy(array('configID' => $configID));
+
+ $hash = md5(microtime(1));
+ $tmp_conf = "../resources/config/$hash";
+ mkdir($tmp_conf ,0777, true);
+ exec("tar -C $tmp_conf -xvf ../resources/bootos/$bootosID/config/default.tgz");
+ //exec("cp ../resources/config/loginfiles/* $path_userconf/rootfs/etc/");
+
+ if($this->thisSession->getMembershipID() != null){
$person = new Application_Model_Person();
$personMapper = new Application_Model_PersonMapper();
$membershipMapper = new Application_Model_MembershipMapper();
$personID = $membershipMapper->find($this->thisSession->getMembershipID())->getPersonID();
$person = $personMapper->find($personID);
- $loginname = strtolower($person->getName());
- $loginname = preg_replace("!\s!","",$loginname);
-
- mkdir($path_userconf ,0777, true);
- exec("tar -C $path_userconf -xvf ../resources/config/$configID/default.tgz");
- exec("cp ../resources/config/loginfiles/* $path_userconf/rootfs/etc/");
- exec("tar -C $path_userconf -xvf ../resources/config/$configID/default.tgz");
- exec("echo '$loginname:x:1000:1000:".$person->getName()." ".$person->getFirstname().",,,:/home/$loginname:/bin/bash' >> $path_userconf/rootfs/etc/passwd");
- exec("md5pass ".$person->getPassword(), $pwhash);
- // crypt(password, '$6$'.randomString(8).'$')
- exec("echo '$loginname:$pwhash[0]:0:0:99999:7:::' >> $path_userconf/rootfs/etc/shadow");
- exec("echo 'mkdir /home/$loginname' >> $path_userconf/initramfs/postinit.local");
+ $username = strtolower($person->getName());
+ $username = preg_replace("!\s!","",$username);
+ $userpassword = $person->getLoginPassword();
+ }
+
+ foreach($bootosuser as $user){
+ if($user->getLogin == '%username%'){
+ $loginname = $username;
+ }else{
+ $loginname = $user->getLogin();
+ }
+
+ if($user->getPassword == '%password%'){
+ $password = $userpassword;
+ }else{
+ $password = $user->getPassword();
+ }
+
+ if($user->getHometypeID() == 2){
+ $homepath = $user->getHomepath();
+ }elseif($user->getHometypeID() == 1){
+ $homepath = "/home/$loginname";
+ }else{
+ $homepath = "/home/$loginname";
+ }
+
+ exec("echo 'chroot /mnt useradd -d ".$homepath." -m -p '".$password."'".$loginname."' >> $tmp_conf/initramfs/postinit.local");
+
}
// create the gzipped tarfile.
- chdir($path_userconf);
+ chdir($tmp_conf);
passthru( "tar cz *");
- }else {
- if($configID == null)
- $configID = 'default';
- chdir("../resources/config/$configID/");
-
- passthru( "cat default.tgz");
+ exec("rm -rf $tmp_conf");
+
}
}else{
header('HTTP/1.0 404 Not Found');
diff --git a/application/models/BootOsUserMapper.php b/application/models/BootOsUserMapper.php
new file mode 100644
index 0000000..a50fd02
--- /dev/null
+++ b/application/models/BootOsUserMapper.php
@@ -0,0 +1,146 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Application_Model_BootOsUserMapper
+{
+
+ protected $_dbTable;
+
+ public function findBy($where, $array=false, $order=false)
+ {
+ foreach($where as $k => $v){
+ if($v != null)
+ $where2[] = "$k = '$v'";
+ else
+ $where2[] = "$k IS NULL";
+ }
+ $where = implode(" AND " ,$where2);
+
+ try{
+ $db = Zend_Db_Table::getDefaultAdapter();
+ $select = $this->getDbTable()->select()
+ ->from($this->_dbTable)
+ ->where($where);
+
+ if(is_array($order)){
+ foreach ($order as $k => $v)
+ $a[] = "$k $v";
+ $select->order($a);
+ }
+
+ $stmt = $select->query();
+ $result = $stmt->fetchAll();
+
+ if(!$array){
+ $entries = array();
+ foreach ($result as $row) {
+ $entry = new Application_Model_BootOsUser($row);
+ $entry->setID($row['bootosuserID']);
+ $entries[] = $entry;
+ }
+ return $entries;
+ }else{
+ return $result;
+ }
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ }
+
+ public function setDbTable($dbTable)
+ {
+ if (is_string($dbTable)) {
+ $dbTable = new $dbTable();
+ }
+
+ if (!$dbTable instanceof Zend_Db_Table_Abstract) {
+ throw new Exception('Invalid table data gateway provided');
+ }
+
+ $this->_dbTable = $dbTable;
+
+ return $this;
+ }
+
+ public function getDbTable()
+ {
+ if (null === $this->_dbTable) {
+ $this->setDbTable('Application_Model_DbTable_BootOsUser');
+ }
+
+ return $this->_dbTable;
+ }
+
+ public function save(Application_Model_BootOsUser $user)
+ {
+ $data = array('bootosuserID'=> $user->getID() ,'configID'=> $user->getConfigID() ,'login'=> $user->getLogin(), 'password'=> $user->getPassword(),'homepath'=> $user->getHomepath() ,'hometypeID'=> $user->getHometypeID());
+ if (null === ($id = $user->getID()) ) {
+ unset($data['bootosuserID']);
+ return $this->getDbTable()->insert($data);
+ } else {
+ $this->getDbTable()->update($data, array('bootosID = ?' => $id));
+ }
+ }
+
+ public function delete(Application_Model_BootOsUser $user)
+ {
+ if (null === ($id = $user->getID()) ) {
+ return;
+ } else {
+ $this->getDbTable()->delete(array('bootosuserID = ?' => $id));
+ }
+ }
+
+ public function find($id, Application_Model_BootOsUser $user = null)
+ {
+ $result = $this->getDbTable()->find($id);
+ if (0 == count($result)) {
+ return;
+ }
+
+ $row = $result->current();
+
+ if($user == null){
+ $user = new Application_Model_BootOsUser();
+ $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID);
+ return $user;
+ }else{
+ $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID);
+ }
+
+ }
+
+ public function fetchAll()
+ {
+ $resultSet = $this->getDbTable()->fetchAll();
+ $entries = array();
+ foreach ($resultSet as $row) {
+ $entry = new Application_Model_BootOsUser();
+
+ $user->setID($row->bootosuserID)->setconfigID($row->configID)->setLogin($row->login)->setPassword($row->password)->setHomepath($row->homepath)->setHometypeID($row->hometypeID);
+
+ $entries[$row->bootosuserID] = $entry;
+ }
+ return $entries;
+ }
+
+ public function compare(Application_Model_BootOsUser $v1,Application_Model_BootOsUser $v2){
+ $vv1 = $v1->toArray();
+ $vv2 = $v2->toArray();
+ return array_diff($vv1,$vv2);
+ }
+
+
+
+}
+
diff --git a/application/models/Config.php b/application/models/Config.php
index 3b609af..295f922 100644
--- a/application/models/Config.php
+++ b/application/models/Config.php
@@ -128,6 +128,7 @@ class Application_Model_Config
}
public function setBootosID($_bootosID)
{
+ $this->_bootosID = $_bootosID;
return $this;
}
diff --git a/application/models/ConfigMapper.php b/application/models/ConfigMapper.php
index 1fcbe45..f46bd72 100644
--- a/application/models/ConfigMapper.php
+++ b/application/models/ConfigMapper.php
@@ -87,7 +87,7 @@ class Application_Model_ConfigMapper
if (null === ($id = $config->getID()) ) {
unset($data['configID']);
- $this->getDbTable()->insert($data);
+ return $this->getDbTable()->insert($data);
} else {
$this->getDbTable()->update($data, array('configID = ?' => $id));
}
@@ -104,12 +104,7 @@ class Application_Model_ConfigMapper
public function find($id, Application_Model_Config $config = null)
{
- if($config == null){
- $return = true;
- }
- if($return){
- $config = new Application_Model_Config();
- }
+
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
@@ -117,10 +112,14 @@ class Application_Model_ConfigMapper
$row = $result->current();
- $config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
- if($return){
+ if($config == null){
+ $config = new Application_Model_Config();
+ $config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
return $config;
- }
+ }else{
+ $config->setID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setCreated($row->created)->setTitle($row->title)->setDescription($row->description)->setVisible($row->visible)->setBootosID($row->bootosID);
+ }
+
}
public function fetchAll()
diff --git a/application/models/HomeTypeMapper.php b/application/models/HomeTypeMapper.php
index 6bccceb..d795941 100644
--- a/application/models/HomeTypeMapper.php
+++ b/application/models/HomeTypeMapper.php
@@ -102,7 +102,7 @@ class Application_Model_HomeTypeMapper
}
}
- public function find($id, Application_Model_HomeType $hometype)
+ public function find($id, Application_Model_HomeType $hometype = null)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
@@ -111,8 +111,14 @@ class Application_Model_HomeTypeMapper
$row = $result->current();
- $hometype->setID($row->hometypeID)
- ->setName($row->name);
+ if($hometype == null){
+ $hometype = new Application_Model_HomeType();
+ $hometype->setID($row->hometypeID)->setName($row->name);
+ return $hometype;
+ }else{
+ $hometype->setID($row->hometypeID)->setName($row->name);
+ }
+
}
public function fetchAll()
diff --git a/application/models/Person.php b/application/models/Person.php
index 2312f65..4d4a000 100644
--- a/application/models/Person.php
+++ b/application/models/Person.php
@@ -26,6 +26,7 @@ class Application_Model_Person
protected $_login;
protected $_password;
protected $_password_salt;
+ protected $_loginpassword;
protected $_suspended;
public function __construct(array $options = null)
@@ -185,6 +186,15 @@ class Application_Model_Person
$this->_password = $_password;
return $this;
}
+ public function getLoginPassword()
+ {
+ return $this->_loginpassword;
+ }
+ public function setLoginPassword($_loginpassword)
+ {
+ $this->_loginpassword = $_loginpassword;
+ return $this;
+ }
public function setPasswordSalt($_password_salt)
{
$this->_password_salt = $_password_salt;
diff --git a/application/models/PersonMapper.php b/application/models/PersonMapper.php
index f073d07..c123bdc 100644
--- a/application/models/PersonMapper.php
+++ b/application/models/PersonMapper.php
@@ -84,7 +84,7 @@ class Application_Model_PersonMapper
public function save(Application_Model_Person $person)
{
- $data = array('personID'=> $person->getID() ,'title'=> $person->getTitle() ,'name'=> $person->getName() ,'firstname'=> $person->getFirstname() ,'street'=> $person->getStreet() ,'housenumber'=> $person->getHousenumber() ,'city'=> $person->getCity() ,'postalcode'=> $person->getPostalcode() ,'logindate'=> $person->getLogindate() ,'registerdate'=> $person->getRegisterdate() ,'email'=> $person->getEmail() ,'login'=> $person->getLogin() ,'password'=> $person->getPassword() ,'password_salt'=> $person->getPasswordSalt() ,'suspended'=> $person->getSuspended() );
+ $data = array('personID'=> $person->getID() ,'title'=> $person->getTitle() ,'name'=> $person->getName() ,'firstname'=> $person->getFirstname() ,'street'=> $person->getStreet() ,'housenumber'=> $person->getHousenumber() ,'city'=> $person->getCity() ,'postalcode'=> $person->getPostalcode() ,'logindate'=> $person->getLogindate() ,'registerdate'=> $person->getRegisterdate() ,'email'=> $person->getEmail() ,'login'=> $person->getLogin() ,'password'=> $person->getPassword(), 'loginpassword'=> $person->getLoginPassword() ,'password_salt'=> $person->getPasswordSalt() ,'suspended'=> $person->getSuspended() );
if (null === ($id = $person->getID()) ) {
unset($data['personID']);
@@ -120,7 +120,7 @@ class Application_Model_PersonMapper
$row = $result->current();
- $person->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended);
+ $person->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setLoginPassword($row->loginpassword)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended);
if($return){
return $person;
}
@@ -133,7 +133,7 @@ class Application_Model_PersonMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_Person();
- $entry->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended);
+ $entry->setID($row->personID)->setTitle($row->title)->setName($row->name)->setFirstname($row->firstname)->setStreet($row->street)->setHousenumber($row->housenumber)->setCity($row->city)->setPostalcode($row->postalcode)->setLogindate($row->logindate)->setRegisterdate($row->registerdate)->setEmail($row->email)->setLogin($row->login)->setPassword($row->password)->setLoginPassword($row->loginpassword)->setPasswordSalt($row->password_salt)->setSuspended($row->suspended);
$entries[] = $entry;
}
diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php
index 4a5bcf4..47aa029 100644
--- a/application/modules/user/controllers/AuthController.php
+++ b/application/modules/user/controllers/AuthController.php
@@ -107,6 +107,7 @@ class User_AuthController extends Zend_Controller_Action
$person->setRegisterdate($date->getTimestamp());
$person->setPasswordSalt(MD5($date->getTimestamp()));
$person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt()));
+ $person->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$'));
try {
$this->personmapper->save($person);
}catch(Zend_Exception $e)
@@ -179,6 +180,7 @@ class User_AuthController extends Zend_Controller_Action
$person->setPassword($_POST['password']);
$person->setPasswordSalt(MD5($date->getTimestamp()));
$person->setPassword(MD5($person->getPassword() . $person->getPasswordSalt()));
+ $person->setLoginPassword(crypt($person->getPassword(), '$6$'.randomString(8).'$'));
try {
$this->personmapper->save($person);
} catch(Zend_Exception $e)
diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php
index e0b27e6..1b0490c 100644
--- a/application/modules/user/controllers/BootmenuController.php
+++ b/application/modules/user/controllers/BootmenuController.php
@@ -325,6 +325,8 @@ class user_BootmenuController extends Zend_Controller_Action
$bootoslist = array();
$parents = $groupgroupsMapper->getParentGroups($groupID);
+ $configlist = array('Preset' => array(), 'Custom' => Array());
+
foreach($parents as $k => $parent){
foreach($parent as $p){
$bootos = $bootosMapper->findBy(array("groupID" => $p));
@@ -333,13 +335,14 @@ class user_BootmenuController extends Zend_Controller_Action
$grouptitle = $groupMapper->find($p)->getTitle();
$bootoslist[$b->getID()] = $b;
$bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle();
+ $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('groupID' => $groupID, 'bootosID' => $b->getID(), 'visible' => '1'));
+ $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1'));
}
}
}
- $configlist = array('Preset' => array(), 'Custom' => Array());
- $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID));
- $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID()));
+
+
$bootmenu = new Application_Model_BootMenu();
$this->bootmenuMapper->find($bootmenuID, $bootmenu);
@@ -444,13 +447,12 @@ class user_BootmenuController extends Zend_Controller_Action
$grouptitle = $groupMapper->find($p)->getTitle();
$bootoslist[$b->getID()] = $b;
$bootosanzeige[$grouptitle][$b->getID()] = $b->getTitle();
+ $configlist['Preset'][$b->getID()] = $configMapper->findBy(array('groupID' => $groupID, 'bootosID' => $b->getID(), 'visible' => '1'));
+ $configlist['Custom'][$b->getID()] = $configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $b->getID(), 'visible' => '1'));
+
}
}
}
-
- $configlist = array('Preset' => array(), 'Custom' => Array());
- $configlist['Preset'] = $configMapper->findBy(array('groupID' => $groupID));
- $configlist['Custom'] = $configMapper->findBy(array('membershipID' => $this->membership->getID()));
$bootmenuentry = new Application_Model_BootMenuEntries();
$bootmenu = new Application_Model_BootMenu();
diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php
index 92dcc5f..9bc6a69 100644
--- a/application/modules/user/controllers/BootosController.php
+++ b/application/modules/user/controllers/BootosController.php
@@ -86,7 +86,6 @@ class user_BootosController extends Zend_Controller_Action
$this->view->bootoslist = array_reverse($this->view->bootoslist);
- $update = $this->_request->getParam('checkupdate');
$groupMapper = new Application_Model_GroupMapper();
if(count($this->view->bootoslist)>0){
@@ -161,6 +160,7 @@ class user_BootosController extends Zend_Controller_Action
try {
$bootosID = $this->bootosMapper->save($bootos);
+ $bootos->setID($bootosID);
if( $_FILES['kernel']['size'] == 0 && $_FILES['kernel']['name'] != '' ||
$_FILES['init']['size'] == 0 && $_FILES['init']['name'] != '' ||
@@ -184,6 +184,8 @@ class user_BootosController extends Zend_Controller_Action
}
if($_FILES['config']['name'] != ''){
move_uploaded_file($_FILES['config']['tmp_name'], $configpath."default.tgz");
+ $newconfig = new Pbs_NewConfig();
+ $newconfig->createDefaultConfig($bootos);
}
diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php
index aba51f7..6acb697 100644
--- a/application/modules/user/controllers/ConfigController.php
+++ b/application/modules/user/controllers/ConfigController.php
@@ -14,6 +14,10 @@ class user_ConfigController extends Zend_Controller_Action
{
protected $configMapper;
+ protected $bootosMapper;
+ protected $bootosuserMapper;
+ protected $bootmenuMapper;
+ protected $bootmenuentriesMapper;
protected $membershipMapper;
protected $membership;
protected $page;
@@ -29,7 +33,7 @@ class user_ConfigController extends Zend_Controller_Action
}
$this->configMapper = new Application_Model_ConfigMapper();
-
+ $this->bootosuserMapper = new Application_Model_BootOsUserMapper();
$this->membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
$this->membershipMapper->find($userIDsNamespace['membershipID'],$this->membership);
@@ -66,20 +70,76 @@ class user_ConfigController extends Zend_Controller_Action
//ACL Darf er Configs sehen?
if(!Pbs_Acl::checkRight('csai') && !Pbs_Acl::checkRight('csui'))
$this->_redirect('/user/index');
-
+
$this->configMapper = new Application_Model_ConfigMapper();
-
+ $this->bootosMapper = new Application_Model_BootOsMapper();
+ $this->bootmenuMapper = new Application_Model_BootMenuMapper();
+ $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
+ $groupMapper = new Application_Model_GroupMapper();
+ $this->view->bootoslist = array();
+ $this->view->configlist = array();
+
if($this->type =='own' && Pbs_Acl::checkRight('csui')){
$this->view->type = 'own';
- $this->view->configlist = $this->configMapper->findBy(array('membershipID' => $this->membership->getID()));
+ $bootmenu = $this->bootmenuMapper->findBy(array('membershipID' => $this->membership->getID()));
+ if($bootmenu != null){
+ $bootmenuID = $bootmenu[0]->getID();
+ $bootmenuentries = $this->bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID));
+ foreach ($bootmenuentries as $bootmenuentry){
+ $bootos = $this->bootosMapper->find($bootmenuentry->getBootosID());
+ $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle());
+ $this->view->bootoslist[$bootos->getID()] = $bootos;
+ $this->view->configlist[$bootos->getID()] = $this->configMapper->findBy(array('membershipID' => $this->membership->getID(), 'bootosID' => $bootos->getID()));
+ foreach ($this->view->configlist[$bootos->getID()] as $config){
+ $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated()));
+ }
+ }
+ }
}else{
+ $groupgroupsMapper = new Application_Model_GroupGroupsMapper();
+
+ $parents = array();
+ $parents = $groupgroupsMapper->getParentGroups($groupID);
+
+ foreach($parents as $k => $parent){
+ foreach($parent as $p){
+ $bootos = $this->bootosMapper->findBy(array("groupID" => $p));
+ foreach ($bootos as $b)
+ if($b->getPublic() - $k >= 0 ){
+ $this->view->bootoslist[] = $b;
+ if(Pbs_Acl::checkRight('cc'))
+ $this->view->configlist[$b->getID()] = $this->configMapper->findBy(array('membershipID' => null, 'bootosID' => $b->getID()));
+ else
+ $this->view->configlist[$b->getID()] = $this->configMapper->findBy(array('membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1'));
+ foreach ($this->view->configlist[$b->getID()] as $config){
+ $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated()));
+ }
+ }
+ elseif($k == 0 && $b->getPublic() == -1 && Pbs_Acl::checkRight('boc')){
+ $this->view->bootoslist[] = $b;
+ if(Pbs_Acl::checkRight('cc'))
+ $this->view->configlist[$b->getID()] = $this->configMapper->findBy(array('membershipID' => null, 'bootosID' => $b->getID()));
+ else
+ $this->view->configlist[$b->getID()] = $this->configMapper->findBy(array('membershipID' => null, 'bootosID' => $b->getID(), 'visible' => '1'));
+ foreach ($this->view->configlist[$b->getID()] as $config){
+ $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated()));
+ }
+ }
+ }
+ }
+
+ $this->view->bootoslist = array_reverse($this->view->bootoslist);
+
+ if(count($this->view->bootoslist)>0){
+ foreach ($this->view->bootoslist as $bootos){
+ $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle());
+ }
+ }
$this->view->type = 'group';
- $this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID()));
+ //$this->view->configlist = $this->configMapper->findBy(array('groupID' => $this->membership->getGroupID()));
}
- foreach ($this->view->configlist as $config){
- $config->setCreated(date(Zend_Registry::get('dateformat'),$config->getCreated()));
- }
+ //print_a($this->view->configlist);
// Search
$search = $this->_request->getParam('search');
@@ -89,17 +149,18 @@ class user_ConfigController extends Zend_Controller_Action
$mySearch->setModule('config');
if($search != ''){
$this->view->search = $mySearch->getSearchTerm();
- $this->view->configlist = $mySearch->search($this->view->configlist);
+ $this->view->configlist = $mySearch->search($this->view->configlist
+ );
}
$this->view->searchform = $mySearch->searchForm();
// Pagination
$pagination = new Pbs_Pagination();
$pagination->setPerPage(10);
- $pagination->setElement($this->view->configlist);
+ $pagination->setElement($this->view->bootoslist);
$pagination->setRequestPage($this->_request->getParam('page'));
$pagination->setPageUrl('/user/config/index/type/'.$this->type.((isset($this->view->search))?'/search/'.$this->view->search:''));
- $this->view->configlist = $pagination->getElements();
+ $this->view->bootoslist = $pagination->getElements();
$this->view->pagination = $pagination->pagination();
$this->view->page = $pagination->getRequestPage();
@@ -114,8 +175,13 @@ class user_ConfigController extends Zend_Controller_Action
{
//ACL Darf er Configs erstellen?
if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco'))
- $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden');
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/forbidden');
+ $bootosID = $this->_request->getParam('bootosID');
+
+ if (!is_numeric($bootosID))
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error');
+
if (!isset($_POST["createconfig"])){
$configForm = new user_Form_Config(array('action' => 'createconfig','page'=>$this->page, 'type'=>$this->type));
} else {
@@ -125,13 +191,17 @@ class user_ConfigController extends Zend_Controller_Action
$config = new Application_Model_Config($_POST);
$config->setCreated(time());
+ $config->setBootosID($bootosID);
- if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group')
- $config->setGroupID($this->membership->getGroupID());
- elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own')
- $config->setMembershipID($this->membership->getID());
+ if(Pbs_Acl::checkRight('cc') && $this->_request->getParam('type') == 'group'){
+ $config->setGroupID($this->membership->getGroupID());
+ }
+ elseif(Pbs_Acl::checkRight('cco') && $this->_request->getParam('type') == 'own'){
+ $config->setVisible('1');
+ $config->setMembershipID($this->membership->getID());
+ }
else
- $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error');
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/addresult/error');
try {
$this->configMapper->save($config);
@@ -148,16 +218,213 @@ class user_ConfigController extends Zend_Controller_Action
$this->view->configForm = $configForm;
}
- public function addUserAction(){
+ public function showconfigAction(){
+
+ $result = $this->_request->getParam('addresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('create',$result);
+ }
+ $result = $this->_request->getParam('deleteresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('delete',$result);
+ }
+ $result = $this->_request->getParam('modifyresult');
+ if($result != ""){
+ $pbsNotifier = new Pbs_Notifier();
+ $this->view->notification = $pbsNotifier->notify('modify',$result);
+ }
+
+ $configID = $this->_request->getParam('configID');
+ if (!is_numeric($configID))
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error');
+
+ $groupID = $this->membership->getGroupID();
+
+ $config = new Application_Model_Config();
+ $this->configMapper->find($configID, $config);
+ if($config->getMembershipID() != null){
+ if($this->membership->getID() != $config->getMembershipID() || (!Pbs_Acl::checkRight('csui') && !Pbs_Acl::checkRight('csui')))
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden');
+ }else{
+ if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('csui') && !Pbs_Acl::checkRight('csai')))
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden');
+ }
+
+ $hometypeMapper = new Application_Model_HomeTypeMapper();
+
+ $this->view->configID = $configID;
+ $this->view->type = $this->_request->getParam('type');
+ $this->view->config = $this->configMapper->find($configID)->getTitle();
+ $this->view->userlist = $this->bootosuserMapper->findBy(array('configID' => $configID));
+ foreach($this->view->userlist as $user){
+ $user->setHometypeID("[".$user->getHometypeID()."] ".$hometypeMapper->find($user->getHometypeID())->getName());
+ }
}
+ public function adduserAction(){
+ $configID = $this->_request->getParam('configID');
+ if (!is_numeric($configID))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error');
+ //ACL Darf er User adden?
+ if(!Pbs_Acl::checkRight('cc') && !Pbs_Acl::checkRight('cco'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/forbidden');
+
+ $hometypeMapper = new Application_Model_HomeTypeMapper();
+ $hometype = $hometypeMapper->fetchAll();
+
+ if (!isset($_POST["addbootosuser"])){
+ $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST);
+ } else {
+ $bootosuserForm = new user_Form_BootosUser(array('action' => 'addbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST);
+
+ if ($bootosuserForm->isValid($_POST)) {
+
+ $bootosuser = new Application_Model_BootOsUser($_POST);
+ $bootosuser->setConfigID($configID);
+ $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath()));
+ if($bootosuser->getPassword() != '%password%')
+ $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$'));
+
+ try {
+ $this->bootosuserMapper->save($bootosuser);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/error');
+ }
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/addresult/ok');
+ }
+ }
+
+ $this->view->bootosuserForm = $bootosuserForm;
+ }
+
+
+ public function edituserAction(){
+ //ACL Darf er Configs editieren?
+ if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden');
+
+ $configID = $this->_request->getParam('configID');
+ $bootosuserID = $this->_request->getParam('bootosuserID');
+
+ if (!is_numeric($configID) || !is_numeric($bootosuserID))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error');
+
+ $groupID = $this->membership->getGroupID();
+
+ $bootosuser = new Application_Model_BootOsUser();
+ $this->bootosuserMapper->find($bootosuserID,$bootosuser);
+
+ $config = new Application_Model_Config();
+ $this->configMapper->find($configID, $config);
+
+ $hometypeMapper = new Application_Model_HomeTypeMapper();
+ $hometype = $hometypeMapper->fetchAll();
+
+ if($config->getMembershipID() != null){
+ if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('ceo'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden');
+ }else{
+ if($this->membership->getGroupID() != $config->getGroupID() || (!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem')))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden');
+ }
+
+ if (!isset($_POST["editbootosuser"])){
+ if(!isset($_POST['homepath'])){
+ $_POST['login'] = $bootosuser->getLogin();
+ $_POST['hometypeID'] = $bootosuser->getHometypeID();
+
+ }
+
+ $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST);
+
+ if(!isset($_POST['homepath']) && $bootosuser->getHometypeID() == '2')
+ $bootosuserForm->populate(array('homepath' => $bootosuser->getHomepath()));
+ }else{
+ $bootosuserForm = new user_Form_BootosUser(array('action' => 'editbootosuser', 'type'=>$this->type, 'configID' => $configID, 'hometype' => $hometype),$_POST);
+
+ if ($bootosuserForm->isValid($_POST)) {
+
+ $bootosuserold = $bootosuser;
+
+ $bootosuser = new Application_Model_BootOsUser($_POST);
+
+ if($bootosuserold->getHometypeID() != $bootosuser->getHometypeID() ||
+ $bootosuserold->getHomepath() != $bootosuser->getHomepath()){
+ //ACL Is he allowed to edit other than Metadata?
+ if(!Pbs_Acl::checkRight('ce'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/forbidden');
+ }
+
+ $bootosuser->setHomepath(str_replace("%login-name%", $bootosuser->getLogin(), $bootosuser->getHomepath()));
+ if($bootosuser->getPassword() != '%password%')
+ $bootosuser->setPassword(crypt($bootosuser->getPassword(), '$6$'.randomString(8).'$'));
+
+ try {
+ $this->bootosuserMapper->save($bootosuser);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/error');
+ }
+
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/modifyresult/ok');
+ }
+
+ }
+
+ $this->view->bootosuserForm = $bootosuserForm;
+ }
+
+ public function deleteuserAction(){
+
+ $configID = $this->_request->getParam('configID');
+ $bootosuserID = $this->_request->getParam('bootosuserID');
+ if (!is_numeric($configID) || !is_numeric($bootosuserID))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error');
+ //ACL Darf er User löschen?
+ if(!Pbs_Acl::checkRight('cd') && !Pbs_Acl::checkRight('cdo'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden');
+
+ try{
+ $bootosuser = new Application_Model_BootOsUser();
+ $this->bootosuserMapper->find($bootosuserID,$bootosuser);
+
+ $config = new Application_Model_Config();
+ $this->configMapper->find($configID,$config);
+
+ if($config->getMembershipID() != null){
+ if($this->membership->getID() != $config->getMembershipID() || !Pbs_Acl::checkRight('cdo'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden');
+ }else{
+ if($this->membership->getGroupID() != $config->getGroupID() || !Pbs_Acl::checkRight('cd'))
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/forbidden');
+ }
+
+ $this->bootosuserMapper->delete($bootosuser);
+
+ }catch(Zend_Exception $e){
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/error');
+ }
+ $this->_redirect('/user/config/showconfig/type/'.$this->type.'/configID/'.$configID.'/deleteresult/ok');
+ }
+
+
+
public function editconfigAction()
{
//ACL Darf er Configs editieren?
if(!Pbs_Acl::checkRight('ce') && !Pbs_Acl::checkRight('cem') && !Pbs_Acl::checkRight('ceo'))
$this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden');
-
+
$configID = $this->_request->getParam('configID');
if (!is_numeric($configID))
$this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error');
@@ -189,17 +456,21 @@ class user_ConfigController extends Zend_Controller_Action
$config = new Application_Model_Config($_POST);
$config->setCreated(time());
+ $config->setBootosID($configold->getBootosID());
- if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null)
- $config->setGroupID($this->membership->getGroupID());
- elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null)
- $config->setMembershipID($this->membership->getID());
+ if(Pbs_Acl::checkRight('ce') && $configold->getGroupID() != null){
+ $config->setGroupID($this->membership->getGroupID());
+ }
+ elseif(Pbs_Acl::checkRight('ceo') && $configold->getMembershipID() != null){
+ $config->setVisible($configold->getVisible());
+ $config->setMembershipID($this->membership->getID());
+ }
else
- $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error');
+ $this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/error');
$config->setID($configID);
- if($configold->getShellscript() != $config->getShellscript()){
+ if($configold->getVisible() != $config->getVisible()){
//ACL Is he allowed to edit other than Metadata?
if(!Pbs_Acl::checkRight('ce'))
$this->_redirect('/user/config/index/type/'.$this->type.'/page/'.$this->page.'/modifyresult/forbidden');
diff --git a/application/modules/user/forms/BootmenuEntries.php b/application/modules/user/forms/BootmenuEntries.php
index 1177d1c..93e3206 100644
--- a/application/modules/user/forms/BootmenuEntries.php
+++ b/application/modules/user/forms/BootmenuEntries.php
@@ -130,12 +130,11 @@ class user_Form_BootmenuEntries extends Zend_Form
$configfield->setLabel('Config:');
$configfield->setAttrib('readOnly', $meta);
- $options = array('Preset' => array('default' => 'default'), 'Custom' => array());
+ $options = array('Preset' => array(), 'Custom' => array());
if(count($this->configlist)>0){
foreach($this->configlist as $k => $v){
- foreach($v as $c)
- //if($c->getID() != $defaultconfigid)
+ foreach($v[$_POST['bootosID']] as $c)
$options[$k][$c->getID()] = $c->getTitle();
}
}
diff --git a/application/modules/user/forms/Bootos.php b/application/modules/user/forms/Bootos.php
index c4b1c70..5e20a8a 100644
--- a/application/modules/user/forms/Bootos.php
+++ b/application/modules/user/forms/Bootos.php
@@ -121,20 +121,17 @@ class user_Form_Bootos extends Zend_Form
));
$this->addElement('file', 'kernel', array(
- 'required' => $filereq,
'readOnly' => $meta,
'label' => 'Kernel:',
));
$this->addElement('file', 'init', array(
- 'required' => $filereq,
'readOnly' => $meta,
'label' => 'Initramfs:',
));
$this->addElement('file', 'config', array(
'validators' => array(array('Extension', false, array('tgz'))),
- 'required' => $filereq,
'readOnly' => $meta,
'label' => 'Config:',
));
diff --git a/application/modules/user/forms/BootosUser.php b/application/modules/user/forms/BootosUser.php
new file mode 100644
index 0000000..d5700d5
--- /dev/null
+++ b/application/modules/user/forms/BootosUser.php
@@ -0,0 +1,161 @@
+ <?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class user_Form_BootosUser extends Zend_Form
+{
+
+ private $action;
+ private $type;
+ private $configID;
+ private $hometype;
+
+ public function setAction($action){
+ $this->action = $action;
+ }
+ public function setType($type){
+ $this->type = $type;
+ }
+ public function setConfigID($configID){
+ $this->configID = $configID;
+ }
+ public function setHometype($hometype){
+ $this->hometype = $hometype;
+ }
+
+
+ public function init()
+ {
+ $this->setName($this->action);
+ $this->setMethod('post');
+
+ if (!Pbs_Acl::checkRight('ce') && $this->action == 'editbootosuser')
+ $meta = true;
+ else
+ $meta = null;
+
+ if(!isset($_POST['hometypeID'])){
+ $_POST['hometypeID'] = '0';
+ }
+
+ $this->addElement('text', 'login', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Login-Name:',
+ 'value' => $_POST['login'],
+ 'description' => 'Tip: Use %username% as a Wildcard'
+ ));
+
+ $this->addElement('password', 'password', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(6)),
+ ),
+ 'required' => true,
+ 'label' => 'Password:',
+ 'errorMessages' => array('Please enter a password with more than 6 characters')
+ ));
+
+ $this->addElement('password', 'repeat_password', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(6)),
+ ),
+ 'required' => true,
+ 'label' => 'Repeat Password:',
+ 'errorMessages' => array('Please repeat the password correctly'),
+ 'description' => 'Tip: Use %password% as a Wildcard'
+ ));
+
+
+
+ $hometypefield = $this->createElement('select','hometypeID');
+ $hometypefield->setLabel('Hometype:');
+ $hometypefield->setAttrib('readOnly', $meta);
+ $hometypefield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();");
+ $hometypefield->setValue($_POST['hometypeID']);
+ foreach($this->hometype as $k => $ht){
+ $hometypefield->addMultiOption($ht->getID(), $ht->getName());
+ }
+
+ $this->addElement($hometypefield);
+
+ if($_POST['hometypeID'] == 0){
+ $this->addElement('text', 'homepath', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Home-Path:',
+ 'size' => '30',
+ 'readOnly' => true,
+ 'value' => '/home/%login-name%'
+ ));
+ }elseif($_POST['hometypeID'] == 1){
+ $this->addElement('text', 'homepath', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Home-Path:',
+ 'size' => '30',
+ 'readOnly' => true,
+ 'value' => 'usbstick://home/%login-name%'
+ ));
+ }else{
+ $this->addElement('text', 'homepath', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'size' => '30',
+ 'required' => true,
+ 'label' => 'Home-Path:',
+ 'readOnly' => $meta
+ ));
+ }
+
+ if($this->action == "addbootosuser")
+ $label = "Add User";
+ else
+ $label = "Edit User";
+
+ $this->addElement('submit', $this->action, array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => $label
+ ));
+
+ $this->addElement('button', 'Cancel', array(
+ 'onclick' => 'self.location="/user/config/showconfig/type/'.$this->type.'/configID/'.$this->configID.'"'
+ ));
+
+
+ $pbsNotifier = new Pbs_Notifier();
+ echo $pbsNotifier->notify('Use <b>%username%</b> and <b>%password%</b> as Wildcards for Login and Password.','info');
+ }
+
+ public function isValid($data)
+ {
+ $this->getElement('repeat_password')->
+ addValidator(new Zend_Validate_Identical($data['password']));
+
+ return parent::isValid($data);
+ }
+
+}
+?>
+
diff --git a/application/modules/user/forms/Config.php b/application/modules/user/forms/Config.php
index 53e260d..3b961b9 100644
--- a/application/modules/user/forms/Config.php
+++ b/application/modules/user/forms/Config.php
@@ -1,4 +1,4 @@
-<?php
+ <?php
/*
* Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
* This program is free software distributed under the GPL version 2.
@@ -26,6 +26,7 @@ class user_Form_Config extends Zend_Form
public function setType($type){
$this->type = $type;
}
+
public function init()
{
$this->setName($this->action);
@@ -45,18 +46,23 @@ class user_Form_Config extends Zend_Form
'label' => 'Title:',
));
-
- $this->addElement('textarea', 'shellscript', array(
+ $this->addElement('textarea', 'description', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 50)),
),
- 'required' => true,
- 'rows' => 10,
- 'cols' => 70,
- 'readOnly' => $meta,
- 'label' => 'Shellscript:',
- ));
+ 'required' => false,
+ 'rows' => 5,
+ 'cols' => 50,
+ 'label' => 'Description:',
+ ));
+
+ if($this->type == 'group'){
+ $visible = $this->createElement('checkbox','visible');
+ $visible->setLabel('Visible:');
+ $visible->setAttrib('readOnly', $meta);
+ $this->addElement($visible);
+ }
if($this->action == "createconfig")
$label = "Create Config";
diff --git a/application/modules/user/views/scripts/config/adduser.phtml b/application/modules/user/views/scripts/config/adduser.phtml
new file mode 100644
index 0000000..2dc2691
--- /dev/null
+++ b/application/modules/user/views/scripts/config/adduser.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->bootosuserForm;
+echo $this->bootosuserForm;
+?>
diff --git a/application/modules/user/views/scripts/config/edituser.phtml b/application/modules/user/views/scripts/config/edituser.phtml
new file mode 100644
index 0000000..2dc2691
--- /dev/null
+++ b/application/modules/user/views/scripts/config/edituser.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->bootosuserForm;
+echo $this->bootosuserForm;
+?>
diff --git a/application/modules/user/views/scripts/config/index.phtml b/application/modules/user/views/scripts/config/index.phtml
index 9bdf185..37f5a9f 100644
--- a/application/modules/user/views/scripts/config/index.phtml
+++ b/application/modules/user/views/scripts/config/index.phtml
@@ -9,12 +9,6 @@
<?php $conflabel = $this->type == 'own'?'group':'own';?>
-<?php if((Pbs_Acl::checkRight('cc') && $this->type == 'group') || (Pbs_Acl::checkRight('cco') && $this->type == 'own')): ?>
-<?php echo $this->formButton('createconfig', 'Create Config', array(
- 'onclick' => 'self.location="/user/config/createconfig/type/'.$this->type.'/page/'.$this->page.'"',
- 'class' => 'addbutton'))?>
-<?php endif;?>
-
<?php if(Pbs_Acl::checkRight('csui')): ?>
<?php echo $this->formButton('ownconfig', 'Show '.$conflabel.' configs', array(
'onclick' => 'self.location="/user/config/index/type/'.$conflabel.'/page/'.$this->page.'"',
@@ -25,63 +19,118 @@
<div class='head'>Available searchfilter:</div>
<?php if(Pbs_Acl::checkRight('csai')): ?>
<div class='code'>configID</div>
+ <div class='code'>visible</div>
<?php endif; ?>
+ <div class='code'>description</div>
<div class='code'>title</div>
- <div class='code'>shellscript</div>
<div class='code'>created</div>
</div>
<div class='listelement'>
- <?php if(count($this->configlist)==0)
- echo "There are no Config's to display." ?>
- <?php foreach ($this->configlist as $k => $config): ?>
+ <?php if(count($this->bootoslist)==0)
+ echo "There are no BootOs's to display." ?>
+ <?php foreach ($this->bootoslist as $k => $bootos): ?>
+ <?php if($bootos->getPublic() != -1 || Pbs_Acl::checkRight('boai'))?>
<div class='element'>
<div class='number'>
- <div class='smallnumber'>Config</div>
- <?php echo $k+1; ?>
+ <div class='smallnumber'>BootOs</div>
+ <?php echo $k ?>
</div>
- <div class='content'>
- <div class='actions'>
- <?php if(((Pbs_Acl::checkRight('ce') || Pbs_Acl::checkRight('cem')) && $this->type == 'group') || ($this->type == 'own' && Pbs_Acl::checkRight('ceo'))): ?>
- <a href="<?php echo $this->url(
+ <div class='content'>
+ <div class='actions'>
+ <?php if((Pbs_Acl::checkRight('cc') && $this->type == 'group') || (Pbs_Acl::checkRight('cco') && $this->type == 'own')): ?>
+ <a href="<?php echo $this->url(
array(
'module' => 'user',
'controller' => 'config',
- 'action' => 'editconfig',
+ 'action' => 'createconfig',
'type' => $this->type,
- 'configID' => $config->getID(),
+ 'bootosID' => $bootos->getID(),
'page' => $this->page
),
'default',
- true, false) ?>"><img src='/media/img/edit.png' alt='Edit Config'/></a>
+ true, false) ?>"><img src='/media/img/add.png' alt='Add Config'/></a>
<?php endif; ?>
- <?php if((Pbs_Acl::checkRight('cd') && $this->type == 'group') || ($this->type == 'own' && Pbs_Acl::checkRight('cdo'))): ?>
- <a href="<?php echo $this->url(
- array(
- 'module' => 'user',
- 'controller' => 'config',
- 'action' => 'deleteconfig',
- 'type' => $this->type,
- 'configID' => $config->getID(),
- 'page' => $this->page
- ),
- 'default',
- true) ?>"><img src='/media/img/delete.png' alt='Delete Config'/></a>
- <?php endif; ?>
- </div>
- <div class='title'><?php echo $this->escape($config->getTitle()); ?></div>
+ </div>
+ <?php if(!Pbs_Acl::checkRight('boai')){
+ $bootos->setGroupID(preg_replace("!^\[[0-9]+\]\s!",'',$bootos->getGroupID()));
+ } ?>
+
+ <?php ?>
+ <div class='title'><?php echo $this->escape($bootos->getTitle()); ?></div>
+ <div class='subtitle'><?php echo $this->escape($bootos->getGroupID()); ?> - <?php echo $this->escape($bootos->getDescription()); ?></div>
<div class='details'>
- <?php if(Pbs_Acl::checkRight('csai')): ?>
- <label>ConfigID</label>
- <div class='item'><?php echo $this->escape($config->getID()); ?></div>
- <?php endif; ?>
- <label>Created</label>
- <div class='item'><?php echo $this->escape($config->getCreated()); ?></div>
+ <?php if(count($this->configlist[$bootos->getID()])==0)
+ echo "There are no Config's to display." ?>
+ <?php foreach ($this->configlist[$bootos->getID()] as $k => $config): ?>
+ <div class='element'>
+ <div class='number'>
+ <div class='smallnumber'>Config</div>
+ <?php echo $k+1; ?>
+ </div>
+ <div class='content'>
+ <div class='actions'>
+ <?php if(((Pbs_Acl::checkRight('ce') || Pbs_Acl::checkRight('cem')) && $this->type == 'group') || ($this->type == 'own' && Pbs_Acl::checkRight('ceo'))): ?>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'config',
+ 'action' => 'showconfig',
+ 'type' => $this->type,
+ 'configID' => $config->getID()
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/show.png' alt='Show Config'/></a>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'config',
+ 'action' => 'editconfig',
+ 'type' => $this->type,
+ 'configID' => $config->getID(),
+
+ 'page' => $this->page
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/edit.png' alt='Edit Config'/></a>
+ <?php endif; ?>
+ <?php if((Pbs_Acl::checkRight('cd') && $this->type == 'group') || ($this->type == 'own' && Pbs_Acl::checkRight('cdo'))): ?>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'config',
+ 'action' => 'deleteconfig',
+ 'type' => $this->type,
+ 'configID' => $config->getID(),
+ 'page' => $this->page
+ ),
+ 'default',
+ true) ?>"><img src='/media/img/delete.png' alt='Delete Config'/></a>
+ <?php endif; ?>
+ </div>
+ <div class='title'><?php echo $this->escape($config->getTitle()); ?></div>
+ <div class='subtitle'><?php echo $this->escape($config->getDescription()) ?></div>
+ <div class='details'>
+ <?php if(Pbs_Acl::checkRight('csai')): ?>
+ <label>ConfigID</label>
+ <div class='item'><?php echo $this->escape($config->getID()); ?></div>
+ <label>Visible</label>
+ <div class='item'><?php echo $this->escape($config->getVisible()); ?></div>
+ <?php endif; ?>
+ <label>Created</label>
+ <div class='item'><?php echo $this->escape($config->getCreated()); ?></div>
+ </div>
+ </div>
+ <div class='clear'></div>
+ </div>
+ <?php endforeach; ?>
+
</div>
</div>
<div class='clear'></div>
</div>
<?php endforeach; ?>
+
</div>
<?php echo $this->pagination; ?>
diff --git a/application/modules/user/views/scripts/config/showconfig.phtml b/application/modules/user/views/scripts/config/showconfig.phtml
new file mode 100644
index 0000000..95e5742
--- /dev/null
+++ b/application/modules/user/views/scripts/config/showconfig.phtml
@@ -0,0 +1,84 @@
+<h1>Details of
+<?php echo $this->config; if(Pbs_Acl::checkRight('csui')): ?><img class='helpericon' src='/media/img/bulb_off.png' /><?php endif; ?></h1>
+<?php if($this->notification != ''){echo $this->notification;} ?>
+
+<?php if(Pbs_Acl::checkRight('csui')): ?>
+<div class='helper infobox'>Here you the the available Configs which you can select to your BootOS. The Config does some modification to the selected BootOs after the start. In Most Cases you don't have to change here anything.</div>
+<?php endif; ?>
+
+<h2>Userlist</h2>
+
+<?php if((Pbs_Acl::checkRight('cc') && $this->type == 'group') || (Pbs_Acl::checkRight('cco') && $this->type == 'own')): ?>
+<?php echo $this->formButton('adduser', 'Add User', array(
+ 'onclick' => 'self.location="/user/config/adduser/configID/'.$this->configID.'/type/'.$this->type.'"',
+ 'class' => 'addbutton'))?>
+<?php endif;?>
+
+<div class='listelement'>
+ <?php if(count($this->userlist)==0)
+ echo "There are no Users to display." ?>
+ <?php foreach ($this->userlist as $k => $user): ?>
+ <div class='element'>
+ <div class='number'>
+ <div class='smallnumber'>User</div>
+ <?php echo $k+1 ?>
+ </div>
+ <div class='content'>
+ <div class='actions'>
+ <?php if(((Pbs_Acl::checkRight('ce') || Pbs_Acl::checkRight('cem')) && $this->type == 'group') || ($this->type == 'own' && Pbs_Acl::checkRight('ceo'))): ?>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'config',
+ 'action' => 'edituser',
+ 'type' => $this->type,
+ 'bootosuserID' => $user->getID(),
+ 'configID' => $this->configID
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/edit.png' alt='Edit User'/></a>
+ <a href="<?php echo $this->url(
+ array(
+ 'module' => 'user',
+ 'controller' => 'config',
+ 'action' => 'deleteuser',
+ 'type' => $this->type,
+ 'bootosuserID' => $user->getID(),
+ 'configID' => $this->configID
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/delete.png' alt='Delete User'/></a>
+ <?php endif; ?>
+ </div>
+ <?php if(!Pbs_Acl::checkRight('csai')){
+ $user->setHometypeID(preg_replace("!^\[[0-9]+\]\s!",'',$user->getHometypeID()));
+ } ?>
+ <div class='details'>
+ <label>Login-Name</label>
+ <div class='item'><?= $user->getLogin() ?></div>
+ <label>Password</label>
+ <div class='item'><?= $user->getPassword() ?></div>
+ <label>Hometype</label>
+ <div class='item'><?= $user->getHometypeID() ?></div>
+ <label>Homepath</label>
+ <div class='item'><?= $user->getHomepath() ?></div>
+
+ </div>
+ </div>
+ <div class='clear'></div>
+ </div>
+ <?php endforeach; ?>
+
+</div>
+
+<script type="text/javascript">
+$(document).ready(function(){
+ if($('.element').find('.dispnone').length >= 1){
+ $(this).find('.title').css('cursor','pointer');
+
+ $('.title').click(function(){
+ $(this).siblings('.dispnone').toggle();
+ });
+ }
+});
+</script>
diff --git a/library/Pbs/NewConfig.php b/library/Pbs/NewConfig.php
new file mode 100644
index 0000000..993a0f1
--- /dev/null
+++ b/library/Pbs/NewConfig.php
@@ -0,0 +1,70 @@
+<?php
+/*
+ * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
+ * This program is free software distributed under the GPL version 2.
+ * See http://gpl.openslx.org/
+ *
+ * If you have any feedback please consult http://feedback.openslx.org/ and
+ * send your suggestions, praise, or complaints to feedback@openslx.org
+ *
+ * General information about OpenSLX can be found at http://openslx.org/
+ */
+
+class Pbs_NewConfig{
+
+ public function createDefaultConfig(Application_Model_BootOs $bootos){
+
+ if($bootos == null)
+ return;
+
+ $config = new Application_Model_Config();
+ $configMapper = new Application_Model_ConfigMapper();
+ $bootosuser = new Application_Model_BootOsUser();
+ $bootosuserkiosk = new Application_Model_BootOsUser();
+ $bootosuserMapper = new Application_Model_BootOsUserMapper();
+
+ try{
+
+ $config->setTitle('Default')
+ ->setDescription('This is the default Config for Bootos: '.$bootos->getTitle())
+ ->setGroupID($bootos->getGroupID())
+ ->setVisible('1')
+ ->setCreated(time())
+ ->setBootosID($bootos->getID());
+
+ $configID = $configMapper->save($config);
+
+ $bootosuser->setConfigID($configID)
+ ->setLogin('%username%')
+ ->setPassword('%password%')
+ ->setHomepath('/home/%username%')
+ ->setHometypeID('0');
+
+ $bootosuserMapper->save($bootosuser);
+
+ $bootosuserkiosk->setConfigID($configID)
+ ->setLogin('kiosk')
+ ->setPassword('kiosk')
+ ->setHomepath('/home/kiosk')
+ ->setHometypeID('0');
+
+ $bootosuserMapper->save($bootosuserkiosk);
+
+ }catch(Zend_Exception $e){
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+
+
+
+ }
+
+ public function parseConfig($bootosID){
+ $configpath = "../resources/bootos/".$bootosID."/config/";
+ //Do something...
+
+ }
+}
+
+?>
diff --git a/setup/pbs-newdata.sql b/setup/pbs-newdata.sql
index ebe5d15..59b9e9e 100644
--- a/setup/pbs-newdata.sql
+++ b/setup/pbs-newdata.sql
@@ -2,11 +2,11 @@ USE ##pbs##;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- Adding person test2//test
-INSERT INTO `pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`) VALUES
-(2, 'Herr', 'Test 2', 'Test 2', 'Teststr,', '5', 'Testburg', '1337', NULL, '1299612370', 'test2', NULL, '4207acba08cadccc397e2302a55b339a', 'f21ee663b17bcefc6868694dffda602a');
+INSERT INTO `pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`, `loginpassword`) VALUES
+(2, 'Herr', 'Test 2', 'Test 2', 'Teststr,', '5', 'Testburg', '1337', NULL, '1299612370', 'test2', NULL, '4207acba08cadccc397e2302a55b339a', 'f21ee663b17bcefc6868694dffda602a', '$6$v66WvVJA$4wmqSpCv0bMSf8aWtS');
-- Adding person test3//test
-INSERT INTO `pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`) VALUES
-(3, 'Herr', 'Test 3', 'Test 3', 'Teststr,', '5', 'Testburg', '1337', NULL, '1299612370', 'test3', NULL, '4207acba08cadccc397e2302a55b339a', 'f21ee663b17bcefc6868694dffda602a');
+INSERT INTO `pbs_person` (`personID`, `title`, `name`, `firstname`, `street`, `housenumber`, `city`, `postalcode`, `logindate`, `registerdate`, `email`, `login`, `password`, `password_salt`, `loginpassword`) VALUES
+(3, 'Herr', 'Test 3', 'Test 3', 'Teststr,', '5', 'Testburg', '1337', NULL, '1299612370', 'test3', NULL, '4207acba08cadccc397e2302a55b339a', 'f21ee663b17bcefc6868694dffda602a', '$6$v66WvVJA$4wmqSpCv0bMSf8aWtS');
-- Adding group
INSERT INTO `pbs_group` (`groupID` ,`title` ,`description`)VALUES
diff --git a/setup/pbs.sql b/setup/pbs.sql
index 39ef83c..1cac013 100644
--- a/setup/pbs.sql
+++ b/setup/pbs.sql
@@ -81,6 +81,7 @@ CREATE TABLE IF NOT EXISTS `pbs_person` (
`login` varchar(30) COLLATE utf8_unicode_ci,
`password` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`password_salt` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
+ `loginpassword` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`suspended` tinyint(1) NOT NULL,
PRIMARY KEY (`personID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;