Beispiel #1
0
 /**
  * add group member
  *
  * add member id to group, creating group if it doesn't already exist
  *
  * @param args json params converted into an array
  *             id device id to add to group
  *             name name of group to add
  * @throws none
  * @return array containing result and possible error messages
  */
 public function ajax_addGroupMember($args)
 {
     $data = array();
     try {
         $grp = $this->getDeviceGroup(null, $args['name']);
         if (is_null($grp)) {
             // add new group entry
             $grp = new deviceGroup();
             $grp->db($this->db);
             $grp->id = 0;
             $grp->name = $args['name'];
             $grp->commit();
             $data['id'] = $grp->id;
             $data['name'] = $grp->name;
         }
         // add member to group
         $grp->addMember($args['id']);
     } catch (Exception $e) {
         return array('result' => 'failure', 'error' => $e->getMessage());
     }
     return array('result' => 'success', 'data' => $data);
 }