Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mike42 committed Dec 11, 2014
1 parent 8281de0 commit 9c31d29
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Model_Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ private function make_controller(Model_Entity $entity) {
$str .= "\tpublic static function update(" . implode(",", $pkfields_defaults) . ") {\n";
$str .= "\t\t/* Check permission */\n";
$str .= "\t\t\$role = session::getRole();\n";
$str .= "\t\tif(!isset(Core::\$permission[\$role]['" . $entity -> table -> name . "']['update']) || count(Core::\$permission[\$role]['" . $table -> name . "']['update']) == 0) {\n";
$str .= "\t\tif(!isset(Core::\$permission[\$role]['" . $entity -> table -> name . "']['update']) || count(Core::\$permission[\$role]['" . $entity -> table -> name . "']['update']) == 0) {\n";
$str .= "\t\t\treturn array('error' => 'You do not have permission to do that', 'code' => '403');\n";
$str .= "\t\t}\n\n";
$str .= "\t\t/* Load ". $entity -> table -> name . " */\n";
Expand Down Expand Up @@ -632,24 +632,16 @@ private function make_controller(Model_Entity $entity) {
$str .= "\t\t\treturn array('error' => 'Failed to update row', 'code' => '500');\n";
$str .= "\t\t}\n";
$str .= "\t}\n\n";

/* End file */
$str .= "}\n?>";

file_put_contents($this -> base . "/lib/Controller/" . $entity -> table -> name . "_Controller.php", $str);
echo $str;
include($this -> base . "/lib/Controller/" . $entity -> table -> name . "_Controller.php");
return;

// Delete
// $str .= "\tpublic static function delete(" . implode(",", $pkfields_defaults) . ") {\n";
// $str .= "\t\t/* Check permission */\n";
// $str .= "\t\t\$role = session::getRole();\n";
// $str .= "\t\tif(!isset(Core::\$permission[\$role]['" . $table -> name . "']['delete']) || Core::\$permission[\$role]['" . $table -> name . "']['delete'] != true) {\n";
// $str .= "\t\t\treturn array('error' => 'You do not have permission to do that', 'code' => '403');\n";
// $str .= "\t\t}\n\n";
$str .= "\tpublic static function delete(" . implode(",", $pkfields_defaults) . ") {\n";
$str .= "\t\t/* Check permission */\n";
$str .= "\t\t\$role = session::getRole();\n";
$str .= "\t\tif(!isset(Core::\$permission[\$role]['" . $entity -> table -> name . "']['delete']) || Core::\$permission[\$role]['" . $entity -> table -> name . "']['delete'] != true) {\n";
$str .= "\t\t\treturn array('error' => 'You do not have permission to do that', 'code' => '403');\n";
$str .= "\t\t}\n\n";

// $str .= "\t\t/* Load ". $table -> name . " */\n";
$str .= "\t\t/* Load ". $entity -> table -> name . " */\n";
// $str .= "\t\t\$". $table -> name . " = " . $table -> name . "_Model::get(" . implode(",", $pkfields) . ");\n";
// $str .= "\t\tif(!\$".$table -> name . ") {\n";
// $str .= "\t\t\treturn array('error' => '" . $table -> name . " not found', 'code' => '404');\n";
Expand All @@ -671,8 +663,16 @@ private function make_controller(Model_Entity $entity) {
// $str .= "\t\t} catch(Exception \$e) {\n";
// $str .= "\t\t\treturn array('error' => 'Failed to delete', 'code' => '500');\n";
// $str .= "\t\t}\n";
// $str .= "\t}\n";
// $str .= "\n";
$str .= "\t}\n";
$str .= "\n";

/* End file */
$str .= "}\n?>";

file_put_contents($this -> base . "/lib/Controller/" . $entity -> table -> name . "_Controller.php", $str);
echo $str;
include($this -> base . "/lib/Controller/" . $entity -> table -> name . "_Controller.php");
return;

// List all
// $str .= "\tpublic static function list_all(\$page = 1, \$itemspp = 20) {\n";
Expand Down

0 comments on commit 9c31d29

Please sign in to comment.