本文整理匯總了PHP中Languages::get_code方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::get_code方法的具體用法?PHP Languages::get_code怎麽用?PHP Languages::get_code使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Languages
的用法示例。
在下文中一共展示了Languages::get_code方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create_client
/**
* Create a new client
*
* Executes the creation of new client in the IspConfig control panel
* Note in order to not fail this command, it must meet the following requirements:
*
* - The customer must be registered in the db.
* - The customer has bought a hosting plan
*
* @param array $task Must be a valid task
* @return integer RemoteClientId
* @access public
*/
public function create_client(array $task)
{
$clientId = "";
if (empty($task)) {
throw new Exception('Task empty.', '3000');
}
// Execute a custom event
$this->events()->trigger('panels_create_client_before', __CLASS__, array('task' => $task));
$server = self::getServer($task['orderitem_id'], 'web');
// Connection to the SOAP system
$client = $this->connect($server['server_id']);
if (!$client) {
throw new Exception("There is no way to connect the client with the IspConfig Panel.", "3010");
}
try {
// Get all the customer information
$customer = Customers::getAllInfo($task['customer_id']);
// Get the client id saved previously in the customer information page
$customAttribute = CustomAttributes::getAttribute($task['customer_id'], 'client_id');
// Get the custom ISPConfig attribute set in the customer control panel
if (is_numeric($customAttribute['value'])) {
/**
* Client_id (IspConfig Attribute Set in ShineISP database in the setup of the panel)
* @see Shineisp_Controller_Plugin_SetupcPanelsModules
*/
$clientId = $customAttribute['value'];
$record = $client->client_get($this->getSession(), $clientId);
if ($record == false) {
$clientId = "";
}
}
// Customer Profile
$record['company_name'] = $customer['company'];
$record['contact_name'] = $customer['firstname'] . " " . $customer['lastname'];
$record['customer_no'] = $customer['customer_id'];
$record['vat_id'] = $customer['vat'];
$record['email'] = $customer['email'];
$record['street'] = !empty($customer['Addresses'][0]['address']) ? $customer['Addresses'][0]['address'] : "";
$record['zip'] = !empty($customer['Addresses'][0]['code']) ? $customer['Addresses'][0]['code'] : "";
$record['city'] = !empty($customer['Addresses'][0]['city']) ? $customer['Addresses'][0]['city'] : "";
$record['state'] = !empty($customer['Addresses'][0]['area']) ? $customer['Addresses'][0]['area'] : "";
$record['country'] = !empty($customer['Addresses'][0]['Countries']['code']) ? $customer['Addresses'][0]['Countries']['code'] : "";
$record['mobile'] = Contacts::getContact($customer['customer_id'], "Mobile");
$record['fax'] = Contacts::getContact($customer['customer_id'], "Fax");
$record['telephone'] = Contacts::getContact($customer['customer_id']);
// System Configuration
$languagecode = Languages::get_code($customer['language_id']);
$record['language'] = $languagecode;
$record['usertheme'] = "default";
$record['template_master'] = 0;
$record['template_additional'] = "";
$record['created_at'] = date('');
$record['web_php_options'] = "no,fast-cgi,cgi,mod,suphp,php-fpm";
$record['ssh_chroot'] = 'jailkit';
// Get the Json encoded parameters in the task
$parameters = json_decode($task['parameters'], true);
// Match all the ShineISP product system attribute and IspConfig attributes (see below about info)
$retval = self::matchFieldsValues($parameters, $record);
if (is_array($retval)) {
$record = array_merge($record, $retval);
} else {
Shineisp_Commons_Utilities::logs("No hosting attribute parameters have been set in ShineISP. Check the hosting product attributes section.", "ispconfig.log");
}
// Execute the SOAP action
if (!empty($clientId) && is_numeric($clientId)) {
$client->client_update($this->getSession(), $clientId, 1, $record);
} else {
$arrUsernames = array();
$arrUsernames = self::generateUsernames($customer);
// Check if username is available
foreach ($arrUsernames as $username) {
if (!$client->client_get_by_username($this->getSession(), $username)) {
break;
}
}
// Create a random password string
$password = Shineisp_Commons_Utilities::GenerateRandomString();
$record['username'] = $username;
$record['password'] = $password;
// Save the setup in the service setup field
OrdersItems::set_setup($task['orderitem_id'], array('url' => 'http://' . $server['ip'] . ':8080', 'username' => $username, 'password' => $password), "webpanel");
// Adding the client in ISPConfig
$clientId = $client->client_add($this->getSession(), 0, $record);
// Update the custom customer attribute client_id
CustomAttributes::saveElementsValues(array(array('client_id' => $clientId)), $task['customer_id'], "customers");
// Execute a custom event
$this->events()->trigger('panels_create_client_after', __CLASS__, array('task' => $task, 'clientid' => $clientId, 'customerdata' => $record));
//.........這裏部分代碼省略.........