/** !!
  * This takes the data from the form and checks it
  * for the purposes of creating an entity, then 
  * syncs the data to the entity.
  * @param $request_data  The data to be added to the entity
  */
 private function handleEntity($request_data)
 {
     $this->err = '';
     // $data = $this->filter($request_data);
     $data = array();
     // use the profile_fields object for some processing
     foreach ($this->profilefields as $i => $d) {
         $k = $d['name'];
         switch ($d['type']) {
             case 'dateselect':
                 $day = @$request_data[$k . '_day'];
                 $month = @$request_data[$k . '_month'];
                 $year = @$request_data[$k . '_year'];
                 if ($day && $month && $year) {
                     $data[$k . '_day'] = $day;
                     $data[$k . '_month'] = $month;
                     $data[$k . '_year'] = $year;
                     $data[$k] = sprintf("%04d-%02d-%02d", $year, $month, $day);
                 }
                 break;
             default:
                 if (!empty($request_data[$k])) {
                     $data[$k] = $request_data[$k];
                 }
                 break;
         }
     }
     $data['type'] = !empty($this->entity_type) ? $this->entity_type : $request_data['type'];
     $data['name'] = $request_data['groupname'];
     $data['group_id'] = $this->gid;
     if (empty($data['name'])) {
         $this->err .= __("Please supply a name.") . "<br/>";
     }
     if (empty($this->err)) {
         // sync it
         TypedGroupEntity::sync($data);
     }
 }
 private function handleEdit($request_data)
 {
     $this->err = '';
     $data = $this->filter($request_data);
     // handle photo upload
     if (!empty($_FILES)) {
         foreach ($_FILES as $field_name => $file_info) {
             if (!empty($file_info['name'])) {
                 $uploadfile = PA::$upload_path . basename($_FILES[$field_name]['name']);
                 $myUploadobj = new FileUploader();
                 $file = $myUploadobj->upload_file(PA::$upload_path, $field_name, true, true, 'image');
                 if ($file == false) {
                     $msg = $myUploadobj->error;
                     $this->err .= sprintf(__('Please upload a valid Game Image in %s'), ucfirst($field_name)) . "<br/>";
                     continue;
                 } else {
                     Storage::link($file, array("role" => "game_image", "user" => PA::$login_user->user_id));
                     $data[$field_name] = $file;
                 }
             } else {
                 if (!empty($this->entity->attributes[$field_name])) {
                     $data[$field_name] = $this->entity->attributes[$field_name];
                 }
             }
         }
     }
     if (empty($data['name'])) {
         $this->err .= __("Please supply a name.") . "<br/>";
     }
     if (empty($this->err)) {
         // sync it
         TypedGroupEntity::sync($data);
     }
 }
Example #3
0
 public static function save_new_org($ccid, $uid, $title, $body, $picture, $group_tags, $group_category, $access = 0, $reg = 0, $is_mod = 0, $header_image = "", $header_image_action = NULL, $display_header_image = NULL, $extra = NULL, $group_type = 'organization')
 {
     // save a new group
     $groupID = self::save_new_group($ccid, $uid, $title, $body, $picture, $group_tags, $group_category, $access, $reg, $is_mod, $header_image, $header_image_action, $display_header_image, $extra);
     // change it's type to an org
     TypedGroupEntity::sync(array('type' => $group_type, 'name' => $title, 'group_id' => $groupID));
     return $groupID;
 }