public function InsertAfter($afterobjectpos) { $this->position = $afterobjectpos + 1; require_once 'dataobjectserver/application.php'; $application = Application::getinstance(); $sortby['position'] = 'asc'; $positioneditems = $application->GetObjectsByClassName(get_class($this), $sortby); foreach ($positioneditems->Items as $positioneditem) { if ($positioneditem->position > $afterobjectpos) { $positioneditem->position += 1; $positioneditem->Save(); } } $this->Save(); }
public function DeleteMenuItem() { $application = Application::getinstance(); $items = $application->GetObjectsByClassName('menuitem'); $start_at = $this->position; $end_at = $this->position; foreach ($items->Items as $item) { if ($item->parentid == $this->id) { $end_at = $item->position > $end_at ? $item->position : $end_at; $item->Delete(); } } foreach ($items->Items as $item) { if ($item->position > $end_at) { $item->position = $item->position - ($end_at - $start_at + 1); $item->Save(); } } $this->Delete(); }
public function Save() { require_once 'dataobjectserver/application.php'; $application = Application::getinstance(); // piaggregate -> aggregatecolumn -> aggregateitem -> tag // first drill down to the aggregateitem for ($i = 0; $i < sizeof($this->aggregatecolumn); $i++) { $aggregatecolumnjson = $this->aggregatecolumn[$i]; //cast the json object to a well formed php object based on the data object model $aggregatecolumn = $application->GetObjectForJSON($aggregatecolumnjson, 'aggregatecolumn'); for ($j = 0; $j < sizeof($aggregatecolumn->aggregateitem); $j++) { $aggregateitemjson = $aggregatecolumn->aggregateitem[$j]; $aggregateitem = $application->GetObjectForJSON($aggregateitemjson, 'aggregateitem'); $aggregateitem->aggregateitemtype[0] = $application->GetObjectForJSON($aggregateitem->aggregateitemtype[0], 'aggregateitemtype'); $aggregateitem->position = $j + 1; $aggregateitem->Save(); $aggregatecolumn->aggregateitem[$j] = $aggregateitem; } $aggregatecolumn->position = $i + 1; $aggregatecolumn->Save(); $this->aggregatecolumn[$i] = $aggregatecolumn; } objectbase::Save(); }
allow_cross_domain_calls(); echo json_encode($itemdetails); }); $app->post('/executesqlquery/', function () use($app) { require_once 'dataobjectserver/application.php'; $application = Application::getinstance(); //cast the json object to a well formed php object based on the data object model $sqlquery = $app->request->post('sqlquery'); $object = $application->GetObjectById('menuitem', -1, 0); $result = $object->ExecuteSQLQuery($sqlquery); allow_cross_domain_calls(); echo json_encode($result); }); $app->post('/fileupload/', function () use($app) { require_once 'dataobjectserver/application.php'; $application = Application::getinstance(); // the reason why fileupload is not part of the saveitemdetails method is that: // the GetObjectForJSON messes up in the file data bytes $itemdetails = $application->GetObjectById('asset', -1); $itemdetails->Save(); allow_cross_domain_calls(); echo json_encode($itemdetails); }); $app->run(); function allow_cross_domain_calls() { // Allow from any origin if (isset($_SERVER['HTTP_ORIGIN'])) { header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}"); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Max-Age: 86400');
function checkOwnedUpdates() { if (!$this->getRequiresUpdates()) { return true; } $whmcs = Application::getinstance(); $licensedAddons = $this->getLicensedAddons(); foreach ($licensedAddons as $addon) { if ($addon['name'] == 'Support and Updates' && $addon['status'] == 'Active') { if (str_replace('-', '', $whmcs->getReleaseDate()) <= str_replace('-', '', $addon['nextduedate'])) { return true; continue; } continue; } } return false; }