public function handlePOST_savePoints($request_data) { global $app; $msg = null; $error = false; $form_data = $request_data['form_data']; $form_data['created'] = strtotime($form_data['created']); $form_data['updated'] = strtotime($form_data['updated']); $ent_name = array_shift($form_data); $media_data = $request_data['media']; foreach ($media_data as $key => $value) { $form_data["media_{$key}"] = $value; } try { $entity = new PointsEntity(); $entity->entity_service = 'internal'; $entity->entity_type = 'points'; $entity->entity_id = $form_data['entity_id']; $entity->entity_name = $ent_name; $entity->attributes = $form_data; PointsEntity::sync($entity); $msg = __("Points data sucessfully stored"); } catch (PAException $e) { $error = true; $msg = $e->message; } $ent = (array) PointsEntity::load($form_data['entity_id']); $items = $this->build_list_of_items(array($ent)); unset($request_data['form_data']); unset($request_data['media']); unset($request_data['action']); unset($request_data['module']); /* $this->view_mode = 'edit'; $this->sub_title = __('Edit Points'); $this->set_inner_template('edit_points_form.tpl.php'); $this->inner_HTML = $this->generate_inner_html(array('sub_title' => $this->sub_title, 'category' => $this->category, 'categories' => $this->categories, 'user_id' => $this->user_id, 'url_base' => $this->url_base, 'item' => $items[0], 'error' => $error, 'message' => $msg, 'fid' => $this->fid ) ); */ /* $request_data['message'] = $msg; $this->view_mode = 'list'; $this->set_inner_template('center_inner_public.tpl.php'); $this->showPointsDirectory($request_data); */ $app->redirect($this->url_base . "&msg=" . urlencode($msg)); }
public static function users_points($uid) { $user_points = array(); $r = Dal::query("SELECT *, attribute_value AS user_id\n FROM {entities} AS E\n LEFT OUTER JOIN {entityattributes} AS EA ON E.id = EA.id\n WHERE entity_service='internal' AND entity_type='points'\n AND attribute_name='user_id'\n AND attribute_value=?", array($uid)); while ($points = Dal::row_assoc($r)) { $user_points[] = PointsEntity::load($points['entity_id']); } return $user_points; }