public static function search($_i, $limit = 100) { $modeler = static::$modeler; $_i->position = urldecode($_i->position); //$_i->field = urldecode($_i->field); if (!in_array($_i->position, array('=%', '%=%', '%=', '='))) { $_i->position = '=%'; } // if(!in_array($_i->field, array('name','ip_address'))){ $_i->field = 'name'; //} if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $where = array(); if (isset($shared_where)) { $where[] = $shared_where; } $where[] = array('field' => $_i->field, 'operator' => $_i->position, 'value' => $_i->search); $_model = new $modeler::$model(); $_model->getAll($where, 'id,name', $limit); $results = $_model->all; unset($_model); } else { $where = array(); if (isset($shared_where)) { $where[] = $shared_where; } $where[] = array('field' => $_i->field, 'operator' => $_i->position, 'value' => $_i->search); $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id); $_model = new $modeler::$model(); $_model->getAll($where, 'id,name', $limit); $results = $_model->all; unset($_model); } return $results; }
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; }
public static function login($json = null) { $module = static::$module; $dialogs = $module::model()->components->dialogs; $dialog = forward_static_call_array(array($dialogs, __FUNCTION__), array()); if (!SessionStore::is($dialog->session_store_key)) { return; } $xhr_cards = $module::model()->xhr->cards; $operations_xhr = $module::model()->xhr->operations; $operations = $module::model()->operations; $modeler = $module::model()->modeler; if ($json != null) { $input = json_decode(rawurldecode($json)); if (isset($input->reset)) { SessionStore::set($dialog->session_store_key, $dialog->session_store_setup); return forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } } $dialog_store = SessionStore::get($dialog->session_store_key); $dialog_step = $dialog->steps[$dialog_store->step]; if (isset($dialog_step->prep) && $dialog_step->prep == true) { if (isset($dialog_step->required_members)) { foreach ($dialog_step->required_members as $m) { if (!isset($input->{$m})) { return; } } } switch ($dialog_store->step) { case 0: if (($modeler::exists(rawurldecode($input->login), 'email') || $modeler::exists(rawurldecode($input->login), 'name')) && \Sequode\Application\Modules\Account\Authority::isActive($modeler::model())) { $dialog_store->prep->user_id = $modeler::model()->id; SessionStore::set($dialog->session_store_key, $dialog_store); } else { $error = 1; } break; case 1: if ($modeler::exists($dialog_store->prep->user_id, 'id') && \Sequode\Application\Modules\Account\Authority::isPassword(rawurldecode($input->secret), $modeler::model())) { $_a = array($modeler::model()); } else { $error = 2; } break; } } if (isset($dialog_step->operation) && is_array($_a)) { if (!forward_static_call_array(array($operations, $dialog_step->operation), $_a)) { $error = 3; } } if (!isset($error)) { $dialog_store->step++; SessionStore::set($dialog->session_store_key, $dialog_store); $console_module = ModuleRegistry::model()['Console']; return intval($dialog_store->step) == 2 ? forward_static_call_array(array($console_module::model()->routes['http'], 'js'), array(false)) : forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } }
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(); }
public static function details($_model_id = 0, $dom_id = 'CardsContainer') { $module = static::$module; $modeler = $module::model()->modeler; if (!($modeler::exists($_model_id, 'id') && (\Sequode\Application\Modules\Account\Authority::isOwner($modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()))) { return; } return CardKitJS::placeCard(ModuleCard::render($module::$registry_key, __FUNCTION__), $dom_id); }
public static function name($_model_id, $dom_id) { $module = static::$module; $modeler = $module::model()->modeler; if (!($modeler::exists($_model_id, 'id') && (\Sequode\Application\Modules\Account\Authority::isOwner($modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()))) { return; } return DOMElementKitJS::placeForm(ModuleForm::render($module::$registry_key, __FUNCTION__), $dom_id); }
public static function search($_i, $limit = 100) { $module = static::$module; $modeler = $module::model()->modeler; if ($_i->coded == 0 && $_i->sequenced == 0) { return array(); } elseif ($_i->coded == 1 && $_i->sequenced == 0) { $shared_where = array('field' => 'usage_type', 'operator' => '=', 'value' => '0'); } elseif ($_i->coded == 0 && $_i->sequenced == 1) { $shared_where = array('field' => 'usage_type', 'operator' => '=', 'value' => '1'); } $_i->position = urldecode($_i->position); if (!in_array($_i->position, array('=%', '%=%', '%=', '='))) { $_i->position = '=%'; } if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $where = array(); if (isset($shared_where)) { $where[] = $shared_where; } $where[] = array('field' => 'name', 'operator' => $_i->position, 'value' => $_i->search); $_model = new $modeler::$model(); $_model->getAll($where, 'id,name', $limit); $results = $_model->all; unset($_model); } else { $results = array(); if ($_i->my_sequodes == 1) { $where = array(); if (isset($shared_where)) { $where[] = $shared_where; } $where[] = array('field' => 'name', 'operator' => $_i->position, 'value' => $_i->search); $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id); $_model = new $modeler::$model(); $_model->getAll($where, 'id,name', $limit); $results = array_merge($results, $_model->all); unset($_model); } if ($_i->shared_sequodes == 1) { $where = array(); if (isset($shared_where)) { $where[] = $shared_where; } $where[] = array('field' => 'name', 'operator' => $_i->position, 'value' => $_i->search); $where[] = array('field' => 'owner_id', 'operator' => '!=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id); $where[] = array('field' => 'shared', 'operator' => '=', 'value' => '1'); $_model = new $modeler::$model(); $_model->getAll($where, 'id,name', $limit); $results = array_merge($results, $_model->all); unset($_model); } } return $results; }
public static function delete($_model_id) { $module = static::$module; $modeler = $module::model()->modeler; $operations = $module::model()->operations; $xhr_cards = $module::model()->xhr->cards; if (!($modeler::exists($_model_id, 'id') && (\Sequode\Application\Modules\Account\Authority::isOwner($modeler::model()) || \Sequode\Application\Modules\Account\Authority::isSystemOwner()))) { return; } forward_static_call_array(array($operations, __FUNCTION__), array()); $js = array(); $js[] = forward_static_call_array(array($xhr_cards, 'my'), array()); return implode(' ', $js); }
public static function details() { $module = static::$module; $modeler = $module::model()->modeler; $operations = $module::model()->operations; $_model = forward_static_call_array(array($modeler, 'model'), array()); $_o = (object) null; $_o->head = 'Account Detail'; $_o->icon_type = 'menu-icon'; $_o->icon_background = 'user-icon-background'; $_o->body[] = CardKitHTML::sublineBlock('Email'); $_o->body[] = $_model->email; if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $_o->body[] = CardKitHTML::modelId($_model); } return $_o; }
public static function main($key = null) { $module = static::$module; $modeler = $module::model()->modeler; $_model = new $modeler::$model(); if ($key == null) { if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $where = array(); $_model->getAll($where, 'id, process_description_node'); $nodes = array(); foreach ($_model->all as $object) { $nodes[] = '"' . $object->id . '":' . $object->process_description_node; } } else { $nodes = array(); $where = array(); $where[] = array('field' => 'owner_id', 'operator' => '!=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id); $where[] = array('field' => 'shared', 'operator' => '=', 'value' => '1'); $_model->getAll($where, 'id, process_description_node'); foreach ($_model->all as $object) { $nodes[] = '"' . $object->id . '":' . $object->process_description_node; } $where = array(); $where[] = array('field' => 'owner_id', 'operator' => '=', 'value' => \Sequode\Application\Modules\Account\Modeler::model()->id); $_model->getAll($where, 'id, process_description_node'); foreach ($_model->all as $object) { $nodes[] = '"' . $object->id . '":' . $object->process_description_node; } } echo '{'; echo "\n"; if (0 < count($nodes)) { echo implode(",\n", $nodes); } echo "\n"; echo '}'; return; } elseif ($modeler::exists($key, 'id') && \Sequode\Application\Modules\Account\Authority::canView()) { echo $modeler::model()->process_description_node; return; } else { echo '{}'; return; } }
public static function details($_model = null) { $module = static::$module; $modeler = $module::model()->modeler; $_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 = 'user-icon-background'; $_o->menu = (object) null; $_o->menu->items = self::modelOperationsMenuItems(); $_o->head = 'User Detail'; $_o->body = array(''); $_o->body[] = CardKitHTML::sublineBlock('Name'); $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/user/updateName', array($modeler::model()->id)), $modeler::model()->name, 'settings'); $_o->body[] = CardKitHTML::sublineBlock('Password'); $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/user/updatePassword', array($modeler::model()->id)), 'Set Password', 'settings'); $_o->body[] = CardKitHTML::sublineBlock('Role'); \Sequode\Application\Modules\Role\Modeler::exists($modeler::model()->role_id, 'id'); $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/user/updateRole', array($modeler::model()->id)), \Sequode\Application\Modules\Role\Modeler::model()->name, 'settings'); $_o->body[] = CardKitHTML::sublineBlock('Active Status'); $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/user/updateActive', array($modeler::model()->id)), $modeler::model()->active == 1 ? 'Active' : 'Suspended', 'settings'); $_o->body[] = CardKitHTML::sublineBlock('Sign Up Date'); $_o->body[] = date('g:ia \\o\\n l jS F Y', $modeler::model()->sign_up_date); $_o->body[] = CardKitHTML::sublineBlock('Allowed Sequode Count'); $_o->body[] = $modeler::model()->allowed_sequode_count; $_o->body[] = CardKitHTML::sublineBlock('Favorite Sequodes'); $_o->body[] = $modeler::model()->sequode_favorites; $_o->body[] = CardKitHTML::sublineBlock('Email'); $_o->body[] = $modeler::model()->email; $_o->body[] = CardKit::ownedItemsCollectionTile('Sequode', 'Sequodes Created : ', $modeler::model()); $_o->body[] = CardKit::ownedItemsCollectionTile('Package', 'Packages Created : ', $modeler::model()); $_o->body[] = CardKit::ownedItemsCollectionTile('Token', 'Tokens Created : ', $modeler::model()); $_o->body[] = CardKit::nextInCollection((object) array('model_id' => $modeler::model()->id, 'details_route' => 'cards/user/details')); if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $_o->body[] = CardKitHTML::modelId($modeler::model()); } return $_o; }
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 = 'Token Details'; $_o->body = array(''); $_o->body[] = (object) array('js' => 'registry.setContext({card:\'cards/token/details\',collection:\'tokens\',node:\'' . $_model->id . '\'});'); $_o->body[] = CardKitHTML::sublineBlock('Name'); $_o->body[] = DOMElementKitJS::loadComponentHere(DOMElementKitJS::xhrCallObject('forms/token/name', array($_model->id)), $_model->name, 'settings'); $_o->body[] = CardKitHTML::sublineBlock('Token'); $_o->body[] = $_model->token; $_o->body[] = CardKit::nextInCollection((object) array('model_id' => $_model->id, 'details_route' => 'cards/token/details')); if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $_o->body[] = CardKitHTML::modelId($_model); } return $_o; }
public static function updateEmail($json = null) { $module = static::$module; $dialogs = $module::model()->components->dialogs; $dialog = forward_static_call_array(array($dialogs, __FUNCTION__), array()); if (!SessionStore::is($dialog->session_store_key)) { return; } $xhr_cards = $module::model()->xhr->cards; $operations = $module::model()->operations; $modeler = $module::model()->modeler; if ($json != null) { $input = json_decode(rawurldecode($json)); if (isset($input->reset)) { SessionStore::set($dialog->session_store_key, $dialog->session_store_setup); return forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } } $dialog_store = SessionStore::get($dialog->session_store_key); $dialog_step = $dialog->steps[$dialog_store->step]; if (isset($dialog_step->prep) && $dialog_step->prep == true) { if (isset($dialog_step->required_members)) { foreach ($dialog_step->required_members as $m) { if (!isset($input->{$m})) { return; } } } switch ($dialog_store->step) { case 0: if (!$modeler::exists(rawurldecode($input->email), 'email') && \Sequode\Application\Modules\Account\Authority::isAnEmailAddress(rawurldecode($input->email))) { $dialog_store->prep->new_email = rawurldecode($input->email); $dialog_store->prep->token = Hashes::generateHash(); SessionStore::set($dialog->session_store_key, $dialog_store); $hooks = array("searchStrs" => array('#TOKEN#'), "subjectStrs" => array($dialog_store->prep->token)); Email::systemSend($dialog_store->prep->new_email, 'Verify your email address with sequode.com', EmailContent::render('activation.txt', $hooks)); } else { $error = true; } break; case 1: if ($dialog_store->prep->token == rawurldecode($input->token)) { $_a = array($dialog_store->prep->new_email); } else { $error = true; } break; } } if (isset($dialog_step->operation) && is_array($_a)) { if (!forward_static_call_array(array($operations, $dialog_step->operation), $_a)) { $error = true; } } if (!isset($error)) { $dialog_store->step++; SessionStore::set($dialog->session_store_key, $dialog_store); return forward_static_call_array(array($xhr_cards, __FUNCTION__), array()); } }
public static function selectPalette($json) { $module = static::$module; $modeler = $module::model()->modeler; $_o = json_decode(stripslashes($json)); if (!is_object($_o) || (trim($_o->palette) == '' || empty(trim($_o->palette)))) { SessionStore::set('palette', false); } else { switch ($_o->palette) { case 'sequode_search': case 'sequode_favorites': SessionStore::set('palette', $_o->palette); break; default: if ($modeler::exists($_o->palette, 'id') && \Sequode\Application\Modules\Account\Authority::canView()) { SessionStore::set('palette', $_o->palette); } break; } } $js[] = DOMElementKitJS::fetchCollection('palette'); return implode(' ', $js); }
public static function updateActive($_model_id, $json) { $module = static::$module; $modeler = $module::model()->modeler; $operations = $module::model()->operations; $xhr_cards = $module::model()->xhr->cards; $input = json_decode(rawurldecode($json)); if (!(\Sequode\Application\Modules\Account\Authority::isSystemOwner() && $modeler::exists($_model_id, 'id'))) { return; } $operations::updateActive($input->active); return $xhr_cards::details($modeler::model()->id); }
public static function internalForms($_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 = 'sequode-icon-background'; $_o->menu = (object) null; $_o->menu->items = self::modelOperationsMenuItems(); $_o->head = $_model->name; $sequence = json_decode($_model->sequence); foreach ($sequence as $loop_sequence_key => $loop_model_id) { $_o->body[] = ModuleCard::render($module::$registry_key, 'internalPositionForms', array($loop_sequence_key)); } if (\Sequode\Application\Modules\Account\Authority::isSystemOwner()) { $_o->body[] = CardKitHTML::modelId($_model); } return $_o; }
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; }