Beispiel #1
0
 private function insertContributors($node)
 {
     foreach ($node->contributors as $i => $auth) {
         $auth = (object) $auth;
         $cid = isset($auth->cid) ? $auth->cid : 0;
         $mid = isset($auth->mid) ? $auth->mid : 0;
         if (!$cid && $mid) {
             $mem = node_load($mid);
             if ($mem) {
                 $cid = contributor_create_from_user($mem->muid);
                 if ($cid) {
                     $node->contributors[$i]['cid'] = $cid;
                 }
             }
         }
     }
     $this->insertIndexedChildren($node, $node->contributors, "pubnode_contributors", "cid");
 }
Beispiel #2
0
 /**
  * Insert or update contributor for each revision of an Interviewer
  */
 private function saveAuthorContrib(&$node)
 {
     if (isset($node->author_mid) && $node->author_mid > 0) {
         $member = node_load($node->author_mid);
         if ($member) {
             $muser = user_load($member->muid);
             $contrib = array('capacity' => $node->author_capacity);
             $cid = contributor_create_from_user($muser, $contrib);
             if ($cid) {
                 $node->author_cid = $cid;
             }
         }
     } else {
         if (isset($node->author_cid) && $node->author_cid > 0) {
             $contrib = node_load($node->author_cid);
             $contrib->title = $node->author_name;
             $contrib->capacity = $node->author_capacity;
             node_save($contrib);
         } else {
             // do nothing: must either have a known mid (from form
             // autocompletion on the current submit) or cid (from previous
             // submit) to save any contrib info
         }
     }
 }