static function addProject($props) { if (!$props) { drupal_set_message(t('Insert requested with empty (filtered) data set'), 'error'); return false; } // sort and process the datetime array structure // pre sql statement. Project::normaliseFormArrays($props); global $user; $txn = db_transaction(); try { $uid = $user->uid; $props['owner_id'] = $uid; //TODO: for now we assume the mentor is the same as creating the project. As long as we have not built //funcitonality to connect mentors to projects, this is a valid assumption $props['mentor_id'] = $uid; if (!isset($props['state'])) { $props['state'] = 'pending'; } //We normalise urls: if they start with http or https we assume the user inserted a full url //otherwise we assume a non-https full url if (isset($props['url']) && $props['url'] && stripos($props['url'], 'http') === FALSE) { $props['url'] = 'http://' . $props['url']; } $result = FALSE; $query = db_insert(tableName(_PROJECT_OBJ))->fields($props); $id = $query->execute(); if ($id) { $result = $id; } else { drupal_set_message(t('We could not add your project'), 'error'); } } catch (Exception $ex) { $txn->rollback(); drupal_set_message(t('We could not add your project. ') . (_DEBUG ? $ex->__toString() : ''), 'error'); } return $result; }