Пример #1
0
 /**
  * Adds contact to a category.
  *
  * @param int|string $category_id Category's simple numeric or system string key (app_id)
  * @throws waException
  */
 public function addToCategory($category_id)
 {
     if (!$this->id) {
         throw new waException('Contact not saved!');
     }
     if (!is_numeric($category_id)) {
         $category_model = new waContactCategoryModel();
         $category = $category_model->getBySystemId($category_id);
         $category_id = $category['id'];
     }
     $contact_categories_model = new waContactCategoriesModel();
     if (!$contact_categories_model->inCategory($this->id, $category_id)) {
         $contact_categories_model->add($this->id, $category_id);
     }
 }