/**
  * Creates an instance method on this TenantObject using the given parameters.
  * @param string $name The name used in code to identify this TenantObjectMethod.
  * @param TenantObjectMethodParameter[] $parameters Array of TenantObjectMethodParameter objects representing parameters to this TenantObjectMethod.
  * @param string $codeblob The PHP code that runs when this TenantObjectMethod is executed.
  * @param string $description  Obsolete - do not use
  * @param string[] $namespaceReferences Array of PHP namespaces that should be referenced by this TenantObjectMethod.
  * @return TenantObjectMethod|NULL The newly created TenantObjectMethod, or NULL if the creation operation failed.
  */
 public function CreateInstanceMethod($name, $parameters, $codeblob, $description = null, $namespaceReferences = null)
 {
     global $MySQL;
     $query = "INSERT INTO " . System::$Configuration["Database.TablePrefix"] . "TenantObjectInstanceMethods (method_ObjectID, method_Name, method_Description, method_CodeBlob) VALUES (";
     $query .= $this->ID . ", ";
     $query .= "'" . $MySQL->real_escape_string($name) . "', ";
     $query .= ($description == null ? "NULL" : "'" . $MySQL->real_escape_string($description) . "'") . ", ";
     $query .= "'" . $MySQL->real_escape_string($codeblob) . "'";
     $query .= ")";
     $result = $MySQL->query($query);
     if ($result === false) {
         PhoenixSNS::Log("Database error when trying to create an instance method for the specified tenant object.", array("DatabaseError" => $MySQL->error . " (" . $MySQL->errno . ")", "Query" => $query));
         return false;
     }
     $method = TenantObjectInstanceMethod::GetByID($MySQL->insert_id);
     if (is_array($namespaceReferences)) {
         foreach ($namespaceReferences as $ref) {
             $method->AddNamespaceReference($ref);
         }
     }
     return $method;
 }
Beispiel #2
0
                 $method->CodeBlob = $_POST["method_CodeBlob"];
                 $method->Update();
                 System::Redirect("~/tenant/manage/" . $tenant->URL . "/objects/" . $object->ID);
                 return true;
             }
             $page = new TenantObjectMethodManagementPage();
             $page->CurrentTenant = $tenant;
             $page->CurrentObject = $object;
             $page->CurrentMethod = $method;
             $page->Render();
             break;
         case "instance":
             $page = new TenantObjectMethodManagementPage();
             $page->CurrentTenant = Tenant::GetByURL($path[0]);
             $page->CurrentObject = TenantObject::GetByID($path[2]);
             $page->CurrentMethod = TenantObjectInstanceMethod::GetByID($path[5]);
             $page->Render();
             break;
     }
     break;
 case "":
     $tenant = Tenant::GetByURL($path[0]);
     $object = TenantObject::GetByID($path[2]);
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $count = $_POST["InstanceProperty_NewPropertyCount"];
         for ($i = $count; $i > 0; $i--) {
             $name = $_POST["InstanceProperty_" . $i . "_Name"];
             $dataType = DataType::GetByID($_POST["InstanceProperty_" . $i . "_DataTypeID"]);
             $defaultValue = $_POST["InstanceProperty_" . $i . "_DefaultValue"];
             $object->CreateInstanceProperty(new TenantObjectInstanceProperty($name, $dataType, $defaultValue));
         }