コード例 #1
0
            $error_array[] = "Please select a category";
        }
    } else {
        // adding new category.
        if (empty($_POST['category_name'])) {
            $error_array[] = "Please enter a category name";
        } else {
            if (!Validation::validate_alpha_numeric($_POST['category_name'], 1)) {
                $error_array[] = "Please enter a valid category name";
            } else {
                if (!empty($_POST['category_name'])) {
                    try {
                        $Links = new Links();
                        $param_array = array('user_id' => $_SESSION['user']['id'], 'category_name' => $_POST['category_name'], 'created' => time(), 'changed' => time());
                        $Links->set_params($param_array);
                        $Links->save_category();
                        $error_array[] = "Category added successfully";
                    } catch (PAException $e) {
                        $error_array[] = $e->message;
                    }
                }
            }
        }
    }
} else {
    if (!empty($_POST['btn_save_link'])) {
        if (empty($_POST['link_categories'])) {
            $error_array[] = "Please select a category";
        }
        if (empty($_POST['title'])) {
            $error_array[] = "Please enter a title for the link";
コード例 #2
0
             $Links->update_category();
             $json_string = '{ "errors" : "List has been updated successfully", "updated_category_id" : ' . $_POST['category_id'] . '}';
         } catch (PAException $e) {
             $json_string = '{ "is_error" : true, "errors" : "List with specified name already exists"}';
         }
         print $json_string;
     }
 } else {
     if (!empty($_POST) && $_POST['form_action'] == 'create_list') {
         $json_string = null;
         if (!empty($_POST['category_name'])) {
             $Links = new Links();
             $Links->user_id = $_SESSION['user']['id'];
             $Links->category_name = $_POST['category_name'];
             try {
                 $category_id = $Links->save_category();
                 $json_string = '{ "errors" : "List has saved successfully", "updated_category_id" : ' . $category_id . '}';
             } catch (PAException $e) {
                 $json_string = '{ "is_error" : true, "errors" : "List with specified name already exists"}';
             }
             print $json_string;
         }
         /**
         * Code for updating the selected links
         */
     } else {
         if (!empty($_POST) && $_POST['form_action'] == 'update_links') {
             $link_count = count($_POST['link_id_updated']);
             $Links = new Links();
             $updated_links_count = 0;
             $Links->user_id = $_SESSION['user']['id'];
コード例 #3
0
 public static function add_default_links($user_id)
 {
     require_once "api/CNNetworkLinks/CNNetworkLinks.php";
     require_once "api/CNLinks/CNLinks.php";
     $network_links = new NetworkLinks();
     $network_owner_id = PA::$network_info->type == MOTHER_NETWORK_TYPE ? SUPER_USER_ID : Network::get_network_owner(PA::$network_info->network_id);
     $condition = array('user_id' => $network_owner_id, 'is_active' => 1);
     $link_categories = $network_links->load_category($condition);
     // load category as set by network operator
     $Links = new Links();
     $error_array = array();
     //providing default links to the user, as set by network operator
     for ($counter = 0; $counter < count($link_categories); $counter++) {
         $param_array = array('category_name' => $link_categories[$counter]->category_name, 'user_id' => $user_id, 'created' => time(), 'changed' => time(), 'is_active' => ACTIVE);
         $Links->set_params($param_array);
         $category_id = $Links->save_category();
         // save network operator category as user's link category
         $network_lists = new NetworkLinks();
         $network_lists->user_id = $network_info->owner_id;
         $condition = array('category_id' => $link_categories[$counter]->category_id, 'is_active' => ACTIVE);
         $list_array = $network_lists->load_link($condition);
         // load list for network operator's category
         for ($i = 0; $i < count($list_array); $i++) {
             $param_array = array('title' => $list_array[$i]->title, 'url' => $list_array[$i]->url, 'category_id' => $category_id, 'created' => time(), 'changed' => time(), 'is_active' => ACTIVE);
             $Links->set_params($param_array);
             $Links->save_link();
             // save network operator list as user's list
         }
     }
 }