/** * @param string $attributes * @return CustomAttributes */ public static function Parse($attributes) { $ca = new CustomAttributes(); if (empty($attributes)) { return $ca; } $pairs = explode('!sep!', $attributes); foreach ($pairs as $pair) { $nv = explode('=', $pair); $ca->Add($nv[0], $nv[1]); } return $ca; }
/** * Create a custom attribute * @param string $var * @param string $label * @param string $type */ public static function createAttribute($var, $label, $type = "text", $section = "customers", $panel_id = null) { // Check if the attribute exists $attr = self::getAttributeIdByVar($var, $section); if (!empty($attr)) { return false; } $attribute = new CustomAttributes(); $attribute['var'] = $var; $attribute['label'] = $label; $attribute['type'] = $type; $attribute['section'] = $section; $attribute['panel_id'] = $panel_id; return $attribute->trySave(); }
public function GetRow($row) { $attributes = null; if (array_key_exists(ColumnNames::ATTRIBUTE_LIST, $row)) { $attributes = CustomAttributes::Parse($row[ColumnNames::ATTRIBUTE_LIST]); } $formattedRow = array(); foreach ($this->columns as $key => $column) { if ($key == ColumnNames::TOTAL || $key == ColumnNames::TOTAL_TIME) { $this->sum += $row[$key]; $this->sumColumn = $column; } if ($attributes != null && BookedStringHelper::StartsWith($key, 'attribute')) { $id = intval(str_replace('attribute', '', $key)); $attribute = $attributes->Get($id); $formattedRow[] = new ReportAttributeCell($column->GetData($attribute)); } else { $formattedRow[] = new ReportCell($column->GetData($row[$key]), $column->GetChartData($row, $key), $column->GetChartColumnType(), $column->GetChartGroup()); } } return $formattedRow; }
/** * @param int $attributeId * @return null|string */ public function GetAttributeValue($attributeId) { return $this->Attributes->Get($attributeId); }
/** * @param $referenceNumber string * @param $startDate Date * @param $endDate Date * @param $resourceName string * @param $resourceId int * @param $reservationId int * @param $userLevelId int|ReservationUserLevel * @param $title string * @param $description string * @param $scheduleId int * @param $userFirstName string * @param $userLastName string * @param $userId int * @param $userPhone string * @param $userPosition string * @param $userOrganization string * @param $participant_list string * @param $invitee_list string * @param $attribute_list string * @param $preferences string */ public function __construct($referenceNumber = null, $startDate = null, $endDate = null, $resourceName = null, $resourceId = null, $reservationId = null, $userLevelId = null, $title = null, $description = null, $scheduleId = null, $userFirstName = null, $userLastName = null, $userId = null, $userPhone = null, $userOrganization = null, $userPosition = null, $participant_list = null, $invitee_list = null, $attribute_list = null, $preferences = null) { $this->ReferenceNumber = $referenceNumber; $this->StartDate = $startDate; $this->EndDate = $endDate; $this->ResourceName = $resourceName; $this->ResourceId = $resourceId; $this->ReservationId = $reservationId; $this->Title = $title; $this->Description = $description; $this->ScheduleId = $scheduleId; $this->FirstName = $userFirstName; $this->OwnerFirstName = $userFirstName; $this->LastName = $userLastName; $this->OwnerLastName = $userLastName; $this->OwnerPhone = $userPhone; $this->OwnerOrganization = $userOrganization; $this->OwnerPosition = $userPosition; $this->UserId = $userId; $this->UserLevelId = $userLevelId; if (!empty($startDate) && !empty($endDate)) { $this->Date = new DateRange($startDate, $endDate); } if (!empty($participant_list)) { $this->ParticipantIds = explode(',', $participant_list); } if (!empty($invitee_list)) { $this->InviteeIds = explode(',', $invitee_list); } $this->Attributes = CustomAttributes::Parse($attribute_list); $this->UserPreferences = UserPreferences::Parse($preferences); }
public function initAll() { // Get the Zend Event Manager $em = Shineisp_Registry::get('em'); $mainConfigfile = APPLICATION_PATH . "/configs/config.xml"; if (file_exists($mainConfigfile)) { $mainconfig = simplexml_load_file($mainConfigfile); } else { throw new Exception($mainConfigfile . " has been not found"); } if (!count($mainconfig->xpath("/shineisp/modules"))) { $modules = $mainconfig->addChild('modules'); } else { $modules = $mainconfig->xpath("/shineisp/modules"); } $path = PROJECT_PATH . "/library/Shineisp/Plugins" . DIRECTORY_SEPARATOR; // << The last slash is very important in the plugin path // Read all the directory recursivelly and get all the files and folders $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); foreach ($iterator as $filename => $path_object) { $pluginConfigFile = $filename; $info = pathinfo($filename); // Select only the plugins that have a xml configuration file if (!empty($info['extension']) && $info['extension'] == "xml") { // Get the directory of the plugin $PluginPath = $info['dirname']; // Delete the main plugin path $PluginBasePath = str_replace($path, "", $info['dirname']); // Convert the result as array $PluginBasePathArray = explode(DIRECTORY_SEPARATOR, $PluginBasePath); // Create the name of the Plugin class $pluginName = 'Shineisp_Plugins_' . implode("_", $PluginBasePathArray) . '_Main'; // Check if plugins looks good $reflectionClass = new ReflectionClass($pluginName); if (!($reflectionClass->isInstantiable() && $reflectionClass->implementsInterface('Shineisp_Plugins_Interface') && is_callable(array($pluginName, 'events')))) { Shineisp_Commons_Utilities::logs("Skipping not instantiable plugin '" . $pluginName . "'"); continue; } // Initialize $plugin = new $pluginName(); $plugin->events($em); // Check if the Main exists if (file_exists($pluginConfigFile) && is_readable($pluginConfigFile)) { $info = pathinfo($pluginConfigFile); if (!empty($info['extension']) && $info['extension'] == "xml") { if (file_exists($pluginConfigFile)) { $config = simplexml_load_file($pluginConfigFile); // If the config file has been created for the registrar ignore it // because the configuration is delegated to the registrar management if (isset($config->attributes()->type) && "registrars" == (string) $config->attributes()->type) { continue; } $panelName = (string) $config->attributes()->name; $var = (string) $config['var']; // Save the module setup in the config.xml file // Now we are checking if the module is already set in the config.xml file if (!count($mainconfig->xpath("/shineisp/modules/{$var}"))) { // The module is not present, we have to create it $module = $modules[0]->addChild($var); // Now we add the setup date as attribute $module->addAttribute('setup', date('YmdHis')); } else { // The module is present and we get it $module = $mainconfig->xpath("/shineisp/modules/{$var}"); // If the setup date attribute is present skip the module process setup if (!empty($module[0]) && $module[0]->attributes()->setup) { continue; } else { // The setup attribute is not present restart the module setup process $module[0]->addAttribute('setup', date('YmdHis')); } } $help = (string) $config->general->help ? (string) $config->general->help : NULL; $description = (string) $config->general->description ? (string) $config->general->description : NULL; $group_id = SettingsGroups::addGroup($config['name'], $description, $help); if (!empty($config->settings) && $config->settings->children()) { foreach ($config->settings->children() as $node) { $configclass = array(); $arr = $node->attributes(); $var = strtolower($config['var']) . "_" . (string) $arr['var']; $label = (string) $arr['label']; $type = (string) $arr['type']; $description = (string) $arr['description']; if ((string) $arr['configclass']) { $configclass = json_decode((string) $arr['configclass'], true); } if (!empty($var) && !empty($label) && !empty($type)) { SettingsParameters::addParam($label, $description, $var, $type, 'admin', 1, $group_id, $configclass); } } if (!empty($config->customfields)) { foreach ($config->customfields->children() as $node) { $arr = $node->attributes(); $var = (string) $node; $label = (string) $arr['label']; $type = (string) $arr['type']; $section = (string) $arr['section']; // Fetch panel_id from database if (!empty($panelName)) { $Panels = Panels::getAllInfoByName($panelName); } $panel_id = !empty($Panels) && isset($Panels['panel_id']) && $Panels['panel_id'] > 0 ? intval($Panels['panel_id']) : null; if (!empty($var) && !empty($label) && !empty($type)) { CustomAttributes::createAttribute($var, $label, $type, $section, $panel_id); } } } } } $xmlstring = $mainconfig->asXML(); // Prettify and save the xml configuration $dom = new DOMDocument('1.0'); $dom->loadXML($xmlstring); $dom->formatOutput = TRUE; $dom->preserveWhiteSpace = TRUE; $dom->saveXML(); if (!@$dom->save($mainConfigfile)) { throw new Exception("Error on saving the xml file in {$mainConfigfile} <br/>Please check the folder permissions"); } } } } } }
/** * Connect into the remote ISPCONFIG webservice * * Executes the 'login' command on ISPCONFIG's servers, to retrive the session variable * for execute the commands. * * @return string Session variable * @access private */ public function connect($serverId) { $Soapclient = $this->getSoapclient(); // Get parameters saved in the database $endpointlocation = CustomAttributes::getAttributeValue($serverId, "endpointlocation"); $endpointuri = CustomAttributes::getAttributeValue($serverId, "endpointuri"); $username = CustomAttributes::getAttributeValue($serverId, "username"); $password = CustomAttributes::getAttributeValue($serverId, "password"); if (!empty($endpointlocation) && !empty($endpointuri) && !empty($username) && !empty($password)) { $client = new SoapClient(null, array('location' => $endpointlocation, 'uri' => $endpointuri, 'trace' => 1, 'exceptions' => 1)); $this->setSession($client->login($username, $password)); $this->setSoapclient($client); return $client; } return false; }
/** * getForm * Get the customized application form * @return unknown_type */ private function getForm($action) { $form = new Admin_Form_CustomersForm(array('action' => $action, 'method' => 'post')); // Add the customer custom attributes $form = CustomAttributes::getElements($form, "customers"); return $form; }
private function AddCustomAttributes($category, CustomAttributes $attributes, &$formattedRow, $key, ReportColumn $column) { $prefix = $category . 'attribute'; if ($attributes != null && BookedStringHelper::StartsWith($key, $prefix)) { $id = intval(str_replace($prefix, '', $key)); $attribute = $attributes->Get($id); $formattedRow[] = new ReportAttributeCell($column->GetData($attribute)); } }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $request = $this->getRequest(); $id = $this->getRequest()->getParam('server_id'); $this->view->title = $this->translator->translate("Edit Server"); $this->view->description = $this->translator->translate("Edit the server parameters."); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/servers/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/servers/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index'); } // Get our form and validate it $form = $this->getForm('/admin/servers/process', $id); if (!$form->isValid($request->getPost())) { $this->view->form = $form; // Invalid entries return $this->render('applicantform'); // re-render the login form } // Save the data $serverID = Servers::saveAll($form->getValues()); #OrdersItemsServers::removeServer(89, $serverID); // Save the attributes $attributeValues = $form->getSubForm('attributes')->getValues(); CustomAttributes::saveElementsValues($attributeValues, $serverID, "servers"); return $this->_helper->redirector('edit', 'servers', 'admin', array('id' => $id)); }