/** * Get list of contacts (IDs) and remove not allowed contacts * @param type $contact_ids */ public function getAllowedContactsIds(array $contact_ids) { $contact_ids = array_map('intval', $contact_ids); if (wa()->getUser()->getRights('contacts', 'edit', true)) { return $contact_ids; } if (!$contact_ids) { return array(); } $m = new waContactModel(); $user_id = wa()->getUser()->getId(); return array_keys($m->select('id')->where("create_contact_id = {$user_id} \n AND id IN(" . implode(',', $contact_ids) . ")")->fetchAll('id')); }
/** * * @return boolean */ public function exists() { if (!$this->id) { return false; } else { $model = new waContactModel(); return !!$model->select('id')->where("id = i:0", array($this->id))->fetch(); } }