예제 #1
0
 /**
  * Create a service
  * @link     https://apidocs.serverdensity.com/?python#creating-a-service
  * @param    array  $service with all it's attributes.
  * @return   an array that is the device.
  */
 public function create($service, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
         $service['tags'] = $formattedTags['tags'];
     }
     $service = $this->makeJsonReady($service);
     return $this->post('inventory/services/', $service);
 }
예제 #2
0
 /**
  * Create a user
  * @link     https://apidocs.serverdensity.com/#creating-a-user
  * @param    array $user
  * @return   an array with the user that got created
  */
 public function create(array $user, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'user');
         // don't overwrite permission array if user creates his own.
         if (!empty($user['permissions'])) {
             $user['permissions'] = array_merge($user['permissions'], $formattedTags);
         } else {
             $user['permissions'] = $formattedTags;
         }
     }
     $user = $this->makeJsonReady($user);
     return $this->post('users/users/', $user);
 }
예제 #3
0
파일: tag.php 프로젝트: renduples/alibtob
        template($tpl_file);
        exit;
    }
    if ($do == "search" && !empty($_GET['q'])) {
        $conditions[] = "Tag.name like '%" . trim($_GET['q']) . "%'";
    }
    if ($do == "del" && !empty($id)) {
        $tag->del($id);
    }
}
if (isset($_POST['del']) && !empty($_POST['id'])) {
    $tag->del($_POST['id']);
}
if (isset($_POST['save']) && !empty($_POST['data']['tag'])) {
    if (isset($_POST['id'])) {
        $id = intval($_POST['id']);
    }
    if ($id) {
        $tag->save($_POST['data']['tag'], "update", $id);
    } else {
        $tag->save($_POST['data']['tag']);
    }
}
$amount = $tag->findCount(null, $conditions);
$page = new Pages();
$page->setPagenav($amount);
//$joins[] = "LEFT JOIN {$tb_prefix}members m ON m.id=Tag.member_id";
$result = $tag->findAll("Tag.*", $joins, $conditions, "Tag.id DESC ", $page->firstcount, $page->displaypg);
setvar("Items", $result);
setvar("ByPages", $page->getPagenav());
template($tpl_file);