/** * Delete something from the ACL. Parameters the same as for addNew(), except the last parameter is not used again * @param string $type It can be 'resource', 'action', 'requester' or 'permission' * @param mixed $what For 'resource', 'action' and 'requester' it should be a string containing the name of the new * element. For 'permission' it should be an associative array containing key-value pairs for each of the types. If no action * has to be defined then it action should be NULL. * @retval false It returns false if you are trying to use it without a database or XML file or if an element can't be found. * @retval true * */ public function deleteACL($type, $what) { if (is_null($this->prefix)) { return false; } if (is_string($what)) { $req = table::findS($this->prefix . "_{$type}s", array($type => $what)); if (!$req) { trigger_error("Can't find {$what} of {$type}"); return false; } $what = $req->id; } $element = rolisz::table($this->prefix . "_{$type}s", $what); $element->delete(); if ($type != 'permissions') { $req = table::findS($this->prefix . '_permissions', array($type => $what)); if (!is_array($req)) { $req = array($req); } $size = sizeOf(req); for ($i = 0; $i < $size; $i++) { $req[$i]->delete(); } } }
<?php include '../rolisz.php'; $form1 = new form(array('id' => 'test1')); $form1->input('text', array('name' => 'user', 'pattern' => '.{6,}'))->input('password', array('name' => 'pass', 'pattern' => '[0-9]{3,5}'))->input('textarea', array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt'))); $form2 = new form(array('id' => 'test2', 'action' => 'testare')); $form2->input('text', array('name' => 'user'))->input('password', array('name' => 'pass'))->input('radio', array('name' => 'radio'))->textarea(array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt'))); //var_dump($form1->getString()); //var_dump($form2->getString()); //$form1->show(); //$form2->show(); //$form1->validate(); $posts = rolisz::connect('MySQLi', 'localhost', 'root', '', 'rolisz'); $posts = rolisz::table('posts', 1); $form3 = new form(array('id' => 'test3'), $posts); $form3->input('text', array('name' => 'author', 'pattern' => function ($arg) { if ($arg == 'rolisz') { return true; } return false; })); $form3->removeInput('title'); var_dump($form3->getString()); $form3->show(); if (isset($_GET['send'])) { $form3->validate(); }