コード例 #1
0
function arraySearch($needle, $haystack, $arraykey = false)
{
    if (!is_array($haystack)) {
        return false;
    }
    foreach ($haystack as $key => $value) {
        $current_key = $key;
        if ($arraykey) {
            if ($needle == $value[$arraykey]) {
                return $key;
            }
            if (arraySearch($needle, $value[$arraykey]) == true) {
                return $current_key;
            }
        } else {
            if ($needle == $value) {
                return $value;
            }
            if (arraySearch($needle, $value) == true) {
                return $current_key;
            }
        }
    }
    return false;
}
コード例 #2
0
function _showCapabilities()
{
    global $Logs;
    $data = admin_getAllCapabWithRights();
    $roles = admin_getAllRoles();
    ?>
	<h3>Edit capabilities</h3>
	<form action="?show=capa" name="fc_capabilities" method="post">
		<table border="1">
			<thead>
			<tr>
				<td>Capability</td>
				<td>Description</td>
				<?php 
    foreach ($roles as $role) {
        ?>
					<td>
						<strong><?php 
        print $role['name'];
        ?>
</strong><br />
						<?php 
        $parent = arraySearch($role['parentid'], $roles, 'id');
        ?>
					
						<?php 
        if ($parent !== false) {
            print "(" . $roles[$parent]['name'] . ")";
        }
        ?>
					</td>
				<?php 
    }
    ?>
				<!-- td>Odstranit</td-->
			</tr>
			</thead>
	
	<?php 
    foreach ($data as $cap) {
        ?>
		
			<tr>
				<th><?php 
        print $cap['name'];
        ?>
</th>
				<td><?php 
        print $cap['description'];
        ?>
</td>
				<?php 
        foreach ($roles as $role) {
            $checkName = "caprole_" . $cap['id'] . "_" . $role['id'];
            $checked = in_array($role['id'], $cap['aRoles']) ? 'checked="checked"' : "";
            ?>
					<td>
						<input <?php 
            print $checked;
            ?>
 type="checkbox" name="<?php 
            print $checkName;
            ?>
" />
					</td>
				<?php 
        }
        ?>
				
				<!-- td>
					<a href="<?php 
        getUrl('admin');
        ?>
?action=deleteCap&id=<?php 
        print $cap['id'];
        ?>
">odstranit</a>
				</td-->
			</tr>
	<?php 
    }
    ?>
		</table>
		<input type="submit" value="Save" name="update_capab" />
	</form>
<?php 
}
コード例 #3
0
 private function checkForm()
 {
     $regDate = '/[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{4}/';
     /// format 1.12.2020
     $regPsc = '/[0-9]{3}+\\s?[0-9]{1,2}+/';
     /// neprihlaseny uzivatel bez uctu ///
     if (!$this->CFG->isAuthenticated()) {
         $this->oCheck->check('dod_nazev', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_ulice', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_mesto', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_psc', "preg_match('{$regPsc}',\$test)", getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_ico', 'is_numeric($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_dic', 'strlen($test)==0 || is_numeric($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_web', 'strlen($test)==0 || $this->checkUrl($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_email', 'strlen($test)==0 || $this->checkEmail($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_tel', 'strlen($test)==0 || $this->checkPhone($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_fax', 'strlen($test)==0 || $this->checkPhone($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('dod_dph', '$test=="' . CD_FAKT_PLATCE_DPH_ANO . '" || $test=="' . CD_FAKT_PLATCE_DPH_NE . '"', getString('Pole Název je poviné!', 'faktura'));
     } else {
         $this->oCheck->check('dod_id', 'is_numeric($test)', getString('Nebyly zaslány údaje o dodavateli!', 'faktura'));
         $dodEx = arraySearch($this->aPost['dod_id'], $this->CFG->getUserData('dodavatele'), 'id') !== false ? true : false;
         $this->oCheck->check('dod_id', '$test==true', getString('Daný dodavatel neexistuje!', 'faktura'), $dodEx);
     }
     /// prihlaseny uzivate a existujici odberatel ///
     if (isset($this->aPost['odb_id']) && $this->CFG->isAuthenticated()) {
         $odbEx = count(self::getOdberatel($this->aPost['odb_id'], $this->CFG->getUseraccountId())) ? true : false;
         $this->oCheck->check('odb_id', '$test==true', getString('Daný odběratel neexistuje!', 'faktura'), $odbEx);
     } else {
         $this->oCheck->check('odb_nazev', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_ulice', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_mesto', 'strlen($test)>0', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_psc', "preg_match('{$regPsc}',\$test)", getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_ico', 'strlen($test)==0 || is_numeric($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_dic', 'strlen($test)==0 || is_numeric($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_email', 'strlen($test)==0 || $this->checkEmail($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('odb_tel', 'strlen($test)==0 || $this->checkPhone($test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('splatnost', "preg_match('/(\\d)+/',\$test)", getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('datum_vystaveni', 'preg_match("' . $regDate . '",$test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('datum_splatnosti', 'preg_match("' . $regDate . '",$test)', getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('cislo_faktury', "preg_match('/(\\d)+/',\$test)", getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('variabilni_symbol', "preg_match('/(\\d)*/',\$test)", getString('Pole Název je poviné!', 'faktura'));
         $this->oCheck->check('vystavil_tel', 'strlen($test)==0 || $this->checkPhone($test)', getString('Pole Název je poviné!', 'faktura'));
     }
     /// chyby ve formulari ///
     if (!$this->oCheck->isValid()) {
         $err = new stdClass();
         foreach ($this->oCheck->getErrors() as $k => $error) {
             $err->{$k} = $error;
         }
         /// errors pro zobrazeni u jednotlivych formularovych polozek ///
         $this->addVar($err, 'form_errors');
         $this->logs->addLog($this->oCheck->getErrors());
         return false;
     }
     return true;
 }
コード例 #4
0
                    $newsort = $k * 10;
                    $Logs->addLog($newsort, 'newsort');
                    $DB->update('core_roles', array('sort', $newsort, false), array('id', '=', $sort['id']));
                }
            }
            $aAlerts[] = "Role was updated.";
        } catch (cException $e) {
            $msg = $e->getDbMessageError(__METHOD__ . '(line:' . __LINE__ . ')', $query);
            $aErrors[] = $msg;
            cLogsDb::addFileLog($msg);
        }
    }
}
/// end of POST data sent ///
$roles = admin_getAllRoles();
if (($id = arraySearch($_GET['id'], $roles, 'id')) !== false) {
    $Role = $roles[$id];
} else {
    header("Location: " . getUrl() . "admin");
}
$Logs->addLog($roles, "admin_getAllRoles");
###########################################################################################
##################################### code to print #######################################
foreach ($aErrors as $error) {
    print "<div class='error'>{$error}</div>";
}
foreach ($aAlerts as $alert) {
    print "<div class='alert'>{$alert}</div>";
}
?>
<h3>Edit role</h3>
コード例 #5
0
                }
            }
            if (!$DB->update('core_users', $aVals, array('id', '=', $_POST['userid']))) {
                throw new cException("Some error during update operation!");
            }
            $aAlerts[] = "User was updated.";
        } catch (cException $e) {
            $msg = $e->getDbMessageError(__METHOD__ . '(line:' . __LINE__ . ')');
            $aErrors[] = $msg;
            cLogsDb::addFileLog($msg);
        }
    }
}
/// end of POST data sent ///
$users = admin_getAllUsers();
if (($id = arraySearch($_GET['id'], $users, 'id')) !== false) {
    $User = $users[$id];
} else {
    header("Location: " . getUrl() . "admin");
}
$roles = admin_getAllRoles();
$Logs->addLog($users, "admin_getAllUsers");
###########################################################################################
##################################### code to print #######################################
foreach ($aErrors as $error) {
    print "<div class='error'>{$error}</div>";
}
foreach ($aAlerts as $alert) {
    print "<div class='alert'>{$alert}</div>";
}
$name = $User['name'];