Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh committed Jun 14, 2017
2 parents 132939e + a8802bb commit 2be92f4
Show file tree
Hide file tree
Showing 17 changed files with 634 additions and 54 deletions.
3 changes: 1 addition & 2 deletions front/phone_line.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Session::checkCentralAccess();
$phoneline = new PluginXivoPhone_Line();
if (isset($_POST["add"])) {
$phoneline->check(-1, CREATE,$_POST);
$phoneline->check(-1, CREATE, $_POST);

if (isset($_POST["phones_id"]) && ($_POST["phones_id"] > 0)
&& isset($_POST["plugin_xivo_lines_id"]) && ($_POST["plugin_xivo_lines_id"] > 0)) {
Expand All @@ -15,4 +15,3 @@
}

Html::displayErrorAndDie('Lost');
?>
2 changes: 1 addition & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function plugin_xivo_uninstall() {
}
}
}
return true ;
return true;
}

function plugin_xivo_getAddSearchOptions($itemtype) {
Expand Down
48 changes: 24 additions & 24 deletions inc/apiclient.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,34 @@ function status() {
$line_id = is_array($line) ? end($line['items'])['id'] : false;

return [
__('Api access', 'xivo') => !empty($this->auth_token),
__('Api access', 'xivo')
=> !empty($this->auth_token),
__('Get phone devices', 'xivo')." (confd.devices.read)"
=> is_array($device),
__('Get single device', 'xivo')." (confd.devices.#.read)"
=> is_array($this->getSingleDevice($device_id, [
'query' => [
'limit' => 1
]
])) && is_array($this->getSingleDeviceLines($device_id, [
'query' => [
'limit' => 1
]
])),
=> is_array($this->getSingleDevice($device_id, [
'query' => [
'limit' => 1
]
])) && is_array($this->getSingleDeviceLines($device_id, [
'query' => [
'limit' => 1
]
])),
__('Get lines', 'xivo')." (confd.lines.read)"
=> is_array($line),
=> is_array($line),
__('Get single line', 'xivo')." (confd.lines.#.read)"
=> is_array($this->getSingleLine($line_id, [
'query' => [
'limit' => 1
]
])),
=> is_array($this->getSingleLine($line_id, [
'query' => [
'limit' => 1
]
])),
__('Get users', 'xivo')." (confd.users.read)"
=> is_array($this->getUsers([
'query' => [
'limit' => 1
]
])),
=> is_array($this->getUsers([
'query' => [
'limit' => 1
]
] )),
];
}

Expand Down Expand Up @@ -244,7 +245,7 @@ function paginate($function = "Devices") {

$items = array_merge($items, $page['items']);
$offset+= $limit;
} while($offset < $page['total']);
} while ($offset < $page['total']);

return $items;
}
Expand Down Expand Up @@ -303,7 +304,7 @@ function getSingleDeviceLines($id = "") {
return false;
}
$lines = [];
foreach($lines_items as $item) {
foreach ($lines_items as $item) {
$lines[] = $this->getSingleLine($item['line_id']);
}
return $lines;
Expand Down Expand Up @@ -421,7 +422,6 @@ function httpQuery($resource = '', $params = array(), $method = 'GET') {
$data['_http_code'] = $http_code;
}


return $data;
}

Expand Down
11 changes: 5 additions & 6 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static function showForConfig(Config $config,
if ($canedit) {
echo Html::hidden('config_class', ['value' => __CLASS__]);
echo Html::hidden('config_context', ['value' => 'plugin:xivo']);
echo Html::submit(_sx('button','Save'), [
echo Html::submit(_sx('button', 'Save'), [
'name' => 'update'
]);
}
Expand All @@ -161,7 +161,7 @@ static function showForConfig(Config $config,

echo "<ul>";
$error = false;
foreach($all_status as $status_label => $status) {
foreach ($all_status as $status_label => $status) {
$color_png = "greenbutton.png";
if (!$status) {
$color_png = "redbutton.png";
Expand Down Expand Up @@ -193,7 +193,7 @@ static function showForConfig(Config $config,
if (isset($data_connect['data']['acls'])) {
echo "<h2>".__("ACL", 'xivo')." (".count($data_connect['data']['acls']).")</h2>";
echo "<ul>";
foreach($data_connect['data']['acls'] as $right) {
foreach ($data_connect['data']['acls'] as $right) {
echo "<li>$right</li>";
}
echo "</ul>";
Expand Down Expand Up @@ -240,9 +240,8 @@ static function showField($options = []) {
$out = "";
$out.= "<div class='xivo_field'>";


// call the field according to its type
switch($options['inputtype']) {
switch ($options['inputtype']) {
default:
case 'text':
$out.= Html::input('fakefield', ['style' => 'display:none;']);
Expand All @@ -252,7 +251,7 @@ static function showField($options = []) {
case 'password':
$out.= "<input type='password' name='fakefield' style='display:none;'>";
$out.= "<input type='password'";
foreach($options['attrs'] as $key => $value) {
foreach ($options['attrs'] as $key => $value) {
$out.= "$key='$value' ";
}
$out.= ">";
Expand Down
8 changes: 4 additions & 4 deletions inc/inventory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static function cronXivoimport(CronTask $crontask) {
}

// import lines
foreach($lines as &$line) {
foreach ($lines as &$line) {
//check if we can retrive the ldap username
$line['glpi_users_id'] = 0;
if (isset($caller_id_list[$line['caller_id_name']])) {
Expand All @@ -80,14 +80,14 @@ static function cronXivoimport(CronTask $crontask) {
$totallines));
}

foreach($devices as $index => &$device) {
foreach ($devices as $index => &$device) {
// remove devices with missing mandatory informations
if (!$xivoconfig['import_empty_sn']
&& empty($device['sn'])) {
unset($devices[$index]);
continue;
}
if (!$xivoconfig['import_empty_mac']
if (!$xivoconfig['import_empty_mac']
&& empty($device['mac'])) {
unset($devices[$index]);
continue;
Expand All @@ -100,7 +100,7 @@ static function cronXivoimport(CronTask $crontask) {

// find possible lines for this device
$device['lines'] = [];
foreach($lines as $line) {
foreach ($lines as $line) {
if ($line['device_id'] == $device['id']) {
$device['lines'][] = $line;
}
Expand Down
5 changes: 1 addition & 4 deletions inc/line.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ function showForm($ID, $options=array()) {
echo "</td>";
echo "</tr>";



// end form html and show controls
$this->showFormButtons($options);

Expand Down Expand Up @@ -356,7 +354,7 @@ static function install(Migration $migration) {

// insert display preferences
$rank = 1;
foreach([2, 4, 7, 8, 6, 5] as $option) {
foreach ([2, 4, 7, 8, 6, 5] as $option) {
$DB->query("REPLACE INTO `glpi_displaypreferences` VALUES (
NULL,
'PluginXivoLine',
Expand All @@ -367,7 +365,6 @@ static function install(Migration $migration) {
$rank++;
}


return true;
}

Expand Down
8 changes: 4 additions & 4 deletions inc/phone.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static function importSingle($device = []) {
'NetworkName__ipaddresses' => ['-1' => $device['ip']],
'_create_children' => true
];
if (count($found_netports) == 0){
if (count($found_netports) == 0) {
$networkport->add($net_input);
} else {
$netport = end($found_netports);
Expand Down Expand Up @@ -145,11 +145,11 @@ static function getFullNetworkPort($phones_id = 0) {
$found_networkports = $networkport_inst->find("`itemtype` = 'Phone'
AND `items_id` = '$phones_id'");

foreach($found_networkports as $networkports_id => &$networkport) {
foreach ($found_networkports as $networkports_id => &$networkport) {
$found_networknames = $networkname_inst->find("`itemtype` = 'NetworkPort'
AND `items_id` = '$networkports_id'");

foreach($found_networknames as $networknames_id => &$networkname) {
foreach ($found_networknames as $networknames_id => &$networkname) {
$found_ipaddresses = $ipaddress_inst->find("`itemtype` = 'NetworkName'
AND `items_id` = '$networknames_id'");

Expand Down Expand Up @@ -178,7 +178,7 @@ static function forceSync($xivo_id = "") {
$device['lines'] = $apiclient->getSingleDeviceLines($xivo_id);

// import lines
foreach($device['lines'] as &$line) {
foreach ($device['lines'] as &$line) {
// add or update assets
$plugin_xivo_lines_id = PluginXivoLine::importSingle($line);
$line['plugin_xivo_lines_id'] = $plugin_xivo_lines_id;
Expand Down
12 changes: 6 additions & 6 deletions inc/phone_line.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class PluginXivoPhone_Line extends CommonDBRelation {
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
switch ($item->getType()) {
case "PluginXivoLine":
$nb = countElementsInTable(self::getTable(), "`plugin_xivo_lines_id` = ".$item->getID()
$nb = countElementsInTable(self::getTable(), "`plugin_xivo_lines_id` = ".$item->getID()
);
return self::createTabEntry(Phone::getTypeName($nb), $nb);
case "Phone":
$nb = countElementsInTable(self::getTable(), "`phones_id` = ".$item->getID()
$nb = countElementsInTable(self::getTable(), "`phones_id` = ".$item->getID()
);
return self::createTabEntry(PluginXivoLine::getTypeName($nb), $nb);
}
Expand Down Expand Up @@ -62,7 +62,7 @@ static function showForLine(PluginXivoLine $line, $withtemplate=0) {
LEFT JOIN `glpi_phones`
ON `glpi_phones`.`id` = `glpi_plugin_xivo_phones_lines`.`phones_id`
WHERE `glpi_plugin_xivo_phones_lines`.`plugin_xivo_lines_id` = $lines_id
".getEntitiesRestrictRequest(" AND","glpi_phones",'','',true). "
".getEntitiesRestrictRequest(" AND", "glpi_phones", '', '', true). "
ORDER BY `glpi_phones`.`name`
";

Expand Down Expand Up @@ -183,7 +183,7 @@ static function showForPhone(Phone $phone, $withtemplate=0) {
LEFT JOIN `glpi_phones`
ON `glpi_phones`.`id` = `glpi_plugin_xivo_phones_lines`.`phones_id`
WHERE `glpi_plugin_xivo_phones_lines`.`phones_id` = $phones_id
".getEntitiesRestrictRequest(" AND","glpi_phones",'','',true). "
".getEntitiesRestrictRequest(" AND", "glpi_phones", '', '', true). "
ORDER BY `glpi_plugin_xivo_lines`.`name`
";

Expand Down Expand Up @@ -285,14 +285,14 @@ static function importAll($phone_lines = [], $phones_id = 0) {
$current_lines = $my_phone_line->find("`phones_id` = $phones_id");

// import all relations
foreach($phone_lines as $phone_line) {
foreach ($phone_lines as $phone_line) {
$phone_line['phones_id'] = $phones_id;
$id = self::importSingle($phone_line);
unset($current_lines[$id]);
}

// remove old lines
foreach($current_lines as $id => $current_line) {
foreach ($current_lines as $id => $current_line) {
$my_phone_line->delete(['id' => $id]);
}
}
Expand Down
Binary file added locales/pt_BR.mo
Binary file not shown.
Loading

0 comments on commit 2be92f4

Please sign in to comment.