Пример #1
0
 public static function details($_model = null)
 {
     $module = static::$module;
     $modeler = $module::model()->modeler;
     $_model = $_model == null ? forward_static_call_array(array($modeler, 'model'), array()) : forward_static_call_array(array($modeler, 'model'), array($_model));
     $_o = (object) null;
     $_o->size = 'large';
     $_o->icon_type = 'menu-icon';
     $_o->icon_background = 'atom-icon-background';
     $_o->menu = (object) null;
     $_o->menu->items = self::modelOperationsMenuItems();
     $_o->head = 'Package Details';
     $_o->body = array('');
     $_o->body[] = (object) array('js' => 'registry.setContext({card:\'cards/package/details\',collection:\'packages\',node:\'' . $_model->id . '\'});');
     $_o->body[] = CardKitHTML::sublineBlock('Name');
     $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/name', array($_model->id)), $_model->name, 'settings');
     $_o->body[] = CardKitHTML::sublineBlock('Package Sequode');
     $_o->body[] = $_model->sequode_id != 0 && \Sequode\Application\Modules\Sequode\Modeler::exists($_model->sequode_id, 'id') ? DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/package/packageSequode', array($_model->id)), \Sequode\Application\Modules\Sequode\Modeler::model()->name, 'settings') : ModuleForm::render(static::$registry_key, 'packageSequode')[0];
     $_o->body[] = CardKitHTML::sublineBlock('Package Token');
     $_o->body[] = $_model->token;
     $_o->body[] = CardKitHTML::sublineBlock('<a target="_blank" href="/source/' . $_model->token . '">Download</a>');
     $_o->body[] = CardKit::nextInCollection((object) array('model_id' => $_model->id, 'details_route' => 'cards/package/details'));
     if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) {
         $_o->body[] = CardKitHTML::modelId($_model);
     }
     return $_o;
 }
Пример #2
0
 public static function source($_model_token)
 {
     if (!(\Sequode\Application\Modules\Package\Modeler::exists($_model_token, 'token') && \Sequode\Application\Modules\Sequode\Modeler::exists(\Sequode\Application\Modules\Package\Modeler::model()->sequode_id, 'id') && (\Sequode\Application\Modules\Account\Authority::isOwner(\Sequode\Application\Modules\Package\Modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()) && (\Sequode\Application\Modules\Account\Authority::isOwner(\Sequode\Application\Modules\Sequode\Modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()))) {
         return;
     }
     header('Content-Type: text/plain', true);
     header('Content-Disposition: attachment; filename="' . \Sequode\Application\Modules\Package\Modeler::model()->name . '.class.php"');
     echo \Sequode\Application\Modules\Package\Operations::download();
 }
Пример #3
0
 public static function updateName($sequode_model_id = 0, $name = '')
 {
     if (!(\Sequode\Application\Modules\Sequode\Modeler::exists($sequode_model_id, 'id') && \Sequode\Application\Modules\Account\Authority::canEdit())) {
         return;
     }
     $object = (object) null;
     $object->Success = false;
     $name = trim(str_replace('-', '_', str_replace(' ', '_', urldecode($name))));
     if (strlen($name) == 0) {
         $object->Error = 'Name cannot be empty';
     } elseif (!eregi("^([A-Za-z0-9_])*\$", $name)) {
         $object->Error = 'Name can be alphanumeric and contain spaces only';
     } elseif (!\Sequode\Application\Modules\Account\Authority::canRename($name)) {
         $object->Error = 'Name already used';
     }
     if (!isset($object->Error)) {
         \Sequode\Application\Modules\Sequode\Modeler::exists($sequode_model_id, 'id');
         \Sequode\Application\Modules\Sequode\Operations::updateName($name);
         $object->Success = true;
     }
     echo json_encode($object);
     return;
 }