示例#1
0
 public static function add(&$data, $userid)
 {
     $res = "Unknown entity";
     switch ($data["assocEntity"]) {
         case "poa":
             break;
         case "area":
             $data["assocEntity"] = "area";
             $res = self::addForRepoArea($data, $userid);
             break;
         default:
             $data["assocEntity"] = "release";
             $res = self::addForRelease($data, $userid);
             break;
     }
     if ($res !== true) {
         if ($res !== false) {
             return $res;
         }
         return "Unknown entity";
     }
     try {
         $contact = new Repository_Model_MetaContact();
         $contact->assocId = $data["assocId"];
         $contact->assocEntity = $data["assocEntity"];
         $contact->externalId = $data["externalId"];
         $contact->contactTypeId = $data["contactTypeId"];
         $contact->firstname = $data["firstname"];
         $contact->lastname = $data["lastname"];
         $contact->email = $data["email"];
         $contact->save();
         $data = $contact;
     } catch (Exception $e) {
         return $e->getMessage();
     }
     return true;
 }
 public function save(Repository_Model_MetaContact $value)
 {
     global $application;
     $data = array();
     if (!isnull($value->getId())) {
         $data['id'] = $value->getId();
     }
     if (!isnull($value->getAssocId())) {
         $data['assocId'] = $value->getAssocId();
     }
     if (!isnull($value->getAssocEntity())) {
         $data['assocEntity'] = $value->getAssocEntity();
     }
     if (!isnull($value->getExternalId())) {
         $data['externalId'] = $value->getExternalId();
     }
     if (!isnull($value->getContactTypeId())) {
         $data['contactTypeId'] = $value->getContactTypeId();
     }
     if (!isnull($value->getFirstname())) {
         $data['firstname'] = $value->getFirstname();
     }
     if (!isnull($value->getLastname())) {
         $data['lastname'] = $value->getLastname();
     }
     if (!isnull($value->getEmail())) {
         $data['email'] = $value->getEmail();
     }
     $q1 = 'id = ?';
     $q2 = $value->id;
     if (null === ($id = $value->id)) {
         unset($data['id']);
         $value->id = $this->getDbTable()->insert($data);
     } else {
         $s = $this->getDbTable()->getAdapter()->quoteInto($q1, $q2);
         $this->getDbTable()->update($data, $s);
     }
 }